Repository navigation
refactor(runtime): errorFromThrown builds its answer from the one types composition - #31437
Conversation
…es composition HttpDispatcher.errorFromThrown composed the thrown-value answer term by term beside actionsDoorAnswerOf's arms. Both now read thrownAnswerOf (@objectstack/types, new export), so one composition serves every door; duplicateArmContext is gone with its only caller. A tie pin drives the dispatcher exit and the /actions door with the same throws and asserts equal responses. No wire change. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5nBSzc6ktJyjdFcDb3
📓 Docs Drift CheckThis PR changes 2 package(s): 4 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 1 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 36 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 a54616b6a6c912e5c6b4e16332f3a6b29f15a2c5 && git checkout a54616b6a6c912e5c6b4e16332f3a6b29f15a2c5
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin ae816c40b75f75ccbb8a512c3f17b36608df3ed4 b888858568bb542946f79ecb461d37391ce63c87 && git checkout -B drift-repro ae816c40b75f75ccbb8a512c3f17b36608df3ed4 && git merge --no-ff b888858568bb542946f79ecb461d37391ce63c87
node scripts/docs-audit/affected-docs.mjs --json ae816c40b75f75ccbb8a512c3f17b36608df3ed4
|
|
domain:server#3 · os-project-manager · session_01FEkQ5pXkgNXVpCn2GZDjyy 席位意见:ACCEPT · Head-sha 席位核对
|
Requested by Leehom · project thread
domain:server#3 · os-project-manager · session_01FEkQ5nBSzc6ktJyjdFcDb3
Fixes #31319
Clause-②: no (fold onto one composition, no wire change)
Metadata-protocol: none
维护者速读
HttpDispatcher.errorFromThrown,不再自己逐项拼(封闭 code、引擎唯一约束的线上拼写与上下文、降级的declaredCode、userMessage、5xx 泄露文本收回),改为调用@objectstack/types新导出的thrownAnswerOf;/actions门的读者actionsDoorAnswerOf的两个分支也用它。只剩一份组装。http-dispatcher.error-leak、dispatcher-5xx-demoted-code-withhold、package-door-error-parity、error-envelope.conformance)零改动全绿,runtime 全量测试全绿。@objectstack/types多一个公开导出。回滚即还原本 PR。packages/runtime/src/http-dispatcher.ts的errorFromThrown(由约 40 行缩为一次调用),packages/types/src/actions-door-answer.ts的thrownAnswerOf,packages/runtime/src/dispatcher-thrown-answer-tie.test.ts。pnpm --filter @objectstack/runtime exec vitest run src/dispatcher-thrown-answer-tie.test.ts(先 build@objectstack/types),预期 7 条全绿。What changes
@objectstack/types: newthrownAnswerOf(err, fallbackStatus)and itsThrownAnswertype (src/actions-door-answer.ts). It is the body of the old privatethrownAnswer(arms 3 and 7 ofactionsDoorAnswerOf), lifted out without the door's operator lines:status, the closedcode(the engine duplicate's ruled wire spelling read offstructuredCodeAnswer),message(leaky 5xx withheld),declaredCode(demotedDeclaredCode),userMessage,details(resolverissues/fieldsplus the duplicate arm's agreeing context).actionsDoorAnswerOf's arms 3 and 7 now return{ ...thrownAnswerOf(err, fallback), operatorLines }; its answers are unchanged.@objectstack/runtimeHttpDispatcher.errorFromThrown: buildsdeclaredCode/userMessageextra fromthrownAnswerOfand hands the answer tothis.error, which stays the one construction point for the envelope. The privateduplicateArmContexthelper is removed with its only caller (its job is thearmContextterm insidethrownAnswerOf), and the now-unused imports go with it. The method's docblock keeps its history; its one{@link duplicateArmContext}now namesthrownAnswerOf.Tests
packages/runtime/src/dispatcher-thrown-answer-tie.test.ts(7 rows), the tie pin. Each row throws the same value at the real/actionsdoor (HttpDispatcher.handleActions) and at the dispatcher exit (errorFromThrown, at the fallback the door's arm reads: 500 for a declared status, 400 for a rejection) and asserts equal{ status, body }, then states the term the row carries: the engine duplicate (UNIQUE_VIOLATION+object/fieldcontext), a producer merely speakingDUPLICATE_RECORD, an unregistered code demoted todeclaredCode, a leaky declared 503 withheld, auserMessage,issues, and a recordValidationError'sfields.Acceptance notes
dispatcher-plugin'serrorResponseBase(the exit for a throw that LEAVESdispatch()), whose docblock already declares that it does not carry the engine-duplicate translation. Out of this card's surface; unchanged.objectstack-issue-31319; this ran in the chain's existing worktreeobjectstack-issue-31317on the same claimed branch.origin/mainafter fix(types): /actions answers a driver string code as the /data door's fault #31397 merged; the merged branch had already been deleted on GitHub, so this is a new branch push, no force.Verification
Head
b8888585(basedb502314, the #31397 merge;origin/main383c3530merged once before opening).No wire change, suites
http-dispatcher.error-leak.test.ts,dispatcher-5xx-demoted-code-withhold.test.ts,package-door-error-parity.test.ts,error-envelope.conformance.test.tswith the new tie pin: Test Files 5 passed (5), Tests 118 passed (118).@objectstack/typesvitest: Test Files 38 passed (38), Tests 881 passed (881).@objectstack/runtimevitest (types from the rebuilt dist): Test Files 560 passed (560), Tests 10323 passed, 19 skipped; lock VERDICT command-exit 0. No existing pin edited.typecheckfor@objectstack/typesand@objectstack/runtime: exit 0.eslint --no-inline-config packages/types packages/runtime: exit 0.@objectstack/mcpnot re-run: its source is untouched,actionsDoorAnswerOf's answers are unchanged and the types change is an added export.Ablation of the tie pin (ablation-replace, restored to HEAD)
packages/runtime/src/http-dispatcher.ts:errorFromThrownmade to drop theuserMessageterm (&& String("ABL31319").length < 0on its spread), a hand-made drift at one exit. Mutation landed (anchor 1 to 0, blob fce6d0b6dc89 to 25ec094ea41b).dispatcher-thrown-answer-tie.test.ts: Tests 1 failed | 6 passed (7), theuserMessagerow,AssertionError: expected { status: 409, body: { …(2) } } to deeply equal { status: 409, body: { …(2) } }. The runtime suite reads its ownsrc/, so no dist leg.git diff HEADempty,git status --porcelainempty.Derived gates
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackatb8888585: 68 commands, each run withtimeout 1500and stdin from/dev/null, exit codes captured before any pipe, all exit 0 on the first run (after a@objectstack/runtimeclosure build).dispatch-gates --ran: 68 derived, 68 run, 0 NOT-MEASURED, 0 UNRUN. Plus the typechecks, scoped eslint and the two full suites above. Not run locally (CI):test:repo, dogfood shards, type-check lanes.Generated by Claude Code