Extract patrol intelligence runtime owner

This commit is contained in:
rcourtman
2026-03-21 15:04:31 +00:00
parent d1f05f873e
commit 72f0596500
9 changed files with 957 additions and 766 deletions
@@ -106,7 +106,7 @@ Own canonical runtime payload shapes between backend and frontend.
4. Route unified resource sensitivity, routing, and `aiSafeSummary` payload changes through `internal/api/resources.go`, `internal/api/contract_test.go`, and the canonical frontend resource consumer proofs together; resource governance metadata must not ship as an API-only or frontend-only heuristic
5. Route unified-resource action, lifecycle, and export audit reads through `internal/api/activity_audit_handlers.go`, `internal/api/router_routes_licensing.go`, and `internal/api/contract_test.go` together so the control-plane execution trail stays on a governed API contract instead of a store-only shape
6. Route dedicated unified-resource timeline and facet-bundle reads through `frontend-modern/src/api/resources.ts`, `internal/api/resources.go`, and `internal/api/contract_test.go` together so the backend facet contract and the frontend client stay aligned on one timeline-first surface, while capability and relationship detail stays backend-owned for AI correlation and change detection
7. Route canonical AI intelligence summary and resource-intelligence reads through `frontend-modern/src/api/ai.ts`, `frontend-modern/src/stores/aiIntelligence.ts`, `frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx`, `frontend-modern/src/pages/AIIntelligence.tsx`, `internal/api/ai_handlers.go`, and `internal/api/contract_test.go` together so the summary card, store state, route shell, and backend payload stay aligned on one governed surface, including the canonical recent-changes slice
7. Route canonical AI intelligence summary and resource-intelligence reads through `frontend-modern/src/api/ai.ts`, `frontend-modern/src/stores/aiIntelligence.ts`, `frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts`, `frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx`, `frontend-modern/src/pages/AIIntelligence.tsx`, `internal/api/ai_handlers.go`, and `internal/api/contract_test.go` together so the summary card, runtime hook, store state, route shell, and backend payload stay aligned on one governed surface, including the canonical recent-changes slice
while keeping the learning counters backend-only coverage, so the summary page keeps Patrol health and findings primary and renders timeline, correlation, and policy-posture data as secondary investigation context rather than as a separate headline product metric
and the shared `frontend-modern/src/components/Infrastructure/ResourceChangeSummary.tsx` card, so canonical recent-change timelines stay rendered through one governed frontend card instead of separate page-local list loops
and the shared `frontend-modern/src/utils/resourceChangePresentation.ts` formatter used by the summary page and resource drawer, so canonical change wording does not drift across surfaces
@@ -316,6 +316,15 @@ and the summary-ordering helper in `frontend-modern/src/features/alerts/types.ts
must stay shared across alert timeline surfaces instead of rebuilding
page-local event summaries or bespoke incident-card markup.
Feature-owned route surfaces under `frontend-modern/src/features/` must also
keep their shell/runtime split explicit once a subsystem grows real transport
or polling lifecycle. The Patrol feature is the current reference shape:
`frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx` stays the
render shell while `frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts`
owns the runtime state machine. Shared shell governance should reinforce that
pattern instead of letting feature render surfaces re-accumulate API and timer
orchestration inline.
Shared primitive consumers that split status-dot tone and status-text tone
must now keep both values routed through the same exported presentation helper.
Feature cards such as RAID status may not call shadow local aliases that drift
@@ -22,20 +22,21 @@ Patrol-specific presentation helpers.
## Canonical Files
1. `frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx`
2. `frontend-modern/src/pages/AIIntelligence.tsx`
3. `frontend-modern/src/stores/aiIntelligence.ts`
4. `frontend-modern/src/types/aiIntelligence.ts`
5. `frontend-modern/src/components/AI/FindingsPanel.tsx`
6. `frontend-modern/src/components/Brand/PulsePatrolLogo.tsx`
7. `frontend-modern/src/components/patrol/`
8. `frontend-modern/src/utils/aiFindingPresentation.ts`
9. `frontend-modern/src/utils/approvalRiskPresentation.ts`
10. `frontend-modern/src/utils/findingAlertIdentity.ts`
11. `frontend-modern/src/utils/patrolEmptyStatePresentation.ts`
12. `frontend-modern/src/utils/patrolFormat.ts`
13. `frontend-modern/src/utils/patrolRunPresentation.ts`
14. `frontend-modern/src/utils/patrolSummaryPresentation.ts`
15. `frontend-modern/src/utils/textPresentation.ts`
2. `frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts`
3. `frontend-modern/src/pages/AIIntelligence.tsx`
4. `frontend-modern/src/stores/aiIntelligence.ts`
5. `frontend-modern/src/types/aiIntelligence.ts`
6. `frontend-modern/src/components/AI/FindingsPanel.tsx`
7. `frontend-modern/src/components/Brand/PulsePatrolLogo.tsx`
8. `frontend-modern/src/components/patrol/`
9. `frontend-modern/src/utils/aiFindingPresentation.ts`
10. `frontend-modern/src/utils/approvalRiskPresentation.ts`
11. `frontend-modern/src/utils/findingAlertIdentity.ts`
12. `frontend-modern/src/utils/patrolEmptyStatePresentation.ts`
13. `frontend-modern/src/utils/patrolFormat.ts`
14. `frontend-modern/src/utils/patrolRunPresentation.ts`
15. `frontend-modern/src/utils/patrolSummaryPresentation.ts`
16. `frontend-modern/src/utils/textPresentation.ts`
## Shared Boundaries
@@ -43,7 +44,7 @@ Patrol-specific presentation helpers.
## Extension Points
1. Add or change Patrol page orchestration through `frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx`, keep `frontend-modern/src/pages/AIIntelligence.tsx` as the route shell, and update `frontend-modern/src/stores/aiIntelligence.ts` together
1. Add or change Patrol page orchestration through `frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts`, keep `frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx` as the feature render shell, keep `frontend-modern/src/pages/AIIntelligence.tsx` as the route shell, and update `frontend-modern/src/stores/aiIntelligence.ts` together
2. Add or change Patrol findings, approvals, investigation, or run-history presentation through `frontend-modern/src/components/AI/FindingsPanel.tsx` and `frontend-modern/src/components/patrol/`
3. Keep Patrol and chat identifier-label presentation aligned through the shared `frontend-modern/src/utils/textPresentation.ts`
4. Keep Patrol and chat stream-matching / mention dedupe aligned through the shared `frontend-modern/src/utils/chatIdentifiers.ts`
@@ -74,6 +75,13 @@ thin shell that delegates to the feature-owned
`frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx`, so Patrol
runtime state and presentation no longer accumulate directly in the route
component itself.
The feature surface now also keeps the same shell/runtime split internally:
`frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx` owns render
composition and Patrol page presentation, while
`frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts` owns Patrol
state, transport, polling, and effect lifecycle. The render shell must not
re-accumulate Patrol API calls, timer orchestration, or store refresh flow
inline.
Patrol finding state must now also consume the canonical camelCase
`alertIdentifier` field and pending-approval expiry metadata end to end.
@@ -2405,6 +2405,8 @@
"frontend-modern/src/components/patrol/RunHistoryEntry.tsx",
"frontend-modern/src/components/patrol/RunHistoryPanel.tsx",
"frontend-modern/src/components/patrol/RunToolCallTrace.tsx",
"frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx",
"frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts",
"frontend-modern/src/pages/AIIntelligence.tsx",
"frontend-modern/src/stores/aiIntelligence.ts",
"frontend-modern/src/types/aiIntelligence.ts",
@@ -2433,6 +2435,8 @@
"match_files": [
"frontend-modern/src/components/Brand/PulsePatrolLogo.tsx",
"frontend-modern/src/components/patrol/index.ts",
"frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx",
"frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts",
"frontend-modern/src/pages/AIIntelligence.tsx",
"frontend-modern/src/stores/aiIntelligence.ts",
"frontend-modern/src/types/aiIntelligence.ts"