Skip to content

fix(cli): the hook-body bound-handle look-back crosses a line break or comment like the rule - #39774

Draft
objectstack-fleet[bot] wants to merge 4 commits into
mainfrom
claude/issue-38777-wip
Draft

objectstack-fleet[bot] wants to merge 4 commits into
mainfrom
claude/issue-38777-wip

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Elon · project thread

Fixes #38777

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户无感:只有直接调用命令行工具里钩子正文提取入口的代码会看到变化,换行或注释拆开的句柄写法现在和单行写法得到同样的能力推断。
  • 为什么做:构建侧的能力推断比发布规则读得少,同一段正文换个排版就在发布时多出一条能力告警,这次把两边对齐。
  • 出错会怎样:最坏是某种写法被多推断出一项读写能力,只影响直接调用该入口的程序,撤回这一个提交即可复原。
  • 要你做什么:无。

What changes

  • packages/cli/src/utils/extract-hook-body.ts: the bound-handle look-back (callsObjectLeafThroughHandle) read the receiver chain between = and .object( with space and tab only, so const repo = ctx.api followed by .object('x'); on the next line bound no handle, while the publish rule binds it. The chain now takes any whitespace (the rule's own step). The comment half rides on the comment-blanked copy the extractor already scans (blankComments), so ctx.api // c then a newline and .object('x') is read too.
  • packages/cli/test/extract-hook-body-local-alias-38690.test.ts: gatedCalls (the census that feeds ENUMERATION, PARITY and REBOUND) gains four bound-handle spellings for every object-leaf gate: one line, a line break, a line comment, a block comment. So both directions are pinned: the build infers the token (ENUMERATION) and the publish rule draws no capability finding on the lowered body (PARITY).
  • .changeset/38777-hook-body-bound-handle-lookback.md: @objectstack/cli patch.

Metadata-protocol re-measured: none holds. The diff touches no file under packages/spec or packages/lint; the metadata schema and the publish rule accept and refuse exactly what they did. What moves is the build-side inference for direct callers of the published ./hook-body entry; os build reprints handlers on one line through its bundler and is not reached.

Tests

PARITY file, at 029f290

pnpm --filter @objectstack/cli exec vitest run --maxWorkers=2 test/extract-hook-body-local-alias-38690.test.ts

 Test Files  1 passed (1)
      Tests  284 passed (284)
Ablation: the look-back put back to space and tab only

node scripts/ablation-replace.mjs --file packages/cli/src/utils/extract-hook-body.ts --anchor ... -- vitest run (same file); the test imports ../src/, so no build sits between the mutation and the run.

ablation-replace: ok mutation landed: anchor 1 -> 0, blob 957939c64737 -> 72ae4427a91b
      Tests  66 failed | 218 passed (284)
   28 ENUMERATION / 28 PARITY / 10 REBOUND
ablation-replace: ok restored: blob == HEAD (957939c64737) and `git diff HEAD` is empty

Acceptance notes

  • node scripts/ci/snapshot-next.mjs --self-test exits 1 locally on this tree, case "live: an older version commit's push run in flight, found by the waiting reader alone". scripts/ci is byte-identical to origin/main 56bed06 on this branch and the case is offline (mocked HTTP), so this diff does not reach it; reported to the seat.
  • The cli typecheck and the gates that read built declarations (check:dts-closure, check:dual-build-cjs-loads, check:i18n*) were not measured locally (the shared verify lock was held throughout); they are CI's, on this PR's checks.

Verification

Files to read first:

  1. packages/cli/src/utils/extract-hook-body.ts, the one-character-class hunk in callsObjectLeafThroughHandle ([\w$.? \t] to [\w$.?\s]): the risk is the look-back now crossing a line break into an unrelated earlier statement; the ^\s*(?:;|\n|$) tail check on what follows .object(...) is unchanged.
  2. packages/cli/test/extract-hook-body-local-alias-38690.test.ts, gatedCalls.

Two-minute check: pnpm --filter @objectstack/cli exec vitest run test/extract-hook-body-local-alias-38690.test.ts reports 284 passed.

🤖 Generated with Claude Code

https://claude.ai/code/session_016WV4cwiNRyb9B38wT2fjYj

…r comment like the rule

The extractor's bound-handle look-back read the receiver chain between `=`
and `.object(` with `[ \t]` only, so `const repo = ctx.api` then
`.object('x');` on the next line (or after a line comment) bound no handle,
while the capability rule binds it. The chain now takes `\s`, the rule's
own step; the comment half is the comment-blanked copy already scanned.
The PARITY/ENUMERATION census gains the bound-handle spellings.

Claude-Session: https://claude.ai/code/session_01Utp6Cb7xdFx3kJYWTmyntt
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

1 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run.

What this run could not see
  • the SDK route bridge reached 71 of 255 client-bound route-ledger rows — the other 184 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 184: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 60 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 — 41 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 64b295cdd75b8fe0aafe158bdb0d7aa54d737b79 → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json 64b295cdd75b8fe0aafe158bdb0d7aa54d737b79

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

@github-actions github-actions Bot added 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 Dec 5, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4cwiNRyb9B38wT2fjYj

CI note: 2026-12-05T01:54Z · Lint · CI, release & engine gates is red at head 029f2904 on one gate, Snapshot lane guard self-test (scripts/ci/snapshot-next.mjs --self-test). It is not this PR's. scripts/ci/ is byte-identical to origin/main here, the same job is red on main 56bed066 (runs 47454493981 and 47452564684), and #39756 tracks it: the self-test fixture's 30-day waiting window expired. The PR waits for that fix on main. Zone em-bill.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4czzaKz49WLAvKtdyiY

席位核对

L1 verdict (L1-b): ACCEPT at head 029f29049b (Fixes #38777, p3). Read at 2026-12-05T02:22Z.

Face: l1-face --pr 39774: 13 ok, 2 flags (floor-checks, all-checks). Both flags come from one red: Lint · CI, release & engine gates fails only on snapshot-next self-test FAILED (1) (job 145495062428), and Lint & Repo Gates is its aggregate. That is the main-wide fixture expiry #39756, fixed on main by #39763 (64b295cd). The diff does not touch scripts/ci. Everything else: 37 success · 17 expected skip.

Against the card. The card asks for three things. (1) The look-back takes the rule's whitespace and comment step: the receiver-chain class goes from [\w$.? \t] to [\w$.?\s], so a line break now crosses, and comments cross on the comment-blanked copy the extractor also reads. (2) The PARITY enumeration gains the bound-handle spelling in both directions: gatedCalls adds one-line, line-break, line-comment and block-comment forms for every object-leaf gate, which feeds ENUMERATION, PARITY and REBOUND. (3) Ablation: putting the class back gives 66 red out of 284. Fixes is right.

Changeset: a patch on @objectstack/cli. Its sentences match the hunk. "os build is unaffected" holds, because the card's reach line says the bundler reprints handlers on one line.

N1 (nit, accepted here): the class still admits identifiers and whitespace between = and the receiver, and the rule does not. The rule binds only when = sits directly before the matched receiver (validate-action-body-capabilities.ts:543, =\s*$). With \s added, a semicolon-free body const a = foo followed by a bare ctx.api.object('x'); on the next line and then a.update({}) now binds a. I checked this with the three regexes in node: PR → a, old → none, rule → none. So the build infers api.write where the rule asks for nothing. The error points toward over-declaring, the code shape is a discarded bare .object(…) statement in semicolon-free code, and the rule's boundOnce check was already missing before this change. It does not block. A tighter chain (IDENT(\s*\??\.\s*IDENT)*) can be a follow-up if the seat wants one.

Landing: not governed, Clause-②: no, +29/−3. Merge main (for #39763) and re-run, then land once Lint is green. A merge-only head keeps this L1. Per em-bill, landing goes through the seat.


Generated by Claude Code

This branch has not been deployed

No deployments
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/s 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.

lint: the hook-body capability extractor's bound-handle look-back stops at a newline or line comment inside the binding, where the rule binds the handle

2 participants