@principles/pd-cli 1.149.0 → 1.149.2
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/dist/commands/evolution-tasks-list.d.ts.map +1 -1
- package/dist/commands/evolution-tasks-list.js +15 -12
- package/dist/commands/evolution-tasks-list.js.map +1 -1
- package/dist/commands/evolution-tasks-show.d.ts.map +1 -1
- package/dist/commands/evolution-tasks-show.js +7 -4
- package/dist/commands/evolution-tasks-show.js.map +1 -1
- package/dist/commands/pain-evidence.d.ts.map +1 -1
- package/dist/commands/pain-evidence.js +3 -1
- package/dist/commands/pain-evidence.js.map +1 -1
- package/dist/commands/pain-record.d.ts +6 -0
- package/dist/commands/pain-record.d.ts.map +1 -1
- package/dist/commands/pain-record.js +78 -29
- package/dist/commands/pain-record.js.map +1 -1
- package/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
- package/dist/commands/runtime-internalization-run-once.js +29 -2
- package/dist/commands/runtime-internalization-run-once.js.map +1 -1
- package/dist/commands/samples-list.d.ts.map +1 -1
- package/dist/commands/samples-list.js +5 -9
- package/dist/commands/samples-list.js.map +1 -1
- package/dist/commands/samples-review.d.ts.map +1 -1
- package/dist/commands/samples-review.js +5 -1
- package/dist/commands/samples-review.js.map +1 -1
- package/dist/commands/trajectory-db-unavailable.d.ts +11 -0
- package/dist/commands/trajectory-db-unavailable.d.ts.map +1 -0
- package/dist/commands/trajectory-db-unavailable.js +15 -0
- package/dist/commands/trajectory-db-unavailable.js.map +1 -0
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/services/rulehost-pipeline-runner.d.ts.map +1 -1
- package/dist/services/rulehost-pipeline-runner.js +18 -3
- package/dist/services/rulehost-pipeline-runner.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/evolution-tasks-list.ts +18 -14
- package/src/commands/evolution-tasks-show.ts +7 -5
- package/src/commands/pain-evidence.ts +3 -1
- package/src/commands/pain-record.ts +82 -29
- package/src/commands/runtime-internalization-run-once.ts +30 -3
- package/src/commands/samples-list.ts +5 -9
- package/src/commands/samples-review.ts +5 -1
- package/src/commands/trajectory-db-unavailable.ts +19 -0
- package/src/index.ts +12 -3
- package/src/services/rulehost-pipeline-runner.ts +18 -2
- package/tests/commands/evolution-tasks-list.test.ts +41 -0
- package/tests/commands/evolution-tasks-show.test.ts +46 -0
- package/tests/commands/pain-record-session-parser.test.ts +25 -1
- package/tests/commands/pain-record.test.ts +68 -9
- package/tests/commands/runtime-activation.test.ts +1 -1
- package/tests/commands/runtime-internalization-run-once.test.ts +8 -1
- package/tests/commands/samples-list.test.ts +43 -0
- package/tests/commands/samples-review.test.ts +41 -0
|
@@ -86,6 +86,7 @@ vi.mock('@principles/core/runtime-v2', () => ({
|
|
|
86
86
|
ArtificerRunner: vi.fn().mockImplementation(function () {
|
|
87
87
|
return { run: mockRun };
|
|
88
88
|
}),
|
|
89
|
+
buildArtificerHostSemanticContext: (registry) => ({ hostKinds: [], tools: registry.hostMappings() }),
|
|
89
90
|
EvaluatorRunner: vi.fn().mockImplementation(function () {
|
|
90
91
|
return { run: mockRun };
|
|
91
92
|
}),
|
|
@@ -197,6 +198,10 @@ const { mockCreateEvaluatorRuntimeContext, mockCreateRolloutGovernanceDeps, mock
|
|
|
197
198
|
const mockCreateEvaluatorRuntimeContext = vi.fn().mockReturnValue({
|
|
198
199
|
ok: true,
|
|
199
200
|
gateDeps: { evaluateInSandbox: vi.fn() },
|
|
201
|
+
// PRI-741: the context resolution also carries the single registry
|
|
202
|
+
// snapshot the parity projection derives from.
|
|
203
|
+
registry: { resolve: vi.fn(), hostMappings: vi.fn().mockReturnValue([{ rawToolName: 'write', canonicalKind: 'write' }]) },
|
|
204
|
+
hostKinds: ['openclaw'],
|
|
200
205
|
});
|
|
201
206
|
const mockCreateRolloutGovernanceDeps = vi.fn().mockReturnValue({
|
|
202
207
|
dispatchActivation: vi.fn(),
|
|
@@ -204,7 +209,9 @@ const { mockCreateEvaluatorRuntimeContext, mockCreateRolloutGovernanceDeps, mock
|
|
|
204
209
|
});
|
|
205
210
|
const mockResolveWorkspaceHostToolSemantics = vi.fn().mockReturnValue({
|
|
206
211
|
ok: true,
|
|
207
|
-
|
|
212
|
+
// PRI-741: the projection reads the host layer via hostMappings() — the
|
|
213
|
+
// mock registry carries it like a real buildToolSemanticRegistry product.
|
|
214
|
+
registry: { resolve: vi.fn(), hostMappings: vi.fn().mockReturnValue([{ rawToolName: 'write', canonicalKind: 'write' }]) },
|
|
208
215
|
hostKinds: ['openclaw'],
|
|
209
216
|
});
|
|
210
217
|
return { mockCreateEvaluatorRuntimeContext, mockCreateRolloutGovernanceDeps, mockResolveWorkspaceHostToolSemantics };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* pd samples list command tests — PRI-753 (Trajectory Reader Reality Fix).
|
|
3
|
+
*
|
|
4
|
+
* A missing workspace trajectory database is an operator-visible failure with
|
|
5
|
+
* a next action (cli-6), never a silent "no samples" answer (rc-9).
|
|
6
|
+
*/
|
|
7
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
8
|
+
|
|
9
|
+
vi.mock('../../src/resolve-workspace.js', () => ({
|
|
10
|
+
resolveWorkspaceDir: vi.fn().mockReturnValue('/tmp/pri753-missing-workspace'),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
import { handleSamplesList } from '../../src/commands/samples-list.js';
|
|
14
|
+
|
|
15
|
+
describe('handleSamplesList — unavailable database (PRI-753)', () => {
|
|
16
|
+
let errorSpy: ReturnType<typeof vi.spyOn>;
|
|
17
|
+
let exitSpy: ReturnType<typeof vi.spyOn>;
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
21
|
+
exitSpy = vi.spyOn(process, 'exit').mockImplementation(((code: number) => {
|
|
22
|
+
throw new Error(`process.exit:${String(code)}`);
|
|
23
|
+
}) as never);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
vi.restoreAllMocks();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('fails loud with reason and next action when trajectory.db is missing', async () => {
|
|
31
|
+
await expect(handleSamplesList({})).rejects.toThrow('process.exit:1');
|
|
32
|
+
|
|
33
|
+
const stderrText = errorSpy.mock.calls.map((call) => String(call[0])).join('');
|
|
34
|
+
expect(stderrText).toContain('Trajectory database unavailable');
|
|
35
|
+
expect(stderrText).toContain(joinPath('.state', 'trajectory.db'));
|
|
36
|
+
expect(stderrText).toContain('pd runtime init --confirm');
|
|
37
|
+
expect(exitSpy).toHaveBeenCalledWith(1);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
function joinPath(a: string, b: string): string {
|
|
42
|
+
return `${a}${process.platform === 'win32' ? '\\' : '/'}${b}`;
|
|
43
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* pd samples review command tests — PRI-753 (Trajectory Reader Reality Fix).
|
|
3
|
+
*
|
|
4
|
+
* A missing workspace trajectory database is an operator-visible failure with
|
|
5
|
+
* a next action (cli-6); failure exits before any mutation (cli-2/cli-5).
|
|
6
|
+
*/
|
|
7
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
8
|
+
|
|
9
|
+
vi.mock('../../src/resolve-workspace.js', () => ({
|
|
10
|
+
resolveWorkspaceDir: vi.fn().mockReturnValue('/tmp/pri753-missing-workspace'),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
import { handleSamplesReview } from '../../src/commands/samples-review.js';
|
|
14
|
+
|
|
15
|
+
describe('handleSamplesReview — unavailable database (PRI-753)', () => {
|
|
16
|
+
let errorSpy: ReturnType<typeof vi.spyOn>;
|
|
17
|
+
let exitSpy: ReturnType<typeof vi.spyOn>;
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
21
|
+
exitSpy = vi.spyOn(process, 'exit').mockImplementation(((code: number) => {
|
|
22
|
+
throw new Error(`process.exit:${String(code)}`);
|
|
23
|
+
}) as never);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
vi.restoreAllMocks();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('fails loud with reason and next action when trajectory.db is missing', async () => {
|
|
31
|
+
await expect(handleSamplesReview({ sampleId: 'sample-001', decision: 'approve' })).rejects.toThrow(
|
|
32
|
+
'process.exit:1'
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const stderrText = errorSpy.mock.calls.map((call) => String(call[0])).join('');
|
|
36
|
+
expect(stderrText).toContain('Trajectory database unavailable');
|
|
37
|
+
expect(stderrText).toContain('trajectory.db');
|
|
38
|
+
expect(stderrText).toContain('pd runtime init --confirm');
|
|
39
|
+
expect(exitSpy).toHaveBeenCalledWith(1);
|
|
40
|
+
});
|
|
41
|
+
});
|