Repository navigation
feat(labeler): admin pause/resume of automated issuance (W9.6 PR-2) - #2027
Conversation
Two admin-only endpoints toggle the global ingestion kill-switch through the mutation guard: the effect flips automation_state.paused and emits an ungated operational event (automation-paused high / automation-resumed info) with the audit row in one batch. System status now reports the paused state, reason, and since; the console dashboard gains an admin-gated pause/resume control. Enforcement already lives in the discovery consumer (PR-0) — this wires the operator surface that drives it, proven end to end (pause endpoint -> consumer retries -> resume -> processes). Claude-Session: https://claude.ai/code/session_014rikrGMh25h1rJczUQyTMM
|
Scope checkThis PR changes 678 lines across 10 files. Large PRs are harder to review and more likely to be closed without review. If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs. See CONTRIBUTING.md for contribution guidelines. |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-playground | 93170bb | Jul 13 2026, 11:11 PM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-demo-do | 93170bb | Jul 13 2026, 11:11 PM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-demo-cache | 93170bb | Jul 13 2026, 11:12 PM |
There was a problem hiding this comment.
Approach judgment
This is the right change, solving the right problem, in a way that fits the labeler's architecture. W9.6 PR-0 built the kill-switch mechanism (automation_state singleton, fail-closed isAutomationPaused, discovery-consumer enforcement); PR-2 wires the operator surface that drives it — two admin-gated endpoints through the existing mutation guard, a status-card read, and a console control. It deliberately mirrors the established emergency-action pattern (runEmergencyAction) but correctly diverges where the semantics differ: no label is issued, so there's no confirmation ceremony, no assertIssuancePersisted, and the operational event is ungated (not label-gated). The kill-switch stays ingestion-only — enforcement lives in processDiscoveryMessage, never the signing layer — so manual/admin issuance (including !takedown) stays available while paused. That's a sound, spec-aligned design.
What I checked
- Authz before effect:
runAutomationTogglerunsguardMutation(role gate + idempotency lookup) before any state UPDATE or event INSERT; the replay path returns the stored descriptor with no side effects. The per-endpoint tests (reviewer→403, unauth→401) verify zero side effects onoperator_actions,operational_events, andautomation_state.paused. Server is authoritative; the consoleisAdminflag is cosmetic. - Idempotency/fingerprint:
parseBody: () => ({})ignores the wire body entirely, sopausedderives from the route, not the body — POSTing{paused:false}to/pausestill pauses (the adversarial note in the description holds). The fingerprint is over{action, reason}only; same key + same reason → replay, same key + different reason → 409, both covered by tests. - Atomicity: the audit row,
automation_stateUPDATE, and event INSERT go in onecommitMutationbatch; a key-race conflict rolls the effect back with the audit insert. No orphan event/state without an audit row.resumeclearspaused_reasonto NULL. A re-pause while paused is a harmless re-write with its own audit row + event (tested). - Status read:
readAutomationStateis a direct singleton read added to the existingPromise.all;paused !== 1(incl. missing row) reads "Active", matching the consumer's fail-closed posture only in the not-paused direction.pausedSince = updated_atis correct while paused (only pause/resume touchupdated_at). - Console:
AutomationControlmints the idempotency key per dialog open and reuses it across retries (correct replay semantics), gates the toggle behindisAdmin, uses logical (RTL-safe) Tailwind, and Kumo components. Invalidatessystem-statuson success. - End-to-end proof: the payoff test drives the real
processDiscoveryMessageon the same D1 — pause → consumer retries (no subject); resume → consumer acks and creates subject + pending run. This genuinely proves the endpoint drives PR-0's gate. - Conventions: SQL is parameterized throughout (no interpolation); no content tables touched (no
localefilter needed);OperatorActionType(pause-issuance/resume-issuance) andOperationalEventType(automation-paused/automation-resumed) were already reserved. Changeset is n/a (private unpublished Worker); i18n is an explicitly documented decision (2026-07-13) not to localize the labeler console.
Conclusion
The implementation is clean, well-tested, and consistent with the established patterns. Fail-closed behavior is preserved and the gate drive is proven end-to-end. I have one non-blocking design observation (below) about notification delivery. Two items the description pre-acknowledges are fine as-is: the missing-singleton-row cosmetic discrepancy (status reads "Active" while the consumer fails closed — only in a broken-migration state, safe direction) and pausedSince reflecting the most recent pause (event-per-action model).
| paused, | ||
| reason: ctx.reason, | ||
| cts: ctx.now.toISOString(), | ||
| }; |
There was a problem hiding this comment.
[suggestion] runAutomationToggle records an automation-paused/automation-resumed row in operational_events but, unlike runEmergencyAction (which enqueues a notification_outbox row to the deployment-alert channel at line ~915), it stages no outbox row. Today that's benign — no outbox delivery worker is wired yet, so nothing is delivered regardless — but when delivery lands, a takedown/compromise will page the on-call channel while a kill-switch activation (severity high, an incident-response action) will be audit-only. If the intent is that pausing ingestion during an incident should also alert the deployment channel, consider staging an outbox row here for consistency; if audit-log/console visibility is deliberately sufficient for a reversible operator action, this is fine as-is. Flagging only as a product question, not a defect.
There was a problem hiding this comment.
Good product question, and I agree it's a decision rather than a defect — so I'm leaving it as-is (audit + console only) pending Matt's call rather than unilaterally deciding a pause should page on-call. The event stream already carries the high-severity automation-paused row, so W11.3 can alarm on it directly; staging a deployment-alert outbox row is a one-line addition if the answer is "a pause should page too." I'm batching this with two other alerting/audit-semantics questions from #2026 to put to Matt together once W9.6's PRs are all in, so the incident-notification policy is decided coherently rather than per-PR.
~ 🤖 Claude Opus 4.8
There was a problem hiding this comment.
Re-review: approach judgment
This is the right change, solving the right problem, in a way that fits the labeler's architecture — unchanged since my prior pass. W9.6 PR-0 built the kill-switch mechanism (automation_state singleton, fail-closed isAutomationPaused, discovery-consumer enforcement); PR-2 wires the operator surface: two admin-gated endpoints through the existing mutation guard, a status-card read, and a console control. It mirrors runEmergencyAction but correctly diverges where the semantics differ — no label is issued, so no confirmation ceremony, no assertIssuancePersisted, and the operational event is ungated (not label-gated). The kill-switch stays ingestion-only (enforcement in processDiscoveryMessage, never the signing layer), so manual/admin issuance including !takedown stays available while paused. Sound and spec-aligned.
What I re-verified
The diff is unchanged from the prior review; I re-traced each hunk against the runtime semantics in AGENTS.md:
- Authz before effect:
runAutomationTogglerunsguardMutation(role gate + idempotency lookup) before any state UPDATE or event INSERT; replay returns the stored descriptor with no side effects. Per-endpoint tests verify zero side effects onoperator_actions,operational_events, andautomation_state.pausedfor reviewer→403 and unauth→401. - Idempotency/fingerprint:
parseBody: () => ({})ignores the wire body, sopausedderives from the route (POSTing{paused:false}to/pausestill pauses). Fingerprint is over{action, reason}only; same key+reason → replay, same key+different reason → 409 — both tested. - Atomicity: audit row +
automation_stateUPDATE + event INSERT go in onecommitMutationbatch; a key-race rolls the effect back with the audit insert.resumeclearspaused_reasonto NULL. Re-pause while paused is a harmless idempotent re-write with its own audit row + event (tested). - Status read:
readAutomationStateis a parameterized singleton read added to the existingPromise.all;paused !== 1(incl. missing row) reads "Active" — the pre-acknowledged cosmetic discrepancy in the safe direction (consumer still fails closed).pausedSince = updated_atis correct while paused (only pause/resume touch it). Note: on a hard D1 error (not a missing row) the status endpoint 500s like its count siblings do — consistent, not a regression. - Console:
AutomationControlmints the idempotency key per dialog open and reuses it across retries, gates the toggle behind cosmeticisAdmin(server authoritative), uses Kumo components and logical (RTL-safe) Tailwind, and invalidatessystem-statuson success. Stale-closure concerns are non-issues (dialog closes on success; submit requires a typed reason). - Dashboard: new
whoamiquery drives cosmeticisAdmin, defaulting tofalsewhile loading/erroring so the toggle hides safely. - End-to-end proof: the payoff test drives the real
processDiscoveryMessageon the same D1 — pause → consumer retries (no subject); resume → consumer acks and creates the subject. Genuinely proves the endpoint drives PR-0's gate. - Conventions: SQL is parameterized throughout; no content tables touched (no
localefilter needed); reservedOperatorActionType/OperationalEventTypereused, nothing frozen touched; the labeler console's no-Lingui posture matches existing components (e.g.AssessmentActionDialog's bare-EnglishCOPY), and is a documented decision; changeset n/a for a private unpublished Worker.
Conclusion
Clean, well-tested, and consistent with the established patterns. Fail-closed behavior is preserved and the gate drive is proven end-to-end. No new blocking or non-blocking findings.
One previously-noted design consideration remains open and is not reposted as a finding: the automation-paused/automation-resumed events are written to operational_events but, unlike emergency takedowns, get no notification_outbox row. I confirmed there is no outbox drain/delivery worker in apps/labeler/src today, so emergency alerts also sit undelivered — the automation omission is consistent with the current state and only becomes observable once a delivery worker is wired. Worth a deliberate decision then; not blocking now.
05afa59
into
feat/plugin-registry-labelling-service
What does this PR do?
W9.6 PR-2 — the admin-only pause/resume of automated issuance, the operator surface for the global ingestion kill-switch. PR-0 (#2024) built the mechanism (the
automation_statesingleton, the fail-closedisAutomationPausedread, and the discovery-consumer enforcement); this PR wires the endpoints, status read, and console control that drive it.POST /admin/api/automation/pauseand/resume, bothrequiredRole: "admin". The effect flipsautomation_state.paused(buildAutomationPauseUpdate) and emits an ungated operational event —automation-paused(severityhigh) orautomation-resumed(info) — committed with the audit row in onecommitMutationbatch. No label is issued, so there's no phantom-label risk andassertIssuancePersisteddoesn't apply. Areasonis required (it folds into the idempotency fingerprint); no confirmation ceremony — pause/resume is reversible and low-blast-radius, unlike a takedown.!takedown— stays available while automation is paused.resumeclearspaused_reasonto NULL. No auto-resume timer; resume is an explicit audited action.automationPaused,pausedReason, andpausedSince(a direct singleton read added to the existing statusPromise.all), degrading in the safe direction on error like its siblings./whoami; the server is authoritative.End-to-end proof: the payoff test drives the real
processDiscoveryMessageon the same DB — hit the pause endpoint, and the consumer retries an ingestion create (no subject created); resume, and it processes to a subject + pending run. This proves the operator endpoint actually drives the gate PR-0 built, not a stubbed flag.OperatorActionTypealready reservedpause-issuance/resume-issuance;operational-events.tsalready reserved the event types. Nothing frozen was touched.Adversarially reviewed by an independent Opus pass targeting authz-before-effect, the end-to-end gate drive, fail-closed preservation, singleton integrity under concurrent pause/resume, and a body-injection surface (
pausedderives from the route, never the wire — POSTing{paused:false}to/pausestill pauses): no blockers, no test fixes needed. Two informational notes, neither worth a guard: a missing singleton row (a broken-migration state) makes the status card read "Active" while the consumer still fails closed and retries everything (cosmetic, safe direction); andpausedSincereflects the most recent pause under the event-per-action model.Stacked on the integration branch (W9.5 + PR-0 + PR-1 merged). Targets
feat/plugin-registry-labelling-service. Related to #1909 and RFC #694.Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runmessages.pochanges except in translation PRs — a workflow extracts catalogs on merge tomain.i18n n/a — the labeler console is deliberately not localized (decision 2026-07-13). Changeset n/a —
apps/labeleris a private, unpublished Worker app.AI-generated code disclosure
Screenshots / test output
pnpm --filter @emdash-cms/labeler test: worker 520 pass (28 files; new pause/resume happy-path, per-endpoint reviewer-403/unauth-401 zero-side-effect, replay/409/re-pause, and the end-to-end consumer-gate proof), console 29 pass (newAutomationControltest)console:buildsucceeds; lint: 0 diagnostics inapps/labelerhttps://claude.ai/code/session_014rikrGMh25h1rJczUQyTMM
Try this PR
Open a fresh playground →
A full working EmDash site, deployed from this branch. Each visit gets its own session-scoped sandbox: no login needed and no shared state. Try the admin, edit content, hit the public site.
Tracks
feat/labeler-pause-resume. Updated automatically when the playground redeploys.