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([issue-711]): address codex iter-3 — record skip before re-registering gated scheduled job
Adam Eivyce2a267d6400
diff --git a/server/services/cos.test.js b/server/services/cos.test.jsindex b454d02f60..523991dcc9 100644--- a/server/services/cos.test.js+++ b/server/services/cos.test.js@@ -680,6 +680,15 @@ describe('cos.js source — priority + capacity invariants', () => {const execFn = extractFnBody(SCHED_SRC, SCHED_SRC.indexOf('export async function executeScheduledJob'));expect(execFn, 'executeScheduledJob must read the cos autonomy mode').toMatch(/getDomainMode\(\s*state\.config\s*,\s*['"]cos['"]\s*\)/);expect(execFn, 'executeScheduledJob must fence on execute').toMatch(/cosAutonomyMode\s*!==\s*['"]execute['"]/);+ // The autonomy-skip branch must record a gate-skip (advances lastRun) BEFORE+ // re-registering — otherwise a past-due job re-registers with stale lastRun+ // and refires every 1s while off/dry-run. Pin that the skip branch calls+ // recordJobGateSkip ahead of registerSingleJobSchedule.+ const skipBranch = execFn.slice(execFn.indexOf("cosAutonomyMode !== 'execute'"));+ const recordIdx = skipBranch.indexOf('recordJobGateSkip');+ const reregIdx = skipBranch.indexOf('registerSingleJobSchedule');+ expect(recordIdx, 'autonomy-skip must call recordJobGateSkip').toBeGreaterThan(-1);+ expect(recordIdx, 'recordJobGateSkip must precede re-registration (no 1s refire loop)').toBeLessThan(reregIdx);// The improvement-check timer must gate its queueEligibleImprovementTasks call.expect(SCHED_SRC, 'improvement-check timer must gate queueing on cos === execute').toMatch(/idleReviewEnabled\s*&&\s*getDomainMode\(\s*state\.config\s*,\s*['"]cos['"]\s*\)\s*===\s*['"]execute['"]/);diff --git a/server/services/cosJobScheduler.js b/server/services/cosJobScheduler.jsindex dbd66c480b..7708c57646 100644--- a/server/services/cosJobScheduler.js+++ b/server/services/cosJobScheduler.js@@ -176,13 +176,19 @@ export async function executeScheduledJob(jobId) {// Per-domain CoS auto-run gate: a SCHEDULED job firing automatically is an// autonomous action, so off/dry-run withhold it (dry-run logs what it would// have run). Manual /jobs/:id triggers run through runJobNow, not this path,- // so explicit user intent is unaffected. Re-register so it fires once the- // domain is dialed back to execute.+ // so explicit user intent is unaffected. Record a skip first (advances+ // lastRun without incrementing runCount, exactly like the gate-skip path) so+ // re-registration computes a FUTURE fire time — re-registering a past-due job+ // with stale lastRun would refire every second (the same 1s-loop the spawn+ // branch's comment warns about).const cosAutonomyMode = getDomainMode(state.config, 'cos');if (cosAutonomyMode !== 'execute') {if (cosAutonomyMode === 'dry-run') {emitLog('info', `[dry-run] CoS auto-run would fire scheduled job: ${job.name}`, { jobId, domainAutonomy: 'cos' });}+ await recordJobGateSkip(jobId).catch(err =>+ console.error(`❌ Failed to record autonomy-skip for ${jobId}: ${err.message}`)+ );await registerSingleJobSchedule(jobId);return;}