@principles/pd-cli 1.73.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.
- package/README.md +90 -0
- package/dist/commands/artifact.d.ts +14 -0
- package/dist/commands/artifact.d.ts.map +1 -0
- package/dist/commands/artifact.js +67 -0
- package/dist/commands/artifact.js.map +1 -0
- package/dist/commands/candidate.d.ts +83 -0
- package/dist/commands/candidate.d.ts.map +1 -0
- package/dist/commands/candidate.js +891 -0
- package/dist/commands/candidate.js.map +1 -0
- package/dist/commands/central-sync.d.ts +10 -0
- package/dist/commands/central-sync.d.ts.map +1 -0
- package/dist/commands/central-sync.js +32 -0
- package/dist/commands/central-sync.js.map +1 -0
- package/dist/commands/console.d.ts +9 -0
- package/dist/commands/console.d.ts.map +1 -0
- package/dist/commands/console.js +114 -0
- package/dist/commands/console.js.map +1 -0
- package/dist/commands/context.d.ts +7 -0
- package/dist/commands/context.d.ts.map +1 -0
- package/dist/commands/context.js +55 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/demo-story-a.d.ts +12 -0
- package/dist/commands/demo-story-a.d.ts.map +1 -0
- package/dist/commands/demo-story-a.js +175 -0
- package/dist/commands/demo-story-a.js.map +1 -0
- package/dist/commands/diagnose.d.ts +35 -0
- package/dist/commands/diagnose.d.ts.map +1 -0
- package/dist/commands/diagnose.js +390 -0
- package/dist/commands/diagnose.js.map +1 -0
- package/dist/commands/evolution-tasks-list.d.ts +15 -0
- package/dist/commands/evolution-tasks-list.d.ts.map +1 -0
- package/dist/commands/evolution-tasks-list.js +34 -0
- package/dist/commands/evolution-tasks-list.js.map +1 -0
- package/dist/commands/evolution-tasks-show.d.ts +14 -0
- package/dist/commands/evolution-tasks-show.d.ts.map +1 -0
- package/dist/commands/evolution-tasks-show.js +52 -0
- package/dist/commands/evolution-tasks-show.js.map +1 -0
- package/dist/commands/flow.d.ts +7 -0
- package/dist/commands/flow.d.ts.map +1 -0
- package/dist/commands/flow.js +57 -0
- package/dist/commands/flow.js.map +1 -0
- package/dist/commands/health.d.ts +16 -0
- package/dist/commands/health.d.ts.map +1 -0
- package/dist/commands/health.js +150 -0
- package/dist/commands/health.js.map +1 -0
- package/dist/commands/history.d.ts +11 -0
- package/dist/commands/history.d.ts.map +1 -0
- package/dist/commands/history.js +50 -0
- package/dist/commands/history.js.map +1 -0
- package/dist/commands/legacy-cleanup.d.ts +27 -0
- package/dist/commands/legacy-cleanup.d.ts.map +1 -0
- package/dist/commands/legacy-cleanup.js +171 -0
- package/dist/commands/legacy-cleanup.js.map +1 -0
- package/dist/commands/legacy-import.d.ts +7 -0
- package/dist/commands/legacy-import.d.ts.map +1 -0
- package/dist/commands/legacy-import.js +86 -0
- package/dist/commands/legacy-import.js.map +1 -0
- package/dist/commands/pain-record.d.ts +10 -0
- package/dist/commands/pain-record.d.ts.map +1 -0
- package/dist/commands/pain-record.js +162 -0
- package/dist/commands/pain-record.js.map +1 -0
- package/dist/commands/proven-channel-baseline.d.ts +12 -0
- package/dist/commands/proven-channel-baseline.d.ts.map +1 -0
- package/dist/commands/proven-channel-baseline.js +97 -0
- package/dist/commands/proven-channel-baseline.js.map +1 -0
- package/dist/commands/remediation-output.d.ts +40 -0
- package/dist/commands/remediation-output.d.ts.map +1 -0
- package/dist/commands/remediation-output.js +23 -0
- package/dist/commands/remediation-output.js.map +1 -0
- package/dist/commands/run.d.ts +10 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +68 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/runtime-activation.d.ts +11 -0
- package/dist/commands/runtime-activation.d.ts.map +1 -0
- package/dist/commands/runtime-activation.js +150 -0
- package/dist/commands/runtime-activation.js.map +1 -0
- package/dist/commands/runtime-canary.d.ts +30 -0
- package/dist/commands/runtime-canary.d.ts.map +1 -0
- package/dist/commands/runtime-canary.js +343 -0
- package/dist/commands/runtime-canary.js.map +1 -0
- package/dist/commands/runtime-diagnostics-export.d.ts +20 -0
- package/dist/commands/runtime-diagnostics-export.d.ts.map +1 -0
- package/dist/commands/runtime-diagnostics-export.js +177 -0
- package/dist/commands/runtime-diagnostics-export.js.map +1 -0
- package/dist/commands/runtime-features.d.ts +26 -0
- package/dist/commands/runtime-features.d.ts.map +1 -0
- package/dist/commands/runtime-features.js +70 -0
- package/dist/commands/runtime-features.js.map +1 -0
- package/dist/commands/runtime-gfi-snapshot.d.ts +7 -0
- package/dist/commands/runtime-gfi-snapshot.d.ts.map +1 -0
- package/dist/commands/runtime-gfi-snapshot.js +101 -0
- package/dist/commands/runtime-gfi-snapshot.js.map +1 -0
- package/dist/commands/runtime-health-snapshot.d.ts +7 -0
- package/dist/commands/runtime-health-snapshot.d.ts.map +1 -0
- package/dist/commands/runtime-health-snapshot.js +93 -0
- package/dist/commands/runtime-health-snapshot.js.map +1 -0
- package/dist/commands/runtime-idle-trigger.d.ts +12 -0
- package/dist/commands/runtime-idle-trigger.d.ts.map +1 -0
- package/dist/commands/runtime-idle-trigger.js +102 -0
- package/dist/commands/runtime-idle-trigger.js.map +1 -0
- package/dist/commands/runtime-internalization-enqueue-successors.d.ts +9 -0
- package/dist/commands/runtime-internalization-enqueue-successors.d.ts.map +1 -0
- package/dist/commands/runtime-internalization-enqueue-successors.js +393 -0
- package/dist/commands/runtime-internalization-enqueue-successors.js.map +1 -0
- package/dist/commands/runtime-internalization-integrity-repair.d.ts +9 -0
- package/dist/commands/runtime-internalization-integrity-repair.d.ts.map +1 -0
- package/dist/commands/runtime-internalization-integrity-repair.js +54 -0
- package/dist/commands/runtime-internalization-integrity-repair.js.map +1 -0
- package/dist/commands/runtime-internalization-integrity.d.ts +7 -0
- package/dist/commands/runtime-internalization-integrity.d.ts.map +1 -0
- package/dist/commands/runtime-internalization-integrity.js +53 -0
- package/dist/commands/runtime-internalization-integrity.js.map +1 -0
- package/dist/commands/runtime-internalization-queue.d.ts +7 -0
- package/dist/commands/runtime-internalization-queue.d.ts.map +1 -0
- package/dist/commands/runtime-internalization-queue.js +85 -0
- package/dist/commands/runtime-internalization-queue.js.map +1 -0
- package/dist/commands/runtime-internalization-run-once.d.ts +12 -0
- package/dist/commands/runtime-internalization-run-once.d.ts.map +1 -0
- package/dist/commands/runtime-internalization-run-once.js +546 -0
- package/dist/commands/runtime-internalization-run-once.js.map +1 -0
- package/dist/commands/runtime-internalization-wake-once.d.ts +8 -0
- package/dist/commands/runtime-internalization-wake-once.d.ts.map +1 -0
- package/dist/commands/runtime-internalization-wake-once.js +72 -0
- package/dist/commands/runtime-internalization-wake-once.js.map +1 -0
- package/dist/commands/runtime-pain-flood-simulation.d.ts +10 -0
- package/dist/commands/runtime-pain-flood-simulation.d.ts.map +1 -0
- package/dist/commands/runtime-pain-flood-simulation.js +104 -0
- package/dist/commands/runtime-pain-flood-simulation.js.map +1 -0
- package/dist/commands/runtime-pruning.d.ts +45 -0
- package/dist/commands/runtime-pruning.d.ts.map +1 -0
- package/dist/commands/runtime-pruning.js +355 -0
- package/dist/commands/runtime-pruning.js.map +1 -0
- package/dist/commands/runtime-recovery.d.ts +9 -0
- package/dist/commands/runtime-recovery.d.ts.map +1 -0
- package/dist/commands/runtime-recovery.js +94 -0
- package/dist/commands/runtime-recovery.js.map +1 -0
- package/dist/commands/runtime-synthetic-baseline.d.ts +7 -0
- package/dist/commands/runtime-synthetic-baseline.d.ts.map +1 -0
- package/dist/commands/runtime-synthetic-baseline.js +59 -0
- package/dist/commands/runtime-synthetic-baseline.js.map +1 -0
- package/dist/commands/runtime-uat.d.ts +52 -0
- package/dist/commands/runtime-uat.d.ts.map +1 -0
- package/dist/commands/runtime-uat.js +274 -0
- package/dist/commands/runtime-uat.js.map +1 -0
- package/dist/commands/runtime.d.ts +20 -0
- package/dist/commands/runtime.d.ts.map +1 -0
- package/dist/commands/runtime.js +256 -0
- package/dist/commands/runtime.js.map +1 -0
- package/dist/commands/samples-list.d.ts +11 -0
- package/dist/commands/samples-list.d.ts.map +1 -0
- package/dist/commands/samples-list.js +37 -0
- package/dist/commands/samples-list.js.map +1 -0
- package/dist/commands/samples-review.d.ts +14 -0
- package/dist/commands/samples-review.d.ts.map +1 -0
- package/dist/commands/samples-review.js +22 -0
- package/dist/commands/samples-review.js.map +1 -0
- package/dist/commands/task.d.ts +14 -0
- package/dist/commands/task.d.ts.map +1 -0
- package/dist/commands/task.js +92 -0
- package/dist/commands/task.js.map +1 -0
- package/dist/commands/trace.d.ts +19 -0
- package/dist/commands/trace.d.ts.map +1 -0
- package/dist/commands/trace.js +154 -0
- package/dist/commands/trace.js.map +1 -0
- package/dist/commands/trajectory.d.ts +11 -0
- package/dist/commands/trajectory.d.ts.map +1 -0
- package/dist/commands/trajectory.js +47 -0
- package/dist/commands/trajectory.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +736 -0
- package/dist/index.js.map +1 -0
- package/dist/legacy/legacy-import.d.ts +15 -0
- package/dist/legacy/legacy-import.d.ts.map +1 -0
- package/dist/legacy/legacy-import.js +141 -0
- package/dist/legacy/legacy-import.js.map +1 -0
- package/dist/legacy/session-history-import.d.ts +26 -0
- package/dist/legacy/session-history-import.d.ts.map +1 -0
- package/dist/legacy/session-history-import.js +151 -0
- package/dist/legacy/session-history-import.js.map +1 -0
- package/dist/principle-tree-ledger-adapter.d.ts +12 -0
- package/dist/principle-tree-ledger-adapter.d.ts.map +1 -0
- package/dist/principle-tree-ledger-adapter.js +12 -0
- package/dist/principle-tree-ledger-adapter.js.map +1 -0
- package/dist/resolve-workspace.d.ts +12 -0
- package/dist/resolve-workspace.d.ts.map +1 -0
- package/dist/resolve-workspace.js +20 -0
- package/dist/resolve-workspace.js.map +1 -0
- package/dist/services/demo-story-a-runner.d.ts +8 -0
- package/dist/services/demo-story-a-runner.d.ts.map +1 -0
- package/dist/services/demo-story-a-runner.js +369 -0
- package/dist/services/demo-story-a-runner.js.map +1 -0
- package/dist/services/feature-flag-loader.d.ts +6 -0
- package/dist/services/feature-flag-loader.d.ts.map +1 -0
- package/dist/services/feature-flag-loader.js +54 -0
- package/dist/services/feature-flag-loader.js.map +1 -0
- package/dist/services/pain-flood-simulation-runner.d.ts +10 -0
- package/dist/services/pain-flood-simulation-runner.d.ts.map +1 -0
- package/dist/services/pain-flood-simulation-runner.js +289 -0
- package/dist/services/pain-flood-simulation-runner.js.map +1 -0
- package/dist/services/proven-channel-baseline-runner.d.ts +12 -0
- package/dist/services/proven-channel-baseline-runner.d.ts.map +1 -0
- package/dist/services/proven-channel-baseline-runner.js +114 -0
- package/dist/services/proven-channel-baseline-runner.js.map +1 -0
- package/dist/services/synthetic-baseline-runner.d.ts +8 -0
- package/dist/services/synthetic-baseline-runner.d.ts.map +1 -0
- package/dist/services/synthetic-baseline-runner.js +251 -0
- package/dist/services/synthetic-baseline-runner.js.map +1 -0
- package/package.json +35 -0
- package/src/commands/artifact.ts +82 -0
- package/src/commands/candidate.ts +1117 -0
- package/src/commands/central-sync.ts +44 -0
- package/src/commands/console.ts +121 -0
- package/src/commands/context.ts +72 -0
- package/src/commands/demo-story-a.ts +195 -0
- package/src/commands/diagnose.ts +452 -0
- package/src/commands/evolution-tasks-list.ts +44 -0
- package/src/commands/evolution-tasks-show.ts +60 -0
- package/src/commands/flow.ts +60 -0
- package/src/commands/health.ts +189 -0
- package/src/commands/history.ts +63 -0
- package/src/commands/legacy-cleanup.ts +206 -0
- package/src/commands/legacy-import.ts +104 -0
- package/src/commands/pain-record.ts +167 -0
- package/src/commands/proven-channel-baseline.ts +113 -0
- package/src/commands/remediation-output.ts +66 -0
- package/src/commands/run.ts +89 -0
- package/src/commands/runtime-activation.ts +176 -0
- package/src/commands/runtime-canary.ts +371 -0
- package/src/commands/runtime-diagnostics-export.ts +229 -0
- package/src/commands/runtime-features.ts +103 -0
- package/src/commands/runtime-gfi-snapshot.ts +135 -0
- package/src/commands/runtime-health-snapshot.ts +106 -0
- package/src/commands/runtime-internalization-enqueue-successors.ts +479 -0
- package/src/commands/runtime-internalization-integrity-repair.ts +69 -0
- package/src/commands/runtime-internalization-integrity.ts +63 -0
- package/src/commands/runtime-internalization-queue.ts +106 -0
- package/src/commands/runtime-internalization-run-once.ts +658 -0
- package/src/commands/runtime-internalization-wake-once.ts +87 -0
- package/src/commands/runtime-pain-flood-simulation.ts +121 -0
- package/src/commands/runtime-pruning.ts +438 -0
- package/src/commands/runtime-recovery.ts +107 -0
- package/src/commands/runtime-synthetic-baseline.ts +70 -0
- package/src/commands/runtime-uat.ts +339 -0
- package/src/commands/runtime.ts +281 -0
- package/src/commands/samples-list.ts +43 -0
- package/src/commands/samples-review.ts +32 -0
- package/src/commands/task.ts +130 -0
- package/src/commands/trace.ts +174 -0
- package/src/commands/trajectory.ts +64 -0
- package/src/index.ts +829 -0
- package/src/legacy/legacy-import.ts +179 -0
- package/src/legacy/session-history-import.ts +231 -0
- package/src/principle-tree-ledger-adapter.ts +13 -0
- package/src/resolve-workspace.ts +20 -0
- package/src/services/demo-story-a-runner.ts +472 -0
- package/src/services/feature-flag-loader.ts +73 -0
- package/src/services/pain-flood-simulation-runner.ts +354 -0
- package/src/services/proven-channel-baseline-runner.ts +150 -0
- package/src/services/synthetic-baseline-runner.ts +291 -0
- package/tests/commands/candidate-audit-repair.test.ts +338 -0
- package/tests/commands/candidate-intake.test.ts +589 -0
- package/tests/commands/candidate-internalization-backfill.test.ts +480 -0
- package/tests/commands/candidate-internalize.test.ts +272 -0
- package/tests/commands/candidate-route.test.ts +328 -0
- package/tests/commands/candidate-show.test.ts +95 -0
- package/tests/commands/cli-command-tree.test.ts +64 -0
- package/tests/commands/context.test.ts +114 -0
- package/tests/commands/demo-story-a.test.ts +255 -0
- package/tests/commands/diagnose.test.ts +792 -0
- package/tests/commands/health.test.ts +330 -0
- package/tests/commands/pain-record.test.ts +316 -0
- package/tests/commands/plugin-config-resolution-cutover.test.ts +220 -0
- package/tests/commands/proven-channel-baseline.test.ts +441 -0
- package/tests/commands/runtime-activation.test.ts +168 -0
- package/tests/commands/runtime-canary.test.ts +369 -0
- package/tests/commands/runtime-diagnostics-export.test.ts +170 -0
- package/tests/commands/runtime-features.test.ts +114 -0
- package/tests/commands/runtime-health-snapshot.test.ts +357 -0
- package/tests/commands/runtime-internalization-enqueue-successors.test.ts +803 -0
- package/tests/commands/runtime-internalization-integrity-repair.test.ts +169 -0
- package/tests/commands/runtime-internalization-integrity.test.ts +102 -0
- package/tests/commands/runtime-internalization-queue.test.ts +252 -0
- package/tests/commands/runtime-internalization-run-once.test.ts +1318 -0
- package/tests/commands/runtime-internalization-wake-once.test.ts +170 -0
- package/tests/commands/runtime-internalization.test.ts +52 -0
- package/tests/commands/runtime-pain-flood-simulation.test.ts +418 -0
- package/tests/commands/runtime-pruning.test.ts +693 -0
- package/tests/commands/runtime-recovery.test.ts +96 -0
- package/tests/commands/runtime-synthetic-baseline.test.ts +249 -0
- package/tests/commands/runtime-uat.test.ts +397 -0
- package/tests/commands/runtime.test.ts +262 -0
- package/tests/commands/trace.test.ts +314 -0
- package/tests/e2e/candidate-intake-e2e.test.ts +316 -0
- package/tests/services/feature-flag-loader.test.ts +207 -0
- package/tests/services/proven-channel-baseline-runner.test.ts +30 -0
- package/tsconfig.json +26 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
|
|
3
|
+
const mockRepair = vi.hoisted(() => vi.fn());
|
|
4
|
+
|
|
5
|
+
vi.mock('../../src/resolve-workspace.js', () => ({
|
|
6
|
+
resolveWorkspaceDir: vi.fn().mockReturnValue('/fake/workspace'),
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
vi.mock('@principles/core/runtime-v2', () => ({
|
|
10
|
+
InternalizationIntegrityRemediation: vi.fn().mockImplementation(function () {
|
|
11
|
+
return { repair: mockRepair };
|
|
12
|
+
}),
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
import { Command } from 'commander';
|
|
16
|
+
import { handleRuntimeInternalizationIntegrityRepair } from '../../src/commands/runtime-internalization-integrity-repair.js';
|
|
17
|
+
|
|
18
|
+
const WS = '/fake/workspace';
|
|
19
|
+
|
|
20
|
+
function makeResult(overrides: Partial<{ dryRun: boolean; repairedCount: number; skippedCount: number; actions: unknown[] }> = {}) {
|
|
21
|
+
const dryRun = overrides.dryRun ?? true;
|
|
22
|
+
return {
|
|
23
|
+
mode: dryRun ? 'dry_run' : 'confirm',
|
|
24
|
+
status: dryRun ? 'no_op' : (overrides.repairedCount ?? 0) > 0 ? 'changed' : 'no_op',
|
|
25
|
+
safeToConfirm: false,
|
|
26
|
+
dryRun,
|
|
27
|
+
repairedCount: overrides.repairedCount ?? 0,
|
|
28
|
+
skippedCount: overrides.skippedCount ?? 0,
|
|
29
|
+
actions: overrides.actions ?? [],
|
|
30
|
+
warnings: [],
|
|
31
|
+
generatedAt: new Date().toISOString(),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function createTestProgram(): Command {
|
|
36
|
+
const program = new Command();
|
|
37
|
+
program.exitOverride();
|
|
38
|
+
|
|
39
|
+
const internalizationCmd = program.command('internalization');
|
|
40
|
+
|
|
41
|
+
internalizationCmd
|
|
42
|
+
.command('integrity-repair')
|
|
43
|
+
.description('Repair broken internalization chain links (operator repair path)')
|
|
44
|
+
.option('-w, --workspace <path>', 'Workspace directory')
|
|
45
|
+
.option('--dry-run', 'Report only, no modifications')
|
|
46
|
+
.option('--confirm', 'Actually repair broken links')
|
|
47
|
+
.option('--json', 'Output raw JSON')
|
|
48
|
+
.action(async (opts) => {
|
|
49
|
+
await handleRuntimeInternalizationIntegrityRepair({ workspace: opts.workspace, confirm: opts.confirm, dryRun: opts.dryRun, json: opts.json });
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return program;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
describe('handleRuntimeInternalizationIntegrityRepair', () => {
|
|
56
|
+
let consoleLogSpy: ReturnType<typeof vi.spyOn>;
|
|
57
|
+
let consoleErrorSpy: ReturnType<typeof vi.spyOn>;
|
|
58
|
+
|
|
59
|
+
beforeEach(() => {
|
|
60
|
+
vi.clearAllMocks();
|
|
61
|
+
consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
62
|
+
consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('outputs JSON result on dry-run', async () => {
|
|
66
|
+
mockRepair.mockReturnValue(makeResult({ dryRun: true }));
|
|
67
|
+
|
|
68
|
+
await handleRuntimeInternalizationIntegrityRepair({ workspace: WS, dryRun: true, confirm: false, json: true });
|
|
69
|
+
|
|
70
|
+
const jsonOutput = JSON.parse(consoleLogSpy.mock.calls[0][0]);
|
|
71
|
+
expect(jsonOutput.dryRun).toBe(true);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('outputs JSON result on confirm', async () => {
|
|
75
|
+
mockRepair.mockReturnValue(makeResult({ dryRun: false, repairedCount: 1 }));
|
|
76
|
+
|
|
77
|
+
await handleRuntimeInternalizationIntegrityRepair({ workspace: WS, confirm: true, json: true });
|
|
78
|
+
|
|
79
|
+
const jsonOutput = JSON.parse(consoleLogSpy.mock.calls[0][0]);
|
|
80
|
+
expect(jsonOutput.dryRun).toBe(false);
|
|
81
|
+
expect(jsonOutput.repairedCount).toBe(1);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('outputs text format when --json not specified', async () => {
|
|
85
|
+
mockRepair.mockReturnValue(makeResult({ dryRun: true }));
|
|
86
|
+
|
|
87
|
+
await handleRuntimeInternalizationIntegrityRepair({ workspace: WS, dryRun: true, confirm: false, json: false });
|
|
88
|
+
|
|
89
|
+
const allOutput = consoleLogSpy.mock.calls.map(c => c.join(' ')).join('\n');
|
|
90
|
+
expect(allOutput).toContain('Integrity Repair');
|
|
91
|
+
expect(allOutput).toContain('DRY-RUN');
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('defaults to dry-run when --confirm not specified', async () => {
|
|
95
|
+
mockRepair.mockReturnValue(makeResult({ dryRun: true }));
|
|
96
|
+
|
|
97
|
+
await handleRuntimeInternalizationIntegrityRepair({ workspace: WS, json: true });
|
|
98
|
+
|
|
99
|
+
expect(mockRepair).toHaveBeenCalledWith({ dryRun: true });
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('enters confirm mode when only --confirm is passed', async () => {
|
|
103
|
+
mockRepair.mockReturnValue(makeResult({ dryRun: false }));
|
|
104
|
+
|
|
105
|
+
await handleRuntimeInternalizationIntegrityRepair({ workspace: WS, confirm: true, json: true });
|
|
106
|
+
|
|
107
|
+
expect(mockRepair).toHaveBeenCalledWith({ dryRun: false });
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('rejects --dry-run and --confirm together', async () => {
|
|
111
|
+
const exitSpy = vi.spyOn(process, 'exit').mockImplementation((code) => { throw new Error(`process.exit:${code}`); });
|
|
112
|
+
|
|
113
|
+
await expect(
|
|
114
|
+
handleRuntimeInternalizationIntegrityRepair({ workspace: WS, dryRun: true, confirm: true, json: true }),
|
|
115
|
+
).rejects.toThrow('process.exit:1');
|
|
116
|
+
|
|
117
|
+
exitSpy.mockRestore();
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
describe('Commander wiring for integrity-repair', () => {
|
|
122
|
+
let consoleLogSpy: ReturnType<typeof vi.spyOn>;
|
|
123
|
+
let consoleErrorSpy: ReturnType<typeof vi.spyOn>;
|
|
124
|
+
|
|
125
|
+
beforeEach(() => {
|
|
126
|
+
vi.clearAllMocks();
|
|
127
|
+
consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
128
|
+
consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('no flags → dry-run mode (confirm=undefined, dryRun=undefined)', async () => {
|
|
132
|
+
mockRepair.mockReturnValue(makeResult({ dryRun: true }));
|
|
133
|
+
|
|
134
|
+
const program = createTestProgram();
|
|
135
|
+
await program.parseAsync(['node', 'pd', 'internalization', 'integrity-repair', '--workspace', WS, '--json']);
|
|
136
|
+
|
|
137
|
+
expect(mockRepair).toHaveBeenCalledWith({ dryRun: true });
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('--confirm alone → confirm mode (not blocked by dryRun default)', async () => {
|
|
141
|
+
mockRepair.mockReturnValue(makeResult({ dryRun: false }));
|
|
142
|
+
|
|
143
|
+
const program = createTestProgram();
|
|
144
|
+
await program.parseAsync(['node', 'pd', 'internalization', 'integrity-repair', '--workspace', WS, '--confirm', '--json']);
|
|
145
|
+
|
|
146
|
+
expect(mockRepair).toHaveBeenCalledWith({ dryRun: false });
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('--dry-run alone → dry-run mode', async () => {
|
|
150
|
+
mockRepair.mockReturnValue(makeResult({ dryRun: true }));
|
|
151
|
+
|
|
152
|
+
const program = createTestProgram();
|
|
153
|
+
await program.parseAsync(['node', 'pd', 'internalization', 'integrity-repair', '--workspace', WS, '--dry-run', '--json']);
|
|
154
|
+
|
|
155
|
+
expect(mockRepair).toHaveBeenCalledWith({ dryRun: true });
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('--dry-run --confirm together → rejected', async () => {
|
|
159
|
+
mockRepair.mockReturnValue(makeResult({ dryRun: true }));
|
|
160
|
+
const exitSpy = vi.spyOn(process, 'exit').mockImplementation((code) => { throw new Error(`process.exit:${code}`); });
|
|
161
|
+
|
|
162
|
+
const program = createTestProgram();
|
|
163
|
+
await expect(
|
|
164
|
+
program.parseAsync(['node', 'pd', 'internalization', 'integrity-repair', '--workspace', WS, '--dry-run', '--confirm', '--json']),
|
|
165
|
+
).rejects.toThrow('process.exit:1');
|
|
166
|
+
|
|
167
|
+
exitSpy.mockRestore();
|
|
168
|
+
});
|
|
169
|
+
});
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
|
|
3
|
+
const mockCheck = vi.hoisted(() => vi.fn());
|
|
4
|
+
|
|
5
|
+
vi.mock('../../src/resolve-workspace.js', () => ({
|
|
6
|
+
resolveWorkspaceDir: vi.fn().mockReturnValue('/fake/workspace'),
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
vi.mock('@principles/core/runtime-v2', () => ({
|
|
10
|
+
InternalizationChainIntegrityReadModel: vi.fn().mockImplementation(function () {
|
|
11
|
+
return { check: mockCheck };
|
|
12
|
+
}),
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
import { handleRuntimeInternalizationIntegrity } from '../../src/commands/runtime-internalization-integrity.js';
|
|
16
|
+
|
|
17
|
+
const WS = '/fake/workspace';
|
|
18
|
+
|
|
19
|
+
function okResult() {
|
|
20
|
+
return {
|
|
21
|
+
overallStatus: 'ok' as const,
|
|
22
|
+
brokenLinks: [],
|
|
23
|
+
chainSummaries: {
|
|
24
|
+
totalCandidates: 1,
|
|
25
|
+
totalDreamerTasks: 1,
|
|
26
|
+
totalPhilosopherTasks: 0,
|
|
27
|
+
totalPIArtifacts: 1,
|
|
28
|
+
chainsWithBrokenLinks: 0,
|
|
29
|
+
},
|
|
30
|
+
generatedAt: new Date().toISOString(),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function degradedResult() {
|
|
35
|
+
return {
|
|
36
|
+
overallStatus: 'degraded' as const,
|
|
37
|
+
brokenLinks: [{
|
|
38
|
+
type: 'missing_dreamer_task',
|
|
39
|
+
severity: 'warning' as const,
|
|
40
|
+
candidateId: 'c1',
|
|
41
|
+
reason: 'No dreamer task for candidate c1',
|
|
42
|
+
recommendedAction: 'Seed a dreamer task.',
|
|
43
|
+
}],
|
|
44
|
+
chainSummaries: {
|
|
45
|
+
totalCandidates: 1,
|
|
46
|
+
totalDreamerTasks: 0,
|
|
47
|
+
totalPhilosopherTasks: 0,
|
|
48
|
+
totalPIArtifacts: 0,
|
|
49
|
+
chainsWithBrokenLinks: 1,
|
|
50
|
+
},
|
|
51
|
+
generatedAt: new Date().toISOString(),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
describe('handleRuntimeInternalizationIntegrity', () => {
|
|
56
|
+
let consoleLogSpy: ReturnType<typeof vi.spyOn>;
|
|
57
|
+
let consoleErrorSpy: ReturnType<typeof vi.spyOn>;
|
|
58
|
+
|
|
59
|
+
beforeEach(() => {
|
|
60
|
+
vi.clearAllMocks();
|
|
61
|
+
consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
62
|
+
consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('outputs ok JSON result', async () => {
|
|
66
|
+
mockCheck.mockReturnValue(okResult());
|
|
67
|
+
|
|
68
|
+
await handleRuntimeInternalizationIntegrity({ workspace: WS, json: true });
|
|
69
|
+
|
|
70
|
+
const jsonOutput = JSON.parse(consoleLogSpy.mock.calls[0][0]);
|
|
71
|
+
expect(jsonOutput.overallStatus).toBe('ok');
|
|
72
|
+
expect(jsonOutput.brokenLinks).toEqual([]);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('outputs degraded result with broken links', async () => {
|
|
76
|
+
mockCheck.mockReturnValue(degradedResult());
|
|
77
|
+
|
|
78
|
+
await handleRuntimeInternalizationIntegrity({ workspace: WS, json: true });
|
|
79
|
+
|
|
80
|
+
const jsonOutput = JSON.parse(consoleLogSpy.mock.calls[0][0]);
|
|
81
|
+
expect(jsonOutput.overallStatus).toBe('degraded');
|
|
82
|
+
expect(jsonOutput.brokenLinks.length).toBeGreaterThan(0);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('outputs text format when --json not specified', async () => {
|
|
86
|
+
mockCheck.mockReturnValue(okResult());
|
|
87
|
+
|
|
88
|
+
await handleRuntimeInternalizationIntegrity({ workspace: WS, json: false });
|
|
89
|
+
|
|
90
|
+
const allOutput = consoleLogSpy.mock.calls.map(c => c.join(' ')).join('\n');
|
|
91
|
+
expect(allOutput).toContain('Internalization Chain Integrity');
|
|
92
|
+
expect(allOutput).toContain('OK');
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('sets exit code on non-ok status', async () => {
|
|
96
|
+
mockCheck.mockReturnValue(degradedResult());
|
|
97
|
+
|
|
98
|
+
await handleRuntimeInternalizationIntegrity({ workspace: WS, json: true });
|
|
99
|
+
|
|
100
|
+
expect(process.exitCode).toBe(1);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* pd runtime internalization queue CLI unit tests.
|
|
3
|
+
*
|
|
4
|
+
* Tests the queue command handler: delegation to InternalizationQueueReadModel,
|
|
5
|
+
* JSON/text output formatting, and exit code behavior.
|
|
6
|
+
* The read model is mocked — its contract is tested in principles-core.
|
|
7
|
+
*/
|
|
8
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
9
|
+
|
|
10
|
+
const { mockGetSnapshot, mockClose } = vi.hoisted(() => ({
|
|
11
|
+
mockGetSnapshot: vi.fn(),
|
|
12
|
+
mockClose: vi.fn().mockResolvedValue(undefined),
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
vi.mock('../../src/resolve-workspace.js', () => ({
|
|
16
|
+
resolveWorkspaceDir: vi.fn().mockReturnValue('/fake/workspace'),
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
vi.mock('@principles/core/runtime-v2', () => ({
|
|
20
|
+
createInternalizationQueueReadModel: vi.fn().mockResolvedValue({
|
|
21
|
+
readModel: { getSnapshot: mockGetSnapshot, close: mockClose },
|
|
22
|
+
close: mockClose,
|
|
23
|
+
}),
|
|
24
|
+
}));
|
|
25
|
+
|
|
26
|
+
vi.mock('../../src/services/feature-flag-loader.js', () => ({
|
|
27
|
+
loadEffectiveFeatureFlags: vi.fn().mockReturnValue({
|
|
28
|
+
flags: {
|
|
29
|
+
prompt: { id: 'prompt', enabled: true, category: 'core' },
|
|
30
|
+
code_tool_hook: { id: 'code_tool_hook', enabled: true, category: 'core' },
|
|
31
|
+
defer_archive: { id: 'defer_archive', enabled: true, category: 'core' },
|
|
32
|
+
},
|
|
33
|
+
source: 'defaults',
|
|
34
|
+
configPath: '/fake/workspace/.pd/feature-flags.yaml',
|
|
35
|
+
warnings: [],
|
|
36
|
+
}),
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
import { handleRuntimeInternalizationQueue } from '../../src/commands/runtime-internalization-queue.js';
|
|
40
|
+
|
|
41
|
+
const WS = '/fake/workspace';
|
|
42
|
+
|
|
43
|
+
function emptySnapshot() {
|
|
44
|
+
return {
|
|
45
|
+
pendingCount: 0,
|
|
46
|
+
retryWaitCount: 0,
|
|
47
|
+
countsByTaskKind: {},
|
|
48
|
+
countsByChannel: {},
|
|
49
|
+
invalidMetadataCount: 0,
|
|
50
|
+
sampleInvalidTaskIds: [],
|
|
51
|
+
blockedSummary: { count: 0, samples: [] },
|
|
52
|
+
dependencyFailedSummary: { count: 0, samples: [] },
|
|
53
|
+
retryWaitPendingSummary: { count: 0, samples: [] },
|
|
54
|
+
leaseConflictSummary: { count: 0, samples: [] },
|
|
55
|
+
unresolvableSummary: { count: 0, samples: [] },
|
|
56
|
+
readyTasks: [],
|
|
57
|
+
noReadyTasks: { reason: 'no_candidates', inspectedCount: 0 },
|
|
58
|
+
suppressedTasks: [],
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
describe('handleRuntimeInternalizationQueue', () => {
|
|
63
|
+
let consoleLogSpy: ReturnType<typeof vi.spyOn>;
|
|
64
|
+
let consoleErrorSpy: ReturnType<typeof vi.spyOn>;
|
|
65
|
+
|
|
66
|
+
beforeEach(() => {
|
|
67
|
+
vi.clearAllMocks();
|
|
68
|
+
consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
69
|
+
consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
afterEach(() => {
|
|
73
|
+
consoleLogSpy.mockRestore();
|
|
74
|
+
consoleErrorSpy.mockRestore();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// ── Empty queue ─────────────────────────────────────────────────────────────
|
|
78
|
+
|
|
79
|
+
it('empty queue returns no_candidates reason in JSON', async () => {
|
|
80
|
+
mockGetSnapshot.mockResolvedValue(emptySnapshot());
|
|
81
|
+
|
|
82
|
+
await handleRuntimeInternalizationQueue({ workspace: WS, json: true });
|
|
83
|
+
|
|
84
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0]);
|
|
85
|
+
expect(output.noReadyTasks.reason).toBe('no_candidates');
|
|
86
|
+
expect(output.pendingCount).toBe(0);
|
|
87
|
+
expect(output.readyTasks).toEqual([]);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('empty queue text output is human-readable', async () => {
|
|
91
|
+
mockGetSnapshot.mockResolvedValue(emptySnapshot());
|
|
92
|
+
|
|
93
|
+
await handleRuntimeInternalizationQueue({ workspace: WS, json: false });
|
|
94
|
+
|
|
95
|
+
const text = consoleLogSpy.mock.calls.map(c => c.join(' ')).join('\n');
|
|
96
|
+
expect(text).toContain('no_ready_tasks');
|
|
97
|
+
expect(text).toContain('no_candidates');
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// ── Invalid metadata ────────────────────────────────────────────────────────
|
|
101
|
+
|
|
102
|
+
it('invalid metadata is counted and sampled in JSON', async () => {
|
|
103
|
+
mockGetSnapshot.mockResolvedValue({
|
|
104
|
+
...emptySnapshot(),
|
|
105
|
+
invalidMetadataCount: 2,
|
|
106
|
+
sampleInvalidTaskIds: ['task_bad_1', 'task_bad_2'],
|
|
107
|
+
noReadyTasks: { reason: 'all_hydration_failed', inspectedCount: 2 },
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
await handleRuntimeInternalizationQueue({ workspace: WS, json: true });
|
|
111
|
+
|
|
112
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0]);
|
|
113
|
+
expect(output.invalidMetadataCount).toBe(2);
|
|
114
|
+
expect(output.sampleInvalidTaskIds).toEqual(['task_bad_1', 'task_bad_2']);
|
|
115
|
+
expect(output.noReadyTasks.reason).toBe('all_hydration_failed');
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('invalid metadata appears in text output', async () => {
|
|
119
|
+
mockGetSnapshot.mockResolvedValue({
|
|
120
|
+
...emptySnapshot(),
|
|
121
|
+
invalidMetadataCount: 3,
|
|
122
|
+
sampleInvalidTaskIds: ['task_bad_1'],
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
await handleRuntimeInternalizationQueue({ workspace: WS, json: false });
|
|
126
|
+
|
|
127
|
+
const text = consoleLogSpy.mock.calls.map(c => c.join(' ')).join('\n');
|
|
128
|
+
expect(text).toContain('invalid_metadata');
|
|
129
|
+
expect(text).toContain('task_bad_1');
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// ── Blocked dependency ─────────────────────────────────────────────────────
|
|
133
|
+
|
|
134
|
+
it('blocked task surfaces blockedBy task IDs in JSON', async () => {
|
|
135
|
+
mockGetSnapshot.mockResolvedValue({
|
|
136
|
+
...emptySnapshot(),
|
|
137
|
+
pendingCount: 1,
|
|
138
|
+
blockedSummary: {
|
|
139
|
+
count: 1,
|
|
140
|
+
samples: [{ taskId: 'task_001', taskKind: 'dreamer', blockedBy: ['task_000'] }],
|
|
141
|
+
},
|
|
142
|
+
noReadyTasks: { reason: 'all_blocked', inspectedCount: 1 },
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
await handleRuntimeInternalizationQueue({ workspace: WS, json: true });
|
|
146
|
+
|
|
147
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0]);
|
|
148
|
+
expect(output.blockedSummary.count).toBe(1);
|
|
149
|
+
expect(output.blockedSummary.samples[0].blockedBy).toContain('task_000');
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('blocked task text output shows blockedBy', async () => {
|
|
153
|
+
mockGetSnapshot.mockResolvedValue({
|
|
154
|
+
...emptySnapshot(),
|
|
155
|
+
blockedSummary: {
|
|
156
|
+
count: 1,
|
|
157
|
+
samples: [{ taskId: 'task_001', taskKind: 'dreamer', blockedBy: ['task_000'] }],
|
|
158
|
+
},
|
|
159
|
+
noReadyTasks: { reason: 'all_blocked', inspectedCount: 1 },
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
await handleRuntimeInternalizationQueue({ workspace: WS, json: false });
|
|
163
|
+
|
|
164
|
+
const text = consoleLogSpy.mock.calls.map(c => c.join(' ')).join('\n');
|
|
165
|
+
expect(text).toContain('blocked');
|
|
166
|
+
expect(text).toContain('task_000');
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// ── Dependency failed ───────────────────────────────────────────────────────
|
|
170
|
+
|
|
171
|
+
it('dependency_failed surfaces failedDependencies in JSON', async () => {
|
|
172
|
+
mockGetSnapshot.mockResolvedValue({
|
|
173
|
+
...emptySnapshot(),
|
|
174
|
+
dependencyFailedSummary: {
|
|
175
|
+
count: 1,
|
|
176
|
+
samples: [{ taskId: 'task_002', taskKind: 'philosopher', failedDependencies: ['task_001'] }],
|
|
177
|
+
},
|
|
178
|
+
noReadyTasks: { reason: 'all_dependency_failed', inspectedCount: 1 },
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
await handleRuntimeInternalizationQueue({ workspace: WS, json: true });
|
|
182
|
+
|
|
183
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0]);
|
|
184
|
+
expect(output.dependencyFailedSummary.count).toBe(1);
|
|
185
|
+
expect(output.dependencyFailedSummary.samples[0].failedDependencies).toContain('task_001');
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('dependency_failed text output shows failed deps', async () => {
|
|
189
|
+
mockGetSnapshot.mockResolvedValue({
|
|
190
|
+
...emptySnapshot(),
|
|
191
|
+
dependencyFailedSummary: {
|
|
192
|
+
count: 1,
|
|
193
|
+
samples: [{ taskId: 'task_002', taskKind: 'philosopher', failedDependencies: ['task_001'] }],
|
|
194
|
+
},
|
|
195
|
+
noReadyTasks: { reason: 'all_dependency_failed', inspectedCount: 1 },
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
await handleRuntimeInternalizationQueue({ workspace: WS, json: false });
|
|
199
|
+
|
|
200
|
+
const text = consoleLogSpy.mock.calls.map(c => c.join(' ')).join('\n');
|
|
201
|
+
expect(text).toContain('dependency_failed');
|
|
202
|
+
expect(text).toContain('task_001');
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
// ── Ready tasks ─────────────────────────────────────────────────────────────
|
|
206
|
+
|
|
207
|
+
it('ready task appears in readyTasks array', async () => {
|
|
208
|
+
mockGetSnapshot.mockResolvedValue({
|
|
209
|
+
...emptySnapshot(),
|
|
210
|
+
pendingCount: 1,
|
|
211
|
+
readyTasks: [{ taskId: 'task_003', taskKind: 'scribe', channel: 'prompt' }],
|
|
212
|
+
noReadyTasks: null,
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
await handleRuntimeInternalizationQueue({ workspace: WS, json: true });
|
|
216
|
+
|
|
217
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0]);
|
|
218
|
+
expect(output.readyTasks).toContainEqual({ taskId: 'task_003', taskKind: 'scribe', channel: 'prompt' });
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it('ready task text output shows ready count', async () => {
|
|
222
|
+
mockGetSnapshot.mockResolvedValue({
|
|
223
|
+
...emptySnapshot(),
|
|
224
|
+
readyTasks: [{ taskId: 'task_003', taskKind: 'scribe', channel: 'prompt' }],
|
|
225
|
+
noReadyTasks: null,
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
await handleRuntimeInternalizationQueue({ workspace: WS, json: false });
|
|
229
|
+
|
|
230
|
+
const text = consoleLogSpy.mock.calls.map(c => c.join(' ')).join('\n');
|
|
231
|
+
expect(text).toContain('ready:');
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// ── Counts by kind / channel ──────────────────────────────────────────────
|
|
235
|
+
|
|
236
|
+
it('countsByTaskKind and countsByChannel are included in JSON', async () => {
|
|
237
|
+
mockGetSnapshot.mockResolvedValue({
|
|
238
|
+
...emptySnapshot(),
|
|
239
|
+
pendingCount: 2,
|
|
240
|
+
retryWaitCount: 1,
|
|
241
|
+
countsByTaskKind: { dreamer: 2, scribe: 1 },
|
|
242
|
+
countsByChannel: { prompt: 3 },
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
await handleRuntimeInternalizationQueue({ workspace: WS, json: true });
|
|
246
|
+
|
|
247
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0]);
|
|
248
|
+
expect(output.countsByTaskKind.dreamer).toBe(2);
|
|
249
|
+
expect(output.countsByTaskKind.scribe).toBe(1);
|
|
250
|
+
expect(output.countsByChannel.prompt).toBe(3);
|
|
251
|
+
});
|
|
252
|
+
});
|