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): select source text scanners for source changes [V4,C7]
Corey Olson502d45851022
diff --git a/src/affected-tests.js b/src/affected-tests.jsindex 65c27b5b..937bbdef 100644--- a/src/affected-tests.js+++ b/src/affected-tests.js@@ -8,6 +8,7 @@ const MODULE = /\.[cm]?js$/u;const TEST = /\.(?:test|spec)\.[cm]?js$/u;// A scanner declares this header rather than executing code while the graph is read.const TEST_TREE_INPUT = '/** @pullboard-test-input test-tree */';+const SOURCE_TREE_INPUT = '/** @pullboard-test-input source-tree */';const GLOBAL = new Set(['bin/run-tests.js', 'package.json', 'package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock', 'pnpm-lock.yaml', 'src/gate.js', 'src/cli.js', 'src/hooks.js', 'src/trusted-policy.js', 'src/affected-tests.js', 'src/module-imports.js']);/** Read exact objects from this checkout, ignoring ambient Git selectors and replacement refs. */@@ -66,8 +67,15 @@ function graphAt(root, commit) {const unknown = new Map();const always = new Set();const testTreeReaders = new Set();+ const sourceTreeReaders = new Set();paths.forEach((path, index) => {- if (TEST.test(path) && modules.get(path).split(/\r?\n/u, 1)[0] === TEST_TREE_INPUT) testTreeReaders.add(path);+ if (TEST.test(path)) {+ for (const line of modules.get(path).split(/\r?\n/u)) {+ if (line === TEST_TREE_INPUT) testTreeReaders.add(path);+ else if (line === SOURCE_TREE_INPUT) sourceTreeReaders.add(path);+ else break;+ }+ }for (const target of imports[index]) {if (target === 'node:module') { unknown.set(path, 'a reached module may create CommonJS imports'); continue; }if (target.startsWith('node:')) continue;@@ -82,12 +90,12 @@ function graphAt(root, commit) {reverse.get(dependency).add(path);}});- return { paths, reverse, unknown, always, testTreeReaders };+ return { paths, reverse, unknown, always, testTreeReaders, sourceTreeReaders };}/*** Select changed tests and every transitive importer in the old and new trees. Old edges cover- * deletions and renames; declared test-tree readers also cover changed test inputs. Other filesystem+ * deletions and renames; declared tree readers also cover changed test or source inputs. Other filesystem* reads and process launches are deliberately not import edges.** @param {string} root@@ -127,8 +135,10 @@ export function selectAffectedTests(root, { base, trunk, commit = 'HEAD', change}}const changedTestInput = changed.some(path => path.startsWith('test/') || TEST.test(path) || /^test\.[cm]?js$/u.test(path));+ const changedSourceInput = changed.some(path => path.startsWith('src/') || path.startsWith('bin/'));const selected = files.filter(path => reached.has(path) || before.always.has(path) || after.always.has(path)- || (changedTestInput && (before.testTreeReaders.has(path) || after.testTreeReaders.has(path))));+ || (changedTestInput && (before.testTreeReaders.has(path) || after.testTreeReaders.has(path)))+ || (changedSourceInput && (before.sourceTreeReaders.has(path) || after.sourceTreeReaders.has(path))));if (selected.length === files.length) return { full: true, reason: 'the change reaches every test file', files };return { full: false, reason: '', files: selected };} catch (error) {diff --git a/test/boundary.test.js b/test/boundary.test.jsindex 12e49811..b244d871 100644--- a/test/boundary.test.js+++ b/test/boundary.test.js@@ -1,3 +1,4 @@+/** @pullboard-test-input source-tree *//*** The boundary (P5): the core stays free of any particular model, inference engine or model vendor,* and of the network. Agents meet it only through the agent contract, so the core never couples todiff --git a/test/machine.test.js b/test/machine.test.jsindex af951bba..557fe13e 100644--- a/test/machine.test.js+++ b/test/machine.test.js@@ -1,3 +1,4 @@+/** @pullboard-test-input source-tree *//*** The item lifecycle's declaration (M1, M2, M4): sound on its own terms, each property shown* failing on a broken copy, and in step with the refusals the board, CLI and spec parser raise today.diff --git a/test/package.test.js b/test/package.test.jsindex 229f462c..1e234ed8 100644--- a/test/package.test.js+++ b/test/package.test.js@@ -1,3 +1,4 @@+/** @pullboard-test-input source-tree *//*** The package stays dependency-free (P3): nothing to install but Node, nothing in node_modules to* trust, and every import is a Node built-in or a file of its own.diff --git a/test/submit-gate.test.js b/test/submit-gate.test.jsindex 38a17d1d..d3a450e4 100644--- a/test/submit-gate.test.js+++ b/test/submit-gate.test.js@@ -1,4 +1,5 @@/** @pullboard-test-input test-tree */+/** @pullboard-test-input source-tree *//*** Submit proves its frozen item check and the import closure its change can reach; only a full* selection can stand in for the project gate, which still runs at landing [V4,C7,V16].@@ -498,6 +499,61 @@ test('a changed test file selects the scanners that read test files [C7,B3]', (t}});+/** Source-tree declarations cover text scanners without broadening unrelated import closures. */+test('a source change selects the tests that scan sources [C7,B3]', (t) => {+ const box = privateRepo(t);+ seedGraph(box);+ const sourceInput = '/** @pullboard-test-input source-tree */\n';+ const testInput = '/** @pullboard-test-input test-tree */\n';+ put(box.root, 'test/scanner.test.js', sourceInput + "import 'node:fs';\n");+ put(box.root, 'test/both.test.js', testInput + sourceInput + "import 'node:fs';\n");+ put(box.root, 'test/nested/both.test.mjs', (sourceInput + testInput).replaceAll('\n', '\r\n') + "import 'node:fs';\n");+ put(box.root, 'test/tests-only.test.js', testInput + "import 'node:fs';\n");+ put(box.root, 'test/quoted.test.js', "const text = '/** @pullboard-test-input source-tree */';\n");+ put(box.root, 'test/late.test.js', "// Not an input declaration.\n" + sourceInput);+ const base = commitAll(box);+ put(box.root, 'src/a.js', 'export const value = 2;\n');+ const commit = commitAll(box, 'feat(core): change source scanner input [G1]');+ const readers = ['test/both.test.js', 'test/nested/both.test.mjs', 'test/scanner.test.js'];+ const selection = selectAffectedTests(box.root, { base, commit });+ assert.equal(selection.full, false, 'scanner declarations keep affected selection');+ assert.deepEqual(selection.files, ['test/a.test.js', ...readers].sort(),+ 'the source change adds declared scanners to its normal import closure');+ for (const path of ['src/new.js', 'bin/tool.mjs']) {+ assert.deepEqual(selectAffectedTests(box.root, { base, commit, changed: [path] }).files, readers,+ path + ' selects scanners without an import edge');+ }+ assert.deepEqual(selectAffectedTests(box.root, { base, commit, changed: ['test/c.test.js'] }).files,+ ['test/both.test.js', 'test/c.test.js', 'test/nested/both.test.mjs', 'test/tests-only.test.js'],+ 'both declaration orders retain test-tree selection without adding source-only readers');+ assert.deepEqual(selectAffectedTests(box.root, { base, commit, changed: ['lib/unrelated.js'] }).files, [],+ 'other trees keep their existing import selection');+ put(box.root, 'test/scanner.test.js', "import 'node:fs';\n");+ const removed = commitAll(box, 'test(core): remove source declaration [G1]');+ assert.deepEqual(selectAffectedTests(box.root, { base: commit, commit: removed, changed: ['src/new.js'] }).files,+ readers, 'old declarations retain readers across removal');+ box.git('rm', 'src/a.js');+ const deleted = commitAll(box, 'refactor(core): remove source input [G1]');+ assert.deepEqual(selectAffectedTests(box.root, { base: commit, commit: deleted }).files,+ ['test/a.test.js', ...readers].sort(), 'source deletion retains old importers and scanners');++ const repository = resolve(import.meta.dirname, '..');+ const actual = privateRepo(t);+ const tracked = execFileSync('git', ['ls-files', '-z', 'src/', 'bin/', 'test/'], {+ cwd: repository, encoding: 'utf8',+ }).split('\0').filter(path => /\.[cm]?js$/u.test(path));+ for (const path of tracked) put(actual.root, path, readFileSync(join(repository, path), 'utf8'));+ const actualBase = commitAll(actual);+ put(actual.root, 'src/scanner-input.js', 'export const scannerInput = true;\n');+ const actualCommit = commitAll(actual, 'test(core): add an unimported source input [G1]');+ const actualSelection = selectAffectedTests(actual.root, { base: actualBase, commit: actualCommit });+ assert.equal(actualSelection.full, false, 'an unimported source addition keeps affected selection');+ for (const scanner of ['test/boundary.test.js', 'test/machine.test.js', 'test/package.test.js',+ 'test/submit-gate.test.js', 'test/wall-clock-budgets.test.js']) {+ assert.ok(actualSelection.files.includes(scanner), 'actual source-tree reader selected: ' + scanner);+ }+});+test('affected selection says explicitly when no claim head was recorded [V4,C7]', (t) => {const box = privateRepo(t);seedGraph(box);diff --git a/test/wall-clock-budgets.test.js b/test/wall-clock-budgets.test.jsindex 1e7b45a5..f0f96a03 100644--- a/test/wall-clock-budgets.test.js+++ b/test/wall-clock-budgets.test.js@@ -1,4 +1,5 @@/** @pullboard-test-input test-tree */+/** @pullboard-test-input source-tree *//** Keep test timing judgments accountable to their actual work [C7]. */import assert from 'node:assert/strict';import { execFileSync } from 'node:child_process';