Skip to content

fix(jobs): a claimed seat is not an observed seat - #1186

Open
HugoXK wants to merge 6 commits into
mainfrom
dev2/368-attribution-ground
Open

HugoXK wants to merge 6 commits into
mainfrom
dev2/368-attribution-ground

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Written-by: Fledge Platform Dev-2

Fixes #368

What changed

The job record now keeps the seat the job claimed and the seat the server observed as two records, and the page marks the difference instead of printing the claim as a fact.

  • jobs.attribution_json keeps what the callback claimed and is never overwritten by an observation.
  • jobs.attribution_ground_json (new column, added the way attribution_json was) stores, per attribution key, claimed, observed and state — grounded, unobserved or no-observation.
  • groundAttribution(claimed, stats) in src/lib/teamStats.ts builds that record; captureTeamStats writes it (src/jobs/service.ts), including the no-observation record on a host where no instance could observe anything.
  • jobAttribution in src/views/pages.ts renders the two markers on the job page and on the dashboard job row: 声称,未观察 / claimed, not observed when an observation ran and did not see the claimed seat, 声称,未核实 / claimed, not verified when nothing observed the job, and nothing when the seat is grounded. A seat only the instance saw is shown from the observation, unmarked.
  • docs/architecture.md promised the stricter behaviour and described only the event; the paragraph now names the two records and the markers.
  • changelog.d/368.added.md: one fragment, the change is user-visible.

The marker is one word about the record, not a gate: verification.ok, mergeReadiness and checkStage are untouched, because an instance exists only where one is configured and a merge-blocking variant is a different card.

The defect this answers

captureTeamStats wrote the observation over the claim (attribution_json), so a claimed Test with zero calls simply disappeared from the page — the reader could not tell a seat that worked from a seat nobody watched — and on a host with no instance the claim stayed and printed as fact. The record had one column holding two different facts, and the page had no way to say which one it was showing.

Carrier

The observation is the DSH per-role call counts (teamState → attribution_ground), which prove presence and never authorship. The review object and the commit author are not carriers here: requiredPass fixes the review account and reviewerAuthoredCommit refuses a reviewer-authored tip, and every commit on this repository resolves to HugoXK or to a bare unlinked email. So the slice ships the provable half — the record refuses a seat it cannot prove — and adds no carrier that could never fire.

A consequence worth naming

attribution_json now always holds the claim, and three readers outside this slice's file list read that column: changeStoryAttribution (src/app.ts:1066), the console SSE snapshot (src/app.ts:3862) and the evolution export (src/lib/evolution/export.ts:22). For a job that an instance observed, those three used to show the observation and now show the claim. They are display surfaces, not gates, and the job page is the surface that distinguishes the two; but this is a real change on a surface the card did not name, so I am stating it rather than burying it. The ground record carries the observed half per key, so moving those readers onto it is a contained follow-up if the seat wants it in this slice — say so and I will do it on this branch.

The three display surfaces whose meaning changes, named so a reviewer can check them without reading prose: changeStoryAttribution (src/app.ts:1066, the Change story card's model · role line), the console SSE snapshot's attribution field (src/app.ts:3862, consumed by the console's live job list) and the evolution export's attribution column (src/lib/evolution/export.ts:47). For a job an instance observed, each of those read the observation before this change and reads the claim after it. None of them is a gate, and the ground record carries the observed half per key, so moving them onto it is a contained change if the seat wants it here.

A second limit, for rows written before the column existed: captureTeamStats used to write the observation over the claim, so a pre-change row carrying team_stats_json holds the observed half in attribution_json and reads unmarked exactly as it does today, while a pre-change row without team stats holds a claim nothing checked and now says so. Where the old capture saw no calls at all it left the claim in place beside the stats, and no record can separate that row from an observed one — that ambiguity is the defect this card exists for, and it closes from here on.

Risk tier

risk-tier: T3; basis: src/db.ts

src/jobs/** and src/db.ts are T3 by the repository's own table; I did not trim the diff to lower it. Eight files, +467/−20.

Red first, at the base

test/attributionGrounding.test.ts run in a clean worktree at the base 25d0c459d0b4a69a55e5884769cf0eb90f79f46d:

npx tsx --test test/attributionGrounding.test.ts
# tests 7   # pass 3   # fail 4
  • row 1 the job page marks the unobserved claim in English — the Test claim had vanished; the page read Lead Claimed · Dev-1 Implemented.
  • row 2 the English page says nothing observed the claim — on a host with no instance the page printed Test Tested as fact.
  • row 5 attribution_json still holds what the job claimed — after the capture the row held {"claimedBy":"Lead","implementedBy":"Dev-1"}.
  • row 7 a legacy row with no observation says its claim was never verified — the pre-change row printed its claim unmarked.

Rows 3, 4 and 6 pass at the base and still pass at the tip; they are the no-regression rows: a grounded seat gains no marker, a seat only the instance saw is shown from the observation, and the three gates return what they returned before.

At the tip

0166539c583d802e91027b698c22a8c86655db89, tree 25d87276119912f460edbb1f7ef1768c04105a42 (the tree is the one the code commit cd16c954a3f0b26875028592fe8e5a29b85310fd carries; the commits after it add the frames and then remove them):

npx tsx --test test/attributionGrounding.test.ts     → 7 passed, 0 failed
npm run check                                        → exit 0

npm run check at the tip: lint 11 warning(s) in 8 entries match the baseline, typecheck clean, # tests 3266 / # pass 3265 / # fail 0 (1 skipped), build clean. One earlier run of the same tree failed test/deployAutomation.test.ts:291 with the lock holder never took the lock — the known fixed-deadline flake on that file — and the re-run is the green one above; nothing in this diff touches it.

node scripts/version.mjs check → version: 0.4.4 ok. node scripts/changelog.mjs check → changelog: 22 fragment(s) ok.

The migration line was exercised on a database written by the base code: opening that file with the tip code adds attribution_ground_json to jobs and the old row reads back with attribution_ground_json: null.

UI evidence

Sixteen frames, before and after, en/zh × 1280/360, on the job page and on the dashboard job row, on the evidence/368 branch: commit 97fbdb3761fb71b896ef3e4fa50deb1644c18755 for the eight job-page frames and commit c22dd3740d270b34b281fb1c7b12c01031ecccb0 for the eight dashboard frames (the repository keeps screenshots on evidence/* branches, so the tree that merges carries the code only).

Each side is produced by its own tree's own team capture against its own SQLite file: the before frames come from a worktree at 25d0c459 whose captureTeamStats wrote the observation over the claim, and the after frames come from this tip. Both seeded the same way: a succeeded job claiming implementedBy: Dev-1, testedBy: Test, served by a loopback server on its own port and signed in as the same account, plus a second job whose Test seat actually made calls. The frame is taken after the Result card is scrolled into view — the earlier attempt framed the top of the page, where the line is not, and produced identical pairs.

before after
job page, en, 1280 before after
job page, en, 360 before after
job page, zh, 1280 before after
job page, zh, 360 before after

The dashboard row needed a second pass, and the reason was not a scroll container. The jobs table sits inside a collapsed <details class="secondary">; while that section is closed the row has no box at all, so a page scroll stops at the section header and the earlier attempt framed the header rather than the line. Each dashboard frame here is taken with the section opened the way a reader opens it, the job_368_unobserved row scrolled to the middle of the viewport, and the row's own text read back at the exact point the shutter opens (elementFromPoint returns that text). The frame therefore shows the row, and the pair differs at every size — before 105,194 bytes against after 106,974 bytes at en/1280, and every one of the four pairs differs byte for byte.

before after
dashboard, en, 1280 before after
dashboard, en, 360 before after
dashboard, zh, 1280 before after
dashboard, zh, 360 before after

The row's text is also read back from the DOM at capture time, so the claim does not depend on a reader opening a PNG:

view before after
job page, en Lead Claimed · Dev-1 Implemented Lead Claimed · Dev-1 Implemented · Test Tested · claimed, not observed
job page, zh Lead 领取 · Dev-1 实现 Lead 领取 · Dev-1 实现 · Test 测试 · 声称,未观察
dashboard rows, en Lead Claimed · Dev-1 Implemented · Test Tested then Lead Claimed · Dev-1 Implemented grounded row unmarked, claimed row · Test Tested · claimed, not observed
dashboard rows, zh Lead 领取 · Dev-1 实现 · Test 测试 then Lead 领取 · Dev-1 实现 已观察的一行无标记,声称的一行 · Test 测试 · 声称,未观察
  • Responsive: documentElement.scrollWidth - clientWidth = 0 on every frame, at 360 and 1280, both pages, both locales, both trees.
  • Keyboard: focusable count unchanged (68 on the job page, 80 on the dashboard, both locales, both widths). The marker is text inside the existing <p class="fine">; it adds no control and no tab stop, so the tab order is the one it already had.
  • Language parity: both markers exist in both languages and the dashboard row is fed by the same helper as the job page, which is why the row in zh says 声称,未观察 and not an English string.
  • Contrast: no new colour pair. The marker rides the existing muted paragraph style, so its contrast is the contrast docs/code-standards.md already requires of .fine; nothing here introduced a lighter grey.

Ran:

  • npx tsx --test test/attributionGrounding.test.ts at 25d0c459d0b4a69a55e5884769cf0eb90f79f46d — 3 passed, 4 failed (the red above)
  • npx tsx --test test/attributionGrounding.test.ts at the tip — 7 passed, 0 failed
  • npx tsx --test test/attribution.test.ts test/teamStats.test.ts test/pages.test.ts test/db.test.ts test/jobs.test.ts — 241 passed, 0 failed
  • npm run check at the tip — exit 0
  • node scripts/risk-gate.mjs --base 25d0c459 — the machine line above
  • node scripts/changelog.mjs check — 22 fragments ok
  • node scripts/version.mjs check — 0.4.4 ok
  • the migration on a database written by the base code — attribution_ground_json added, old row reads null
  • the 16 frames (8 job page, 8 dashboard) and the DOM read-back above, from two worktrees on loopback ports 8478 (before) and 8479 (after)

Not run:

  • Docker image build and the docker smoke test; real SMTP
  • a real DSH instance: the capture is exercised through the same teamState seam the service uses, with a stub returning per-role call counts, so no HTTP reached a real bridge
  • scripts/visual-matrix.ts (the overflow, focus and touch checks are done on the two pages above instead), scripts/mock-snapshot.ts, and any external a11y scanner
  • the reference-equality of the two seeded databases beyond the job rows the frames show

Rollback

Revert the commit. The column is additive: an older binary ignores attribution_ground_json, and a row written by this code still has its claim in attribution_json, so nothing is lost on a revert. The page falls back to today's reading for any row without a ground record.

Docs and changelog

docs/architecture.md is updated in the same PR (its paragraph promised this behaviour and described only the event). changelog.d/368.added.md carries the user-visible line. No Docs-not-needed: claim.

answering body ea8bd38ffb3f (issue-gate)

The job row held one attribution column and the team capture wrote the
server observation over the claim, so the page printed a claimed seat as a
fact and a claim with nothing behind it looked like a seat the instance saw.

The claim stays in attribution_json; attribution_ground_json records the
observation beside it, per attribution key, as claimed / observed / state
(grounded, unobserved, no-observation). The job page and the dashboard row
mark a claim the instance did not see as 'claimed, not observed' and a claim
nothing observed as 'claimed, not verified', and leave a grounded seat
unmarked. A seat only the instance saw is shown from the observation.

Nothing blocks: verification.ok, mergeReadiness and the stage gate are
untouched, because an instance exists only where one is configured.
16 frames: before and after, en and zh, 1280 and 360, job page and dashboard
row. Each pair is produced by its own tree's own team capture, so the before
frames show the claim being overwritten and the after frames show the marker.

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

  • One writer per column: claimJobTerminal stores the callback's claim (src/jobs/service.ts:1849), captureTeamStats writes attribution_ground_json and never touches the claim (:3347-3351, no-instance branch :3329-3331), and groundAttribution derives per-key claimed/observed/state (src/lib/teamStats.ts:33-47); the column is additive in CREATE TABLE (src/db.ts:1596) and added by ALTER on an existing file (:3273), so rollback loses nothing.
  • The page marks only what the record cannot prove: jobAttribution (src/views/pages.ts:529-571) emits claimed, not observed / claimed, not verified, leaves grounded and observed-only seats unmarked, and reconstructs a legacy row from team_stats_json presence (:509-528) instead of guessing a state the old capture did not record.
  • My own run, same test file both trees: at 25d0c459 3 passed / 4 failed, at this tip 7 passed / 0 failed — the red is behaviour, not a missing module.
  • 16 frames exist and are placed off-branch (8 job page at 97fbdb37, 8 dashboard at c22dd374), 1280x1100 and 360x900, every before/after pair differs in blob sha and byte size, and the dashboard cause is corrected to the collapsed <details> opened for the capture; I cannot see pixels (this model has no image input), so I verified PNG signature, dimensions, blob sha and size, not the rendered text.
  • Scope: the three readers that now show the claim (src/app.ts:1066, src/app.ts:3862, src/lib/evolution/export.ts:47) belong in a follow-up card, not this slice — each needs its own rendering decision when claim and observation disagree and the export column needs a semantic choice — but I would not let that card wait past the next dispatch.

Ran:

npx tsx --test test/attributionGrounding.test.ts   # in a 25d0c459 worktree with this tip's test file: 3 pass / 4 fail
npx tsx --test test/attributionGrounding.test.ts   # at 0166539c: 7 pass / 0 fail
node -e 'read PNG signature, IHDR, sha256 and size of the 16 evidence blobs'

Not run:

  • npm run check at the tip (the author's 3266-test run; I ran this file alone, plus the tree/evidence reads above)
  • a real DSH instance and the Docker image
  • the rendered text inside the frames — no image input on this model

Written-by: HugoXK-bot

The frames live in 32c587f for the links in the pull request body; the tree
that merges carries the code only.
A row with team stats keeps reading as observed; a row without them says its
claim was never verified.
The first frames were viewport shots of a line that sits below the fold, so the
before and after pairs were byte-identical. These are taken after the Result card
is scrolled into view, so the job page frames differ by the marker.
The frames live in 3e7e3770 for the links in the pull request body; the tree that
merges carries the code only.

This branch has not been deployed

No deployments
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.

feat: prove who authored the verifier instead of trusting the job's claim

2 participants