Repository navigation
fix(jobs): a clause the contract never asked for is not a pass - #1181
Conversation
Three of the seven clauses — evidence, sections and forbidden actions — answer `pass` when the contract names nothing to check, and every dispatched job seals those three lists empty. So the audit printed a check it never performed, next to its own detail that said nothing was asked, and the card summarised it as "every machine-checkable clause passed". The empty branch now yields its own clause outcome, `not-asked`, which is neither `pass` nor `unverifiable` and stays out of the record's fold — a contract that asks for nothing is still a record-level `pass`, and no merge outcome moves. The page allows the fourth word through the shape check (a status outside the allowlist would blank the whole card), renders it `— 无须核对 / — not asked`, and builds the summary's limit sentence from the record so it names only the families that were not asked. T2. Docs: docs/architecture.md states the fourth outcome beside the trichotomy.
Eight frames from the real app: the same seeded store and session cookie, the record produced by each tree's own evaluator, only the tree differs. They are referenced from the pull request by this commit and removed in the next one, so the merged tree carries none of them.
The pull request embeds them from the evidence commit above; keeping 2 MB of screenshots in every clone of main is not worth it.
HugoXK-bot
left a comment
There was a problem hiding this comment.
Verdict: PASS at f1851a2
The production path is the empty branch, and the fix is there: src/jobs/service.ts:1535-1536 seals the three lists empty while :2396-2398 passes null, so src/lib/instructions.ts:194-195, :207-208 and :220-221 now answer not-asked; the fold at :233-237 ignores that outcome, so adherence_status keeps its three values and the merge gate still blocks only on violation (service.ts:2526, :2941).
The page half is in the same diff, which is what the shape check needs: src/views/pages.ts:4446-4460 extends the clause allowlist (without it readAdherence returns null and the card reads "no clause audit recorded yet"), :4517-4524 maps the fourth word to — 无须核对 / — not asked, and :4530-4544 builds the summary from the record so only the unasked families are named while a contract that names them keeps the plain sentence.
Tests pin both halves: test/instructions.test.ts:153-181 keeps not-asked out of pass/unverifiable and asserts the record still passes, test/pages.test.ts:1358-1421 asserts the card is not the no-record fallback and covers the partial case; test (24) and coverage are green at this tip.
UI surface: the job page's adherence card did change, and the PR carries 8 before/after PNGs at evidence commit 966ac26c (1280×3412 and 360×4256/4257, 265–298 KB), with none left in the tip tree; visual and ci-ok are green, the only red run is the pre-PASS review-gate.
T2 is the right tier (src/lib/instructions.ts), the diff is exactly the six files, the changelog fragment is present, and there is no workflow, permission or gate change.
Ran: curl /repos/HugoXK/fledge/commits/f1851a25f0208ed3249509af8f312da9b9cbce98/check-runs?filter=latest — 31 runs, only the pre-PASS review-gate red, ci-ok/test (24)/coverage/visual success; contents API for shots1175 at 966ac26c (8 files) and at the tip (absent); node -e with scripts/lib/risk.mjs tierForFiles → T2, basis src/lib/instructions.ts; head and base (a2ae5911) tarballs diffed — exactly the six files; greps showing adherence_json is read only at src/views/pages.ts:4516 and that no other file consumes a clause status.
Not run: npm run check locally (the fetched tarball has no node_modules), no browser or app here, and this seat cannot open the PNGs (this model takes no image input), so I verified their provenance, count and dimensions rather than their pixels; the Docker image was not run.
Written-by: HugoXK-bot
Written-by: HugoXK
Author: Fledge Platform Dev-2
Fixes #1175
Three of the seven clauses —
evidence.required,sections.required,actions.forbidden— answerpasswhen the contract names nothing to check, and every dispatched job seals exactly those three lists empty (src/jobs/service.ts:1535-1536), while the gate's observation of them is hardcodednull(:2396-2398). The empty branch is therefore the only branch those clauses can take on a real job, and it ran ahead of thenullbranch (src/lib/instructions.ts:184-185,:197-198,:210-211before:186-187,:199-200,:212-213), so the page printed通过 / passbeside a detail that said nothing was asked and closed the card with "所有可机检的条款都通过了。/ Every machine-checkable clause passed." The comment beside the observation promises the opposite:actions: nullis there to keep the clauseunverifiable"rather than a pass this process cannot see" (:2378-2379). The record's fold (:223-227) then made a clean job readpass, anddocs/architecture.md:3699-3708is the rule the record exists for: a clause ispasswhen it was observed and satisfied.Design. A fourth clause-level outcome,
not-asked, for a family the contract does not ask for. Notpass: nothing was checked. Notunverifiable: that word means "asked for and not observed", and using it here would make every compliance record onmainreadunverifiableand hide the genuine unobserved case — the failure the card anddocs/architecture.md:3759-3760rule out. It stays out of the record's fold, so such a contract is still a record-levelpass,adherence_statuskeepspass | violation | unverifiable, and the merge gate does not move.What changed.
src/lib/instructions.ts— aClauseStatustype (AdherenceStatus | 'not-asked') and the three empty branches returning it. The detail text is unchanged: it was already honest, and the reader needs to know the family was considered. The fold at:223-227is untouched, andAdherenceStatusstill describes the record.src/views/pages.ts— the clause shape check inreadAdherencenow accepts the fourth word, the label map renders it— 无须核对 / — not asked, and the pass-branch summary is built from the record: it names only the families that were not asked, so a contract that names them keeps today's sentence and a partial case never claims all three.docs/architecture.md— one sentence beside the trichotomy stating the fourth outcome and that it is outside the fold.changelog.d/1175.fixed.md— the wording a reader sees changed.test/instructions.test.tsandtest/pages.test.ts— new cases;test/jobs.test.tsis untouched and still green (passon a clean contract,unverifiableon an unobserved requirement).The trap the card named, and why the page moved in the same commit.
readAdherencerejects an unrecognised clause status by returningnull, which renders the card as "no clause audit recorded yet". A status the evaluator can write and the allowlist cannot read does not make the audit more honest — it deletes it. The new page test asserts the card is not the no-record fallback before it asserts anything about the words, so the two halves cannot drift apart silently.Red first, at base
a2ae59117c8a8e53c92d4a1a8a2ed8f78db9a807(tree5950b299).test/instructions.test.ts→a requirement the contract never asked for is not asked, never a passfails:evidence.required is its own outcome, not a verdict: + 'pass' / - 'not-asked'.test/pages.test.ts→a clause the contract never asked for reads as not asked, never as a passfails: the record is dropped by the shape check, so the card falls back to "no clause audit recorded yet".Ran:
npm run checkon the tree off1851a25f0208ed3249509af8f312da9b9cbce98— the tree is0808182d819aa776839e57b48b99c8633fbf4567, read back from the API and equal to the local tree: exit 0, 3259 tests / 3258 pass / 1 skipped,lint: 11 warning(s) in 8 entries match the baseline, typecheck and build clean.node --import tsx --test test/instructions.test.ts test/pages.test.ts— 92/92 at the tip; 2 failures at the base (above).node scripts/risk-gate.mjs --base <base>—risk-tier: T2; basis: src/lib/instructions.ts.node scripts/changelog.mjs check— 21 fragments ok;node scripts/version.mjs check— 0.4.4 ok.buildApp+listen, port 8475/8476/8477): the same seeded store, session and locale cookie, one job, the adherence record produced by each tree's own evaluator, only the tree differs. DOM read-back: the three verdict cells read通过 / passbefore and— 无须核对 / — not askedafter in both locales; the summary reads "所有可机检的条款都通过了。" / "Every machine-checkable clause passed." before and names the limit after;scrollWidth - innerWidth = 0at 360 and 1280 in every frame.Not run: no production instance (still
0.4.3, so the page change is not live until the next instance update); no Playwright matrix job — the frames are one script run per tree, not a regression suite; no keyboard walk, because the change adds no focusable control (the measured focusable count is 65 in every frame, before and after, and the row is a table cell, not a target).risk-tier: T2; basis: src/lib/instructions.ts
Docs:
docs/architecture.mdis updated in this PR with the fourth outcome;node scripts/changelog.mjs checkpasses with the one fragment.Before/after frames (
shots1175/, referenced from evidence commit966ac26c671d66f60c7483160ccc35047a02e639and removed from the tip tree somaincarries no screenshots), same seeded store, same session and locale, only the tree differs.The four states the card asks for now render distinctly: not asked (
— 无须核对 / — not asked), asked and satisfied (通过 / pass), asked and broken (违反 / violation), asked and not observed (无法核对 / unverifiable). The verdict stays a word, never a colour alone, and both locales carry the same table.Risk: T2. The failure mode is a reader who wants a verdict word instead of a dash; the detail text beside it already said nothing was asked, and the record still says
passwhere nothing failed, so nothing that gates a merge changes.src/jobs/service.ts,tryMergeandsrc/db.tsare not in the diff. Rollback: revert this commit; the three rows return topassand the summary to the completeness sentence.