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

keep the churn detector's signatureRepeatCount honest across a dispatch

[._.]/ Adam Eivyf0d86325d52f
diff --git a/server/services/taskSchedule.js b/server/services/taskSchedule.js
index 050706490e..029681bd5c 100644
--- a/server/services/taskSchedule.js
+++ b/server/services/taskSchedule.js
@@ -1130,8 +1130,19 @@ export async function recordPerpetualDispatch(taskType, appId = null, signature)
const schedule = await loadSchedule();
const record = ensureExecutionRecord(schedule, taskType, appId);
for (const field of PARK_FIELDS) delete record[field];
- if (signature == null) delete record.lastActionableSignature;
- else record.lastActionableSignature = signature;
+ // Mirrors parkPerpetual's signature handling, including the churn detector's
+ // `signatureRepeatCount`. A dispatch only happens when the set CHANGED (an
+ // unchanged one parks instead), so this is always the "new signature ⇒ first
+ // sighting" case — leaving the previous count in place would let the NEXT park
+ // increment a stale value, over-reporting "same finding again" to a detector
+ // that parks the coordinator and files a tracker issue off that number.
+ if (signature == null) {
+ delete record.lastActionableSignature;
+ delete record.signatureRepeatCount;
+ } else {
+ record.lastActionableSignature = signature;
+ record.signatureRepeatCount = 1;
+ }
const count = (record.perpetualDispatchCount || 0) + 1;
record.perpetualDispatchCount = count;
await saveSchedule(schedule);
diff --git a/server/services/taskSchedule.test.js b/server/services/taskSchedule.test.js
index a11eae7dd2..01a092b378 100644
--- a/server/services/taskSchedule.test.js
+++ b/server/services/taskSchedule.test.js
@@ -1714,6 +1714,23 @@ describe('taskSchedule', () => {
expect(partial).toEqual([])
})
+ // The churn detector (agentChurn.js) parks a coordinator and FILES a tracker
+ // issue off signatureRepeatCount, so a dispatch that leaves a stale count
+ // behind makes the next park increment it and over-report "same finding
+ // again". A dispatch only happens on a CHANGED set, so it resets to 1.
+ it('recordPerpetualDispatch resets signatureRepeatCount for the new signature', async () => {
+ mockSchedule({
+ tasks: { 'branch-reconcile': { type: 'perpetual', enabled: true } },
+ executions: { 'task:branch-reconcile': { lastRun: null, count: 0, perApp: {
+ 'app-1': { lastRun: null, count: 0, lastActionableSignature: 'old-sig', signatureRepeatCount: 4 }
+ } } }
+ })
+ await recordPerpetualDispatch('branch-reconcile', 'app-1', 'new-sig')
+ const rec = JSON.parse(writeFile.mock.calls.at(-1)[1]).executions['task:branch-reconcile'].perApp['app-1']
+ expect(rec.lastActionableSignature).toBe('new-sig')
+ expect(rec.signatureRepeatCount).toBe(1)
+ })
+
// The park has to land the zeroed budget itself: a second await is a step a
// future park path can forget, and a stale count caps the NEXT drain early.
it('parkPerpetual clears the dispatch budget when handed dispatchCount: 0', async () => {