@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,168 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
|
|
3
|
+
const mockGetArtifactById = vi.fn();
|
|
4
|
+
const mockClose = vi.fn().mockResolvedValue(undefined);
|
|
5
|
+
|
|
6
|
+
vi.mock('../../src/resolve-workspace.js', () => ({
|
|
7
|
+
resolveWorkspaceDir: vi.fn().mockReturnValue('/fake/workspace'),
|
|
8
|
+
}));
|
|
9
|
+
|
|
10
|
+
vi.mock('@principles/core/runtime-v2', async (importOriginal) => {
|
|
11
|
+
const original = await importOriginal() as Record<string, unknown>;
|
|
12
|
+
return {
|
|
13
|
+
...original,
|
|
14
|
+
RuntimeStateManager: vi.fn().mockImplementation(function () {
|
|
15
|
+
return {
|
|
16
|
+
initialize: vi.fn().mockResolvedValue(undefined),
|
|
17
|
+
close: mockClose,
|
|
18
|
+
piArtifactStore: {
|
|
19
|
+
getArtifactById: mockGetArtifactById,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}),
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
import { handleRuntimeActivationDispatch } from '../../src/commands/runtime-activation.js';
|
|
27
|
+
|
|
28
|
+
const WS = '/fake/workspace';
|
|
29
|
+
|
|
30
|
+
function makeArtifact(overrides: Record<string, unknown> = {}) {
|
|
31
|
+
return {
|
|
32
|
+
artifactId: 'art-001',
|
|
33
|
+
artifactKind: 'principle',
|
|
34
|
+
sourceTaskId: 'task-001',
|
|
35
|
+
sourcePrincipleId: 'P_001',
|
|
36
|
+
lineageArtifactIds: [],
|
|
37
|
+
validationStatus: 'validated',
|
|
38
|
+
contentJson: JSON.stringify({ principleId: 'P_001', text: 'Test', review: { decision: 'approve_rollout' } }),
|
|
39
|
+
createdAt: '2026-01-01T00:00:00.000Z',
|
|
40
|
+
updatedAt: '2026-01-01T00:00:00.000Z',
|
|
41
|
+
...overrides,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
describe('handleRuntimeActivationDispatch', () => {
|
|
46
|
+
let consoleLogSpy: ReturnType<typeof vi.spyOn>;
|
|
47
|
+
let consoleErrorSpy: ReturnType<typeof vi.spyOn>;
|
|
48
|
+
|
|
49
|
+
beforeEach(() => {
|
|
50
|
+
vi.clearAllMocks();
|
|
51
|
+
consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
52
|
+
consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
53
|
+
mockGetArtifactById.mockResolvedValue(makeArtifact());
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
afterEach(() => {
|
|
57
|
+
consoleLogSpy.mockRestore();
|
|
58
|
+
consoleErrorSpy.mockRestore();
|
|
59
|
+
process.exitCode = 0;
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('JSON output contains activationId, decision, reason, targetRef', async () => {
|
|
63
|
+
await handleRuntimeActivationDispatch({
|
|
64
|
+
workspace: WS,
|
|
65
|
+
artifactId: 'art-001',
|
|
66
|
+
channel: 'prompt',
|
|
67
|
+
json: true,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0]);
|
|
71
|
+
expect(output).toHaveProperty('decision');
|
|
72
|
+
expect(output).toHaveProperty('activationId');
|
|
73
|
+
expect(output).toHaveProperty('action');
|
|
74
|
+
expect(output).toHaveProperty('targetRef');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('dry-run outputs would_activate', async () => {
|
|
78
|
+
await handleRuntimeActivationDispatch({
|
|
79
|
+
workspace: WS,
|
|
80
|
+
artifactId: 'art-001',
|
|
81
|
+
channel: 'prompt',
|
|
82
|
+
dryRun: true,
|
|
83
|
+
json: true,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0]);
|
|
87
|
+
expect(output.decision).toBe('would_activate');
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('confirm outputs activated', async () => {
|
|
91
|
+
await handleRuntimeActivationDispatch({
|
|
92
|
+
workspace: WS,
|
|
93
|
+
artifactId: 'art-001',
|
|
94
|
+
channel: 'prompt',
|
|
95
|
+
confirm: true,
|
|
96
|
+
json: true,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0]);
|
|
100
|
+
expect(output.decision).toBe('activated');
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('high-risk channel returns refused', async () => {
|
|
104
|
+
await handleRuntimeActivationDispatch({
|
|
105
|
+
workspace: WS,
|
|
106
|
+
artifactId: 'art-001',
|
|
107
|
+
channel: 'code_tool_hook',
|
|
108
|
+
json: true,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0]);
|
|
112
|
+
expect(output.decision).toBe('refused');
|
|
113
|
+
expect(process.exitCode).toBe(1);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('missing artifact returns invalid_artifact', async () => {
|
|
117
|
+
mockGetArtifactById.mockResolvedValue(null);
|
|
118
|
+
|
|
119
|
+
await handleRuntimeActivationDispatch({
|
|
120
|
+
workspace: WS,
|
|
121
|
+
artifactId: 'nonexistent',
|
|
122
|
+
channel: 'prompt',
|
|
123
|
+
json: true,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0]);
|
|
127
|
+
expect(output.decision).toBe('invalid_artifact');
|
|
128
|
+
expect(process.exitCode).toBe(1);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('--dry-run and --confirm are mutually exclusive', async () => {
|
|
132
|
+
await handleRuntimeActivationDispatch({
|
|
133
|
+
workspace: WS,
|
|
134
|
+
artifactId: 'art-001',
|
|
135
|
+
channel: 'prompt',
|
|
136
|
+
dryRun: true,
|
|
137
|
+
confirm: true,
|
|
138
|
+
json: true,
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith('Error: --dry-run and --confirm are mutually exclusive');
|
|
142
|
+
expect(process.exitCode).toBe(1);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('default is dry-run (would_activate)', async () => {
|
|
146
|
+
await handleRuntimeActivationDispatch({
|
|
147
|
+
workspace: WS,
|
|
148
|
+
artifactId: 'art-001',
|
|
149
|
+
channel: 'prompt',
|
|
150
|
+
json: true,
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0]);
|
|
154
|
+
expect(output.decision).toBe('would_activate');
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('text output is human-readable', async () => {
|
|
158
|
+
await handleRuntimeActivationDispatch({
|
|
159
|
+
workspace: WS,
|
|
160
|
+
artifactId: 'art-001',
|
|
161
|
+
channel: 'prompt',
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
const text = consoleLogSpy.mock.calls[0][0];
|
|
165
|
+
expect(text).toContain('Activation:');
|
|
166
|
+
expect(text).toContain('would_activate');
|
|
167
|
+
});
|
|
168
|
+
});
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
mockSchemaCheck,
|
|
5
|
+
mockHealthSnapshot,
|
|
6
|
+
mockHealthClose,
|
|
7
|
+
mockOrphanCandidates,
|
|
8
|
+
mockQueueSnapshot,
|
|
9
|
+
mockQueueClose,
|
|
10
|
+
mockAuditConsistency,
|
|
11
|
+
mockBuildGfiSnapshot,
|
|
12
|
+
mockClassifyGfiHealth,
|
|
13
|
+
} = vi.hoisted(() => ({
|
|
14
|
+
mockSchemaCheck: vi.fn(),
|
|
15
|
+
mockHealthSnapshot: vi.fn(),
|
|
16
|
+
mockHealthClose: vi.fn().mockResolvedValue(undefined),
|
|
17
|
+
mockOrphanCandidates: vi.fn(),
|
|
18
|
+
mockQueueSnapshot: vi.fn(),
|
|
19
|
+
mockQueueClose: vi.fn().mockResolvedValue(undefined),
|
|
20
|
+
mockAuditConsistency: vi.fn(),
|
|
21
|
+
mockBuildGfiSnapshot: vi.fn(),
|
|
22
|
+
mockClassifyGfiHealth: vi.fn(),
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
vi.mock('../../src/resolve-workspace.js', () => ({
|
|
26
|
+
resolveWorkspaceDir: vi.fn().mockReturnValue('/fake/workspace'),
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
vi.mock('@principles/core/runtime-v2', () => ({
|
|
30
|
+
SchemaConformanceReadModel: vi.fn().mockImplementation(function () {
|
|
31
|
+
return { check: mockSchemaCheck };
|
|
32
|
+
}),
|
|
33
|
+
OperatorHealthReadModel: vi.fn().mockImplementation(function () {
|
|
34
|
+
return { getSnapshot: mockHealthSnapshot, close: mockHealthClose };
|
|
35
|
+
}),
|
|
36
|
+
PruningReadModel: vi.fn().mockImplementation(function () {
|
|
37
|
+
return { getOrphanDerivedCandidates: mockOrphanCandidates };
|
|
38
|
+
}),
|
|
39
|
+
createInternalizationQueueReadModel: vi.fn().mockResolvedValue({
|
|
40
|
+
readModel: { getSnapshot: mockQueueSnapshot },
|
|
41
|
+
close: mockQueueClose,
|
|
42
|
+
}),
|
|
43
|
+
auditCandidateLedgerConsistency: mockAuditConsistency,
|
|
44
|
+
buildGfiWorkspaceSnapshot: mockBuildGfiSnapshot,
|
|
45
|
+
classifyGfiWorkspaceHealth: mockClassifyGfiHealth,
|
|
46
|
+
}));
|
|
47
|
+
|
|
48
|
+
vi.mock('../../src/services/feature-flag-loader.js', () => ({
|
|
49
|
+
loadEffectiveFeatureFlags: vi.fn().mockReturnValue({
|
|
50
|
+
source: 'defaults',
|
|
51
|
+
configPath: '/fake/workspace/.pd/feature-flags.yaml',
|
|
52
|
+
flags: {
|
|
53
|
+
prompt: { id: 'prompt', category: 'core', enabled: true, since: '2026-05-24' },
|
|
54
|
+
code_tool_hook: { id: 'code_tool_hook', category: 'core', enabled: true, since: '2026-05-24' },
|
|
55
|
+
defer_archive: { id: 'defer_archive', category: 'core', enabled: true, since: '2026-05-24' },
|
|
56
|
+
gfi: { id: 'gfi', category: 'quiet', enabled: true, since: '2026-05-24' },
|
|
57
|
+
},
|
|
58
|
+
warnings: [],
|
|
59
|
+
}),
|
|
60
|
+
}));
|
|
61
|
+
|
|
62
|
+
import { runCanaryChecks } from '../../src/commands/runtime-canary.js';
|
|
63
|
+
import { loadEffectiveFeatureFlags } from '../../src/services/feature-flag-loader.js';
|
|
64
|
+
|
|
65
|
+
const WS = '/fake/workspace';
|
|
66
|
+
|
|
67
|
+
function healthySchemaResult() {
|
|
68
|
+
return {
|
|
69
|
+
overallStatus: 'ok' as const,
|
|
70
|
+
checkedDatabasePath: `${WS}/.pd/state.db`,
|
|
71
|
+
tables: {
|
|
72
|
+
tasks: { exists: true, missingColumns: [] },
|
|
73
|
+
runs: { exists: true, missingColumns: [] },
|
|
74
|
+
artifacts: { exists: true, missingColumns: [] },
|
|
75
|
+
commits: { exists: true, missingColumns: [] },
|
|
76
|
+
principle_candidates: { exists: true, missingColumns: [] },
|
|
77
|
+
pi_artifacts: { exists: true, missingColumns: [] },
|
|
78
|
+
},
|
|
79
|
+
indexes: { missingIndexes: [] },
|
|
80
|
+
migrationsNeeded: [],
|
|
81
|
+
generatedAt: new Date().toISOString(),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function healthyHealthSnapshot() {
|
|
86
|
+
return {
|
|
87
|
+
generatedAt: new Date().toISOString(),
|
|
88
|
+
workspace: WS,
|
|
89
|
+
painChain: { lastSuccessfulChain: null, failureCategory: null },
|
|
90
|
+
candidateLedger: { auditStatus: 'ok' as const, orphanCandidateCount: 0, missingLedgerCount: 0 },
|
|
91
|
+
pruning: { watchCount: 0, reviewCount: 0, orphanDerivedCandidateCount: 0 },
|
|
92
|
+
gfi: { active: null, staleSessionCount: 0, totalSessionCount: 0, activeSessionCount: 0, generatedAt: new Date().toISOString() },
|
|
93
|
+
overallStatus: 'healthy' as const,
|
|
94
|
+
recommendedActions: [],
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function healthyQueueSnapshot() {
|
|
99
|
+
return {
|
|
100
|
+
pendingCount: 0, retryWaitCount: 0, countsByTaskKind: {}, countsByChannel: {},
|
|
101
|
+
invalidMetadataCount: 0, sampleInvalidTaskIds: [],
|
|
102
|
+
blockedSummary: { count: 0, samples: [] }, dependencyFailedSummary: { count: 0, samples: [] },
|
|
103
|
+
leaseConflictSummary: { count: 0, samples: [], sampleTaskIds: [] },
|
|
104
|
+
retryWaitPendingSummary: { count: 0, samples: [] },
|
|
105
|
+
unresolvableSummary: { count: 0, samples: [] },
|
|
106
|
+
readyTasks: [], noReadyTasks: null, suppressedTasks: [],
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function healthyGfiSnapshot() {
|
|
111
|
+
return {
|
|
112
|
+
active: null, staleSessionCount: 0, totalSessionCount: 0, activeSessionCount: 0, generatedAt: new Date().toISOString(),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
describe('runCanaryChecks', () => {
|
|
117
|
+
beforeEach(() => {
|
|
118
|
+
vi.clearAllMocks();
|
|
119
|
+
mockSchemaCheck.mockReturnValue(healthySchemaResult());
|
|
120
|
+
mockHealthSnapshot.mockResolvedValue(healthyHealthSnapshot());
|
|
121
|
+
mockHealthClose.mockResolvedValue(undefined);
|
|
122
|
+
mockOrphanCandidates.mockReturnValue({ candidates: [], dbReadable: true });
|
|
123
|
+
mockQueueSnapshot.mockResolvedValue(healthyQueueSnapshot());
|
|
124
|
+
mockQueueClose.mockResolvedValue(undefined);
|
|
125
|
+
mockAuditConsistency.mockResolvedValue({ status: 'ok', consumedCount: 0, orphanCandidateCount: 0, missingLedgerCount: 0 });
|
|
126
|
+
mockBuildGfiSnapshot.mockReturnValue(healthyGfiSnapshot());
|
|
127
|
+
mockClassifyGfiHealth.mockReturnValue({ status: 'healthy', reason: '0 active, 0 stale sessions', staleGfiDegradedThreshold: 40 });
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('returns healthy when all checks are healthy', async () => {
|
|
131
|
+
const result = await runCanaryChecks(WS);
|
|
132
|
+
|
|
133
|
+
expect(result.overallStatus).toBe('healthy');
|
|
134
|
+
expect(result.checks.length).toBeGreaterThanOrEqual(5);
|
|
135
|
+
expect(result.checks.every(c => c.status === 'healthy')).toBe(true);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('returns degraded when a single check is degraded', async () => {
|
|
139
|
+
mockSchemaCheck.mockReturnValue({
|
|
140
|
+
...healthySchemaResult(),
|
|
141
|
+
overallStatus: 'degraded',
|
|
142
|
+
migrationsNeeded: ['add_trigger_pattern'],
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
const result = await runCanaryChecks(WS);
|
|
146
|
+
|
|
147
|
+
expect(result.overallStatus).toBe('degraded');
|
|
148
|
+
const schemaCheck = result.checks.find(c => c.name === 'schema_conformance');
|
|
149
|
+
expect(schemaCheck?.status).toBe('degraded');
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('continues other checks when one throws', async () => {
|
|
153
|
+
mockAuditConsistency.mockRejectedValue(new Error('DB error'));
|
|
154
|
+
|
|
155
|
+
const result = await runCanaryChecks(WS);
|
|
156
|
+
|
|
157
|
+
expect(result.overallStatus).not.toBe('healthy');
|
|
158
|
+
const auditCheck = result.checks.find(c => c.name === 'candidate_audit');
|
|
159
|
+
expect(auditCheck?.status).toBe('error');
|
|
160
|
+
expect(auditCheck?.error).toBeTruthy();
|
|
161
|
+
const schemaCheck = result.checks.find(c => c.name === 'schema_conformance');
|
|
162
|
+
expect(schemaCheck?.status).toBe('healthy');
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('produces stable JSON-serializable output', async () => {
|
|
166
|
+
const result = await runCanaryChecks(WS);
|
|
167
|
+
|
|
168
|
+
const json = JSON.stringify(result);
|
|
169
|
+
const parsed = JSON.parse(json);
|
|
170
|
+
|
|
171
|
+
expect(parsed.overallStatus).toBe('healthy');
|
|
172
|
+
expect(parsed.checks).toBeInstanceOf(Array);
|
|
173
|
+
expect(parsed.recommendedNextActions).toBeInstanceOf(Array);
|
|
174
|
+
expect(parsed.generatedAt).toBeTruthy();
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('includes recommendedNextActions for schema mismatch', async () => {
|
|
178
|
+
mockSchemaCheck.mockReturnValue({
|
|
179
|
+
...healthySchemaResult(),
|
|
180
|
+
overallStatus: 'degraded',
|
|
181
|
+
migrationsNeeded: ['add_trigger_pattern'],
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
const result = await runCanaryChecks(WS);
|
|
185
|
+
|
|
186
|
+
expect(result.recommendedNextActions.length).toBeGreaterThan(0);
|
|
187
|
+
expect(result.recommendedNextActions.some(a => a.includes('migrate schema'))).toBe(true);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('includes recommendedNextActions for pruning orphans', async () => {
|
|
191
|
+
mockOrphanCandidates.mockReturnValue({
|
|
192
|
+
candidates: [{ candidateId: 'c1', principleId: 'p1', reason: 'not found' }],
|
|
193
|
+
dbReadable: true,
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
const result = await runCanaryChecks(WS);
|
|
197
|
+
|
|
198
|
+
expect(result.overallStatus).toBe('degraded');
|
|
199
|
+
expect(result.recommendedNextActions.some(a => a.includes('pruning orphans') || a.includes('dry-run'))).toBe(true);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it('uses createInternalizationQueueReadModel with readonly: true (no RuntimeStateManager)', async () => {
|
|
203
|
+
const fs = await import('fs');
|
|
204
|
+
const src = fs.readFileSync(require.resolve('../../src/commands/runtime-canary.ts'), 'utf-8');
|
|
205
|
+
expect(src).not.toContain('RuntimeStateManager');
|
|
206
|
+
expect(src).toContain('createInternalizationQueueReadModel');
|
|
207
|
+
expect(src).toMatch(/createInternalizationQueueReadModel\(\{[^}]*readonly:\s*true/);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('calls queue close once on healthy path', async () => {
|
|
211
|
+
await runCanaryChecks(WS);
|
|
212
|
+
expect(mockQueueClose).toHaveBeenCalledTimes(1);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('includes nextReadyTaskKind and nextReadyTaskId in top-level internalizationQueueSummary when queue has ready tasks', async () => {
|
|
216
|
+
mockQueueSnapshot.mockResolvedValue({
|
|
217
|
+
pendingCount: 2,
|
|
218
|
+
retryWaitCount: 1,
|
|
219
|
+
countsByTaskKind: { dreamer: 3 },
|
|
220
|
+
countsByChannel: {},
|
|
221
|
+
invalidMetadataCount: 0,
|
|
222
|
+
sampleInvalidTaskIds: [],
|
|
223
|
+
blockedSummary: { count: 0, samples: [] },
|
|
224
|
+
dependencyFailedSummary: { count: 0, samples: [] },
|
|
225
|
+
leaseConflictSummary: { count: 0, samples: [], sampleTaskIds: [] },
|
|
226
|
+
retryWaitPendingSummary: { count: 0, samples: [] },
|
|
227
|
+
unresolvableSummary: { count: 0, samples: [] },
|
|
228
|
+
readyTasks: [
|
|
229
|
+
{ taskId: 'task-abc-123', taskKind: 'dreamer', channel: 'pi' },
|
|
230
|
+
{ taskId: 'task-def-456', taskKind: 'philosopher', channel: 'pi' },
|
|
231
|
+
],
|
|
232
|
+
noReadyTasks: null,
|
|
233
|
+
suppressedTasks: [],
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
const result = await runCanaryChecks(WS);
|
|
237
|
+
|
|
238
|
+
expect(result.internalizationQueueSummary).toBeDefined();
|
|
239
|
+
expect(result.internalizationQueueSummary?.readyCount).toBe(2);
|
|
240
|
+
expect(result.internalizationQueueSummary?.retryWaitCount).toBe(1);
|
|
241
|
+
expect(result.internalizationQueueSummary?.pendingCount).toBe(2);
|
|
242
|
+
expect(result.internalizationQueueSummary?.nextReadyTaskKind).toBe('dreamer');
|
|
243
|
+
expect(result.internalizationQueueSummary?.nextReadyTaskId).toBe('task-abc-123');
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it('includes noReadyReason in internalizationQueueSummary when no ready tasks exist', async () => {
|
|
247
|
+
mockQueueSnapshot.mockResolvedValue({
|
|
248
|
+
pendingCount: 0,
|
|
249
|
+
retryWaitCount: 0,
|
|
250
|
+
countsByTaskKind: {},
|
|
251
|
+
countsByChannel: {},
|
|
252
|
+
invalidMetadataCount: 5,
|
|
253
|
+
sampleInvalidTaskIds: ['bad-1', 'bad-2'],
|
|
254
|
+
blockedSummary: { count: 0, samples: [] },
|
|
255
|
+
dependencyFailedSummary: { count: 0, samples: [] },
|
|
256
|
+
leaseConflictSummary: { count: 0, samples: [], sampleTaskIds: [] },
|
|
257
|
+
retryWaitPendingSummary: { count: 0, samples: [] },
|
|
258
|
+
unresolvableSummary: { count: 0, samples: [] },
|
|
259
|
+
readyTasks: [],
|
|
260
|
+
noReadyTasks: { reason: 'all_hydration_failed', inspectedCount: 5 },
|
|
261
|
+
suppressedTasks: [],
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
const result = await runCanaryChecks(WS);
|
|
265
|
+
|
|
266
|
+
expect(result.internalizationQueueSummary).toBeDefined();
|
|
267
|
+
expect(result.internalizationQueueSummary?.readyCount).toBe(0);
|
|
268
|
+
expect(result.internalizationQueueSummary?.retryWaitCount).toBe(0);
|
|
269
|
+
expect(result.internalizationQueueSummary?.pendingCount).toBe(0);
|
|
270
|
+
expect(result.internalizationQueueSummary?.nextReadyTaskKind).toBeNull();
|
|
271
|
+
expect(result.internalizationQueueSummary?.nextReadyTaskId).toBeNull();
|
|
272
|
+
expect(result.internalizationQueueSummary?.noReadyReason).toBe('all_hydration_failed');
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
describe('GFI config warning degraded status', () => {
|
|
276
|
+
it('returns healthy when GFI disabled with no warnings', async () => {
|
|
277
|
+
vi.mocked(loadEffectiveFeatureFlags).mockReturnValue({
|
|
278
|
+
source: 'defaults',
|
|
279
|
+
configPath: `${WS}/.pd/feature-flags.yaml`,
|
|
280
|
+
flags: {
|
|
281
|
+
gfi: { id: 'gfi', category: 'quiet', enabled: false, since: '2026-05-24' },
|
|
282
|
+
},
|
|
283
|
+
warnings: [],
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
const result = await runCanaryChecks(WS);
|
|
287
|
+
const gfiCheck = result.checks.find(c => c.name === 'gfi_snapshot');
|
|
288
|
+
|
|
289
|
+
expect(gfiCheck?.status).toBe('healthy');
|
|
290
|
+
expect(gfiCheck?.summary).toContain('disabled');
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
it('returns degraded when GFI disabled but config has warnings (malformed YAML)', async () => {
|
|
294
|
+
vi.mocked(loadEffectiveFeatureFlags).mockReturnValue({
|
|
295
|
+
source: 'defaults',
|
|
296
|
+
configPath: `${WS}/.pd/feature-flags.yaml`,
|
|
297
|
+
flags: {
|
|
298
|
+
gfi: { id: 'gfi', category: 'quiet', enabled: false, since: '2026-05-24' },
|
|
299
|
+
},
|
|
300
|
+
warnings: ['feature-flags.yaml: YAML parse error, using defaults'],
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
const result = await runCanaryChecks(WS);
|
|
304
|
+
const gfiCheck = result.checks.find(c => c.name === 'gfi_snapshot');
|
|
305
|
+
|
|
306
|
+
expect(gfiCheck?.status).toBe('degraded');
|
|
307
|
+
expect(gfiCheck?.summary).toContain('warnings');
|
|
308
|
+
expect(gfiCheck?.details).toBeDefined();
|
|
309
|
+
expect(result.recommendedNextActions.some(a => a.includes('feature-flags.yaml'))).toBe(true);
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it('returns degraded when GFI disabled but config has malformed override warning', async () => {
|
|
313
|
+
vi.mocked(loadEffectiveFeatureFlags).mockReturnValue({
|
|
314
|
+
source: 'workspace_file',
|
|
315
|
+
configPath: `${WS}/.pd/feature-flags.yaml`,
|
|
316
|
+
flags: {
|
|
317
|
+
gfi: { id: 'gfi', category: 'quiet', enabled: false, since: '2026-05-24' },
|
|
318
|
+
},
|
|
319
|
+
warnings: ["flag 'gfi': malformed override kept default (enabled must be boolean)"],
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
const result = await runCanaryChecks(WS);
|
|
323
|
+
const gfiCheck = result.checks.find(c => c.name === 'gfi_snapshot');
|
|
324
|
+
|
|
325
|
+
expect(gfiCheck?.status).toBe('degraded');
|
|
326
|
+
expect(result.recommendedNextActions.some(a => a.includes('feature-flags.yaml') || a.includes('pd runtime features'))).toBe(true);
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
it('runs GFI snapshot when flag enabled with no warnings', async () => {
|
|
330
|
+
vi.mocked(loadEffectiveFeatureFlags).mockReturnValue({
|
|
331
|
+
source: 'workspace_file',
|
|
332
|
+
configPath: `${WS}/.pd/feature-flags.yaml`,
|
|
333
|
+
flags: {
|
|
334
|
+
gfi: { id: 'gfi', category: 'quiet', enabled: true, since: '2026-05-24' },
|
|
335
|
+
},
|
|
336
|
+
warnings: [],
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
const result = await runCanaryChecks(WS);
|
|
340
|
+
const gfiCheck = result.checks.find(c => c.name === 'gfi_snapshot');
|
|
341
|
+
|
|
342
|
+
expect(gfiCheck?.status).toBe('healthy');
|
|
343
|
+
expect(gfiCheck?.summary).toContain('OK');
|
|
344
|
+
expect(mockBuildGfiSnapshot).toHaveBeenCalled();
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
it('recommends session lifecycle review for GFI session issues (not config)', async () => {
|
|
348
|
+
vi.mocked(loadEffectiveFeatureFlags).mockReturnValue({
|
|
349
|
+
source: 'defaults',
|
|
350
|
+
configPath: `${WS}/.pd/feature-flags.yaml`,
|
|
351
|
+
flags: {
|
|
352
|
+
gfi: { id: 'gfi', category: 'quiet', enabled: true, since: '2026-05-24' },
|
|
353
|
+
},
|
|
354
|
+
warnings: [],
|
|
355
|
+
});
|
|
356
|
+
mockClassifyGfiHealth.mockReturnValue({
|
|
357
|
+
status: 'degraded',
|
|
358
|
+
reason: '5 stale sessions found',
|
|
359
|
+
staleGfiDegradedThreshold: 40,
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
const result = await runCanaryChecks(WS);
|
|
363
|
+
const gfiCheck = result.checks.find(c => c.name === 'gfi_snapshot');
|
|
364
|
+
|
|
365
|
+
expect(gfiCheck?.status).toBe('degraded');
|
|
366
|
+
expect(result.recommendedNextActions.some(a => a.includes('GFI sessions') || a.includes('session lifecycle'))).toBe(true);
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
});
|