Repository navigation
feat(monitoring): serve the monitor kind list at runtime so contributed kinds are not blocked - #28367
Conversation
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks: the diff adds no new control or string. A monitor of an edition-registered kind now shows the existing states and save/restart controls, so no screenshot can show a change on the stock dashboard. Notes
[UX-REVIEWED] 776266f Description read[DESCRIPTION-READ] 595cce3355140a9a834079220ca79cae23052f15ff8e3e23ae0bfc84bf00b36e That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The contract is served at runtime and only ever adds kinds, and the bundled snapshot stays as the fallback. That fixes the root cause the PR names, and it stays reversible. Notes
[DESIGN-REVIEWED] 776266f Description read[DESCRIPTION-READ] 309948d9376a6705d2db32a2028edaa60e37bcfddbaba26fcceded63623b348d That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. Linked issue #25689 is the defect's provenance, and the fix removes the cause (a build-time kind vocabulary) rather than special-casing one kind. One undeclared rider and one unweighed deletion are noted below. Notes
What this change shipsInventory (6 items) — 4 justifiedIntent: a monitor of an edition-contributed kind shows its real state with save and restart enabled in the dashboard. This is an ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 776266f Description read[DESCRIPTION-READ] a8c5c191145695ef742e13d7f5b25857c029b820a1b459351483b69b5280713a That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
8120f35 to
7ac98f0
Compare
|
Both findings addressed in F1 (useMonitorContract.ts — seeded Redux monitors stay blocked after install). Confirmed: F2 (automation.ts / writeMonitor — valid contributed-kind target edits refused). Confirmed: the built-in-only Also, per the other lanes: removed the issue/PR numbers from code comments and docstrings (comment-history gate passes locally with 0), added the |
7ac98f0 to
2879bf9
Compare
2879bf9 to
7945883
Compare
|
Rebased onto current main to clear the merge conflict; no content change. Head: 7945883. |
7945883 to
e7a9cc3
Compare
|
Both upheld findings addressed in F1 (useMonitorContract.ts:53 - contract not refreshed on reconnect). The reconnect invalidation list in F2 (feature-map row). The "Monitor loops" row in Diff vs the prior head touches only |
e7a9cc3 to
8776beb
Compare
|
Hold for human review at 8776beb. This adds a new dashboard route, GET /api/monitor-contract (mcp_routes.py#L677), and new routes are reserved for a human reviewer. I found no defect: the handler returns only monitor_frontend_contract() under the same cookie auth as GET /api/autonudge, the client merges the runtime kinds with the bundled ones so built-ins cannot drop out, and older gateways fall back on 404. All AI lanes pass at this head, the author answered the earlier-head findings with fixes, and checks are green. What clears it: a maintainer confirming the new route's exposure (cookie-authed read, no strict-internal registration) is intended. AI findings judged non-blocking:
— crew-pr-reviewer (r144) |
8776beb to
9172199
Compare
|
Rebased onto current main to clear the merge conflict (route-table test pins only); no content change. New head: 9172199. |
…ed kinds are not blocked An edition can register its own pull-request-shaped monitor kind at boot, and the backend probes it, but the dashboard reads its kind vocabulary only from the checked-in snapshot website/src/monitoring/contract.json. A monitor whose kind is absent from that snapshot was rendered as blocked even while it probed normally, with its save and restart controls disabled. Serve the contract from the gateway at runtime and prefer it over the bundled snapshot: - GET /api/monitor-contract returns monitor_frontend_contract(), now built from the live registry (built-ins plus contributed kinds) via a new all_pull_request_monitor_kinds(). It is a cookie-authed read registered beside the other dashboard monitor reads, deliberately not on the strict-internal paths, so a browser reaches it under the same auth as GET /api/autonudge. - The dashboard fetches it once (useMonitorContract, react-query) and installs its kind list through a runtime seam in monitoring/automation.ts that the record normalizer and the pull-request watch check consult. The installed set is bundled-union-runtime, so a payload can only add kinds, never shrink the built-ins. A 404 (older gateway), any fetch error, or a payload without the kind list all leave the bundled vocabulary in force. - On install the hook invalidates the normalizer-fed queries and re-runs the authoritative automation seed, so a contributed-kind record already projected into Redux as blocked is re-normalized to its real state without a poll. - Editing a contributed-kind monitor's target skips the built-in-only client parser (which would reject it) and sends the trimmed target for the backend's kind-specific validation; built-in editing and creation are unchanged, and a backend refusal surfaces through the existing error path. - Reconnect refreshes the runtime contract: the reconnect invalidation list in serverState.ts now invalidates the monitor-contract query, so a gateway restart that registered a contributed kind while the socket was down installs the new vocabulary (and re-seeds) instead of leaving its monitors blocked until a page reload. - Lists GET /api/monitor-contract and useMonitorContract ownership in the Monitor loops row of the feature map. The bundled contract.json and its parity test are unchanged; with no contributed kinds the runtime contract equals the snapshot. Built-in kinds' behaviour is unchanged. Updates the monitor-architecture spec and the plugin docstring that documented the gap. Closes #25689
9172199 to
776266f
Compare
|
Rebased onto current main to clear the merge conflict (route-table test pin only); no content change. New head: 776266f. |
bolichen97
left a comment
There was a problem hiding this comment.
Approving at 776266f.
I read every product hunk; the PR touches 26 files, most of them tests.
- Backend:
GET /api/monitor-contractreturnsmonitor_frontend_contract(), which now listsall_pull_request_monitor_kinds(), the built-ins plus kinds registered at boot. It is a read-only route with no per-session or owner data, on the same cookie auth asGET /api/autonudge. - Client:
useMonitorContractfetches it once with no retry, andsetRuntimeMonitorContractcan only add kinds to the bundled set, never remove a built-in. A 404 from an older gateway leaves the bundled contract in force. The dependent queries and the automation seed are refreshed only when the kind set grows, and a reconnect refetches the contract. - Editing a contributed kind skips the built-in URL parser and sends the trimmed target for the backend's own validation. Built-in kinds keep the client parser.
No regex added. All checks are green.
Problem / Motivation
Goal: A monitor of a kind an edition contributed at boot shows its real state in the dashboard, with save and restart enabled, instead of appearing blocked.
An edition can register its own pull-request-shaped monitor kind at boot (
register_monitor_kind), and the backend accepts and probes it. The dashboard, though, reads its monitor-kind vocabulary only from the checked-in snapshotwebsite/src/monitoring/contract.json, imported at build time byautomation.tsandautoNudgeLoop.ts. A monitor whose kind is absent from that snapshot was rendered as blocked even while it probed normally, and its save and restart controls were disabled. Stop still worked.Why it matters
Until this lands, a downstream edition cannot ship a contributed monitor kind to users: every monitor of that kind reads as blocked in the session automation popover regardless of its real state, with save and restart unavailable.
Not a goal
contract.jsonand its parity test are kept as the fallback; this does not remove the snapshot.What changed (motivation → approach → change)
Symptom: a contributed-kind monitor reads as blocked because the dashboard's
supportedgate checks the monitor kind against the bundled snapshot, which lists only the built-in kinds. Root cause: the kind vocabulary is a build-time snapshot, andmonitor_frontend_contract()itself drewpullRequestMonitorKindsfrom the frozen built-in constant rather than the live registry.Approach: serve the contract at runtime and prefer it over the snapshot, keeping the snapshot as the fallback (chosen over regenerating the snapshot per edition, which cannot cover kinds registered at a downstream's boot).
monitor_frontend_contract()now buildspullRequestMonitorKindsfrom the live registry (built-ins plus contributed kinds) via a newregistry.all_pull_request_monitor_kinds(). With no plugins the result equals the frozen built-in set.GET /api/monitor-contractreturns the runtime contract. It is a cookie-authed browser read registered besideGET /api/autonudge, deliberately not on the strict-internal paths, and exposes only the same vocabulary the bundle already ships — no per-session or owner data.useMonitorContract, react-query) and installs its kind list through a runtime seam inmonitoring/automation.tsthat the record normalizer'ssupportedgate and the pull-request-watch check consult. The installed set is bundled ∪ runtime, so a payload can only add kinds, never shrink the built-ins. On a 404 (older gateway), any fetch error, or a payload without the kind list, the bundled vocabulary stays in force.Backwards compatibility
Compatible: the change only ADDS kinds to the dashboard's vocabulary and adds one read route; it rejects, renames, and removes nothing.
monitor_frontend_contract()returns the same shape; with no contributed kinds itspullRequestMonitorKindsis byte-identical to the bundled snapshot (pinned by the snapshot parity test). An older gateway without the new route is handled by the client's 404 fallback.Removes nothing: no path, record, key, or public function is hidden, deleted, renamed, or tightened.
Tests
automationContributedKind.test.ts: a contributed kind reads as blocked without the runtime contract and as its real, actionable state with it; built-ins are unchanged with no contributed kinds; a partial/older payload and a payload omitting a bundled kind both leave the bundled kinds in force (add-only).useMonitorContract.test.ts: success installs the kinds; a 404 and other errors fall back to the bundled contract; a record normalized before the contract arrives flips from blocked to its real state once installed, with the contract fetched exactly once; a payload adding nothing touches no queries.hooks/websocket/monitorContractReseed.test.tsx: a contributed-kind monitor seeded into Redux as blocked flips to actionable when the contract installs, driven by a REST re-seed (never a websocket frame), contract fetched once.SessionAutomationPopover.test.tsx: a contributed-kind target edit is sent trimmed to the update endpoint (not refused client-side), and a backend refusal surfaces through the error path; built-in editing unchanged.api_monitor_contractreturns the contract and names a contributed kind;all_pull_request_monitor_kinds()and the contract include a contributed kind and still agree with the built-ins when none is registered; the route-sweep integration test proves the new read answers 401/403 unauthenticated; the snapshot parity test and the server composition contract are updated and green.Proof: not provable -- frontend test (prove.py runs Python only); the normalizer behaviour change is a frontend
.tschange, and the backend tests exercise added surface rather than reverting a production hunk.Manual verification
N/A — unit and integration coverage is sufficient. The visible effect requires a downstream edition to register a contributed kind, which the stock dashboard cannot do; the contributed-kind paths are covered by the tests above.
Screenshots / video
Why no screenshot: the stock dashboard registers no contributed monitor kinds, so there is no rendered delta to capture; the visible change (a contributed-kind monitor showing its real state with save/restart enabled) only appears once a downstream edition registers a kind, and is covered by the normalizer and popover tests.
Related Issues
Closes #25689
Checklist