feat(devices): fleet migration posture report (#3244) - #3264
Open
ToddHebebrand wants to merge 2 commits into
Open
feat(devices): fleet migration posture report (#3244)#3264ToddHebebrand wants to merge 2 commits into
ToddHebebrand wants to merge 2 commits into
Conversation
Deploying breeze with
|
| Latest commit: |
7fc9889
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://537c649a.breeze-9te.pages.dev |
| Branch Preview URL: | https://feat-3244-fleet-posture-repo.breeze-9te.pages.dev |
Two aggregate queries over devices.management_posture (detections via CROSS JOIN LATERAL; coverage denominators separately, no lateral join) behind GET /devices/management-posture/summary and /devices, plus the Fleet Posture web page, CSV export, orphaned remote-access callout, docs, and the mixed-fixture integration test. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Progress chips now PARTITION the fleet from fresh counts (stale-clean no longer reads as verified-clean; both/Breeze-only derive from freshDetectedDevices). - Drill-down pins the org whose count it explains (orgId param) so All-organizations mode cannot mix orgs under one heading. - Best-effort remoteAccess fetch: rejection no longer sinks the main report; missing findings surface an explicit note. - Orphaned-RA callout restricted to RMM-bundled survivors (ScreenConnect, Splashtop) instead of every RA detection. - categoryFromHash own-property check (#toString no longer wedges page). - fetchSummary out-of-order guard; drill-down load-more errors keep loaded rows and offer retry. - Extracted shared buildDeviceScope (posture + stats routes). - Hoisted web posture category constants to lib/postureCategories.ts. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ToddHebebrand
force-pushed
the
feat/3244-fleet-posture-report
branch
from
August 8, 2026 15:23
e921153 to
7fc9889
Compare
Collaborator
Author
|
Review run: Findings: 10 raised → 8 fixed in 7fc9889; 2 deliberately deferred:
Tests: all single-fork, package-local vitest —
Status: review-clean (0 outstanding findings), rebased onto latest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3244 (epic #3249).
Surfaces the management-posture detection Breeze already collects (
agent/internal/mgmtdetect/→devices.management_posturejsonb) as a fleet-level migration/decommission report. Surfacing only: no agent changes, no new tables/columns — the jsonb stays the single source of truth.Spec:
docs/superpowers/specs/onboarding-signup/2026-08-08-fleet-migration-posture-report-design.md· Plan:docs/superpowers/plans/open/2026-08-08-fleet-migration-posture-report.md(both on the #3250 docs branch).API
services/managementPostureReport.ts— two aggregate queries, per the plan's critical note:CROSS JOIN LATERAL jsonb_array_elements(...),count(DISTINCT devices.id)per (org, product, status), plus a fresh-countFILTERoncollectedAt.totalDevices,neverScanned(postureIS NULL),stale,scannedNoneDetected(empty array OR absent key),detectedDevices,freshDetectedDevices.GROUP BYwith aLEFT JOIN LATERAL: that collapses never-scanned / category-absent / empty-array into one(NULL, NULL)group, making a never-scanned device read as verified-clean — the exact failure that strands endpoints in Phase 6 of a migration.categoryis validated against the ingest enum (MANAGEMENT_POSTURE_CATEGORIES, now exported fromroutes/agents/schemas.tsas the single source of truth) and rides a bind param with an explicit::textcast — never string interpolation.routes/devices/posture.ts—GET /devices/management-posture/summary(orgId?,category?=rmm,stalenessDays?=7) andGET /devices/management-posture/devices(product,category?,status?, pagination). Scoping mirrorsGET /devices/stats:authMiddleware+requireScope+DEVICES_READ,auth.orgCondition, 403 on inaccessible?orgId, site-allowlist narrowing (empty allowlist ⇒ empty report), decommissioned + ephemeral devices excluded. Mounted beforecoreRoutesso/management-posture/*isn't eaten by the/:idmatcher.Web
components/devices/FleetPostureReport.tsx+pages/devices/posture.astro+ sidebar entry (Reporting → Fleet Posture, gated ondevices:read). Org narrowing rides the global org selector (/devices/*isorg-or-all;fetchWithAuthinjectsorgId).fresh of totalon every row; stale/never-scanned cards); a bare zero is never rendered — zero detections with unknown/stale devices shows an explicit amber caveat.remoteAccesssummary fetch — ScreenConnect/Splashtop survive their RMM's uninstall).toCsv+downloadBlob(injection-neutralized), for customer-facing migration evidence.window.location.hashper the repo's URL-state convention.fleetPosture.*(devices ns) +nav.fleetPostureadded to all 7 locales with real translations; all four i18n guard suites pass.Tests
services/managementPostureReport.test.ts(unit, mockeddb.execute): asserts two separate queries (lateral join in detections only, none in coverage), scope propagation, assembly, numeric coercion, orphan-detection throw, category validation.routes/devices/posture.test.ts(unit): defaults, category 400 (incl. SQL-injection-shaped input), inaccessible-org 403, org/site narrowing, empty-allowlist short-circuit, pagination.services/managementPostureReport.integration.test.ts(real Postgres, the load-bearing one): one org seeded with all four populations at once — never-scanned, stale-with-detection, fresh empty-array, fresh absent-key, fresh-detected, duplicate-product, decommissioned, plus a second partner's org. Asserts the partitionneverScanned + stale + freshClean + freshDetected == totalDevices, empty-array/absent-key land inscannedNoneDetected(notneverScanned), duplicate product counts once,active/installed/unknownkept separate,fresh <= total, org/partner scoping, drill-down, staleness-window boundary. Registered invitest.integration.config.ts(and excluded from the unit runner). A single-population fixture passes against the broken one-query form — this fixture is what actually guards the design.components/devices/FleetPostureReport.test.tsx: render, zero-caveat, orphan callout, drill-down fetch, error state.devicesis already registered andmanagement_postureis alreadyexcludedOpen.Deviations from the plan (flagged, not silent)
deleted_at IS NULL;deviceshas no such column — used the repo's actual liveness convention fromGET /devices/stats(status != 'decommissioned' AND is_ephemeral = false).allowedSiteIds; adding a free-form site dropdown would grow the API surface beyond the spec. Can follow as a small increment if wanted.org_idindex; partner-wide roll-up is an on-demand full scan). Needs a one-off measurement on a seeded stack before/after merge; happy to record numbers on [API][Web] Fleet migration/decommission report — Management Posture already detects 11 competing RMMs and nothing consumes it #3244 from an environment with a DB.apps/docs/.../migration/toolkit.mdxonly exists on the unmerged docs(migration): RMM-to-Breeze migration guides and toolkit #3250 docs branch, not onmain— cannot be edited from this PR. Should be a follow-up commit on docs(migration): RMM-to-Breeze migration guides and toolkit #3250 (or after it merges).features/management-posture.mdx(on main) is updated here with the fleet view + both endpoints.Verification
vitest run(single-fork): service unit 10/10, route unit 10/10, agentssecurity.test.ts+ devicesstats.test.ts12/12, web component 5/5, i18n guards + sidebar structural + no-silent-mutations 182/182 — all green.tsc --noEmit: clean forapps/apiandapps/web. (astro checkcannot run locally — Node 20 vs Astro's >=22.12 — the new 13-line.astropage mirrorscompare.astro; CI covers it.)it.runIf(DATABASE_URL)) elsewhere.🤖 Generated with Claude Code