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

test([pipeline-list-strip-route-contract-tests]): pin runHistory-strip at the HTTP boundary

[._.]/ Adam Eivy18d99db0c5b0
diff --git a/PLAN.md b/PLAN.md
index 6be1a707f1..01eb066210 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -6,7 +6,6 @@ For project goals, see [GOALS.md](./GOALS.md). For completed work, see [.changel
- [ ] [agent-spawn-widen-try-finally-guard] **Widen the `spawningTasks` guard in `agentLifecycle.js` to cover the whole spawn path.** `server/services/agentLifecycle.js:~165` adds `task.id` to `spawningTasks` but the `try/finally` only wraps a narrow window; an uncaught throw inside `buildAgentPrompt`, `writeFile('prompt.txt')`, `createAgentRun`, or `registerAgent` (lines ~165–525) leaks the guard forever, permanently blocking re-spawns of that task id until process restart. Four `it.skip('TODO(plan.md backlog): …')` tests at `agentLifecycle.test.js:440-490` already pin the regression and flip green on fix. Single-user system means a stuck guard is silently un-recoverable.
- [ ] [backport-pre-023-migrations-to-_lib] **Back-port pre-023 prompt-replace migrations onto `scripts/migrations/_lib.js`.** 003 / 004 / 005 / 006 / 010 / 013 / 019 all clone the inline `applyMigration` + per-file scan + customized-skip warning pattern that `_lib.js` now centralizes. Wrap any `OLD_SHIPPED_MD5: string` entries (003 / 004 / 006) into single-element arrays to match the `accepted[filename]: string[]` shape. Drop ~70 LOC per migration; nothing changes behaviorally so the only risk is mis-typed hashes — review each diff alongside a re-run of its test against the `_testHelpers.js` `runPromptMigrationTests`. Settled-history migrations have a higher rewrite-bar than active code, so a separate PR with focused review is appropriate. Surfaced by /simplify during `[pipeline-idea-stage-character-detail-plumbing]`.
-- [ ] [pipeline-list-strip-route-contract-tests] **Lock the runHistory-strip decision at the HTTP boundary.** `server/services/pipeline/issues.js`'s `listIssues` / `listRecentIssues` take `withHistory` (default `true`); the strip choice now lives in `server/routes/pipeline.js`. Service-layer tests cover both shapes, but no route test asserts the response. Add Supertest coverage to `server/routes/pipeline.test.js`: (1) `GET /api/pipeline/series/:id/issues` (paginated + non-paginated) seeds an issue with persisted runHistory and asserts the response body's `stages.*.runHistory` is `[]`; (2) for `GET /api/pipeline/issues/recent` — whose route projection drops `stages` entirely — spy on `issuesSvc.listRecentIssues` and assert it's called with `{ withHistory: false }`. Caught by codex review iter 2 on PR #411 as LOW non-blocking; deferred to keep that PR scoped to the perf change.
- [ ] [codex5-polling-consolidation] **[P2][PERF]** Migrate remaining `setInterval` callers to `useAutoRefetch`. The shared hook at `client/src/hooks/useAutoRefetch.js` exists; 20+ pages/components still spin local `setInterval`s — ChiefOfStaff, Brain, DigitalTwin, Loops, Browser, CyberCity, ImageGen, Ambient, AgentsPage, calendar, meatspace, city tabs. Migrate each to `useAutoRefetch` (which already provides the `document.visibilityState === 'hidden'` short-circuit); for domains with a Socket.IO event stream, switch to event-driven refetch instead of polling.
- [ ] [codex5-client-error-reporter] **[P2][OBSERVABILITY]** Funnel client errors into Review Hub. `client/src/main.jsx`'s `window.onerror` + `unhandledrejection` listeners only `console.log` today. Add `POST /api/client-errors` with redaction (drop tokens / long payloads) + rate-limit (~1/sec, drop duplicates by message+stack hash). Surface grouped client errors in the Review Hub feed; optionally raise a CoS task at a configurable threshold.
- [ ] [codex5-dashboard-intent-layouts] **[P2][DASHBOARD]** Finish intent-named layouts + morning default + widget suggestions. `server/services/dashboardLayouts.js` seeds `morning-review` and `ops` already; still missing `Deep Work`, `Health`, `Agent Watch`. Add the three remaining seeded layouts, a "make this my morning default" toggle that activates a layout in a configured time window, and a "widget suggestion" hint: when a layout omits a widget whose data source is populated (e.g. layout has no calendar widget but calendar is connected), surface an inline "Add Calendar?" affordance.
diff --git a/server/routes/pipeline.test.js b/server/routes/pipeline.test.js
index f824ac9b4f..7c200f6742 100644
--- a/server/routes/pipeline.test.js
+++ b/server/routes/pipeline.test.js
@@ -476,6 +476,54 @@ describe('pipeline routes', () => {
expect(r.body.find((i) => i.id === iss1.body.id)?.seriesName).toBe('Alpha');
});
+ // Service-layer tests cover withHistory:true/false; these pin the route
+ // wiring on the endpoints UI lists hit so a future change can't silently
+ // re-introduce stage runHistory on list payloads.
+ describe('list endpoints strip runHistory at the HTTP boundary', () => {
+ async function seedIssueWithHistory(app) {
+ const ser = await request(app).post('/api/pipeline/series').send({ name: 'S' });
+ const iss = await request(app).post(`/api/pipeline/series/${ser.body.id}/issues`).send({ title: 'I' });
+ await request(app).post(`/api/pipeline/issues/${iss.body.id}/stages/idea/generate`).send({ seedInput: 'v1' });
+ const r = await request(app).post(`/api/pipeline/issues/${iss.body.id}/stages/idea/generate`).send({ seedInput: 'v2' });
+ expect(r.body.stage.runHistory).toHaveLength(1);
+ return { seriesId: ser.body.id, issueId: iss.body.id };
+ }
+
+ it.each([
+ ['non-paginated', '', (body) => body, { withHistory: false }],
+ ['paginated', '?offset=0&limit=10', (body) => body.items, { paginated: true, withHistory: false }],
+ ])('GET /series/:id/issues (%s) strips stages.*.runHistory and forwards withHistory:false', async (_label, qs, pickItems, expectedArgs) => {
+ const issuesSvc = await import('../services/pipeline/issues.js');
+ const app = makeApp();
+ const { seriesId, issueId } = await seedIssueWithHistory(app);
+ const spy = vi.spyOn(issuesSvc, 'listIssues');
+ const r = await request(app).get(`/api/pipeline/series/${seriesId}/issues${qs}`);
+ expect(r.status).toBe(200);
+ expect(spy).toHaveBeenCalledTimes(1);
+ expect(spy).toHaveBeenCalledWith(expect.objectContaining({ seriesId, ...expectedArgs }));
+ const items = pickItems(r.body);
+ expect(Array.isArray(items)).toBe(true);
+ expect(items.find((i) => i.id === issueId).stages.idea.runHistory).toEqual([]);
+ spy.mockRestore();
+ });
+
+ it('GET /issues/recent forwards withHistory:false and projects stages out of the response', async () => {
+ const issuesSvc = await import('../services/pipeline/issues.js');
+ const app = makeApp();
+ // Tiny seed so the response is non-empty and we can assert the
+ // route's `stages`-dropping projection actually holds.
+ const ser = await request(app).post('/api/pipeline/series').send({ name: 'S' });
+ await request(app).post(`/api/pipeline/series/${ser.body.id}/issues`).send({ title: 'T' });
+ const spy = vi.spyOn(issuesSvc, 'listRecentIssues');
+ const r = await request(app).get('/api/pipeline/issues/recent?limit=5');
+ expect(r.status).toBe(200);
+ expect(spy).toHaveBeenCalledTimes(1);
+ expect(spy).toHaveBeenCalledWith(expect.objectContaining({ withHistory: false }));
+ expect(r.body[0]).not.toHaveProperty('stages');
+ spy.mockRestore();
+ });
+ });
+
it('POST /issues/:id/stages/storyboards/scenes/:index/video returns the enqueued jobId', async () => {
const app = makeApp();
const ser = await request(app).post('/api/pipeline/series').send({ name: 'S' });