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
refactor: delete the retired Deep certification preparer and its dead-export exemption (#10649)
[._.]/ Adam Eivyc7efec7d8102
diff --git a/server/deadExports.test.js b/server/deadExports.test.jsindex 7c2c272714..6c01c34f58 100644--- a/server/deadExports.test.js+++ b/server/deadExports.test.js@@ -16,7 +16,6 @@ function excluded(file, name) {if (file.startsWith('server/integrations/')) return true; // Standalone integration API clients.if (file.startsWith('server/lib/aiToolkit/')) return true; // Vendored toolkit public barrel surface.if (file === 'server/lib/mockPathsDataRoot.js') return true; // Test-only helper module (#9032) — every export here is meant to be reached exclusively from *.test.js, which this scan intentionally excludes as a "mention".- if (file === 'server/services/deepAudit.js' && name === 'prepareDeepAudit') return true; // Historical certification preparer: Deep is now an extended audit and spawn no longer calls it, but its tests pin the retained read-only evidence behavior until it is deleted with them.if (file === 'server/lib/browserSuiteGate.js') return true; // Test-only `canRun` guard (#10312) — reached exclusively from *.browser.test.js.return false;}diff --git a/server/services/agentPromptBuilder.test.js b/server/services/agentPromptBuilder.test.jsindex 56b02400aa..457da46658 100644--- a/server/services/agentPromptBuilder.test.js+++ b/server/services/agentPromptBuilder.test.js@@ -1,4 +1,3 @@-vi.mock('./deepAudit.js', () => ({ prepareDeepAudit: vi.fn(async () => '## SERVER DEEP CONTRACT — overrides bounded prompts') }));/*** Tests for the light-vs-full context split in buildAgentPrompt.*@@ -4548,8 +4547,6 @@ it.each(['api', 'cli', 'tui'])('gives extended Deep precedence over customized qexpect(prompt.startsWith('## Deep audit — extended regular audit')).toBe(true);expect(prompt).toContain('fix multiple worthwhile issues');expect(prompt).toContain('partial coverage is valid');- const { prepareDeepAudit } = await import('./deepAudit.js');- expect(prepareDeepAudit).not.toHaveBeenCalled();});it('preserves the extended marker in split prompts, refuses unknown versions and legacy launches', async () => {diff --git a/server/services/deepAudit.db.test.js b/server/services/deepAudit.db.test.jsindex abed7ced65..55111f16bb 100644--- a/server/services/deepAudit.db.test.js+++ b/server/services/deepAudit.db.test.js@@ -2,7 +2,8 @@import { afterAll, describe, expect, it } from 'vitest';import { checkHealth, query, close } from '../lib/db.js';import { requireDbOrSkip } from '../lib/dbTestGate.js';-import { prepareDeepAudit, checkpointDeepAudit, getDeepAuditLedger } from './deepAudit.js';+import { assignDeepAuditAttempt, createDeepAuditLedger } from '../lib/deepAudit.js';+import { checkpointDeepAudit, getDeepAuditLedger } from './deepAudit.js';const health = await checkHealth().catch(error => ({ connected: false, error: error.message }));const runDb = requireDbOrSkip('deepAudit', health.connected, health.error);@@ -10,7 +11,7 @@ const id = `test-deep-${process.pid}-${Date.now()}`;const blob = 'a'.repeat(40);const task = { id, description: 'Example audit', metadata: { app: id, deepAuditId: id, auditDepth: 'deep', fileIssues: true } };const scope = { revision: 'b'.repeat(40), files: [{ path: 'source.js', blob }], capabilities: {}, exclusions: [], promptHash: 'example', promptVersions: { contract: 1 } };-const deps = { inventory: async () => scope, write: async () => {} };+const deps = { inventory: async () => scope };afterAll(async () => {if (runDb) await query('DELETE FROM deep_audit_ledgers WHERE id=$1', [id]);@@ -19,7 +20,10 @@ afterAll(async () => {describe.skipIf(!runDb)('Deep audit PostgreSQL persistence', () => {it('serializes overlapping checkpoint merges without losing evidence and replays after output loss', async () => {- await Promise.all(['first', 'second'].map(agentId => prepareDeepAudit({ task, agentId, workspacePath: '/example' }, deps)));+ // Deep launches no longer create ledgers; persist one as a retained legacy ledger would be.+ const seeded = createDeepAuditLedger({ id, appId: id, category: 'code-quality', scope, delivery: 'file-issues' });+ for (const agentId of ['first', 'second']) assignDeepAuditAttempt(seeded, agentId);+ await query('INSERT INTO deep_audit_ledgers (id, app_id, category, ledger) VALUES ($1,$2,$3,$4::jsonb)', [id, id, seeded.category, JSON.stringify(seeded)]);const initial = await getDeepAuditLedger(id);const checkpoint = async (agentId, index) => {const attempt = initial.attempts[agentId];diff --git a/server/services/deepAudit.js b/server/services/deepAudit.jsindex c4b60bc852..ec0f8dcb51 100644--- a/server/services/deepAudit.js+++ b/server/services/deepAudit.js@@ -1,14 +1,13 @@import { isLegacyDeepAudit } from '../lib/auditWorkflow.js';/** Machine-local, DB-primary coverage evidence. No timers or provider calls. */-import { join, resolve } from 'path';+import { join } from 'path';import { ensureSchema, query, withTransaction } from '../lib/db.js';import { execGit } from '../lib/execGit.js';-import { atomicWrite, PATHS } from '../lib/fileUtils.js';+import { PATHS } from '../lib/fileUtils.js';import { tryReadFile } from '../lib/jsonIo.js';import { canonicalSnapshotChecksum } from '../lib/snapshotChecksum.js';import { normalizeAuditTaskType, isAuditTaskType } from '../lib/auditCatalog.js';-import { createDeepAuditLedger, assignDeepAuditAttempt, deepAuditProgress, deepAuditInstructions, deepAuditAssignment,- mergeDeepAuditReport, refreshDeepAuditScope, DEEP_AUDIT_CONTRACT_VERSION } from '../lib/deepAudit.js';+import { deepAuditProgress, mergeDeepAuditReport, DEEP_AUDIT_CONTRACT_VERSION } from '../lib/deepAudit.js';import { PROMPT_VERSIONS } from './taskPromptDefaults/versions.js';import { resolveTaskHookType } from './taskTypeHooks.js';@@ -19,10 +18,8 @@ function deepAuditId(task) {: task.id);}-function deepAuditPaths(_workspacePath, agentId) {- const prefix = `.portos-deep-${canonicalSnapshotChecksum(agentId).slice(0, 24)}`;- const directory = join(PATHS.cos, 'deep-audit-checkpoints');- return { ledgerPath: join(directory, `${prefix}-ledger.json`), assignmentPath: join(directory, `${prefix}-assignment.json`), reportPath: join(directory, `${prefix}-report.json`) };+function deepAuditReportPath(agentId) {+ return join(PATHS.cos, 'deep-audit-checkpoints', `.portos-deep-${canonicalSnapshotChecksum(agentId).slice(0, 24)}-report.json`);}async function inventoryDeepAudit(workspacePath, { promptHash, category }) {@@ -90,39 +87,6 @@ export async function getDeepAuditSourceRevision(task, deps = {}) {return ledger.scope.revision;}-/** Expand only a clean snapshot; never reset a retained submodule's work. */-async function initializeDeepAuditSubmodules(workspacePath) {- const directories = (await execGit(['rev-parse', '--git-dir', '--git-common-dir'], workspacePath)).stdout.trim().split('\n');- if (directories.length !== 2 || resolve(workspacePath, directories[0]) === resolve(workspacePath, directories[1])) return;- const dirty = (await execGit(['diff', '--ignore-submodules=none', '--name-only', 'HEAD', '--'], workspacePath)).stdout.trim();- if (dirty) throw new Error('Deep audit needs a clean source snapshot; retained changes must be preserved');- await execGit(['submodule', 'update', '--init', '--recursive'], workspacePath);-}--/** Inject at the common spawn boundary, after all saved/custom/legacy task rendering. */-export async function prepareDeepAudit({ task, agentId, workspacePath }, deps = {}) {- if (!isLegacyDeepAudit(task.metadata)) return null;- if (!agentId || !workspacePath || !task.metadata?.app || !deepAuditId(task)) throw new Error('Deep audit needs an identified agent, app and workspace');- const category = isAuditTaskType(resolveTaskHookType(task)) ? normalizeAuditTaskType(resolveTaskHookType(task)) : 'code-quality';- const promptHash = canonicalSnapshotChecksum({ description: task.description, prompt: task.metadata?.prompt, context: task.metadata?.context });- if (!deps.inventory) await initializeDeepAuditSubmodules(workspacePath);- const scope = await (deps.inventory || inventoryDeepAudit)(workspacePath, { promptHash, category });- const initial = createDeepAuditLedger({ id: deepAuditId(task), appId: task.metadata.app, category, scope,- delivery: task.metadata.fileIssues === true || task.metadata.fileIssues === 'true' ? 'file-issues' : 'fix' });- const ledger = await (deps.mutate || mutateLedger)(initial.id, initial, current => {- if (current.appId !== initial.appId || current.category !== initial.category || current.delivery !== initial.delivery) {- throw new Error('Deep audit resume must keep the same app, category and delivery mode');- }- const refreshed = refreshDeepAuditScope(current, scope);- assignDeepAuditAttempt(refreshed, agentId);- return refreshed;- });- const paths = deepAuditPaths(workspacePath, agentId);- await (deps.write || atomicWrite)(paths.ledgerPath, ledger);- await (deps.write || atomicWrite)(paths.assignmentPath, deepAuditAssignment(ledger, ledger.attempts[agentId]));- return deepAuditInstructions({ ledger, attempt: ledger.attempts[agentId], ...paths });-}-/** Import even on failure; absent/malformed output preserves a partial, resumable ledger. */export async function checkpointDeepAudit({ task, agentId, workspacePath, success }, deps = {}) {if (!isLegacyDeepAudit(task.metadata)) return null;@@ -145,7 +109,7 @@ export async function checkpointDeepAudit({ task, agentId, workspacePath, succes});if (canonicalSnapshotChecksum(scope) !== current.scopeHash) throw new Error('Source changed during review; resume to invalidate and re-inventory');}- const contents = await (deps.read || tryReadFile)(deepAuditPaths(workspacePath, agentId).reportPath);+ const contents = await (deps.read || tryReadFile)(deepAuditReportPath(agentId));if (!contents) throw new Error('Deep audit checkpoint missing; no coverage credited');return mergeDeepAuditReport(current, agentId, JSON.parse(contents), { deliverySuccess: success === true, validationRevision });} catch (err) {diff --git a/server/services/deepAudit.test.js b/server/services/deepAudit.test.jsindex bfa924e176..8525803c28 100644--- a/server/services/deepAudit.test.js+++ b/server/services/deepAudit.test.js@@ -4,8 +4,9 @@ import { tmpdir } from 'os';import { join } from 'path';import { execGit } from '../lib/execGit.js';import { canonicalSnapshotChecksum } from '../lib/snapshotChecksum.js';-import { assignDeepAuditAttempt, deepAuditProgress, mergeDeepAuditReport } from '../lib/deepAudit.js';-import { prepareDeepAudit, checkpointDeepAudit } from './deepAudit.js';+import { assignDeepAuditAttempt, createDeepAuditLedger, deepAuditAssignment, deepAuditInstructions, deepAuditProgress,+ mergeDeepAuditReport, refreshDeepAuditScope } from '../lib/deepAudit.js';+import { checkpointDeepAudit } from './deepAudit.js';vi.mock('./appQualitySchedule.js', () => ({ detectRepoCapabilities: async () => ({ capabilities: { api: true } }) }));@@ -44,8 +45,22 @@ beforeEach(() => {};});const saved = () => JSON.parse(database.get('audit-1'));-async function prepare(agentId, selected = task) {- return prepareDeepAudit({ task: selected, agentId, workspacePath: '/example/repo' }, deps);+// Deep launches no longer create ledgers; seed one the way retained legacy ledgers were written.+async function prepare(agentId, selected = task, seedScope = pinned) {+ if (!selected.metadata?.auditDepth) return null;+ const scope = structuredClone(seedScope);+ const initial = createDeepAuditLedger({ id: selected.metadata.deepAuditId || 'audit-1', appId: selected.metadata.app, category: 'code-quality', scope,+ delivery: selected.metadata.fileIssues === true ? 'file-issues' : 'fix' });+ const ledger = await deps.mutate(initial.id, initial, current => {+ const refreshed = refreshDeepAuditScope(current, scope);+ assignDeepAuditAttempt(refreshed, agentId);+ return refreshed;+ });+ const prefix = `.portos-deep-${canonicalSnapshotChecksum(agentId).slice(0, 24)}`;+ const paths = { ledgerPath: `${prefix}-ledger.json`, assignmentPath: `${prefix}-assignment.json`, reportPath: `${prefix}-report.json` };+ await deps.write(paths.ledgerPath, ledger);+ await deps.write(paths.assignmentPath, deepAuditAssignment(ledger, ledger.attempts[agentId]));+ return deepAuditInstructions({ ledger, attempt: ledger.attempts[agentId], ...paths });}function payload(agentId, overrides = {}) {const ledger = saved();@@ -283,33 +298,9 @@ describe('Deep coverage workflow across serialized restarts', () => {expect(await prepare('a', legacy)).toBeNull();expect(await finish('a', legacy)).toBeNull();expect(database.size).toBe(0);- await prepare('a');- await expect(prepare('b', { ...task, metadata: { ...task.metadata, app: 'another-app' } })).rejects.toThrow('same app');});});-it('pins an actual Git inventory and refuses tracked and untracked drift', async () => {- const directory = await mkdtemp(join(tmpdir(), 'deep-audit-test-'));- try {- await execGit(['init'], directory);- await writeFile(join(directory, 'source.js'), 'export const value = 1;\n');- await execGit(['add', '.'], directory);- await execGit(['-c', 'user.name=Example', '-c', '[email protected]', 'commit', '-m', 'fixture'], directory);- const inspect = () => prepareDeepAudit({ task, agentId: 'git-agent', workspacePath: directory }, { ...deps, inventory: undefined });- await inspect();- const pinned = saved().scope;- expect(pinned.promptVersions.contract).toBe(3);- expect(pinned.files).toHaveLength(1);- expect(pinned.files[0]).toMatchObject({ path: 'source.js', kind: 'blob' });- await writeFile(join(directory, 'untracked.js'), 'new source');- await expect(inspect()).rejects.toThrow('clean source snapshot');- await rm(join(directory, 'untracked.js'));- await writeFile(join(directory, 'source.js'), 'changed source');- await expect(inspect()).rejects.toThrow('clean source snapshot');- } finally { await rm(directory, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 }); }-});--it('enrolls newly discovered workflows without shrinking the mechanically inventoried scope', async () => {await prepare('a');const p = payload('a');@@ -409,74 +400,26 @@ it('requires cross-boundary evidence before accepting a trace', async () => {expect(saved().reason).toContain('Missing trace evidence');});-it('resumes an interrupted real Git inventory of 1626 files without repeating or losing owned file coverage', async () => {- const directory = await mkdtemp(join(tmpdir(), 'deep-audit-partition-git-'));- const phases = [];- let phase = 'file creation', phaseStarted = Date.now(), primaryError;- const nextPhase = name => {- phases.push({ phase, elapsedMs: Date.now() - phaseStarted });- phase = name; phaseStarted = Date.now();- };- const setupOptions = process.platform === 'win32' ? { timeout: 60_000 } : {};+it('checkpoints against a real Git inventory and refuses tracked and untracked drift', async () => {+ const directory = await mkdtemp(join(tmpdir(), 'deep-audit-test-'));try {- await mkdir(join(directory, 'large'));- await Promise.all(Array.from({ length: 1626 }, (_, i) => writeFile(join(directory, 'large', `${String(i).padStart(4, '0')}.js`), `export const value = ${i};\n`)));- nextPhase('init/config');await execGit(['init'], directory);- // A disposable fixture must not leave detached Git maintenance writing- // objects after the awaited commit exits and teardown removes the repo.- await execGit(['config', '--local', 'gc.auto', '0'], directory);- await execGit(['config', '--local', 'maintenance.auto', 'false'], directory);- nextPhase('add');- await execGit(['add', '.'], directory, setupOptions);- nextPhase('commit');- await execGit(['-c', 'user.name=Example', '-c', '[email protected]', 'commit', '-m', 'large fixture'], directory, setupOptions);- nextPhase('initial inventory');+ await writeFile(join(directory, 'source.js'), 'export const value = 1;\n');+ await execGit(['add', '.'], directory);+ await execGit(['-c', 'user.name=Example', '-c', '[email protected]', 'commit', '-m', 'fixture'], directory);const realDeps = { ...deps, inventory: undefined };- await prepareDeepAudit({ task, agentId: 'large-first', workspacePath: directory }, realDeps);- const before = saved(), attempt = before.attempts['large-first'];- expect(before.scope.files).toHaveLength(1626);- expect(before.units).toHaveLength(204);- expect(before.groups.every(group => group.files.length === 1626)).toBe(true);- expect(before.units.every(unit => unit.files.length <= 24)).toBe(true);- const unit = before.units.find(unit => unit.id === attempt.unitIds[0]);- report = JSON.stringify({ version: 1, scopeHash: before.scopeHash, attemptId: attempt.id,- prerequisiteHash: attempt.prerequisiteHash, pass: 'static', units: [{ id: unit.id, status: 'evidenced',- reason: 'Fixture simulates one completed partition before interruption', sources: before.scope.files.filter(file => unit.files.includes(file.path)).map(({ path, blob }) => ({ path, blob })), evidence }],- candidates: [], stopReason: 'Interrupted after one bounded partition' });- nextPhase('checkpoint');- const checkpoint = await checkpointDeepAudit({ task, agentId: attempt.id, workspacePath: directory, success: false }, realDeps);- expect(checkpoint).toMatchObject({ satisfiedPasses: 1, requiredPasses: 816, complete: false });+ const checkpoint = () => checkpointDeepAudit({ task, agentId: 'git-agent', workspacePath: directory, success: true }, realDeps);+ await writeFile(join(directory, 'untracked.js'), 'new source');+ await prepare('git-agent');report = null;- expect(await checkpointDeepAudit({ task, agentId: attempt.id, workspacePath: directory, success: false }, realDeps)).toEqual(checkpoint);- nextPhase('resume');- await prepareDeepAudit({ task, agentId: 'large-resume', workspacePath: directory }, realDeps);- expect(saved().scopeHash).toBe(before.scopeHash);- expect(saved().attempts['large-resume']).toMatchObject({ pass: 'trace', unitIds: [unit.id] });- expect(saved().units.find(item => item.id === unit.id).evidence.static).toBeDefined();- expect(deepAuditProgress(saved()).complete).toBe(false);- } catch (error) {- primaryError = error;- nextPhase('cleanup');- error.message += `; fixture phases: ${JSON.stringify(phases)}`;- throw error;- } finally {- if (!primaryError) nextPhase('cleanup');- try {- await rm(directory, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 });- } catch (cleanupError) {- const detail = `cleanup after ${Date.now() - phaseStarted}ms: ${cleanupError.message}`;- // Preserve the actual Git/assertion failure; cleanup must not mask it.- if (primaryError) primaryError.message += `; ${detail}`;- else { cleanupError.message += `; fixture phases: ${JSON.stringify(phases)}`; throw cleanupError; }- }- }-// Windows CI includes real filesystem work and repeated Git process startup-// for 1,626 files. Keep the fixture bounded without dropping any source files-// or interruption/resume assertions; add/commit get a fixture-local 60s allowance-// within this same overall budget. This is not a throughput benchmark.-}, process.platform === 'win32' ? 90000 : 20000);-+ expect(await checkpoint()).toMatchObject({ complete: false });+ expect(saved().reason).toContain('clean source snapshot');+ await rm(join(directory, 'untracked.js'));+ await writeFile(join(directory, 'source.js'), 'changed source');+ expect(await checkpoint()).toMatchObject({ complete: false });+ expect(saved().reason).toContain('clean source snapshot');+ } finally { await rm(directory, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 }); }+});it('rejects a late static report after its partition has advanced through independent review', async () => {await prepare('static-a'); await prepare('static-b');diff --git a/server/services/deepAudit.workspace.test.js b/server/services/deepAudit.workspace.test.jsindex d33ece692f..7d5e42aa6e 100644--- a/server/services/deepAudit.workspace.test.js+++ b/server/services/deepAudit.workspace.test.js@@ -30,17 +30,33 @@ vi.mock('../lib/fileUtils.js', async original => ({ ...(await original()), PATHSvi.mock('./instanceIdentity.js', () => ({ ensureInstanceId: async () => 'fixture-instance' }));vi.mock('./appQualitySchedule.js', () => ({ detectRepoCapabilities: async () => ({ capabilities: {} }) }));import { createWorktree, adoptWorktree } from './worktreeManager.js';-import { prepareDeepAudit, getDeepAuditSourceRevision, checkpointDeepAudit } from './deepAudit.js';+import { assignDeepAuditAttempt, createDeepAuditLedger, refreshDeepAuditScope } from '../lib/deepAudit.js';+import { getDeepAuditSourceRevision, checkpointDeepAudit } from './deepAudit.js';let root, repo, ledger;const task = { id: 'audit', description: 'Inspect all source', metadata: { auditDepth: 'deep', app: 'fixture', fileIssues: true, deepAuditId: 'fixture-audit' } };const git = async (args, cwd = repo) => (await execGit(args, cwd)).stdout.trim();const commit = async cwd => git(['-c', 'user.name=Test', '-c', '[email protected]', '-c', 'commit.gpgsign=false', 'commit', '-am', 'fixture'], cwd);const deps = {- write: async () => {},+ inventory: async () => structuredClone(ledger.scope),mutate: async (_id, initial, mutate) => (ledger = await mutate(structuredClone(ledger || initial))),readLedger: async () => ledger,};+// Deep launches no longer create ledgers; seed one pinned to the workspace HEAD as a retained legacy ledger would be.+async function seedAttempt(agentId, cwd, selected = task) {+ const revision = await git(['rev-parse', 'HEAD'], cwd);+ const files = (await git(['ls-tree', '-r', revision], cwd)).split('\n').filter(Boolean).map(line => {+ const [meta, path] = line.split('\t'); const [mode, kind, blob] = meta.split(' ');+ return { path, blob, mode, kind };+ });+ const scope = { revision, files, capabilities: {}, exclusions: [], promptHash: 'example', promptVersions: { contract: 1 } };+ const initial = createDeepAuditLedger({ id: selected.metadata.deepAuditId, appId: selected.metadata.app, category: 'code-quality', scope, delivery: 'file-issues' });+ await deps.mutate(initial.id, initial, current => {+ const refreshed = refreshDeepAuditScope(current, scope);+ assignDeepAuditAttempt(refreshed, agentId);+ return refreshed;+ });+}beforeEach(async () => {root = await mkdtemp(join(tmpdir(), 'deep-workspace-'));repo = join(root, 'repo');@@ -60,7 +76,7 @@ afterEach(async () => { vi.unstubAllEnvs(); await rm(root, { recursive: true, foit('keeps accepted coverage on a fresh resume after remote main advances; Quick still follows main', async () => {const first = await createWorktree('agent-first', repo, task.id, { baseBranch: 'main', linkDependencies: false });- await prepareDeepAudit({ task, agentId: 'agent-first', workspacePath: first.worktreePath }, deps);+ await seedAttempt('agent-first', first.worktreePath);const pin = ledger.scope.revision;const attempt = ledger.attempts['agent-first'];const unit = ledger.units[0];@@ -74,7 +90,7 @@ it('keeps accepted coverage on a fresh resume after remote main advances; Quickconst baseCommit = await getDeepAuditSourceRevision(task, deps);expect(baseCommit).toBe(pin);const resumed = await createWorktree('agent-resume', repo, task.id, { baseBranch: 'main', baseCommit, linkDependencies: false });- await prepareDeepAudit({ task: { ...task, id: 'new-resume-task', metadata: { ...task.metadata, resumedFromAgentId: 'agent-first' } }, agentId: 'agent-resume', workspacePath: resumed.worktreePath }, deps);+ await seedAttempt('agent-resume', resumed.worktreePath);expect(ledger.generation).toBe(1);expect(ledger.units[0].evidence.static).toBeTruthy();expect(await git(['rev-parse', 'HEAD'], resumed.worktreePath)).toBe(pin);@@ -90,9 +106,7 @@ it('expands a fresh submodule at its gitlink and refuses to reset retained submoawait git(['submodule', 'add', child, 'lib/child']); await commit(repo); await git(['push', 'origin', 'main']);const worktree = await createWorktree('agent-submodule', repo, task.id, { baseBranch: 'main', linkDependencies: false });const workspacePath = worktree.worktreePath;- await prepareDeepAudit({ task, agentId: 'agent-submodule', workspacePath }, deps);- expect(ledger.scope.capabilities.submodules).toEqual([]);- expect(ledger.scope.files.some(f => f.path === 'lib/child/nested.js' && f.kind === 'blob')).toBe(true);+ await git(['submodule', 'update', '--init', '--recursive'], workspacePath);fault.rejectAdd = true;// Force differing spellings through the filesystem-identity fallback, even// on hosts where realpath normally normalizes both sides to the same string.@@ -119,8 +133,7 @@ it('expands a fresh submodule at its gitlink and refuses to reset retained submoexpect(await git(['rev-parse', 'HEAD'], replacement.worktreePath)).toBe(retainedHead);expect(await git(['branch', '--show-current'], workspacePath)).toBe('');expect(await readFile(join(workspacePath, 'lib/child/nested.js'), 'utf8')).toContain('nested = true');- await prepareDeepAudit({ task, agentId: 'agent-next', workspacePath: replacement.worktreePath }, deps);- expect(ledger.scope.capabilities.submodules).toEqual([]);+ await git(['submodule', 'update', '--init', '--recursive'], replacement.worktreePath);const nested = join(replacement.worktreePath, 'lib/child');await writeFile(join(nested, 'untracked.txt'), 'preserve me');await expect(adoptWorktree('agent-dirty', repo, replacement.worktreePath, worktree.branchName, { deepResume: true })).rejects.toThrow('preserve it');@@ -128,8 +141,5 @@ it('expands a fresh submodule at its gitlink and refuses to reset retained submoexpect(await git(['branch', '--show-current'], replacement.worktreePath)).toBe(worktree.branchName);await rm(join(nested, 'untracked.txt'));await writeFile(join(nested, 'nested.js'), 'export const nested = false;\n'); await commit(nested);- const retained = await git(['rev-parse', 'HEAD'], nested);- await expect(prepareDeepAudit({ task, agentId: 'next', workspacePath: replacement.worktreePath }, deps)).rejects.toThrow('clean source snapshot');- expect(await git(['rev-parse', 'HEAD'], nested)).toBe(retained);await expect(adoptWorktree('agent-committed-child', repo, replacement.worktreePath, worktree.branchName, { deepResume: true })).rejects.toThrow('preserve it');});