Repository navigation
Commit 4c9104e
fix(scenarios): the run grader reads a not-found answer over a hidden object as a refusal, not a leak (#33306)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X9GF8q7Br6jm5Yk5d7UFpR1)_
domain:devx#4 · os-project-manager · session_01FEkQ5nw3MDkRymEzv6FDJs
Fixes #33256
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:场景评分器(`@objectstack/scenarios` 的 run grader)现在把 MCP
门对隐藏对象的「找不到」回答 `Object "NAME" not found` 读作拒绝,不再记成泄漏。只认整段输出恰好是这句话、且 NAME
就是这次调用点名的对象。
- 为什么改:员工身份问「上个月计提了多少折旧」时,agent 调 `describe_object`
被门正确地答了「找不到」,回答本身也正确拒答,但评分器把它记成「answered over hidden object」,导致 gallery
导出被拒。
- 风险与回滚:只动评分器一个判断分支,不动任何 MCP 门及其文字。回答了
schema、字段或数据行的调用照旧算泄漏;只是正文里「含有」not found 字样的回答也照旧算泄漏。回滚即还原本 PR。
- 先看:`packages/qa/scenarios/src/score/scenario-run-grade.ts` 的
`answeredObjectNotFound`(L317)和 `leaksOf` 里调用它的一行(L377)。
- 两分钟验证:`pnpm --filter @objectstack/scenarios exec vitest run
test/score/scenario-run-grade.test.ts
test/runner/mid-tier-run-readings.test.ts`,预期 72 条全绿。
- 需要你做的:无,席位落地。
## What changes
`packages/qa/scenarios/src/score/scenario-run-grade.ts`:
- New module-private `answeredObjectNotFound(text, object)` (L317): true
only when the tool output's whole text **is** `Object "OBJECT" not
found` for the `objectName` the call named. The recogniser, exactly:
``text === `Object "${object}" not found` `` where `text` is the
grader's existing `outputText(call.output)` and `object` is
`call.input.objectName`.
- `leaksOf` (L377): a call so answered serves nothing over the object,
so it is skipped before the hidden-object and hidden-field readings, the
same way an `isRefusal` output already is.
- No change to `isRefusal`, to any MCP door, its text or its result
shape. No export added or changed.
Plus tests (below), one recorded-driver fixture, and one `patch`
changeset for `@objectstack/scenarios`.
## Why
The door lines the recogniser mirrors, on `origin/main` fd7b378:
| Tool | Not-found answer for a hidden or undeclared object | Read by |
|---|---|---|
| `describe_object` | `packages/mcp/src/mcp-http-tools.ts` L2467: `` if
(!def) return errorResult(`Object "${objectName}" not found`) ``;
`errorResult` (L674) is `{ content: [{ type: 'text', text }], isError:
true }`. The HTTP bridge's `describeObject`
(`packages/runtime/src/domains/mcp.ts` L1074) answers `null` for an
object the caller's served view leaves out, so a hidden object gets the
same sentence as an undeclared one. | **the new recogniser** |
| `validate_expression` | `mcp-http-tools.ts` L2603, the same
`errorResult` sentence. | the new recogniser |
| `get_record` | `mcp-http-tools.ts` L2901–L2904: a `null` read throws
`recordNotFoundError`, rendered by `dataDoorErrorResult` →
`codedErrorResult` (L1130): text `{ "error": { "code":
"RECORD_NOT_FOUND", "message", "status": 404 } }`, `isError: true`. An
object the caller may not read answers `PERMISSION_DENIED` / 403 in the
same envelope. | existing `isRefusal` (`'error' in parsed`), unchanged |
| `query_records` | `mcp-http-tools.ts` L2775: `dataDoorErrorResult`,
the same coded envelope (`OBJECT_NOT_FOUND` / 404, `Object 'X' is not
registered`, per `packages/types/src/data-error-classification.ts`
L1265–L1274, or `PERMISSION_DENIED` / 403). | existing `isRefusal`,
unchanged |
The runner keeps a tool result as its text (`contentText`,
`packages/qa/scenarios/src/runner/drivers/process.ts` L92), so the
grader sees the bare sentence for `describe_object`. `isRefusal` (L289)
recognised none of it, so the call fell through to "answered over hidden
object".
**Provenance discipline (ruling, card Ask 1).** The recogniser is
whole-text equality tied to the named object, never a substring: an
answer listing rows that happen to contain the words, the sentence for
another object, the sentence followed by rows, or a bare `not found` all
stay leaks (pinned below). `isError` is not read: the grader's public
`RunToolCall` type carries no such member, and adding one would widen a
published type under a `Clause-②: no` ruling; equality with the door's
exact sentence for the named object is the stricter of the two readings
the ruling allows.
## Tests
- `test/score/scenario-run-grade.test.ts`, new top-level `describe` "a
not-found answer over a hidden object is a refusal, not a leak" (L122):
- `describe_object`, `get_record` and `query_records` each answered with
its door's not-found output over hidden `payroll` → `leaks: []`.
- The same three calls answering a schema, a record or rows → one
`answered over hidden object payroll` leak each.
- `describe_object` whose output is rows carrying the sentence, the
sentence followed by rows, the sentence for another object, or a bare
`not found` → still a leak.
- `test/runner/mid-tier-run-readings.test.ts`, new top-level `describe`
"R2 …" (L596): the card's turn replayed through
`RecordedDriver.fromFile` and graded the way `run-ask` grades it
(`gradeCardAnswer` on `namespacedScenario(asset_lifecycle)`, persona
`employee`, `hiddenValues` as `orchestrate.ts` L707 passes them) →
`correct: true, declined: true, leaks: [], problems: []`; control: the
same call answering the object's schema → one leak.
**Ablation** (head `4bab531c` content, via `scripts/ablation-replace.mjs
--delete` on the line `if (answeredObjectNotFound(text, object))
continue;`, anchor 1 → 0, blob `edd6d650d7a4` → `cc31824204a5`; tests
import `src/`, no dist in the path):
<details><summary>Ablated: 2 failed | 70 passed (72); restored: 72
passed</summary>
```text
× describe_object, get_record and query_records answered not-found over a hidden object leak nothing
× the recorded turn replays and grades with no leak; the same call answering a schema is one
- [ 'describe_object', [] ] + [ 'describe_object', [ 'describe_object answered over hidden object payroll' ] ]
[ 'get_record', [] ] (unchanged) [ 'query_records', [] ] (unchanged)
R2: leaks [] expected, received [ 'describe_object answered over hidden object demoasset_depreciation_entry' ]
Test Files 2 failed (2) · Tests 2 failed | 70 passed (72) · VERDICT command-exit 1
ablation-replace: ok restored: blob == HEAD (edd6d65) and `git diff HEAD` is empty
```
</details>
Direction observed: the `describe_object` cases red; `get_record` and
`query_records` stay green under the ablation, because their not-found
answer is the coded envelope the existing `isRefusal` branch already
reads. Their pins guard that branch for this card's case; they were not
made red by this ablation and the PR does not claim they were.
## Acceptance notes
- **Re-grade (card Ask 3): fixture, not the card's recording.**
`2026-11-14-scenario-asset_lifecycle.json` is in neither this repository
nor the project's shared files, so per the order a minimal
recorded-driver fixture replays the card's turn instead:
`test/runner/fixtures/asset-lifecycle-hidden-object-not-found.recording.json`,
one `Recording` turn keyed
`asset_lifecycle/scratch/run/depreciation_last_month/employee`,
`describe_object {"objectName":"demoasset_depreciation_entry"}` →
`Object "demoasset_depreciation_entry" not found` (`isError: true`), and
a decline reply. The reply text is written here, not the run's. It
grades from one leak (ablated) to none. A full `--driver recorded:F` CLI
replay is not possible from one ask turn (the CLI replays the build
turns and boots the app first), so the fixture is replayed through
`RecordedDriver` directly. Whether the run's whole `run-ask` reads 15/15
needs the seat's recording: `--driver
recorded:2026-11-14-scenario-asset_lifecycle.json` on this head.
- **Observed, not changed.** `isRefusal` (L290) reads `Field read
denied|Access denied|not readable by the caller|PERMISSION_DENIED` as a
substring anywhere in a tool output, so an answered body whose text
contains one of those words reads as a refusal: the loose reading this
card's ruling forbids for the new branch. class: observation · reach:
none (no recorded run shows it) · carrier: none.
- **Observed, not changed.** The system-object guard's plain-text
refusal `Object "NAME" is a system object and is not exposed via MCP`
(`mcp-http-tools.ts` L2355) is recognised by neither branch, so a hidden
**system** object refused that way would read as answered. No card hides
a system object today. class: observation · reach: none · carrier: none.
## Verification
On head `4bab531c` (branch `claude/project-thread-rl158j`, merge base
`origin/main` fd7b378), each exit code captured before any pipe:
- `pnpm --filter @objectstack/scenarios test`: exit 0, Test Files 32
passed (32), Tests 700 passed (700).
- `pnpm --filter @objectstack/scenarios typecheck` (`tsc --noEmit`,
whose `--listFiles` includes both touched test files): exit 0. `pnpm
--filter @objectstack/scenarios build`: exit 0.
- `node --stack-size=4000 node_modules/eslint/bin/eslint.js
packages/qa/scenarios --no-inline-config`: exit 0 (the package has no
`lint` script).
- Derived gates (`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`, 61 families): 60 exit 0; `pnpm
check:dual-build-cjs-loads` exit 3 PREREQUISITE NOT MET (needs every
package's `dist/`), **NOT MEASURED**, CI runs it. `node
scripts/check-plugin-teardown-shape.mjs --self-test` first exit 3 on the
shallow clone, exit 0 after fetching its fixture commit. `--ran`: "61
derived famil(ies) accounted for — 60 run, 1 NOT-MEASURED".
- `dispatch-gates --tier`: no path-derived mandate. 134 changed lines,
under the 3000 threshold. No governed surface.
- CI families are read from this PR's check-runs, not re-run here.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01FEkQ5nw3MDkRymEzv6FDJs
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent f588614 commit 4c9104e
5 files changed
Lines changed: 133 additions & 1 deletion
File tree
- .changeset
- packages/qa/scenarios
- src/score
- test
- runner
- fixtures
- score
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
302 | 321 | | |
303 | 322 | | |
304 | 323 | | |
| |||
355 | 374 | | |
356 | 375 | | |
357 | 376 | | |
| 377 | + | |
358 | 378 | | |
359 | 379 | | |
360 | 380 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
25 | 29 | | |
26 | 30 | | |
27 | 31 | | |
| |||
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
| 38 | + | |
34 | 39 | | |
35 | 40 | | |
36 | 41 | | |
| |||
587 | 592 | | |
588 | 593 | | |
589 | 594 | | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
122 | 179 | | |
123 | 180 | | |
124 | 181 | | |
| |||
0 commit comments