Skip to content

feat(spec,runtime): hook refusals on handler hooks, with declared reasons and params - #33641

Merged
objectstack-fleet[bot] merged 25 commits into
mainfrom
claude/issue-33214-handler-hook-refusals
Nov 15, 2026
Merged

objectstack-fleet[bot] merged 25 commits into
mainfrom
claude/issue-33214-handler-hook-refusals

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #33214

Clause-②: yes
Metadata-protocol: added
Skills-docs: follow-up #33658 — skills/objectstack-data/references/data-hooks.md (the "Declared refusals (refusals)" section teaches a sandboxed body only, one sentence per code, no params), skills/objectstack-i18n/SKILL.md (the hooks.HOOK.refusals.CODE.message row has no reasons key)

维护者速读

  • 改了什么:用 TypeScript handler 写的 hook 现在也能声明 refusals(拒绝目录)。一个错误码下可以登记多句话(reasons),每句话可以带参数(params)。中文用户看到中文,线上的错误码不变。
  • 为什么改:下游应用的业务拦截全写在 TS handler 里,平台以前只给沙箱 js body 翻译拒绝提示,所以 zh-CN 用户读到的是英文。按裁决 6879477573(问一 A、问二 S1、问三 是)落地。
  • 风险与回滚:没声明 refusals 的 hook 两条路径都不受影响;声明了 refusals、但没用新功能的 hook,线上信封与改动前逐字节相同(有对比测试钉住)。新增的进程内拦截只在声明了 refusals 的 handler 上启用。回滚 = revert 本 PR。
  • 先看:packages/runtime/src/sandbox/hook-refusal-catalogue.ts(进程内应答与宿主错误标记)、packages/runtime/src/sandbox/body-runner.ts 的 withInProcessHookTitle、packages/spec/src/data/hook.zod.ts 的 refuseUndeclaredLiteralRefusalCode。
  • 两分钟验证:pnpm --filter @objectstack/verify exec vitest run src/harness.hook-refusal-door.test.ts,预期 2 个测试通过:源码启动(handler 进程内运行)与产物启动(沙箱 body)在 Accept-Language: zh-CN 下返回逐字节相同的中文拒绝信封。
  • 需要你做的:无,席位落地。

What changes

Under maintainer ruling 6879477573 (问一 A · 问二 S1 · 问三 是, inside ruling 6431311681 letter A), a hook's refusal catalogue is answered on every path the hook runs on, and an entry can hold several declared sentences with parameters.

  1. refusals on a handler hook (packages/spec/src/data/hook.zod.ts, hook-refusal-codes.ts). The schema accepts refusals on a hook whose handler is an inline function or a string reference. It reads an inline handler's literal throws off its source, the same text the build's lowering peels, and refuses an undeclared code or reason there, at handler. A js body still wins over a handler, as at bind. Still refused: an expression body, or neither a body nor a handler.
  2. The in-process seam answers the catalogue (packages/runtime/src/sandbox/body-runner.ts withInProcessHookTitle, wired at packages/runtime/src/app-artifact-handlers.ts with hook and options.i18n). For a hook that declares refusals, the seam hands the handler ctx.api, ctx.ql and ctx.title as host surfaces that mark every error a host call raises, and answers the handler's own throw through resolveInProcessHookRefusal (hook-refusal-catalogue.ts), which builds the same SandboxError the body path builds. A marked host error, a SandboxError and a crash pass through unchanged. A callback the handler hands a host call (a transaction body) stays the handler's: what it throws is the handler's refusal. A hook with no catalogue runs exactly as before; the seam's old call shape (a hook name) is unchanged.
  3. reasons (S1): refusals.CODE.reasons.REASON.message, with snake_case reasons. The hook throws { code, reason } and is answered with the reason's sentence, the entry's status and the unchanged wire code. An undeclared reason is refused loudly: at save when literal, otherwise as a 500 naming the hook, the code and the reason. The translation key is hooks.HOOK.refusals.CODE.reasons.REASON.message (translation.zod.ts, hookRefusalMessageKey(hook, code, reason?)). The i18n walk counts each reason (packages/lint/src/i18n-walk.ts), and os validate refuses a reason key the code does not declare (packages/lint/src/validate-translation-references.ts).
  4. params: the entry declares names, and its sentences may hold double-brace holes over those names only. A hole over an undeclared name is refused at save by the closed-scope judge the action copy slots use (closedScopeTemplateRefusal). An entry with no params stays plain text and every hole in it is refused, as before. The runtime fills the picked (translated or declared) sentence from the throw's params through the formula template engine the flow end refusal renders with, with only declared names in scope. params and reason cross the QuickJS __errorInfo channel, kept off SandboxErrorInfo and the wire (sandboxRefusalAddressOf, quickjs-runner.ts).
  5. The translation.zod.ts hooks docblock's "no hole is filled" sentence is corrected. Docs: content/docs/automation/hooks.mdx gains a "Refusing in the user's language" section; content/docs/ui/translations.mdx and content/docs/protocol/kernel/i18n-standard.mdx gain the reasons key.

Generated and ledger files moved with it: api-surface, export-origins, authorable-surface, the reference docs, the strictness ledger counts, liveness rows (hook/refusals.reasons, hook/refusals.params, translation/hooks.refusals.reasons), and dropped-refinements.baseline.json (the hole rule is now a refinement, because it depends on params, so data/HookRefusal is declared there).

Tests

  • packages/spec/src/data/hook-refusals.test.ts: handler accept/refuse, reasons accept/refuse, literal reason reading, params holes. 96 pass.
  • packages/runtime/src/sandbox/hook-refusal-catalogue.test.ts: body-path reasons and params; a byte-identical envelope pin for a hook using none of the new parts, whose literal was measured on the base commit e540baf with the base's three runtime files checked out; the in-process seam's wire against the body path's, zh-CN, faults, crash and host-raised pass-through (ctx.api, ctx.ql, inside a transaction callback), and the untouched no-catalogue hook. 36 pass.
  • packages/verify/src/harness.hook-refusal-door.test.ts: bootStack(config) (in-process handler) against the artifact door (sandboxed body) under Accept-Language: zh-CN; the two envelopes are byte-identical. 2 pass.
  • packages/cli/test/i18n-hook-refusal-coverage.test.ts (reasons harvested, demanded, scaffolded; 10 pass), packages/cli/test/lower-callables.test.ts (the build lowering keeps the catalogue and is judged on the lowered body; 31 pass), packages/lint/src/validate-translation-references.test.ts (reason translation targets; 241 pass).

Acceptance notes

  • Studio hook form: filed Studio: the hook form offers a refusal as message + status only, so it cannot author the refusals.CODE.reasons and params that #33214 adds #33657. The form offers a refusal as message + status only, so it cannot author reasons / params (the dev's open question 2, answered A by record 6889389473).

  • A hook that already declares refusals and also throws an unrelated string reason property is now judged on that reason: an undeclared one is a 500 fault. Before this change a reason field was not read.

  • On the in-process path, the host surfaces are proxies only for a hook that declares refusals. A method is called on the object the proxy fronts, and anything the handler hands back to a host call is unwrapped first.

  • The published JSON Schema no longer carries the hole pattern on a refusal message (now a refinement; declared in dropped-refinements.baseline.json).

Verification

Measured at head 68aca57b (after one merge of origin/main, 9f736f2e), in this cloud container.

Ablations, one per new pin (each mutation proven on disk by scripts/ablation-replace.mjs; each restore proven by blob == HEAD and an empty git diff HEAD)
  • Runtime, src-resolved: A1 the in-process answer removed from the seam: 5 in-process pins red. A2 the undeclared-reason guard removed: 3 red. A3 the params fill removed: 4 red. A4 the host-raised mark removed: 3 red (ctx.api, ctx.ql, transaction). A5 the VM address channel removed: 6 red. A6 the reason sentence pick removed: 4 red. A7 one byte added to userMessage: the byte-identical pin and 15 more red.
  • Spec: S1 handler acceptance reverted: 4 red. S2 the handler source read removed: 2 red. S3 the literal reason reading removed: 2 red. S4 the params hole judge removed: 3 red.
  • Lint: L1 the reason translation-target check removed: 2 red. L2 the i18n walk's reasons removed, rebuilt into packages/lint/dist (preflight: marker present in 2 built files): the 3 CLI reason pins red; restore rebuilt, marker absent, tree clean.
  • Verify, dist-resolved: V1 the seam's in-process answer removed, rebuilt into packages/runtime/dist (preflight: marker present in 2 built files; the mutate leg's declarations step refused the now-unused names after the JS was emitted): the source-door parity pin red, the artifact door green; restore rebuilt, marker absent, tree clean.
Local gates and package suites
  • node scripts/pm/dispatch-gates.mjs --commands (no paths) derives 118 commands at this head; --ran reconciles 118 of 118. First run: 113 at exit 0, and five non-zero:
    • check:dispatcher-error-vocabulary (exit 1, a finding): two new helpers passed a code parameter into an object literal. Restructured so the code reaches the literal as a local, as before. Exit 0 at head.
    • check:test-source-alias (exit 1, a finding): two new tests loaded modules inside a clocked window. The loads moved to module top. Exit 0 at head.
    • check-plugin-teardown-shape.mjs --self-test (exit 3, prerequisite: the pinned commit was outside the shallow clone): fetched, exit 0.
    • check:skill-examples (exit 3, prerequisite: client-react not built): built, exit 0.
    • check:dual-build-cjs-loads (exit 3, prerequisite: needs every package's dist/, a full monorepo build): NOT MEASURED locally; CI runs it.
  • After the last spec edit, the spec was rebuilt and these were rerun at head, each exit 0: check:generated, check:api-surface, check:dual-source-exports, check:entry-nameability, check:exported-any, check:skill-examples, check:liveness, every other spec check:* in the list, check:cross-package-test-inputs, check:i18n-walk-parity, check:doc-authoring, check:issue-citations, check:nul-bytes, check:spec-docblock-symbol-anchors, and the changeset gates.
  • Typecheck, each exit 0: spec, runtime, lint, cli, verify.
  • Tests: @objectstack/spec 839 files pass, 1 skipped (26874 tests pass) at head; @objectstack/runtime 599 files (10694) pass; @objectstack/lint 208 files (8890) pass; @objectstack/cli --project unit 417 files (5956) pass; @objectstack/verify 52 files (439) pass. The CLI integration layer is declared to CI (no spawn entry touched).

Generated by Claude Code

…and reference docs (#33214)

Claude-Session: https://claude.ai/code/session_017xRBcRivaGj55DhDi7sE8w
Co-authored-by: Claude <noreply@anthropic.com>
… not a helper parameter (#33214)

Claude-Session: https://claude.ai/code/session_017xRBcRivaGj55DhDi7sE8w
Co-authored-by: Claude <noreply@anthropic.com>
…ndler-hook-refusals

# Conflicts:
#	content/docs/automation/hooks.mdx
@github-actions github-actions Bot added size/xl documentation Improvements or additions to documentation protocol:data protocol:system tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 15, 2026
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 3 package(s): @objectstack/lint, @objectstack/runtime, @objectstack/spec, touching 65 documentable anchor(s). ⚠️ 8 changed file(s) yielded no anchor (packages/spec/api-surface/data.json, packages/spec/authorable-surface/data.json, packages/spec/dropped-refinements.baseline.json, …), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

1 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/automation/hook-bodies.mdx (via body.source (literal, a string literal in refusalSourceOf; a string literal in refuseUndeclaredLiteralRefusalCode; a string literal in undeclaredHookRefusalCodeAtSave; a string literal in undeclaredHookRefusalReasonAtSave; a string literal on a changed line))

⛔ 2 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-0.mdx (via HookSchema (symbol, a top-level const))
  • content/docs/releases/v17/17-7.mdx (via HookSchema (symbol, a top-level const), bindAppArtifactHandlers (symbol, a top-level function))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 8 changed file(s) yielded no anchor (packages/spec/api-surface/data.json, packages/spec/authorable-surface/data.json, packages/spec/dropped-refinements.baseline.json, …) — pages documenting those are invisible to this run
  • 7 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 177 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 48e695966ad76eee523d8a1321a88317ee4acfa6 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 00b3c9f3abeab5d02f5cf1b23164c1e3c9f0c13b — the merge of head da6c538b7643003b2de36ac47aea018c6aa39c87 into base 48e695966ad76eee523d8a1321a88317ee4acfa6, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 00b3c9f3abeab5d02f5cf1b23164c1e3c9f0c13b && git checkout 00b3c9f3abeab5d02f5cf1b23164c1e3c9f0c13b
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 48e695966ad76eee523d8a1321a88317ee4acfa6 da6c538b7643003b2de36ac47aea018c6aa39c87 && git checkout -B drift-repro 48e695966ad76eee523d8a1321a88317ee4acfa6 && git merge --no-ff da6c538b7643003b2de36ac47aea018c6aa39c87

node scripts/docs-audit/affected-docs.mjs --json 48e695966ad76eee523d8a1321a88317ee4acfa6

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 48e695966ad76eee523d8a1321a88317ee4acfa6 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:spec#2 · sunhaolin · session_017xRBcSbLCxEmyHf9upz3pz

Contract-review-handoff: review#2 — CONTRACT_REVIEW_TIER unavailable (the seat's isolated reviewer refused by its session classifier twice, 2026-11-14T17:2xZ) · head 7bb3498

Card #33214. Ruling 6879477573 (问一 A, 问二 S1, 问三 params) inside ruling 6431311681 (#26170 letter A). The dev reports are 6888595211 and 6888828706. The PR merged main at 7bb34983, and CI on that head is green: 58 success, 10 skipped. The dev's two open_questions (a stray reason; the Studio hook form) are for the record's ③.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

review#2 · os-project-manager · session_01FEkQ5nhu4dRbKVQKDB4CDB

Contract-review-claim: session_01FEkQ5nhu4dRbKVQKDB4CDB · head 7bb3498 · 2026-11-15T04:40Z

…declares reasons; compile hook refusal templates (#33214)

Claude-Session: https://claude.ai/code/session_017xRBcRivaGj55DhDi7sE8w
Co-authored-by: Claude <noreply@anthropic.com>
…ms compile refusals; skills follow-up #33658 (#33214)

Claude-Session: https://claude.ai/code/session_017xRBcRivaGj55DhDi7sE8w
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

review#2 · os-project-manager · session_01FEkQ5nhu4dRbKVQKDB4CDB

Contract-review-claim: session_01FEkQ5nhu4dRbKVQKDB4CDB · head 1c9a1ec · 2026-11-15T06:08Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

review#2 · os-project-manager · session_01FEkQ5nhu4dRbKVQKDB4CDB

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 1c9a1ecf2461a0de9e7095aae08318cc27f791fd
Local-runs: none
Scope: packages/spec/src/data/hook-refusal-codes.ts, packages/spec/src/data/hook.zod.ts, packages/spec/src/system/i18n-resolver.ts, packages/spec/src/system/translation.zod.ts + packages/runtime/src/sandbox/hook-refusal-catalogue.ts, packages/runtime/src/sandbox/body-runner.ts, packages/runtime/src/sandbox/quickjs-runner.ts, packages/runtime/src/app-artifact-handlers.ts, packages/lint/src/i18n-walk.ts, packages/lint/src/validate-translation-references.ts, packages/lint/src/validate-hook-refusal-templates.ts, packages/lint/src/validate-expressions.ts

Delta review of the hop 7bb349830803 to 1c9a1ecf2461, against record 6889389473 (FAIL: M1, S1). Inputs read: that record; the one PR comment after it (the review claim 6890153084; no dev report or ruling was posted for this hop); the five commits of the hop (90536ecd7, 9337b82aa, 3a820ad12, 7434178fb, 1c9a1ecf2), all the PR's own, with no merge of main among them; their 12-file compare; the head versions of the scope files through the contents API; the check-runs on this head (58 success, 10 skipped, none failed or pending). Cited code read on main: packages/formula/src/template-engine.ts.

① Derived judgments

  • Literal reason reading at save (refuseUndeclaredLiteralRefusalCode): now skipped when the thrown code's entry declares no reasons. It reaches only entries that carry the new reasons key, which main refused as an unknown key. No accepted input is newly refused. Right.
  • Run-time reason read (declaredAnswer, declaredReason): a thrown reason is judged and picked only where the entry holds a reasons map. Without one, the entry's own sentence and its own translation key answer, as on main. Right.
  • New lint pass hookRefusalTemplateIssues: errors only on sentences of an entry that declares params, a key main refused. A new refusal over inputs main never accepted. Right.
  • Schema describe text and docblocks on HookRefusal and Hook.refusals: reworded to the two rules above. No accept-set change in this hop; api-surface and export-origins are untouched by it. Right.
  • The other judgments of record 6889389473 ① are untouched by this hop and stand.

② Semver level

minor on spec, runtime and lint stands, and Check Changeset is green on this head.

Clause-②: yes — correct, unchanged.

Metadata-protocol: added is now the right value. With the reason read confined to entries that declare reasons, nothing main accepted is refused and nothing main answered is answered differently, so no ADR-0087 disposition is owed. The changeset sentence that a hook declaring none of the new parts answers as before now names the reason case and is true in the tree (pinned at save and on both run paths).

③ Boundary flags

④ Design judgment

M1, closed. Option (a), at both places.

  • Save: hook.zod.ts reads hook.refusals[code]?.reasons and continues when it is absent. A reason is refused only under a code whose entry declares reasons.
  • Run: declaredAnswer raises the undeclared-reason fault only when entry.reasons is an object, and declaredRefusalMessage goes through declaredReason, so with no reasons map the sentence and the translation key are the code's own. The body path and the in-process path share both functions.
  • Pins: hook-refusals.test.ts saves a main-shaped body hook and a handler hook that throw a reason under a code with no reasons. hook-refusal-catalogue.test.ts answers a main-shaped hook throwing a reason with its declared status, code and message on the body path and on the in-process path, and checks in zh-CN that the code's key is read and no reason key. The earlier pin that held the narrowing in place was rewritten to the opposite.
  • A thrown params under an entry with no params was never read, and still is not.

S1, closed for the doors that compile. validate-hook-refusal-templates.ts compiles each sentence of an entry with params through validateExpression('template', …) and adds its own refusal of an argument-less currency. Every finding is an error. It runs in runStackExpressionPasses whenever the write is not an object write, which covers os validate, os compile and the publish gate's hook write; each is pinned. The cases the earlier record listed (logic, an unknown formatter, an empty hole, currency with no code) are refused there. The engine on main allows one formatter per hole and refuses an empty currency: argument at compile, so the exact-match test on the word currency leaves no hole through. The describe text on message, reasons and params now agrees with what is refused.

Nits (no effect on correctness or the contract; accepted deviations or follow-up cards):

  • N1 to N5 of record 6889389473 are untouched by this hop and stay open as recorded. N4 now also covers the new rule: a translated sentence with an argument-less currency hole is not judged.
  • N6, new. The compile rule lives in lint only. HookSchema.parse by itself (defineStack, a source boot that never ran os validate) still accepts a hole with logic or an argument-less currency under params, and fillHookRefusalParams then serves the sentence as written, with a warning. The HookRefusalSchema docblock names where the rule is enforced; the field describe says "refused" without naming where. This is the posture the action copy slots already have.
  • N7, new. The pass's own hole pattern excludes an opening brace inside a hole, and the engine's pattern does not. A malformed hole of that shape with | currency skips the pass's currency sentence; the engine's compile still judges it.

Held. No new export, no schema key and no wire field in this hop. The regenerated content/docs/references/data/hook.mdx matches the describe text in hook.zod.ts. The ledger line in authored-site-expression.test.ts classifies the new pass beside actionCopyTemplateIssues.

No must-fix and no should-fix remains. Nits only: this is the final round for this PR's contract face.

Implemented-by: claude/issue-33214-handler-hook-refusals
Reviewed-by: session_01FEkQ5nhu4dRbKVQKDB4CDB

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:spec#2 · sunhaolin · session_017xRBcSbLCxEmyHf9upz3pz

维护者速读 · PR #33641 @ da6c538b · 2026-11-15T08:11Z

席位核对

ACCEPT.

  • Form: draft → main, Fixes #33214 only. Clause-②: yes, Metadata-protocol: added and Skills-docs: follow-up #33658 are line-leading in the body. The changeset bumps spec, runtime and lint at minor.
  • Ruling: 6879477573 (问一 A, 问二 S1, 问三 params), inside 6431311681 (i18n: an app hook's business refusal has no translation key — a zh-CN user reads "A current clean version is required before signing." in English #26170 letter A). The M1 fix keeps the diff additive, which is the premise the ruling was given on. No narrowing.
  • Contract review: review#2 (CONTRACT_REVIEW_TIER).
    • Record 6889389473 is a FAIL on 7bb34983: M1 (the reason reading narrowed shipped behaviour) and S1 (holes that cannot render were accepted under params).
    • Record 6890372056 is the delta PASS on 1c9a1ecf: M1 and S1 are closed, and nits N1 to N7 remain. Per the record, this is the final round for the contract face.
  • Head: da6c538b is 1c9a1ecf plus a merge of main (K was 76) and the regenerated export-origins, api-surface and translation reference. The PR's own diff against main is byte-identical before and after the merge (37 files, +2110 / −174; the +/− lines diff empty), so the records cover it.
  • Check-runs @ da6c538b: 68 runs, 58 success and 10 skipped, none failed or pending. The reds on 90536ecd, 9337b82a and 3a820ad1 are superseded heads: either their lanes were cancelled, or the reference-docs drift was fixed in 7434178f.
  • Dev report: 6890540624. 117 of 118 derived gates exit 0. check:dual-build-cjs-loads exits 3 locally because it needs a full build; it is green in CI. Typecheck exits 0 for spec, runtime, lint, cli and verify.
  • Seat readings @ 2026-11-15T08:11Z:
    • check-governed-merges --pr 33641: NOT governed; 2284 lines ≤ 3000.
    • git merge-tree against main: clean.
    • K = 6.
  • Accepted deviations:
    • N1 to N7 of the records, among them: the binds without wrapHandler; the ctx.transaction surface; the formatter locale; translation holes not judged by os validate; and the compile rule living in lint only.
    • The S1 compile pass lives in packages/lint (the action-copy precedent), not in the spec parse.
    • The surface grew by the gate-forced ledgers and generated files, and by i18n-resolver.ts (accepted by record 6889389473).
  • Out of scope: filed Studio: the hook form offers a refusal as message + status only, so it cannot author the refusals.CODE.reasons and params that #33214 adds #33657 (the Studio hook form cannot author reasons / params; premise corrected after record 6890372056) and skills: the hooks and i18n skills do not teach a handler-authored hook's refusals, the per-code reasons, or params (#33214) #33658 (skills docs).
  • Landing clause: non-governed queue landing by the seated lane seat.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 15, 2026 08:11
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit 53f5a4c Nov 15, 2026
69 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-33214-handler-hook-refusals branch November 15, 2026 08:44
scbdzhwl pushed a commit to scbdzhwl/objectstack-analysis that referenced this pull request Nov 16, 2026
…arams (objectstack-ai#33775)

<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XGooifXpuUREdsVd5x9prTS)_

domain:skills#1 · os-project-manager · session_01FEkQ5o9NG21PoQGHjYvjzM

Fixes objectstack-ai#33658

Clause-②: no
Metadata-protocol: none

## 维护者速读

- 改了什么:数据技能 `data-hooks.md` 的「声明式拒绝」一节改为教 objectstack-ai#33214 之后的真实规则:`handler`
钩子也能声明 `refusals`;同一个码下可以有多句 `reasons`(抛 `{ code, reason }`);声明 `params`
后句子里的双花括号占位符只能引用已声明的名字。i18n 技能在原有翻译键旁加上 reasons 的翻译键。
- 为什么改:PR objectstack-ai#33641 合并后,旧文档仍说「只有沙箱 JS 能声明拒绝、一码一句、不许占位符」,AI
照着写会继续抛英文句子或自造错误码。
- 风险与回滚:只改两份技能文档加一个 changeset,无代码;为付 token 棘轮删了同文件内四处重复说明。回滚即 revert。
- 先看:`skills/objectstack-data/references/data-hooks.md` 的 `### Declared
refusals` 一节(示例与下方 5 条要点);其次 `skills/objectstack-i18n/SKILL.md` 的
App-authored 一条。
- 两分钟验证:`node scripts/check-skills-token-ratchet.mjs` 全绿,data-hooks.md 为
9990/10011。
- 需要你做的:无,席位落地(按低风险 skills 臂;臂若读出 Tier H 则需你批准合并)。

## What changes

Three files, no code.

**`skills/objectstack-data/references/data-hooks.md` § Declared refusals
(`refusals`)**

- The example's `ASSET_NOT_IN_STOCK` entry now declares `params:
['due']` and a `reasons` entry `on_loan` whose sentence fills a `due`
hole, and the body throws `Object.assign(new Error(), { code:
'ASSET_NOT_IN_STOCK', reason: 'on_loan', params: { due: asset.due_date }
})` before the existing code-only throw.
- "Only a `js` `body` can declare one: a `handler` hook, inline TS
included, is refused at save" is replaced: a `js` body or a `handler`
(inline or named) can declare one; an `expression` body, or neither, is
refused at save.
- New bullets: `reasons` are snake_case, thrown as `reason`, and keep
the code's wire `code` and status; `params` names what a hole may fill,
and a hole over any other name, or any hole with no `params`, is
refused.
- The translation bullet names both keys,
`hooks.HOOK.refusals.CODE.message` and
`hooks.HOOK.refusals.CODE.reasons.REASON.message`, and says the thrown
text (not "the body's own text") is unused.
- The refusal bullet adds "a reason missing from a code's `reasons`".
- The intro says "the hook throws the code" instead of "its body throws
the code".

**`skills/objectstack-i18n/SKILL.md` § Server-Composed User Text**: the
App-authored bullet names
`hooks.HOOK.refusals.CODE.reasons.REASON.message` beside the code's key,
and says a translation of a sentence whose entry declares `params` keeps
its holes, filled by the runtime after it is picked.

**`.changeset/33658-skills-hook-refusal-reasons-params.md`**:
`'@objectstack/skills': patch` (the catalog ships in
`@objectstack/skills`).

**Token ratchet payment (same file, restatements only).** data-hooks.md
was at 10004/10011; the new text cost about 150 tokens. Removed:

| Removed | Its home in the same file |
|:--|:--|
| "The deprecated `handler` takes an inline function or a registered
function's name (Registration Methods)." | the `body` vs `handler` table
(inline) and Registration Methods 1 (string name via `functions`) |
| "So spell keys against the object's declared fields, and on an insert
event read `previous` only against `null` ..." | the paragraph above it
(a typo'd key and a `previous` column on an insert fail the write) and
the `previous is null on insert` bullet |
| "(A declarative `condition` does not hit this wall ...)" under Gotcha
1 | § `condition`: "`record` here is the RECORD ... unlike `ctx.input` /
`ctx.result` inside the body, which stay partial, see Gotcha 1" |
| "Register it like any hook, add it to `defineStack({ hooks: [...] })`
..." after the copy-paste example | Registration Methods 1
(`defineStack({ hooks })`, `AppPlugin` auto-binds) |

No ceiling moved. `i18n.sourceLocale` teaching is untouched (objectstack-ai#33635
holds it).

## Why

PR objectstack-ai#33641 (objectstack-ai#33214, ruling 6879477573) made `HookSchema` and the runtime
accept `refusals` on a handler hook, `reasons` under a code and declared
`params`. The skills still taught the pre-objectstack-ai#33641 rule, so an agent would
keep a hand-written body for every rule, one sentence per code and no
params.

## Tests

No test file is committed (skills text only). Two one-time checks of the
new example, both against `main` @ `12a0f09f` built under the lock:

<details><summary>HookSchema.parse on the published example and six
mutants (packages/spec dist)</summary>

```
example parse: true
hole over undeclared name: refused: refusals.ASSET_NOT_IN_STOCK.reasons.on_loan.message A hook refusal `message` binds only `due` ...
hole with no params: refused: refusals.ASSET_NOT_IN_STOCK.reasons.on_loan.message A hook refusal `message` whose entry declares no `params` is plain text ...
literal undeclared reason: refused: body.source `body.source` throws code 'ASSET_NOT_IN_STOCK' with reason 'lost' ...
inline handler + refusals: ACCEPTED
inline handler, undeclared reason: refused: handler `handler` throws code 'ASSET_NOT_IN_STOCK' with reason 'lost' ...
string handler + refusals: ACCEPTED
expression body + refusals: refused: refusals `refusals` is answered for a sandboxed `body` ...
```

The block was read out of the edited markdown file, not retyped. Each
bullet's claim has a mutant above.
</details>

<details><summary>Real QuickJS run of the example's throw lines (scratch
test beside hook-refusal-catalogue.test.ts, deleted after)</summary>

The body was bound through `hookBodyRunnerFactory` +
`QuickJSScriptRunner` with the hook passed through `HookSchema.parse`;
the one `ctx.api` read was swapped for an input value, every throw line
kept as published. `Tests 5 passed (5)`, exit 0.

```
ON_LOAN {"status":409,"body":{"error":"This asset is on loan until 2026-12-01.","code":"RESOURCE_CONFLICT","declaredCode":"ASSET_NOT_IN_STOCK","object":"asset_checkout","userMessage":"This asset is on loan until 2026-12-01."}}
ZH {"status":409,"body":{"error":"该资产借出至 2026-12-01。","code":"RESOURCE_CONFLICT","declaredCode":"ASSET_NOT_IN_STOCK","object":"asset_checkout","userMessage":"该资产借出至 2026-12-01。"}}
RETIRED {"status":409,"body":{"error":"Only an in-stock asset can be checked out.","code":"RESOURCE_CONFLICT","declaredCode":"ASSET_NOT_IN_STOCK","object":"asset_checkout","userMessage":"Only an in-stock asset can be checked out."}}
```
</details>

## Acceptance notes

Each taught rule, read from `main` @ `12a0f09f`:

| Taught | Read from |
|:--|:--|
| a `js` body or a `handler` (inline or string) may declare `refusals`;
`expression` body or neither refused at `refusals` |
`packages/spec/src/data/hook.zod.ts`
`refuseUndeclaredLiteralRefusalCode` (`answered = body === undefined ?
hasHandler : language === 'js'`) |
| reasons snake_case, thrown as `reason`, keep the code's status and
wire code | `HOOK_REFUSAL_REASON_PATTERN` (`hook-refusal-codes.ts`);
`HookRefusalSchema` `reasons` describe; runtime `declaredAnswer` |
| a hole only over a declared param; no `params` means no hole |
`hookRefusalMessageRefusal` (`closedScopeTemplateRefusal` with `roots:
params`) |
| literal undeclared code or reason refused at save, else a 500 |
`hookRefusalCodesThrownIn` / `hookRefusalReasonsThrownIn`; runtime
`undeclaredHookRefusalReasonAtRun` |
| reason key, and a translation keeps its holes |
`hookRefusalMessageKey` (`system/i18n-resolver.ts`);
`translation.zod.ts` `hooks` docblock |

Out of scope, noted for the seat (not filed): the objectstack-data eval
`hooks-security-seeds-datasources.json` id 7 `expected_output` still
ends "a catalogue on a hook without a `js` body is refused at save",
which objectstack-ai#33641 made false (a `handler` hook may declare one). Its
assertions (`must_contain`, `must_not_contain`) are unaffected. carrier:
the skills seat.

## Verification

Readings on head `6072b2db`:

- **Model tier** (`dispatch-gates --tier`): MANDATORY contract-review
tier, `skills/**` clause ①, no one-line exit. This branch was written at
the default tier; the seat's in-seat at-tier contract review pays the
mandated tier.
- **`check-governed-merges.mjs --branch claude/project-thread-3vm39u`**:
GOVERNED, `skills/**` ×2, landing tier H on a path list; low-risk skills
arm NOT MEASURED there ("no reading of the pull request was handed in").
The arm is read with `--pr` on this PR.
- **Skills readings (lines; tokens = ceil(bytes/4)):** data-hooks.md 892
to 893 lines, 10004 to 9990 tokens (ceiling 10011);
objectstack-i18n/SKILL.md 522 to 524 lines, 5918 to 5971 tokens (ceiling
6333). Bundle, all 11 `skills/*/SKILL.md`: 4588 to 4590 lines, 59049 to
59102 tokens.
- **`check-skill-line-ratchet.mjs`**: exit 0.

<details><summary>Derived gates: 48 derived, 47 exit 0, 1 NOT MEASURED,
plus check:skill-examples</summary>

`node scripts/pm/dispatch-gates.mjs --ran FILE`: "48 derived famil(ies)
accounted for, 47 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit
3)".

- exit 0: check-adr-0087-registration (base, self-test),
check-changeset-no-major, check-closing-keyword-parity (+ self-test),
check-comment-mask-corpus, check-doc-route-spelling (advisory,
self-test), check-dts-emitted self-test, check-empty-changeset (base,
self-test), check-skills-token-ratchet (+ self-test), ci
assert-turbo-remote-cache / plan-test-core-shards / prune-turbo-cache /
snapshot-next self-tests, check-governed-queue-guard self-test,
release-rehearsal-clone self-test, release-pending-publish self-test,
lint check:doc-formula-expressions, spec check:skill-docs, spec
check:skill-refs, check:agent-test-spelling,
check:changeset-gate-self-tests, check:ci-filter-parity,
check:closed-ceremony-text, check:corpus-claim-drift,
check:cross-package-test-inputs, check:doc-authoring,
check:driver-memory-census, check:dts-closure, check:gitlink-declared,
check:lean-entry-closure, check:merge-driver, check:nul-bytes,
check:pm-governed-merges, check:pm-skill-id-lint, check:published-files,
check:refd-timer-probe, check:role-word, check:skill-compatibility,
check:skill-frame-sync, check:skill-identifier-liveness,
check:skill-links, check:sourcemap-no-sources-content,
check:watch-hint-literal.
- NOT MEASURED: `pnpm check:dual-build-cjs-loads` exit 3, reason: it
reads every package's `dist` and asks for a full `pnpm build`; this diff
touches no package, so CI's run is the reading.
- Outside the derivation: `pnpm --filter @objectstack/spec run
check:skill-examples` exit 0, "346 prose examples type-check across 3
surface(s)".
</details>

---
_Generated by [Claude
Code](https://claude.ai/code/session_01FEkQ5o9NG21PoQGHjYvjzM)_

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01FEkQ5o9NG21PoQGHjYvjzM
<!-- signed: domain:skills#1 · os-project-manager ·
session_01FEkQ5o9NG21PoQGHjYvjzM -->

Co-authored-by: Claude <noreply@anthropic.com>
scbdzhwl pushed a commit to scbdzhwl/objectstack-analysis that referenced this pull request Nov 16, 2026
objectstack-ai#33796)

<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XNgQVJVHQG8aPco5eaW7Vvs)_

Fixes objectstack-ai#33657

Clause-②: yes (widening)
Metadata-protocol: none

Seat `domain:ui#1` · os-project-manager · card thread
`session_01FEkQ5oQHgtkqYPCqstiKir` · claim 6892138272

## 维护者速读

- 改了什么:Studio 的钩子(hook)表单里,每条拒绝目录条目除了「提示语」和「状态码」,现在还能填「原因」(同一错误码下的多句提示,以
snake_case 原因名为键)和「参数」(提示语里 `{{ 名称 }}` 可以填的名字)。表单定义 `hookForm`
加两行;渲染器本来就能画「嵌套在键值记录里的键值记录」和名称列表。契约复审 S1
之后另有一处渲染器修正:可选的键值记录行删掉最后一条时,现在写成「不存在」,不再写成空对象 `{}`。
- 为什么改:objectstack-ai#33214 让拒绝目录支持 `reasons` 和 `params`,但 Studio 表单只给了两项,作者在 Studio
里没法声明这两项能力。
- 风险与回滚:元数据可写内容不变(这两个键本来就合法),只是表单多了两行。实测:在改动前,带 `reasons`/`params` 的目录经
Studio 编辑其他字段后已经能原样保存,本改动后依旧如此;只填提示语和状态码的条目保存结果与今天逐字节相同。回滚即还原本 PR。
- 契约复审 S1 修正(d3ff3bdb):之前加一条原因再删掉,Studio 会存下 `reasons:
{}`;空对象和不写读法不同(空对象会拒绝主体抛出的每个原因,不写则不读原因),而界面上两者看起来一样。同样的问题在上一层:删掉最后一个错误码会存下
`refusals: {}`,它会拒绝主体抛出的每个错误码。现在两处都写成「不存在」;必填的键值记录行(对象的 `fields`)照旧保留
`{}`。
-
先看:`packages/spec/src/data/hook.form.ts`(新增的两行)、`ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.hookRefusalReasons-33657.test.tsx`(经真实
Studio
编辑页填写、保存、读回)、`packages/spec/src/system/metadata-form-zod-reconciliation.test.ts`(删掉两条
omit 台账行)。
- 两分钟验证:在 Studio 打开任一带 `refusals` 的钩子,点「编辑」,展开一条错误码:应看到 Key / Message /
Status / Reasons / Params 五项;在 Reasons 里加 `plan_locked` 并填一句话,在 Params
里填 `state`,保存后重新打开仍在。
- 需要你做的:无,席位落地(`hook.form.ts` 随 `@objectstack/spec` 发布,席位先补契约复审记录)。

## What changes

- **The form** (`packages/spec/src/data/hook.form.ts`). The `refusals`
row's entry gains two sub-rows after `message` and `status`:
- `reasons`: `type: 'record'`, `widget: 'key-only-record'`, with one
sub-row `message` (required textarea). A reason entry is `{ message }`
and nothing else, with no member that echoes its key, so it takes the
same key-only record control the catalogue itself takes. The key rule
the control checks is the served schema's own `propertyNames.pattern`
for `reasons`, which the spec derives from
`HOOK_REFUSAL_REASON_PATTERN`; the form restates no rule.
  - `params`: `type: 'tags'`, the name list control.
- The entry `message` help text said the sentence is "plain text, with
no placeholders". Once `params` is on the same card that is false, so it
now says a `{{ name }}` hole fills a declared param. The new rows' help
texts recite `HookRefusalSchema`'s own `.describe()` text.
- **The ledger**
(`packages/spec/src/system/metadata-form-zod-reconciliation.test.ts`):
the two `omit` rows for `hook` / `refusals` / `reasons` and `params` are
gone.
- **Drawing the rows needed no renderer change.** Measured on
`origin/main` before any edit (below): the console's generic form
renderer (`SchemaForm`'s `RecordField`) already draws a key-only record
nested inside a key-only record entry, reads each level's key rule from
the schema it is handed (`servedRecordKeyPattern`), and draws a `tags`
row as the string-tags widget.
- **Removing the last entry of an optional record row writes it absent**
(`ui/packages/app-shell/src/views/metadata-admin/SchemaForm.tsx`,
contract review S1, d3ff3bd). `RecordField.removeItem` emitted `{}`
once the last entry went, and nothing on the save path dropped it.
`RecordField` now takes `FieldControl`'s `offerUnset` (the key is
optional and not a list element, the condition the enum select's "— None
—" already uses) and, when that holds, emits an empty map as
`undefined`, the form's clear convention. A required row keeps `{}`. See
"S1: empty versus absent" below for the forms this reaches.
- **Translations.** The three new rows and the changed help text are
translated in the ten locales of `@objectstack/platform-objects`'
metadata-form bundles (regenerated with `node
scripts/check-i18n-bundles.mjs --write`, then the new leaves translated
by hand, the same ten the `refusals` row is translated in; a second
`--write` dropped the source-hash entries of the translated leaves). The
French label "Message" stays a byte copy of the source, as the existing
`refusals.message` label already is. The console's zh-CN form labels
(`metadata-form-zh-cn.ts`, read by the Pending changes sheet) name the
three rows.
- **Census counts.** Three `@objectstack/platform-objects` translation
pins count the hook form's enumerated children and the row labels
authored in the three hand-translated locales; the three new rows move
them from 9 to 12 and from 738 to 741, each with a comment naming the
rows.
- **Changeset** `.changeset/33657-hook-form-refusal-reasons-params.md`:
`@objectstack/spec`, `@objectstack/platform-objects`,
`@object-ui/app-shell`, `@object-ui/console` patch (a widening with
`Metadata-protocol: none`; app-shell is private and console's `dist`
ships it).

## Measured first (on `origin/main` bd96ec9, before any edit)

A probe through the real Studio edit page (`MetadataResourceEditPage`
for `hook`, the served form `hookForm`, the served schema from
`HookSchema`), over a stored hook whose `refusals.CONTRACT_LOCKED`
declares `message`, `status: 409`, `params: ['state']` and
`reasons.plan_locked.message`:

1. **What the entry offers:** the open entry's labels read `Key*`,
`Message*`, `Status`, nothing else. The deciding line is the `refusals`
row's `fields` array in `hook.form.ts`, which lists `message` and
`status` only; the renderer draws exactly the sub-rows a record row
lists (`RecordField` maps its `specs`, the row's `fields`).
2. **Round trip:** a Label edit then Save sent the body with `refusals`
byte-identical (`params` and `reasons` kept), and so did an edit of the
entry's own `message`. The deciding lines: the page sends the whole
draft, and `RecordField`'s `updateItem` writes `{ ...entry, ...patch }`,
so members the form does not list are kept. So the card's "may lose them
on a Studio edit" did not hold on main; the round-trip pin below now
holds it.
3. **Can the renderer draw the shape?** The same probe with a form that
adds a nested key-only `reasons` record and a `params` tags row drew
`Key / Message / Status / Reasons / Params`, showed `plan_locked` as a
nested entry, and no element id was duplicated. A nested `type:
'record'` sub-row goes through the same `FieldRow` → `resolveFieldFace`
→ `RecordField` path as a top-level one, with the sub-schema from
`pickSubSchema`.

## S1: empty versus absent (contract review 6893396284)

Measured through the real Studio edit page on 2238c90, before the fix
(each new pin below red, received shown):

- add `plan_locked` to `CONTRACT_LOCKED`, remove it, edit Label, Save:
the entry was stored as `{ message, reasons: {}, status: 409 }`;
- over a stored entry with one reason, remove it, Save: `reasons: {}`,
`params` kept;
- remove the only refusal code, Save: `refusals: {}`.

`{}` and absent read differently at both levels. For `reasons`,
`hook.zod.ts`'s save-time check refuses every literal reason thrown
under a code whose `reasons` is `{}`, and the runtime catalogue faults a
computed one; an absent `reasons` does not read the thrown reason. For
`refusals`, `{}` is a declared catalogue with no codes, so every code
the body throws is refused (and a non-js body is refused outright); an
absent catalogue leaves the throws as they were. The screen draws the
same empty list either way.

The generic `RecordField` inline face is reached by exactly three form
rows across the served forms (`type: 'record'` rows in
`packages/spec/src/**/*.form.ts`; no other form declares one, and the
other `type: 'record'` hits in the repo are pages):

| Form row | Required? | Before | After |
|---|---|---|---|
| `object` → `fields` | `required: true` | `{}` | `{}` (unchanged, no
absent state) |
| `hook` → `refusals` | optional | `{}` (refuses every thrown code) |
absent |
| `hook` → `refusals.<CODE>.reasons` | optional | `{}` (refuses every
thrown reason) | absent |

So `{}` and absent are not equivalent for the second row either, and the
generic fix changes it in the same direction as the finding. That is why
the fix is generic and gated on the row being optional, rather than
local to the hook form: the form has no per-row way to say "empty means
absent", and the `refusals` row has the same defect. Add-then-remove
with no other edit now returns the draft to the stored hook, so the page
has nothing to save.

## Tests

-
`ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.hookRefusalReasons-33657.test.tsx`
(new, the real Studio form): the real page with the production
registrations, the type row built the way the server builds it
(`hookForm` + `z.toJSONSchema(HookSchema, { io: 'input' })`), a stub
metadata client as the stored row.
- an opened refusal entry offers exactly `Key, Message, Status, Reasons,
Params`;
- author a reason (`plan_locked` + its message) and a param (`state`)
through the rendered controls, Save: the PUT body's entry is `{ message,
status, reasons: { plan_locked: { message } }, params: ['state'] }` and
`HookSchema` parses it; then a fresh page over the stored row shows the
reason and its message and the `state` chip;
- a stored catalogue that uses `reasons` and `params` round-trips a
Label edit: the body equals the stored hook with the new label;
- CONTROL: a refusal with only `message` + `status` saves exactly as
stored (keys `message`, `status`).
- S1: add then remove the only reason (plus a Label edit, so there is
something to save): the entry is stored as `{ message, status }`, keys
exactly those two;
- S1: remove the last stored reason: the entry is the stored one without
`reasons` (`params` kept);
- S1 CONTROL: add a second reason and remove the first: `reasons` holds
the second, as before;
- S1: remove the only refusal code: the stored hook has no `refusals`
key.
-
`ui/packages/app-shell/src/views/metadata-admin/SchemaForm.keyOnlyRecord-26835.test.tsx`
(the form definition test, new `describe`): `hookForm` declares
`reasons` as a key-only record of `{ message }` and `params` as `tags`;
the served schema's reason key rule is
`HOOK_REFUSAL_REASON_PATTERN.source`; author a reason + param and the
value parses as written; a reason key `PLAN_LOCKED` is refused with the
served rule and the value does not move; a stored catalogue reloads into
the same rows. The file's `addKey` helper now takes the last `Key` box:
an open entry draws a second one for its `reasons`, and the catalogue's
own box comes after every card. The existing CONTROL there ("a hook
authored with two refusals saves a body HookSchema accepts as written")
passes unchanged in substance.
- `SchemaForm.keyOnlyRecord-26835.test.tsx`, S1 `describe`: removing the
last entry of the optional `refusals` row leaves no `refusals` key and
`HookSchema` parses the value; CONTROL: the same row declared `required:
true` keeps `refusals: {}`.
- `packages/spec/src/system/metadata-form-zod-reconciliation.test.ts`:
green without the two `omit` rows (`hook.refusals` offers both keys).

### Ablations

Through `scripts/ablation-replace.mjs --delete` on the form source, each
leg running the reconciliation test (spec `src`), a spec rebuild,
`scripts/ablation-dist-preflight.mjs @objectstack/spec MARKER --absent`
(ui vitest reads spec from `dist`), and both ui pin files (17 tests).
Each restored with blob == HEAD and `git diff HEAD` empty; then spec
rebuilt and the preflight run without `--absent` found both markers back
in `dist` (exit 0), and both pin files were 17/17 green.

- `reasons` row deleted: reconciliation 1 failed / 75 (`hook.refusals:
accepted by the Zod but unauthorable in the form … expected [ 'reasons'
] to deeply equal []`); ui 6 failed / 17 (the offer pin, the Studio
author-save-reload pin, and all four SchemaForm `reasons`/`params`
pins).
- `params` row deleted: reconciliation 1 failed / 75 (`expected [
'params' ]`); ui 5 failed / 17 (the offer pin, both author pins, the
definition pin and the reload pin).
- The round-trip and CONTROL pins stay green under both: they hold
behaviour that already held on main, which is what they are for.
- S1, the empty-to-absent arm reverted (`emit` writes the map as given):
4 failed / 23 across the two ui pin files (the SchemaForm optional-row
pin and the three Studio S1 pins); the S1 CONTROLs stay green.
- S1, the `offerUnset` gate dropped (every empty map written absent): 1
failed / 15 in `SchemaForm.keyOnlyRecord-26835.test.tsx`, the
required-row CONTROL. Both restored by copying the fixed file back;
23/23 green.

## Acceptance notes

- **The premise's second half did not hold on main.** A catalogue using
`reasons` / `params` already kept them through a Studio edit (measured
above). The new round-trip pin holds that, and nothing in this diff
changes it.
- **`params` is not checked in the form.** The tags control accepts any
text; a non-identifier is refused at save by `HookSchema` (`A refusal
param is an identifier (e.g. state)`), and a `{{ }}` hole over an
undeclared name is refused there too. The form restates no rule, as the
order asks.
- **Not changed (order's ⛔):** `hook.zod.ts`, the runtime refusal
catalogue, the lint rule, any server code.
- **Noted, not filed:** the `refusals` row's help text still ends
"JavaScript (L2) bodies only", while since objectstack-ai#33641 a `handler` hook may
declare `refusals` too. The Studio form authors a `body` hook (the
handler row is the collapsed "Legacy handler" text field), so the
sentence still describes what this form authors; left as is to keep this
diff to the two rows. carrier: none.

## Verification

<details><summary>S1 round (head d3ff3bd)</summary>

- `dispatch-gates --commands` derives the same 88 families on d3ff3bd;
all 88 exit 0, run sequentially after a full workspace build. `--ran`:
88 derived, 88 run, 0 NOT-MEASURED.
- From `ui/`: the two pin files, 23 passed; the 15 metadata-admin test
files that touch a record row, `keyField` or `refusals` (`grep -l "type:
'record'\|keyField\|refusals\|RecordField"`), 179 passed. A run of the
whole `metadata-admin/` folder (281 files) did not finish inside a
25-minute timeout and was stopped; CI runs it.
- `pnpm --filter @object-ui/app-shell run type-check` exit 0. ESLint
`--no-inline-config` on the three changed ui files: exit 0, 17 warnings,
none on a changed line.
- `origin/main` is 28 commits past the branch; `git merge-tree` against
it is clean.

</details>

<details><summary>Local gates, suites, type-check and lint (head
2238c90)</summary>

- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derives 88 families for this diff (tree
2238c90). All 88 exit 0 on 2238c90, run sequentially after a full
workspace build (`turbo run build`, 119 tasks). `--ran` reconciliation:
88 derived, 88 run, 0 NOT-MEASURED, 0 UNRUN.
- First round (heads 8daba63 to e764497, before the last commit): 86
exit 0; `check-plugin-teardown-shape --self-test` exit 3 (shallow clone;
exit 0 after fetching its fixture commit) and `check:test-source-alias`
exit 1 (the edited `SchemaForm.keyOnlyRecord-26835.test.tsx` reaches
`import('@objectstack/lint')` through the condition widget; module-top
`@objectstack/formula` / `@objectstack/lint` imports added in 2238c90).
The second round above is the one on the final head.
- `node scripts/check-i18n-bundles.mjs --write
--filter=platform-objects` regenerated the 21 drifted bundle files
(eleven metadata-form bundles and ten source-hash tables); the new
leaves were then translated by hand and a second `--write` dropped their
source-hash entries. `pnpm check:i18n`, `check:i18n-stale-fill` and
`check:i18n-coverage` (423 baselined, none new) exit 0.
- Suites under the lock: `pnpm --filter @objectstack/spec test` 842
files, 26942 passed, 1 todo. `pnpm --filter
@objectstack/platform-objects test` 122 files, 1972 passed (first run: 3
failed, the hook form's enumerated-children census `9` and the
zh-CN/ja-JP/es-ES row-label census `738`, which the three new rows move
to `12` and `741`; updated in e764497 with their reason). From `ui/`:
`SchemaForm.keyOnlyRecord-26835.test.tsx`,
`ResourceEditPage.hookRefusalReasons-33657.test.tsx` and
`metadata-form-i18n.test.ts`, 39 passed. The full app-shell suite and
the rest of the farm are CI's.
- `pnpm --filter @object-ui/app-shell run type-check`, `pnpm --filter
@objectstack/spec typecheck`, `pnpm --filter
@objectstack/platform-objects typecheck`: exit 0. ESLint
`--no-inline-config` on every changed source and test file: exit 0, one
warning on an unchanged line of the existing harness (`sink.value =
next`). `pnpm check:new-line-citations` (from `ui/`): 0 new, exit 0.
- `origin/main` moved 9 commits past base bd96ec9; none touches a file
in this diff.

</details>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01FEkQ5oQHgtkqYPCqstiKir

---
_Generated by [Claude
Code](https://claude.ai/code/session_01FEkQ5oQHgtkqYPCqstiKir)_

<!-- signed: domain:ui#1 · os-project-manager ·
session_01FEkQ5oQHgtkqYPCqstiKir -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation protocol:data protocol:system size/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants