Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
fix(core): read test import bindings without evaluating code [C7]
Corey Olson4aedceb3859e
diff --git a/docs/api.md b/docs/api.mdindex 74585165..aa75747a 100644--- a/docs/api.md+++ b/docs/api.md@@ -678,7 +678,7 @@ A board-recorded item merge covers its introduced commits only when its exact suThe JSON result includes `verification` entries with PR number, exact head, state, assurance, receipt identities, and any unverified commit IDs. GitHub statuses are shared by PRs with the same head: if an outside or unproven PR shares a commit with a proven proposal, the shared status stays red rather than lending the proposal's green status to it. Publishing observes and posts statuses; it never merges a PR or requires outside authors to use Pullboard.-A Node test that intentionally generates CPU load declares `{ cpuLoad: true }` in its test options. `bin/run-tests.js` discovers declarations without running the module and places the selected files on a registered runner, even with local-first admission or an inherited coordinator lease. While runners are registered it waits for a compatible runner instead of using local or short capacity; browser and GUI requirements still apply. A runner failure never permits this load to fall back locally. With no runners registered it uses the ordinary local admission and prints the reason. Source must be clean and committed for remote execution. Discovery conservatively places the whole selected file, including when a name filter selects only some cases; comments and string/template examples do not declare load. Options that cannot be read statically count as declared load: computed property names, object spreads, opaque option expressions, unresolved test-function uses and unreadable test-context member uses, unresolved CommonJS registration paths, dynamic imports, executable `eval`/`Function` references and `node:vm`/`node:module` imports require runner placement. Readable direct subtests and ordinary context lifecycle hooks retain their ordinary classification. Discovery never evaluates those expressions. A directly readable literal `cpuLoad: false` remains ordinary work.+A Node test that intentionally generates CPU load declares `{ cpuLoad: true }` in its test options. `bin/run-tests.js` discovers declarations without running the module and places the selected files on a registered runner, even with local-first admission or an inherited coordinator lease. While runners are registered it waits for a compatible runner instead of using local or short capacity; browser and GUI requirements still apply. A runner failure never permits this load to fall back locally. With no runners registered it uses the ordinary local admission and prints the reason. Source must be clean and committed for remote execution. Discovery conservatively places the whole selected file, including when a name filter selects only some cases; comments and string/template examples do not declare load. Options that cannot be read statically count as declared load: computed property names, object spreads, opaque option expressions, unresolved test-function uses and unreadable test-context member uses, unresolved CommonJS registration paths, dynamic imports, executable `eval`/`Function` references and `node:vm`/`node:module` imports require runner placement. Readable direct subtests and ordinary context lifecycle hooks retain their ordinary classification. V8 identifies imported modules without executing them; comments, quoted named imports and escaped module specifiers cannot hide registration aliases. A node:test binding that the bounded reader cannot understand is conservatively placed on runners. Discovery never evaluates those expressions. A directly readable literal `cpuLoad: false` remains ordinary work.`pullboard why <file>[:<line>] --json` uses the `why file` catalog shape; this names the file form, not a literal `file` argument. It traces commits on the repository's actual primary branch, then resolves their item trailers, served row IDs and answered decisions in one board query. The legacy `why <id>` shape is unchanged. Answered decisions carry their recorded origin, statement, rationale, decider and relayer; absent historical provenance remains `unknown`. Row and item origins are also `unknown` unless recorded, rather than inferred from a related decision. An agent may label a relayed or inherited answer but cannot use that label to mint a person-origin record. Unproven original decider identities remain unknown, with the answering relay seat recorded separately.diff --git a/src/module-imports.js b/src/module-imports.jsindex 55865ff4..13627462 100644--- a/src/module-imports.js+++ b/src/module-imports.js@@ -286,22 +286,45 @@ function opaqueTestContext(source) {}/** Unknown test option expressions are declarations under the conservative placement contract. */-function unreadableTestOptions(source, quoted) {- const code = lex(source).code;+function unreadableTestOptions(source, quoted, moduleImports) {+ const lexical = lex(source);+ const code = lexical.code;const names = new Set(['test', 'it', 'describe']);- for (const match of source.matchAll(/\bimport\s+([^;'"]+?)\s+from\s*(['"])node:test\2/gu)) {- const defaultBinding = /^\s*([A-Za-z_$][\w$]*)(?:\s*,|\s*$)/u.exec(match[1]);+ // Preserve literal spelling while removing comments, then let V8 identify every module specifier.+ const characters = source.split('');+ for (const { start, end } of lexical.comments) for (let at = start; at < end; at += 1) {+ if (characters[at] !== '\n' && characters[at] !== '\r') characters[at] = ' ';+ }+ const clean = characters.join('');+ const declarations = [...clean.matchAll(/\bimport\s+([^;]*?)\s+from\s*((?:"(?:[^"\\]|\\[\s\S])*"|'(?:[^'\\]|\\[\s\S])*'))/gu)]+ .filter(match => code.slice(match.index, match.index + 6) === 'import');+ const modules = look(declarations.map(match => `import ${match[2]};`));+ let recognizedTestImport = false;+ for (const [index, match] of declarations.entries()) {+ if (!modules[index].imports.includes('node:test')) continue;+ recognizedTestImport = true;+ const bindingSource = match[1].trim();+ const bindingCode = lex(bindingSource).code;+ const defaultBinding = /^([A-Za-z_$][\w$]*)(?:\s*,|\s*$)/u.exec(bindingCode);if (defaultBinding) names.add(defaultBinding[1]);- const namespace = /^\s*\*\s+as\s+([A-Za-z_$][\w$]*)/u.exec(match[1]);- if (namespace) names.add(namespace[1]);- const bindings = match[1].replace(/[{}*]/gu, ' ').split(',');- for (const binding of bindings) {- const [original, alias] = binding.trim().split(/\s+as\s+/u);- const name = (alias ?? original)?.trim();- if (['test', 'it', 'describe', 'suite', 'default'].includes(original?.trim())- && /^[A-Za-z_$][\w$]*$/u.test(name ?? '')) names.add(name);+ const namespace = /^(?:[A-Za-z_$][\w$]*\s*,\s*)?\*\s+as\s+([A-Za-z_$][\w$]*)$/u.exec(bindingCode);+ if (namespace) { names.add(namespace[1]); continue; }+ const named = /^(?:[A-Za-z_$][\w$]*\s*,\s*)?\{([\s\S]*)\}$/u.exec(bindingSource);+ if (!named) {+ if (!/^[A-Za-z_$][\w$]*$/u.test(bindingCode)) return true;+ continue;+ }+ for (const binding of named[1].split(',')) {+ if (!binding.trim()) continue;+ const parsed = /^\s*([A-Za-z_$][\w$]*|'(?:test|it|describe|suite|default)'|"(?:test|it|describe|suite|default)")(?:\s+as\s+([A-Za-z_$][\w$]*))?\s*$/u.exec(binding);+ if (!parsed) return true;+ const original = parsed[1].replace(/^["']|["']$/gu, '');+ const name = parsed[2] ?? original;+ if (['test', 'it', 'describe', 'suite', 'default'].includes(original)) names.add(name);}}+ // V8 is authoritative: a valid node:test import that this bounded reader missed stays on runners.+ if (moduleImports.includes('node:test') && !recognizedTestImport) return true;// A direct alias retains the same conservative rule, including renamed imported test functions.let changed = true;while (changed) {@@ -310,8 +333,7 @@ function unreadableTestOptions(source, quoted) {if (names.has(match[2]) && !names.has(match[1])) { names.add(match[1]); changed = true; }}}- const imports = [...source.matchAll(/\bimport\s+(?:[A-Za-z_$][\w$]*\s*,?\s*)?(?:\{[^}]*\}|\*\s+as\s+[A-Za-z_$][\w$]*)?\s*from\s*(['"])[^'"]+\1/gu)]- .map(match => [match.index, match.index + match[0].length]);+ const imports = declarations.map(match => [match.index, match.index + match[0].length]);for (const word of code.matchAll(/\b[A-Za-z_$][\w$]*\b/gu)) {if (!names.has(word[0]) || imports.some(([from, to]) => word.index >= from && word.index < to)) continue;const tail = pastGap(source, word.index + word[0].length);@@ -362,7 +384,7 @@ export function cpuLoadOptionsIn(sources) {const parsed = look([...sources, ...variants]);let next = sources.length;return sources.map((source, index) => {- let found = !parsed[index].compiles || commonJs[index] || opaqueLoading[index] || unreadableTestOptions(source, quoted[index]);+ let found = !parsed[index].compiles || commonJs[index] || opaqueLoading[index] || unreadableTestOptions(source, quoted[index], parsed[index].imports);for (const { disabled } of occurrences[index]) {if (!parsed[next].compiles && !disabled) found = true;next += 1;