claude-code-session-manager 0.85.0 → 0.87.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/dist/assets/AgentLibrary-DyLWzZDf.js +3 -0
  2. package/dist/assets/{DataModel-DRH-Ty20.js → DataModel--mISIJ6h.js} +1 -1
  3. package/dist/assets/{History-CfRhT1Im.js → History-C2ahUXTg.js} +2 -2
  4. package/dist/assets/{Hooks-wEmh_U6c.js → Hooks-BiC6oyR2.js} +3 -3
  5. package/dist/assets/{HostBilko-D_t7Rbi7.js → HostBilko-BPleEOld.js} +1 -1
  6. package/dist/assets/{Library-CpArQ-OJ.js → Library-Dc8Qst1R.js} +1 -1
  7. package/dist/assets/{ListDetail-pjaKYs84.js → ListDetail-DIXh-OLX.js} +1 -1
  8. package/dist/assets/MarkdownEditor-C90bkLXK.js +1 -0
  9. package/dist/assets/{McpServers-ftqaV3kn.js → McpServers-DqcbLOLZ.js} +2 -2
  10. package/dist/assets/{Memory-ChMWkNd0.js → Memory-CW62MXlh.js} +4 -4
  11. package/dist/assets/{Panel-D9Kr40Ai.js → Panel-Bw1FhRuF.js} +1 -1
  12. package/dist/assets/Permissions-BcUC-5y8.js +3 -0
  13. package/dist/assets/{Plugins-BtChISho.js → Plugins-BnKx9flD.js} +2 -2
  14. package/dist/assets/{ProvenanceBadge-DBA5EcYy.js → ProvenanceBadge-Bw5vNVPT.js} +1 -1
  15. package/dist/assets/{SaveBar-I0_dWNTX.js → SaveBar-CWr0O_w-.js} +1 -1
  16. package/dist/assets/Scheduler-DYdLuUqq.js +14 -0
  17. package/dist/assets/{ScopeSwitcher-5GTEveb2.js → ScopeSwitcher-CrBLbg8s.js} +1 -1
  18. package/dist/assets/Settings-DluB-vN1.js +3 -0
  19. package/dist/assets/{SkillReferenceGraph-DNBFGrYE.js → SkillReferenceGraph-CHLSseay.js} +1 -1
  20. package/dist/assets/{Skills-DJB6-bBM.js → Skills-gNdo_HNK.js} +2 -2
  21. package/dist/assets/{SystemPrompt-BiDDrJUA.js → SystemPrompt-Cru05-Ia.js} +1 -1
  22. package/dist/assets/{TagLibrary-_Wrevtop.js → TagLibrary-DNHY0xou.js} +1 -1
  23. package/dist/assets/{TiptapBody-OWWXdLRy.js → TiptapBody-I4lmbCgP.js} +1 -1
  24. package/dist/assets/{Toggle-B122N0HL.js → Toggle-bWMHjmRh.js} +1 -1
  25. package/dist/assets/{index-CDo9xBR9.css → index-DV3PorRY.css} +1 -1
  26. package/dist/assets/{index-DhvuQL4C.js → index-fc_JjdxL.js} +724 -724
  27. package/dist/assets/settingsSchema-BfhtZnGD.js +3 -0
  28. package/dist/index.html +2 -2
  29. package/package.json +15 -14
  30. package/plugins/CLAUDE.md +61 -0
  31. package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
  32. package/plugins/session-manager-dev/skills/builder/4-manual/SKILL.md +1 -1
  33. package/plugins/session-manager-dev/skills/ops-sweep/SKILL.md +1 -1
  34. package/scripts/scheduler-mcp-server.cjs +7 -0
  35. package/src/main/__tests__/agentModelResolve.test.cjs +100 -9
  36. package/src/main/__tests__/broadcastCoalescer.test.cjs +18 -0
  37. package/src/main/__tests__/epicMint.test.cjs +2 -2
  38. package/src/main/__tests__/health-delegation-chain.test.cjs +2 -1
  39. package/src/main/__tests__/health-starve-escalation.test.cjs +94 -0
  40. package/src/main/__tests__/loadGateDetailTick.test.cjs +31 -0
  41. package/src/main/__tests__/machineProfile.test.cjs +19 -1
  42. package/src/main/__tests__/needsReviewLedger.test.cjs +162 -0
  43. package/src/main/__tests__/opsErrorLogTelemetryTap.test.cjs +3 -3
  44. package/src/main/__tests__/pollLoop-dispatch-on-failure.test.cjs +15 -1
  45. package/src/main/__tests__/prdCreateDisposition.test.cjs +201 -0
  46. package/src/main/__tests__/prdFrontmatterDisposition.test.cjs +125 -0
  47. package/src/main/__tests__/prdLocations.test.cjs +100 -2
  48. package/src/main/__tests__/prdLocationsArchived.test.cjs +43 -1
  49. package/src/main/__tests__/prdSetDisposition.test.cjs +222 -0
  50. package/src/main/__tests__/pty-session-open-telemetry.test.cjs +96 -0
  51. package/src/main/__tests__/queue-health-verdict.test.cjs +170 -0
  52. package/src/main/__tests__/queue-starvation-per-project.test.cjs +147 -0
  53. package/src/main/__tests__/queueHistory.test.cjs +63 -0
  54. package/src/main/__tests__/reconcileTiming.test.cjs +135 -0
  55. package/src/main/__tests__/scheduleJobTransitions.test.cjs +101 -1
  56. package/src/main/__tests__/scheduler-boot-orphans.test.cjs +2 -2
  57. package/src/main/__tests__/scheduler-broadcast-reconcile.test.cjs +121 -0
  58. package/src/main/__tests__/scheduler-cross-project-batch.test.cjs +43 -0
  59. package/src/main/__tests__/scheduler-failed-autoreset.test.cjs +121 -0
  60. package/src/main/__tests__/scheduler-guard-verdict-autoresolve.test.cjs +344 -0
  61. package/src/main/__tests__/scheduler-job-budget.test.cjs +172 -0
  62. package/src/main/__tests__/scheduler-looks-done.test.cjs +93 -3
  63. package/src/main/__tests__/scheduler-needs-review-autoresolve.test.cjs +189 -0
  64. package/src/main/__tests__/scheduler-no-dead-end-status.test.cjs +152 -0
  65. package/src/main/__tests__/scheduler-porcelain-rename.test.cjs +164 -0
  66. package/src/main/__tests__/scheduler-quarantine-autoresolve.test.cjs +165 -0
  67. package/src/main/__tests__/scheduler-reap-dead-running-jobs.test.cjs +160 -0
  68. package/src/main/__tests__/scheduler-reaper-helpers-basics.test.cjs +87 -0
  69. package/src/main/__tests__/scheduler-shared-tree-guard.test.cjs +88 -0
  70. package/src/main/__tests__/scheduler-starve-escalation.test.cjs +154 -0
  71. package/src/main/__tests__/scheduler-worktree-cap-defer.test.cjs +14 -0
  72. package/src/main/__tests__/telemetryClient.test.cjs +75 -5
  73. package/src/main/__tests__/telemetrySettings.test.cjs +32 -0
  74. package/src/main/chatRunner.cjs +8 -5
  75. package/src/main/health.cjs +76 -3
  76. package/src/main/historyAggregator.cjs +5 -0
  77. package/src/main/index.cjs +95 -44
  78. package/src/main/ipcSchemas.cjs +47 -0
  79. package/src/main/lib/__tests__/active-sessions.test.cjs +251 -0
  80. package/src/main/lib/__tests__/bootSelfHeal.test.cjs +107 -0
  81. package/src/main/lib/__tests__/delegationReadiness.test.cjs +322 -43
  82. package/src/main/lib/__tests__/effectiveModelInfo.test.cjs +239 -0
  83. package/src/main/lib/__tests__/gitWorktree.test.cjs +89 -0
  84. package/src/main/lib/__tests__/guardShims.test.cjs +151 -0
  85. package/src/main/lib/__tests__/loadGate.test.cjs +103 -2
  86. package/src/main/lib/__tests__/opsRootAbsoluteCwd.test.cjs +5 -5
  87. package/src/main/lib/__tests__/prdDisposition.test.cjs +224 -0
  88. package/src/main/lib/__tests__/reaperHelpers.test.cjs +179 -1
  89. package/src/main/lib/__tests__/telemetryBoot.test.cjs +11 -0
  90. package/src/main/lib/__tests__/usageCircuit.test.cjs +224 -0
  91. package/src/main/lib/__tests__/watchdog-helpers.test.cjs +312 -0
  92. package/src/main/lib/__tests__/watchdog-relaunch.test.cjs +193 -0
  93. package/{scripts → src/main}/lib/activeSessions.cjs +50 -4
  94. package/src/main/lib/agentModelResolve.cjs +65 -27
  95. package/src/main/lib/bootSelfHeal.cjs +88 -0
  96. package/src/main/lib/delegationReadiness.cjs +290 -225
  97. package/src/main/lib/effectiveModelInfo.cjs +333 -0
  98. package/src/main/lib/ephemeralCwd.cjs +1 -1
  99. package/src/main/lib/epicMint.cjs +3 -3
  100. package/src/main/lib/gitWorktree.cjs +42 -12
  101. package/src/main/lib/guardShims.cjs +156 -0
  102. package/src/main/lib/jobDirtFilter.cjs +7 -2
  103. package/src/main/lib/launchFailure.cjs +2 -1
  104. package/src/main/lib/loadGate.cjs +23 -1
  105. package/src/main/lib/machineProfile.cjs +15 -0
  106. package/src/main/lib/mcpToolCatalog.cjs +4 -1
  107. package/src/main/lib/needsReviewLedger.cjs +205 -0
  108. package/src/main/lib/opsErrorLog.cjs +1 -1
  109. package/src/main/lib/opsOwnership.cjs +1 -1
  110. package/src/main/lib/prdCreate.cjs +56 -1
  111. package/src/main/lib/prdDisposition.cjs +199 -0
  112. package/src/main/lib/prdFrontmatter.cjs +8 -2
  113. package/src/main/lib/prdLocations.cjs +167 -45
  114. package/src/main/lib/projectHomeAdminRoutes.cjs +4 -4
  115. package/src/main/lib/projectPageSummarySchema.cjs +1 -1
  116. package/src/main/lib/projectRootResolve.cjs +1 -1
  117. package/src/main/lib/queueHistory.cjs +19 -1
  118. package/src/main/lib/queueStore.cjs +6 -1
  119. package/src/main/lib/reaperHelpers.cjs +181 -15
  120. package/src/main/lib/scheduleJobSchema.cjs +8 -0
  121. package/src/main/lib/scheduleJobTransitions.cjs +33 -0
  122. package/src/main/lib/schedulerBatch.cjs +12 -1
  123. package/src/main/lib/schedulerConfig.cjs +37 -0
  124. package/src/main/lib/telemetryBoot.cjs +11 -8
  125. package/src/main/lib/telemetryClient.cjs +44 -2
  126. package/src/main/lib/telemetrySettings.cjs +20 -3
  127. package/src/main/lib/usageCircuit.cjs +159 -0
  128. package/{scripts → src/main}/lib/watchdogHelpers.cjs +1 -1
  129. package/src/main/pty.cjs +9 -0
  130. package/src/main/scheduler/prdParser.cjs +13 -0
  131. package/src/main/scheduler.cjs +1869 -193
  132. package/src/main/templates/PRD_AUTHORING.md +50 -0
  133. package/src/main/templates/project-pages-catalog.json +1 -1
  134. package/src/main/usage.cjs +21 -3
  135. package/src/preload/api.d.ts +92 -1
  136. package/src/preload/index.cjs +10 -0
  137. package/web/README.md +41 -0
  138. package/{scripts/render-project-pages.cjs → web/project-pages/render.cjs} +4 -4
  139. package/{scripts/render-project-pages → web/project-pages/renderer}/dist/renderer.cjs +1 -1
  140. package/{scripts/validate-project-pages-summary.cjs → web/project-pages/validate-summary.cjs} +5 -5
  141. package/dist/assets/AgentLibrary-Bkv-HcP1.js +0 -3
  142. package/dist/assets/MarkdownEditor-Xc141kjj.js +0 -1
  143. package/dist/assets/Permissions-DKoNVgzj.js +0 -3
  144. package/dist/assets/Scheduler-CbES7MC8.js +0 -14
  145. package/dist/assets/Settings-BX3FElXk.js +0 -3
  146. package/dist/assets/settingsSchema-sGoCTd7J.js +0 -3
  147. /package/{scripts/project-pages-logic → web/project-pages/logic}/dist/logic.cjs +0 -0
@@ -0,0 +1,162 @@
1
+ /**
2
+ * needsReviewLedger.test.cjs — unit tests for src/main/lib/needsReviewLedger.cjs's
3
+ * pure ladder-rung classification, line builders, and rollup reduction.
4
+ *
5
+ * Run: timeout 120 npx vitest run src/main/__tests__/needsReviewLedger.test.cjs
6
+ */
7
+ 'use strict';
8
+
9
+ import { test, expect } from 'vitest';
10
+ const {
11
+ LADDER_RUNGS,
12
+ classifyLadderRung,
13
+ buildNeedsReviewEntryLine,
14
+ buildNeedsReviewResolutionLine,
15
+ reduceNeedsReviewLedger,
16
+ } = require('../lib/needsReviewLedger.cjs');
17
+
18
+ // ---------- classifyLadderRung ----------
19
+
20
+ test('classifyLadderRung maps every known automated source to its named rung', () => {
21
+ expect(classifyLadderRung({ source: 'scheduler:mechanicalRecovery' })).toBe('mechanical-recovery');
22
+ expect(classifyLadderRung({ source: 'spawnJob:dispatch', reason: 'dispatched for resume-recovery' })).toBe('resume-recovery');
23
+ expect(classifyLadderRung({ source: 'spawnInvestigation:start' })).toBe('auto-fix');
24
+ expect(classifyLadderRung({ source: 'spawnJob:auto-promote' })).toBe('auto-fix');
25
+ expect(classifyLadderRung({ source: 'reverifyNeedsReview:auto-promote' })).toBe('auto-fix');
26
+ expect(classifyLadderRung({ source: 'reverifyNeedsReview:heal' })).toBe('reverify');
27
+ expect(classifyLadderRung({ source: 'needsReviewAutoResolve' })).toBe('reverify');
28
+ });
29
+
30
+ test('classifyLadderRung: ordinary spawnJob:dispatch (no resume-recovery reason) is NOT resume-recovery', () => {
31
+ // 'spawnJob:dispatch' is shared with the everyday pending->running dispatch
32
+ // — only the resume-recovery REASON text distinguishes the two.
33
+ expect(classifyLadderRung({ source: 'spawnJob:dispatch', reason: 'dispatched for execution' })).toBe('manual-reset');
34
+ });
35
+
36
+ test('classifyLadderRung: unrecognized/explicit-reset sources default to manual-reset', () => {
37
+ expect(classifyLadderRung({ source: 'ipc:schedule:reset-job' })).toBe('manual-reset');
38
+ expect(classifyLadderRung({ source: 'remote:resetJob' })).toBe('manual-reset');
39
+ expect(classifyLadderRung({ source: 'clear-queue' })).toBe('manual-reset');
40
+ expect(classifyLadderRung({})).toBe('manual-reset');
41
+ });
42
+
43
+ test('LADDER_RUNGS names exactly the 6 documented rungs', () => {
44
+ expect(LADDER_RUNGS).toEqual(['mechanical-recovery', 'resume-recovery', 'quarantine', 'auto-fix', 'reverify', 'manual-reset']);
45
+ });
46
+
47
+ // ---------- buildNeedsReviewEntryLine / buildNeedsReviewResolutionLine ----------
48
+
49
+ test('buildNeedsReviewEntryLine: park reason prefers verifierVerdict, then heldReason, then error', () => {
50
+ const entry = { to: 'needs_review', source: 'spawnJob:finalize', at: '2026-09-13T00:00:00.000Z' };
51
+ expect(buildNeedsReviewEntryLine({ slug: 's1', verifierVerdict: 'uncommitted_changes', heldReason: 'held', error: 'err' }, entry).reason).toBe('uncommitted_changes');
52
+ expect(buildNeedsReviewEntryLine({ slug: 's1', heldReason: 'held', error: 'err' }, entry).reason).toBe('held');
53
+ expect(buildNeedsReviewEntryLine({ slug: 's1', error: 'err' }, entry).reason).toBe('err');
54
+ expect(buildNeedsReviewEntryLine({ slug: 's1' }, entry).reason).toBeNull();
55
+ });
56
+
57
+ test('buildNeedsReviewEntryLine: carries slug/cwd/epicId/runId/at/source verbatim', () => {
58
+ const job = { slug: '42-x', cwd: '/proj', epicId: 'epic-1', runId: 'run-9' };
59
+ const entry = { to: 'needs_review', source: 'spawnJob:finalize', at: '2026-09-13T00:00:00.000Z' };
60
+ const line = buildNeedsReviewEntryLine(job, entry);
61
+ expect(line).toEqual({
62
+ kind: 'needs_review_entry',
63
+ slug: '42-x',
64
+ cwd: '/proj',
65
+ epicId: 'epic-1',
66
+ runId: 'run-9',
67
+ at: '2026-09-13T00:00:00.000Z',
68
+ reason: null,
69
+ source: 'spawnJob:finalize',
70
+ });
71
+ });
72
+
73
+ test('buildNeedsReviewResolutionLine: references the EPISODE runId, not job.runId, and computes dwellMs', () => {
74
+ const job = { slug: '42-x', cwd: '/proj', epicId: 'epic-1', runId: 'run-LATER' };
75
+ const entry = { to: 'completed', source: 'reverifyNeedsReview:heal', at: '2026-09-13T00:10:00.000Z' };
76
+ const episode = { runId: 'run-ORIGINAL', enteredAt: '2026-09-13T00:00:00.000Z' };
77
+ const line = buildNeedsReviewResolutionLine(job, entry, episode);
78
+ expect(line.runId).toBe('run-ORIGINAL');
79
+ expect(line.resolvedTo).toBe('completed');
80
+ expect(line.ladderRung).toBe('reverify');
81
+ expect(line.dwellMs).toBe(10 * 60_000);
82
+ });
83
+
84
+ test('buildNeedsReviewResolutionLine: dwellMs is null when the episode has no enteredAt (defensive — should not happen in practice)', () => {
85
+ const job = { slug: '42-x', runId: 'run-1' };
86
+ const entry = { to: 'failed', source: 'ipc:schedule:reset-job', at: '2026-09-13T00:00:00.000Z' };
87
+ const line = buildNeedsReviewResolutionLine(job, entry, { runId: 'run-1', enteredAt: null });
88
+ expect(line.dwellMs).toBeNull();
89
+ });
90
+
91
+ // ---------- reduceNeedsReviewLedger ----------
92
+
93
+ function entryLine({ slug, runId, at, reason = 'uncommitted_changes', source = 'spawnJob:finalize' }) {
94
+ return { kind: 'needs_review_entry', slug, cwd: null, epicId: null, runId, at, reason, source };
95
+ }
96
+ function resolutionLine({ slug, runId, at, resolvedTo = 'completed', ladderRung = 'reverify', source = 'reverifyNeedsReview:heal', dwellMs = 1000 }) {
97
+ return { kind: 'needs_review_resolution', slug, cwd: null, epicId: null, runId, at, resolvedTo, ladderRung, source, dwellMs };
98
+ }
99
+
100
+ test('reduceNeedsReviewLedger: entry-only (unresolved) episode counts toward byReason and unresolvedCount, not byLadderRung', () => {
101
+ const lines = [entryLine({ slug: 'a', runId: 'r1', at: '2026-09-13T00:00:00.000Z', reason: 'silent_no_op' })];
102
+ const rollup = reduceNeedsReviewLedger(lines);
103
+ expect(rollup.byReason).toEqual({ silent_no_op: 1 });
104
+ expect(rollup.byLadderRung).toEqual({});
105
+ expect(rollup.unresolvedCount).toBe(1);
106
+ expect(rollup.dwellMsP50).toBeNull();
107
+ expect(rollup.dwellMsP90).toBeNull();
108
+ });
109
+
110
+ test('reduceNeedsReviewLedger: entry+resolution pair resolves and contributes dwell', () => {
111
+ const lines = [
112
+ entryLine({ slug: 'a', runId: 'r1', at: '2026-09-13T00:00:00.000Z' }),
113
+ resolutionLine({ slug: 'a', runId: 'r1', at: '2026-09-13T00:00:05.000Z', dwellMs: 5000, ladderRung: 'mechanical-recovery' }),
114
+ ];
115
+ const rollup = reduceNeedsReviewLedger(lines);
116
+ expect(rollup.unresolvedCount).toBe(0);
117
+ expect(rollup.byLadderRung).toEqual({ 'mechanical-recovery': 1 });
118
+ expect(rollup.dwellMsP50).toBe(5000);
119
+ expect(rollup.dwellMsP90).toBe(5000);
120
+ });
121
+
122
+ test('reduceNeedsReviewLedger: repeated entries for the same slug (different runIds) count as independent episodes', () => {
123
+ const lines = [
124
+ entryLine({ slug: 'a', runId: 'r1', at: '2026-09-13T00:00:00.000Z', reason: 'uncommitted_changes' }),
125
+ resolutionLine({ slug: 'a', runId: 'r1', at: '2026-09-13T00:00:10.000Z', dwellMs: 10_000, ladderRung: 'manual-reset' }),
126
+ entryLine({ slug: 'a', runId: 'r2', at: '2026-09-13T01:00:00.000Z', reason: 'uncommitted_changes' }),
127
+ // r2 never resolves.
128
+ ];
129
+ const rollup = reduceNeedsReviewLedger(lines);
130
+ expect(rollup.byReason).toEqual({ uncommitted_changes: 2 });
131
+ expect(rollup.unresolvedCount).toBe(1);
132
+ expect(rollup.byLadderRung).toEqual({ 'manual-reset': 1 });
133
+ expect(rollup.dwellMsP50).toBe(10_000);
134
+ });
135
+
136
+ test('reduceNeedsReviewLedger: p50/p90 over several resolved episodes', () => {
137
+ const dwells = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10_000];
138
+ const lines = dwells.flatMap((d, i) => [
139
+ entryLine({ slug: `s${i}`, runId: `r${i}`, at: '2026-09-13T00:00:00.000Z' }),
140
+ resolutionLine({ slug: `s${i}`, runId: `r${i}`, at: '2026-09-13T00:00:00.000Z', dwellMs: d }),
141
+ ]);
142
+ const rollup = reduceNeedsReviewLedger(lines);
143
+ expect(rollup.dwellMsP50).toBe(5000);
144
+ expect(rollup.dwellMsP90).toBe(9000);
145
+ });
146
+
147
+ test('reduceNeedsReviewLedger: ignores unrelated (terminal) rows mixed into the same lines array', () => {
148
+ const lines = [
149
+ { kind: 'terminal', slug: 'a', status: 'completed', runId: 'r1' },
150
+ { slug: 'b', status: 'failed', runId: 'r2' }, // legacy row, no kind at all
151
+ entryLine({ slug: 'c', runId: 'r3', at: '2026-09-13T00:00:00.000Z' }),
152
+ ];
153
+ const rollup = reduceNeedsReviewLedger(lines);
154
+ expect(rollup.unresolvedCount).toBe(1);
155
+ expect(Object.keys(rollup.byReason)).toEqual(['uncommitted_changes']);
156
+ });
157
+
158
+ test('reduceNeedsReviewLedger: empty/non-array input returns a zeroed rollup, never throws', () => {
159
+ expect(reduceNeedsReviewLedger([])).toEqual({ byReason: {}, byLadderRung: {}, unresolvedCount: 0, dwellMsP50: null, dwellMsP90: null });
160
+ expect(reduceNeedsReviewLedger(null)).toEqual({ byReason: {}, byLadderRung: {}, unresolvedCount: 0, dwellMsP50: null, dwellMsP90: null });
161
+ expect(reduceNeedsReviewLedger(undefined)).toEqual({ byReason: {}, byLadderRung: {}, unresolvedCount: 0, dwellMsP50: null, dwellMsP90: null });
162
+ });
@@ -24,7 +24,7 @@ afterEach(async () => {
24
24
  if (originalSmTelemetrySpool === undefined) delete process.env.SM_TELEMETRY_SPOOL; else process.env.SM_TELEMETRY_SPOOL = originalSmTelemetrySpool;
25
25
  const telemetryPath = require.resolve('../lib/telemetryClient.cjs');
26
26
  delete require.cache[telemetryPath];
27
- const activeSessionsPath = require.resolve('../../../scripts/lib/activeSessions.cjs');
27
+ const activeSessionsPath = require.resolve('../lib/activeSessions.cjs');
28
28
  delete require.cache[activeSessionsPath];
29
29
  while (tmpDirs.length) {
30
30
  const d = tmpDirs.pop();
@@ -89,8 +89,8 @@ test('an ephemeral cwd yields zero local lines but one telemetry record, with a
89
89
  const worktreeCwd = path.join(KIND_CONFIG.epic.root, 'fakehash', 'fake-epic-id');
90
90
  const realRoot = '/home/bilko/Projects/real-project';
91
91
 
92
- const activeSessionsPath = require.resolve('../../../scripts/lib/activeSessions.cjs');
93
- const original = require('../../../scripts/lib/activeSessions.cjs');
92
+ const activeSessionsPath = require.resolve('../lib/activeSessions.cjs');
93
+ const original = require('../lib/activeSessions.cjs');
94
94
  require.cache[activeSessionsPath] = {
95
95
  id: activeSessionsPath,
96
96
  filename: activeSessionsPath,
@@ -73,10 +73,24 @@ function mkProject() {
73
73
  return { cwd, slug };
74
74
  }
75
75
 
76
+ // dependsOn deliberately references a slug that can never resolve (no such
77
+ // row, no history/archive entry) so pickNextBatch's dep gate holds this job
78
+ // forever instead of ever handing it to spawnJob. tickQueue() still reaches
79
+ // the picker and stamps lastDispatchAttemptAt (that stamp is unconditional —
80
+ // see lastDispatchAttemptAt's own header comment), which is the only thing
81
+ // these tests assert on. Without this, the picker actually dispatches the
82
+ // job: spawnJob() is fire-and-forget (scheduler.cjs's own comment: "spawnJob
83
+ // is fire-and-forget; it calls tickQueue() on completion") and its real
84
+ // child-process exit handler later calls mutate() independently of the
85
+ // tickTail chain flushPendingTick() drains — round-tripping whatever
86
+ // lastDispatchAttemptAt was in memory at ITS read time. Reproduced outside
87
+ // vitest: that stray write landed ~2s after this suite's own reset-to-null,
88
+ // clobbering the NEXT test's "still null" assertion with the previous test's
89
+ // stamp. A held (never-dispatched) job has no such background continuation.
76
90
  async function seedOnePendingJob() {
77
91
  const { cwd, slug } = mkProject();
78
92
  await scheduler.writeQueue({
79
- jobs: [{ slug, title: 'x', cwd, status: 'pending', dependsOn: [] }],
93
+ jobs: [{ slug, title: 'x', cwd, status: 'pending', dependsOn: ['unresolvable-dep-never-completes'] }],
80
94
  config: {},
81
95
  paused: null,
82
96
  });
@@ -0,0 +1,201 @@
1
+ /**
2
+ * prdCreateDisposition.test.cjs — scheduler wave-disposition PRD:
3
+ * createPrd()'s authoring-time disposition gate. A PRD landing as a wave
4
+ * ROOT (no dependsOn of its own) in an Epic that already has incomplete
5
+ * PRDs must record an explicit 'append'/'new-head' choice — required for an
6
+ * interactive caller, defaulted (and logged) for a non-interactive one.
7
+ *
8
+ * Run: timeout 120 npx vitest run src/main/__tests__/prdCreateDisposition.test.cjs
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ import { test, expect, beforeEach, afterEach } from 'vitest';
14
+ const fsp = require('node:fs/promises');
15
+ const os = require('node:os');
16
+ const path = require('node:path');
17
+ const config = require('../config.cjs');
18
+ const prdParser = require('../scheduler/prdParser.cjs');
19
+ const { parsePrdFile } = require('../lib/prdFrontmatter.cjs');
20
+ const { createPrd } = require('../lib/prdCreate.cjs');
21
+
22
+ async function mkTmpPrdsDir() {
23
+ const root = await fsp.mkdtemp(path.join(os.tmpdir(), 'sm-disposition-create-prd-'));
24
+ config.addAllowedRoot(root);
25
+ const prdsDir = path.join(root, '.claude', 'prds');
26
+ await fsp.mkdir(prdsDir, { recursive: true });
27
+ return prdsDir;
28
+ }
29
+
30
+ /** Minimal fake `remote` — same shape as prdCreate.test.cjs's
31
+ * makeFakeRemoteWithPrdsDir, but listPrds also reports sourcePromptId/
32
+ * dependsOn (read back from each seeded file's real frontmatter) and
33
+ * status (from the test-supplied statusBySlug map) — the fields
34
+ * createPrd()'s disposition gate actually reads. */
35
+ function makeFakeRemote(prdsDir, statusBySlug = {}) {
36
+ return {
37
+ async allocateParallelGroup() {
38
+ return prdParser.allocateParallelGroup(prdsDir);
39
+ },
40
+ async readPrd(slug) {
41
+ try {
42
+ const text = await fsp.readFile(path.join(prdsDir, `${slug}.md`), 'utf8');
43
+ return { ok: true, text };
44
+ } catch (e) {
45
+ return { ok: false, error: e?.message };
46
+ }
47
+ },
48
+ async writePrd(slug, body) {
49
+ try {
50
+ const filePath = path.join(prdsDir, `${slug}.md`);
51
+ await config.writeTextAtomic(filePath, body, { writer: 'scheduler' });
52
+ return { ok: true };
53
+ } catch (e) {
54
+ return { ok: false, error: e?.message };
55
+ }
56
+ },
57
+ async listPrds() {
58
+ const entries = await fsp.readdir(prdsDir);
59
+ const prds = [];
60
+ for (const f of entries) {
61
+ if (!f.endsWith('.md')) continue;
62
+ const slug = f.slice(0, -3);
63
+ const raw = await fsp.readFile(path.join(prdsDir, f), 'utf8');
64
+ const { frontmatter } = parsePrdFile(raw);
65
+ prds.push({
66
+ slug,
67
+ sourcePromptId: frontmatter.sourcePromptId ?? null,
68
+ dependsOn: frontmatter.dependsOn ?? null,
69
+ status: statusBySlug[slug] ?? null,
70
+ });
71
+ }
72
+ return { prds, total: prds.length, limit: prds.length, offset: 0, hasMore: false };
73
+ },
74
+ };
75
+ }
76
+
77
+ /** Seeds a fixture PRD file directly (bypassing createPrd) at an explicit,
78
+ * already-NN-prefixed slug, so tests can assert dependsOn against a known
79
+ * name instead of a freshly-allocated one. */
80
+ async function seedPrd(prdsDir, slug, { sourcePromptId, dependsOn } = {}) {
81
+ const lines = ['---', 'title: seed', `sourcePromptId: ${sourcePromptId}`];
82
+ if (dependsOn && dependsOn.length) lines.push(`dependsOn: [${dependsOn.join(', ')}]`);
83
+ lines.push('---', '# Goal', '', 'seed body', '');
84
+ await fsp.writeFile(path.join(prdsDir, `${slug}.md`), lines.join('\n'));
85
+ }
86
+
87
+ function validBody(overrides = {}) {
88
+ return {
89
+ title: 'Wave 2 root',
90
+ cwd: os.homedir(),
91
+ estimateMinutes: 10,
92
+ goal: 'Do the follow-on work.',
93
+ acceptanceCriteria: ['a'],
94
+ implementationNotes: 'n',
95
+ ...overrides,
96
+ };
97
+ }
98
+
99
+ // This suite's own process may itself be running as a scheduled job (this
100
+ // file's disposition gate keys directly off SM_SCHEDULER_JOB_SLUG — see
101
+ // createPrd()) — never assume it's unset going in; each test controls it
102
+ // explicitly.
103
+ const originalJobSlug = process.env.SM_SCHEDULER_JOB_SLUG;
104
+ beforeEach(() => {
105
+ delete process.env.SM_SCHEDULER_JOB_SLUG;
106
+ });
107
+ afterEach(() => {
108
+ if (originalJobSlug === undefined) delete process.env.SM_SCHEDULER_JOB_SLUG;
109
+ else process.env.SM_SCHEDULER_JOB_SLUG = originalJobSlug;
110
+ });
111
+
112
+ test('refuses to write, without a disposition, a new root joining an Epic that already has an incomplete PRD', async () => {
113
+ const prdsDir = await mkTmpPrdsDir();
114
+ await seedPrd(prdsDir, '1-wave1-tail', { sourcePromptId: 'epic-1' });
115
+ const remote = makeFakeRemote(prdsDir, { '1-wave1-tail': 'pending' });
116
+
117
+ const result = await createPrd(validBody({ sourcePromptId: 'epic-1' }), remote);
118
+
119
+ expect(result.ok).toBe(false);
120
+ expect(result.status).toBe(400);
121
+ expect(result.error).toMatch(/disposition/i);
122
+ });
123
+
124
+ test('disposition: append attaches the new root behind the Epic\'s current terminal PRD', async () => {
125
+ const prdsDir = await mkTmpPrdsDir();
126
+ await seedPrd(prdsDir, '1-wave1-tail', { sourcePromptId: 'epic-1' });
127
+ const remote = makeFakeRemote(prdsDir, { '1-wave1-tail': 'pending' });
128
+
129
+ const result = await createPrd(validBody({ sourcePromptId: 'epic-1', disposition: 'append' }), remote);
130
+
131
+ expect(result.ok).toBe(true);
132
+ const written = await fsp.readFile(path.join(prdsDir, result.filename), 'utf8');
133
+ expect(written).toMatch(/^dependsOn: \[1-wave1-tail\]$/m);
134
+ expect(written).toMatch(/^disposition: append$/m);
135
+ });
136
+
137
+ test('disposition: new-head leaves the new root independent (no dependsOn)', async () => {
138
+ const prdsDir = await mkTmpPrdsDir();
139
+ await seedPrd(prdsDir, '1-wave1-tail', { sourcePromptId: 'epic-1' });
140
+ const remote = makeFakeRemote(prdsDir, { '1-wave1-tail': 'pending' });
141
+
142
+ const result = await createPrd(validBody({ sourcePromptId: 'epic-1', disposition: 'new-head' }), remote);
143
+
144
+ expect(result.ok).toBe(true);
145
+ const written = await fsp.readFile(path.join(prdsDir, result.filename), 'utf8');
146
+ expect(written).not.toContain('dependsOn');
147
+ expect(written).toMatch(/^disposition: new-head$/m);
148
+ });
149
+
150
+ test('a non-interactive caller (SM_SCHEDULER_JOB_SLUG set) with no disposition defaults to append, logged as a default', async () => {
151
+ const prdsDir = await mkTmpPrdsDir();
152
+ await seedPrd(prdsDir, '1-wave1-tail', { sourcePromptId: 'epic-1' });
153
+ const remote = makeFakeRemote(prdsDir, { '1-wave1-tail': 'pending' });
154
+ process.env.SM_SCHEDULER_JOB_SLUG = 'some-running-job';
155
+
156
+ const result = await createPrd(validBody({ sourcePromptId: 'epic-1' }), remote);
157
+
158
+ expect(result.ok).toBe(true);
159
+ const written = await fsp.readFile(path.join(prdsDir, result.filename), 'utf8');
160
+ expect(written).toMatch(/^dependsOn: \[1-wave1-tail\]$/m);
161
+ expect(written).toMatch(/^disposition: append$/m);
162
+ });
163
+
164
+ test('no disposition required for the first PRD in a brand-new Epic', async () => {
165
+ const prdsDir = await mkTmpPrdsDir();
166
+ const remote = makeFakeRemote(prdsDir);
167
+
168
+ const result = await createPrd(validBody({ sourcePromptId: 'epic-empty' }), remote);
169
+
170
+ expect(result.ok).toBe(true);
171
+ const written = await fsp.readFile(path.join(prdsDir, result.filename), 'utf8');
172
+ expect(written).not.toContain('disposition');
173
+ });
174
+
175
+ test('no disposition required when every existing PRD in the Epic is already completed', async () => {
176
+ const prdsDir = await mkTmpPrdsDir();
177
+ await seedPrd(prdsDir, '1-wave1-tail', { sourcePromptId: 'epic-done' });
178
+ const remote = makeFakeRemote(prdsDir, { '1-wave1-tail': 'completed' });
179
+
180
+ const result = await createPrd(validBody({ sourcePromptId: 'epic-done' }), remote);
181
+
182
+ expect(result.ok).toBe(true);
183
+ const written = await fsp.readFile(path.join(prdsDir, result.filename), 'utf8');
184
+ expect(written).not.toContain('disposition');
185
+ });
186
+
187
+ test('an explicit dependsOn bypasses the disposition gate entirely', async () => {
188
+ const prdsDir = await mkTmpPrdsDir();
189
+ await seedPrd(prdsDir, '1-wave1-tail', { sourcePromptId: 'epic-1' });
190
+ const remote = makeFakeRemote(prdsDir, { '1-wave1-tail': 'pending' });
191
+
192
+ const result = await createPrd(
193
+ validBody({ sourcePromptId: 'epic-1', dependsOn: ['1-wave1-tail'] }),
194
+ remote,
195
+ );
196
+
197
+ expect(result.ok).toBe(true);
198
+ const written = await fsp.readFile(path.join(prdsDir, result.filename), 'utf8');
199
+ expect(written).toMatch(/^dependsOn: \[1-wave1-tail\]$/m);
200
+ expect(written).not.toContain('disposition');
201
+ });
@@ -0,0 +1,125 @@
1
+ /**
2
+ * prdFrontmatterDisposition.test.cjs — scheduler wave-disposition PRD:
3
+ * `disposition` ('append' | 'new-head') is a recognized, patchable PRD
4
+ * frontmatter key, same pattern as `dependsOn` in
5
+ * prdFrontmatterDependsOn.test.cjs. It records the authoring-time decision
6
+ * for a wave's root PRD: does it extend the Epic's existing dependsOn chain
7
+ * (append) or start an independent, parallel-eligible chain (new-head)?
8
+ *
9
+ * Run: timeout 120 npx vitest run src/main/__tests__/prdFrontmatterDisposition.test.cjs
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ import { test, expect } from 'vitest';
15
+
16
+ const { parsePrdFile, serializePrdFile, RECOGNIZED_KEYS } = require('../lib/prdFrontmatter.cjs');
17
+
18
+ test('disposition is a recognized key', () => {
19
+ expect(RECOGNIZED_KEYS.has('disposition')).toBe(true);
20
+ });
21
+
22
+ test('parsePrdFile parses disposition: append and round-trips it byte-identically when unedited', () => {
23
+ const raw = [
24
+ '---',
25
+ 'title: A second wave',
26
+ 'cwd: ~/Projects/session-manager',
27
+ 'estimateMinutes: 20',
28
+ 'dependsOn: [widget-base]',
29
+ 'disposition: append',
30
+ '---',
31
+ '# Goal',
32
+ '',
33
+ 'Extend the chain.',
34
+ '',
35
+ ].join('\n');
36
+
37
+ const { frontmatter, body } = parsePrdFile(raw);
38
+ expect(frontmatter.disposition).toBe('append');
39
+ expect(serializePrdFile(frontmatter, body)).toBe(raw);
40
+ });
41
+
42
+ test('parsePrdFile parses disposition: new-head', () => {
43
+ const raw = [
44
+ '---',
45
+ 'title: A parallel wave',
46
+ 'cwd: ~/Projects/session-manager',
47
+ 'estimateMinutes: 20',
48
+ 'disposition: new-head',
49
+ '---',
50
+ 'body',
51
+ '',
52
+ ].join('\n');
53
+
54
+ const { frontmatter } = parsePrdFile(raw);
55
+ expect(frontmatter.disposition).toBe('new-head');
56
+ });
57
+
58
+ test('parsePrdFile leaves disposition unset for an unrecognized value rather than throwing', () => {
59
+ const raw = [
60
+ '---',
61
+ 'title: A hand-edited PRD',
62
+ 'cwd: ~/Projects/session-manager',
63
+ 'estimateMinutes: 20',
64
+ 'disposition: sideways',
65
+ '---',
66
+ 'body',
67
+ '',
68
+ ].join('\n');
69
+
70
+ const { frontmatter } = parsePrdFile(raw);
71
+ expect(frontmatter.disposition).toBeUndefined();
72
+ });
73
+
74
+ test('parsePrdFile leaves disposition undefined when omitted — a PRD authored before this field existed round-trips unaffected', () => {
75
+ const raw = [
76
+ '---',
77
+ 'title: An older PRD',
78
+ 'cwd: ~/Projects/session-manager',
79
+ 'estimateMinutes: 10',
80
+ '---',
81
+ '# Goal',
82
+ '',
83
+ 'Do the thing.',
84
+ '',
85
+ ].join('\n');
86
+
87
+ const { frontmatter, body } = parsePrdFile(raw);
88
+ expect(frontmatter.disposition).toBeUndefined();
89
+ expect(serializePrdFile(frontmatter, body)).toBe(raw);
90
+ });
91
+
92
+ test('serializePrdFile emits a newly-set disposition onto a frontmatter object that lacked one', () => {
93
+ const raw = [
94
+ '---',
95
+ 'title: Legacy PRD',
96
+ 'cwd: ~/Projects/session-manager',
97
+ 'estimateMinutes: 5',
98
+ '---',
99
+ 'body',
100
+ '',
101
+ ].join('\n');
102
+
103
+ const { frontmatter, body } = parsePrdFile(raw);
104
+ const updated = serializePrdFile({ ...frontmatter, disposition: 'new-head' }, body);
105
+ expect(updated).toContain('disposition: new-head');
106
+ });
107
+
108
+ test('serializePrdFile patches an existing disposition (promoting append to new-head)', () => {
109
+ const raw = [
110
+ '---',
111
+ 'title: A second wave',
112
+ 'cwd: ~/Projects/session-manager',
113
+ 'estimateMinutes: 20',
114
+ 'dependsOn: [widget-base]',
115
+ 'disposition: append',
116
+ '---',
117
+ 'body',
118
+ '',
119
+ ].join('\n');
120
+
121
+ const { frontmatter, body } = parsePrdFile(raw);
122
+ const updated = serializePrdFile({ ...frontmatter, dependsOn: [], disposition: 'new-head' }, body);
123
+ expect(updated).toContain('disposition: new-head');
124
+ expect(updated).not.toContain('dependsOn');
125
+ });
@@ -7,12 +7,17 @@
7
7
 
8
8
  'use strict';
9
9
 
10
- import { test, expect, afterEach } from 'vitest';
10
+ import { test, expect, afterEach, vi } from 'vitest';
11
11
  const fs = require('node:fs');
12
12
  const fsp = require('node:fs/promises');
13
13
  const os = require('node:os');
14
14
  const path = require('node:path');
15
- const { resolvePrdWriteDir, resolvePrdsDirs } = require('../lib/prdLocations.cjs');
15
+ const {
16
+ resolvePrdWriteDir,
17
+ resolvePrdsDirs,
18
+ resolveEpicPrdWriteDir,
19
+ listEpicPrdDirs,
20
+ } = require('../lib/prdLocations.cjs');
16
21
 
17
22
  const tmpDirs = [];
18
23
  afterEach(async () => {
@@ -95,3 +100,96 @@ test('resolvePrdsDirs returns [] when no project has a recent transcript', () =>
95
100
  const dirs = resolvePrdsDirs(90, { projectsDir: '/nonexistent-projects-dir' });
96
101
  expect(dirs).toEqual([]);
97
102
  });
103
+
104
+ test('listEpicPrdDirs memoizes on the Epics-root mtime: no readdir on a repeat call, but a freshly minted Epic prds dir is picked up on the very next call', async () => {
105
+ const cwd = await fsp.mkdtemp(path.join(os.tmpdir(), 'sm-prdloc-memo-cwd-'));
106
+ tmpDirs.push(cwd);
107
+ fs.mkdirSync(resolveEpicPrdWriteDir(cwd, 'epic-1'), { recursive: true });
108
+
109
+ const first = listEpicPrdDirs(cwd);
110
+ expect(first).toEqual([resolveEpicPrdWriteDir(cwd, 'epic-1')]);
111
+
112
+ const readdirSpy = vi.spyOn(fs, 'readdirSync');
113
+ try {
114
+ // Nothing under the Epics root changed — the cached result comes back
115
+ // without a fresh readdir of the Epics root.
116
+ const second = listEpicPrdDirs(cwd);
117
+ expect(second).toEqual(first);
118
+ expect(readdirSpy).not.toHaveBeenCalled();
119
+ } finally {
120
+ readdirSpy.mockRestore();
121
+ }
122
+
123
+ // A brand-new Epic's prds/ dir is a NEW entry under the Epics root, which
124
+ // bumps the root's own mtime — no TTL wait required to see it.
125
+ fs.mkdirSync(resolveEpicPrdWriteDir(cwd, 'epic-2'), { recursive: true });
126
+ const third = listEpicPrdDirs(cwd);
127
+ expect(third).toEqual(
128
+ expect.arrayContaining([resolveEpicPrdWriteDir(cwd, 'epic-1'), resolveEpicPrdWriteDir(cwd, 'epic-2')]),
129
+ );
130
+ });
131
+
132
+ test('listEpicPrdDirs: an unreadable Epics root does not write a poisoned entry that survives the dir becoming readable', async () => {
133
+ const cwd = await fsp.mkdtemp(path.join(os.tmpdir(), 'sm-prdloc-unreadable-cwd-'));
134
+ tmpDirs.push(cwd);
135
+
136
+ // No Epics root at all yet.
137
+ expect(listEpicPrdDirs(cwd)).toEqual([]);
138
+
139
+ // The root now exists, with a real Epic prds dir inside it.
140
+ fs.mkdirSync(resolveEpicPrdWriteDir(cwd, 'epic-1'), { recursive: true });
141
+ expect(listEpicPrdDirs(cwd)).toEqual([resolveEpicPrdWriteDir(cwd, 'epic-1')]);
142
+ });
143
+
144
+ test('resolvePrdsDirs EDGE (non-negotiable): a new epics/<id>/prds dir created after a prior call is visible on the VERY NEXT call, no TTL wait', async () => {
145
+ const projectsDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'sm-prdloc-freshness-projects-'));
146
+ tmpDirs.push(projectsDir);
147
+ const projectCwd = await fsp.mkdtemp(path.join(os.tmpdir(), 'sm-prdloc-freshness-cwd-'));
148
+ tmpDirs.push(projectCwd);
149
+
150
+ const projDir = path.join(projectsDir, 'freshness-project');
151
+ fs.mkdirSync(projDir, { recursive: true });
152
+ fs.writeFileSync(path.join(projDir, 'session1.jsonl'), `${JSON.stringify({ cwd: projectCwd })}\n`);
153
+
154
+ const before = resolvePrdsDirs(90, { projectsDir });
155
+ const newEpicPrdDir = resolveEpicPrdWriteDir(projectCwd, 'freshly-minted-epic');
156
+ expect(before).not.toContain(newEpicPrdDir);
157
+
158
+ fs.mkdirSync(newEpicPrdDir, { recursive: true });
159
+
160
+ const after = resolvePrdsDirs(90, { projectsDir });
161
+ expect(after).toContain(newEpicPrdDir);
162
+ });
163
+
164
+ test('resolvePrdsDirs: calls with an explicit { projectsDir } opts are keyed separately per projectsDir and never share a stale cache entry', async () => {
165
+ const projectsDirA = await fsp.mkdtemp(path.join(os.tmpdir(), 'sm-prdloc-keyed-a-'));
166
+ tmpDirs.push(projectsDirA);
167
+ const projectsDirB = await fsp.mkdtemp(path.join(os.tmpdir(), 'sm-prdloc-keyed-b-'));
168
+ tmpDirs.push(projectsDirB);
169
+ const cwdA = await fsp.mkdtemp(path.join(os.tmpdir(), 'sm-prdloc-keyed-cwd-a-'));
170
+ tmpDirs.push(cwdA);
171
+ const cwdB = await fsp.mkdtemp(path.join(os.tmpdir(), 'sm-prdloc-keyed-cwd-b-'));
172
+ tmpDirs.push(cwdB);
173
+
174
+ const projDirA = path.join(projectsDirA, 'proj-a');
175
+ fs.mkdirSync(projDirA, { recursive: true });
176
+ fs.writeFileSync(path.join(projDirA, 'session1.jsonl'), `${JSON.stringify({ cwd: cwdA })}\n`);
177
+ fs.mkdirSync(resolvePrdWriteDir(cwdA), { recursive: true });
178
+
179
+ const projDirB = path.join(projectsDirB, 'proj-b');
180
+ fs.mkdirSync(projDirB, { recursive: true });
181
+ fs.writeFileSync(path.join(projDirB, 'session1.jsonl'), `${JSON.stringify({ cwd: cwdB })}\n`);
182
+ fs.mkdirSync(resolvePrdWriteDir(cwdB), { recursive: true });
183
+
184
+ const dirsA = resolvePrdsDirs(90, { projectsDir: projectsDirA });
185
+ const dirsB = resolvePrdsDirs(90, { projectsDir: projectsDirB });
186
+
187
+ expect(dirsA).toContain(resolvePrdWriteDir(cwdA));
188
+ expect(dirsA).not.toContain(resolvePrdWriteDir(cwdB));
189
+ expect(dirsB).toContain(resolvePrdWriteDir(cwdB));
190
+ expect(dirsB).not.toContain(resolvePrdWriteDir(cwdA));
191
+
192
+ // Re-querying A after B was resolved must still reflect A's own state, not
193
+ // B's — proof the two opts objects never shared one cache key.
194
+ expect(resolvePrdsDirs(90, { projectsDir: projectsDirA })).toEqual(dirsA);
195
+ });