You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 36873ee
Browse filesBrowse the repository at this point in the historyBrowse files
feat(scenarios): a card names the agent action an operation goes through (via) (#36503)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9JpRoUZGqtwqMU5k7b4C58D)_
Part of #36206 (item 3 and the PAY-0044 position land here; the
column-total half of item 2 waits on the eval seat's re-score and stays
open on the card).
Clause-②: yes (widening)
Metadata-protocol: none
Ruling-ref: 7077801044 (item 3 C, PAY-0044 folded)
## 维护者速读
-
用户能看到什么变化:评测席位跑场景卡时,经理通过卡片自带的审批动作做决定的那一步,搭建分不再因经理没有直接改审批记录的权限而被扣,改记为“未测”;其余用户无感。
- 为什么做:场景库专题(画廊刷新)里请假余额和采购到收货两张卡,搭建正确却被扣分;顺带修正订单到回款卡上一笔付款落在“近 30
天”边界日、导致卡片答案与平台口径不一致的问题。
- 出错会怎样:最坏是某张卡的这一项授权检查被记为“未测”而不是“失败”,只影响评测分数,改动可直接撤回。
- 要你做什么:无。
## What changes
Against `origin/main` 59392ed.
| Part | Change |
|:--|:--|
| Card schema | An operation may carry `via`: the card's own agent
action the write is designed to go through. Optional; a card without it
reads exactly as before. |
| Loader | Refuses a `via` that is not one of the card's
`run.agentActions` on the operation's object (the ruled check), and a
`via` on a `refused` operation (a refused write has no route; without
this the key would be accepted and do nothing). |
| Grant grading (`gradePersonaGrants`) |
`persona-grant:PERSONA:OBJECT:VERB` is **not measured, never a pass**,
when the set withholds the verb AND every operation that needs it has a
designed route the build declares: its `via` action, or (unchanged) the
card's confirm-gated action for a `pending_confirmation` write. A set
that grants the verb still passes. An operation without `via` is graded
as today, so one unrouted applied write of the same verb keeps the check
measured. The existing confirm-gated branch and its detail text are
unchanged; the `no designed route` pin (`start_qa`, non-confirm action,
no `via`) stays green. |
| Cards | `via: decide_approval_step` on leave_balances
`manager_approves_step_one`, requisition_to_receipt
`manager_approves_level_one` and travel_expense
`manager_approves_step_one`. Not tagged (no measured run yet):
asset_lifecycle `manager_approves_scrap`, order_to_cash
`approve_discount`. A library pin lists exactly the three tagged
operations. |
| PAY-0044 | order_to_cash's PAY-0044 moves from 2026-10-01 to
2026-10-02 (bank reference `ACH-1002-058`), the same one-day move PR
#36320 gave TK-0091, and the seed rule names the exception. The library
pin of last-N-days truths that change under the platform's preset flips
to `[]`. `collected_by_team_last_30_days` west becomes 58300 (was 53500;
the payment now falls inside the card's 30-day window too). The only
other reader of `payment_date` is the collection-call automation check
(paid by due + 15 days), which reads the same for INV-1058 either way. |
`Clause-②: yes (widening)` reading: `src/index.ts` does `export * from
'./schema.js'`, so `OperationSchema` and `ScenarioCardSchema` are on the
package's `.` entry (`package.json` `exports["."]` maps to
`dist/index.*`); `PersonaGrantNeed` (gains `routedVia`) is on `./score`
via `export * from './scenario-tags.js'`.
**Read first (by risk):**
1. `packages/qa/scenarios/src/score/scenario-tags.ts`: `designedRoutes`
and the new branch at the top of `gradePersonaGrants`'s needed path; the
old confirm branch must read unchanged when no operation names `via`.
2. `packages/qa/scenarios/src/loader.ts`: the `via` block in the
operations loop.
3. `docs/qa/scenarios/order_to_cash.json`: PAY-0044 row and the
seed-rule sentence.
**Two-minute check:** `pnpm --filter @objectstack/scenarios exec vitest
run test/score/scenario-tags.test.ts test/refusals.test.ts
test/library.test.ts`, expect all green, including the new `an applied
write the card routes through its own action` case.
## Tests
- New `scenario-tags.test.ts` case: with the read-only contractor and
`start_qa` routed `via set_task_status`, the update check is not
measured with the named detail and counts in neither figure; a granting
set still passes; a build without the action keeps it measured (fails);
the card without `via` fails as before; a second unrouted update keeps
it measured.
- Three new `refusals.test.ts` rows: an undeclared action, the card's
action on another object, a `via` on a refused write.
- `library.test.ts`: the tagged-operations pin; the last-N-days pin
flipped to `[]`.
- `order-to-cash.test.ts`: the `collected_by_team_last_30_days` truth
updated to west 58300.
<details><summary>Package suite and typecheck (head bb187ca, merged
main)</summary>
```text
pnpm --filter @objectstack/scenarios typecheck && pnpm --filter @objectstack/scenarios exec vitest run --maxWorkers=2
Test Files 42 passed (42)
Tests 1310 passed (1310)
os-verify-lock: VERDICT command-exit 0
```
The package's `typecheck` includes `test/**`. The commit after that one
adds only the changeset.
</details>
<details><summary>Ablations (one-time, restored to HEAD; not left in the
tree)</summary>
```text
grading: scenario-tags.ts `const via = n.routedVia.filter(...)` -> `const via: string[] = [];`
ablation-replace: ok mutation landed: anchor 1 -> 0, blob 7ae784e -> 77cf0c9a74ac
x an applied write the card routes through its own action (`via`) ...
Tests 1 failed | 101 passed (102) (the confirm-gated / no-designed-route pin stays green)
ablation-replace: ok restored: blob == HEAD (7ae784e) and `git diff HEAD` is empty
loader: `if (op.via !== undefined) {` -> `if (op.via !== undefined && false) {`
ablation-replace: ok mutation landed: anchor 1 -> 0, blob 2d93286 -> 8a1456983646
Tests 3 failed | 118 passed (121) (the three new refusal rows)
ablation-replace: ok restored: blob == HEAD (2d93286) and `git diff HEAD` is empty
```
Both subjects resolve from `src/` (relative imports), so no rebuild sat
between mutation and run.
</details>
<details><summary>Derived gate families (head 8eb5896): 68 derived, 66
exit 0, 2 NOT MEASURED</summary>
`node scripts/pm/dispatch-gates.mjs --commands` (merge base 59392ed),
each run with its exit captured before any pipe, then `--ran` with the
codes: "68 derived famil(ies) accounted for — 66 run, 2 NOT-MEASURED (2
DERIVED from a recorded exit 3)".
- NOT MEASURED: `pnpm check:dual-build-cjs-loads`, reason: PREREQUISITE
NOT MET (reads built output of every package; this worktree built only
the scenarios closure). CI's `Lint & Repo Gates` runs it.
- NOT MEASURED: `pnpm check:type-check-debt`, reason: its closure build
never got a turn on the shared verify lock (queue-timeout, held by
another session's dogfood run). The diff touches no tsconfig or
typecheck script; the scenarios package typecheck is green above. CI's
`Lint & Repo Gates` runs it.
- Every other derived family exited 0, including `check:nul-bytes`,
`check:cross-package-test-inputs`, `check:published-files`,
`check:doc-authoring`, `check:issue-citations` and
`check:adr-0087-registration`.
- Full dogfood battery: not run (no `!` in the title, no `(narrowing)`
arm).
</details>
## Acceptance notes
- The loader's refusal of `via` on a `refused` operation goes one step
past the ruled text (which names only the not-an-action refusal).
Reason: grading reads `via` only on writes that need a grant, so on a
refused write the key would be accepted and ignored. It is a refusal on
a key that is new in this PR; no card writes it.
- Not tagged, by the ruling: asset_lifecycle `manager_approves_scrap`
(`decide_scrap_request`) and order_to_cash `approve_discount`
(`decide_discount_approval`) have the same decide-through-action shape,
but no measured run shows the grant check failing there yet.
- Item 2b (a decline stating a whole-column total) is not in this PR; it
waits on the eval seat's re-score of `september_commission`.
## Verification
Item 3 is graded on the next gallery refresh: leave_balances and
requisition_to_receipt Build and Iterate should read
`persona-grant:dept_manager:approval_step:update` as not measured when
the build routes the decision through `decide_approval_step` without
granting the update, and as passed when it grants it.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01ADHkmRY38EZf38Yy3zthbY
<!-- signed: repo:objectstack#2 · os-steve ·
session_01ADHkmRY38EZf38Yy3zthbY -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
feat(scenarios): a scenario card names the agent action an operation goes through (`via`)
6
+
7
+
Clause-②: yes (widening) — `OperationSchema` (exported from the package's `.` entry, and through it `ScenarioCardSchema`) accepts an optional `via`; `PersonaGrantNeed` (the `./score` entry) gains `routedVia`
8
+
Metadata-protocol: none
9
+
10
+
- A card operation may name, as `via`, the card's own agent action the write is designed to go through (one of `run.agentActions` on the operation's object). The loader refuses a `via` that is not such an action, and a `via` on a `refused` operation.
11
+
- The Build check `persona-grant:<persona>:<object>:<verb>` is not measured, never a pass, when the persona's set withholds the verb and every operation needing it names a `via` action the build declares (or, as before, waits on confirmation behind the card's confirm-gated action the build declares). A set that grants the verb still passes; an operation without `via` is graded as before.
12
+
- leave_balances `manager_approves_step_one`, requisition_to_receipt `manager_approves_level_one` and travel_expense `manager_approves_step_one` name `decide_approval_step` as their route.
13
+
- Card data: order_to_cash's PAY-0044 is paid on 2026-10-02, not 2026-10-01, so no payment sits on the day the platform's `last_30_days` preset counts and the card's 30-day window does not (`collected_by_team_last_30_days` west is now 58300).
Copy file name to clipboardExpand all lines: docs/qa/scenarios/order_to_cash.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
{
2
-
"$comment": "Seed rule (so every truth can be worked by hand), as of 2026-10-31: account a(k), k = 1..12, is owned by rep [e02, e03, e04, e06, e07, e08][(k-1) mod 6] (team east: e02-e04 under manager e01; team west: e06-e08 under e05) on net_45 terms when k mod 4 = 0, else net_30. Order i = 1..120 is for a((i-1) mod 12 + 1), owned by that account's owner, dated 2026-07..10 day ((i-1) mod 30)+1 (i 1-30 July, 31-60 August, 61-90 September, 91-120 October), with two lines: hardware p((i-1) mod 3 + 1) x (10 + 5(i mod 5)) at list price, 20% off when i mod 10 = 0, and service p(4 + i mod 3) x (1 + i mod 4) at list price. A line discount above 10% routes the order to the owner's manager (`approver`; `approved_on` the next day once approved). Status: i 1-90 cancelled when i mod 20 = 13, else fulfilled; i 91-120 by i mod 10: 1-3 fulfilled, 4, 5 and 9 confirmed, 6-7 draft, 8 cancelled, 0 pending_approval. A fulfilled order is invoiced 7 days after its order date as INV-(1000+i), due after the account's terms. Payments as of asOf: Harbor Foods (a05) has paid nothing; Ironwood Labs (a09) pays half on the due date; Cedar Logistics (a02) pays in full 20 days after the due date; every other account pays in full 3 days before it; method by k mod 3: 0 wire, 1 ach, 2 check. Activities: one touchpoint per account per month on day 30 - 2k by the owner (July meeting, August call, September email, October call), plus a collection_call by e09 on the day an invoice is 15 days past due when it is not fully paid by then.",
2
+
"$comment": "Seed rule (so every truth can be worked by hand), as of 2026-10-31: account a(k), k = 1..12, is owned by rep [e02, e03, e04, e06, e07, e08][(k-1) mod 6] (team east: e02-e04 under manager e01; team west: e06-e08 under e05) on net_45 terms when k mod 4 = 0, else net_30. Order i = 1..120 is for a((i-1) mod 12 + 1), owned by that account's owner, dated 2026-07..10 day ((i-1) mod 30)+1 (i 1-30 July, 31-60 August, 61-90 September, 91-120 October), with two lines: hardware p((i-1) mod 3 + 1) x (10 + 5(i mod 5)) at list price, 20% off when i mod 10 = 0, and service p(4 + i mod 3) x (1 + i mod 4) at list price. A line discount above 10% routes the order to the owner's manager (`approver`; `approved_on` the next day once approved). Status: i 1-90 cancelled when i mod 20 = 13, else fulfilled; i 91-120 by i mod 10: 1-3 fulfilled, 4, 5 and 9 confirmed, 6-7 draft, 8 cancelled, 0 pending_approval. A fulfilled order is invoiced 7 days after its order date as INV-(1000+i), due after the account's terms. Payments as of asOf: Harbor Foods (a05) has paid nothing; Ironwood Labs (a09) pays half on the due date; Cedar Logistics (a02) pays in full 20 days after the due date; every other account pays in full 3 days before it, except PAY-0044 (INV-1058, due 2026-10-04), paid 2026-10-02 so no payment sits on 2026-10-01, the day the platform's last_30_days preset (31 days ending on asOf) counts and the card's 30-day window does not; method by k mod 3: 0 wire, 1 ach, 2 check. Activities: one touchpoint per account per month on day 30 - 2k by the owner (July meeting, August call, September email, October call), plus a collection_call by e09 on the day an invoice is 15 days past due when it is not fully paid by then.",
if(!personas.has(op.actingAs))refuse([...at,'actingAs'],`no persona \`${op.actingAs}\``);
928
+
if(op.via!==undefined){
929
+
if(op.outcome.kind==='refused'){
930
+
refuse([...at,'via'],`a \`refused\` write goes through no route: \`via\` names the agent action an applied or confirmation-gated write is designed to go through`);
0 commit comments