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

address review (claude): guard the churn issue body against shared-formatter drift

[._.]/ Adam Eivy6ebb2d876e43
diff --git a/server/services/agentChurn.test.js b/server/services/agentChurn.test.js
index 8cf9a28ff0..3cc2da0a88 100644
--- a/server/services/agentChurn.test.js
+++ b/server/services/agentChurn.test.js
@@ -118,6 +118,47 @@ describe('churn issue copy', () => {
expect(body).not.toMatch(/\/Users\//);
expect(body).not.toMatch(/origin\//);
});
+
+ // The durations are rendered by `formatDurationShort`, which agentChurn shares
+ // with selfDiagnostics. Pin the rendered strings here so a diagnostics-motivated
+ // tweak to that formatter can't silently reword the auto-filed churn issue.
+ it('renders the durations through the shared short-duration formatter', () => {
+ const body = buildChurnIssueBody({
+ taskType: 'self-improve:branch-reconcile',
+ churn: {
+ reason: 'short-lived-burst',
+ windowCompleted: 24,
+ windowMs: CHURN_WINDOW_MS,
+ shortLivedCount: 24,
+ shortLivedSampleSize: 24,
+ medianDurationMs: 90_000,
+ medianGapMs: 8 * MIN
+ },
+ generatedAt: '2026-08-12T08:00:00.000Z'
+ });
+ expect(body).toContain('**Short-lived (< 5m):** 24 of 24 timed runs');
+ expect(body).toContain('**Median duration:** 1m 30s');
+ expect(body).toContain('**Median gap between completions:** 8m');
+ });
+
+ it('renders absent durations as the em-dash sentinel', () => {
+ const body = buildChurnIssueBody({
+ taskType: 'self-improve:branch-reconcile',
+ churn: {
+ reason: 'rapid-succession',
+ windowCompleted: 12,
+ windowMs: CHURN_WINDOW_MS,
+ shortLivedCount: 0,
+ shortLivedSampleSize: 0,
+ medianDurationMs: null,
+ medianGapMs: null
+ },
+ generatedAt: '2026-08-12T08:00:00.000Z'
+ });
+ expect(body).toContain('**Median duration:** —');
+ expect(body).toContain('**Median gap between completions:** —');
+ expect(body).toContain('(no per-run duration recorded — used completion spacing)');
+ });
});
describe('shouldFileChurnAlert', () => {
diff --git a/server/services/autonomousJobs/selfDiagnostics.js b/server/services/autonomousJobs/selfDiagnostics.js
index 039dbcfb98..86ea3f7bcf 100644
--- a/server/services/autonomousJobs/selfDiagnostics.js
+++ b/server/services/autonomousJobs/selfDiagnostics.js
@@ -94,6 +94,8 @@ export function computeFailingCategories(byTaskType, { minCompleted = 1, now = D
* Distinct from `fileUtils.formatDuration` (which floors to whole minutes and
* renders sub-minute as "0m") and the client `formatDurationMs`: diagnostics
* durations are often seconds, and absent must read as `—`, not a zero duration.
+ * SHARED — also renders the churn issue body in `services/agentChurn.js`
+ * (`buildChurnIssueBody`). Changing the output here changes both filed issues.
*/
export function formatDurationShort(ms) {
if (!Number.isFinite(ms) || ms < 0) return '—'