Repository navigation
fix(lint)!: refuse a hook or job body that does not compile in the (ctx) wrapper the runtime runs it in - #35713
Conversation
…ime runs them in Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgTggz8AL2bCABoDGis
…ts changeset Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgTggz8AL2bCABoDGis
…he hook/job compile check Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgTggz8AL2bCABoDGis
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgTggz8AL2bCABoDGis
📓 Docs Drift CheckThis PR changes 3 package(s): 1 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
What this run could not see
Coarse fallback — 179 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 c146d75f42e9b7b068d2f00ad8ae6fad87797fe6 && git checkout c146d75f42e9b7b068d2f00ad8ae6fad87797fe6
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin a35187eeceae2e4d7b6c53ed52e579faeb53a7e0 ed1bf20389b9d8f1d4126e2265ffdf7c55fde1d9 && git checkout -B drift-repro a35187eeceae2e4d7b6c53ed52e579faeb53a7e0 && git merge --no-ff ed1bf20389b9d8f1d4126e2265ffdf7c55fde1d9
node scripts/docs-audit/affected-docs.mjs --json a35187eeceae2e4d7b6c53ed52e579faeb53a7e0
|
|
repo:objectstack#1 · os-sales · session_01L6bhgTggz8AL2bCABoDGis {
"issue": 34987,
"status": "done",
"branch": "claude/project-thread-iswnar",
"pr": "https://github.com/objectstack-ai/objectstack/pull/35713",
"head_sha": "ed1bf20389b9d8f1d4126e2265ffdf7c55fde1d9",
"session": "session_01L6bhgTggz8AL2bCABoDGis",
"premise_still_valid": true,
"summary": "Hooks and jobs were measured to share one wrapper, (async (ctx) => { SOURCE })(globalThis.__ctx), in quickjs-runner.ts (its only branch is origin.kind !== 'action'). hookBodyFunctionExpression / HOOK_BODY_PARAMETERS now live beside actionBodyFunctionExpression in action-body-wrapper.ts and the runner builds the hook/job wrapper from it, byte-identical to before. The compile-and-classify core was lifted out of validateActionBodyCompiles as judgeBodyCompile (the regexp pattern/token split from PR #35672 reused unchanged, action findings byte-identical). New gating rule validateHookAndJobBodyCompiles adds two NEW rule ids, hook-body-does-not-compile and job-body-does-not-compile: one walk and one registry entry because there is one wrapper, two ids because an id names the body kind. It runs on all three CLI commands and on runtimeTypes ['hook']. A job is allowRuntimeCreate: false and hooks is not an ObjectSchema key, so no job or object door exists. os explain pages for both ids, ADR-0087 semantic entry hook-job-body-does-not-compile-refused, docs updated. First-party exposure: 0.",
"tests": "validate-hook-body-compiles.test.ts 11/11, pinning one uncompilable hook (hook-body-does-not-compile · error · hooks[0].body.source) and one uncompilable job (job-body-does-not-compile · error · jobs[0].body.source), plus door tests (os validate/build/lint, runtime publish gate refused and admitted) and controls. @ ed1bf2038: pnpm --filter @objectstack/lint test → 222/222 files, 9336/9336 tests; lint and runtime typecheck exit 0. @ e1209577f: spec test 861 files / 27494 passed; runtime test 631 files / 11629 passed, 25 skipped. Ablation via ablation-replace.mjs, committed first: anchor 'recordsOf(stack.hooks).forEach' changed to recordsOf(undefined), x1 to x0, blob 7abe508df968 to 8271a15f3259. Result 5 failed / 6 passed of 11, the predicted direction (every hook pin red, the job pin green). Restore proven: blob == HEAD, git diff HEAD empty. The subject resolves via relative src imports, so no dist leg. Public-door probe: os validate on a stack with both bodies exits 1, naming hook \"stamp_owner\" and job \"nightly_close\" with SyntaxError and line 1.",
"gates": "dispatch-gates --repo objectstack-ai/objectstack --commands @ ed1bf2038: 118 commands, every one 'cmd :: exit 0' (log: scratchpad gate-results3.txt). --ran: '118 derived, 118 run, 0 NOT-MEASURED, 0 UNRUN' (a derived zero). The first sweep @ f58a65afe had check:docs-transcript-drift :: exit 1 (rule count 73 to 74), fixed in e1209577f. Local-only check:dev-prereqs :: exit 1: 35 unbuilt ui/ dists, container state, the diff touches no ui/. check:nul-bytes :: exit 0. overlap-check @ ed1bf2038: VERDICT clean exit 0. PR check-runs: in_progress, not awaited.",
"dogfood_battery": "ed1bf20389b9d8f1d4126e2265ffdf7c55fde1d9 · VERDICT command-exit 0 · held the lock 1987s · Test Files 482 passed, 3 skipped (485) · Tests 4093 passed, 68 skipped (4161) · no failure",
"line_budget": "691 changed lines (+626 / -65) over 17 files, under the 3000 human-merge threshold. No skills/** path, so no skill line ratchet applies.",
"files_changed": [
".changeset/34987-hook-job-body-does-not-compile.md",
"content/docs/automation/hook-bodies.mdx",
"content/docs/deployment/cli.mdx",
"content/docs/deployment/validating-metadata.mdx",
"content/docs/getting-started/build-with-claude-code.mdx",
"content/docs/ui/react-pages.mdx",
"packages/lint/src/action-body-wrapper.ts",
"packages/lint/src/authoring-rules.ts",
"packages/lint/src/index.ts",
"packages/lint/src/rule-explanations.ts",
"packages/lint/src/runtime.ts",
"packages/lint/src/validate-action-body-compiles.ts",
"packages/lint/src/validate-hook-body-compiles.test.ts",
"packages/lint/src/validate-hook-body-compiles.ts",
"packages/runtime/src/sandbox/quickjs-runner.ts",
"packages/spec/src/migrations/entries/semantic/18.action-body-does-not-compile-refused.ts",
"packages/spec/src/migrations/entries/semantic/18.hook-job-body-does-not-compile-refused.ts"
],
"first_party_exposure": "0. 33 literal L2 bodies judged across examples/**, apps/**, skills/**, content/docs/** (releases excluded) and packages/qa/**, 0 refused. 22 are built from variables or interpolation, all in dogfood tests, and the dogfood battery is green. 9 hook bodies in compiled artifacts (app-crm 1, app-showcase 8), 0 refused. The showcase's one job carries a handler, not a body. os validate over 4 examples: 0 findings. One docs fence (hook-bodies.mdx, compiled-artifact shape) elides its body with an ellipsis: prose, not metadata.",
"deviations": [
"overlap-check ran before pushes 1 (8329621bb) and 4 (ed1bf2038), not before pushes 2 (f58a65afe) and 3 (e1209577f). A run after the fact at e1209577f was clean.",
"File surface grew beyond the claim: content/docs/deployment/cli.mdx, content/docs/getting-started/build-with-claude-code.mdx and content/docs/ui/react-pages.mdx (a forced 73 to 74 rule-count edit, check:docs-transcript-drift), and content/docs/deployment/validating-metadata.mdx (the same edit plus a door-table row for the new rule).",
"PR body opens with the attribution comment, the Requested-by line and the signature line, as the dispatch ordered, so 'Fixes #34987' is line 4, not line 1.",
"The relay action carries the relay's own discriminator key 'op': 'pr_create' besides title/head/base/body.",
"Commits carry the model-free trailer pair the dispatch named, not the harness reminder's Co-Authored-By line with a model name.",
"A container restart killed the first background gate sweep and dogfood run. Both re-ran in full on the final head ed1bf2038 after the one main merge (238661f47).",
"The validating-metadata.mdx door-table row carries a tracker number (#34987), as its sibling rows do."
],
"relay_writes": "3: pr_create (PR #35713), the os-dev-report comment on the PR, and its copy on card #34987",
"api_writes": "3 relay writes: POST /repos/objectstack-ai/objectstack/pulls (draft, forced), POST /repos/objectstack-ai/objectstack/issues/35713/comments, POST /repos/objectstack-ai/objectstack/issues/34987/comments. Plus 4 git pushes to claude/project-thread-iswnar (not REST).",
"mcp_calls": "0",
"open_questions": [],
"security_findings": "none",
"out_of_scope_findings": [
"carrier: none · noted, not filed. A hook or job body that still fails to compile at run time gets the runner's generic \"hook 'NAME' threw: SyntaxError\" sentence, not the coded actionBodyCompileFailure sentence actions get.",
"carrier: seat (Skills-docs: follow-up owed) · skills/objectstack-data/references/data-hooks.md, section 'Sandbox restrictions', names no compile check."
]
} |
|
repo:objectstack#1 · os-sales · session_01L6bhgTggz8AL2bCABoDGis Contract-review-claim: session_01L6bhgTggz8AL2bCABoDGis · head ed1bf20 · 2026-11-20T02:36Z Generated by Claude Code |
|
repo:objectstack#1 · os-sales · session_01L6bhgTggz8AL2bCABoDGis Contract review brief — PR #35713 @
|
|
repo:objectstack#1 · os-sales · session_01L6bhgTcFanGhTvqS1V2Q4U 维护者速读
席位核对 — ACCEPT (L1-a) · repo:objectstack#1 · head
|
|
repo:objectstack#1 · os-sales · session_01L6bhgTggz8AL2bCABoDGis Contract reviewServed-tier: Read for this record: card #34987 (body, claim 7025754901, dev report 7028038495); PR #35713 (body, its 17 files, the net diff against One reading for the seat: the dogfood battery the dev report cites is a local run, not a check-run. On this head ① Derived judgmentsAccept-set changes, each judged against the tree:
Public surface:
② Semver level
③ Boundary flags
Deviations (report 7028030483):
Out-of-scope lines:
PR-body and claim notes:
SQL push-down: the diff reads and writes no data. No query, no id materialisation, no in-app join. Nothing is escalated. ④ Design judgmentThe narrowing against the published spec on The three card constraints, read on the tree:
Implementing files:
What I tried in order to break it:
Pins: 11 cases. The card's two are there, one hook that does not compile and one job that does not compile, each with rule id, severity and path. No must-fix, no should-fix.
Implemented-by: VERDICT: PASS Generated by Claude Code |
|
repo:objectstack#1 · os-sales · session_01L6bhgUkbQqRUUFSiu2HGob L2 adoption · 2026-11-20T03:00Z · The seat adopts the #34987 card thread's isolated record 7028965301 for head The verdict is PASS, with no must-fix, no should-fix and no escalated item. The card's three constraints hold: one wrapper function, byte-identical to main's inline string; ADR-0077 §3 untouched; the #35672 severity split reused as is. Nits: N6 (the changeset's L1-a ACCEPT on this head is 7028632821. |
|
repo:objectstack#1 · os-sales · session_01L6bhgTggz8AL2bCABoDGis Landing · 2026-11-20T03:04Z · head
State change: draft → ready, auto-merge armed. Follow-ups: #35714 (skills doc), #35715 (runtime compile-failure sentence), #35720 (review nits N1–N5); N6 accepted as a deviation. #34987 closes on merge through Generated by Claude Code |
Requested by Sales · project thread
repo:objectstack#1 · os-sales · session_01L6bhgTggz8AL2bCABoDGis
Fixes #34987
Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: follow-up #35714 — skills/objectstack-data/references/data-hooks.md (its "Sandbox restrictions" section teaches what a hook body may contain and names no compile check; not a
domain:skillsPR, soskills/**is not edited here)维护者速读
body.language: 'js')现在在运行时真正包裹它们的(async (ctx) => { … })里做一次编译检查;编译不过的报hook-body-does-not-compile/job-body-does-not-compile,级别 error,os validate/os build/os lint与 hook 的发布门都会拒收。const ctx = ctx.input || {}、同名let声明两次)能通过所有作者期检查,部署后每次运行都在第一条语句前抛 SyntaxError;action 已有同款检查(action-body-does-not-compile),hook 和 job 没有。packages/lint/src/validate-hook-body-compiles.ts(新规则本体);packages/runtime/src/sandbox/quickjs-runner.ts中hookBodyFunctionExpression(args.source)那一处 hunk(运行时包裹来源);packages/lint/src/validate-action-body-compiles.ts中抽出的judgeBodyCompile(action 规则输出须保持不变)。pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2 src/validate-hook-body-compiles.test.ts,预期 11 个用例全绿,其中一个不可编译的 hook 与一个不可编译的 job 各报 error。What changes
(ctx)wrapper.hookBodyFunctionExpression(source)andHOOK_BODY_PARAMETERSjoinactionBodyFunctionExpressioninpackages/lint/src/action-body-wrapper.ts(exported from@objectstack/lint, the function also from@objectstack/lint/runtime).quickjs-runner.tsnow builds the hook and job wrapper from it instead of spelling it inline; the produced text is byte-identical to what it built before. Measured in the runner: hooks and jobs both take(async (ctx) => { SOURCE })(globalThis.__ctx)(the runner's only branch isorigin.kind !== 'action'), so there is one wrapper for both, not two.judgeBodyCompile(expression, parameters)(withbodyCompileMessage/bodyCompileHint) is lifted out ofvalidateActionBodyCompilesunchanged in behaviour: the regular-expression pattern/token split from the previous change is reused as is, not altered.action-body-does-not-compile's findings are byte-identical (its 25 pins pass unedited).validateHookAndJobBodyCompiles, rule idshook-body-does-not-compileandjob-body-does-not-compile(decision: two new ids rather than widening the action id, because the id names the body kind andos explain/suppressWarningsaddress one kind; one walk and one registry entry, because the wrapper is one). Same severity split as the action rule. Walkshooks[*].bodyandjobs[*].body,language: 'js'only; a hook lowered from an inlinehandleris located athooks[N].handler.runtimeTypes: ['hook']. A job isallowRuntimeCreate: false, so no door publishes one, andhooksis not an ObjectSchema key, so no object write carries a hook. The rule loads no dependency (hostnode:vm), so it is safe on the kernel boot path.os explainpages for both ids;hook-bodies.mdxgains the check;validating-metadata.mdxgains its door-table row; the four CLI transcripts that print the author-time rule count read 74 (a direct consequence of the new registry entry, caught bycheck:docs-transcript-drift).hook-job-body-does-not-compile-refused; the action entry's sentence "hook and job bodies are not judged" is corrected to point at it. ADR-0077 Decision 3 (a hook body always requires human review) is untouched: this adds a build error and lowers no review friction.Tests
packages/lint/src/validate-hook-body-compiles.test.ts(11 cases): one uncompilable hook (const ctx = ctx.input || {}; return 1;→hook-body-does-not-compile,error,hooks[0].body.source) and one uncompilable job (let x = 1; let x = 2;→job-body-does-not-compile,error,jobs[0].body.source); the parse check reporting nothing on both; the severity split (pattern warns, token refused); controls that valid bodies, L1 bodies and handler-only hooks pass; lowered-hook location; never-runs;os explain; the door tests overos validate/os build/os lintand the runtime publish gate (refused and admitted).Acceptance notes
{ language: 'js', source }literals acrossexamples/**,apps/**,skills/**,content/docs/**(releases excluded) andpackages/qa/**: 33 literal bodies judged, 22 built from variables or interpolations (all in dogfood tests, which the dogfood battery runs), 0 refused. One docs fence inhook-bodies.mdx(the compiled-artifact shape) elides its body with an ellipsis; it is prose, not metadata. Compiled artifacts:app-crm1 hook body andapp-showcase8 hook bodies (its one job carries ahandler, no body), 0 refused;os validateover all four examples exits 0 with no finding of either id.(function(){ return (SOURCE); })()) and are outside this rule.hook 'NAME' threw: SyntaxError …, not the coded sentence actions get (actionBodyCompileFailure). Noted, not filed: the author-time refusal now covers the doors, and the run-time sentence already names the body and the error.claude/project-thread-iswnar, notclaude/issue-34987-*. Platform exception: this card thread can push only its assigned branch; the claim (comment 7025754901) names it.Verification
All readings on head
ed1bf2038(merge oforigin/main238661f into the branch), unless a line names another.Unit and package suites
pnpm --filter @objectstack/lint test→ Test Files 222 passed (222), Tests 9336 passed (9336);pnpm --filter @objectstack/lint typecheckandpnpm --filter @objectstack/runtime typecheckexit 0 (VERDICT command-exit 0).e1209577f:pnpm --filter @objectstack/spec test→ 861 files / 27494 passed;pnpm --filter @objectstack/runtime test→ 631 files / 11629 passed, 25 skipped (VERDICT command-exit 0). The merge brought no runtime or spec change.Door probe (os validate) and first-party exposure
os validateexits 1 and printshook "stamp_owner" › body: body does not compile in the wrapper the runtime runs it in, (async (ctx) => { … }) (SyntaxError: Identifier 'ctx' has already been declared, line 1), so every run of this hook failsathooks[0].body.source, and the same forjob "nightly_close"atjobs[0].body.source.os validate --jsonoverapp-todo,app-crm,app-showcase,app-multi-package: exit 0 each, 0 findings of either id. Static scan after the merge: 33 literal bodies judged, 0 refused (one ellipsis docs fence, prose).Ablation (one, committed first)
node scripts/ablation-replace.mjsonvalidate-hook-body-compiles.ts, anchorrecordsOf(stack.hooks).forEachreplaced byrecordsOf(undefined).forEach: anchor 1 to 0, blob 7abe508df968 to 8271a15f3259; the card's test file went red as predicted, 5 failed / 6 passed of 11 (every hook pin red, the job pin green). Restore proven: blob equals HEAD,git diff HEADempty. The subject resolves through relativesrc/imports, so nodist/leg applies.Gates
node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack --commandsated1bf2038: 118 commands, all run, allexit 0;--ranreconciliation:118 derived, 118 run, 0 NOT-MEASURED, 0 UNRUN(a derived zero, every line carries its exit code).check:docs-transcript-driftwas red on the first sweep (the new registry entry moves the printed author-time rule count from 73 to 74); fixed ine1209577f, green since.check:dev-prereqs: exit 1, 35 unbuiltui/workspace dists. A fact about this container, not this diff, which touches noui/path.Dogfood battery (narrowing arm, once on the final head)
ed1bf20389b9d8f1d4126e2265ffdf7c55fde1d9: closure build, thenpnpm --filter @objectstack/dogfood testunder the verify lock.VERDICT command-exit 0, Test Files 482 passed, 3 skipped (485), Tests 4093 passed, 68 skipped (4161), no failure.Generated by Claude Code
🤖 Generated with Claude Code
https://claude.ai/code/session_01L6bhgTggz8AL2bCABoDGis