Skip to content

feat(spec): a restriction profile lists the approval pair through a derived vocabulary and splits allowSandboxedJs off allowCode - #31410

Merged
objectstack-fleet[bot] merged 16 commits into
mainfrom
claude/project-thread-7zgbrf
Nov 8, 2026
Merged

objectstack-fleet[bot] merged 16 commits into
mainfrom
claude/project-thread-7zgbrf

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by 田騏 · project thread

Fixes #31344

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

维护者速读

What changes

Builds on PR #31277, which has since landed on main. This branch has origin/main merged at 77a675d.

Spec (packages/spec/src/system/restriction-profile.zod.ts)

  • New export RestrictionProfileNodeType: the profile's own node vocabulary, derived as FlowNodeAction.options plus the spec-declared plugin node contracts APPROVAL_NODE_TYPE and APPROVAL_REVISE_NODE_TYPE. allowedFlowNodeTypes is now an array of it. FlowNodeAction is unchanged. The vocabulary stays disjoint from the ADR-0031 containers that a reader always allows, and the loop asymmetry is recorded in the docblock only.
  • New required boolean allowSandboxedJs. It governs every L2 language: 'js' body: hooks[].body, actions[].body and jobs[].body. allowCode is narrowed in its docblock and .describe() to in-process code: handler-form hooks and jobs, functions, plugins, the other code keys and the script node. L1 expression bodies fall under neither key. New near-miss aliases (allowSandboxedHooks, allowScriptBodies, …) point to the new key.

Reader (packages/cli/src/utils/restriction-profile.ts)

  • Reader rule 2 is now "outside the profile vocabulary ⇒ allowCode", so the approval pair is judged by allowedFlowNodeTypes.
  • A hook is judged by the body it runs, because a body wins over handler as it does at bind. A js body falls under allowSandboxedJs, an expression body under neither key, and a hook with no body that names a handler under allowCode.
  • Actions were never read before. A js body on a type: 'script' action (the only type the runtime runs a body for), whether top-level or embedded on objects[].actions, is now judged by allowSandboxedJs. A bound action that defineStack echoes into its object is judged once, at its top-level path.
  • Jobs are judged by allowScheduledAutomation first (one row). When that passes, a js body falls under allowSandboxedJs and a handler-only job under allowCode. A pull job falls under neither key.

Generated: content/docs/references/**, api-surface, authorable-surface, declaration-map, export-origins and json-schema.manifest are regenerated. The type-alias-convention pin gains one line, 842 → 843.

Tests

  • packages/spec/src/system/restriction-profile.test.ts pins three things. The derivation is exactly FlowNodeAction.options plus the pair. FlowNodeAction is not widened. The vocabulary is disjoint from parallel / try_catch. It also covers the new required key (missing, non-boolean, near-miss aliases) and a profile that lists the pair under allowCode: false.
  • packages/cli/src/utils/restriction-profile.test.ts flips the approval → allowCode case, so a profile that omits the pair now refuses it by allowedFlowNodeTypes. A new describe covers every body carrier in each form, the hosted profile, the precedence of allowScheduledAutomation, and the bound-action echo.
  • packages/cli/test/validate-target-restriction-profile.test.ts runs the door on a Team-shaped stack (an approval flow plus a sandboxed hook). The Team profile passes it. allowSandboxedJs: false refuses the hook, and a profile that omits approval refuses that node.

Acceptance notes

  • RestrictionProfileSchema has not shipped. packages/spec is at 18.3.0 on npm, and the schema's own changeset 31156-restriction-profile-schema.md is still pending. Adding a required key therefore narrows nothing a released consumer holds. That is why the title carries no ! and the declaration is Clause-②: yes (widening) / Metadata-protocol: added. The claim declared Metadata-protocol: none; it is corrected here because the profile is on the spec's authorable surface (authorable-surface/system.json) and One authoring source (cloud#3659 A), 2/4: a RestrictionProfile schema in spec, and os validate --target checks metadata against an environment's profile #31156 declared it added.
  • A script action with no body, whose target names a function, is not judged per item. The function it names is already refused under allowCode: false through the functions key. This is unchanged and outside the ruling's scope.

Verification

Head 8ef2c1ef (origin/main 77a675d merged; spec regenerated with check:generated --fix, nothing stale).

Local tests and typecheck
  • pnpm --filter @objectstack/cli exec vitest run --project unit :: exit 0 — Test Files 401 passed (401), Tests 5682 passed (5682)
  • pnpm --filter @objectstack/cli typecheck :: exit 0 (tsc + check:test-typecheck)
  • pnpm --filter @objectstack/spec typecheck :: exit 0
  • pnpm --filter @objectstack/spec exec vitest run src/system/restriction-profile.test.ts src/type-alias-convention.pin.test.ts :: exit 0 — 41 passed
  • pnpm --filter @objectstack/cli exec vitest run src/utils/restriction-profile.test.ts test/validate-target-restriction-profile.test.ts :: exit 0 — 45 passed
  • eslint (no inline config) on the six touched source/test files :: exit 0
  • The integration tier of packages/cli is left to CI.
Derived gates (dispatch-gates --commands, 108 families)

dispatch-gates --ran: 108 derived, 107 run, 1 NOT MEASURED, 0 unrun. Five families first exited 3 because a built prerequisite was missing (check:skill-examples, check:dual-build-cjs-loads, check:i18n, check:i18n-coverage, check:i18n-walk-parity). After the prerequisites were built, all five exited 0.

NOT MEASURED: node scripts/check-plugin-teardown-shape.mjs --self-test :: exit 3. Its fixture is pinned to commit 621a487, which this shallow clone cannot reach. The change touches no plugin, and CI runs it.

All other families :: exit 0.

Contract review

An independent Fable review of the spec contract diff, plus the reader that implements it, returned PASS with no must-fix findings. It raised two should-fix items, both applied: an action body is judged only on a type: 'script' action, because that is the only type the runtime runs a body for; and a hook with neither a body nor a handler is not refused. Its nits on the vocabulary .describe() and docblock wrapping were also applied. A delta re-review returned PASS. The verdict is posted as a PR comment.


🤖 Generated with Claude Code

https://claude.ai/code/session_017ihL2f9i7baA5w5Ta9Ai5P

claude added 16 commits November 7, 2026 20:43
…ch containers as structural

A restriction profile's allowedFlowNodeTypes can only name FlowNodeAction
ids, and parallel / try_catch are engine built-ins outside it, so under
allowCode: false the reader refused them as plugin nodes with no way to
allow them. They are now always allowed, like start / end, and every node
inside their regions is still judged. loop is a FlowNodeAction id and
stays judged by the list. The allowedFlowNodeTypes docblock states the
reader rules.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…r takes as code, devPlugins included

Co-Authored-By: Claude <noreply@anthropic.com>
…-0phzyp

# Conflicts:
#	packages/cli/src/utils/restriction-profile.ts
…llowCode, now that os build leaves it out of the artifact

Co-Authored-By: Claude <noreply@anthropic.com>
…type outside the vocabulary with a code plugin

Co-Authored-By: Claude <noreply@anthropic.com>
… describe the profile vocabulary

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ihL2f9i7baA5w5Ta9Ai5P
…er binds nothing

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ihL2f9i7baA5w5Ta9Ai5P
…to claude/project-thread-7zgbrf

# Conflicts:
#	packages/spec/src/system/restriction-profile.zod.ts
…-7zgbrf

# Conflicts:
#	packages/cli/src/utils/restriction-profile.test.ts
#	packages/cli/src/utils/restriction-profile.ts
#	packages/spec/src/system/restriction-profile.zod.ts
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:spec#4 · marchtian · session_017ihL2f9i7baA5w5Ta9Ai5P

Fable review · spec contract diff · PASS

This is the maintainer's standing rule for spec changes: an independent review by an isolated Fable subagent. It was given the card, the ruling record on #31354, the approved analysis and the diff, and not the author's conclusions. Its scope was the spec contract diff plus the reader code that implements it.

Round 1 at 1b583369: PASS, with 0 must-fix, 2 should-fix and 5 nits.

  • The schema matches the ruling exactly. The vocabulary is FlowNodeAction.options plus approval / approval_revise, and FlowNodeAction is not widened. allowSandboxedJs is a required boolean. allowCode is narrowed to in-process code. L1 expression bodies fall under neither key. The loop asymmetry is recorded in the docblock only.
  • The reader's classification matches what the runtime binds:
    • Hooks: a body wins over handler, as in the hook binder.
    • Actions: top-level and objects[].actions, matching the runtime's action collection. A bound action echoed by mergeActionsIntoObjects is judged once.
    • Jobs: the schedule rule is judged first, then the body or handler. A pull job falls under neither key.
    • No carrier of a js body is missed.
  • The changeset is defensible: the schema is unshipped (18.3.0 on npm, 31156-restriction-profile-schema.md still pending), so the required key is not breaking.
  • Should-fix 1, applied: judge an action body only on a type: 'script' action, the only type the runtime runs a body for.
  • Should-fix 2, applied: do not refuse a hook that has neither a body nor a handler, because it binds nothing.
  • Nits applied: a .describe() on RestrictionProfileNodeType, and docblock re-wraps. Not applied: repointing the existing allowScripts → allowCode alias (the script node is allowCode), and splitting the changeset in two (the single changeset is gate-valid).

Delta re-review of 1b583369 → cd3dfce2: PASS, with 0 must-fix and 0 should-fix. Three nits followed: two line wraps, and treating an empty handler: '' as binding nothing. All three were applied in 2ed6a89d. After that, origin/main (with #31277) was merged without changing these files' content.


Generated by Claude Code

@github-actions github-actions Bot added documentation Improvements or additions to documentation protocol:system tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

13 anchor(s) derived from 2 changed package(s); no hand-written page names any of them. ⚠️ 5 changed file(s) yielded no anchor (packages/spec/api-surface/system.json, packages/spec/authorable-surface/system.json, packages/spec/declaration-map/system.json, …), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

What this run could not see
  • 5 changed file(s) yielded no anchor (packages/spec/api-surface/system.json, packages/spec/authorable-surface/system.json, packages/spec/declaration-map/system.json, …) — pages documenting those are invisible to this run
  • the SDK route bridge reached 64 of 227 client-bound route-ledger rows — the other 163 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 163: 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; 104 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 — 180 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 405a78eae9311598f8868fe5bff92a2e17520f68 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 165c7c36a86892ce896c0826e19afc0d5ae44a03 — the merge of head 8ef2c1ef5cac0ec76da4c6bc62aa23abc441dbaa into base 405a78eae9311598f8868fe5bff92a2e17520f68, 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 165c7c36a86892ce896c0826e19afc0d5ae44a03 && git checkout 165c7c36a86892ce896c0826e19afc0d5ae44a03
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 405a78eae9311598f8868fe5bff92a2e17520f68 8ef2c1ef5cac0ec76da4c6bc62aa23abc441dbaa && git checkout -B drift-repro 405a78eae9311598f8868fe5bff92a2e17520f68 && git merge --no-ff 8ef2c1ef5cac0ec76da4c6bc62aa23abc441dbaa

node scripts/docs-audit/affected-docs.mjs --json 405a78eae9311598f8868fe5bff92a2e17520f68

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

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:spec#4 · marchtian · session_017ihL2eAG5J8aqAyPZif4BJ

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 8ef2c1ef5cac0ec76da4c6bc62aa23abc441dbaa
Local-runs: none
Scope: packages/spec/src/system/restriction-profile.zod.ts (hit) + packages/cli/src/utils/restriction-profile.ts, .changeset/31344-restriction-profile-approval-pair-sandboxed-js.md (implementing); read-only outside the diff: packages/runtime/src/sandbox/body-runner.ts, packages/runtime/src/app-artifact-handlers.ts, packages/runtime/src/app-plugin.ts, packages/spec/src/automation/{flow,approval,control-flow}.zod.ts, packages/spec/src/data/hook-body.zod.ts, packages/spec/src/system/job.zod.ts

① Derived judgments

Ruling #31354 item 2 ("DERIVED vocabulary = FlowNodeAction.options ∪ APPROVAL_NODE_TYPE/APPROVAL_REVISE_NODE_TYPE; ⛔ not added to FlowNodeAction; reader rule 2 reworded; CLI approval test flips; spec test pins the derivation; structural set and vocabulary disjoint") — all met. RestrictionProfileNodeType is built by spread from the two spec declarations (restriction-profile.zod.ts:42-45); FlowNodeAction (flow.zod.ts:45-73) is untouched; allowedFlowNodeTypes is .array(RestrictionProfileNodeType) (:224); reader rule 2 reads PROFILE_NODE_TYPES (restriction-profile.ts:184, :434) and parallel/try_catch stay in rule 1 only. The spec test pins the exact derivation, the non-widening of FLOW_BUILTIN_NODE_TYPES, and disjointness from the containers; the CLI test's approval → allowCode case is replaced by acme_sign, and the pair is now refused by allowedFlowNodeTypes under both allowCode values.

Item 3 ("REQUIRED boolean allowSandboxedJs over every L2 language:'js' body on hooks/actions/jobs; allowCode keeps in-process code; L1 under neither; actions now read; loop asymmetry docblock-only") — met. The key is required (:170-176, 5 missing-key issues pinned). Reader: hook js body → allowSandboxedJs, expression → neither, no body + handler → allowCode (:264-273); action js body judged only for type: 'script' or omitted type (:312), matching the runtime's action.type ?? 'script' gate in body-runner.ts:559-561; bound-action echo deduped (:313), matching mergeActionsIntoObjects (stack.zod.ts:5686); job: schedule first, then js body, then handler (:349-370), matching app-artifact-handlers.ts:414-419 (pull > body > handler) and hookCarriesBody (:593, body-first). loop noted at :39 only. Both earlier should-fixes are present at this head (type gate :312; the inert hook rp_inert is refused by nothing, tested).

nit — restriction-profile.zod.ts:126 says "only a hook or job with no body is in-process code"; the reader (correctly) also requires a handler. Accepted deviation (covered by "a key that carries nothing refuses nothing"); prose only.

② Semver level

@objectstack/spec minor is right: npm @objectstack/spec is 18.3.0 and packages/spec/CHANGELOG.md has zero mentions of RestrictionProfile; .changeset/31156-restriction-profile-schema.md is still pending, so the released acceptance set gains a whole new type and the required key narrows nothing released. FlowNodeAction and FLOW_BUILTIN_NODE_TYPES are unchanged; no released export is narrowed. @objectstack/cli patch is right: src/utils/restriction-profile.ts is not reachable from the package exports (., ./console, ./hook-body), and the behaviour change is a reader fix. No ! owed.

③ Boundary flags

PR author objectstack-fleet[bot] (REST). Nothing outside the claimed surface. Generated files consistent with the source: api-surface (+const/+type), declaration-map, export-origins (type-form, same as FlowNodeAction), json-schema.manifest (+system/RestrictionProfileNodeType), authorable-surface (+allowSandboxedJs), references mdx (1636→1637, table rows), type-alias pin 842→843 with the Iso_…RestrictionProfileNodeType line. No cycle: approval.zod.ts imports only identity/shared. Declarations Clause-②: yes (widening) and Metadata-protocol: added are correct: relative to released 18.3.0 the whole type is new and the accepted set only grows.

④ Design judgment

The spec file holds against the code it cites: ScriptBodySchema/HookBodySchema (hook-body.zod.ts:197,256), job body wins over handler (job.zod.ts:323), an action body runs only for script (body-runner.ts:559). The acceptance scenario is exercised at the door: test/validate-target-restriction-profile.test.ts TEAM profile (allowCode:false, allowSandboxedJs:true, pair listed) passes an approval flow and a sandboxed hook, and allowSandboxedJs:false / an omitted approval each refuse by the right rule. Reader and binder cannot disagree on body-vs-handler precedence.

Implemented-by: claude/project-thread-7zgbrf
Reviewed-by: session_017ihL2eAG5J8aqAyPZif4BJ

VERDICT: PASS

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 8, 2026 06:56
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge November 8, 2026 06:57
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 8, 2026
Merged via the queue into main with commit acfc86c Nov 8, 2026
66 checks passed
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:system size/l 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