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: fence historical queued audits and preserve custom Deep identity

Adam Eivy3aa5e27e7206
diff --git a/client/src/components/apps/AppQualityRunner.jsx b/client/src/components/apps/AppQualityRunner.jsx
index 6e64aea07e..7e3f046edf 100644
--- a/client/src/components/apps/AppQualityRunner.jsx
+++ b/client/src/components/apps/AppQualityRunner.jsx
@@ -106,7 +106,7 @@ export default function AppQualityRunner({ app, children }) {
<label htmlFor="quality-depth" className="block text-sm">Audit depth
<select id="quality-depth" className="block w-full bg-port-bg border border-port-border rounded p-2" value={auditDepth} disabled={busy} onChange={event => setAuditDepth(event.target.value)}>
<option value="quick">Quick — broad scan, focused review</option>
- <option value="deep">Deep — persistent coverage and independent passes</option>
+ <option value="deep">Deep — extended investigation and multiple fixes</option>
</select>
</label>
{auditDepth === 'deep' && <p className="text-xs text-gray-400">Spend more time investigating high-risk paths and fixing multiple worthwhile issues in one run. The summary reports coverage and remaining limits; Deep does not certify every file.</p>}
diff --git a/client/src/components/apps/AppQualityRunner.test.jsx b/client/src/components/apps/AppQualityRunner.test.jsx
index e43ebc6288..e57fcbbf5b 100644
--- a/client/src/components/apps/AppQualityRunner.test.jsx
+++ b/client/src/components/apps/AppQualityRunner.test.jsx
@@ -278,5 +278,6 @@ it('explains extended Deep and preserves old evidence without offering legacy re
expect(screen.queryByRole('button', { name: 'Resume Deep audit' })).not.toBeInTheDocument();
expect(screen.getByText(/Historical exhaustive audit/)).toBeInTheDocument();
expect(screen.getByText(/multiple worthwhile issues in one run/)).toBeInTheDocument();
+ expect(screen.getByRole('option', { name: 'Deep — extended investigation and multiple fixes' })).toBeInTheDocument();
expect(resumeMaintenanceRun).not.toHaveBeenCalled();
});
diff --git a/server/lib/autonomousJobTask.js b/server/lib/autonomousJobTask.js
index f86af46cb4..ded8ed3860 100644
--- a/server/lib/autonomousJobTask.js
+++ b/server/lib/autonomousJobTask.js
@@ -24,6 +24,11 @@ export function generatedJobTaskFields(generated) {
const meta = generated?.metadata || {};
return {
description: generated?.description,
+ // Preserve workflow identity through manual/quota projection. Keep any
+ // checkpoint id so the creation boundary rejects it instead of erasing it.
+ ...(meta.auditDepth != null || meta.auditWorkflow != null || meta.deepAuditId != null ? {
+ metadata: { auditDepth: meta.auditDepth, auditWorkflow: meta.auditWorkflow, deepAuditId: meta.deepAuditId }
+ } : {}),
priority: generated?.priority,
prompt: meta.prompt,
// App-scoped jobs carry the target app so `prepareAgentWorkspace` resolves
diff --git a/server/services/cosTaskStore.test.js b/server/services/cosTaskStore.test.js
index 98f7a65647..2ec8ed58f1 100644
--- a/server/services/cosTaskStore.test.js
+++ b/server/services/cosTaskStore.test.js
@@ -2631,3 +2631,15 @@ it('creates a fresh extended task rather than reviving a parked historical check
expect(await reviveBlockedTask(legacy.id, {}, 'internal')).toMatchObject({ error: expect.stringContaining('read-only') });
expect((await getTaskById(legacy.id)).status).toBe('blocked');
});
+
+
+it('preserves custom Deep workflow through projection and non-raw persistence', async () => {
+ const { generatedJobTaskFields } = await import('../lib/autonomousJobTask.js');
+ const legacy = await addTask({ id: 'sys-old-custom', description: 'Custom deep audit', status: 'blocked', metadata: { app: 'example', auditDepth: 'deep', deepAuditId: 'historic', existingBranch: 'cos/preserved' } }, 'internal', { raw: true });
+ const fields = generatedJobTaskFields({ description: 'Custom deep audit', metadata: { app: 'example', auditDepth: 'deep', auditWorkflow: 'extended-v1', provider: 'codex', model: 'gpt-6-astra', effort: 'medium', openPR: true, useWorktree: true } });
+ const fresh = await addTask(fields, 'internal');
+ expect(fresh.duplicate).not.toBe(true);
+ expect((await getTaskById(fresh.id)).metadata).toMatchObject({ auditDepth: 'deep', auditWorkflow: 'extended-v1', provider: 'codex', model: 'gpt-6-astra', effort: 'medium', openPR: 'true', useWorktree: 'true' });
+ expect((await getTaskById(legacy.id)).metadata).toMatchObject({ deepAuditId: 'historic', existingBranch: 'cos/preserved' });
+ await expect(addTask(generatedJobTaskFields({ metadata: { auditDepth: 'deep', deepAuditId: 'historic' } }), 'internal')).rejects.toThrow('read-only');
+});
diff --git a/server/services/onDemandDrain.js b/server/services/onDemandDrain.js
index 227de51ed2..184a4caad5 100644
--- a/server/services/onDemandDrain.js
+++ b/server/services/onDemandDrain.js
@@ -209,11 +209,20 @@ export async function drainOnDemandRequests(ctx, adapter) {
if (!request) continue;
let acceptedTaskId = null;
let preparationFailed = false;
+ let refusalReason = null;
try {
// Receipts are immutable while queued; resolve dispatch from the claimed
// record as well, rather than keeping snapshot objects across ownership.
targetApp = request.appId ? apps.find(app => app.id === request.appId) : null;
const cardId = cardIdForRequest(request);
+ // Saved invocation parameters are not a new launch boundary. Old queued
+ // certification work must not silently become an extended audit on boot.
+ if (isLegacyDeepAudit(request.burn?.overrides?.params)) {
+ refusalReason = 'Historical Deep requests are read-only; start a new Deep audit.';
+ await openCard(request);
+ await finishPreflightCard(cardId, { outcome: 'failed', reason: 'deep-audit-historical', note: refusalReason });
+ continue;
+ }
await openCard(request);
// Off the queue and into preparation. A task type with its own preflight
// (pr-reviewer) has no `prepare` step and reports its real first step
@@ -348,7 +357,7 @@ export async function drainOnDemandRequests(ctx, adapter) {
throw error;
} finally {
if (claim) await settleOnDemandRequest(claim, { taskId: acceptedTaskId,
- reason: acceptedTaskId ? null : preparationFailed ? 'Request preparation failed; resume explicitly.' : 'Request produced no task; resume explicitly.' });
+ reason: acceptedTaskId ? null : refusalReason ?? (preparationFailed ? 'Request preparation failed; resume explicitly.' : 'Request produced no task; resume explicitly.') });
}
}
diff --git a/server/services/onDemandDrain.test.js b/server/services/onDemandDrain.test.js
index 55714c3a50..b25a726f6f 100644
--- a/server/services/onDemandDrain.test.js
+++ b/server/services/onDemandDrain.test.js
@@ -752,3 +752,28 @@ it('refuses an unrelated active duplicate instead of claiming its delivery', asy
expect(spawned).toEqual([]);
expect(settleOnDemandRequest).toHaveBeenLastCalledWith(expect.anything(), { taskId: null, reason: 'Request produced no task; resume explicitly.' });
});
+
+
+describe.each(ENGINES)('%s — historical queued Deep compatibility', (_name, makeAdapter) => {
+ it('durably refuses a saved legacy invocation before preparation without changing its evidence', async () => {
+ const request = appRequest({ origin: 'quota-burn', burn: { family: 'codex', stepId: 'old-step', overrides: { params: { auditDepth: 'deep', deepAuditId: 'retained-ledger' } } } });
+ const saved = JSON.stringify(request);
+ mocks.getOnDemandRequests.mockResolvedValue([request]);
+ const { adapter, spawned } = makeAdapter();
+ await drainOnDemandRequests({ state: STATE }, adapter);
+ expect(mocks.prepareManagedAppImprovementTask).not.toHaveBeenCalled();
+ expect(mocks.generateSelfImprovementTaskForType).not.toHaveBeenCalled();
+ expect(mocks.addTask).not.toHaveBeenCalled();
+ expect(mocks.applyOnDemandRunResets).not.toHaveBeenCalled();
+ expect(spawned).toEqual([]);
+ expect((await import('./onDemandHandoff.js')).settleOnDemandRequest).toHaveBeenCalledWith(expect.objectContaining({ request }), { taskId: null, reason: 'Historical Deep requests are read-only; start a new Deep audit.' });
+ expect(JSON.stringify(request)).toBe(saved);
+ });
+ it('dispatches an explicitly marked new extended request', async () => {
+ mocks.getOnDemandRequests.mockResolvedValue([appRequest({ origin: 'quota-burn', burn: { family: 'codex', stepId: 'new-step', overrides: { params: { auditDepth: 'deep', auditWorkflow: 'extended-v1' } } } })]);
+ const { adapter, spawned } = makeAdapter();
+ await drainOnDemandRequests({ state: STATE }, adapter);
+ expect(mocks.prepareManagedAppImprovementTask).toHaveBeenCalledOnce();
+ expect(spawned).toHaveLength(1);
+ });
+});