Repository navigation
Commit f3028c5
fix(rest,runtime): the draft and layered _env reads of a name only disabled packages hold answer their own 404 (#38633)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9St4eUWHFcCKuRUrCZPperJ)_
Fixes #34261
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:搭建者在环境地址下打开某个名字的草稿、草稿预览或分层视图,而这个名字只由已停用的包持有时,现在看到“不存在”,不再看到点名那个停用包的冲突提示;普通读取早已如此。
- 为什么做:同一地址换个开关答案就不同,违背维护者“停用就该全部消失”的原则;本卡把剩下的三种读法补齐。
-
出错会怎样:最坏情况是本该显示的草稿被答成“不存在”,或停用包重新出现在冲突提示里;不会泄露其他包的草稿(有专门测试守住),撤回这个改动即可恢复原样。
- 要你做什么:无。
## What changes
`GET /meta/:type/_env/:name` answered `404` for a name only disabled
packages hold since #33385. For a caller `mayReadPendingDrafts` admits,
three spellings of that read still answered `409 RESOURCE_CONFLICT`
naming the disabled package. Each now answers its bare by-name read's
404 and names no package, on `RestServer` and the runtime dispatcher
alike:
| read at `_env` | before | after |
|---|---|---|
| `?state=draft` (any case) | `409 RESOURCE_CONFLICT` naming the
disabled holder | `404 NO_DRAFT` (the by-name draft read's answer, per
the ADR-0150 2026-11-26 note) |
| `?preview=draft` | `409` | `404 RESOURCE_NOT_FOUND` |
| `?layers=true` | `409` | `404 RESOURCE_NOT_FOUND` |
**Mechanism (measured, and it changes the suggested route).** The marked
refusal (`DISABLED_HOLDERS_ONLY_REFUSAL`) used to be swallowed only for
the plain read. If the three arms were simply judged by the plain read
too, a leak opens. In the test with a draft-reading engine double, an
enabled package C held a stored draft of the name and the registry did
not hold it. The bare `?state=draft` and `?preview=draft` served C's
draft to an admitted builder while the plain read withheld the name. So
`_env` would have served C's draft. That ablation reds the new guard pin
on all 20 types, on both transports. So `admitEnvironmentAddress` now
judges **the read the caller is answered**:
- the plain read must withhold the name, as before;
- for an admitted draft switch, that same draft read (`getMetaItem` with
`state: 'draft'` / `previewDrafts: true`, the arguments the item read
sends) must withhold it as well. Its `404 NO_DRAFT` counts as withheld.
If it serves an item or throws anything else, the refusal stands;
- the layered view (`?layers=`, when the protocol has a layered read) is
judged by the plain read. Its chain (`createMetaLayeredAnswer` step 1b)
withholds every layer whenever the plain read withholds a disabled
holder's item. The pins show this with C's draft and with C's unhydrated
active row.
The judge reads no draft switch of its own. It receives the switches the
call site already declared with their `mayReadPendingDrafts` admission
(`isDraftRead`, `previewDrafts` in the runtime, `answeredRead` on REST).
So the `[#20338]` draft-switch census in
`meta-draft-read-builder-gate.test.ts` still counts exactly its ledgered
sites.
Landing: `packages/rest/src/meta-qualified-item-route.ts` and
`packages/runtime/src/domains/meta.ts`, plus their tests and the
changeset. One more file, outside the claimed surface:
`scripts/engine-double-contract.pinned.json` gains two add-only rows. It
is written by `node scripts/check-engine-double-contract.mjs --write`,
because the two test files' `findOne` doubles now route through
`assertEngineFindOnePredicate` and the gate's ledger records that pinned
coverage. The producer of the mark,
`packages/metadata-protocol/src/protocol-exact-qualifier.ts`, is
untouched.
**ADR text this makes stale (outside this PR's surface,
`docs/adr/**`).** In ADR-0150's 2026-11-26 note, this sentence: "Three
reads at `_env` still answer `409` at this head (`?state=draft`,
`?preview=draft`, `?layers=true`), and card #34261 carries their move to
`404`." Proposed replacement: "At `_env`, `?state=draft` answers `404
NO_DRAFT` and `?preview=draft` and `?layers=true` answer `404`, each
judged by the read the caller is answered; an enabled package's stored
draft that the plain read does not see keeps the `409` for the draft
reads (#34261)."
## Tests
- `packages/rest/src/meta-qualified-item-route.test.ts` and
`packages/runtime/src/domains/meta-qualified-item-read.test.ts`:
#33995's CONTROL ("an admitted draft switch or the layered view refuses
409, as on main") is replaced, per type over `PACKAGE_SCOPED_READ_TYPES`
(20 types), by two pins:
- **the flip**: `_env` with `state=draft` / `DRAFT` answers `[404,
NO_DRAFT]`, and `preview=draft` / `layers=true` answer `[404,
RESOURCE_NOT_FOUND]`. This holds with no row and with a package-less
draft (the holder's customization) stored, and the answer never names
the holder or the draft. A caller not admitted to drafts still gets
`[404, RESOURCE_NOT_FOUND]`. CONTROL: once re-enabled, each of the four
refuses `409` naming the holder.
- **the guard**: an enabled package's stored draft. The bare
`?state=draft`, `?preview=draft` and `?package=C&state=draft` serve it
(named, so the `409` leg cannot pass vacuously). `_env` draft reads
answer `[409, RESOURCE_CONFLICT]` and never that draft. `?layers=true`
answers 404 at the bare read and at `_env`. With C's unhydrated active
row, `_env?layers=true` follows the plain read: `409` on the four
row-served types, else `404`. CONTROL: an enabled registry holder's own
draft is still served at the bare read, and `_env` refuses it naming
that holder.
- The engine doubles' `findOne` now reads the stored rows, behind a
per-pin opt-in (`findOneReadsStoredRows`, reset in `beforeEach`). The
old CONTROL's draft row was never readable through the old `findOne →
null`.
## Acceptance notes
- The `409` that remains for a draft read over an enabled package's
stored draft names the disabled registry holder as its candidate, not
the enabled package that holds the draft. Plain `_env` over an
unhydrated active row already pins the same thing as a CONTROL (review#2
S4). This PR leaves it unchanged.
- The FROM→TO 404 pins of #33385 (plain `_env`) are unchanged.
## Verification
All readings are on `objectstack-ai/objectstack`. The final head is
`e24d418ae`, and the base is `7213177e`.
<details><summary>Package suites (final head e24d418)</summary>
- `pnpm --filter @objectstack/rest test`: Test Files 441 passed (441),
Tests 9073 passed, 351 skipped (9424)
- `pnpm --filter @objectstack/runtime test`: Test Files 656 passed
(656), Tests 12521 passed, 25 skipped (12546)
- `pnpm --filter @objectstack/rest --filter @objectstack/runtime
typecheck`: exit 0, and `check:test-typecheck: OK` on both
</details>
<details><summary>Ablations (each restored with git checkout
HEAD)</summary>
- Draft-arm judge removed (the plain-read-only route), final head: REST
20 failed of 437, runtime 20 failed of 443. All failures are the
stored-draft guard pin, one per type, and the assertion bodies show the
gamma draft served at `_env`.
- Source restored to base `7213177e` (test files kept): REST 40 failed
of 437, runtime 40 failed of 443. Those are the flip pin (409 where 404
is pinned) and the guard pin's layered leg, 20 types each.
</details>
<details><summary>Local gate subset (dispatch-gates --commands, 83
families, final head)</summary>
- 82 exit 0. `check:engine-double-contract` was red at the first head,
because the `findOne` doubles did not route through the predicate. It is
fixed in this PR and exits 0.
- NOT MEASURED: `node scripts/check-plugin-teardown-shape.mjs
--self-test` exits 3. Its pinned positive-control commit `621a4876`
cannot be reached from this clone even after `git fetch --deepen=1500`.
CI runs it.
- `dispatch-gates --ran`: 83 derived, 83 run, 0 UNRUN.
- `overlap-check.mjs`: VERDICT clean, merging cleanly against
origin/main and against #38497, which shares the pinned ledger file.
</details>
Two-minute check: `pnpm --filter @objectstack/rest exec vitest run
--maxWorkers=2 src/meta-qualified-item-route.test.ts -t "answers its own
404"` should show 20 tests passing. Then revert the
`withholds(switches)` line in `meta-qualified-item-route.ts`: the
"stored draft" pins should go red, with the gamma draft served in the
assertion body.
Read first: `packages/rest/src/meta-qualified-item-route.ts`
`admitEnvironmentAddress` (the two-step judge),
`packages/runtime/src/domains/meta.ts` (the same judge and its call
site's `layeredView` choice), then the guard pin in either test file.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmRar3Kkg6SpwVgaaVE)_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01ADHkmRar3Kkg6SpwVgaaVE
<!-- signed: repo:objectstack#3 · os-steve ·
session_01ADHkmRar3Kkg6SpwVgaaVE -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 3fbcce2 commit f3028c5
6 files changed
Lines changed: 288 additions & 98 deletions
File tree
- .changeset
- packages
- rest/src
- runtime/src/domains
- scripts
| 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 | + | |
| 20 | + | |
| 21 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
85 | 88 | | |
86 | 89 | | |
| 90 | + | |
87 | 91 | | |
88 | 92 | | |
89 | 93 | | |
| |||
92 | 96 | | |
93 | 97 | | |
94 | 98 | | |
95 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
96 | 104 | | |
97 | 105 | | |
98 | 106 | | |
| |||
432 | 440 | | |
433 | 441 | | |
434 | 442 | | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
449 | 456 | | |
450 | 457 | | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
456 | 469 | | |
457 | | - | |
458 | | - | |
| 470 | + | |
459 | 471 | | |
460 | | - | |
| 472 | + | |
461 | 473 | | |
462 | 474 | | |
463 | | - | |
| 475 | + | |
464 | 476 | | |
465 | 477 | | |
466 | | - | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
467 | 510 | | |
468 | 511 | | |
469 | | - | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
470 | 523 | | |
471 | 524 | | |
472 | 525 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
62 | | - | |
| 63 | + | |
| 64 | + | |
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
| |||
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
74 | 89 | | |
75 | 90 | | |
76 | 91 | | |
| |||
79 | 94 | | |
80 | 95 | | |
81 | 96 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
87 | 104 | | |
88 | 105 | | |
89 | 106 | | |
90 | 107 | | |
91 | | - | |
| 108 | + | |
92 | 109 | | |
93 | 110 | | |
94 | 111 | | |
95 | 112 | | |
96 | 113 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
106 | 129 | | |
107 | 130 | | |
108 | 131 | | |
| |||
161 | 184 | | |
162 | 185 | | |
163 | 186 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
169 | 194 | | |
170 | | - | |
171 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
172 | 198 | | |
173 | | - | |
| 199 | + | |
174 | 200 | | |
175 | 201 | | |
176 | 202 | | |
| |||
0 commit comments