Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: retain structural guards in full pregate plans (#11269)

Adam Eivy10479a19e232
diff --git a/scripts/ci-test-plan.js b/scripts/ci-test-plan.js
index 0c3dc30fb9..daef228a70 100644
--- a/scripts/ci-test-plan.js
+++ b/scripts/ci-test-plan.js
@@ -471,7 +471,7 @@ const featureDirectory = (path) => {
return null;
};
-const structuralTestsFor = (changedFiles, trackedSet) => {
+export const structuralTestsFor = (changedFiles, trackedSet) => {
const selected = [];
const add = (path) => {
if (trackedSet.has(path)) selected.push(path);
diff --git a/scripts/pregate.js b/scripts/pregate.js
index e59f821286..cb5213fb83 100644
--- a/scripts/pregate.js
+++ b/scripts/pregate.js
@@ -35,7 +35,7 @@ import { spawnSync } from 'child_process';
import { execFileSync } from 'child_process';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';
-import { ALWAYS_RUN_TESTS } from './ci-test-plan.js';
+import { ALWAYS_RUN_TESTS, structuralTestsFor } from './ci-test-plan.js';
import { assertNodeVersion } from './checkNodeVersion.js';
import { isDirectlyInvoked } from './lib/directInvocation.js';
@@ -118,19 +118,30 @@ export function resolvePlanStages(plan, { skipLint = false, baseSha } = {}) {
* A full plan is CI's answer to "this diff could break anything", which is
* correct there and unusable here — the complete suite is far longer than
* anyone runs before a push, so the honest local default is the subset that
- * catches the tree-wide guards, plus a line saying what was dropped. `--full`
- * opts back in.
+ * catches always-run and diff-selected structural guards, plus a line saying
+ * what was dropped. `--full` opts back in.
*/
-export function downgradeFullPlan(plan, trackedFiles) {
+export function downgradeFullPlan(plan, trackedFiles, changedFiles = []) {
const tracked = new Set(trackedFiles);
+ const structuralGuards = structuralTestsFor(changedFiles, tracked);
+ const serverStructuralGuards = structuralGuards.filter((path) => !path.startsWith('client/'));
+ const clientStructuralGuards = structuralGuards.filter((path) => path.startsWith('client/'));
// Discover convention guards so new client scanners join the local gate
// without a second hand-maintained list (including guards under hooks/).
const clientGuards = trackedFiles.filter((path) => /^client\/src\/.*Conventions\.test\.js$/.test(path));
return {
...plan,
full: false,
- server: { mode: 'files', files: ALWAYS_RUN_TESTS.filter((path) => tracked.has(path)), sources: [] },
- client: { mode: clientGuards.length > 0 ? 'files' : 'skip', files: clientGuards, sources: [] },
+ server: {
+ mode: 'files',
+ files: [...new Set([...ALWAYS_RUN_TESTS.filter((path) => tracked.has(path)), ...serverStructuralGuards])],
+ sources: [],
+ },
+ client: {
+ mode: clientGuards.length > 0 || clientStructuralGuards.length > 0 ? 'files' : 'skip',
+ files: [...new Set([...clientGuards, ...clientStructuralGuards])],
+ sources: [],
+ },
lint: { mode: 'full', files: [] },
};
}
@@ -264,8 +275,8 @@ function main() {
console.log(`📋 ${raw.changed_files.length} changed file(s) — ${plan.reason}.`);
if (plan.full && !options.full) {
- plan = downgradeFullPlan(plan, git(['ls-files']).split('\n').filter(Boolean));
- console.log('⚠️ CI will run the FULL suite for this diff — running the always-run guards only. Pass --full to run everything.');
+ plan = downgradeFullPlan(plan, git(['ls-files']).split('\n').filter(Boolean), changedFiles);
+ console.log('⚠️ CI will run the FULL suite for this diff — running always-run and diff-selected structural guards only. Pass --full to run everything.');
}
const stages = resolvePlanStages(plan, { skipLint: options.skipLint, baseSha });
diff --git a/scripts/pregate.test.js b/scripts/pregate.test.js
index e25c3a4eaf..42a32d10ca 100644
--- a/scripts/pregate.test.js
+++ b/scripts/pregate.test.js
@@ -290,6 +290,14 @@ describe('downgradeFullPlan', () => {
const downgraded = downgradeFullPlan(planWith({ full: true }), []);
expect(downgraded.server.files).toEqual([]);
});
+
+ it('keeps structural guards selected by a large diff when downgrading a full plan', () => {
+ const tracked = [...ALWAYS_RUN_TESTS, 'server/lib/index.test.js'];
+ const changedFiles = Array.from({ length: 31 }, (_, index) => `server/lib/module-${index}.js`);
+ const downgraded = downgradeFullPlan(planWith({ full: true }), tracked, changedFiles);
+
+ expect(downgraded.server.files).toContain('server/lib/index.test.js');
+ });
});
describe('parseArgs', () => {