@principles/pd-cli 1.93.0 → 1.94.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.
@@ -57,11 +57,17 @@ vi.mock('@principles/core/runtime-v2', () => {
57
57
  SqliteSourceTraceLocator: vi.fn().mockImplementation(function () { return {}; }),
58
58
  StoreEventEmitter: vi.fn().mockImplementation(function () { return {}; }),
59
59
  storeEmitter: { emitTelemetry: vi.fn() },
60
- DiagnosticianRunner: vi.fn().mockImplementation(function () { return {}; }),
61
- PassThroughValidator: vi.fn().mockImplementation(function () { return {}; }),
62
- DefaultDiagnosticianValidator: vi.fn().mockImplementation(function () { return {}; }),
60
+ SplitDiagnosticianRunner: vi.fn().mockImplementation(function () { return {}; }),
61
+ DiagRootCauseRunner: vi.fn().mockImplementation(function () { return {}; }),
62
+ DiagDistillerRunner: vi.fn().mockImplementation(function () { return {}; }),
63
+ DiagRouterRunner: vi.fn().mockImplementation(function () { return {}; }),
64
+ DefaultDiagRootCauseValidator: vi.fn().mockImplementation(function () { return {}; }),
65
+ DefaultDiagDistillerValidator: vi.fn().mockImplementation(function () { return {}; }),
66
+ DisabledDiagnosticianRunner: vi.fn().mockImplementation(function () { return {}; }),
63
67
  TestDoubleRuntimeAdapter: vi.fn().mockImplementation(function () { return {}; }),
64
68
  OpenClawCliRuntimeAdapter: vi.fn().mockImplementation(function () { return {}; }),
69
+ PiAiRuntimeAdapter: vi.fn().mockImplementation(function () { return {}; }),
70
+ SPLIT_PIPELINE_TOTAL_TIMEOUT_MS: 300000,
65
71
  PDRuntimeError: class PDRuntimeError extends Error {
66
72
  constructor(public category: string, message: string) {
67
73
  super(message);
@@ -78,8 +84,12 @@ vi.mock('@principles/core/runtime-v2', () => {
78
84
  agentId: 'main',
79
85
  }),
80
86
  isRuntimeConfigError: vi.fn().mockReturnValue(false),
81
- isFeatureEnabled: vi.fn().mockReturnValue(false),
87
+ isFeatureEnabled: vi.fn().mockReturnValue(true),
82
88
  resolveOutputLanguage: vi.fn().mockReturnValue({ outputLanguage: 'zh-CN' }),
89
+ validatePdConfig: vi.fn().mockReturnValue({ valid: true, errors: [] }),
90
+ computeEffectivePdConfig: vi.fn().mockReturnValue({ config: {}, source: 'defaults', warnings: [] }),
91
+ computeFeatureFlagsFromConfig: vi.fn().mockReturnValue({}),
92
+ redactPdConfig: vi.fn().mockImplementation((c) => c),
83
93
  run: vi.fn().mockResolvedValue({
84
94
  status: 'succeeded',
85
95
  taskId: 'test-task-1',
@@ -89,11 +89,17 @@ vi.mock('@principles/core/runtime-v2', () => {
89
89
  SqliteSourceTraceLocator: vi.fn().mockImplementation(function () { return {}; }),
90
90
  StoreEventEmitter: vi.fn().mockImplementation(function () { return {}; }),
91
91
  storeEmitter: { emitTelemetry: vi.fn() },
92
- DiagnosticianRunner: vi.fn().mockImplementation(function () { return {}; }),
93
- DefaultDiagnosticianValidator: vi.fn().mockImplementation(function () { return {}; }),
92
+ SplitDiagnosticianRunner: vi.fn().mockImplementation(function () { return {}; }),
93
+ DiagRootCauseRunner: vi.fn().mockImplementation(function () { return {}; }),
94
+ DiagDistillerRunner: vi.fn().mockImplementation(function () { return {}; }),
95
+ DiagRouterRunner: vi.fn().mockImplementation(function () { return {}; }),
96
+ DefaultDiagRootCauseValidator: vi.fn().mockImplementation(function () { return {}; }),
97
+ DefaultDiagDistillerValidator: vi.fn().mockImplementation(function () { return {}; }),
98
+ DisabledDiagnosticianRunner: vi.fn().mockImplementation(function () { return {}; }),
94
99
  TestDoubleRuntimeAdapter: vi.fn().mockImplementation(function () { return {}; }),
95
100
  OpenClawCliRuntimeAdapter: vi.fn().mockImplementation(function () { return {}; }),
96
101
  PiAiRuntimeAdapter: vi.fn().mockImplementation(function () { return {}; }),
102
+ SPLIT_PIPELINE_TOTAL_TIMEOUT_MS: 300000,
97
103
  PDRuntimeError: class PDRuntimeError extends Error {
98
104
  constructor(public category: string, message: string) {
99
105
  super(message);
@@ -103,7 +109,12 @@ vi.mock('@principles/core/runtime-v2', () => {
103
109
  CandidateIntakeService: MockCandidateIntakeService,
104
110
  resolveRuntimeConfig: mockResolveRuntimeConfig,
105
111
  isRuntimeConfigError: vi.fn().mockReturnValue(false),
112
+ isFeatureEnabled: vi.fn().mockReturnValue(true),
106
113
  resolveOutputLanguage: vi.fn().mockReturnValue({ outputLanguage: 'zh-CN' }),
114
+ validatePdConfig: vi.fn().mockReturnValue({ valid: true, errors: [] }),
115
+ computeEffectivePdConfig: vi.fn().mockReturnValue({ config: {}, source: 'defaults', warnings: [] }),
116
+ computeFeatureFlagsFromConfig: vi.fn().mockReturnValue({}),
117
+ redactPdConfig: vi.fn().mockImplementation((c) => c),
107
118
  run: mockRun,
108
119
  status: vi.fn(),
109
120
  };
@@ -149,12 +149,33 @@ describe('E2E: pd candidate intake flow', () => {
149
149
  }
150
150
  }
151
151
 
152
- function readLedgerFile(workspace: string): any[] {
153
- const ledgerPath = join(workspace, '.pd', 'principle-tree-ledger.json');
152
+ function readLedgerFile(workspace: string): Array<{ id: string; sourceRef: string; status: string; evaluability: string }> {
153
+ const ledgerPath = join(workspace, '.state', 'principle_training_state.json');
154
154
  if (!existsSync(ledgerPath)) return [];
155
155
  const content = readFileSync(ledgerPath, 'utf-8');
156
- const data = JSON.parse(content);
157
- return data.principles || [];
156
+ const data: unknown = JSON.parse(content);
157
+ if (typeof data !== 'object' || data === null) return [];
158
+ const tree = (data as Record<string, unknown>)._tree ?? (data as Record<string, unknown>).tree ?? {};
159
+ if (typeof tree !== 'object' || tree === null) return [];
160
+ const principles = (tree as Record<string, unknown>).principles ?? {};
161
+ if (typeof principles !== 'object' || principles === null) return [];
162
+ return Object.values(principles).map((p: unknown) => {
163
+ if (typeof p !== 'object' || p === null) {
164
+ return { id: '', sourceRef: 'candidate://', status: '', evaluability: '' };
165
+ }
166
+ const pObj = p as Record<string, unknown>;
167
+ const painIds = pObj.derivedFromPainIds;
168
+ const candidateId = Array.isArray(painIds) && typeof painIds[0] === 'string' ? painIds[0] : '';
169
+ const id = typeof pObj.id === 'string' ? pObj.id : '';
170
+ const rawStatus = typeof pObj.status === 'string' ? pObj.status : '';
171
+ const evaluability = typeof pObj.evaluability === 'string' ? pObj.evaluability : '';
172
+ return {
173
+ id,
174
+ sourceRef: `candidate://${candidateId}`,
175
+ status: rawStatus === 'candidate' ? 'probation' : rawStatus,
176
+ evaluability,
177
+ };
178
+ });
158
179
  }
159
180
 
160
181
  it('Test 1 (Happy path E2E): pending candidate → intake → consumed → ledgerEntryId in output', () => {