Skip to content

fix(cli): the hook-body extractor infers member tokens through a body-local alias of ctx.MEMBER - #38731

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/issue-38690-extractor-local-alias
Nov 30, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/issue-38690-extractor-local-alias

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread
Refs #38690 (step 1)
Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:开发者把钩子或动作处理函数里的日志、编号、邮件、动态、关联标题先取成局部变量再调用时,构建现在会自动授予对应权限,运行时不再在调用处被沙箱拒绝。
  • 为什么做:属于构建期处理函数降级这一组修复,替写内联处理函数的开发者补上发布检查已认、构建却没推断出的写法。
  • 出错会怎样:最坏是多授予一个函数体确实调用了的权限;钩子里经别名发邮件会像直接写法一样在构建时被拒;可直接撤回。
  • 要你做什么:无。

What changes

os build lowers an inline hook handler / action target to a js body and infers body.capabilities from its source. The member patterns spelled ctx. (ctx.log.info, ctx.crypto.randomUUID, ctx.email.send, ctx.activity.append), and the rebind followed only the handler's own parameter, so a body-local alias inferred nothing and the sandbox refused the call at run time, while the publish check (validate-action-body-capabilities, memberReceivers) reads the same alias as a receiver of ctx.MEMBER.

  • bodyMemberAliases (new, packages/cli/src/utils/extract-hook-body.ts) reads the handler's parse for exactly the two alias shapes the lint rule credits: const l = ctx.MEMBER (not ctx?.MEMBER, not a chain) and a plain element destructured off ctx (const { log } = ctx, const { log: l } = ctx; no default, rest or nesting). A name counts only when declared once and never assigned or stepped again (the rule's boundOnce). title is collected on the hook face only (the host builds ctx.title only for hook bodies).
  • reboundCapabilities takes those aliases as a third argument and reads them the way the rule reads its receivers: a CALL of a gated leaf (?. allowed on either side), and for title a call with an argument. A field read infers nothing.
  • The published ExtractedBody.capabilities union is unchanged (seven tokens). No spec, no packages/lint edit.
  • content/docs/automation/hook-bodies.mdx ### Capability inference (claim amendment 1): the crypto.uuid and log rows name the alias shapes, new email.send and activity.append rows (which the table never had) name theirs, the *.title(…) row names the hook-face alias form, one sentence defines the two alias shapes and what infers nothing, and the over-inclusive paragraph now names email.send as its exception (a hook body is never granted it, so a hook that spells or alias-calls it is refused at build).

Read first (by risk): bodyMemberAliases (the shape set must equal the rule's), the call-shaped alias loop at the top of reboundCapabilities, then the docs table hunk (every sentence there must hold for the extractor as built).

Tests

New packages/cli/test/extract-hook-body-local-alias-38690.test.ts (93 cases):

  • refused-before / inferred-now, per member and shape on each face the gate is installed on: log (local, destructure, renamed destructure), crypto.uuid, email.send (measured here; the card had it unmeasured), activity.append (local, destructure), and a hook's title(FIELD) giving api.read. At base d2caaec40d this file ran 49 failed / 44 passed.
  • controls that infer nothing: a local bound to ctx.input.log, a reassigned let, a local bound to ctx.log.child, field reads (not calls) off each member alias, a title alias read or called with no argument, an alias spelled inside a string, a destructure with a default.
  • enumeration: every sandbox gate whose member is a ctx.MEMBER receiver (all eight rows of lint's SANDBOX_CAPABILITY_GATES, api included), through ctx.MEMBER, a bound local, a destructure and a renamed destructure. SANDBOX_CAPABILITY_GATES is exported by none of @objectstack/lint's three entries (., ./runtime, ./rule-explanations), and a relative import into packages/lint/src would need a cross-package-test-inputs declaration outside this card's file surface, so the table is mirrored in the test and pinned to the cli's own published union (satisfies Record over ExtractedBody['capabilities'], plus a coverage assertion).
Ablations (one per member family, scripts/ablation-replace.mjs)

Each removes one member from ALIASABLE_MEMBERS, runs the new file, restores; every restore printed blob == HEAD and git diff HEAD is empty.

  • log removed: 13 failed of 93 (the six log alias cases, six log enumeration rows, the optional-call case).
  • crypto removed: 10 failed (four alias cases, six enumeration rows).
  • email removed: 10 failed.
  • activity removed: 10 failed.
  • title removed: 5 failed (two alias cases, three enumeration rows).
Local readings at head (cli unit layer, typecheck, gates)
  • Build: pnpm --filter '@objectstack/cli^...' build under the verify lock: VERDICT command-exit 0.
  • pnpm --filter @objectstack/cli exec vitest run --project unit --maxWorkers=2: Test Files 451 passed (451), Tests 6544 passed (6544), VERDICT command-exit 0. The integration layer is CI's.
  • pnpm --filter @objectstack/cli typecheck: VERDICT command-exit 0 (test layer OK under tsconfig.test.json).
  • Six extractor files (extract-hook-body, the new file, hook-body-parameter-rebind, hook-body-mail-grant, lower-callables, published-subpath-hook-body.pin): 259 passed. No existing expected capability list changed.
  • Round 1 (bcd5926dbc), dispatch-gates --commands: 69 families; 68 exit 0; check:dual-build-cjs-loads exit 3 PREREQUISITE NOT MET, NOT MEASURED there.
  • Round 2 (2ed55579aa, docs page added), dispatch-gates --commands: 100 families, all exit 0 (nine first exited 3 on a fresh tree's missing builds and were re-run after building their closures, check:dual-build-cjs-loads among them). Docs families include check:doc-anchors, check:docs-section-name, check:doc-frontmatter, check:docs-single-h1, check:docs-spec-enumerations, check:docs-transcript-drift, check:doc-route-spelling --advisory, check:section-landing-index, spec check:docs. --ran reconciliation: 100 derived, 100 run, 0 NOT-MEASURED, 0 UNRUN.

Acceptance notes

  • First-party bodies, before and after (every body in examples/app-crm, app-multi-package, app-showcase, app-starter, app-todo, packages/apps/connector-docusign, connector-github, connector-stripe, loaded, normalized and lowered): 134 body rows, inferred lists byte-identical. No first-party body uses an alias shape.
  • Parity is kept with the rule, no wider: an alias reached through a renamed context root (async (c) => { const l = c.log; l.info('x') }, const { log } = c, or const c = ctx; const l = c.log) still infers nothing here, and the rule does not read it either. Reported to the seat as a finding, not fixed here.
  • A hook body that calls send(...) through an email alias now carries email.send, so the hook's parse refuses it at build, exactly as ctx.email.send(...) spelled directly already is. Before, it shipped and failed at the call.
  • The alias calls are matched on the body text (the receiver-loose machinery reboundCapabilities already uses), so a string containing such a call next to a real alias over-infers; for email.send on a hook that is a build refusal, the same edge the direct pattern documents.
  • Step 2 (lint dropping its lowered skips) stays on the card.

Verification

Two-minute check: pnpm --filter @objectstack/cli exec vitest run --maxWorkers=2 test/extract-hook-body-local-alias-38690.test.ts. Expect 1 file, 93 tests passed. Docs: the ### Capability inference table on the hook-bodies page has five member rows (crypto.uuid, log, email.send, activity.append, title), each naming its alias shapes.


Generated by Claude Code

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

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/cli, touching 12 documentable anchor(s).

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

  • content/docs/automation/hook-bodies.mdx (via activity.append (literal, a string literal in activity), api.read (literal, a string literal in reboundCapabilities), crypto.uuid (literal, a string literal in crypto), email.send (literal, a string literal in email), randomUUID (literal, a string literal in crypto))
  • content/docs/automation/hooks.mdx (via api.read (literal, a string literal in reboundCapabilities))
  • content/docs/automation/jobs.mdx (via api.read (literal, a string literal in reboundCapabilities))
  • content/docs/deployment/validating-metadata.mdx (via activity.append (literal, a string literal in activity), api.read (literal, a string literal in reboundCapabilities), crypto.uuid (literal, a string literal in crypto), email.send (literal, a string literal in email))
  • content/docs/kernel/runtime-services/email-service.mdx (via email.send (literal, a string literal in email))
  • content/docs/protocol/kernel/plugin-spec.mdx (via email.send (literal, a string literal in email))
What this run could not see
  • 4 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 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; 124 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 — 40 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 0d68ce2db33a4328362b2695174b47277f377daa → packageMentionDocs.

Which tree this was computed on

This run read content/docs from caa840a74280f86957d609f3bc78279207f34b72 — the merge of head 2ed55579aa1ab62f2c6c276a6ccc7b2a5e0e7552 into base 0d68ce2db33a4328362b2695174b47277f377daa, 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 caa840a74280f86957d609f3bc78279207f34b72 && git checkout caa840a74280f86957d609f3bc78279207f34b72
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 0d68ce2db33a4328362b2695174b47277f377daa 2ed55579aa1ab62f2c6c276a6ccc7b2a5e0e7552 && git checkout -B drift-repro 0d68ce2db33a4328362b2695174b47277f377daa && git merge --no-ff 2ed55579aa1ab62f2c6c276a6ccc7b2a5e0e7552

node scripts/docs-audit/affected-docs.mjs --json 0d68ce2db33a4328362b2695174b47277f377daa

⚠️ 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 0d68ce2db33a4328362b2695174b47277f377daa → pass the list as
args.docs, on the commit named under Which tree this was computed on.

… alias shapes and the email and activity rows

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

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmSwS4mQyXWrddL4r6B

Final green head · 2026-11-30T09:19Z · zone o3-B · 2ed55579aa · check-runs: 44 success, 19 expected skips, 0 failed, 0 pending · mergeable_state clean · draft, Clause-②: no and Metadata-protocol: none, +261 / -7 over 4 files against origin/main.
The dev's reports are 7272833184 (the build) and 7273455657 (the docs rows).

  • What changes. Step 1 of cli: the hook-body extractor infers nothing through a body-local alias of ctx.log, ctx.crypto, ctx.activity or ctx.title, so a lowered handler is refused at the call #38690: the hook-body extractor infers each member token through a body-local alias, in the two shapes lint credits (a local bound once to ctx.MEMBER, and a destructure off ctx), for crypto.uuid, log, email.send, activity.append, and a hook's ctx.title(FIELD) ⇒ api.read. The published ExtractedBody.capabilities union does not change.
  • Tests. 93 new cases; the cli unit project passes 6544. Five per-member ablations each went red and were restored clean. Across the first-party configs, 134 lowered bodies have unchanged inferred lists.
  • Fix round since the first push: 2ed55579aa, under claim amendment 1 (7272858601), brings the ### Capability inference table in content/docs/automation/hook-bodies.mdx up to the extractor: the crypto.uuid, log and *.title rows name their alias shapes, new email.send and activity.append rows, and the over-inclusive paragraph names email.send as its exception. The docs drift check named that page. The body is patched from the dev's draft.
  • Gates. dispatch-gates --ran at this head: 100 derived, 100 run, all exit 0 (check:dual-build-cjs-loads, NOT MEASURED in round 1, is measured green here). overlap-check was clean before each push.
  • l1-face flags nothing. The owed sentence reads are the changeset and hook-bodies.mdx.
    Sent to L1-b. No L2 is owed: Clause-②: no, no spec or governed path, nothing narrowed. Refs #38690 (step 1): step 2 (lint drops its lowered skips, a narrowing) stays on the card.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmT9HTWLMN33WUVxVWB
L1-b, the seat's L1 thread · 2026-11-30T09:26Z · first review

席位核对

ACCEPT @ 2ed5557 (card #38690, step 1; draft; 4 files, +261/−7)

  • Shape. Draft on main; Refs #38690 (step 1) is the partial-landing spelling execution-duties.md accepts, and right: step 2 (lint drops its lowered skips) stays on the card. No closing keyword binds any card.
  • Parity with the publish rule, read side by side. bodyMemberAliases takes exactly the two shapes memberReceivers (packages/lint/src/validate-action-body-capabilities.ts:259-273) credits: const l = ctx.MEMBER with no ?., no chain and nothing built on it (the rule's (?!\s*(?:\?|\.|\[|\()); the AST reads ctx.log.child and ctx.log ?? x as not-a-member-access), and a plain element destructured off ctx with no default, rest or nesting. Both apply the rule's boundOnce (declared once, never assigned or stepped). title only on the hook face. A token is inferred only for a CALL of the gated leaf off the alias, as the sandbox gates the call. The renamed-root alias (const c = ctx; c.log) stays out on both sides; the body reports it to the seat as a finding.
  • Clause-②: no holds, including the new build refusal. A hook that calls send(…) through an email alias is now refused at build. That input did not work on main either (it shipped and failed at every call), the direct spelling ctx.email.send in a hook is already refused at build, and the page already said a hook body is never granted mail. A declared refusal now enforced on a second spelling is not a narrowing (the fix(cloud-connection): install-local connects a composed bundle's package-body datasources and judges their names #34633 precedent). First-party measurement: 134 lowered bodies, inferred lists byte-identical. ExtractedBody.capabilities stays the seven-token union. patch is right.
  • Changeset and docs, sentence by sentence. The changeset's two shapes, the five leaf-to-token mappings, "a field read that is not a call, a local reassigned after its declaration, and a destructure with a default infer nothing", the unchanged published union, and the hook-mail paragraph all hold against the code. hook-bodies.mdx: the crypto.uuid, log, new email.send and activity.append rows and the extended title row each name the alias forms the code reads; the new paragraph ("two shapes only, the ones the publish check reads … an alias of an alias, and a field read that is not a call infer nothing") is true; the email.send exception sentence matches the hook face. ("os validate read the same body as granted" in the changeset is the card's wording: lint skips lowered bodies today, which is step 2.)
  • My runs (fresh worktree, @objectstack/cli^... built): the new file 93/93. My own ablation, removing the boundOnce check in bodyMemberAliases: 1 red ("a local reassigned after its declaration"), restored. On top of the dev's five member-family ablations. Nit, no change asked: a name declared twice (shadowed in a nested scope) is excluded by the same line but has no case of its own.
  • The test mirrors lint's SANDBOX_CAPABILITY_GATES rather than importing it, because no @objectstack/lint entry exports it and a relative import needs a declaration outside the claim. The mirror is pinned to the cli's own union with a coverage assertion. Accepted.

Checks at this head (read before writing, latest per name): 44 success, 19 skipped, 0 failure, 0 in progress. Two of the skips are the opt-in Dogfood battery (opt-in) lane and its shard, skipped by their label guard; this PR carries no marker, so they are expected here.
L2: not owed (no face; Clause-②: no). Dogfood: not owed. The zone lands it.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmSwS4mQyXWrddL4r6B

Landing · 2026-11-30T09:27Z · zone o3-B · head 2ed55579aa1ab62f2c6c276a6ccc7b2a5e0e7552 · ACCEPT → PR #38731 comment 7274229222 (L1-b) · Contract review: not owed (no face, Clause-②: no)

Reading Value
check-runs at head (pr-state) 44 success · 19 expected skip · 0 unexpected skip · 0 failed · 0 pending; mergeable_state clean
check-governed-merges --pr 38731 · K NOT governed, 268 changed lines (+261 / -7) · landing-k OK, K = 3 < 15, no shared book moved

State: ready for review and auto-merge in this stroke. Refs #38690 (step 1): the card stays open for step 2. L1-b's one nit (no case of its own for a name declared twice in a nested scope) is accepted in the record with no push.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 30, 2026 09:28
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 30, 2026
Merged via the queue into main with commit 855c3e1 Nov 30, 2026
64 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-38690-extractor-local-alias branch November 30, 2026 09:53
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…an authored one (objectstack-ai#38755)

<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi92EfsyzCyjwc8X5TRpmNj6z)_

Fixes objectstack-ai#38690

Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: none — no `skills/**` text taught the lowered exemption;
the one docs page that did
(`content/docs/deployment/validating-metadata.mdx`, the two capability
rows) is corrected here

## 维护者速读

- 用户能看到什么变化:挂在字符串 handler / target
旁的钩子和脚本动作函数体(构建产物,或手写的)现在也会被校验权限声明,缺权限时在发布和 os validate
时就报错,而不是上线后每次运行被沙箱拒掉;同时构建能认出 `ctx.log?.info(…)` 这类可选链、空白、注释写法,自动补上权限。
- 为什么做:这是「钩子与动作函数体权限校验」这张卡的第二步;取消当时为构建产物留的豁免,并把构建的推断补到与校验规则逐个写法一致。
- 出错会怎样:手写在字符串 handler / target
旁、漏声明权限的函数体,以及构建后丢了权限的产物,发布会被拒并点名缺的权限;首方示例与连接器应用实测零新增拒绝,可整 PR 撤回。
- 要你做什么:无。

## What changes

`validate-action-body-capabilities` (`@objectstack/lint`) skipped a body
it took for one the build lowered: a hook body `os build` / `os verify`
lowered from an inline `handler`, and at the runtime publish doors any
hook body beside a string `handler` (`isLoweredHandlerBody`); and any
action body beside a string `target`, judged for `api.write` alone
(`isLoweredTargetBody`). The skip covered a body written by hand beside
a string ref as well, since the rule cannot tell the two apart. The
reason was that the build's capability inference did not read every
gated call the rule reads. Step 1 of this card (PR objectstack-ai#38731) and objectstack-ai#38653
(PR objectstack-ai#38686) closed that gate by gate; this PR closes it spelling by
spelling.

So this PR:

- drops both skips and the three helpers that only served them
(`isLoweredHandlerBody`, `isLoweredTargetBody`,
`loweredActionBodyPaths`). `validateActionBodyCapabilities` no longer
takes the `loweredHookRefs` context, and its registry entry passes the
stack alone. Neither function was on the package's barrel.
- makes the CLI extractor
(`packages/cli/src/utils/extract-hook-body.ts`) infer each gated call in
each spelling the rule reads. Its `ctx`-anchored member patterns, and
their rebound siblings for a renamed or destructured hook context, were
literal `ctx.log.info`: `ctx.log?.info(…)`, `ctx?.crypto.randomUUID()`,
`ctx.activity?.append(…)`, `ctx.email?.send(…)`, `ctx . log . info(…)`
and `ctx.title?.(field)` lowered without their token, and the rule read
each as the gated call. Each step now takes `?.` and whitespace, `title`
takes the optional call, and inference also reads a comment-blanked copy
of the source (the rule's own walk, strings kept), so a comment between
steps no longer hides a call. Every change widens: what inferred a token
before still does. A hook handler that calls `ctx.email.send` in any of
these spellings now lowers with the grant and is refused at build by the
hook parse, as `ctx.email.send(…)` already was.
- exports `SANDBOX_CAPABILITY_GATES` and `type SandboxCapabilityGate`
from the lint barrel, and moves the step-1 CLI enumeration pin off its
hand-kept mirror onto that table.
- adds a PARITY pin in the CLI. Every gate, leaf, receiver shape and
face, in each spelling the rule reads (plain, `?.` before the member,
before the leaf and before the call, whitespace, a block or line comment
between steps), is lowered through `extractLoweredBody` and judged by
`runAuthoringRules('build', …)` twice: ungranted it must draw the gate's
finding (so the rule reads that spelling and the pin is not vacuous),
lowered it must draw none. A REBOUND block does the same through a hook
handler's renamed and destructured context parameter. The one exclusion
is a hook body's `email.send`, pinned instead as a build refusal in
every spelling.
- corrects the text that described the exemption: the two `os explain`
entries, the docs rule table, the rule's docblock and the comment over
the `lowerCallables` target-shape pin.
- registers the narrowing as ADR-0087 semantic entry
`lowered-hook-and-action-bodies-capabilities-judged`, with a BREAKING
changeset carrying FROM → TO for both authors (a body lowered by the
build or written by hand beside a string ref) and the remedy for each:
rebuild, or declare the token.
- corrects the pending objectstack-ai#37815 changeset and its semantic entry, whose
sentences this PR makes false (see Deliberate correction).

The limit, stated: the build's reading covers the rule's by the pin's
enumeration (census × receivers × spellings × faces), not by proof.
Where the two differ outside it, the build reads more (a renamed context
root, a spelling inside a string), and the over-inferred grant is one
the sandbox never checks, except `email.send` on a hook, which is
refused at build as before.

Measured cost before the change, on `origin/main` at `f782a12033`
(scratch script, not committed): every first-party stack
(`examples/app-crm`, `app-multi-package` with its two packages,
`app-showcase`, `app-starter`, `app-todo`,
`packages/apps/connector-docusign`, `connector-github`,
`connector-stripe`) loaded, normalized, lowered and parsed as
`judgeAuthorTimeRules` does, then judged by the shipped rule and by the
rule with both skips emulated away. 70 hook and action bodies, 1 of them
lowered (app-crm's opportunity hook): 0 findings shipped, 0 without the
skips, **0 newly refused**. The population holds one lowered body, so it
bounds authored bodies; the lowered side is bounded by the PARITY pin.

## Tests

- New
`packages/lint/src/validate-action-body-capabilities.lowered-38690.test.ts`
(26 tests). Per removed skip, a lowered body calling each gate
ungranted, spelled directly and through an alias: refused (hook: `os
validate` / `build` / `lint` and the hook save door; action: top level,
object-inline, `os validate` / `build` / `lint`, the action and object
doors). Controls: the same lowered body granted is not refused. A
lowered body's write keeps its own id beside the other tokens.
- `packages/cli/test/extract-hook-body-local-alias-38690.test.ts` (284
tests): the mirror table is deleted; ENUMERATION reads
`SANDBOX_CAPABILITY_GATES` and spells every leaf in every spelling
through seven receivers; PARITY and REBOUND as above; a hook handler
calling `ctx.email.send` in seven spellings plus a renamed context is
refused by `HookSchema` after `lowerCallables`.

Red first, each fix:

- PARITY harness: the earlier PARITY judged the extracted record without
`language: 'js'`, which the rule skips, so it could not go red. With the
body record the build writes and the widened spellings, against the old
extractor: 51 failed.
- Extractor `?.` / whitespace / optional call / rebound: the pins
against the extractor at `a68c0a41cc`: 76 failed of 247 (ENUMERATION 27,
PARITY 24, REBOUND 25). Hook mail in the new spellings: 4 failed of 8
(they built clean before).
- Comment between steps: against the extractor at `2aec12e986`: 210
failed of 284, every one a comment spelling.

Ablations at the head (`scripts/ablation-replace.mjs`, restore proven
blob == HEAD): `MEMBER_STEP` back to a plain `\.`: 84 failed
(ENUMERATION 32, PARITY 28, REBOUND 20, mail 4). `title` without the
optional call: 11 failed. Inference over the raw source only: 210
failed. The skips re-inserted in the rule, per removed skip: hook 14
failed / 12 passed, non-write action 12 failed / 14 passed of the lint
file.

Forced test edits, named:

-
`packages/lint/src/validate-action-body-capabilities.hook-and-tokens-37815.test.ts`:
two describe blocks deleted, `authored hook bodies only: a body lowered
from a handler is not judged (objectstack-ai#37815 route C)` and `authored action
bodies only past the writes: a body lowered from a target is judged for
api.write alone (objectstack-ai#37815 M1)`. They pinned the two skips this PR removes;
the new file pins the opposite. Their authored-body halves stay covered
by the same file's arm (a)/(b) cases. The two predicate imports go with
them.
- `packages/cli/test/lower-callables.test.ts`: comment only, over the
`[objectstack-ai#38653]` target-shape pin, which named `isLoweredTargetBody`. The pin
itself is unchanged.

## Acceptance notes

- The lowered hook finding's path stays `hooks[N].body.capabilities` on
the seat's answer (claim amendment 5). Its premise, that a fresh build
never draws the finding, holds again at this head for every spelling the
PARITY pin enumerates; for an artifact that lost a grant, or a
hand-written body, that key is the right one.

## Deliberate correction

`Check Changeset` (`check-empty-changeset`) is red on purpose: this PR
edits a pending release note it did not add. DELIBERATE CORRECTION, not
a collision; ⛔ do not restore the base text. Both files below are
unreleased (merged after 19.0.0-next.2) and ship in the same release as
this PR, and this PR makes their sentences about lowered bodies false.
Text only: no code, no entry id, no level or disposition line changes.
Scope per claim amendment 5 (7276409399); rewrites 2 and 4 of the
changeset and 3 and 4 of the entry re-trued per L2 7278772654.

**`.changeset/37815-body-capabilities-every-gate.md`**

1. BREAKING paragraph. Before: "whose authored L2 body calls a member".
After: "whose L2 body calls a member".
2. `hook-body-capability-undeclared` bullet. Before: "an authored L2
hook body that calls any of those gates" … "Only a body the author wrote
is judged: a hook body `os build` / `os verify` lowered from an inline
`handler` is not, since its grant is the build's inference (the lowered
reading is objectstack-ai#38653)." After: "an L2 hook body that calls any of those
gates" … "A hook body `os build` / `os verify` lowered from an inline
`handler` is judged the same way: its grant is the one the build
inferred from its calls, and the build reads each gated call in each
spelling the rule reads."
3. `action-body-capability-undeclared` bullet. Before: "an authored L2
action body that calls a gate other than the writes without its token.
An action body `os build` / `os verify` lowered from an inline `target`
function is not judged for these tokens, since its grant is the build's
inference (the lowered reading is objectstack-ai#38653); its writes are still judged
under `action-body-write-capability-undeclared`." After: "an L2 action
body that calls a gate other than the writes without its token. An
action body `os build` / `os verify` lowered from an inline `target`
function is judged the same way, against the grant the build inferred
from its calls."
4. Paragraph after FROM → TO. Before: "A hook whose body was lowered
from an inline `handler` is unchanged: FROM and TO alike, it is not
judged by this rule. So is an action whose body was lowered from an
inline `target` function, for every token but `api.write`: … TO, it
still builds clean, and its writes are judged as before." After: "A hook
written as an inline `handler`, and an action written as an inline
`target` function, need no change: the build infers the grant from each
gated call in each spelling the rule reads (`?.`, whitespace or a
comment between steps, the optional call), so the body it lowers carries
the token. … TO, it still builds clean, its lowered body granted
`api.transaction`."


**`packages/spec/src/migrations/entries/semantic/19.hook-and-action-bodies-calling-an-ungranted-gate-refused.ts`**
(entry `hook-and-action-bodies-calling-an-ungranted-gate-refused`, id
unchanged)

1. Header comment. Before: "an authored L2 hook body that calls". After:
"an L2 hook body that calls".
2. `surface`. Before: "only a body the author wrote (a hook body lowered
from an inline handler is not judged, and an action body lowered from an
inline target function is judged for its writes alone, as before)".
After: "whether the author wrote the body or os build lowered it from an
inline handler or target function".
3. `replacement`, last sentence. Before: "needs no change for the other
tokens: its lowered body is not judged for them (a later change carries
the lowered reading)." After: "needs no change: os build infers the
grant from each gated call in each spelling the rule reads (?.,
whitespace or a comment between steps, the optional call), so the body
it lowers carries the token, and that lowered body is judged like an
authored one."
4. `reason`. Before: "A hook body os build lowered from an inline
handler is not judged, and an action body it lowered from an inline
target function is judged only for api.write, as before: such a grant is
the build's inference, not the author's, and the inference does not yet
read every gated shape, so a hook written as a handler and an action
written as a target function are unchanged." After: "A hook body os
build lowered from an inline handler, and an action body it lowered from
an inline target function, are judged the same way: their grant is the
build's inference, which reads each gated call in each spelling the rule
reads, pinned spelling by spelling against the rule, so a hook written
as a handler and an action written as a target function build clean."

## Verification

Two-minute check: `pnpm --filter @objectstack/cli exec vitest run
test/extract-hook-body-local-alias-38690.test.ts`. Expect 1 file, 284
tests passed. With `MEMBER_STEP` in `extract-hook-body.ts` set back to a
plain `\.`, 84 of them fail.

Read first: the `MEMBER_STEP` / `memberLeafRx` / `blankComments` block
and the inference loop in `packages/cli/src/utils/extract-hook-body.ts`,
then the PARITY block in the test above, then the two removed skips in
`packages/lint/src/validate-action-body-capabilities.ts`.

<details><summary>Local gates at 3ca3538 (head)</summary>

- Derived round: `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` listed 122 commands (the 119 of the last
round plus `check:i18n`, `check:i18n-coverage`,
`check:i18n-walk-parity`); each ran with stdin closed and its exit
recorded before any pipe: 121 :: exit 0, and `node
scripts/check-empty-changeset.mjs --base origin/main` :: exit 1, the
DELIBERATE CORRECTION refusal above, by design. `dispatch-gates --ran`:
122 derived, 122 run, 0 NOT-MEASURED, 0 UNRUN.
- Packages: `pnpm --filter @objectstack/lint test` 252 files / 10106
tests passed; cli `vitest run --project unit` 451 files / 6737 tests
passed; `pnpm --filter @objectstack/lint typecheck` and `pnpm --filter
@objectstack/cli typecheck` exit 0; spec rebuilt, `src/migrations` 5
files / 209 tests passed.
- `node scripts/check-changeset-no-major.mjs --base origin/main --event`
over this body: exit 0 (level axis: `@objectstack/lint` minor carries
`Metadata-protocol: narrowed`; ADR-0087 `registered
lowered-hook-and-action-bodies-capabilities-judged`).
- `node scripts/pm/overlap-check.mjs` at this head: clean against
origin/main (f576dee), objectstack-ai#38497 and objectstack-ai#38192.
- Not run locally: the cli `integration` layer and `test:repo` (CI's
Test Core); the dogfood battery is CI's on this head (`!` title,
narrowing arm).

</details>

---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmSa9QNE6qXdrFAvnUr)_
<!-- signed: repo:objectstack#3 · os-steve ·
session_01ADHkmSa9QNE6qXdrFAvnUr -->

---------

Co-authored-by: Claude <noreply@anthropic.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 size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants