Repository navigation
Commit 347adbd
test(rest): drop the registrar-file list's length pins from six rest tests (#26518)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XWY3q77HVXScL7HC17h5BrU)_
Fixes #26433
Part of #26431
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:`packages/rest` 里六个测试文件删掉了「注册器文件清单长度 =
18」这条手抄断言(`meta-draft-read-door-census.test.ts` 顺带删掉 `SITES` =
8),只改测试,不发布任何东西。
- 为什么改:清单本身就是权威;这条数字每次把一个路由模块拆出 `rest-server.ts`
都会让六个文件同时变红,钉的是树的转录,不是不变量(维护者在退役检查清扫里「同意」)。
- 风险与回滚:只删断言,每个文件原本要抓的缺陷都做了一次消融,仍然变红;回滚就是 revert 这一个 commit。
-
先看:`meta-draft-read-door-census.test.ts`(唯一加了防空守卫的文件)、`rest-server-docblock-position.test.ts`(还留着一个手算的楼层和
`70`,见 Acceptance notes)、`rest-server-canonical-query-ast.test.ts`。
- 两分钟验证:`pnpm --filter @objectstack/rest exec vitest run
src/meta-draft-read-door-census.test.ts
src/rest-server-docblock-position.test.ts`,预期 2 个文件全绿。
- 需要你做的:无,席位落地。
## What changes
- Six readers of `REST_SERVER_REGISTRAR_FILES` lose
`expect(REST_SERVER_REGISTRAR_FILES).toHaveLength(18)`:
`ui-view-route-identity.measurement.test.ts`,
`ui-view-route-tenancy.measurement.test.ts`,
`rest-server-canonical-query-ast.test.ts`,
`rest-server-query-number-census.test.ts`,
`meta-draft-read-door-census.test.ts`,
`rest-server-docblock-position.test.ts`. Each keeps iterating the list
it imports.
- `meta-draft-read-door-census.test.ts` also loses
`expect(SITES).toHaveLength(8)`: its first case ("the sites found are
exactly the ledgered ones") already holds the sum as an exact set
equality against the ledger. The case that held both pins is left with
only a list-mirroring assertion, which passes on an empty list, so it
gains the ruled anti-vacuity guard
`expect(REST_SERVER_REGISTRAR_FILES.length).toBeGreaterThan(0)`. No
other file goes vacuous on an empty list (measured below), so no other
guard is added.
- Prose the deletion made false is corrected in place, nothing more: the
four case titles that said "its length and … are pinned" now name only
what is still pinned, the header sentences that said a case "pins the
list's length" drop that clause, and each slice-history comment log gets
one closing `[#26433]` line. The `length N → M` history entries stay as
history.
## Why
The list file's own header says it is ⛔ not a gate and that each reader
stays the authority on what it counts. The length pin made every reader
red on every registrar move, for a number nobody derives anything from
(#26431's rule: a pin on something that already has an authority is
retired, not loosened).
## Tests
All runs on head `83cff86f77` (base `45de8c6cba`), rest's dependency
closure built first (`pnpm --filter '@objectstack/rest^...' build`, lock
VERDICT exit 0).
- The six files: `Test Files 6 passed (6)`, `Tests 223 passed | 18
skipped`.
- `pnpm --filter @objectstack/rest test` (project `local`): `Test Files
324 passed (324)`, `Tests 6483 passed | 326 skipped`, VERDICT exit 0.
- `pnpm --filter @objectstack/rest test:repo` (project `repo`, which
holds `rest-server-canonical-query-ast.test.ts`): `Test Files 5 passed
(5)`, `Tests 280 passed | 18 skipped`, VERDICT exit 0.
- `pnpm --filter @objectstack/rest typecheck` (tsc plus
`check:test-typecheck` over `tsconfig.test.json`, which includes
`*.test.ts`): VERDICT exit 0.
- Acceptance grep: `git grep -n "REGISTRAR_FILES).toHaveLength" --
packages/rest` → no hit, exit 1.
<details><summary>Each file still reds on the defect it was written for
(one ablation per file, via scripts/ablation-replace.mjs; every mutation
landed and was restored to the HEAD blob)</summary>
The six tests read route sources as text from `src/` or mount
`RestServer` from `src/` by relative import, so no `dist/` sits on the
path and no rebuild is owed per leg. Each ablation mutates a moved route
module (not `rest-server.ts`), so it also proves the reader still
reaches files off the list.
| File | Ablation (route module) | Result |
|:--|:--|:--|
| `ui-view-route-identity.measurement.test.ts` | delete `if
(this.enforceAuth(req, res, context)) return;` in `ui-routes.ts` | 1
file failed: "the handler now calls `enforceAuth` — read off the mounted
registrar…" |
| `ui-view-route-tenancy.measurement.test.ts` | delete the
`enforceEnvironmentOwnership(...)` line in `ui-routes.ts` | 1 file
failed, 11 cases, including "⭐ the registrar body itself carries the
three steps" and "⭐ THE PIN" |
| `rest-server-canonical-query-ast.test.ts` | `where: { id: jobId }` →
`filter: { id: jobId }` in `data-action-routes.ts` | 1 file failed: "no
server-built `query` literal spells a wire alias" |
| `rest-server-query-number-census.test.ts` | add a bare
`Number(req.query.zzAbl)` in `search-routes.ts` | 1 file failed: "no
coercion is unclassified…" and the sum case (`sites` 8 → 9) |
| `meta-draft-read-door-census.test.ts` | add `req.query?.state ===
'draft'` in `search-routes.ts` | 1 file failed: "the sites found are
exactly the ledgered ones" (so dropping `SITES` 8 loses nothing) |
| `rest-server-docblock-position.test.ts` | stack a TSDoc block above
another in `email-routes.ts` | 1 file failed: "binds every TSDoc block
to a declaration — none is stacked above another" |
Every leg: `ablation-replace: ok mutation landed: anchor 1 -> 0`, then
`ok restored: blob == HEAD … and git diff HEAD is empty`. (In a first
pass the tool refused five of the six legs before any test ran, because
each anchor was a substring of its own replacement or was not deleted;
the canonical leg ran in that pass and red as it does in the table. All
six were rerun with non-overlapping anchors or `--delete`, and the table
is that rerun.)
</details>
<details><summary>Dry move: a new registrar module appended to the list
(the point of the change)</summary>
Probe: a new `zz-dry-move-routes.ts` (module header and `export {};`, no
route body) appended to `REST_SERVER_REGISTRAR_FILES`, list length 19.
All legs restored; final `git diff HEAD` empty, `git status` clean.
| Leg | Result |
|:--|:--|
| base test files (pins in) | `Test Files 6 failed (6)`: each of the six
reds on its `toHaveLength(18)` line |
| this head | `Test Files 2 failed / 4 passed`: identity, tenancy,
query-number and meta-draft stay green.
`rest-server-canonical-query-ast` and `rest-server-docblock-position`
red because their per-file floor tables (`REGISTRAR_QUERY_SLOT_FLOORS`,
`MOVED_FILE_FLOORS`) have no row for the new module |
| this head plus the two floor rows the module would owe (`0` and `1`) |
`Test Files 1 failed / 5 passed`: only `rest-server-docblock-position`'s
`expect(…minBlocks sum).toBe(70)` reds |
So on this head a new module costs the list file plus its own floor row
in two tables, plus the docblock file's `70`. The floor rows are
per-file measurements the two censuses ask for by design ("a file the
split adds to the list needs a floor here before this census reads it"),
not length transcriptions, and the ruling keeps them. The `70` is a hand
sum of the table beside it: see Acceptance notes.
</details>
<details><summary>Empty list: no reader goes vacuous</summary>
`REST_SERVER_REGISTRAR_FILES` emptied in place (`].filter(() =>
false);`), restored after: `Test Files 6 failed (6)`, 11 cases. Each
file reds on an assertion it already had (identity and tenancy on the
over-40 call counts, canonical on the floors' keys and the slot sum,
query-number on its sum and positive control, docblock on the floors'
keys), and meta-draft's list case reds on the new guard
(`meta-draft-read-door-census.test.ts:291`).
</details>
## Verification
<details><summary>Local gate subset: 49 derived, 48 run exit 0, 1 NOT
MEASURED</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` on this diff named 49 commands; each was run
with its exit code captured before any pipe, then reconciled with
`--ran`: `✓ dispatch-gates --ran: 49 derived famil(ies) accounted for —
48 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3)`.
- NOT MEASURED: `pnpm check:dual-build-cjs-loads`, exit 3 PREREQUISITE
NOT MET (needs every package's `dist/`; only rest's closure is built
here). CI runs it.
- Lint scoped to the touched package: `eslint packages/rest
--no-inline-config` exit 0.
- Not run locally, CI's: the repo-wide `pnpm lint`, Test Core shards,
the type-check lanes, dogfood (no `!` in the title, no `(narrowing)`
arm).
</details>
`skip-changeset`: tests only. Nothing under `packages/rest` that ships
in `files[]` changes.
## Acceptance notes
- **Seventh copy, not in this PR:**
`packages/qa/dogfood/test/authz-conformance.test.ts:1646` on
`origin/main` `b7f2b0c290`
(`expect(REST_SERVER_REGISTRAR_FILES).toHaveLength(18)`; it sat at 1642
before PR #26491 landed in that file) is `domain:devx`'s; the seat files
its child card.
- **Same pin under an alias:**
`packages/rest/src/execctx-consumer-census.test.ts:848` pins
`expect(SITE_FILES).toHaveLength(18)`, where `SITE_FILES =
REST_SERVER_REGISTRAR_FILES` (line 149). The card's acceptance grep does
not see it. That file is #26436's; it belongs on that card.
- **Hand sum beside its own table:**
`rest-server-docblock-position.test.ts:301`,
`expect(MOVED_FILES.reduce(…)).toBe(70)` is the sum of
`MOVED_FILE_FLOORS` in the same file, and it is the one red left in the
dry move once the new module has its floor row. Same family as #26431;
left alone here because the ruling says nothing else changes.
- **Header prose now partly false:**
`rest-server-registrar-files.ts:23-26` still says each reader "pins the
list's `length`". After this PR that is true only of the dogfood copy
and the `execctx` alias above. The file is outside this card's file
surface; whichever of those two cards removes the last pin should reword
it.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01FEkQ5nSKhKswuL33xRZZ3g)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent 42ec951 commit 347adbd
6 files changed
Lines changed: 22 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
239 | | - | |
| 239 | + | |
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
288 | | - | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
289 | 292 | | |
290 | | - | |
291 | 293 | | |
292 | 294 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| |||
403 | 403 | | |
404 | 404 | | |
405 | 405 | | |
406 | | - | |
| 406 | + | |
407 | 407 | | |
408 | 408 | | |
409 | 409 | | |
| |||
425 | 425 | | |
426 | 426 | | |
427 | 427 | | |
428 | | - | |
| 428 | + | |
429 | 429 | | |
430 | 430 | | |
431 | 431 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
| 144 | + | |
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| |||
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
275 | | - | |
| 275 | + | |
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
298 | | - | |
| 298 | + | |
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
75 | | - | |
| 74 | + | |
| 75 | + | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| |||
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
306 | | - | |
| 306 | + | |
307 | 307 | | |
308 | 308 | | |
309 | 309 | | |
| |||
355 | 355 | | |
356 | 356 | | |
357 | 357 | | |
358 | | - | |
| 358 | + | |
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
88 | | - | |
| 87 | + | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| |||
400 | 400 | | |
401 | 401 | | |
402 | 402 | | |
403 | | - | |
| 403 | + | |
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
109 | | - | |
| 108 | + | |
| 109 | + | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| |||
1177 | 1177 | | |
1178 | 1178 | | |
1179 | 1179 | | |
1180 | | - | |
| 1180 | + | |
1181 | 1181 | | |
1182 | 1182 | | |
1183 | 1183 | | |
| |||
0 commit comments