Repository navigation
fix(types, rest): element-check a package-scoped refusal's candidates; pin the cross-object batch and a census door - #33606
Conversation
…he cross-object batch and the package door The rest door's candidates read cast the shared recogniser's readonly unknown[] to core's holder type. Each element is now checked against the four holder kinds; a list with any element that is not a holder is answered as no list. Pins the cross-object POST /batch's details.candidates and the package publish door's (a census door). Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cz4f7zEQZ2C9GTG382
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cz4f7zEQZ2C9GTG382
…recogniser Measured: with the check in the rest door only, a malformed candidates list was withheld by createMany, the cross-object batch and the /meta reads but still echoed by the single-record /data doors, the per-row errors and the resolver's doors. The check now lives in packageScopedRefusalCandidates, which answers its list typed as holders, so every door reads one rule and the rest door drops its cast. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cz4f7zEQZ2C9GTG382
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cz4f7zEQZ2C9GTG382
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cz4f7zEQZ2C9GTG382
📓 Docs Drift Check3 anchor(s) derived from 2 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. What this run could not see
Coarse fallback — 27 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 2e710ba6a9e66751a4ecaaaf430f61ebaa72cc8d && git checkout 2e710ba6a9e66751a4ecaaaf430f61ebaa72cc8d
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin c32bb6ccbb293a4bda77010ce7ad416fcfeb1138 8f3bfc202c91986f94994dfc0974d842dea45603 && git checkout -B drift-repro c32bb6ccbb293a4bda77010ce7ad416fcfeb1138 && git merge --no-ff 8f3bfc202c91986f94994dfc0974d842dea45603
node scripts/docs-audit/affected-docs.mjs --json c32bb6ccbb293a4bda77010ce7ad416fcfeb1138 |
|
domain:server#5 · os-elon-musk · session_016WV4cz4f7zEQZ2C9GTG382 Area notes for the reviewer:
|
|
Contract-review-claim: session_016WV4d1PGptBW3QRQNmy5e6 · head 8f3bfc2 · 2026-11-15T02:34Z review#3. |
Review — PASSHead-sha: Read: the PR's three commits on top of (1) The check belongs in
(2)
The pins measure what they claim.
Nits (none blocks).
Folded #32761 was measured and not fixed. Sending it to the loose-ends card at landing is right: its TO is a decision, and the fix reaches metadata-protocol (lease E1). Reviewed-by: |
|
domain:server#5 · os-elon-musk · session_016WV4czrwT7WKAde95kC4cg
|
Requested by Elon · project thread
Fixes #32744
Clause-②: no
Metadata-protocol: none
domain:server#5 · os-elon-musk · session_016WV4cz4f7zEQZ2C9GTG382 (area-lease pilot #33059, area E2b)
维护者速读
packageScopedRefusalCandidates现在逐个检查候选元素的形状,只有每个元素都是四种持有者之一时才回答details.candidates,rest 不再做裸类型转换;另外给跨对象POST /batch和包发布门补上候选列表的回归钉。createMany拦下、却被单条/data写和批量行错误原样回显,所以校验放进各门共用的识别器。packages/types/src/thrown-http-error.ts的packageScopedRefusalCandidates与新的元素校验;packages/rest/src/error-response.ts去掉强制转换的那一处;packages/rest/src/rest-batch-endpoint.test.ts末尾新增的 describe。pnpm --filter @objectstack/rest exec vitest run src/rest-batch-endpoint.test.ts,预期 32 例全过(其中 10 例为本 PR 新增)。Clause-②: no对畸形列表这一角的判定(见 Acceptance notes),其余无,席位落地。What changes
POST /batchcarriesdetails.candidates: pin only. The route already passes the candidates option (batch-routes.ts); PR feat(types, rest, metadata-protocol)!: a package-scoped refusal names its candidates on every /data write door #32740 left it NOT MEASURED because the sqlite harness has no transactional batch. Pinned inrest-batch-endpoint.test.ts(the route's own harness, transactional engine double): the class and a plain error of its shape, thrown by a create op and by an update op, answer409 RESOURCE_CONFLICTwitherror,codeanddetails.candidates; aRESOURCE_CONFLICTwith no refusal answers nodetails.packageScopedRefusalCandidates(@objectstack/types) checks each element of the refusal's list against the four kinds of core'sPackageScopedHolder(packagewith a stringpackageId,environment,platform,residualwith a stringownerId) and answers the list typed as those holders; a list with any element that is not a holder is answered as no list, as a non-array already was.error-response.tsassigns the answer to core's type with no cast, so the compiler now checks the two shapes line up.POST /packages/publish(package-routes.ts, a door the resolver'sdetailsreaches) answers a thrownPackageScopedNameRefusedErrorwith409 RESOURCE_CONFLICTanddetails.candidates, in a valid ADR-0112 envelope. Pinned inpackage-door-declared-code.test.ts.data-package-scoped-refusal-candidates.test.tsnow points at the new pin.Why item 2 is in
@objectstack/types, not only inpackages/rest. I first wrote the check in the rest door alone, then measured it on the sqlite harness (heada645d6627): a refusal of the class's shape withcandidates: ['bad']answered with nodetailsoncreateMany, butdetails.candidates: ['bad']on singlePOST/PATCH /data/:object, on theupdateManyand/:object/batchrow errors, and on thestatusCode: 409spelling of the same refusal atcreateMany(which takesmapDataError, not the rest passthrough). A rest-only check would have made the doors disagree. The card's other option, narrowing the recogniser's return type, keeps them on one rule.One answer moves, and only for a refusal no framework producer throws. FROM
details.candidatesechoing a list that holds a non-holder element TO nodetails.candidatesmember, on every door that reads the recogniser. Status,codeand the sentence stay the same. DeclaredClause-②: no: the published member is documented as holders, and every holder core constructs passes. A reviewer who reads this corner as a narrowing should switch the line toClause-②: no (narrowing)(see Acceptance notes).Tests
rest-batch-endpoint.test.ts: new top-level describe, 10 cases (3 for item 1, 1 four-kinds positive, 5 malformed lists, 1 control).package-door-declared-code.test.ts: new section 6, 1 case (item 3).thrown-http-error.test.ts(@objectstack/types): 2 cases: the four kinds pass on the recogniser, the resolver andmapDataError; five malformed lists answer no candidates on the recogniser, the resolver,thrownAnswerOfandmapDataError, while status and code stay409 RESOURCE_CONFLICT.Red before, green after (item 2), through
dist/. With the element check replaced by a pass-through inpackages/typessource, rebuilt, and the marker found inpackages/types/dist/index.jsandindex.mjsbyablation-dist-preflight, 5 of the 32 rest batch cases fail (the 5 malformed lists) and 1 of the 16 types cases fails. Then the source was restored (blob equal to HEAD,git diff HEADempty), rebuilt, and the marker was confirmed absent. Items 1 and 3 are pin only: the behaviour they pin already shipped in PR #32740, so this PR does not ablate them.Acceptance notes
nobecause no framework producer can cause the move. The alternative isno (narrowing), which brings a BREAKING banner, an ADR-0087 marker and a full dogfood run. Both lines are in the PR body and the changeset, so a switch only edits those two places.packages/rest/src/**. Item 2's fix is one function inpackages/types/src/thrown-http-error.ts(and its test), for the door-agreement reason above. Nothing underpackages/metadata-protocol/src/**orpackages/rest/src/analytics-*is touched.httpStatus: null#32761, measured onmainbehaviour (heada645d6627; the NaN path is unchanged by this PR), not fixed here. AbeforeInsert/beforeUpdatehook throwing{ code: 'MY_REFUSAL', status: NaN }: whole-request doors (POST,PATCH /data/:object,createMany) answer500 { error: 'Internal server error', code: 'INTERNAL_ERROR' }; per-row doors (updateMany,/:object/batchupdate) answer207with row error{ code: 'VALIDATION_ERROR', message: 'The update of this record failed. The reason is in the server log.', httpStatus: null }. The same throw withstatus: Infinitygets the same whole-request answer, and its row error is{ code: 'INTERNAL_ERROR', …, httpStatus: null }.statusCode: NaNreads the same asstatus: NaN. So the card's defect reproduces: a row shipshttpStatus: null, and the row'scodediffers between NaN and Infinity while the whole-request door answers both the same way. Choosing the TO (item 2 of metadata-protocol + types: a batch row error whose throw declares a non-finite status shipshttpStatus: null#32761) is a decision the card leaves open, and the fix sits in@objectstack/types' resolver and intoRowApiError(packages/metadata-protocol, E1's lease). It is listed for a split-out card, not done here.@objectstack/clientstale comment aboveerror.details = …(outside the leased surface), the jsdoc wording nits, and the rename of the CONTROL describe that holds the NaN per-row cases. These are listed for the seat.Verification
Local runs (heads `38ef56b8d` and `8f3bfc202`)
At
38ef56b8d:pnpm --filter @objectstack/types test: Test Files 39 passed (39), Tests 909 passed (909).pnpm --filter @objectstack/rest typecheck: exit 0.pnpm --filter @objectstack/metadata-protocol typecheck: exit 0 (it imports the recogniser).pnpm --filter @objectstack/rest test: Test Files 411 passed (411), Tests 8404 passed, 332 skipped (8736).dispatch-gates.mjs --commands, 65 commands): 63 exit 0.check:test-source-aliasexited 1: the edited batch suite reached@objectstack/objectqlonly through a dynamic import.8f3bfc202adds the module-top import the gate asks for, and the gate then exits 0.check:dual-build-cjs-loadsexited 3 (PREREQUISITE NOT MET: no fullpnpm buildin this worktree), so it is NOT MEASURED locally and left to CI.--ranreconciliation: 65 derived, 64 run, 1 NOT-MEASURED, 0 UNRUN.At
8f3bfc202(a one-line test import on top of the above):rest-batch-endpoint.test.tsandpackage-door-declared-code.test.ts: Test Files 2 passed (2), Tests 66 passed (66).check:test-source-alias,check:undeclared-dep-imports,check:cross-package-test-inputs,check:engine-double-contract,check:rest-log-spy-declared,check:nul-bytes,check:tier-file-adoption: each exit 0.eslint --no-inline-configon the six touched source and test files: exit 0.🤖 Generated with Claude Code