fix(devx): bound check-driver-conformance's import scan to one statement - #12370
Merged
yinlianghui merged 1 commit intoAug 25, 2026
Merged
Conversation
`drivenFrom` decided "is this marker imported from @objectstack/spec/data" with `import[\s\S]*?\bSYMBOL\b[\s\S]*?from '<specifier>'`. Both `[\s\S]*?` are unbounded, so the three parts never had to come from the same import STATEMENT: a marker imported from a LOCAL module scored as shared-standard coverage by borrowing a sibling statement's specifier. #12135's comment masking closed the prose assembly path, not this one. The import scan is now one bounded statement matcher, reused for both halves of the rule so no roaming `import[\s\S]*?from…` is left beside the one being bound. The clause class `[^;'"]` cannot cross a statement terminator or a string literal, which is what makes the bound hold. Measured before and after over the real population — 5 drivers x 9 case-sets, 2664 (file, marker) readings, of which 54 are readings where the marker appears in code at all: 0 differ. The gate's full output is byte-identical, so no cell was dropped and the ledger is unchanged. A real parse via `ts-parse.mjs` was measured and rejected: correct, but it costs the gate its dependency-freedom (it would refuse until `pnpm install` has run) for 911ms/pass against ~0.4s for the whole gate today. Both directions are pinned, and repairs a pin the bound would otherwise have weakened: #12135's falsifiability probe called the live `drivenFrom`, so the bound turned it from a statement about masking into a statement about the bound. It now asserts against the superseded rule as text, and a second fixture — marker genuinely imported, referenced only in a docblock — keeps masking itself falsifiable. Part of #12320 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UjM2ia8Av1v5NqfqQEQmC6
yinlianghui
marked this pull request as ready for review
August 25, 2026 23:29
yinlianghui
deleted the
claude/issue-12320-driver-conformance-import-regex
branch
August 25, 2026 23:41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #12320
drivenFrominscripts/check-driver-conformance.mjsdecided "is this marker imported from@objectstack/spec/data" with a regex whose two[\s\S]*?runs were unbounded on both sides of the symbol. The three parts it wants — theimportkeyword, the symbol, and the matching specifier — never had to come from the same import statement. #12135's comment masking closed the prose assembly path; this is the cross-statement one, and it survived it.A marker imported from a local module scored as shared-standard coverage by borrowing a sibling statement's specifier:
That defeats the rule the self-test already pinned one spelling of — a locally re-declared fixture is not the shared standard — by importing the local fixture instead of declaring it with
const.Live or latent: measured, with a positive control
Swept all 5 driver packages x 9 case-sets, comparing the roaming rule against a per-statement read on masked text:
(file, marker)pairs sweptThe zero is load-bearing, so it carries a control: the synthetic above was run through the same comparison and reads
loose=true bounded=false. The sweep can see the shape — a zero means "none present", not "my search was wrong". A genuine shared import readstruein both.So the defect is LATENT, not live. No cell is dropped, the gate's full output is byte-identical before and after, and no DEBT entry is owed.
Why a bounded regex and not a real parse
An AST read via
scripts/ts-parse.mjswas prototyped and measured before choosing, not waved off: it is correct (refuses the synthetic, accepts a genuine import) and found 0 unparseable files among the 296 driver sources. It was rejected on cost — not the 911ms per pass against ~0.4s for this whole gate, but thatts-parse.mjsimportstypescript, so adopting it trades a gate that runs in a fresh worktree with nonode_modulesfor one that refuses untilpnpm installhas run.The objection a bounded regex must answer is that it is a second roaming regex beside the first. It is not: the clause class
[^;'"]cannot cross a statement terminator or a string literal, so a match starting at oneimportcannot reach a later statement'sfrom— every intervening specifier is quoted. It is also the only import matcher left in the file; the reference half carried its own roamingimport[\s\S]*?from…for stripping, and leaving that would have left the smell this change exists to remove.Two deliberate narrowings, both measured to move no cell: a bare re-export (
export { X } from …— re-exporting the cases is not running them), and a side-effect import (no clause, no symbol).Proven red, not merely narrowed
Reverse-verified by ablation on the committed fix: the import half was reverted to the roaming form, the mutation confirmed on disk three ways (the anchor text gone, the mutated
drivenFromprinted from disk, and the blob movinge51329eab4->5c664f1e37), and the self-test then failed on exactly the two#12320cases and nothing else. The restore leg returned the blob byte-identical toe51329eab4, under atrap … EXIT INT TERM.A pin this would have quietly weakened, repaired
#12135's falsifiability probe was written as
drivenFrom(proseOnly, …)— it asserted "the unmasked rule accepts this fixture" by calling the live detector. The statement bound makes that fixture red for a second, independent reason, so the probe stopped being a statement about masking and became one about the bound: a stronger tree, but a weaker pin.Repaired rather than absorbed. The probe now asserts against the superseded rule spelled out as text (so it keeps measuring what it is about), and a new fixture keeps masking itself falsifiable on the shape where the two rules come apart — a marker genuinely imported from the shared module whose only mention is a docblock. Measured: unmasked it is coverage, masked it is not.
Verification
All 12 gates green at
bfa9860e0a, the final commit — the 10 derived bynode scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstackfrom the real change set, pluscheck:nul-bytesand the gate's own--self-test. Exit codes captured before any pipe.No changeset: this is an internal CI gate script and publishes nothing user-visible.
Generated by Claude Code
Generated by Claude Code