Skip to content

fix(evaluation): record an unverified shadow attempt as missing, not none - #1219

Merged
HugoXK merged 1 commit into
mainfrom
dev1/1128-shadow-recorder
Nov 23, 2026
Merged

HugoXK merged 1 commit into
mainfrom
dev1/1128-shadow-recorder

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 22, 2026

Copy link
Copy Markdown
Owner

Written-by: HugoXK

Fixes #1128

What was wrong

createMockShadowHost (src/jobs/shadow.ts:72 at the pin) published verificationJson: null for every attempt. evidenceOf (src/lib/evaluation.ts:332-337) reads null as none, so the bundled recorder's four holdout attempts were all scored "nothing was recorded" even though each attempt ran and opened a pull request. --record printed versions[].evidence = {"verified":0,"missing":0,"none":4}, and its replay printed the same.

What changed

  • src/jobs/shadow.ts: an attempt that opened a pull request now publishes the snapshot the recorder actually observed — {"ok":false,"reasons":["shadow recorder: the bundled mock opened a pull request and observed no check runs"]} — and an attempt that opened nothing publishes null, because there was nothing to verify. The rule is one small exported function, observedVerification(pullRequest), so both halves are testable without a host that can skip the mock's pull request.
  • test/evaluationShadow.test.ts: the red test, covering the card's six acceptance points.
  • changelog.d/1128.fixed.md: one fragment; the artifact a human reads changes.

src/lib/evaluation.ts is consumed, not edited: parseVerification (src/lib/verification.ts:119-130) accepts {"ok":false}, and evidenceOf already maps that to missing. No score, interval, refusal code or saturation label moves.

Red first, at the pin d16ebf60cc260a3af30223392a86379deac1fd15

node --import tsx scripts/evolution-shadow.ts --shadow test/fixtures/shadow/holdout.json --record /tmp/a1128.json --out /tmp/r1128.json → report [{"verified":0,"missing":0,"none":4}], and every recorded verificationJson was null. The new tests failed at that tip.

Tests, against the card's acceptance list

  1. every task's evidence is missing and none is none — test/evaluationShadow.test.ts
  2. record then replay through the real --attempts path (child process, the checked-in CLI) — the replayed versions[].evidence and tasks[].evidence equal the recording run's
  3. the record's verificationJson is a string, parseVerification returns non-null, and ok is false
  4. the snapshot carries no key only a pull-request read could produce (sha, prState, draft, mergeableState, combinedStatus, reviews), has no non-zero checks counts, and merged stays false
  5. assertShadowHost and LIVE_REPOSITORY stay green, and createMockShadowHost().capabilities is all false
  6. a refusal fixture that opened nothing keeps none, pinned through observedVerification(null) === null plus a run over an in-memory refusal fixture

Alternatives considered

  • Publish a fuller snapshot (sha, prState, checks, reviews) so the record resembles a job snapshot. Rejected: the mock reads nothing, so each of those values would be invented, which is the class of mistake this card removes.
  • Change evidenceOf to treat null as missing. Rejected: out of scope, and it would erase the "not recorded" state an operator host still needs.
  • Leave the recorder and document that none means "mock". Rejected: none already has a meaning, and the card's expected behaviour is missing.

Uncertainty and residual risk

evidenceOf still maps an unparseable snapshot and an ok: false snapshot to the same missing bucket; this card takes the ok: false path and does not change that mapping — the card names that as its residual. The bundled fixture set is four pull-request fixtures, so acceptance 6 pins the "publishes nothing when nothing opened" rule at its seam rather than through a full mock run.

Risk and rollback

  • Tier: T3 by path (src/jobs/**); node scripts/risk-gate.mjs --base main printed risk-tier: T3; basis: src/jobs/shadow.ts.
  • Rollback: revert the squash commit. The artifact returns to none for every attempt; no schema, no migration, no stored data changes.

Docs

Docs-not-needed: docs/architecture.md:1416-1444 already says the evidence state comes from the same parseVerification a job uses, and it does not describe the recorder's old null. The new snapshot is exactly that shape, so no doc line moves.

Ran:

  • npm run check at this tip — pass: lint, typecheck, 3315 tests / 3315 pass / 0 fail, build
  • npx tsx --test test/evaluationShadow.test.ts — 13/13 pass
  • record + replay command above at this tip — both reports {"verified":0,"missing":4,"none":0}
  • node scripts/version.mjs check — version: 0.4.5 ok
  • node scripts/risk-gate.mjs --base main — risk-tier: T3; basis: src/jobs/shadow.ts

Not run: no live host, repository, token or database — the shadow path is offline by design and createMockShadowHost still declares all capabilities false; no browser render, because this changes a JSON artifact and no rendered page.

One note for the reviewer: the first full npm run check on this tip failed one unrelated test, deployAutomation "the deploy lock wait reads the holder instead of probing it" (its injected clock reached elapsedMs 5000 and the assert wanted > 5000). It passes alone and on a second full run, and this diff touches neither deploy/ nor that test — recording it so the green run above is not read as the first attempt.

The bundled shadow recorder published `verificationJson: null` for every
attempt, so `--record` scored attempts that ran and opened a pull request as
`none` ("nothing was recorded") even though they observed no check runs. It now
publishes the snapshot it observed — `{"ok": false, "reasons": [...]}` — for an
attempt that opened a pull request, and nothing when nothing was opened, so the
report says `missing` and the `--attempts` replay prints the same counts.

Fixes #1128
Docs-not-needed: docs/architecture.md already says the evidence state comes from the same parseVerification a job uses.

@HugoXK-bot HugoXK-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verdict: PASS at 0de9ecd

  • The recorder now publishes what it observed: observedVerification (src/jobs/shadow.ts:67) emits the {ok:false,reasons:[…]} snapshot only when a pull request opened (:89-94), and evidenceOf maps that to missing while a null still reads none (src/lib/evaluation.ts:332-337); parseVerification accepts it on the boolean alone (src/lib/verification.ts:119-127).
  • Driven at this tip: --record printed [{"verified":0,"missing":4,"none":0}] with four string snapshots and zero nulls, and the --attempts replay printed the same counts with every task missing; test/evaluationShadow.test.ts is 13/13.
  • No UI surface (无 UI 面); the snapshot invents no sha/prState/checks field, the refusal path still publishes null (observedVerification(null) === null), capabilities stay all false, and CI at this sha is green except the pre-verdict review-gate.

Ran:

  • node --import tsx --test test/evaluationShadow.test.ts — 13 pass / 0 fail
  • node --import tsx scripts/evolution-shadow.ts --shadow test/fixtures/shadow/holdout.json --record … --out … and the --attempts replay — both [{"verified":0,"missing":4,"none":0}]
    Not run: npm run check at this tip (no repo-wide dev dependencies installed here); the head's CI test (24) and coverage are green.

Written-by: HugoXK-bot

@HugoXK-bot HugoXK-bot added the review:approved Issue reviewed and approved by the Fledge Platform Reviewer label Nov 23, 2026
@HugoXK
HugoXK merged commit c13c8c7 into main Nov 23, 2026
36 of 37 checks passed
@HugoXK
HugoXK deleted the dev1/1128-shadow-recorder branch November 23, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review:approved Issue reviewed and approved by the Fledge Platform Reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(evaluation): the bundled shadow recorder reports "no checks recorded", not "unknown"

2 participants