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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: retain active test roots when process ownership is unreadable
[._.]/ Adam Eivy04c6837a783c
diff --git a/scripts/lib/vitestStaleRunRoots.js b/scripts/lib/vitestStaleRunRoots.jsindex 30b21c2d83..2da579842d 100644--- a/scripts/lib/vitestStaleRunRoots.js+++ b/scripts/lib/vitestStaleRunRoots.js@@ -261,7 +261,7 @@ export function killTestProcessesUnder(root, { read = readTestProcesses, probe =}export function sweepOrphanedTestProcesses(tmpRoot, { prefix = 'pvt-', now = Date.now(), probe = isOwnerAlive,- read = readTestProcesses, terminate = terminatePid } = {}) {+ read = readTestProcesses, terminate = terminatePid, probePid = probeTestPid } = {}) {const snapshot = ownedSnapshot(tmpRoot, prefix, read);if (!snapshot) return { signaled: 0, inspected: false, preserved: new Set(), records: null };const preserved = new Set();@@ -278,7 +278,8 @@ export function sweepOrphanedTestProcesses(tmpRoot, { prefix = 'pvt-', now = Dat}if (signaled) console.warn(`🧹 Requested termination of ${signaled} interrupted-run test processes; settlement pending`);const inspected = snapshot.records.every(record => snapshot.ancestors.has(record.pid) || record.terminal- || (record.ownershipComplete !== false && Array.isArray(record.args) && record.env && typeof record.env === 'object'));+ || (record.ownershipComplete !== false && Array.isArray(record.args) && record.env && typeof record.env === 'object')+ || probePid(record.pid) === false);return { signaled, inspected, preserved, records: snapshot.records };}@@ -291,11 +292,11 @@ export function sweepStaleRunRoots(tmpRoot, { prefix = 'pvt-', now = Date.now(),throw new Error('Owned temp prefix must be a nonempty name ending in a hyphen');}// No snapshot at all (reader down, or ancestry rejected) cannot prove a- // dead owner's children exited, so POSIX keeps those roots. An unrelated- // unreadable row inside an otherwise real snapshot must not do the same:- // dead owners are still reclaimed, while pid-less roots wait for a complete- // inventory. Preserved children and unsettled pending identities stay either way.- const { inspected, preserved, records } = sweepOrphanedTestProcesses(tmpRoot, { prefix, now, probe, read, terminate });+ // dead owner's children exited, so POSIX keeps those roots. A live unreadable+ // row may be an unobserved orphan using any root. Ancestors, terminal rows and+ // missing PIDs can be excluded independently; other rows need ownership data.+ // Preserved children and unsettled pending identities stay either way.+ const { inspected, preserved, records } = sweepOrphanedTestProcesses(tmpRoot, { prefix, now, probe, read, terminate, probePid });if (!records && process.platform !== 'win32') return;let names;try {@@ -313,7 +314,8 @@ export function sweepStaleRunRoots(tmpRoot, { prefix = 'pvt-', now = Date.now(),const owner = readOwner(path);const alive = owner ? probe(owner) : null;if (alive === true) continue;- if (alive === false || (inspected && now - stat.mtimeMs > STALE_ROOT_AGE_MS)) {+ if ((alive === false && (inspected || (process.platform === 'win32' && !records)))+ || (inspected && now - stat.mtimeMs > STALE_ROOT_AGE_MS)) {rmSync(path, { recursive: true, force: true });}} catch {diff --git a/scripts/testOwnedProcessRecovery.test.js b/scripts/testOwnedProcessRecovery.test.jsindex fc359b79c3..9c76b5786d 100644--- a/scripts/testOwnedProcessRecovery.test.js+++ b/scripts/testOwnedProcessRecovery.test.js@@ -101,7 +101,7 @@ describe('test process ownership boundaries', () => {} finally { rmSync(host, { recursive: true, force: true }); }});- it('reclaims a dead owner when an unrelated process row is incomplete', () => {+ it.each(['live', 'gone'])('requires terminal proof before ignoring an incomplete %s process row', mode => {const host = mkdtempSync(join(tmpdir(), 'recovery-unrelated-'));const dead = join(host, 'pvt-dead');const aged = join(host, 'pvt-aged');@@ -118,9 +118,10 @@ describe('test process ownership boundaries', () => {{ pid: 900003, ownershipComplete: false },],probe: () => false,+ probePid: () => mode === 'live',});- expect(existsSync(dead)).toBe(false);- expect(existsSync(aged)).toBe(true);+ expect(existsSync(dead)).toBe(mode === 'live');+ expect(existsSync(aged)).toBe(mode === 'live');} finally { rmSync(host, { recursive: true, force: true }); }});@@ -193,6 +194,34 @@ describe('test process ownership boundaries', () => {});describe.skipIf(process.platform === 'win32')('real interrupted-run recovery', () => {+ it('retains files used by a live orphan whose ownership is unreadable in the first snapshot', async () => {+ const host = mkdtempSync(join(tmpdir(), 'recovery-unreadable-child-'));+ const root = join(host, 'pvt-owned');+ mkdirSync(root);+ writeFileSync(join(root, '.owner.pid'), '2147483646 0\n');+ writeFileSync(join(root, 'active-evidence'), 'still in use');+ const child = spawn(process.execPath, ['-e', "process.stdout.write('ready'); setInterval(()=>{},1000)"], {+ env: { PATH: process.env.PATH, NODE_ENV: 'test', PORTOS_TEST_TEMP_ROOT: root }, stdio: ['ignore', 'pipe', 'ignore'],+ });+ try {+ await new Promise((resolve, reject) => { child.once('error', reject); child.stdout.once('data', resolve); });+ sweepStaleRunRoots(host, { probe: () => false, read: () => [+ { pid: process.pid, ppid: process.ppid, args: [], env: {} },+ { pid: process.ppid, ppid: 1, args: [], env: {} },+ { pid: child.pid, ppid: 1, start: 'orphan', ownershipComplete: false },+ ] });+ expect(isProcessAlive(child.pid)).toBe(true);+ expect(existsSync(join(root, 'active-evidence'))).toBe(true);+ } finally {+ await new Promise(resolve => {+ if (child.exitCode !== null || child.signalCode !== null) return resolve();+ child.once('close', resolve);+ child.kill('SIGKILL');+ });+ rmSync(host, { recursive: true, force: true });+ }+ });+it('reaps environment-only and script-path children while preserving unrelated and live-owner processes', async () => {const host = mkdtempSync(join(tmpdir(), 'recovery-owned-'));const children = [];