Repository navigation
fix(scenarios): travel_expense filing checks per-type amounts via aggregate post-states and relation paths; records stamp the card sha256 and summaries refuse mixed cards - #35044
Conversation
…_submit_from_text Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufziH9rnXEpD9ne7yFhD
…ther line shape Add aggregate post-states (sum / each) and relation paths in a post-state where, with loader validation, tests, README lines and a changeset. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufziH9rnXEpD9ne7yFhD
📓 Docs Drift Check33 anchor(s) derived from 1 changed package(s); no hand-written page names any of them. What this run could not see
Coarse fallback — 1 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 97c06b6df7439abf9fa4e898e6a3a63526e64aeb && git checkout 97c06b6df7439abf9fa4e898e6a3a63526e64aeb
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin b85dff0f4350f4846b03c31b328fc5a8f782d1c9 236748846a49323b9223904672f1a0c049a7cb32 && git checkout -B drift-repro b85dff0f4350f4846b03c31b328fc5a8f782d1c9 && git merge --no-ff 236748846a49323b9223904672f1a0c049a7cb32
node scripts/docs-audit/affected-docs.mjs --json b85dff0f4350f4846b03c31b328fc5a8f782d1c9 |
… scorecard, and refuse to sum mixed card hashes Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufziH9rnXEpD9ne7yFhD
…se-② yes (widening) Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufziH9rnXEpD9ne7yFhD
|
repo:objectstack#3 · os-support-ai · session_01WGufzfWpJ96QY9T7d8DvFg L1: ACCEPT · 2026-11-18T01:45ZHead-sha: c8ab4e4 席位核对
What I checked
Must-fixNone. Should-fixNone. Notes
NextClause-② is yes, so this goes to the seat's L2. After that it is an ordinary queue landing (not governed). If anything is pushed after c8ab4e4, a delta read is owed. |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgh1zkZzDXL36ckWAG Contract-review-claim: session_01WGufzgh1zkZzDXL36ckWAG · head |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgh1zkZzDXL36ckWAG Contract reviewServed-tier: Face: declaration ( Check-runs on ① Derived judgmentsEach accept-set or public-surface change the diff implies (
② Semver level
③ Boundary flagsS1 (should-fix): the card stamp hashes the file at record-write time, not the bytes the run loaded. This is L1 N1, graded up from a note.
n1 (nit): n2 (nit): Adding
n3 (nit, L1 N2 carried): c4a0c6d has a SQL push-down (Prime Directive 5): no finding.
Dev flags and
Must-fix: none. Should-fix: S1 (open; a delta read is owed before landing, per contract-review.md: "no open must-fix or should-fix"). Implemented-by: VERDICT: PASS |
…ead after the run Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufziH9rnXEpD9ne7yFhD
|
repo:objectstack#3 · os-support-ai · session_01WGufzgh1zkZzDXL36ckWAG Contract-review-claim: session_01WGufzgh1zkZzDXL36ckWAG · head |
|
repo:objectstack#3 · os-support-ai · session_01WGufzfWpJ96QY9T7d8DvFg L1: ACCEPT · 2026-11-18T02:33ZHead-sha: b2d22c5 席位核对
Delta
Must-fixNone. Should-fixNone. Notes
NextThis ACCEPT is conditional on the last CI check finishing green on b2d22c5. It then returns to the seat's L2 for its delta. After that it is an ordinary queue landing. Any push after b2d22c5 owes a delta read. |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgh1zkZzDXL36ckWAG Contract reviewServed-tier: This is a delta review of Face: declaration. The delta adds no path. It is one fast-forward commit (b2d22c5) touching 6 files that are already in the PR's 17-file list. None of them is a published schema or a governed path. Inputs read:
Check-runs on
① Derived judgments
② Semver level
③ Boundary flagsS1 (should-fix, from
n4 (nit, new):
n5 (nit, new): the PR body's
n6 (nit, new): the pins test
n7 (nit, L1 N3 agreed):
n1-n3 from
SQL push-down (Prime Directive 5): no finding. The delta adds no query, no id materialisation and no in-app join. It hashes a local file. The Dev flags and
Must-fix: none. Should-fix: none open; S1 is closed. Nits: n1-n7. Implemented-by: VERDICT: PASS |
|
repo:objectstack#3 · os-support-ai · session_01WGufzfWpJ96QY9T7d8DvFg L1: ACCEPT · 2026-11-18T02:42ZHead-sha: 2367488 席位核对
Must-fixNone. Should-fixNone. NotesNone new. NextThis ACCEPT is conditional on CI finishing green on 2367488. Then the area lands it through the ordinary queue. Any further push owes another read. |
|
repo:objectstack#3 · os-support-ai · session_01WGufziH9rnXEpD9ne7yFhD Landing · area o3-F · 2026-11-18T03:03Z · #35025 per-type amounts and the card stamp
State change: ready for review + auto-merge (merge queue). #35025 closes on merge via |
|
repo:objectstack#3 · os-support-ai · session_01WGufziH9rnXEpD9ne7yFhD Hand-off · area o3-F · 2026-11-18T03:23Z · queued, nothing left but the merge
|
Requested by Yibo Wang · project thread
Fixes #35025
Clause-②: yes (widening) — the run record gains a top-level
card: { id, sha256 }and its scorecard acardStamp; a card's post-state gains the optionalsum/eachmembers and relation-pathwherekeys; new exportsCardStamp,cardStampOf,cardStampText,relationObjects,DeclaredLookups;LoadedScenariogainsfileSha256;cli.tsexportsloadedCardStamp;summarygains a card dimension. Every card and record that loaded, graded or summed before still does.Metadata-protocol: none
This PR delivers both halves of #35025: the card and grader change, and a card stamp on the record and the scorecard, which tells a round graded before a card change from one graded after it. Round 2 merged origin/main (#35023 landed as 339c2f4) with a plain merge, which applied with no conflicts, and added the stamp on top.
维护者速读
file_and_submit_from_text不再要求明细行必须是「酒店 1 行×2 晚、餐补 1 行×3 天」。现在检查的是:TR-0121 这张新报销单下,酒店合计 860,餐补合计 345,且没有任何一行超标。报销单本身的检查(报销人、已提交、总额 1205、审计人)不变。为此评分器新增两样东西:聚合式状态检查(sum/each),以及where里的关联路径(如claim.trip)。@objectstack/scenarios),不影响运行时。其它场景卡不受影响。本卡这一项在改动前后的轮次之间不可直接对比,所以每条运行记录现在都带上卡片文件的 sha256,记分卡多打一行card: travel_expense (sha256 …)。summary遇到卡片哈希不同的记录会拒绝合并,并写明两个哈希各自来自哪些记录。回滚即还原本 PR。packages/qa/scenarios/src/score/scenario-operation-grade.ts(aggregateChecks)、packages/qa/scenarios/src/runner/observe.ts(readPath/relationObjects)、packages/qa/scenarios/src/runner/summary.ts(card维度与拒绝行)。pnpm --filter @objectstack/scenarios exec vitest run --maxWorkers=2 test/travel-expense.test.ts,预期 10 个测试全过,其中两种填法都通过,填错的三种情况失败。What changes
Card (
docs/qa/scenarios/travel_expense.json, operationfile_and_submit_from_text). The two claim-line entries pinned{expense_type, quantity: 2|3, unit_amount}and read one row each. They are replaced by three aggregate entries, all scoped to the new claim for trip t121 throughclaim.trip:sum: {amount: 860}over the hotel lines;sum: {amount: 345}over the meals lines;each: {over_standard: false}over every line of the claim.The claim entry (
claimant e02,status submitted,total_amount 1205) andauditActor: employeeare unchanged.Grader (
score/scenario-operation-grade.ts). The grader could not express a sum or a multi-row match before: awherehad to match exactly one row (->one-row), andwherekeys were the object's own fields only. Anappliedstate entry can now be an aggregate over every row itswherematches:sum: each field's total must equal the declared number (state:LABEL.sum(amount), within a millionth). A row that reads no number fails it.each: every row must hold the value (state:LABEL.each(field)), compared the wayvaluescompares it.->rows, never a vacuous pass.Schema (
schema.tsPostStateSchema):sumandeachare optional.values,absentor an aggregate.where, never byid.wherekey may be a dotted relation path (FieldPathSchema).Loader (
loader.ts):wherekey goes through the same relation-path check that persona scopes and truth filters use (checkPath, againstexpect.lookups);sumandeachfield must be one the seed carries;Runner (
runner/observe.ts,runner/orchestrate.ts).postStateRowsresolves a relation path through the card's lookups and the rows read after the turn.relationObjectsnames the objects a path hops to, and the runner now reads them beside the post-states' own objects.touchedRowIdandobserveOperationtake the lookups too.Docs: the card format in
docs/qa/scenarios/README.md, and the grader line inpackages/qa/scenarios/README.md.Card stamp (
runner/scorecard.ts,runner/cli.ts,runner/summary.ts):CardStamp { id, sha256 }andcardStampOf. The sha256 is taken over the card file's bytes as the runner loaded them, before the run moved its dates or prefixed its names.LoadedScenario.fileSha256, new).cli.tsstamps each run from that throughloadedCardStamp, never by reading the file again after the run. A card edited during its run keeps its load-time hash, and a card moved or deleted meanwhile still gets its record. This follows the supplied-template path, which also hashes the bytes it read once.runRecordwrites it at the record's top level (card), andcardScorecardcarries it ascardStamp.renderScorecardprintscard: travel_expense (sha256 FIRST12)under the packages line.summaryaddscardtoTABLE_DIMENSIONS. A table whose runs graded two card files is refused, with the linethe runs differ in card: `card: ID (sha256 A)` (files…) vs `card: ID (sha256 B)` (files…), naming each hash and the records holding it. A stamped record next to one written before the stamp readscard: not recordedand is refused the same way. Unstamped records keep summing with each other, and their dimensions line is unchanged.Changeset:
patchon@objectstack/scenarios(Metadata-protocolnone), with both declaration lines.Tests
All readings at head
b2d22c5f.test/travel-expense.test.ts, a new top-leveldescribe. It runs the real card throughnamespacedScenario,observeOperationandgradeCardOperation, over the full seed, whose other claims carry hotel and meals lines of their own:relationObjects=[demotravel_expense_claim];statusalone;each(over_standard)), and a claim with no lines (three->rows);test/score/scenario-operation-grade.test.ts, a newdescribefor the aggregate checks: both line shapes, a wrong total, an over-standard line, a non-number cell, zero rows, decimal sums, and an unobserved aggregate.test/runner/summary.test.ts, a new top-leveldescribefor the card dimension. Two hashes refuse the table, and the refusal line names each hash with its records (a1.json,a2.jsonvsb.json);summaryMainexits 1. A stamped record next to an unstamped one is refused. One hash sums, and the dimensions line names it. Unstamped records print nocard:.test/runner/orchestrate.test.ts, a new top-leveldescribe:runRecordstampscardat the top level and on the scorecard, and the scorecard prints the line;cardkey and no line;test/refusals.test.ts: seven new refusal cases (an aggregate byid,valuesplus an aggregate, an emptyeach, a sum over a text field, a sum over a missing field, a path through no declared lookup, a path ending on a missing field). Plus one clean-load control:account.namepath, aneach, and asumoveremployees.Package suite, typecheck, ablation
pnpm --filter @objectstack/scenarios build && … typecheck && … testatb2d22c5f:VERDICT command-exit 0,Test Files 39 passed (39),Tests 1128 passed (1128).tsc --noEmit -p tsconfig.json --listFilesincludes the edited test files.scripts/ablation-replace.mjs: the anchor hit went from 1 to 0, and the restore was confirmed by a blob equal to HEAD and an emptygit diff HEAD. The tests importsrc/, so there is no dist leg.gradeOperation,checks.push(...aggregateChecks(at, s, rows));replaced byvoid aggregateChecks;:Tests 6 failed | 52 passed (58)acrosstravel-expenseandscenario-operation-grade.observe.tsmatches, the relation-path read replaced byundefined:Tests 3 failed | 7 passed (10)intravel-expense(both pass cases, the recorded-run case and the wrong-filing case).summary.ts,'card'dropped fromTABLE_DIMENSIONS:Tests 3 failed | 24 passed (27)insummary.scorecard.ts, thecardStampTextline deleted fromrenderScorecard:Tests 1 failed | 143 passed (144)inorchestrate.cli.ts,loadedCardStampput back to re-reading the file after the run (suppliedTemplateOf(loaded.file).sha256):Tests 2 failed | 2 passed | 142 skipped (146)under-t 'card stamp'. The edited-card pin fails on the hash, and the deleted-card pin fails withENOENT.Acceptance notes
caseHashor revision, andenv.frameworkis only the checkout commit. The stamp is new in this PR. Records written before it readcard: not recordedinsummary, and are never summed with stamped ones.run_action(demotravel_file_expense_claim), which answers{ ok, action, objectName, result: { id } }.RecordedDriver'screatedIdOf(runner/driver.ts) reads only a top-levelid. So the new claim's id is never mapped, and the nextrun_action(demotravel_submit_claim) is re-sent with the recordedrecordId. The app answersRECORD_NOT_FOUND, not the recordedHOOK_ABORTED. This is reported to the seat for filing, not fixed here.Verification
Regrade of the iteration-2 recording (travel_expense, ask, workspace)
Command:
run-scenarios --only travel_expense --modes ask --template …/build/travel_expense/template.json --ask-repeats 5 --packages workspace --driver recorded:…/iter2/ask.rec.json, written to a scratch out dir (round 1, at6513b37c;packages: workspace @ 6513b37c). Round 2 did not repeat it: the card-stamp commits change no grade.packages: workspace @ 99bd2203):file_and_submit_from_textFAIL onstate:demotravel_expense_claim[trip="t121"].statusalone (read "draft", declared "submitted"). The two quantity-shaped line entries pass.Run-operations 2/3 · 3 not measured · 2 started from restored rows.6513b37c): the operation is NOT MEASURED:the replay is not faithful: … run_action was refused HOOK_ABORTED in the recorded run and refused RECORD_NOT_FOUND on replay(see Acceptance notes).Run-operations 2/2 · 4 not measured · 2 started from restored rows.Seed 173/757,Run-问数 25/25 · 40 not measuredandRun · datasets 25/25are the same as the recorded round.6513b37c: the record's claim row and its two lines, over the namespaced seed, throughobserveOperationandgradeCardOperation. Result: FAIL onstatusalone.sum(amount)reads860 = 860 over 1 row(s)for hotel and345 = 345 over 1 row(s)for meals, andeach(over_standard)reads2 of 2 row(s) read false. Claimant, total and audit actor pass. One limit: the record keeps only the rows the oldwherematched, so a third line on that claim would not show here.Local gates
node scripts/pm/dispatch-gates.mjs --commandsatb2d22c5fderived 70 commands. 68 exited 0. Two exited 3 (PREREQUISITE NOT MET), so they are NOT MEASURED:node scripts/check-plugin-teardown-shape.mjs --self-test: its fixture is pinned to a commit outside this shallow clone, and it tests the checker itself;pnpm check:dual-build-cjs-loads: it needs the whole workspacedist/after the merge (CI builds it).--ranreconciliation:70 derived, 68 run, 2 NOT-MEASURED, 0 UNRUN.node scripts/pm/overlap-check.mjsatb2d22c5f:VERDICT clean exit 0. It merges cleanly with origin/main a3e216e, and no open PR shares a file.node scripts/check-nul-bytes.mjs: exit 0.CI families are left to this PR's check-runs.
Generated by Claude Code