Repository navigation
fix(types): /actions answers a driver string code as the /data door's fault - #31397
Conversation
… fault actionsDoorAnswerOf read a status-less throw carrying a driver errno (SQLITE_BUSY, ECONNREFUSED) as a 400 VALIDATION_ERROR rejection with the errno in declaredCode, where /data answers 500 DATABASE_ERROR. A new arm asks mapDataError whenever the code would be demoted off the closed vocabulary, and serves that door's fault when it reads one. Closed codes, bare Errors and sandboxed coded refusals keep the 400 rejection. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5nBSzc6ktJyjdFcDb3
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5nBSzc6ktJyjdFcDb3
…n the driver-code pin Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5nBSzc6ktJyjdFcDb3
📓 Docs Drift Check1 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 — 22 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 39f538d11543333d253adc6c85e423145d4140df && git checkout 39f538d11543333d253adc6c85e423145d4140df
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 77a675db1a2daf3e1f33357e147098e450788fd9 0b36be09cfe348b3fe525df43262903d52b674ed && git checkout -B drift-repro 77a675db1a2daf3e1f33357e147098e450788fd9 && git merge --no-ff 0b36be09cfe348b3fe525df43262903d52b674ed
node scripts/docs-audit/affected-docs.mjs --json 77a675db1a2daf3e1f33357e147098e450788fd9 |
|
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 #31317
Clause-②: no (a driver fault inside an action body moves from 400 VALIDATION_ERROR to the 5xx fault /data already answers: a status/code correction on an error answer, not a widening; measured from the real diff, no accepted input and no success shape changes)
Metadata-protocol: none
维护者速读
SQLITE_BUSY、ECONNREFUSED)且没有声明 HTTP 状态时,POST /api/v1/actions现在回/api/v1/data同样的服务器故障(SQLITE_BUSY是500 DATABASE_ERROR/Internal data error),不再回400 VALIDATION_ERROR并把驱动 code 放进declaredCode。MCP 的run_action/resume_run跟着/actions一起变。/actions把驱动名和驱动原文暴露给了调用方;重试、告警、网关错误率都看不到这类故障。/data判为 5xx」这一类;封闭 code(RECORD_LOCKED等)、裸Error、带状态的抛错、沙箱动作体的带 code 拒绝都照旧是 400(有对照 pin)。代价:进程内动作处理器抛自造 code 且不带状态,会变成 500 并丢 code([Decision] Is ADR-0112'sdeclaredCodechannel in scope for 5xx sanitisation at all — and the answer must be applied to all three doors at once #12509 裁决的既定代价,带上状态即可保留)。runtime 559 个测试文件、mcp 60 个、types 38 个全绿。回滚即还原本 PR。packages/types/src/actions-door-answer.ts新增的 Arm 6(判定只用demotedDeclaredCode+/data的mapDataError,不另抄一份),packages/runtime/src/domains/actions-driver-code-fault-parity.test.ts,packages/mcp/src/mcp-coded-refusal.test.ts改动的那一行。pnpm --filter @objectstack/runtime exec vitest run src/domains/actions-driver-code-fault-parity.test.ts(先 build@objectstack/types),预期 7 条全绿;其中 3 条在 main 上是红的(expected 400 to be 500)。What changes
@objectstack/typesactionsDoorAnswerOf: a new arm between the unexpected-fault arm and the 400 rejection. When a throw that declared no status spells a.codethat is not a closed ADR-0112 code, it asks the/datadoor's own classifier,mapDataError(err, objectName), and when that door answers a server fault (isServerFault),/actionsanswers that door's status, code and sentence. Nothing the throw carried rides along (nodeclaredCode, nodetails); the full text is logged as adriver fault (CODE): …operator line.demotedDeclaredCode(resolveThrownHttpError(err, 400)) !== undefined(@objectstack/typesthrown-http-error.ts). It is the read that put the driver spelling into/actions'declaredCode, and it is present exactly when the code is not a closed vocabulary member. A closed code (RECORD_LOCKED,PERMISSION_DENIED) is not demoted, so it stays the rejection. The fault/refusal decision itself ismapDataError(data-error-classification.ts) plusisServerFault(server-fault-log.ts), the reads/dataanswers with. ⛔ No copy of either./actions-vs-/datadifference is removed, since the difference is gone.@objectstack/mcp: comment only.errorResultFromThrown'sactionsDoorAnswerOf./actionsand MCPrun_actionbefore/data){ code: 'SQLITE_BUSY' }, textSQLITE_BUSY: database is locked400 VALIDATION_ERROR, the driver text,declaredCode: SQLITE_BUSY500 DATABASE_ERROR,Internal data errorSqliteError{ code: 'ECONNREFUSED' }, textconnect ECONNREFUSED 127.0.0.1:5432400 VALIDATION_ERROR, the text,declaredCode: ECONNREFUSED500 INTERNAL_ERROR,Internal server errorRECORD_LOCKED)400 RECORD_LOCKEDError400 VALIDATION_ERROR, its sentence409 RESOURCE_CONFLICT,declaredCode400 VALIDATION_ERROR,declaredCode(/dataanswers 400 too)Tests
packages/runtime/src/domains/actions-driver-code-fault-parity.test.ts(7 rows): §1 three driver rows, one row per door. Each asserts the literal/actionswire answer through the realHttpDispatcher.handleActions, its equality withmapDataErroron a fresh copy of the throw, no driver spelling or text anywhere in the body, and the operator line. §2 the four controls above.packages/types/src/actions-door-answer.test.ts: the driver-string-code row moved from the old 400 answer to the fault answer with its operator line.packages/mcp/src/mcp-coded-refusal.test.ts: the mcp: run_action and resume_run answer a code-less sandboxed action-body throw with the wrapper naming the body, where /actions answers 400 HOOK_ABORTED with the sentence #31271SQLITE_BUSYcase onrun_action/resume_runmoved to500 DATABASE_ERRORwith one operator log line; its block comment updated. The row still asserts equality withactionsDoorAnswerOfon a fresh copy.Acceptance notes
/dataalso answers as a fault, now gets the fault here and loses the code: the 2026-08-27 ruling on [Decision] Is ADR-0112'sdeclaredCodechannel in scope for 5xx sanitisation at all — and the answer must be applied to all three doors at once #12509 (the discriminator is the status channel, never the code's spelling). It keeps its code by declaring the status it means. Measured for real callers: the runtime (559 files), mcp (60) and types (38) suites are green with no pin edited beyond the two above;SANDBOX_AUTHORED_LIMB(DUPLICATE, sandboxed) is untouched because/dataanswers sandboxed coded refusals 400; the sister repo hotcrm's coded refusals all declare a status (src/sales/objects/_refusal.ts). No caller found for whom the 400 reading is load-bearing./dataanswers several of these as 500 (VALIDATION_ERROR,RECORD_LOCKED,CONFLICTwith no status),/actionskeeps its 400 with the code, per the order (only the driver-fault class moves). That remaining difference is noted, not filed.No handler registeredthrow inaction-execution.ts. That throw has nocode, so the new arm never reads it; whoever lands second merges main and re-reads the other's pins.31271changeset says the driver-code difference between/actionsand/datais not changed; this PR's changeset supersedes that sentence and does not edit it.Verification
Head
0b36be09(basef4b4c8ae,origin/maineff90af6merged once before opening).Red first, fix, suites
f4b4c8ae(mapDataErrorvsactionsDoorAnswerOf, scratch, not committed):SQLITE_BUSY: database is lockedanswered/data500 DATABASE_ERRORand/actions400 VALIDATION_ERROR+declaredCode: SQLITE_BUSY;ECONNREFUSEDand57P01the same split with/data500 INTERNAL_ERROR. Closed codes with no status (RECORD_LOCKED,PERMISSION_DENIED,VALIDATION_ERROR), a bareErrorand a sandboxedCREDIT_LIMITanswered/actions400 with their own code.actions-driver-code-fault-parity.test.tsTests 3 failed | 4 passed (7),AssertionError: expected 400 to be 500(the three §1 rows; §2 controls green). With the fix: 7 passed.@objectstack/typesvitest: Test Files 38 passed (38), Tests 881 passed (881).@objectstack/runtimevitest (types from the rebuilt dist): Test Files 559 passed (559), Tests 10316 passed, 19 skipped. No runtime/actionspin edited.@objectstack/mcpvitest: Test Files 60 passed (60), Tests 872 passed (872).typecheckfor@objectstack/types,@objectstack/runtime,@objectstack/mcp: exit 0 (runtime re-run on0b36be09).eslint --no-inline-config packages/types packages/runtime packages/mcp: exit 0; the edited test file re-run on0b36be09: exit 0.Ablation (ablation-replace, restored to HEAD)
packages/types/src/actions-door-answer.ts: the new arm'sif (isServerFault(door.status)) {made never-true (&& String("ABL31317").length < 0). Mutation landed (anchor 1 to 0, blob e90d4eecf361 to 79160314fb55);pnpm --filter @objectstack/types build;ablation-dist-preflight @objectstack/types ABL31317: marker present indist/index.jsanddist/index.mjs. Runtimeactions-driver-code-fault-parity.test.ts: Tests 3 failed | 4 passed (7),expected 400 to be 500.git diff HEADempty,git status --porcelainempty; rebuilt types, preflight--absent: marker absent from all 12 built files; the pin 7 passed.Derived gates
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackatf8f57861: 66 commands, each run withtimeout 900, exit codes captured before any pipe. First pass: 64 exit 0;check:dual-build-cjs-loadsexit 3 (prerequisite: not every dist built yet);check:test-source-aliasexit 1 (the new pin reached@objectstack/metadata's lazy import through the dispatcher; fixed in0b36be09with a module-top import). Re-run on0b36be09:check:test-source-aliasexit 0,check:dual-build-cjs-loadsexit 0.dispatch-gates --ran: 66 derived, 66 run, 0 NOT-MEASURED, 0 UNRUN. Plus the three package typechecks and the scoped eslint above. Not run locally (CI):test:repo, dogfood shards, type-check lanes.Generated by Claude Code