Skip to content

feat(labeler): reviewer rerun and false-positive override (W9.5) - #2023

Merged
ascorbic merged 4 commits into
feat/plugin-registry-labelling-servicefrom
feat/labeler-override
Jul 13, 2026
Merged

ascorbic merged 4 commits into
feat/plugin-registry-labelling-servicefrom
feat/labeler-override

Conversation

@ascorbic

@ascorbic ascorbic commented Jul 13, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Adds plan item W9.5 — two reviewer actions on an assessment: re-run and false-positive override. Both go through the W9.2 mutation guard and commit their label rows atomically with the operator audit row in a single commitMutation batch.

Re-run (POST /admin/api/assessments/{id}/rerun) advances a settled assessment back to pending (advanceAssessmentToPending) so the pipeline re-evaluates it. Per the ratified decision, rerun-to-pending is accepted as-is — no attempt to diff against the prior run.

False-positive override (POST /admin/api/assessments/{id}/override) is the interesting one: it negates every live automated block on the subject and issues the eligibility pair (assessment-passed + assessment-overridden) in one atomic batch. prepareOverrideIssuance signs the N block-negations via buildIssuanceStatements directly and the eligibility pair through the manual issuance path, each piece keyed distinctly (${actionId}:${val}:${neg ? "neg" : "pos"}) so replay and race-loser skipping stay deterministic across the whole multi-label set. Override permanence (§10) needs no evaluator change: a later automated block is still emitted but resolves inert because the pass/override pair outranks it, and assertAutomatedNegationAllowed refuses any automation attempt to negate the human pass.

Ratified decisions folded in (2026-07-13):

  1. Rerun-to-pending accepted — re-running simply re-queues; no prior-run diffing.
  2. Override negates all live blocks, server-validated confirmation — the operator retypes the exact CID, validated server-side and folded into the idempotency fingerprint; the override is CID-bound.
  3. Override-retract leaves blocks negated — retracting the override does not resurrect the negated automated blocks; the subject settles into a safe-blocked resting state (blocks negated, no eligibility) rather than snapping back to blocked.

Correctness and guarding:

  • No phantom success, generalized to N labels. The W9.4 audit-without-label guard is now assertIssuancePersisted(string[]), applied symmetrically on both the proceed and replay paths. If a signing-key rotation raced such that the guarded issuance INSERTs matched zero rows while the unguarded audit row committed, the handler returns LABEL_ISSUANCE_UNAVAILABLE (503, retryable) instead of a 200 that falsely claims the release is cleared.
  • Subject+CID label read (getActiveLabelState) surfaces manual and override labels in the console's assessment/subject views, so a reviewer sees the true resting state before and after acting.

Console: an override dialog and a rerun/action dialog on assessment detail, with the typed-CID confirmation, client-generated ULID idempotency keys, and 409/503 surfaced as retryable. Plain English strings (the console is not localized, per the W9.3 decision).

Adversarially reviewed by an independent Opus pass focused on the multi-label atomic composition, the §10 automated-negation-proof property, replay determinism across the N+2 statement set, and unauthenticated/under-privileged reach. Verdict: no blockers — the signing crown jewels hold. Its one finding was a test-honesty gap: the override endpoint had no test proving it rejects an unauthenticated (401) or under-privileged (403) caller before signing. That test is added, asserting zero side effects (no audit row, no eligibility label, block untouched) on both rejection paths.

Three informational notes it raised, not addressed here (surfaced for a call, none security-impacting):

  1. Rerun has no rate limit — a reviewer could re-queue repeatedly. Reviewer-gated and idempotency-keyed, but a per-subject cooldown is worth considering as a later hardening pass.
  2. Stuck-503 within a dialog session (inherited from W9.4) — if the phantom-success guard fires, retrying the same idempotency key keeps returning 503; recovery is a fresh key, which the console mints on dialog reopen.
  3. Rerun replay reconstructs its pending key from MODERATION_POLICY.policyVersion — a policy-version bump between the original commit and a replay would spuriously 503. Static within a deploy, so low risk; noted rather than defended.

Stacked directly on the integration branch (W9.1–W9.4 merged). Targets feat/plugin-registry-labelling-service. Related to #1909 and RFC #694.

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (if applicable). Do not include messages.po changes except in translation PRs — a workflow extracts catalogs on merge to main.
  • I have added a changeset (if this PR changes a published package)
  • New features link to an approved Discussion: RFC RFC: Decentralized Plugin Registry #694

i18n n/a — no admin UI; the labeler console is deliberately not localized (decision 2026-07-13). Changeset n/a — apps/labeler is a private, unpublished Worker app; the policy fixture it bundles is internal.

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Claude Code with Claude Fable 5 (coordination), Opus 4.8 subagents (design, implementation, adversarial review)

Screenshots / test output

  • pnpm --filter @emdash-cms/labeler test: worker 459 pass (26 files — the console-assessment-mutations suite covers rerun-to-pending, multi-block atomic override, the eligibility pair, override permanence (§10), override-retract → safe-blocked, replay determinism, the 503 suppression guard on both paths, and the new override-authorization rejections), console 20 pass
  • Typecheck (both projects) clean; console:build succeeds; lint: 0 diagnostics in apps/labeler

https://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-override. Updated automatically when the playground redeploys.

Rerun mints an operator trigger and re-pends the release. Override
negates all live automated blocks and issues assessment-passed plus
assessment-overridden as one atomic batch under a single audit row;
override-retract negates only the eligibility pair, leaving blocks
negated for a safe-blocked resting state. Adds the subject+CID label
read and surfaces manual/override labels in the console.

Claude-Session: https://claude.ai/code/session_014rikrGMh25h1rJczUQyTMM
@changeset-bot

changeset-bot Bot commented Jul 13, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 668dc45

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions Bot added size/XL review/needs-review No maintainer or bot review yet labels Jul 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Scope check

This PR changes 2,346 lines across 14 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.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 13, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-demo-do 668dc45 Jul 13 2026, 08:48 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 13, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-playground 668dc45 Jul 13 2026, 08:48 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 13, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-demo-cache 668dc45 Jul 13 2026, 08:48 PM

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approach judgment

This is the right change for the right problem, and it fits the labeler's architecture. The W9.5 plan item — reviewer rerun and false-positive override (plus override-retract) — is linked to the approved RFC #694 and stacked on the W9.1–W9.4 integration branch. The design is sound: every action goes through the W9.2 mutation guard, commits its label rows + the operator audit row in a single commitMutation batch, and the override negates the entire live automated-block set before issuing the assessment-passed + assessment-overridden pair in one atomic transaction. The §10 "automation can never retract a human pass" property is preserved both at the evaluator (override pair outranks later automated blocks → suppressed) and at the signing guard (assertAutomatedNegationAllowed refuses automated negation of a manual-headed stream). Replay determinism across the N+2 statement set is handled by deriving the persistence/tail keys from the committed descriptor (the race-winner's on conflict), not the locally built ones.

What I checked

  • Atomicity / FK ordering: runRerun batches [audit, runStatement, pendingActionInsert, pendingLabelInsert] so issuance_actions.assessment_id → assessments.id resolves within the transaction. Verified against the 0003 migration FK.
  • No-phantom-success guard: assertIssuancePersisted(string[]) is applied symmetrically on proceed and replay for all three actions; a mid-batch signing-state suppression (all-or-nothing within one D1 transaction snapshot) → 503 with the audit committed but no labels, and replay re-503s. The override-phantom test exercises this honestly via a batch-truncating Proxy.
  • Stale-set rejection: assertNegatableBlockSet requires the submitted negate set to equal the live automated-block set (including duplicate/empty handling) and maps a mismatch to a clean 400 before signing. TOCTOU between the read and commit is benign because the override pair suppresses any block that appears in the gap.
  • Authorization ordering: auth → role → body parse happens in guardMutation before any signing; the new override-authz test asserts zero side effects on 401/403. Confirmed against the guard's step order.
  • Route dispatcher changes: the broadened subjects and labels branches still fall through to NOT_FOUND for unknown sub-paths; no collision with assessments/:id/labels or the mutation routes.
  • Additive LabelStreamWinner.neg doesn't break existing consumers (xrpc-router.toActiveLabelView, serializeSubjectLabel).
  • RTL/Tailwind: the new dialogs use only logical/neutral classes (flex, gap-*, justify-end, text-kumo-*, bg-kumo-elevated); no physical directional classes. i18n is n/a for the deliberately-unlocalized labeler console per the W9.3 decision.

I found no logic bugs, regressions, security issues, or convention violations. The implementation matches the ratified decisions, and the adversarial review's test-honesty gap (override authz) is genuinely closed.

Minor observations (non-blocking)

  • One maintainability suggestion below (hardcoded block vocabulary).
  • Test-completeness gaps, not bugs: there is no rerun-specific 503 phantom test (only override), and no override-retract confirmation-mismatch / 409 test (rerun and override have them). The shared assertIssuancePersisted code path is otherwise well covered.

None of these block merge.

Comment thread apps/labeler/console/src/labels.ts Outdated
Comment on lines +39 to +43
/** The automated blocking label vocabulary (policy `category: automated-block`),
* mirrored so the console can list a release's active blocks for the override
* ceremony. Presentation only — the server re-derives the authoritative set from
* live label state and rejects a stale submission. */
export const AUTOMATED_BLOCK_LABELS: ReadonlySet<string> = new Set([

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[suggestion] The console hardcodes the automated-block vocabulary in AUTOMATED_BLOCK_LABELS. It happens to match the policy fixture's automated-block category today, but the two are not derived from a shared source. If a future policy bump adds a new automated-block label, a release carrying it would render the override flow broken from the reviewer's seat: AssessmentDetail filters activeBlocks through this stale set, so the new block won't appear in the override dialog's "blocks to negate", and the submitted (stale) set is then rejected by the server's assertNegatableBlockSet with a 400 — the override silently stops working until this constant is hand-updated. The server is correctly authoritative (so no safety gap), but the presentation set drifting from the fixture is an operational footgun.

Consider deriving the console's block vocabulary from the same policy fixture (or an automatedBlockCategories(MODERATION_POLICY)-equivalent export) instead of a literal Set, so a fixture grant lights up here too with no code change — the same property the issuer already has.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in a6348be — AUTOMATED_BLOCK_LABELS is now automatedBlockCategories(MODERATION_POLICY) imported from the worker's own src/policy.ts (dependency-pure: only the fixture), so the console shares both the source and the derivation with the issuer. The same commit closes the two test-completeness notes: a rerun mid-commit-suppression 503 test (both paths, no run created) and override-retract confirmation-mismatch + idempotency-409 tests.

~ 🤖 Claude Opus 4.8

@github-actions github-actions Bot added review/awaiting-author Reviewed; waiting on the author to respond and removed review/needs-review No maintainer or bot review yet labels Jul 13, 2026
The console mirrored the automated-block set as a hand-maintained
literal, so a future policy grant would silently break the override
dialog (stale set -> server 400). Derive it with the server's own
automatedBlockCategories(MODERATION_POLICY) instead.

Also closes the reviewer-noted test gaps: rerun mid-commit suppression
503s on both paths without creating a run, and override-retract rejects
a wrong confirmation and 409s idempotency-key reuse.

Claude-Session: https://claude.ai/code/session_014rikrGMh25h1rJczUQyTMM
@github-actions github-actions Bot added review/needs-rereview New commits since the last review and removed review/awaiting-author Reviewed; waiting on the author to respond labels Jul 13, 2026
@ascorbic ascorbic added the bot:review Trigger an emdashbot code review on this PR label Jul 13, 2026

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review

This is a re-review. My previous pass found no bugs and two minor, non-blocking observations. Both are now closed:

  • Test-completeness gaps fixed. The rerun now has a dedicated 503 phantom test ("503s and creates no run when the batch is suppressed mid-commit"), and override-retract has its 409 different-fingerprint test ("409s the same key with a different fingerprint"). The shared assertIssuancePersisted(string[]) path (proceed + replay, all three actions) is now exercised honestly.
  • Hardcoded block vocabulary replaced. AUTOMATED_BLOCK_LABELS / isAutomatedBlock in console/src/labels.ts are now derived from the policy fixture via automatedBlockCategories(MODERATION_POLICY), so a fixture change reaches the override ceremony without a code edit.

What I re-verified

  • Atomicity / FK ordering: runRerun batches [audit, runStatement, ...pending.statements]; the run row precedes the pending issuance so issuance_actions.assessment_id → assessments.id resolves inside the D1 batch.
  • No-phantom-success guard: assertIssuancePersisted(string[]) loops every issuance key on both proceed and replay for rerun, override (N negations + pair), and override-retract. A signing-state suppression that drops the guarded INSERT…SELECT rows (audit commits, labels don't) surfaces 503; replay re-503s. The Proxy-truncation tests reproduce the observable outcome honestly.
  • §10 automation-negation guard: buildIssuanceStatements only runs assertAutomatedNegationAllowed (and the in-batch NOT EXISTS condition) for action.type === "automated-assessment" && neg. The override negations and override-retract are manual actions, so they bypass it — which is correct: a reviewer (manual) may negate an automated block, and may negate the manual override pair. The permanence test confirms automation still cannot retract the pass.
  • Replay determinism: override/override-retract keys are derived from the committed descriptor (returned.actionId/negated/issued), not the locally built ones, so a race-loser checks the winner's rows. Rerun reconstructs its pending key from the stored uri/cid/triggerId.
  • Authorization: all read routes (subjects/:uri/labels, labels/override-effect-preview) sit behind guardRead({ minRole: "reviewer" }); the new override-authz test asserts zero side effects on 401/403 before signing.
  • Route dispatch: the broadened subjects/labels branches still fall through to NOT_FOUND; no collision with assessments/:id/{rerun,override,override-retract}.
  • Additive LabelStreamWinner.neg + serializeSubjectLabel don't break existing consumers; SQL is parameterized; the new dialogs use only logical/neutral Tailwind + semantic tokens; i18n is n/a per the W9.3 decision (labeler console deliberately unlocalized).

No logic bugs, regressions, security issues, or AGENTS.md violations. One new, non-blocking observation below — the preview and the submit disagree on what's "negatable" for a manually-issued automated-block label. The server still rejects safely (400), so there's no incorrect state; it's a UX/preview-accuracy gap.

Comment on lines +99 to +101
const activeBlocks = activeSubjectLabels
.filter((label) => label.active && isAutomatedBlock(label.val))
.map((label) => label.val);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[suggestion] activeBlocks is derived from getSubjectLabels (the per-val stream winner) filtered by label.active && isAutomatedBlock(label.val). isAutomatedBlock keys on the label value's policy category, not on the provenance of the active event — and getActiveLabelState marks a label active for any non-negated, unexpired, CID-applicable head regardless of whether that head was issued by automation or manually. RELEASE_ISSUABLE_LABELS exposes the automated-block vocabulary (e.g. malware, data-exfiltration) as cid-bound manual-issue options, so a reviewer can manually block a release with malware via the Issue dialog.

In that state the console shows the Override (unblock) button and the OverrideDialog preview (computeOverrideEffectPreview) overlays a negation of malware + the eligibility pair and reports after: eligible. But on submit, assertNegatableBlockSet derives the live set from getNegatableAutomatedLabels, which requires the head to be an automated-assessment non-negation — a manual malware head is excluded, so the live set is empty and the submitted negate: ["malware"] is rejected with 400 INVALID_BODY ("Request body is invalid"). The reviewer is shown a preview promising "eligible" and then a confusing 400.

No incorrect data state results (the server guards correctness), and the correct unblock path there is the label-level Retract, not the override. But the preview and submit use two different definitions of "negatable," which is reachable through normal console workflow. Consider gating the Override button (or the preview) on the same negatable-set semantics the submit enforces — e.g. surface provenance/type in SubjectLabel so the console can distinguish an automated-head block from a manual one, or have the preview endpoint call assertNegatableBlockSet and 400 when the set isn't live-negatable so the dialog never over-promises.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 357260a, taking your first option — provenance on the wire. LabelStreamWinner/SubjectLabel now carry automated (from the head's issuance_actions.type via a join in getActiveLabelState — action_id is NOT NULL so the inner join is total), and activeBlocks filters on label.automated so a manually-headed block never reaches the override button or preview; its path is the label retract, which the detail view already offers. Pinned by a test that manually issues impersonation next to an automated malware: the read reports the provenance split, override naming the manual head 400s, and the automated-only set proceeds.

~ 🤖 Claude Opus 4.8

@github-actions github-actions Bot added review/awaiting-author Reviewed; waiting on the author to respond and removed review/needs-rereview New commits since the last review labels Jul 13, 2026
The subject-label read now carries the stream head's provenance
(automated vs manual), and the console only counts automated heads as
override-negatable. A manually-headed block-category label previously
showed the override button and an eligible preview that the server then
rejected with 400; its unblock path is the label retract.

Claude-Session: https://claude.ai/code/session_014rikrGMh25h1rJczUQyTMM
@github-actions github-actions Bot added review/needs-rereview New commits since the last review and removed review/awaiting-author Reviewed; waiting on the author to respond labels Jul 13, 2026
@ascorbic ascorbic added bot:review Trigger an emdashbot code review on this PR and removed bot:review Trigger an emdashbot code review on this PR labels Jul 13, 2026

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review (3rd pass) of W9.5 — reviewer rerun + false-positive override.

Approach: Sound and consistent with the W9.x architecture. The two new mutation routes (assessments/:id/rerun, assessments/:id/override, assessments/:id/override-retract) reuse the W9.2 guardMutation + commitMutation batch, fold the path assessmentId into the request fingerprint, and validate the typed CID server-side from the loaded assessment. The override composes N block-negations + the eligibility pair as one atomic batch with distinct per-piece signing keys (overridePieceKey), and the §10 automation-negation guard is correctly bypassed for the manual negations (a reviewer may negate an automated block; automation still cannot negate the manual pass). The change is additive (new routes, new LabelStreamWinner.neg/automated fields, new serialize path) and doesn't alter existing consumers. No AGENTS.md violations: apps/labeler is private: true/unpublished so no changeset is required; the labeler console is deliberately unlocalized (W9.3 decision) and the new dialogs use only logical/neutral Tailwind + kumo-* semantic tokens; all SQL is parameterized; reads sit behind guardRead({minRole:"reviewer"}), mutations behind the guard's reviewer gate.

What I re-verified (no new bugs):

  • Atomicity / FK ordering: rerun batches [audit, runStatement, ...pending.statements] so issuance_actions.assessment_id → runId resolves inside the D1 batch.
  • No-phantom-success, generalized to N labels: assertIssuancePersisted(string[]) loops every issuance key on both proceed and replay for all three actions; a mid-batch signing suppression (audit commits, labels don't) surfaces 503, and replay re-503s. The Proxy-truncation tests model the observable outcome honestly.
  • Replay determinism: override/override-retract keys are derived from the committed descriptor (returned.actionId/negated/issued), and rerun reconstructs its pending key from the stored uri/cid/triggerId — so a race-loser checks the winner's rows. The known policy-version-bump-on-replay 503 is acknowledged in the PR.
  • Negatable-set equality: assertNegatableBlockSet rejects any submitted set ≠ the live getNegatableAutomatedLabels∩automated-block (including duplicates and stale sets) before signing; the console's activeBlocks filter (active && automated && isAutomatedBlock) matches the server's automated-head semantics.
  • §10 permanence: the negations/retract are manual actions, so buildIssuanceStatements' isAutomatedNegation guard is skipped; assertAutomatedNegationAllowed still refuses an automated negation of the manual pass. The permanence test confirms a later automated block is emitted-but-inert.
  • Authorization: the new override-authz test asserts 401/403 with zero side effects before any signing; the broadened subjects/labels read branches still fall through to NOT_FOUND, no collision with assessments/:id/{rerun,override,override-retract}.

Carry-over (still open, non-blocking): the one observation from the prior pass is unchanged — computeOverrideEffectPreview overlays the client-supplied negate set without intersecting the live negatable set, so the preview can render an "eligible" after for a set the submit endpoint would reject with 400 (a manually-headed automated-block label, or a set that went stale between the subject-label read and the preview). The normal console flow doesn't trigger this (it filters by label.automated and re-reads on invalidation), and the server always rejects safely, so there's no incorrect state — it's a preview-accuracy/UX gap. Logged as a single suggestion below; no needs_fixing issues found.

Comment on lines +207 to +212
if (params.negate.includes(winner.val))
supersedes.push({ val: winner.val, cid: winner.cid, sequence: winner.sequence });
}

const overlays: ModerationLabel[] = [
...params.negate.map((val) => ({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[suggestion] computeOverrideEffectPreview builds the overlay negations (line 212) and the supersedes list (line 207) directly from the client-supplied params.negate, without intersecting the live negatable set. The submit endpoint (assertNegatableBlockSet → getNegatableAutomatedLabels filtered to automated-block) re-derives the authoritative set and rejects any mismatch with 400. So the preview can show an "eligible" after for a negate set the submit would reject — e.g. a manually-headed automated-block label, or a set that went stale between the subject-label read and the preview call. The console's normal flow avoids this (it filters active && automated && isAutomatedBlock and re-fetches labels on invalidation) and the server rejects safely, so this is a preview-accuracy/UX gap, not a correctness bug. Deriving the overlay from the live negatable set would make the preview match what the submit actually does:

Suggested change
if (params.negate.includes(winner.val))
supersedes.push({ val: winner.val, cid: winner.cid, sequence: winner.sequence });
}
const overlays: ModerationLabel[] = [
...params.negate.map((val) => ({
const liveNegatable = new Set(
(await getNegatableAutomatedLabels(db, { src: labelerDid, uri: params.uri, cid: params.cid }))
.map((l) => l.val)
.filter((val) => getLabelDefinition(val)?.category === "automated-block"),
);
const negateVals = params.negate.filter((val) => liveNegatable.has(val));

then use negateVals for both the supersedes.includes check and the overlay negate.map.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closed in 668dc45 — the preview handler now runs the same assertNegatableBlockSet check as submit and maps NegatableBlockSetError to a 400, so the two definitions of "negatable" can no longer diverge; a preview that renders is one the submit would accept. Pinned by a test issuing a manual impersonation head next to an automated malware: preview naming both → 400, the live set → 200.

~ 🤖 Claude Opus 4.8

@github-actions github-actions Bot added review/awaiting-author Reviewed; waiting on the author to respond and removed review/needs-rereview New commits since the last review labels Jul 13, 2026
…e set

The preview overlaid whatever negate set the caller supplied, so a
direct API call could render an eligible outcome the submit endpoint
would reject with 400. The preview now runs the same
assertNegatableBlockSet check as submit and 400s on mismatch.

Claude-Session: https://claude.ai/code/session_014rikrGMh25h1rJczUQyTMM
@github-actions github-actions Bot added review/needs-rereview New commits since the last review and removed review/awaiting-author Reviewed; waiting on the author to respond labels Jul 13, 2026
@ascorbic ascorbic added bot:review Trigger an emdashbot code review on this PR and removed bot:review Trigger an emdashbot code review on this PR labels Jul 13, 2026

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review (4th pass) of W9.5 — reviewer rerun + false-positive override.

Approach: unchanged and sound. The two single-purpose assessment actions (rerun, override-retract) and the multi-label atomic override reuse the W9.2 guardMutation + commitMutation batch, fold the path assessmentId into the request fingerprint, and validate the typed CID server-side from the loaded assessment. The override composes N block-negations + the eligibility pair in one atomic batch with distinct per-piece signing keys (overridePieceKey), the §10 automation-negation guard is correctly bypassed for the manual negations, and override-retract leaves the negated blocks in place (safe-blocked resting state). The change is additive and fits EmDash's architecture; no AGENTS.md violations (apps/labeler is private/unpublished → no changeset; console deliberately unlocalized; SQL parameterized; reads behind guardRead, mutations behind the guard's reviewer gate).

Carry-over resolved. The one observation from the 3rd pass — that computeOverrideEffectPreview overlaid the client-supplied negate set without intersecting the live negatable set, so the preview could render an "eligible" after for a set the submit endpoint would 400 — is now closed. handleOverrideEffectPreview runs assertNegatableBlockSet (the identical live-set check runOverride runs) before computing the preview, returning 400 INVALID_REQUEST for a manually-headed automated-block label or a stale/incomplete set. I verified computeOverrideEffectPreview has exactly one production caller (the validated handler), and the new test rejects a preview whose negate set the submit endpoint would reject asserts both the manual-head and incomplete-set cases 400 on the preview path while the live set 200s. The preview can no longer over-promise an outcome the submit would reject.

What I re-verified (no new bugs):

  • Routing: the broadened subjects/labels read branches in console-api.ts and the new assessments/:id/{rerun,override,override-retract} mutation branches fall through to NOT_FOUND for unknown segments; no collision between the read and mutation routers (distinct first segments).
  • No-phantom-success (N labels): assertIssuancePersisted(string[]) loops every issuance key on both proceed and replay for all three actions; rerun reconstructs its pending key from the committed descriptor (returned.uri/cid/triggerId), override/override-retract derive keys from the committed actionId/negated/issued. Race-loser keys come from the winner's stored descriptor. The Proxy-truncation tests honestly model the observable 503 + replay-re-503.
  • Negatable-set equality: assertNegatableBlockSet rejects any submitted set ≠ live getNegatableAutomatedLabels∩automated-block (including duplicates and stale sets) before signing; the console's activeBlocks filter (active && automated && isAutomatedBlock) matches the server's automated-head semantics, and the new provenance test confirms a manually-headed block is excluded from the offer and rejected on submit.
  • Authorization: the override-authz test asserts 401/403 with zero side effects (no audit row, no eligibility label, block untouched) before any signing.
  • §10 permanence / override-retract: unchanged; tests confirm a later automated block is emitted-but-inert, automation cannot negate the manual pass, and retract leaves blocks negated (blocked + missing-assessment-pass).

No needs_fixing issues found; the prior non-blocking suggestion is now addressed. Clean to merge.

@github-actions github-actions Bot added review/approved Approved; no new commits since and removed review/needs-rereview New commits since the last review labels Jul 13, 2026
@ascorbic
ascorbic merged commit 19dea73 into feat/plugin-registry-labelling-service Jul 13, 2026
14 checks passed
@ascorbic
ascorbic deleted the feat/labeler-override branch July 13, 2026 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:review Trigger an emdashbot code review on this PR cla: signed review/approved Approved; no new commits since size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant