Skip to content

fix(jobs): a clause the contract never asked for is not a pass - #1181

Merged
HugoXK merged 3 commits into
mainfrom
dev2/1175-not-asked
Nov 20, 2026
Merged

HugoXK merged 3 commits into
mainfrom
dev2/1175-not-asked

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Written-by: HugoXK
Author: Fledge Platform Dev-2

Fixes #1175

Three of the seven clauses — evidence.required, sections.required, actions.forbidden — answer pass when 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 hardcoded null (:2396-2398). The empty branch is therefore the only branch those clauses can take on a real job, and it ran ahead of the null branch (src/lib/instructions.ts:184-185, :197-198, :210-211 before :186-187, :199-200, :212-213), so the page printed 通过 / pass beside 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: null is there to keep the clause unverifiable "rather than a pass this process cannot see" (:2378-2379). The record's fold (:223-227) then made a clean job read pass, and docs/architecture.md:3699-3708 is the rule the record exists for: a clause is pass when it was observed and satisfied.

Design. A fourth clause-level outcome, not-asked, for a family the contract does not ask for. Not pass: nothing was checked. Not unverifiable: that word means "asked for and not observed", and using it here would make every compliance record on main read unverifiable and hide the genuine unobserved case — the failure the card and docs/architecture.md:3759-3760 rule out. It stays out of the record's fold, so such a contract is still a record-level pass, adherence_status keeps pass | violation | unverifiable, and the merge gate does not move.

What changed.

  • src/lib/instructions.ts — a ClauseStatus type (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-227 is untouched, and AdherenceStatus still describes the record.
  • src/views/pages.ts — the clause shape check in readAdherence now 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.ts and test/pages.test.ts — new cases; test/jobs.test.ts is untouched and still green (pass on a clean contract, unverifiable on an unobserved requirement).

The trap the card named, and why the page moved in the same commit. readAdherence rejects an unrecognised clause status by returning null, 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 (tree 5950b299).

  • test/instructions.test.ts → a requirement the contract never asked for is not asked, never a pass fails: 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 pass fails: the record is dropped by the shape check, so the card falls back to "no clause audit recorded yet".
  • That run is 2 files / 2 failures, 90 pass. At the tip the two files are 92/92.

Ran:

  • npm run check on the tree of f1851a25f0208ed3249509af8f312da9b9cbce98 — the tree is 0808182d819aa776839e57b48b99c8633fbf4567, 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.
  • Frames from the real app on loopback (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 通过 / pass before and — 无须核对 / — not asked after in both locales; the summary reads "所有可机检的条款都通过了。" / "Every machine-checkable clause passed." before and names the limit after; scrollWidth - innerWidth = 0 at 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.md is updated in this PR with the fourth outcome; node scripts/changelog.mjs check passes with the one fragment.

Before/after frames (shots1175/, referenced from evidence commit 966ac26c671d66f60c7483160ccc35047a02e639 and removed from the tip tree so main carries no screenshots), same seeded store, same session and locale, only the tree differs.

1280 360
before en before en 1280 before en 360
after en after en 1280 after en 360
before zh before zh 1280 before zh 360
after zh after zh 1280 after zh 360

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 pass where nothing failed, so nothing that gates a merge changes. src/jobs/service.ts, tryMerge and src/db.ts are not in the diff. Rollback: revert this commit; the three rows return to pass and the summary to the completeness sentence.

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 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 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

@HugoXK
HugoXK merged commit cf352fd into main Nov 20, 2026
36 of 37 checks passed
@HugoXK
HugoXK deleted the dev2/1175-not-asked branch November 20, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(jobs): the clause audit prints "pass" for the requirements the sealed contract never asked for

2 participants