Skip to content

fix(pm): the scratch-dir scan does not read a declaration as a directory-creating site - #23304

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-23294-scratch-scan-declarations
Oct 13, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-23294-scratch-scan-declarations

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #23294
Clause-②: no

main's hourly full battery is red on Lint · PM dispatch-gates (the card behind it is #23274). The live-tree case "no mkdtempSync site in this tree takes a base the scan cannot read" reads examples/app-showcase/types/node-shim.d.ts:30 as a call. That line is a type declaration, export function mkdtempSync(prefix: string): string;, and the scan cannot resolve its "base", prefix: string. The declaration is correct and the reader is wrong, so this PR fixes the reader. The shim is not touched, and no gate is added.

The change

scratchDirSitesInSource (scripts/pm/dispatch-gates.mjs) no longer counts a declaration as a directory-creating site. It recognises two shapes:

  • A declaration file (.d.ts, .d.mts, .d.cts). TypeScript admits no statement in an ambient context, so every match in one is a signature, and the function returns zero sites for it.
  • A match the function keyword precedes. This covers declare function, export function, an overload, and the head of a same-file wrapper. What follows the name there is a parameter list being declared, not an argument being passed. singleCallSiteParameters already uses the same test to skip its own declarations.

Every other match is judged exactly as before. SCRATCH_CALL, the resolver and the verdict are unchanged. A wrapper's body is still read, because the calls inside it are calls.

Deliberately narrow. An interface method signature, an object-literal method or a class method in an ordinary .ts / .mjs source is still read as a site. The text that would clear one (a name, an argument list, then :) is also the text of a ternary's call, and this scan's bias is to report a site rather than clear it. A shape this rule does not clear fails loud, with its file and line. None of those shapes occurs in the tree today (measured below).

What moved on the tree

A probe listed every raw SCRATCH_CALL match in the tracked JS/TS sources, with the module's own classification of each. "Before" is the base bae5841bce and "after" is the fix, measured both before and after the merge of main (the same numbers both times):

before after
raw matches 1764 1764
sites the scan counts 1764 1762
in-tree sites 63 63
exposed 0 0
unresolved, all 315 313
unresolved mkdtempSync 1 0

The in-tree, covered, exposed and unresolved lists from exposedScratchDirs were also diffed field by field between the base tree and the fix. They differ by two unresolved entries, both in the shim, and by nothing else:

  • line 30, mkdtempSync with prefix: string, which is the red;
  • line 26, mkdirSync with path: string, which has been there since 24964153e2. It was silent only because the mkdirSync half is not held to completeness.

No in-tree, covered or outside site moved.

Other declaration shapes. Across all 1764 raw matches, 2 sit in a declaration file, and the same 2 are function-keyword declarations. Outside the shim, no match is followed by : or { after its argument list, and no match has a type-annotated first argument. So the tree has no declare function, overload, interface signature or method in a .ts source to handle today.

Self-test: six new cases, in the fast tier

The six new cases are in-process fixtures, so they sit in the fast tier, which is the tier this PR's lane runs. Each rule is pinned on a fixture only it can clear, and three controls keep both rules honest:

  1. A module shim's two signatures in a .d.ts are no site.
  2. The file rule alone: an interface method signature in a .d.mts, with no function keyword, is no site.
  3. The keyword rule alone: declare function, export function and an overload in a .ts source are no site.
  4. CONTROL: const dir = mkdtempSync(someUnreadableBase); in a .ts source is still UNRESOLVED. The case asserts the call name and the expression.
  5. CONTROL: the same call beside a declaration of the same name is still the one site, UNRESOLVED on line 2.
  6. CONTROL: in a wrapper function mkdirSync(dir) whose body calls fs.mkdirSync(dir, …), the head is not a site and the body's call is, UNRESOLVED on line 2.

The live-tree case is unchanged and stays in the slow tier.

The battery, both tiers (node scripts/pm/dispatch-gates.mjs --self-test, the equivalent of the schedule and push runs):

  • Before, at bae5841bce: ✗ dispatch-gates self-test: 1 of 2093 case(s) failed., exit 1. The one red is the card's case, word for word.
  • After, at 82522ac6a8 (this PR's head): ✓ dispatch-gates self-test: 2099 cases pass., exit 0, with fast 1839 case(s) in 428.5s · slow 260 case(s) in 1253.3s. The live-tree cases now read:
    • ✓ the sweep really read this tree (1762 directory-creating site(s) across 8973 tracked source(s))
    • ✓ and it really found in-tree fixture roots (63)
    • ✓ no mkdtempSync site in this tree takes a base the scan cannot read

The six-case difference is these cases: the tier-partition pin moved from 1817 fast + 260 slow to 1823 fast + 260 slow.

Ablations (one-time proofs, nothing left in the tree)

Each mutation went through node scripts/ablation-replace.mjs in wrap mode, on scripts/pm/dispatch-gates.mjs, with the fast tier as the wrapped command. Every leg reported the anchor going from 1 to 0 and a changed blob hash. Every restore reported a blob equal to HEAD (c7096603fe14) and an empty git diff HEAD. A driver script re-checked both after each leg, and the tree held zero ablation markers at the end.

ablation expected observed
A1: the declaration-file early return removed case 2 red case 2 red, 1 of 1839. It found the .d.mts signature as an UNRESOLVED site.
A2: the function-keyword skip removed case 3 red cases 3, 5 and 6 red, 3 of 1839. That is wider than I predicted, and correctly so: cases 5 and 6 assert that the declaration line is not a site, as well as that the call is one.
A3: the keyword test made to match everything, so every site is cleared cases 4 to 6 red cases 4, 5 and 6 red, 3 of 1839, each reading scanned: 0

Local verification, at 82522ac6a8

  • Derived gates. node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack derived 29 commands, and all 29 exited 0. The reconciliation (--ran) reads: 29 derived famil(ies) accounted for — 29 run, 0 NOT-MEASURED (a DERIVED zero …). pnpm check:pm-dispatch-gates runs the wrapper self-test and then the dev-box fast tier. It exited 0 with 1839 fast cases.
  • Selected CI family outside the derived list. The CI selector, run locally as a pull_request event, also selects bare_root_worklist, which is not among the 29. node scripts/pm/bare-root-worklist.mjs --self-test exited 0.
  • Lint, as a proven narrowing.
    • Population: the two touched files. eslint.config.mjs lints both, and neither came back ignored.
    • eslint --no-inline-config --format json reports 2 files, 0 errors and 0 warnings.
    • Invariance: the config enables no type-aware linting (no parserOptions.project, no projectService), so this diff cannot move the verdict for any untouched file.
    • The full pnpm lint is CI's.
  • pnpm check:nul-bytes: OK, 11261 text files, no raw control bytes.

Whether Lint · PM dispatch-gates runs on this PR

It does. scripts/ci/select-gate-families.sh, run locally as a pull_request event against this branch, prints run pm_dispatch_gates reads scripts/pm/dispatch-gates.mjs (M, scripts), because scripts/pm/* is in that family's read-set.

On pull_request and merge_group, though, the lane runs the fast tier only. So this PR's CI reads the six new cases, but not the live-tree case, which runs on push to main and on the hourly schedule. The both-tiers result above is the local equivalent of that run.

PR #23273's paths were outside the read-set: whole-tree content reads are off the PR path by a ruled narrowing. That is why only the hourly run caught the red.

Changeset

None, with label skip-changeset. Both touched files belong to the repository root package, @objectstack/spec-monorepo, which is "private": true and declares no files, so nothing here is published. The nearest package.json above each file is the root's.

Positive control: the same lookup on packages/spec/src/data/field.zod.ts lands on @objectstack/spec. That package is not private, and its files list includes src/**/*.zod.ts, so that file does publish.

Acceptance notes (observations, not filed)

  • ci-failure.mjs --run misses a roster member. node scripts/pm/ci-failure.mjs --run 38411694784, re-run for this PR, still exits 2. It says that Lint & Repo Gates has "NONE of its members … among this sha's check-runs". The red member is there: three check-runs named Lint · PM dispatch-gates exist on 042ef51530, a success (run 38409754946), the failure (115345404875, run 38411694784) and a later cancelled one (115345950501, run 38411617233). The likeliest reading, not verified in the code, is that grouping by name across every run on the sha keeps the later cancelled row, and that row is not in the asked run. This is out of this card's scope and is handed to the seat with the evidence above.
  • The fast tier and the in-process scratch cases. The existing hermetic scratch-scan cases still sit inside the slow section "the change set derived from git", next to the git fixtures. They are in-process and could run in the fast tier too. They are left where they are, with a pointer to the new block. Carrier: none.

Generated by Claude Code

…ory-creating site

A module shim's `export function mkdtempSync(prefix: string): string;` matched
SCRATCH_CALL as a call whose base (`prefix: string`) no resolver can read, so
the live-tree case "no mkdtempSync site in this tree takes a base the scan
cannot read" redded the full battery on main. The declaration is correct; the
reader was wrong.

scratchDirSitesInSource now skips the two declaration shapes: a declaration
file (.d.ts / .d.mts / .d.cts, which admits no statement), and a match the
`function` keyword precedes (its parameter list is declared, not passed).
Every other match is judged exactly as before. Measured at bae5841: 1764
raw matches; 1764 -> 1762 sites, the two removed being the showcase node:fs
shim's mkdirSync and mkdtempSync signatures; in-tree 63 -> 63, exposed 0 -> 0,
unresolved 315 -> 313, unresolved mkdtempSync 1 -> 0.

The self-test pins each rule on a fixture only it can clear, plus three
controls: a real mkdtempSync(someUnreadableBase) call in a .ts source is
still UNRESOLVED, alone, beside a same-name declaration, and in a same-name
wrapper's body. They are in-process, so they sit in the fast tier.

Claude-Session: https://claude.ai/code/session_012zwsLMxQBwHUYJgPyrpEvx
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet objectstack-fleet Bot added the skip-changeset PR has no user-facing published change; bypasses the changeset gate label Oct 13, 2026
@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review October 13, 2026 17:06
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge October 13, 2026 17:06
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Oct 13, 2026
Merged via the queue into main with commit 4c54486 Oct 13, 2026
44 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-23294-scratch-scan-declarations branch October 13, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m skip-changeset PR has no user-facing published change; bypasses the changeset gate

Projects

None yet

2 participants