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
test: prove idle request consent through dispatch (#9455)
[._.]/ Adam Eivyfe784a0a75c9
diff --git a/server/services/cosIdleReviewParity.test.js b/server/services/cosIdleReviewParity.test.jsindex 50d6960b98..1fddf8c642 100644--- a/server/services/cosIdleReviewParity.test.js+++ b/server/services/cosIdleReviewParity.test.js@@ -8,7 +8,7 @@ const mocks = vi.hoisted(() => ({emitLog: vi.fn(),recordDecision: vi.fn(async () => {}),apps: [], requests: [], activity: {}, cards: {}, persisted: [], executions: [], perpetualDispatches: [],- noWork: false, budget: { exceeded: null, budget: {}, usage: {} }, preflightInputs: [], hookInputs: [], userTasks: [],+ autoApprove: true, noWork: false, budget: { exceeded: null, budget: {}, usage: {} }, preflightInputs: [], hookInputs: [], userTasks: [],}));vi.mock('./cosEvents.js', () => ({@@ -104,7 +104,7 @@ vi.mock('./taskTypeHooks.js', async (importActual) => ({}));vi.mock('./taskLearning.js', async (importActual) => ({...(await importActual()),- getTaskTypeConfidence: async () => ({ autoApprove: true }),+ getTaskTypeConfidence: async () => ({ autoApprove: mocks.autoApprove }),}));vi.mock('./cosTaskPreStepBlocks.js', async (importActual) => ({...(await importActual()),@@ -164,6 +164,7 @@ beforeEach(() => {mocks.executions = [];mocks.perpetualDispatches = [];mocks.noWork = false;+ mocks.autoApprove = true;mocks.budget = { exceeded: null, budget: {}, usage: {} };mocks.preflightInputs = [];mocks.hookInputs = [];@@ -248,6 +249,9 @@ describe.each(engines)('%s idle admission public boundary', (name, run) => {mocks.requestsAfterPriority0 = true;mocks.cards['preflight-demand-1'] = { outcome: 'waiting' };mocks.noWork = noWork;+ // A manual receipt supplies consent even when the ordinary scheduled+ // task would need approval because its learned confidence is low.+ mocks.autoApprove = false;mocks.interval.perpetual = true;await run();expect(mocks.requests).toEqual([]);@@ -256,6 +260,7 @@ describe.each(engines)('%s idle admission public boundary', (name, run) => {outcome: noWork ? 'nothing-to-do' : 'handed-off', taskId: readyTasks()[0]?.id ?? null,});expect(mocks.perpetualDispatches).toHaveLength(noWork ? 0 : 1);+ if (!noWork) expect(readyTasks()[0]).toMatchObject({ autoApproved: true, approvalRequired: false });if (!noWork) expect(readyTasks()[0].metadata).toMatchObject({onDemand: true, onDemandOrigin: 'user',provider: 'example-provider', model: 'example-model', effort: 'high',diff --git a/server/services/cosTaskGenerator.test.js b/server/services/cosTaskGenerator.test.jsindex d36c0ead3f..c6ed1744ac 100644--- a/server/services/cosTaskGenerator.test.js+++ b/server/services/cosTaskGenerator.test.js@@ -380,28 +380,6 @@ describe('isConfiguredApprovalRequired', () => {});});-describe('the on-demand consent flip reaches every drain path', () => {- // Run Now is the user's sign-off. Without this flip, a safety-kind or- // low-confidence type (release-check used to match `\brelease\b`) is- // persisted as APPROVAL, Priority 2 will not pick it, and force-spawn- // refuses it — so "Run Now" sits in awaiting-approve forever.- //- // The two Priority-0 engines run ONE shared drain now, and its- // consent-before-admission ordering is pinned behaviorally in- // onDemandDrain.test.js. What is left here is the THIRD path — idle review- // stealing a queued on-demand request — which carries its own copy.-- it('idle-review steal path consents when it drains an on-demand request', () => {- const start = GEN_SRC.indexOf('async function generateManagedAppImprovementTask(app, state');- expect(start).toBeGreaterThan(-1);- // Slice to the end of the function, not a fixed byte window: the consent line- // sits at the bottom of a body that grows, so a magic number makes an- // unrelated comment above it read as a missing consent call.- const body = GEN_SRC.slice(start, GEN_SRC.indexOf('\n return { task, pendingPerpetualDispatch, skip: null };', start));- expect(body).toMatch(/selectionReason === 'on-demand'\) applyOnDemandConsent\(task\)/);- });-});-// #1650/#4520: a task this instance must not run — a live lease held by ANOTHER// instance, or a pin naming another instance — must be skipped during candidate// selection, BEFORE the engine emits `task:ready` + trackSpawn. Otherwise that