diff --git a/specification/loops/xrvxyr-unit-lane-classification/loop.json b/specification/loops/xrvxyr-unit-lane-classification/loop.json new file mode 100644 index 00000000000..fb597ebf475 --- /dev/null +++ b/specification/loops/xrvxyr-unit-lane-classification/loop.json @@ -0,0 +1,65 @@ +{ + "name": "xrvxyr-unit-lane-classification", + "goal": "Keep standard unit checks out of the Mac heavy test lanes while direct E2E and full checks still reserve a lane.", + "createdAt": "2026-11-30T16:46:07.940Z", + "updatedAt": "2026-11-30T16:52:18.028Z", + "template": "bug-fix", + "templateLineage": ["bug-fix"], + "enforceOrder": true, + "regressionCommits": 1, + "steps": [ + { + "id": "spec", + "title": "Identify the failing behavior, expected behavior, and reproduction.", + "status": "complete", + "completedAt": "2026-11-30T16:46:21.984Z", + "evidence": "The root test:unit shell command reserves a Mac test lane because its exclusion glob contains .e2e.test.; it should use only ordinary resource admission." + }, + { + "id": "coverage", + "title": "Explain why existing standardized tests missed the bug; name the scenario, fixture, lifecycle or assertion gap and reusable test change.", + "status": "complete", + "completedAt": "2026-11-30T16:47:03.973Z", + "evidence": "The existing heavy command classification case has a positive E2E path and a negative tsc case. Add the real unit wrapper plus direct and shell exclude forms with positive E2E controls." + }, + { + "id": "red", + "title": "Strengthen the existing standardized test; commit it before repair, run it failing with loop record --phase red, and preserve the assertion.", + "status": "complete", + "completedAt": "2026-11-30T16:48:55.027Z", + "evidence": "10b585a8b failed the standard unit wrapper assertion: expected true to be false. The two macOS-only cases were skipped on Linux." + }, + { + "id": "implement", + "title": "Implement the smallest repair without weakening the regression test.", + "status": "complete", + "completedAt": "2026-11-30T16:49:31.888Z", + "evidence": "Exclude Vitest glob values from lane detection and preserve explicit E2E targets and suite commands." + }, + { + "id": "green", + "title": "Rerun the same unchanged regression test at a separate fix commit with loop record --phase green; preserve passing proof.", + "status": "complete", + "completedAt": "2026-11-30T16:52:18.028Z", + "evidence": "Committed f1385bada passed the unchanged classification regression in the same Linux Bun profile as the red record." + }, + { + "id": "siblings", + "title": "Run harness loop siblings to record the root cause and evaluate the same pattern across committed source.", + "status": "pending" + }, + { + "id": "verify", + "title": "Run relevant project checks and affected UI browser flows with fresh inspected screenshots and no unexpected browser errors; preserve diagnostics and keep pending until proof passes.", + "status": "pending" + } + ], + "evaluators": [ + { + "id": "check", + "title": "Run the project check script.", + "command": "bun run check", + "step": "verify" + } + ] +} diff --git a/specification/loops/xrvxyr-unit-lane-classification/trace.ndjson b/specification/loops/xrvxyr-unit-lane-classification/trace.ndjson new file mode 100644 index 00000000000..892e7442918 --- /dev/null +++ b/specification/loops/xrvxyr-unit-lane-classification/trace.ndjson @@ -0,0 +1,6 @@ +{"event":"loop.created","timestamp":"2026-11-30T16:46:07.940Z","name":"xrvxyr-unit-lane-classification","goal":"Keep standard unit checks out of the Mac heavy test lanes while direct E2E and full checks still reserve a lane.","template":"bug-fix","templateLineage":["bug-fix"]} +{"event":"step.completed","timestamp":"2026-11-30T16:46:21.984Z","loop":"xrvxyr-unit-lane-classification","step":"spec","evidence":"The root test:unit shell command reserves a Mac test lane because its exclusion glob contains .e2e.test.; it should use only ordinary resource admission."} +{"event":"step.completed","timestamp":"2026-11-30T16:47:03.973Z","loop":"xrvxyr-unit-lane-classification","step":"coverage","evidence":"The existing heavy command classification case has a positive E2E path and a negative tsc case. Add the real unit wrapper plus direct and shell exclude forms with positive E2E controls."} +{"event":"step.completed","timestamp":"2026-11-30T16:48:55.027Z","loop":"xrvxyr-unit-lane-classification","step":"red","evidence":"10b585a8b failed the standard unit wrapper assertion: expected true to be false. The two macOS-only cases were skipped on Linux."} +{"event":"step.completed","timestamp":"2026-11-30T16:49:31.888Z","loop":"xrvxyr-unit-lane-classification","step":"implement","evidence":"Exclude Vitest glob values from lane detection and preserve explicit E2E targets and suite commands."} +{"event":"step.completed","timestamp":"2026-11-30T16:52:18.028Z","loop":"xrvxyr-unit-lane-classification","step":"green","evidence":"Committed f1385bada passed the unchanged classification regression in the same Linux Bun profile as the red record."} diff --git a/specification/tracker-native-service.md b/specification/tracker-native-service.md index ab0f600aeb8..5ab16e8eb30 100644 --- a/specification/tracker-native-service.md +++ b/specification/tracker-native-service.md @@ -429,11 +429,13 @@ emergency value of 5. Carry forward 20 on `daniel-primary-mbp`. Preserve any explicit `nonHarborSessionLimit` if configured. Verify both installed ceilings and each host's RAM-limited free slots after activation. -Managed full checks and browser suites use the separate macOS heavy test -lanes. On a Mac with at least 10 cores, the first two suites can run at -background priority and subsequent suites wait for a free lane and lower -load. Use `harness resources run --heavy-test -- ` for other heavy -suites. In a managed session, `tracker host-work ssh auto -- ` +Managed full checks and browser or E2E suites share the macOS account's +heavy test lanes across worktrees. A Mac with at least 10 cores has two +lanes. Smaller Macs have one. Suites run at background priority and wait +for a free lane and acceptable load before starting. Standard unit suites +use ordinary CPU and RAM admission. Use +`harness resources run --heavy-test -- ` for other heavy suites. +In a managed session, `tracker host-work ssh auto -- ` chooses an eligible Mac for a portable CPU-heavy command and runs it through the managed lane with the estimated budget. Remote execution uses the existing SSH route for that Tracker computer. The command must use paths @@ -533,14 +535,17 @@ or recovery attempt. An external driver owns its own host and is not sampled. and 1% of inodes free. An unreadable filesystem holds the launch. - On the primary Mac, MB2 and the box, the home filesystem needs 30 GB free. Disk percentage does not hold a launch. -- The Macs need at least 25% free memory (unknown holds) and a one-minute load - under 15. They also hold when the five-minute load exceeds 1.5 per core. Other - hosts use that sustained-load threshold and hold while free memory is under 10%. +- Mac session launches need a known free-memory reading of at least 25% and + enough RAM above the reserve for one more session. New Mac heavy test lanes + wait while the one-minute load is at least 15 or the five-minute load exceeds + 1.5 per core. Other hosts apply that sustained-load threshold to session + launches and hold while free memory is under 10%. - The shared box also waits while busy: load over 1.0 per core, free memory under 15%, or under 100,000 or 3% free inodes. -On MB2, Harbor is the home project and its requests are considered first. All -other work gets one session at a time, only while the one-minute load is under 4. Its worker runs under `nice -n 10` with a four-core budget in +On MB2, Harbor is the home project. An explicitly configured +`nonHarborSessionLimit` caps concurrent sessions for other projects. Their +workers run under `nice -n 10` with a four-core budget in `TRACKER_CPU_BUDGET` and the CMake, Cargo, Make, OpenMP, Rayon and Go parallelism variables, and its brief states the budget. These cap cooperating build tools; they do not enforce a hard CPU limit. diff --git a/src/utils/execution-runtimes/withMacHeavyTestLane.ts b/src/utils/execution-runtimes/withMacHeavyTestLane.ts index 6e6081cee8d..f303a00f36c 100644 --- a/src/utils/execution-runtimes/withMacHeavyTestLane.ts +++ b/src/utils/execution-runtimes/withMacHeavyTestLane.ts @@ -19,13 +19,22 @@ const legacyLock = '.harness-full-check.lock'; const lockBusy = 75; // The runner argv and shell scripts used by Harness package commands. -const heavyRunner = - /\bplaywright\s+test\b|\btest:(?:e2e|native|package|all)\b|\bvitest\s+run\b[^;\n]*\.e2e\.test\./; +const heavyRunner = /\bplaywright\s+test\b|\btest:(?:e2e|native|package|all)\b/; +const vitestE2e = /\bvitest\s+run\b[^;\n&|]*\.e2e\.test\./; +const shellExclusion = /(^|\s)--exclude(?:=|[ \t]+)(?:"[^"\n]*"|'[^'\n]*'|[^\s;&|]+)/g; export function isHeavyTestCommand(args: readonly string[]): boolean { if (args[0] === 'bun' && args[1] === 'scripts/run-checks.ts') return true; - if (args[0] === 'sh' && args[1] === '-c') return heavyRunner.test(args[2] ?? ''); - return heavyRunner.test(args.join(' ')); + if ((args[0] === 'sh' || args[0] === '/bin/sh') && args[1] === '-c') { + const script = args[2] ?? ''; + return heavyRunner.test(script) || vitestE2e.test(script.replace(shellExclusion, '$1')); + } + if (heavyRunner.test(args.join(' '))) return true; + const filters = args.filter( + (arg, index) => + arg !== '--exclude' && !arg.startsWith('--exclude=') && args[index - 1] !== '--exclude' + ); + return vitestE2e.test(filters.join(' ')); } /** Apply the same lane budget across worktrees and resource homes for the OS account. */ diff --git a/test/utils/execution-runtimes/with-mac-heavy-test-lane.test.ts b/test/utils/execution-runtimes/with-mac-heavy-test-lane.test.ts index c1db45fc6a9..212d4139ad8 100644 --- a/test/utils/execution-runtimes/with-mac-heavy-test-lane.test.ts +++ b/test/utils/execution-runtimes/with-mac-heavy-test-lane.test.ts @@ -14,10 +14,21 @@ test('recognizes the standard suite commands without queuing routine type checks ['bun', 'scripts/run-checks.ts', '--part', 'desktop'], ['sh', '-c', 'PROJECT_REPORTS_ASSET_STORAGE=local playwright test && bun run test:shell'], ['sh', '-c', 'bun run --cwd packages/hub check && bun run --cwd packages/hub test:e2e'], - ['vitest', 'run', 'test/resources-cli.e2e.test.ts'] + ['vitest', 'run', 'test/resources-cli.e2e.test.ts'], + ['/bin/sh', '-c', "vitest run --exclude='test/desktop e2e/*.e2e.test.ts' test/cli.e2e.test.ts"], + ['vitest', 'run', '--exclude', 'test/**/*.e2e.test.ts', 'test/cli.e2e.test.ts'] ]; expect(commands.every(isHeavyTestCommand)).toBe(true); expect(isHeavyTestCommand(['sh', '-c', 'tsc --noEmit "$@"', '--'])).toBe(false); + const unitCommands = [ + ['sh', '-c', 'vitest run --exclude "test/**/*.e2e.test.ts" "$@"', '--'], + ['/bin/sh', '-c', 'vitest run --exclude "test/**/*.e2e.test.ts" test/queue.test.ts'], + ['sh', '-c', "vitest run --exclude='test/desktop e2e/*.e2e.test.ts' test/queue.test.ts"], + ['vitest', 'run', '--exclude', 'test/desktop e2e/*.e2e.test.ts', 'test/queue.test.ts'], + ['vitest', 'run', '--exclude=test/**/*.e2e.test.ts', 'test/queue.test.ts'] + ]; + for (const command of unitCommands) + expect(isHeavyTestCommand(command), command.join(' ')).toBe(false); }); test.skipIf(process.platform !== 'darwin')(