Skip to content

chore(ci): census the call sites that set the vouched-reference mark - #31086

Merged
os-zhuang merged 6 commits into
mainfrom
claude/sec-hardening-r20
Nov 7, 2026
Merged

os-zhuang merged 6 commits into
mainfrom
claude/sec-hardening-r20

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

security#1 · os-tesla · session_01L9qibvynRbCtMndW8EHNGc

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:新增门禁 check:vouch-for-reference-callers:在 packages/、examples/、apps/ 下,只有 file-attachments 写入方(file-attachment-service.ts,恰 2 处直接调用)可以设置 vouched-reference 标记;对 vouchForReference、VOUCHED_REFERENCES 或其 Symbol 描述的任何其它写法(改名、命名空间、别名、.call、方括号、defineProperty、看不懂的 Symbol.for 参数)都转红并点名文件与行。
  • 为什么改:该标记是一项受控豁免,每个调用点都须单独复核;门禁把这条规则变成机械检查,新调用点只能以显式的白名单编辑落地。
  • 风险与回滚:纯工具改动,不发布任何包、不改运行时;最坏情况是门禁误红,回滚即还原这 7 个文件。
  • 先看:① scripts/check-vouch-for-reference-callers.mjs 的 censusOf 与 ALLOWED_CALLERS;② .github/workflows/lint.yml 的 Single authz resolver guard 步骤;③ scripts/cross-package-test-inputs.mjs 的 core 条目注释(packages/** .ts 边界)。
  • 两分钟验证:pnpm check:vouch-for-reference-callers,预期两行 ✓:self-test 39 cases pass,以及 file-attachment-service.ts (2)。
  • 需要你做的:本 PR 触及 .github/workflows/**(Tier H),需要维护者合并或授权批准。

What changes

The only production code that may set the vouched-reference mark (vouchForReference, @objectstack/core) is packages/services/service-storage/src/file-attachment-service.ts, at exactly two call sites (attachFileAs and attachUploadAs). This PR adds a call-site census gate that holds that rule.

  • scripts/check-vouch-for-reference-callers.mjs. Outside the defining module, every mention of vouchForReference, VOUCHED_REFERENCES or the key's Symbol.for description, in code or in a string literal, is exactly one of three things:

    1. A direct call, which is counted.
    2. An unrenamed import/export … from specifier, which sets nothing.
    3. A finding, naming the file and line. This covers renames on import or export, namespace or member access, bracket or string-keyed access, value aliases, .call/.apply, require destructuring, the key as a computed property or as an argument to Object.defineProperty/Reflect.set, and the description in any literal.

    A Symbol.for(…) whose argument is not a plain literal, an unsubstituted template, or a same-file const bound to a plain literal is a finding too. Counted calls are held equal to ALLOWED_CALLERS. A new caller, a count that moves either way, or a stale row is red. The stale-row message names both remedies: remove the row, or restore the call. Code is told from comments by maskComments (scripts/js-comment-mask.mjs), and Symbol.for arguments are read off maskCommentsAndLiterals. Test files are outside the census, and an empty scan is refused. The --self-test carries a 39-battery roster with a floor and the verdict handshake.

  • Surfaces. The bare run reads packages/, examples/ and apps/ over every source extension. It runs in the lint step on every PR, uncached, and it is the authority. --ts-only reads packages/** .ts alone. That is the radius of the @objectstack/core pin (its declaration-table entry and test:repo turbo inputs, which also name the script), so what the pin judges equals what re-runs it. ROOT_DIR_WATCH_HINTS spells the three roots as subtrees for the dispatch derivation, as check-org-identifier.mjs does over the same roots. The self-test holds it equal to SCAN_ROOTS.

  • Root alias check:vouch-for-reference-callers (self-test, then scan), wired into the existing Single authz resolver guard step of lint.yml. No new check context and no new required-status entry.

  • packages/core/src/security/vouched-reference-callers.pin.test.ts, listed in vitest.repo-tests.json, runs --self-test and --ts-only where Test Core runs them.

The allowlist was re-read against main (37371559b): the file holds exactly two vouchForReference( calls, and nothing else under the three roots mentions the mark outside a comment. The tree has 57 Symbol.for code sites, and all of them are readable.

Tests

  • Core repo project: 7 files / 96 tests pass on ef6658f2d1. The pin is compiled by tsconfig.test.json with no new test-typecheck debt.
  • Tree ablations, each through scripts/ablation-replace.mjs, with the restore proven by blob equal to HEAD and an empty git diff HEAD. Each injection reds the bare run, naming the file:
    • a call in packages/rest/src/query-allowlist.ts (also red under --ts-only, and the pin goes red);
    • removing the attachFileAs call (row pins 2, file holds 1);
    • import { VOUCHED_REFERENCES as MARK } (line 2);
    • Symbol.for(PREFIX + …) with an imported constant (line 3);
    • a value alias of vouchForReference (line 3);
    • a call after 'https://…' on the same line;
    • a call in examples/app-crm/src/actions/convert-lead.action.ts, which is green under --ts-only by design;
    • a call in a .mjs file under packages/, which is green under --ts-only by design.
  • Rule ablations in the script itself. Each one turns its batteries red:
    • rename finding off: 3 batteries;
    • mention finding off: 13;
    • Symbol.for argument rule off: 2;
    • maskComments swapped for a //-to-end-of-line strip: 2;
    • examples/apps dropped from SCAN_ROOTS: 1;
    • stale-row remedy text cut: 1;
    • a root dropped from, or added to, ROOT_DIR_WATCH_HINTS: 2 and 1.
  • Removing the alias line from lint.yml reds check-self-test-wired (alias-self-test-not-run).

Acceptance notes

  • Tier H: the diff touches .github/workflows/lint.yml. check-governed-merges --pr names exactly that path, landing tier H, 588 changed lines, under the 3,000-line threshold.
  • No published package moves. The only file under a package is a *.test.ts in @objectstack/core, which ships dist only. Check Changeset route 2 applies, through the skip-changeset label.
  • The step runs its two commands under the default bash -e, so a red check:authz-resolver stops the census from running in that same step. The step is red either way.

Verification

Gate run
✓ check-vouch-for-reference-callers self-test: 39 cases pass.
✓ check-vouch-for-reference-callers: every call site that sets the vouched-reference mark is allow-listed (packages/, examples/, apps/, every source extension) — packages/services/service-storage/src/file-attachment-service.ts (2).
✓ check-vouch-for-reference-callers: every call site that sets the vouched-reference mark is allow-listed (the .ts surface) — packages/services/service-storage/src/file-attachment-service.ts (2).
Derived gate families

dispatch-gates --commands derives 94 commands on the final head ef6658f2d1; all 94 exit 0 and --ran reconciles 94 run, 0 unrun. dispatch-gates --self-test --fast (1954 cases), bare-root-worklist --self-test, check-watch-hint-literal --self-test, check-self-test-wired and check-comment-mask-adoption are green, and every check-run on ef6658f2d1 concluded success or skipped.


Generated by Claude Code

The only production code that may set the vouched-reference mark
(`vouchForReference`, @objectstack/core) is the file-attachments writer,
at its two call sites (attachFileAs and attachUploadAs). The new census
gate holds that: a file outside ALLOWED_CALLERS that sets the mark, a
listed file with more or fewer call sites than its row, a renamed import,
or the mark's key spelled by hand is red, naming the file.

The bare run judges every source extension and runs in the lint step
beside the single authz resolver guard. The @objectstack/core repo pin
runs it with --ts-only, so what the pin judges equals the `.ts` radius
that re-runs it.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibvynRbCtMndW8EHNGc
@github-actions github-actions Bot added size/m ci/cd dependencies Pull requests that update a dependency file tests labels Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

⚠️ 1 changed file(s) yielded no anchor (packages/core/vitest.repo-tests.json), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files. Nothing else in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 1 changed package(s)).

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/core/vitest.repo-tests.json) — pages documenting those are invisible to this run
  • 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 — 39 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 719a502b260616c5ffe62db3c3089f3f27e78622 → packageMentionDocs.

@objectstack-fleet objectstack-fleet Bot added the skip-changeset PR has no user-facing published change; bypasses the changeset gate label Nov 7, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#1 · os-tesla · session_01L9qibvynRbCtMndW8EHNGc

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 8e8195debf30e2bfe16fda10afa540b71fc14d11
Local-runs: none
Scope: .github/workflows/lint.yml + scripts/check-vouch-for-reference-callers.mjs, package.json, packages/core/src/security/vouched-reference-callers.pin.test.ts, packages/core/vitest.repo-tests.json, scripts/cross-package-test-inputs.mjs, turbo.json (the rule and the gate that holds it, read as one change); cited on main (0373715, the merge base): packages/core/src/security/vouched-reference.ts, packages/services/service-storage/src/file-attachment-service.ts, scripts/check-self-test-wired.mjs, scripts/js-comment-mask.mjs, scripts/check-single-authz-resolver.mjs, scripts/check-system-context-census.mjs, packages/core/src/security/operation-private-keys.pin.test.ts, scripts/ci/lane-verdict.mjs, .github/workflows/ci.yml (the filter job), scripts/pm/check-governed-merges.mjs.

Reviewed at 2026-11-07T05:11Z. Face: rules, read off the PR's file list by record-recognisers --paths — .github/workflows/lint.yml is a governed path (register row .github/workflows/**, Tier H), so the review is owed at CONTRACT_REVIEW_TIER with the workflow file as its hits. Because the row is Tier H, this record is the seat's review of the change and not its landing instrument: landing still waits for the maintainer's word (Prime Directive #14). Inputs: the PR body, its file list, the three-dot diff 037371559b...8e8195debf (7 files, +399/−3; the merge commit brings nothing else), the check-runs on the head, and the cited code on main. Nothing was built, run or re-run.

① Derived judgments

What the change holds, read against the code it cites. vouchForReference (packages/core/src/security/vouched-reference.ts) returns a copy of a context carrying the VOUCHED_REFERENCES symbol; isVouchedReference reads it in objectql's write-time reference check so one (object, field, id) is not asked of the caller's read door. The header of that module says the mark is set only by a service verb on its own write and names the file-attachments writer as the one case. On main, file-attachment-service.ts holds exactly two calls — line 378 inside attachUploadAs and line 539 inside attachFileAs (the latter under caller ? … : context, so the system context carries no mark) — and no other production file under packages/ mentions the function, the key or the symbol string outside a comment (objectql's engine-referential-integrity.ts calls isVouchedReference, which sets nothing; engine-unreadable-reference-target.test.ts is a test). The ALLOWED_CALLERS row (count: 2, reason naming both verbs and the sys_attachment.file_id value) is therefore a true statement about main.

Accept-set changes — what goes red. Under packages/, on a tracked or untracked non-test source file of extension .ts .mts .cts .tsx .js .mjs .cjs .jsx: (a) a vouchForReference( call in a file with no ALLOWED_CALLERS row — red, naming the file and the count; (b) a listed file whose call count differs from its row, in either direction — red, naming the file and both numbers; (c) a row whose file no longer calls — red as a stale row; (d) an ESM import or re-export spelled vouchForReference as X — red; (e) [VOUCHED_REFERENCES] as a computed property outside the defining module — red; (f) Symbol.for('objectstack.core.vouchedReferences') spelled outside the defining module, single or double quotes — red; (g) a scan that sees zero source files — red, never a green skip. Every finding names a path and a line. Red exits 1 from the alias, which bash -e carries to the step.

What stays green. Test files (.test. .spec. .testkit. __tests__/ __fixtures__/); lines whose first non-blank characters are //, /* or *; the rest of a line after //; any span inside backticks on a line; the defining module's own spellings; everything under examples/, apps/, ui/, scripts/ and every path outside packages/; and — the finding below — every indirection that reaches the key or the function without one of the six literal spellings above.

Can the scan miss a real call site? Yes, in two ways the gate's own rule says it should not.

  1. The key's hiding spellings are not findings while the function's are. The header's rule (2) closes vouchForReference as X because a rename "would hide every later call from (1)". The identical rename of the key — import { VOUCHED_REFERENCES as MARK } from '@objectstack/core' followed by { ...ctx, [MARK]: [ref] } — is matched by nothing: the rename regex names only vouchForReference, and rule (3)'s regex requires the bracket to hold the literal identifier. The same is true of a namespace spelling ([core.VOUCHED_REFERENCES], [sec.VOUCHED_REFERENCES]), of Object.defineProperty(ctx, VOUCHED_REFERENCES, …) / Reflect.set, of Symbol.for fed a constant or a template literal instead of a quoted string, and — on the function side — of a value alias (const vouch = vouchForReference; vouch(ctx, ref)), vouchForReference.call(…), a destructuring rename in a .js/.cjs require ({ vouchForReference: v }), and a string-keyed access (core['vouchForReference'](…)). Each of these is a new call site under packages/ that the PR body says "goes red naming the file" and that stays green. The census chose to chase hiding spellings (rules 2 and 3), so leaving the symmetric ones open is a gap in its stated model, not a limit it declared. The sibling pin that declined to chase indirection (operation-private-keys.pin.test.ts) said so in its header and matched declarations only; this gate claims the wider property.

  2. The comment stripping is a private line rule of the family the tree retired. censusOf drops a line whose first non-blank characters are //, /* or *, and cuts every line at its first //. scripts/js-comment-mask.mjs (58 adopters, among them check-self-test-wired.mjs and check-cross-package-test-inputs.mjs) exists because exactly this //-to-end-of-line rule is blind to string literals: a line such as const u = 'https://…'; const c = vouchForReference(ctx, ref); loses its call, a one-liner opening with /* … */ before code is dropped whole, and a block comment whose inner lines lack a leading * is counted as code (a false red — the safe direction, but noise). check-comment-mask-adoption.mjs states the rule in its first line: nobody writes a new private comment-stripper. The gate's two regexes did not trip that adoption gate on this head, so the rule holds here by reading, not by machinery.

Other extensions and the packages/ boundary. The eight extensions cover every source kind the workspace writes; .d.ts is admitted and harmless. The boundary is the real question. pnpm-workspace.yaml makes apps/* and examples/* workspace members; examples/app-showcase and examples/app-todo depend on @objectstack/core directly, the showcase is what pnpm dev boots in-process, and the two trees hold 209 non-test source files. A call written in one of them reaches the engine exactly as a call under packages/ does, and example code is what authors copy from. Of the siblings, check-single-authz-resolver.mjs scans ['packages'] only; check-system-context-census.mjs walks packages/ and examples/; the org-identifier guard in the same lint lane reads examples/, apps/ and packages/. The pin's --ts-only radius must stay packages/**/*.ts (below), but the bare run in the lint lane sits behind no cache and no radius, so nothing stops it from reading examples/ and apps/ too. As written, the header's first sentence ("every production source file that sets the mark") is wider than what the scan reads, and the body's claim is narrowed to "under packages/" only one paragraph later. Should-fix: widen the bare run, or narrow the claim to the surface. ui/ is a client tree and scripts/ holds no engine context; neither needs the census.

The --ts-only split. Honest in both directions. inScanSurface(path, { tsOnly: true }) is endsWith('.ts'), which admits neither .mts nor .cts nor .tsx — the same boundary operation-private-keys.pin.test.ts measured and kept — and it equals the @objectstack/core glob packages/**/*.ts in scripts/cross-package-test-inputs.mjs and the @objectstack/core#test:repo input in turbo.json; the gate script itself is added to both in the same hunk, and the pin names it through resolve(HERE, '…'), a spelling the cross-package gate reads. Under --ts-only the allowlist is narrowed to .ts rows before the stale-row pass, so a non-.ts row is left to the bare run rather than reported stale — the third battery pins that. The CI step does not go blind: the bare run lives in lint-docs-code (lane 3 of the Lint & Repo Gates aggregate), which needs only schedule-gate, carries no path filter and no cache, so every PR runs the eight-extension census. One input the pin's radius does not name: the gate imports scripts/invoked-as.mjs, which decides only whether main() runs; a cached green cannot change meaning through it. Not a finding.

Is the self-test genuinely wired? Yes. The root alias is --self-test && scan; check-self-test-wired.mjs reads the lane's run: | block with pnpm\s+(?:run\s+)?(alias) after masking YAML comments, so the alias is a wired member and the comment in the hunk that names --self-test is prose to it; the PR's ablation 4 reports the expected alias-self-test-not-run red when the line is removed. The core pin runs --self-test and --ts-only as two cases and asserts an empty stderr, exit 0 and the success line. The battery meets the AGENTS.md shape: a frozen roster of 15 named batteries with a floor of 1 each, the roster size pinned at 15, red when a case names an undeclared battery, when a declared battery registers fewer than its pin, when a label is reused, or when the roster shrinks; selfTestReachedVerdict is set as the last statement after the success line, and main() exits 1 saying the verdict was not reached when it is unset. Table-driven after check-agent-model-declared.mjs, copied and not imported. The 15 cases cover (a)–(g) above plus the three --ts-only cases; none covers the spellings in finding 1 or the string-literal shapes in finding 2, which is consistent with the gate not detecting them.

Does the workflow edit add or change a required context? No. The hunk edits the run: of the existing step single-authz-resolver-guard (same name:, same id:, same continue-on-error: true) in the existing lint-docs-code lane; no job, step or output is added. The lane's Lane verdict step reads toJSON(steps), so a red step still reds the lane and the lane still reds the required Lint & Repo Gates aggregate, whose roster is untouched. With the default bash -e, a red check:authz-resolver stops the census from running in that step; the step is red either way, and the census's own red is reported on the next run. check-required-contexts.mjs's contract (the ten names) is not touched.

Checks on the head at the time of reading. Lint & Repo Gates success (2026-11-07T05:03:08Z, all eight lanes green — the new step runs in lint-docs-code, check-self-test-wired.mjs and check-comment-mask-adoption.mjs in lint-repo-tooling, check:cross-package-test-inputs, check:ci-filter-parity and check:turbo-task-graph in lint-ci-engine, so every one of them passed on this head); Governed Surface Queue Guard, Build Core, Live E2E UI, Build & E2E UI and Lint UI success; Test Core shards 2/8 and 8/8 success with the other six in progress (the repo project that runs the new pin is among them), TypeScript Type Check, Type Check UI and Test UI still in progress at the last read (2026-11-07T05:09:00Z). Check Changeset shows one failure (2026-11-07T04:59:13Z: the run that fired at open waited its label window and found no label) superseded by the labeled re-run that skipped (2026-11-07T04:59:21Z) once objectstack-fleet[bot] applied skip-changeset at 2026-11-07T04:59:10Z — the documented shape, and not one of the ten required contexts.

② Semver level

No published package moves. The only file under a package is packages/core/src/security/vouched-reference-callers.pin.test.ts plus the vitest.repo-tests.json roster entry; @objectstack/core ships dist only, and a *.test.ts is compiled by tsconfig.test.json, never emitted. The root package.json gains a check:* script, turbo.json and scripts/** are tooling, .github/workflows/lint.yml is CI. Changeset: none is correct, and Check Changeset route 2 prescribes the skip-changeset label for a diff that publishes nothing from any released package; the label is on the PR, applied by the seat's bot, as the PR body left it. Clause-②: no and Metadata-protocol: none are both line-initial in the body and both right: nothing an author can write changes, no key, value, type, meaning or default. Level: no release; the declarations, had a changeset existed, would grade patch. Nothing to carry a BREAKING banner or an ADR-0087 disposition.

③ Boundary flags

  • Governed: .github/workflows/lint.yml — register row workflows, Tier H. This record reviews the change; it does not lift the Tier H landing rule (Prime Directive feat: Comprehensive CRM example demonstrating all ObjectStack protocol features #14: the maintainer's merge, enqueue, or an authorized approval). check-governed-merges --branch per the PR body names exactly that path at 402 changed lines.
  • No packages/spec change; no regenerated artifact owed. No ADR-governed surface touched; the mark's own rule stays where vouched-reference.ts wrote it, and the gate header restates it in rule form.
  • No new environment variable, no new route, no runtime behaviour: the diff can only ever turn a CI step red.
  • The gate reads the tree through git ls-files --cached --others --exclude-standard -- packages, so build output never reads as a call site and an untracked new file is judged locally before it is committed — the finding: the merge queue is being blocked by a fourth __ operation-private-key declaration that exists in no merged commit — main is clean, so the copy is riding in an open PR #7706 shape the sibling pin adopted.
  • Cross-package declaration and turbo inputs widen together (both hunks add the gate's own path and nothing else), so check:cross-package-test-inputs Layer B holds and Layer C holds because scripts/** sits in ci.yml's crosspkg list.

④ Design judgment

This is the sibling gates' shape, in the parts that matter: an allowlist whose rows carry a reason, equality counts rather than a ceiling (the "recorded set is exactly reached" property check-self-test-wired.mjs's header singles out as the one that makes a weakened rule visible), a stale-row pass, an empty scan refused by name, git's surface rather than a directory crawl, a table-driven self-test with a named-battery floor and a verdict handshake, and a repo-project pin whose judged population equals its declared radius. The two-surface split is the right answer to the .ts-only radius the core entry's comment defends; it is better than widening the glob and better than a pin that judges what nothing re-runs for it. Folding the alias into the existing authz-resolver step rather than a new step keeps the required set and the lane roster byte-identical, which is what the aggregate's header asks of a new gate.

Where it departs from the house shape, the departures are the two findings in ①: a hand-written comment rule where the tree has one shared mask and a gate that exists to stop new private ones, and a hiding-spelling rule applied to one of the gate's two names. Both are cheap to close and both close in the fail-safe direction. The simplest remedy for finding 1 is one rule instead of several: on a scanned line, any occurrence of vouchForReference or VOUCHED_REFERENCES that is neither a counted call vouchForReference( nor an unrenamed import { … } / export { … } from specifier is a finding ("a spelling the census cannot count — call vouchForReference, unrenamed, or add the row"), plus a Symbol.for( whose argument is not a quoted literal. That collapses rename, namespace access, value alias, .call, defineProperty and string-keyed access into one regex pair and two or three batteries, and it is the direction the sibling header prefers — a false red over a quiet green. For finding 2, import { maskComments } from './js-comment-mask.mjs' and run the census over the masked text; the backtick rule can stay, since the mask deliberately leaves template literals alone.

Two smaller notes, neither a finding. The pin test asserts the literal file-attachment-service.ts (2), a second copy of the row that must move with it; it pins the tree rather than the list, so the duplication is tolerable, but a future row is a two-file edit. And the stale-row message says "remove the stale row" where the sibling messages also say what the file should do instead; adding "or restore the call" would keep the equality's two directions equally visible to the next author.

Must-fix

  1. The census does not treat the key's hiding spellings as findings while it does the function's: import { VOUCHED_REFERENCES as X }, [ns.VOUCHED_REFERENCES], Object.defineProperty/Reflect.set with the key, a Symbol.for fed a constant or template, and on the function side a value alias, .call, a require destructuring rename and a string-keyed access all set the mark under packages/ and stay green. Close with one "uncountable mention is a finding" rule on both identifiers, and pin it with batteries.
  2. censusOf strips comments with a private first-character and //-to-end-of-line rule — the family scripts/js-comment-mask.mjs retired and check-comment-mask-adoption.mjs forbids anew — and it hides a call that follows a // inside a string on the same line or follows a /* … */ opener. Mask with maskComments before counting; add a battery for each of the two shapes.

Should-fix

  1. Widen the bare run's roots to examples/ and apps/ (workspace members that depend on @objectstack/core and boot the kernel), or narrow the header's "every production source file" to "under packages/"; the pin's --ts-only radius stays packages/**/*.ts either way.
  2. Make the stale-row message name both remedies (remove the row, or restore the call), as the count-mismatch message already does.

Implemented-by: claude/sec-hardening-r20
Reviewed-by: session_01L9qibvynRbCtMndW8EHNGc

VERDICT: FAIL

…ery other spelling

Outside the defining module, every mention of vouchForReference,
VOUCHED_REFERENCES or the key's Symbol.for description is a counted direct
call, an unrenamed import/export-from specifier, or a finding naming the
file and line. Renames of either name, namespace and bracket access, value
aliases, .call/.apply, require destructuring, the key as a computed
property or a defineProperty/Reflect.set argument, and the description in
any literal are all findings. A Symbol.for whose argument is not a plain
literal or a same-file const bound to one is a finding too.

Comments are told from code by maskComments (js-comment-mask.mjs) rather
than a private line rule, so a // inside a string or a /* ... */ span on
the same line no longer hides a call.

The bare run now reads examples/ and apps/ as well as packages/; --ts-only
keeps the core pin's packages/**/*.ts radius. The stale-row message names
both remedies. The self-test grows to 37 batteries.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibvynRbCtMndW8EHNGc
@github-actions github-actions Bot added size/l and removed size/m labels Nov 7, 2026
…or the dispatch derivation

The census walks packages/, examples/ and apps/ whole, and the dispatch
derivation refuses a bare root word as too generic, so SCAN_ROOTS alone
left the gate in no dispatch brief. ROOT_DIR_WATCH_HINTS spells the same
three roots as subtrees, as check-org-identifier.mjs does over the same
roots, and two self-test batteries hold it equal to SCAN_ROOTS.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibvynRbCtMndW8EHNGc
check-watch-hint-literal reads the declaration as a literal array of
strings; an Object.freeze wrapper is a computed spelling to it.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibvynRbCtMndW8EHNGc
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#1 · os-tesla · session_01L9qibvynRbCtMndW8EHNGc

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: ef6658f2d1c35db4fb8487be8bf5ada1c42222aa
Local-runs: none
Scope: .github/workflows/lint.yml + scripts/check-vouch-for-reference-callers.mjs, package.json, packages/core/src/security/vouched-reference-callers.pin.test.ts, packages/core/vitest.repo-tests.json, scripts/cross-package-test-inputs.mjs, turbo.json (the rule and the gate that holds it, read as one change); cited on main (0373715, the merge base; none of the cited files differs on origin/main 51992df): packages/core/src/security/vouched-reference.ts, packages/services/service-storage/src/file-attachment-service.ts, scripts/js-comment-mask.mjs (maskComments, maskCommentsAndLiterals), scripts/check-self-test-wired.mjs, scripts/check-org-identifier.mjs (ROOT_DIR_WATCH_HINTS), scripts/pm/bare-root-worklist.mjs, scripts/pm/dispatch-gates.mjs (the subtree idiom and the wide-population channel), scripts/check-comment-mask-adoption.mjs, scripts/check-watch-hint-literal.mjs, scripts/cross-package-test-inputs.mjs, turbo.json, the Single authz resolver guard step of lint.yml.

Reviewed at 2026-11-07T06:32Z, round 2. Face: rules, read off the PR's file list by record-recognisers --paths (.github/workflows/lint.yml is the one hits path; register row .github/workflows/**, Tier H), so the review is owed at CONTRACT_REVIEW_TIER. Because the row is Tier H, this record is the seat's review of the change and not its landing instrument: landing waits for the maintainer's word (Prime Directive #14). Inputs: the PR body as updated, its file list, the three-dot diff 037371559b...ef6658f2d1 (7 files, +585/−3; four commits since the round-1 head 8e8195debf), the check-runs on the head, the round-1 record (comment 6702662967, 2026-11-07T05:11:46Z) and the cited code on main. Nothing was built, run or re-run; every count below is a git grep or git ls-tree over the merge base.

① Derived judgments

Round-1 must-fix 1 — every mention that is not a counted call in an allow-listed file is a finding. Closed in code. censusOf now has one rule with three outcomes. MENTION matches vouchForReference and VOUCHED_REFERENCES as whole tokens and vouchedReferences inside any longer text, over maskComments(source), so string, template and regex literals are still in view. First pass: every import { … } from / export { … } from specifier list is read; a specifier equal to the bare name is blanked and sets nothing, a specifier that renames (as X, on import or export, type-qualified or not) is a finding and is blanked too, so it is reported once. Second pass: every remaining mention is a counted call only when it is the function, is not preceded by ., [, ', " or a backtick, and is followed by an optional type argument list and (; anything else is a finding naming the file and line. Read against the shapes round 1 listed, each is now red, and each has a battery: the key renamed on import then used as [MARK] (red at the import line), [ns.VOUCHED_REFERENCES], Object.defineProperty(ctx, VOUCHED_REFERENCES, …), Reflect.set(ctx, VOUCHED_REFERENCES, …), const v = vouchForReference; v(…), .call, .apply, const { vouchForReference: v } = require(…) in a .cjs, core['vouchForReference'](…), core.vouchForReference(…), a template-literal mention, a rename on re-export, Symbol.for('objectstack.core.vouchedReferences'), and Symbol.for fed a same-file const holding the description, an imported or concatenated constant, or a substituted template. The defining module is the one file whose own spellings are exempt, by exact path.

Trying to miss a call site again. Read, not run; every line is a trace through the regexes above.

  • globalThis.Symbol.for(…): \bSymbol\s*\.\s*for\s*\( matches after the dot. Red when the argument is unreadable; the description, if written whole anywhere, is a mention and red on its own.
  • (await import('@objectstack/core')).vouchForReference(…) and m.vouchForReference(…) after a dynamic import: preceded by ., red. const { vouchForReference } = await import(…): the destructured name is neither a specifier of an import … from statement nor followed by (, so it is a finding at the destructure — a false red in the fail-safe direction, and the remedy text ("call directly, unrenamed") is not quite the author's remedy (a static import). Same for an unrenamed require destructuring in a .cjs/.js file: red, as the header's rule 3 says it is.
  • Re-export chains: export { vouchForReference } from '@objectstack/core' in a barrel is unrenamed and green; a consumer calling the name imported from the barrel is counted wherever the call is, since the count never asks where the import came from. export * from carries no name and is green; export * as sec from then sec.vouchForReference( is red. A local export { vouchForReference } without from is red (false red, fail-safe). A local redefinition — export const vouchForReference = core.vouchForReference — is red twice.
  • Object.assign(target, markedCtx) or { ...markedCtx }: not a spelling at all. The mark rides a spread by design (vouched-reference.ts, "It is spent on the verb's own write"); the census counts call sites, not the writes a marked context reaches, and the header says so ("every call site is reviewed on its own"). The reviewer of the one row still reads the reach of each call, as attachUploadAs hands its marked unitContext to one insert. A design limit stated in the gate, not a gap in its rule.
  • .cjs / .jsx / .mts / .cts / .tsx: SOURCE_FILE admits all eight extensions on the bare run; .d.ts is admitted and a declare function vouchForReference( in one would count as a call and red — fail-safe.
  • Parenthesised or comma-wrapped references ((0, vouchForReference)(…)), ?.(, a callback position (refs.map(vouchForReference)), a nested type argument list with its own angle brackets or a parenthesised function type inside one: each fails CALL_TAIL and is a finding. False reds, all in the fail-safe direction; the type-argument shape is the one an author may actually write, and the remedy is a local type alias.
  • A .testkit. file is outside the census by name but is importable by production code. On main the three files importing a *.testkit module are a vitest reporter, a global-setup file and a .pin.ts, so the pattern is not practised; still, a testkit that wraps the call and a production file that imports the wrapper would be green on both sides. Noted below as a boundary to state, not a must-fix: the sibling operation-private-keys.pin.test.ts keeps the same exclusion.
  • The one class the census cannot see: a name that never appears in the source as a whole token, and a symbol read off a context that already carries the mark. No text census closes that class, and the header does not claim to: rule 3 is "anything else among the occurrences of the three names". The header should say the boundary in one sentence so the next reader does not infer a wider property (should-fix 2).

Round-1 must-fix 2 — the shared mask. Closed. censusOf reads maskComments(source) and unreadableSymbolFor reads maskCommentsAndLiterals(source) alongside it, both from scripts/js-comment-mask.mjs; no private stripper remains. Two batteries pin the two shapes round 1 named (a // inside a string before a call on the same line; a /* … */ span before code on the same line), and the PR's rule ablation reports both go red when the mask is swapped for a line strip. The comment battery also covers a block comment whose inner lines have no leading star, which the old rule counted as code. check-comment-mask-adoption is green on this head.

Round-1 should-fix 3 — the bare run reads examples/ and apps/. Closed. SCAN_ROOTS is ['packages', 'examples', 'apps']; readTree passes them to git ls-files and inScanSurface admits a path under any of them. Two batteries pin an examples/ call red on the bare run and green under --ts-only. On the merge base the three roots hold 4,437 + 170 + 39 non-test source files; the only mentions outside the defining module are the two counted calls, the unrenamed re-export pair in packages/core/src/security/index.ts, and comments.

Round-1 should-fix 4 — the stale-row message names both remedies. Closed. "Remove the stale row in the same change, or restore the call it pins if its removal was not meant"; the battery asserts the second clause by text.

The Symbol.for argument rule and its breadth. It runs over every Symbol.for( in code (not in a literal) in every scanned file, whether or not the file mentions the mark. Readable means a plain quoted literal, a template with no substitution, or a bare identifier bound in the same file by const to a plain literal (the binding is found by name, not by scope; a shadowing parameter is a contrivance the mention rule still covers whenever the description is written whole). Option A (as written, every Symbol.for) against Option B (only files that mention the mark): A is the right breadth, and B is close to empty. A file that mentions the mark is already red for the mention, so B adds a finding only where a finding already stands; the case the rule exists for — a description assembled from pieces, in a file that by construction writes none of the three names — is exactly the file B would never read. Cost today: zero, every one of the tree's Symbol.for code sites under the three roots reads plainly (57 by the PR's count, 59 by a line grep that also catches two trailing-comment lines). Cost tomorrow: a convention that a registry key's description is visible at its Symbol.for, which is sound hygiene on its own and which every present site already meets. One cost to soften: the finding is printed by a gate named for the vouched-reference mark, and its text names no reason an author of an unrelated symbol under apps/ would recognise — one clause ("so that the description it registers is seen not to be the vouched-reference mark's") would place it (should-fix 3).

ROOT_DIR_WATCH_HINTS = ['packages/**', 'examples/**', 'apps/**'] — honest, and what it costs. Honest: readTree enumerates exactly those three subtrees through git ls-files, reads every source file in them (the fixed-string prefilter runs after the read, so every file is opened), and any file under them can change the verdict by gaining a call or a Symbol.for. The declaration is the check-org-identifier.mjs shape over the same roots, spelled as a plain literal (the last commit, ef6658f2d1, made it one; check-watch-hint-literal reads only that spelling), with two batteries holding it set-equal to SCAN_ROOTS in both directions. Cost to the derivation: the family lands in the MATCHED column of every card that touches any file under the three roots — in practice nearly every card — adding one command (an in-memory self-test and a scan that opens 4,646 files and reads 104 of them past the prefilter; a few seconds, no network). Precision in the worklist's sense is 36% (4,646 non-test source files of 12,815 tracked under the roots), beside the 39% the worklist's REFUSE-WIDE row records for check-single-authz-resolver.mjs, the sibling in the same step, which declares nothing. The tree carries both precedents: that REFUSE-WIDE row, and the October 18 withdrawal of four such rows under ruling 6243472660, which ordered a four-root gate to declare its roots. The PR takes the later direction, the self-test holds it from drifting, and bare-root-worklist --self-test and Lint · PM dispatch-gates are green on the head. Acceptable; the trade is the maintainer's to revisit, not a finding.

Accept-set changes — what goes red. On a tracked or untracked, non-ignored, non-test file of extension .ts .mts .cts .tsx .js .mjs .cjs .jsx under packages/, examples/ or apps/: (a) a counted call in a file with no row; (b) a listed file whose count differs from its row, either way; (c) a row whose file no longer calls (stale, both remedies named); (d) any mention of vouchForReference or VOUCHED_REFERENCES that is neither a counted call nor an unrenamed import/export … from specifier — renames on import or export, member, namespace, bracket or string-keyed access, value aliases, .call/.apply, require destructuring (renamed or not), the key as a computed property or as an argument, a mention in a type position, a local redefinition, a destructured dynamic import; (e) vouchedReferences inside any literal or identifier, case-sensitive; (f) a Symbol.for( in code whose argument is not a plain literal, an unsubstituted template, or a same-file const bound to a plain literal; (g) an empty scan. Every finding names a path and a line; red exits 1 from the alias, which bash -e carries to the step.

What stays green. Test files by name (.test. .spec. .testkit. __tests__/ __fixtures__/); comments, through the shared mask; the defining module's own spellings; isVouchedReference, withoutVouchedReferences, VouchedReference (none contains a matched token); unrenamed specifiers in import/export … from statements; a Symbol.for inside a string or template of generated source; ui/, scripts/, content/ and every path outside the three roots; under --ts-only, everything that is not a packages/** .ts file, including the rows for such files; and the assembled-name class above. The three roots hold no vouchedReferences token outside the defining module today, so the unbounded third alternative of MENTION costs nothing now; an author who later names a local vouchedReferencesByObject in objectql will meet a false red with a remedy text about the symbol description.

Is the self-test genuinely wired, and does its floor hold? Yes on both. The root alias is --self-test && scan; check-self-test-wired.mjs reads multi-line run: | blocks (its own battery at line 1198 holds that shape) and credits the alias, and the PR's ablation reports alias-self-test-not-run when the line is removed. The roster is 39 named batteries, each pinned at 1, SELF_TEST_BATTERY_FLOOR = 39, and 39 table rows whose labels match the roster one to one (37 verdict rows and two holds rows for the hint declaration). The floor reds when the roster shrinks below 39, when a label repeats, when a case names an undeclared battery, or when a declared battery registers fewer than its pin. selfTestReachedVerdict is set as the last statement after the success line, and main() exits 1 naming the unreached verdict when it is unset. Table-driven after check-agent-model-declared.mjs, copied, not imported. The core pin runs --self-test and --ts-only live and asserts an empty stderr, exit 0 and the success line; its second assertion still carries a literal copy of the row (file-attachment-service.ts (2)), so a future row is a two-file edit — round 1's note stands, tolerable.

The pin's radius, one input short. The @objectstack/core entry of cross-package-test-inputs.mjs and the test:repo turbo inputs both gain scripts/check-vouch-for-reference-callers.mjs, so Layer B holds and the pin re-runs when the gate changes. The gate now imports scripts/js-comment-mask.mjs, and the pin's verdict depends on what that module calls code: the same table already records this exact dependence for envelope-caller-census.test.ts ("a real read, not a prose mention: the census count changes if the mask does") and names the mask as an input there. A mask change would replay a cached green on the pin while the bare run in the lint lane, uncached and a superset of the .ts surface, still judges the same files on the same PR — so nothing goes unjudged, but the pin's standing is stale on such a change. Add the mask to the entry and to turbo.json (should-fix 1).

Does the workflow edit add or change a required context? No. The hunk edits the run: of the existing single-authz-resolver-guard step (same name:, id: and continue-on-error: true) in lint-docs-code, lane 3 of 8 behind Lint & Repo Gates; the lane's Lane verdict reads toJSON(steps), so a red step still reds the lane and the aggregate. No job, step, output, needs or if: changes; the ten required contexts in check-required-contexts.mjs are untouched. Under the default bash -e, a red check:authz-resolver stops the census from running in that step and the step is red either way; the census's own red is seen on the next run.

Checks on the head. Every check-run on ef6658f2d1 concluded success or skipped: Lint & Repo Gates with all eight lanes, Governed Surface Queue Guard, Build Core, Test Core and its eight shards, TypeScript Type Check and the four typecheck lanes, Test UI, Lint UI, Build & E2E UI, Live E2E UI, Check PR Size, the PR-body guards. Check Changeset ran twice and skipped twice — the skip-changeset label was on the PR before this head's runs, so the round-1 failure-then-skip shape did not recur.

② Semver level

No published package moves. The only file under a package is packages/core/src/security/vouched-reference-callers.pin.test.ts, listed in vitest.repo-tests.json, compiled by tsconfig.test.json and never emitted; @objectstack/core ships dist only. The root package.json gains one check:* alias; turbo.json, scripts/** and .github/workflows/lint.yml are tooling and CI. Changeset: none is correct; Check Changeset route 2 applies through the skip-changeset label, which the PR carries. Clause-②: no and Metadata-protocol: none are both line-initial in the body and both right: nothing an author can write changes. Level: no release; had a changeset existed it would grade patch. No BREAKING banner, no ADR-0087 disposition.

③ Boundary flags

  • Governed: .github/workflows/lint.yml, register row .github/workflows/**, Tier H. This record reviews the change and does not lift the Tier H landing rule. The PR's check-governed-merges --pr reading names exactly that path, 588 changed lines.
  • No packages/spec change, no regenerated artifact owed, no ADR surface. The mark's rule stays in vouched-reference.ts; the gate header restates it and adds the census's own boundary.
  • No environment variable, route or runtime behaviour: the diff can only turn a CI step red.
  • The scan reads git's surface (--cached --others --exclude-standard), so build output never counts and an untracked new file is judged locally before commit.
  • Declaration and turbo inputs widen together in the same hunk; Layer C holds because scripts/** sits in ci.yml's crosspkg list. One input (the mask) is still undeclared, above.

④ Design judgment

This is the sibling gates' shape, and closer to it than round 1's head: an allowlist whose rows carry a reason; equality counts, not a ceiling; a stale-row pass that names both remedies; an empty scan refused by name; git's surface, not a directory crawl; the shared comment mask; a table-driven self-test with a named-battery floor and the verdict handshake; a repo-project pin whose judged population equals its declared re-run radius, with the wider surface judged uncached in the lint lane on every PR; the dispatch declaration spelled the way the derivation reads it and held set-equal to the scan; and the alias folded into an existing step so the lane roster and the required set stay byte-identical.

The one-rule redesign ("a mention the census cannot count is a finding") is the direction round 1 asked for and the one the sibling headers prefer: a false red over a quiet green. Its false reds are enumerable and cheap — a destructured dynamic import or require, a local re-export without from, a callback position, a type argument list with nested brackets — and each has a one-line remedy, though the shared remedy text fits the renamed cases better than the destructured ones. The Symbol.for readability rule is fail-safe at zero present cost and is the only breadth at which it has teeth.

What remains is boundary prose and one declared input, not machinery: the header should say in one sentence what no text census sees (an assembled or escaped name; a symbol read off an already-marked context), the way the sibling pin states what it declined to chase; the mask belongs in the pin's declared inputs by the table's own precedent; and the Symbol.for finding should carry its reason. None of the three changes an accept set.

Must-fix

  • none

Should-fix

  1. Add scripts/js-comment-mask.mjs to the @objectstack/core globs in scripts/cross-package-test-inputs.mjs and to @objectstack/core#test:repo inputs in turbo.json, as the envelope-caller-census entry already does for the same dependence; the pin's verdict moves when the mask does.
  2. State the census's boundary in the header in one sentence: a name assembled from pieces or spelled with escapes, and a symbol read off a context that already carries the mark, are outside any text census and are left to the row's reviewer; and either drop .testkit. from TEST_FILE or name it there as a known edge.
  3. Give the Symbol.for finding its reason in one clause, since it fires in files that never mention the mark; and let the "cannot count" remedy text also name the static-import remedy for a destructured import()/require.

Implemented-by: claude/sec-hardening-r20
Reviewed-by: session_01L9qibvynRbCtMndW8EHNGc

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#1 · os-tesla · session_01L9qibvynRbCtMndW8EHNGc

席位核对

ACCEPT · 2026-11-07T06:33Z · head ef6658f2d1c35db4fb8487be8bf5ada1c42222aa

  • Contract review: PASS at this head, CONTRACT_REVIEW_TIER on the rules face (.github/workflows/lint.yml, Tier H), record 6703410200. It supersedes the round-1 FAIL 6702662967, and every round-1 item is closed in code with a battery. There is no must-fix. Its three should-fixes go into this seat's follow-up list, and none changes what lands here:
    • Name scripts/js-comment-mask.mjs in the core pin's declared inputs (cross-package-test-inputs.mjs, turbo.json).
    • Add one boundary sentence to the census header, and settle .testkit..
    • Give the Symbol.for finding its reason clause and a static-import remedy.
  • Seat rulings on the dev's open question: the Symbol.for argument rule stays wide (option A). It is fail-safe and costs nothing today. The ROOT_DIR_WATCH_HINTS declaration over packages/, examples/ and apps/ is accepted as the same trade check-org-identifier.mjs makes.
  • What lands: a call-site census gate, check:vouch-for-reference-callers.
    • The file-attachments writer is the only production code that may set the vouched-reference mark, at two allow-listed calls.
    • Any other spelling under packages/, examples/ or apps/ is red, and so is a moved count or a stale row.
    • The bare run is wired into the existing single authz resolver guard step. The --ts-only run is a core repo pin. No required context is added or changed.
  • Checks: every check-run on this head is success or skipped. The ten required contexts are green, and Check Changeset is skipped under skip-changeset. git merge-tree against current main is clean.
  • Gates (dev, at this head): dispatch-gates --commands derived 94, ran 94, all green. The fast-tier self-test (1954 cases), bare-root-worklist, check-watch-hint-literal, check-self-test-wired and check-comment-mask-adoption self-tests are all green. The census self-test passes 39 cases (floor 39). Tree and rule ablations went red as predicted and were restored.
  • Shape: base main, no closing keyword, tooling only. Clause-②: no, Metadata-protocol: none, skip-changeset.
  • Governed: check-governed-merges.mjs --pr 31086 reports GOVERNED. The one path is .github/workflows/lint.yml, Tier H, 588 changed lines ≤ 3000.
  • Landing authority: Tier H, so the maintainer's standing approval for Tier S does not cover it. Landing waits for an approving review from a governed approver.
  • Next: relay pr_request_reviewers naming os-zhuang. After the approval comes pr_ready + automerge_enable.

Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/cd dependencies Pull requests that update a dependency file size/l skip-changeset PR has no user-facing published change; bypasses the changeset gate tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants