create-principles-disciple 1.147.19 → 1.148.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/_release/product-identity.json +1 -1
  2. package/codex-adapter/package.json +1 -1
  3. package/console/dist/server/config/pd-config-store.js +6 -6
  4. package/console/dist/server/index.d.ts +20 -0
  5. package/console/dist/server/index.js +104 -84
  6. package/console/dist/server/models/ApprovalsConsoleModel.d.ts +1 -1
  7. package/console/dist/server/models/ApprovalsConsoleModel.js +5 -2
  8. package/console/dist/server/models/GovernanceExperienceCollector.js +2 -1
  9. package/console/dist/server/models/GovernanceProjectionCollector.js +11 -10
  10. package/console/dist/server/models/IntentPageModel.js +1 -1
  11. package/console/dist/server/models/OwnerDecisionViewModel.d.ts +3 -2
  12. package/console/dist/server/models/OwnerDecisionViewModel.js +8 -7
  13. package/console/dist/server/routes/activations.js +5 -5
  14. package/console/dist/server/routes/approvals-grouped.js +2 -2
  15. package/console/dist/server/routes/approvals.js +7 -7
  16. package/console/dist/server/routes/config.d.ts +4 -4
  17. package/console/dist/server/routes/config.js +5 -5
  18. package/console/dist/server/routes/evidence-chain.d.ts +1 -1
  19. package/console/dist/server/routes/evidence-outcomes.d.ts +2 -2
  20. package/console/dist/server/routes/examiner.d.ts +12 -12
  21. package/console/dist/server/routes/examiner.js +2 -2
  22. package/console/dist/server/routes/failed-tasks.d.ts +4 -4
  23. package/console/dist/server/routes/failed-tasks.js +10 -10
  24. package/console/dist/server/routes/governance.d.ts +1 -1
  25. package/console/dist/server/routes/governance.js +3 -3
  26. package/console/dist/server/routes/intent-decisions.d.ts +6 -6
  27. package/console/dist/server/routes/intent-decisions.js +13 -13
  28. package/console/dist/server/routes/intent.js +6 -6
  29. package/console/dist/server/routes/lifecycle.js +3 -3
  30. package/console/dist/server/routes/onboarding.d.ts +1 -1
  31. package/console/dist/server/routes/onboarding.js +4 -4
  32. package/console/dist/server/routes/owner-decision.d.ts +5 -5
  33. package/console/dist/server/routes/owner-decision.js +3 -3
  34. package/console/dist/server/routes/owner-decisions.d.ts +3 -3
  35. package/console/dist/server/routes/owner-decisions.js +3 -3
  36. package/console/dist/server/routes/owner-identity.d.ts +1 -1
  37. package/console/dist/server/routes/owner-identity.js +1 -1
  38. package/console/dist/server/routes/principles.d.ts +4 -3
  39. package/console/dist/server/routes/principles.js +5 -4
  40. package/console/dist/server/routes/receipts.d.ts +2 -2
  41. package/console/dist/server/routes/receipts.js +4 -4
  42. package/console/dist/server.d.ts +2 -1
  43. package/console/dist/server.js +9 -1
  44. package/console/dist/shared/prompt-injection-contract.d.ts +1 -1
  45. package/console/dist/web/assets/app.js +23 -23
  46. package/core/dist/index.d.ts +1 -1
  47. package/core/dist/index.d.ts.map +1 -1
  48. package/core/dist/index.js +3 -2
  49. package/core/dist/index.js.map +1 -1
  50. package/core/dist/runtime/activation/approval-review-guard.d.ts +2 -2
  51. package/core/dist/runtime/activation/approval-review-guard.d.ts.map +1 -1
  52. package/core/dist/runtime/activation/approval-review-guard.js +6 -1
  53. package/core/dist/runtime/activation/approval-review-guard.js.map +1 -1
  54. package/core/dist/runtime/activation/prompt-budget-policy.d.ts +9 -1
  55. package/core/dist/runtime/activation/prompt-budget-policy.d.ts.map +1 -1
  56. package/core/dist/runtime/activation/prompt-budget-policy.js +9 -1
  57. package/core/dist/runtime/activation/prompt-budget-policy.js.map +1 -1
  58. package/core/dist/runtime/activation/recovery-control-surfaces.d.ts +1 -1
  59. package/core/dist/runtime/activation/recovery-control-surfaces.js +2 -2
  60. package/core/dist/runtime/activation/recovery-control-surfaces.js.map +1 -1
  61. package/core/dist/runtime/adapter/output-schema-registry.d.ts +1 -1
  62. package/core/dist/runtime/adapter/output-schema-registry.d.ts.map +1 -1
  63. package/core/dist/runtime/adapter/output-schema-registry.js +23 -18
  64. package/core/dist/runtime/adapter/output-schema-registry.js.map +1 -1
  65. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js +1 -1
  66. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js.map +1 -1
  67. package/core/dist/runtime/adapter/schema-json-converter.d.ts +1 -1
  68. package/core/dist/runtime/adapter/schema-json-converter.js +1 -1
  69. package/core/dist/runtime/adapter/tools/diagnostician-tool.js +1 -1
  70. package/core/dist/runtime/adapter/tools/diagnostician-tool.js.map +1 -1
  71. package/core/dist/runtime/diagnostician-output.d.ts +2 -2
  72. package/core/dist/runtime/diagnostician-output.d.ts.map +1 -1
  73. package/core/dist/runtime/diagnostician-output.js +1 -1
  74. package/core/dist/runtime/diagnostician-output.js.map +1 -1
  75. package/core/dist/runtime/feature-flags/plugin-surface-registry.d.ts.map +1 -1
  76. package/core/dist/runtime/feature-flags/plugin-surface-registry.js +10 -0
  77. package/core/dist/runtime/feature-flags/plugin-surface-registry.js.map +1 -1
  78. package/core/dist/runtime/governance-experience-contract.d.ts +4 -4
  79. package/core/dist/runtime/governance-experience-contract.d.ts.map +1 -1
  80. package/core/dist/runtime/governance-experience-contract.js +3 -2
  81. package/core/dist/runtime/governance-experience-contract.js.map +1 -1
  82. package/core/dist/runtime/governance-experience.d.ts.map +1 -1
  83. package/core/dist/runtime/governance-experience.js +2 -1
  84. package/core/dist/runtime/governance-experience.js.map +1 -1
  85. package/core/dist/runtime/governance-projection-contract.d.ts +14 -14
  86. package/core/dist/runtime/governance-projection-contract.d.ts.map +1 -1
  87. package/core/dist/runtime/governance-projection-contract.js +4 -3
  88. package/core/dist/runtime/governance-projection-contract.js.map +1 -1
  89. package/core/dist/runtime/governance-projection.d.ts.map +1 -1
  90. package/core/dist/runtime/governance-projection.js +2 -1
  91. package/core/dist/runtime/governance-projection.js.map +1 -1
  92. package/core/dist/runtime/index.d.ts +2 -2
  93. package/core/dist/runtime/index.d.ts.map +1 -1
  94. package/core/dist/runtime/index.js +2 -3
  95. package/core/dist/runtime/index.js.map +1 -1
  96. package/core/dist/runtime/internalization/artificer-runner.d.ts +1 -1
  97. package/core/dist/runtime/internalization/artificer-runner.d.ts.map +1 -1
  98. package/core/dist/runtime/internalization/artificer-runner.js +3 -2
  99. package/core/dist/runtime/internalization/artificer-runner.js.map +1 -1
  100. package/core/dist/runtime/internalization/diag-distiller-runner.d.ts.map +1 -1
  101. package/core/dist/runtime/internalization/diag-distiller-runner.js +3 -2
  102. package/core/dist/runtime/internalization/diag-distiller-runner.js.map +1 -1
  103. package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts.map +1 -1
  104. package/core/dist/runtime/internalization/diag-rootcause-runner.js +3 -2
  105. package/core/dist/runtime/internalization/diag-rootcause-runner.js.map +1 -1
  106. package/core/dist/runtime/internalization/diag-router-runner.d.ts.map +1 -1
  107. package/core/dist/runtime/internalization/diag-router-runner.js +4 -3
  108. package/core/dist/runtime/internalization/diag-router-runner.js.map +1 -1
  109. package/core/dist/runtime/internalization/dreamer-runner.d.ts.map +1 -1
  110. package/core/dist/runtime/internalization/dreamer-runner.js +3 -2
  111. package/core/dist/runtime/internalization/dreamer-runner.js.map +1 -1
  112. package/core/dist/runtime/internalization/evaluator-runner.d.ts.map +1 -1
  113. package/core/dist/runtime/internalization/evaluator-runner.js +3 -2
  114. package/core/dist/runtime/internalization/evaluator-runner.js.map +1 -1
  115. package/core/dist/runtime/internalization/philosopher-runner.d.ts +1 -1
  116. package/core/dist/runtime/internalization/philosopher-runner.d.ts.map +1 -1
  117. package/core/dist/runtime/internalization/philosopher-runner.js +3 -2
  118. package/core/dist/runtime/internalization/philosopher-runner.js.map +1 -1
  119. package/core/dist/runtime/internalization/rollout-reviewer-output.d.ts +1 -1
  120. package/core/dist/runtime/internalization/rollout-reviewer-output.js +1 -1
  121. package/core/dist/runtime/internalization/rollout-reviewer-output.js.map +1 -1
  122. package/core/dist/runtime/internalization/rollout-reviewer-runner.d.ts.map +1 -1
  123. package/core/dist/runtime/internalization/rollout-reviewer-runner.js +3 -2
  124. package/core/dist/runtime/internalization/rollout-reviewer-runner.js.map +1 -1
  125. package/core/dist/runtime/internalization/router-context-evidence.d.ts +1 -1
  126. package/core/dist/runtime/internalization/router-context-evidence.d.ts.map +1 -1
  127. package/core/dist/runtime/internalization/router-context-evidence.js +4 -1
  128. package/core/dist/runtime/internalization/router-context-evidence.js.map +1 -1
  129. package/core/dist/runtime/internalization/scribe-runner.d.ts +1 -1
  130. package/core/dist/runtime/internalization/scribe-runner.d.ts.map +1 -1
  131. package/core/dist/runtime/internalization/scribe-runner.js +3 -2
  132. package/core/dist/runtime/internalization/scribe-runner.js.map +1 -1
  133. package/core/dist/runtime/learning-lab/actor-action-output.d.ts +1 -1
  134. package/core/dist/runtime/learning-lab/actor-action-output.d.ts.map +1 -1
  135. package/core/dist/runtime/learning-lab/actor-action-output.js +1 -1
  136. package/core/dist/runtime/learning-lab/actor-action-output.js.map +1 -1
  137. package/core/dist/runtime/observer/correction-observer.d.ts.map +1 -1
  138. package/core/dist/runtime/observer/correction-observer.js +3 -2
  139. package/core/dist/runtime/observer/correction-observer.js.map +1 -1
  140. package/core/dist/runtime/owner-decision/owner-decision-view-contract.d.ts +1 -1
  141. package/core/dist/runtime/owner-decision/owner-decision-view-contract.d.ts.map +1 -1
  142. package/core/dist/runtime/owner-decision/owner-decision-view-contract.js +2 -1
  143. package/core/dist/runtime/owner-decision/owner-decision-view-contract.js.map +1 -1
  144. package/core/dist/runtime/owner-decision/owner-decision-view.d.ts +8 -8
  145. package/core/dist/runtime/owner-decision/owner-decision-view.d.ts.map +1 -1
  146. package/core/dist/runtime/owner-decision/owner-decision-view.js +10 -9
  147. package/core/dist/runtime/owner-decision/owner-decision-view.js.map +1 -1
  148. package/core/dist/runtime/principle-reuse/reuse-evaluation-output.d.ts +1 -1
  149. package/core/dist/runtime/principle-reuse/reuse-evaluation-output.d.ts.map +1 -1
  150. package/core/dist/runtime/principle-reuse/reuse-evaluation-output.js +1 -1
  151. package/core/dist/runtime/principle-reuse/reuse-evaluation-output.js.map +1 -1
  152. package/core/dist/runtime/principle-reuse/reuse-evaluation-runner.d.ts.map +1 -1
  153. package/core/dist/runtime/principle-reuse/reuse-evaluation-runner.js +5 -4
  154. package/core/dist/runtime/principle-reuse/reuse-evaluation-runner.js.map +1 -1
  155. package/core/dist/runtime/schema-version.d.ts +30 -14
  156. package/core/dist/runtime/schema-version.d.ts.map +1 -1
  157. package/core/dist/runtime/schema-version.js +33 -13
  158. package/core/dist/runtime/schema-version.js.map +1 -1
  159. package/core/package.json +1 -1
  160. package/host-runtime/dist/prompt-injection-budget-observation.js +10 -8
  161. package/host-runtime/dist/signal-classifier.d.ts +3 -1
  162. package/host-runtime/dist/signal-classifier.js +5 -3
  163. package/host-runtime/package.json +1 -1
  164. package/package.json +3 -3
  165. package/pd-mcp-server/dist/version.d.ts +1 -1
  166. package/pd-mcp-server/dist/version.js +1 -1
  167. package/pd-mcp-server/package.json +1 -1
  168. package/plugin/dist/bundle.js +441 -441
  169. package/plugin/dist/core/event-log.d.ts +5 -0
  170. package/plugin/dist/governance-audit.js +2 -2
  171. package/plugin/dist/openclaw.plugin.json +1 -1
  172. package/plugin/dist/rulehost-evidence.js +9 -9
  173. package/plugin/openclaw.plugin.json +1 -1
  174. package/plugin/package.json +1 -1
  175. package/release-manager/package.json +1 -1
  176. package/workbuddy-adapter/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "productVersion": "2.8.4",
4
- "sourceCommit": "e501b96540b127d14b8f5562c7ba1d3ed8bb9788"
4
+ "sourceCommit": "1dd3b8e871ed88bac3cf2cc3a7dcaea9838271ba"
5
5
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/codex-adapter",
3
- "version": "0.8.4",
3
+ "version": "0.8.5",
4
4
  "description": "Codex CLI host adapter for Principles Disciple — implements HostAdapter interface for OpenAI Codex CLI's stdin/stdout JSON hook model (ADR-0020).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1120,7 +1120,7 @@ export function createRuntimeProfile(workspaceDir, profileId, payload) {
1120
1120
  statusCode: 400,
1121
1121
  error: 'bad_request',
1122
1122
  message: `Runtime profile '${profileId}' already exists. Use PATCH to update it.`,
1123
- nextAction: `Use PATCH /api/v1/config/profiles/${encodeURIComponent(profileId)} to update the existing profile`,
1123
+ nextAction: `Use PATCH /api/config/profiles/${encodeURIComponent(profileId)} to update the existing profile`,
1124
1124
  };
1125
1125
  }
1126
1126
  // 5. Extract only known fields from payload (prevents unknown field persistence)
@@ -1210,7 +1210,7 @@ export function updateRuntimeProfile(workspaceDir, profileId, patch) {
1210
1210
  statusCode: 404,
1211
1211
  error: 'not_found',
1212
1212
  message: `Runtime profile '${profileId}' does not exist. Available profiles: ${Object.keys(effective.config.runtimeProfiles).join(', ')}`,
1213
- nextAction: 'Use POST /api/v1/config/profiles to create a new profile',
1213
+ nextAction: 'Use POST /api/config/profiles to create a new profile',
1214
1214
  };
1215
1215
  }
1216
1216
  const existingProfile = effective.config.runtimeProfiles[profileId];
@@ -1227,7 +1227,7 @@ export function updateRuntimeProfile(workspaceDir, profileId, patch) {
1227
1227
  statusCode: 400,
1228
1228
  error: 'retired_profile_type',
1229
1229
  message: `Runtime profile type 'openclaw' is retired (ADR-0029) and cannot be updated. The profile stays readable for legacy compatibility only.`,
1230
- nextAction: `DELETE /api/v1/config/profiles/${encodeURIComponent(profileId)} and create a pi-ai profile instead (provider + model + apiKeyEnv)`,
1230
+ nextAction: `DELETE /api/config/profiles/${encodeURIComponent(profileId)} and create a pi-ai profile instead (provider + model + apiKeyEnv)`,
1231
1231
  };
1232
1232
  }
1233
1233
  // 6. Reject type change (type change = delete + create)
@@ -1239,7 +1239,7 @@ export function updateRuntimeProfile(workspaceDir, profileId, patch) {
1239
1239
  statusCode: 400,
1240
1240
  error: 'bad_request',
1241
1241
  message: `Cannot change profile type (existing: '${existingProfile.type}', requested: '${String(patchType)}'). Type change equals delete + create. Delete this profile and create a new one instead.`,
1242
- nextAction: `DELETE /api/v1/config/profiles/${encodeURIComponent(profileId)} then POST /api/v1/config/profiles with the new type`,
1242
+ nextAction: `DELETE /api/config/profiles/${encodeURIComponent(profileId)} then POST /api/config/profiles with the new type`,
1243
1243
  };
1244
1244
  }
1245
1245
  }
@@ -1337,7 +1337,7 @@ export function deleteRuntimeProfile(workspaceDir, profileId) {
1337
1337
  statusCode: 400,
1338
1338
  error: 'bad_request',
1339
1339
  message: `Cannot delete runtime profile '${profileId}' because it is the default runtime. Change the default runtime first.`,
1340
- nextAction: 'Use PATCH /api/v1/config/default-runtime to change the default to another profile before deleting',
1340
+ nextAction: 'Use PATCH /api/config/default-runtime to change the default to another profile before deleting',
1341
1341
  };
1342
1342
  }
1343
1343
  // 5. Reject if any agent binding references this profile (list the agents)
@@ -1354,7 +1354,7 @@ export function deleteRuntimeProfile(workspaceDir, profileId) {
1354
1354
  statusCode: 400,
1355
1355
  error: 'bad_request',
1356
1356
  message: `Cannot delete runtime profile '${profileId}' because it is referenced by agents: ${referencingAgents.join(', ')}. Update their bindings first.`,
1357
- nextAction: `Use PATCH /api/v1/config/agents/:agentName/binding to reassign: ${referencingAgents.join(', ')}`,
1357
+ nextAction: `Use PATCH /api/config/agents/:agentName/binding to reassign: ${referencingAgents.join(', ')}`,
1358
1358
  };
1359
1359
  }
1360
1360
  // 6. Read raw config to preserve unknown sections, remove the profile
@@ -1 +1,21 @@
1
+ import * as http from 'http';
2
+ import { type FeedbackChannelConfig } from './config/pd-config-store.js';
3
+ import { AuthConfig } from './config/AuthConfig.js';
4
+ import { WorkspaceConfigStore } from './config/WorkspaceConfigStore.js';
5
+ import { WorkspaceService } from './models/WorkspaceService.js';
6
+ interface AppServices {
7
+ workspaceDir: string;
8
+ authConfig: AuthConfig;
9
+ configStore: WorkspaceConfigStore;
10
+ workspaceService: WorkspaceService;
11
+ feedbackFlags: Record<string, {
12
+ enabled: boolean;
13
+ }>;
14
+ maintainerEmail: string;
15
+ feedbackChannelConfig: FeedbackChannelConfig;
16
+ }
17
+ export declare function initServices(workspaceDir: string, authConfig: AuthConfig): Promise<AppServices>;
18
+ export declare function closeServices(): Promise<void>;
19
+ export declare function handleRequest(services: AppServices): (req: http.IncomingMessage, res: http.ServerResponse) => void;
1
20
  export declare function main(): Promise<void>;
21
+ export {};
@@ -2,7 +2,7 @@ import * as http from 'http';
2
2
  import * as fs from 'fs';
3
3
  import * as os from 'os';
4
4
  import * as path from 'path';
5
- import { fileURLToPath } from 'url';
5
+ import { fileURLToPath, pathToFileURL } from 'url';
6
6
  import { resolveApplyFullTimeoutMs, resolveCheckTimeoutMs } from './update-timeout.js';
7
7
  import { loadPdConfig, computeFlagsFromLoadResult, getFeedbackMaintainerEmail, getFeedbackChannelConfig, } from './config/pd-config-store.js';
8
8
  import { resolveOwnerIdentity, defaultOwnerIdentityHomeDir } from '@principles/core/runtime';
@@ -234,7 +234,7 @@ function asyncHandler(fn, timeoutMs = REQUEST_TIMEOUT_MS) {
234
234
  });
235
235
  };
236
236
  }
237
- async function initServices(workspaceDir, authConfig) {
237
+ export async function initServices(workspaceDir, authConfig) {
238
238
  const configStore = new WorkspaceConfigStore();
239
239
  const workspaceService = new WorkspaceService(configStore);
240
240
  // Load feature flags from canonical .pd/config.yaml — fail-closed: on error, feedback_channel uses defaults
@@ -287,7 +287,7 @@ async function initServices(workspaceDir, authConfig) {
287
287
  feedbackChannelConfig,
288
288
  };
289
289
  }
290
- async function closeServices() {
290
+ export async function closeServices() {
291
291
  disposeFeedbackReportModels();
292
292
  disposeFailedTasksModels();
293
293
  disposeReceiptsModels();
@@ -304,7 +304,7 @@ async function closeServices() {
304
304
  disposeOnboardingModels();
305
305
  }
306
306
  // ── Route handler ───────────────────────────────────────────────────────────
307
- function handleRequest(services) {
307
+ export function handleRequest(services) {
308
308
  const { handleWorkspacesRoute } = createWorkspacesRoutes(services.configStore, services.workspaceService);
309
309
  return (req, res) => {
310
310
  const urlPath = req.url?.split('?')[0] ?? '/';
@@ -336,8 +336,13 @@ function handleRequest(services) {
336
336
  return;
337
337
  }
338
338
  // ── API routes ──────────────────────────────────────────────────
339
+ // PRI-1139: canonical API paths are version-neutral. The deprecated
340
+ // `/api/v1/` prefix is a frozen wire literal kept as a read alias: strip
341
+ // it once here, then dispatch on the canonical `/api/...` form below, so
342
+ // both spellings reach the exact same handler branch by construction.
343
+ const routePath = urlPath.startsWith('/api/v1/') ? `/api/${urlPath.slice('/api/v1/'.length)}` : urlPath;
339
344
  // GET /api/feedback/submit/channels — submit-ladder probe
340
- if (urlPath === '/api/feedback/submit/channels') {
345
+ if (routePath === '/api/feedback/submit/channels') {
341
346
  asyncHandler(() => handleFeedbackChannelsRoute(req, res, {
342
347
  workspaceDir: services.workspaceDir,
343
348
  channelConfig: services.feedbackChannelConfig,
@@ -348,53 +353,48 @@ function handleRequest(services) {
348
353
  }
349
354
  // GET/POST /api/feedback/reports, /api/feedback/reports/:id,
350
355
  // POST /api/feedback/reports/:id/submit
351
- if (urlPath === '/api/feedback/reports' || urlPath.startsWith('/api/feedback/reports/')) {
352
- const subPath = urlPath.slice('/api/feedback/reports'.length);
356
+ if (routePath === '/api/feedback/reports' || routePath.startsWith('/api/feedback/reports/')) {
357
+ const subPath = routePath.slice('/api/feedback/reports'.length);
353
358
  asyncHandler(() => handleFeedbackReportsRoute(req, res, { workspaceDir: services.workspaceDir, subPath, featureFlags: services.feedbackFlags, maintainerEmail: services.maintainerEmail, channelConfig: services.feedbackChannelConfig }))(req, res);
354
359
  return;
355
360
  }
356
- // Task 9: GET /api/v1/failed-tasks, /api/v1/failed-tasks/:id
357
- if (urlPath === '/api/v1/failed-tasks' || urlPath.startsWith('/api/v1/failed-tasks/')) {
358
- const subPath = urlPath.slice('/api/v1/failed-tasks'.length);
361
+ // Task 9: GET /api/failed-tasks, /api/failed-tasks/:id
362
+ if (routePath === '/api/failed-tasks' || routePath.startsWith('/api/failed-tasks/')) {
363
+ const subPath = routePath.slice('/api/failed-tasks'.length);
359
364
  asyncHandler(() => handleFailedTasksRoute(req, res, { workspaceDir: services.workspaceDir, subPath, featureFlags: services.feedbackFlags }))(req, res);
360
365
  return;
361
366
  }
362
- // PRI-533: GET /api/v1/receipts/counts, /api/v1/receipts/principles/:id
363
- if (urlPath === '/api/v1/receipts' || urlPath.startsWith('/api/v1/receipts/')) {
364
- const subPath = urlPath.slice('/api/v1/receipts'.length);
367
+ // PRI-533: GET /api/receipts/counts, /api/receipts/principles/:id
368
+ if (routePath === '/api/receipts' || routePath.startsWith('/api/receipts/')) {
369
+ const subPath = routePath.slice('/api/receipts'.length);
365
370
  asyncHandler(() => handleReceiptsRoute(req, res, services.workspaceDir, subPath))(req, res);
366
371
  return;
367
372
  }
368
- // GET /api/v1/approvals/grouped (MUST be before approvals catch-all)
369
- if (urlPath === '/api/v1/approvals/grouped') {
373
+ // GET /api/approvals/grouped (MUST be before approvals catch-all)
374
+ if (routePath === '/api/approvals/grouped') {
370
375
  asyncHandler(() => handleApprovalsGroupedRoute(req, res, services.workspaceDir))(req, res);
371
376
  return;
372
377
  }
373
- // GET /api/v1/approvals, /api/v1/approvals/:id, POST /api/v1/approvals/:id/approve, /api/v1/approvals/:id/reject
374
- if (urlPath.startsWith('/api/v1/approvals')) {
375
- const subPath = urlPath.slice('/api/v1/approvals'.length);
378
+ // GET /api/approvals, /api/approvals/:id, POST /api/approvals/:id/approve, /api/approvals/:id/reject
379
+ if (routePath.startsWith('/api/approvals')) {
380
+ const subPath = routePath.slice('/api/approvals'.length);
376
381
  asyncHandler(() => handleApprovalsRoute(req, res, services.workspaceDir, subPath))(req, res);
377
382
  return;
378
383
  }
379
384
  // GET /api/principles/core — read-only PD Core Principles reference
380
385
  // (MUST be before the /api/principles catch-all so "core" is not parsed
381
- // as a principle id; the /api/v1/principles mount does not expose it.)
382
- if (urlPath === '/api/principles/core') {
386
+ // as a principle id; the /api/principles mount does not expose it.)
387
+ if (routePath === '/api/principles/core') {
383
388
  asyncHandler(() => handleCorePrinciplesRoute(req, res))(req, res);
384
389
  return;
385
390
  }
386
- // GET /api/principles, /api/principles/:id
387
- if (urlPath === '/api/principles' || urlPath.startsWith('/api/principles/')) {
388
- const subPath = urlPath.slice('/api/principles'.length);
389
- asyncHandler(() => handlePrinciplesRoute({ req, res, workspaceDir: services.workspaceDir, subPath }))(req, res);
390
- return;
391
- }
392
- // GET /api/v1/principles/:id/governance
393
- // Owner Decision Experience v1: canonical Owner decision projection —
394
- // dispatched BEFORE the principles catch-all so the static inbox path is
395
- // never parsed as `/:id` (SPEC §15). Read-only; flag-gated inside.
396
- if (urlPath.startsWith('/api/v1/principles/')) {
397
- const subPath = urlPath.slice('/api/v1/principles'.length);
391
+ // PRI-1139: ONE canonical principles mount. Owner-decision sub-paths
392
+ // dispatch BEFORE the plain principles catch-all so the static inbox
393
+ // path is never parsed as /:id (SPEC §15); both the deprecated
394
+ // /api/v1/principles alias and the pre-cutover unversioned mount reach
395
+ // this same branch.
396
+ if (routePath === '/api/principles' || routePath.startsWith('/api/principles/')) {
397
+ const subPath = routePath.slice('/api/principles'.length);
398
398
  if (subPath === '/owner-decision-inbox') {
399
399
  asyncHandler(() => handleOwnerDecisionInboxRoute({ req, res, workspaceDir: services.workspaceDir, featureFlags: services.feedbackFlags, now: () => new Date().toISOString() }))(req, res);
400
400
  return;
@@ -414,13 +414,13 @@ function handleRequest(services) {
414
414
  return;
415
415
  }
416
416
  // Workspace management routes
417
- if (urlPath === '/api/workspaces' || urlPath.startsWith('/api/workspaces/')) {
418
- const subPath = urlPath.slice('/api/workspaces'.length);
417
+ if (routePath === '/api/workspaces' || routePath.startsWith('/api/workspaces/')) {
418
+ const subPath = routePath.slice('/api/workspaces'.length);
419
419
  asyncHandler(() => handleWorkspacesRoute(req, res, subPath))(req, res);
420
420
  return;
421
421
  }
422
422
  // GET /api/update/history (MUST be before update catch-all)
423
- if (urlPath === '/api/update/history') {
423
+ if (routePath === '/api/update/history') {
424
424
  asyncHandler(() => handleUpdateHistoryRoute(req, res, services.workspaceDir, ''))(req, res);
425
425
  return;
426
426
  }
@@ -428,15 +428,15 @@ function handleRequest(services) {
428
428
  // POST /api/update/recovery/resolve (MUST be before the update
429
429
  // catch-all; PRI-848/853 surfaces — resolve runs the pure journal
430
430
  // decision, it does not re-point installation state itself).
431
- if (urlPath === '/api/update/recovery' || urlPath.startsWith('/api/update/recovery/') || urlPath.startsWith('/api/update/transaction/')) {
432
- const subPath = urlPath.slice('/api/update'.length);
431
+ if (routePath === '/api/update/recovery' || routePath.startsWith('/api/update/recovery/') || routePath.startsWith('/api/update/transaction/')) {
432
+ const subPath = routePath.slice('/api/update'.length);
433
433
  asyncHandler(() => handleUpdateTransactionRoute(req, res, subPath))(req, res);
434
434
  return;
435
435
  }
436
436
  // Update routes: GET /api/update/check, POST /api/update/apply-full
437
437
  // (handleUpdateRoute 404s every other subPath)
438
- if (urlPath === '/api/update' || urlPath.startsWith('/api/update/')) {
439
- const subPath = urlPath.slice('/api/update'.length);
438
+ if (routePath === '/api/update' || routePath.startsWith('/api/update/')) {
439
+ const subPath = routePath.slice('/api/update'.length);
440
440
  const isApply = subPath === '/apply';
441
441
  const isApplyFull = subPath === '/apply-full';
442
442
  const isCheck = subPath === '/check';
@@ -447,29 +447,29 @@ function handleRequest(services) {
447
447
  asyncHandler(() => handleUpdateRoute(req, res, services.workspaceDir, subPath), timeout)(req, res);
448
448
  return;
449
449
  }
450
- // Config API routes: /api/v1/config/summary, /api/v1/config/catalog,
451
- // /api/v1/config/agents/:name/binding, /api/v1/config/readiness/:name
452
- if (urlPath === '/api/v1/config' || urlPath.startsWith('/api/v1/config/')) {
453
- const subPath = urlPath.slice('/api/v1/config'.length);
450
+ // Config API routes: /api/config/summary, /api/config/catalog,
451
+ // /api/config/agents/:name/binding, /api/config/readiness/:name
452
+ if (routePath === '/api/config' || routePath.startsWith('/api/config/')) {
453
+ const subPath = routePath.slice('/api/config'.length);
454
454
  asyncHandler(() => handleConfigRoute(req, res, { workspaceDir: services.workspaceDir, subPath }))(req, res);
455
455
  return;
456
456
  }
457
- // CR8: GET /api/v1/lifecycle/principles/:principleId
458
- if (urlPath.startsWith('/api/v1/lifecycle')) {
459
- const subPath = urlPath.slice('/api/v1/lifecycle'.length);
457
+ // CR8: GET /api/lifecycle/principles/:principleId
458
+ if (routePath.startsWith('/api/lifecycle')) {
459
+ const subPath = routePath.slice('/api/lifecycle'.length);
460
460
  asyncHandler(() => handleLifecycleRoute(req, res, services.workspaceDir, subPath))(req, res);
461
461
  return;
462
462
  }
463
463
  // SPEC-PD-EXAMINER-001 v0.9 §8: Examiner offline studies (local-dev
464
464
  // scope — the route answers 503 when the lab tooling is not present).
465
- if (urlPath === '/api/v1/examiner' || urlPath.startsWith('/api/v1/examiner/')) {
466
- const subPath = urlPath.slice('/api/v1/examiner'.length);
465
+ if (routePath === '/api/examiner' || routePath.startsWith('/api/examiner/')) {
466
+ const subPath = routePath.slice('/api/examiner'.length);
467
467
  asyncHandler(() => handleExaminerRoute(req, res, services.workspaceDir, subPath))(req, res);
468
468
  return;
469
469
  }
470
- // CR8: GET /api/v1/activations
471
- if (urlPath === '/api/v1/activations' || urlPath.startsWith('/api/v1/activations/')) {
472
- const subPath = urlPath.slice('/api/v1/activations'.length);
470
+ // CR8: GET /api/activations
471
+ if (routePath === '/api/activations' || routePath.startsWith('/api/activations/')) {
472
+ const subPath = routePath.slice('/api/activations'.length);
473
473
  // ADR-0022 (PRI-578): single resolver — env > ~/.pd/owner.json > none
474
474
  const identity = resolveOwnerIdentity(process.env, defaultOwnerIdentityHomeDir());
475
475
  const ownerActor = services.authConfig.isEnabled() && identity.ownerId && identity.credentialId
@@ -481,14 +481,14 @@ function handleRequest(services) {
481
481
  }))(req, res);
482
482
  return;
483
483
  }
484
- // ADR-0022 (PRI-578): /api/v1/owner-identity — GET status, POST register, DELETE unregister
485
- if (urlPath === '/api/v1/owner-identity' || urlPath.startsWith('/api/v1/owner-identity/')) {
486
- const subPath = urlPath.slice('/api/v1/owner-identity'.length);
484
+ // ADR-0022 (PRI-578): /api/owner-identity — GET status, POST register, DELETE unregister
485
+ if (routePath === '/api/owner-identity' || routePath.startsWith('/api/owner-identity/')) {
486
+ const subPath = routePath.slice('/api/owner-identity'.length);
487
487
  asyncHandler(() => handleOwnerIdentityRoute(req, res, defaultOwnerIdentityHomeDir(), subPath, services.authConfig))(req, res);
488
488
  return;
489
489
  }
490
- // PRI-585: GET /api/v1/governance/experience (flag-gated read-only snapshot)
491
- if (urlPath === '/api/v1/governance/experience') {
490
+ // PRI-585: GET /api/governance/experience (flag-gated read-only snapshot)
491
+ if (routePath === '/api/governance/experience') {
492
492
  asyncHandler(() => handleGovernanceExperienceRoute(req, res, {
493
493
  workspaceDir: services.workspaceDir,
494
494
  featureFlags: services.feedbackFlags,
@@ -496,26 +496,26 @@ function handleRequest(services) {
496
496
  }))(req, res);
497
497
  return;
498
498
  }
499
- // CR8: GET /api/v1/governance/queue
500
- if (urlPath === '/api/v1/governance/queue') {
499
+ // CR8: GET /api/governance/queue
500
+ if (routePath === '/api/governance/queue') {
501
501
  asyncHandler(() => handleGovernanceRoute(req, res, services.workspaceDir))(req, res);
502
502
  return;
503
503
  }
504
- if (urlPath === '/api/v1/governance/rule-candidate-bindings' || urlPath.startsWith('/api/v1/governance/rule-candidate-bindings/')) {
504
+ if (routePath === '/api/governance/rule-candidate-bindings' || routePath.startsWith('/api/governance/rule-candidate-bindings/')) {
505
505
  const { ownerId, credentialId } = resolveOwnerIdentity(process.env, defaultOwnerIdentityHomeDir());
506
506
  asyncHandler(() => handleRuleCandidateBindingsRoute(req, res, {
507
507
  workspaceDir: services.workspaceDir,
508
- subPath: urlPath.slice('/api/v1/governance/rule-candidate-bindings'.length),
508
+ subPath: routePath.slice('/api/governance/rule-candidate-bindings'.length),
509
509
  ownerIdentity: services.authConfig.isEnabled() && ownerId !== null && credentialId !== null
510
510
  ? { ownerId, credentialId } : null,
511
511
  }))(req, res);
512
512
  return;
513
513
  }
514
- // PRI-629: GET/POST /api/v1/governance/owner-decisions — unified Owner Inbox
514
+ // PRI-629: GET/POST /api/governance/owner-decisions — unified Owner Inbox
515
515
  // (read projection + resolution). Identity derived server-side (SPEC §29):
516
516
  // configured owner when registered, else the authenticated console operator.
517
- if (urlPath === '/api/v1/governance/owner-decisions' || urlPath.startsWith('/api/v1/governance/owner-decisions/')) {
518
- const subPath = urlPath.slice('/api/v1/governance/owner-decisions'.length);
517
+ if (routePath === '/api/governance/owner-decisions' || routePath.startsWith('/api/governance/owner-decisions/')) {
518
+ const subPath = routePath.slice('/api/governance/owner-decisions'.length);
519
519
  const odIdentity = resolveOwnerIdentity(process.env, defaultOwnerIdentityHomeDir());
520
520
  const { ownerId, credentialId } = odIdentity;
521
521
  const authEnabledForOwner = services.authConfig.isEnabled()
@@ -529,46 +529,46 @@ function handleRequest(services) {
529
529
  }))(req, res);
530
530
  return;
531
531
  }
532
- if (urlPath.startsWith('/api/v1/governance/design-gate/')) {
532
+ if (routePath.startsWith('/api/governance/design-gate/')) {
533
533
  const identity = resolveOwnerIdentity(process.env, defaultOwnerIdentityHomeDir());
534
534
  const { ownerId, credentialId } = identity;
535
535
  asyncHandler(() => handleDesignGateRoute(req, res, {
536
536
  workspaceDir: services.workspaceDir,
537
- subPath: urlPath.slice('/api/v1/governance/design-gate'.length),
537
+ subPath: routePath.slice('/api/governance/design-gate'.length),
538
538
  ownerIdentity: services.authConfig.isEnabled() && ownerId !== null && credentialId !== null
539
539
  ? { ownerId, credentialId } : null,
540
540
  }))(req, res);
541
541
  return;
542
542
  }
543
- // PRI-466/477: GET/POST/PUT /api/v1/intent (+ /init, /content sub-paths)
544
- if (urlPath === '/api/v1/intent' || urlPath.startsWith('/api/v1/intent/')) {
545
- const subPath = urlPath === '/api/v1/intent' ? '' : urlPath.slice('/api/v1/intent'.length);
543
+ // PRI-466/477: GET/POST/PUT /api/intent (+ /init, /content sub-paths)
544
+ if (routePath === '/api/intent' || routePath.startsWith('/api/intent/')) {
545
+ const subPath = routePath === '/api/intent' ? '' : routePath.slice('/api/intent'.length);
546
546
  asyncHandler(() => handleIntentRoute(req, res, { workspaceDir: services.workspaceDir, subPath }))(req, res);
547
547
  return;
548
548
  }
549
- // PRI-470: IntentDecisionRecord (POST/GET /api/v1/intent-decisions, /:id, /summary)
550
- if (urlPath === '/api/v1/intent-decisions' || urlPath.startsWith('/api/v1/intent-decisions/')) {
551
- const subPath = urlPath.slice('/api/v1/intent-decisions'.length);
549
+ // PRI-470: IntentDecisionRecord (POST/GET /api/intent-decisions, /:id, /summary)
550
+ if (routePath === '/api/intent-decisions' || routePath.startsWith('/api/intent-decisions/')) {
551
+ const subPath = routePath.slice('/api/intent-decisions'.length);
552
552
  asyncHandler(() => handleIntentDecisionsRoute(req, res, services.workspaceDir, subPath))(req, res);
553
553
  return;
554
554
  }
555
- // Onboarding wizard: POST /api/v1/onboarding/run-demo — spawns `pd demo story-a`
555
+ // Onboarding wizard: POST /api/onboarding/run-demo — spawns `pd demo story-a`
556
556
  // (spec 2026-06-30-new-user-onboarding-design.md §6.3 改动 5)
557
- if (urlPath === '/api/v1/onboarding' || urlPath.startsWith('/api/v1/onboarding/')) {
558
- const subPath = urlPath === '/api/v1/onboarding' ? '' : urlPath.slice('/api/v1/onboarding'.length);
557
+ if (routePath === '/api/onboarding' || routePath.startsWith('/api/onboarding/')) {
558
+ const subPath = routePath === '/api/onboarding' ? '' : routePath.slice('/api/onboarding'.length);
559
559
  asyncHandler(() => handleOnboardingRoute(req, res, { workspaceDir: services.workspaceDir, subPath }))(req, res);
560
560
  return;
561
561
  }
562
- // PRI-331: GET /api/v1/evidence-chain
563
- if (urlPath === '/api/v1/evidence-chain') {
562
+ // PRI-331: GET /api/evidence-chain
563
+ if (routePath === '/api/evidence-chain') {
564
564
  asyncHandler(() => handleEvidenceChainRoute(req, res, services.workspaceDir))(req, res);
565
565
  return;
566
566
  }
567
- // PD v2 Phase 1: POST /api/v1/evidence/outcomes — Owner outcome feedback
567
+ // PD v2 Phase 1: POST /api/evidence/outcomes — Owner outcome feedback
568
568
  // into the normalized evidence ledger. Identity derived server-side,
569
569
  // same rule as owner-decisions (configured owner or authenticated
570
570
  // console operator; never a body-supplied identity).
571
- if (urlPath === '/api/v1/evidence/outcomes') {
571
+ if (routePath === '/api/evidence/outcomes') {
572
572
  const eoIdentity = resolveOwnerIdentity(process.env, defaultOwnerIdentityHomeDir());
573
573
  const { ownerId, credentialId } = eoIdentity;
574
574
  const authEnabledForOwner = services.authConfig.isEnabled()
@@ -582,7 +582,7 @@ function handleRequest(services) {
582
582
  return;
583
583
  }
584
584
  // GET /api/health
585
- if (urlPath === '/api/health') {
585
+ if (routePath === '/api/health') {
586
586
  asyncHandler(() => handleHealthRoute(req, res, {
587
587
  workspaceDir: services.workspaceDir,
588
588
  authenticationMode: services.authConfig.isEnabled() ? 'authenticated' : 'no_auth',
@@ -590,7 +590,7 @@ function handleRequest(services) {
590
590
  return;
591
591
  }
592
592
  // 404 fallback for API routes
593
- sendNotFound(res, `Route ${urlPath} not found`);
593
+ sendNotFound(res, `Route ${routePath} not found`);
594
594
  return;
595
595
  }
596
596
  // 404 fallback
@@ -651,7 +651,27 @@ export async function main() {
651
651
  console.log('[pd-console] Auth: ' + (authConfig.isEnabled() ? 'enabled' : 'disabled'));
652
652
  });
653
653
  }
654
- main().catch((err) => {
655
- console.error('[pd-console] Fatal startup error:', err);
656
- process.exit(1);
657
- });
654
+ // cli-7 / PRI-892 precedent: importing this module (a test driving
655
+ // handleRequest directly, for example) must NOT start a production console.
656
+ // The unguarded call bound port 3100 and initialized the first registered
657
+ // workspace — including the real ~/.pd history reconciliation and the
658
+ // ~/.openclaw/extensions backup migration — as an import side effect.
659
+ // Node hands argv[1] as the unresolved link path while import.meta.url is the
660
+ // realpath, so canonicalize before comparing.
661
+ function isMainModuleEntry() {
662
+ const [, entry] = process.argv;
663
+ if (!entry)
664
+ return false;
665
+ try {
666
+ return pathToFileURL(fs.realpathSync(entry)).href === import.meta.url;
667
+ }
668
+ catch {
669
+ return false;
670
+ }
671
+ }
672
+ if (isMainModuleEntry()) {
673
+ main().catch((err) => {
674
+ console.error('[pd-console] Fatal startup error:', err);
675
+ process.exit(1);
676
+ });
677
+ }
@@ -125,7 +125,7 @@ export declare class ApprovalsConsoleModel {
125
125
  listApprovals(filter?: ApprovalListFilter): Promise<ApprovalListResult>;
126
126
  getApprovalDetail(approvalId: string): Promise<(ApprovalWithContext & {
127
127
  isMvpProven: boolean;
128
- writeGuardVersion: 'approval-review-v1';
128
+ writeGuardVersion: 'approval-review';
129
129
  review: {
130
130
  expectedReview: ApprovalReviewGuard;
131
131
  material: ApprovalReviewMaterial;
@@ -109,14 +109,17 @@ export class ApprovalsConsoleModel {
109
109
  return null;
110
110
  }
111
111
  const artifact = await new SqlitePIArtifactStore(connection).getArtifactById(record.artifactId);
112
- const common = { schemaVersion: 'approval-review-v1', approvalId, artifactId: record.artifactId, channel: record.channel };
112
+ // PRI-1139: the guard minted here carries the version-neutral
113
+ // 'approval-review'; the core guard schema still accepts the pre-cutover
114
+ // spelling submitted by in-flight older clients.
115
+ const common = { schemaVersion: 'approval-review', approvalId, artifactId: record.artifactId, channel: record.channel };
113
116
  const expectedReview = artifact
114
117
  ? { ...common, artifactState: 'present', artifactDigest: computeArtifactDigest(artifact) }
115
118
  : { ...common, artifactState: 'missing' };
116
119
  const material = approvalReviewMaterial(record.artifactId, record.channel, artifact?.contentJson ?? null);
117
120
  db.exec('COMMIT');
118
121
  return { ...record, confidenceLabel: mapConfidenceToLabel(record.confidence), isMvpProven: MVP_PROVEN_CHANNELS.has(record.channel),
119
- writeGuardVersion: 'approval-review-v1', review: { expectedReview, material } };
122
+ writeGuardVersion: 'approval-review', review: { expectedReview, material } };
120
123
  }
121
124
  catch (error) {
122
125
  try {
@@ -14,6 +14,7 @@
14
14
  import * as fs from 'node:fs';
15
15
  import * as path from 'node:path';
16
16
  import { createHash } from 'node:crypto';
17
+ import { RUNTIME_CONTRACT_SCHEMA_VERSION } from '@principles/core/runtime';
17
18
  import { deriveGovernanceExperienceSnapshot, deriveOwnerGovernanceView, } from '@principles/core/runtime';
18
19
  import { GovernanceProjectionCollector, isRecord, readOwnString, } from './GovernanceProjectionCollector.js';
19
20
  import { loadPdConfig } from '../config/pd-config-store.js';
@@ -239,7 +240,7 @@ export class GovernanceExperienceCollector {
239
240
  : { environment: 'unknown', source: 'missing' }
240
241
  : { environment: 'unknown', source: 'missing', configIssue: 'config_invalid' };
241
242
  return {
242
- schemaVersion: '1',
243
+ schemaVersion: RUNTIME_CONTRACT_SCHEMA_VERSION,
243
244
  asOf,
244
245
  workspaceHash: hashWorkspacePath(this.workspaceDir),
245
246
  governanceViews: views,
@@ -1,5 +1,6 @@
1
1
  import * as fs from 'node:fs';
2
2
  import * as path from 'node:path';
3
+ import { RUNTIME_CONTRACT_SCHEMA_VERSION } from '@principles/core/runtime';
3
4
  import { Value } from '@sinclair/typebox/value';
4
5
  import { GovernanceFactsSchema, SqliteConnection, isPDErrorCategory, parsePITaskMetadata, PD_TASK_STATUSES, PRINCIPLE_STATUSES, isPDTaskStatus, } from '@principles/core/runtime';
5
6
  export const GOVERNANCE_TASK_KINDS = new Set([
@@ -198,7 +199,7 @@ export class GovernanceProjectionCollector {
198
199
  revisionIdentities.push(identity);
199
200
  materializedRevisionSources.add(sourceTaskId);
200
201
  derivedRelations.push({
201
- schemaVersion: '1', family: 'derived_relation', sourceRef: { type: 'task', id: task.taskId }, principleId,
202
+ schemaVersion: RUNTIME_CONTRACT_SCHEMA_VERSION, family: 'derived_relation', sourceRef: { type: 'task', id: task.taskId }, principleId,
202
203
  taskId: task.taskId, lineageConfidence: taskLineageConfidence, recordedAt: task.updatedAt,
203
204
  revisionIdentity: identity, relation: 'revision_materialized',
204
205
  evidenceRefs: [
@@ -214,7 +215,7 @@ export class GovernanceProjectionCollector {
214
215
  });
215
216
  }
216
217
  const fact = {
217
- schemaVersion: '1', family: 'task', sourceRef: { type: 'task', id: task.taskId }, principleId,
218
+ schemaVersion: RUNTIME_CONTRACT_SCHEMA_VERSION, family: 'task', sourceRef: { type: 'task', id: task.taskId }, principleId,
218
219
  taskId: task.taskId, lineageConfidence: taskLineageConfidence, recordedAt: task.updatedAt,
219
220
  occurredAt: task.createdAt, taskKind: task.taskKind, channel: task.channel, status: task.status,
220
221
  attemptCount: task.attemptCount, maxAttempts: task.maxAttempts,
@@ -232,7 +233,7 @@ export class GovernanceProjectionCollector {
232
233
  sourceRefs.push(fact.sourceRef);
233
234
  if ((task.taskKind === 'evaluator' || task.taskKind === 'rollout_reviewer') && task.runnerDecision !== undefined) {
234
235
  runnerVerdicts.push({
235
- schemaVersion: '1', family: 'runner_verdict', sourceRef: fact.sourceRef, principleId,
236
+ schemaVersion: RUNTIME_CONTRACT_SCHEMA_VERSION, family: 'runner_verdict', sourceRef: fact.sourceRef, principleId,
236
237
  taskId: task.taskId, lineageConfidence: taskLineageConfidence, recordedAt: task.updatedAt,
237
238
  runnerKind: task.taskKind, outcome: task.runnerDecision,
238
239
  });
@@ -249,7 +250,7 @@ export class GovernanceProjectionCollector {
249
250
  }
250
251
  else if ((task.taskKind === 'evaluator' || task.taskKind === 'rollout_reviewer') && task.status === 'succeeded') {
251
252
  derivedRelations.push({
252
- schemaVersion: '1', family: 'derived_relation', sourceRef: fact.sourceRef, principleId,
253
+ schemaVersion: RUNTIME_CONTRACT_SCHEMA_VERSION, family: 'derived_relation', sourceRef: fact.sourceRef, principleId,
253
254
  taskId: task.taskId, lineageConfidence: taskLineageConfidence, recordedAt: task.updatedAt,
254
255
  relation: 'verdict_missing', evidenceRefs: [fact.sourceRef],
255
256
  });
@@ -269,7 +270,7 @@ export class GovernanceProjectionCollector {
269
270
  if (taskId === undefined || task.completionIntent?.status !== 'pending' || materializedRevisionSources.has(taskId))
270
271
  continue;
271
272
  derivedRelations.push({
272
- schemaVersion: '1', family: 'derived_relation', sourceRef: task.sourceRef, principleId,
273
+ schemaVersion: RUNTIME_CONTRACT_SCHEMA_VERSION, family: 'derived_relation', sourceRef: task.sourceRef, principleId,
273
274
  taskId, lineageConfidence: 'strong', recordedAt: task.recordedAt,
274
275
  relation: 'revision_pending', evidenceRefs: [task.sourceRef],
275
276
  });
@@ -281,7 +282,7 @@ export class GovernanceProjectionCollector {
281
282
  if (!strongTaskIds.has(dependencyTaskId))
282
283
  continue;
283
284
  derivedRelations.push({
284
- schemaVersion: '1', family: 'derived_relation', sourceRef: { type: 'task', id: dependencyTaskId }, principleId,
285
+ schemaVersion: RUNTIME_CONTRACT_SCHEMA_VERSION, family: 'derived_relation', sourceRef: { type: 'task', id: dependencyTaskId }, principleId,
285
286
  taskId: dependencyTaskId, lineageConfidence: 'strong', recordedAt: successor.updatedAt,
286
287
  relation: 'successor_present',
287
288
  evidenceRefs: [{ type: 'task', id: dependencyTaskId }, { type: 'task', id: successor.taskId }],
@@ -312,7 +313,7 @@ export class GovernanceProjectionCollector {
312
313
  }
313
314
  const strongApprovalRef = { type: 'approval', id: approvalId };
314
315
  const fact = {
315
- schemaVersion: '1', family: 'approval', sourceRef: strongApprovalRef, principleId, artifactId,
316
+ schemaVersion: RUNTIME_CONTRACT_SCHEMA_VERSION, family: 'approval', sourceRef: strongApprovalRef, principleId, artifactId,
316
317
  approvalId, channel, outcome, lineageConfidence: 'strong', recordedAt: decidedAt ?? requestedAt,
317
318
  };
318
319
  if (decidedAt !== undefined)
@@ -346,7 +347,7 @@ export class GovernanceProjectionCollector {
346
347
  }
347
348
  const strongActivationRef = { type: 'activation', id: activationId };
348
349
  const fact = {
349
- schemaVersion: '1', family: 'activation', sourceRef: strongActivationRef, principleId, artifactId,
350
+ schemaVersion: RUNTIME_CONTRACT_SCHEMA_VERSION, family: 'activation', sourceRef: strongActivationRef, principleId, artifactId,
350
351
  activationId, channel, outcome: deactivatedAt === undefined ? 'active' : 'deactivated',
351
352
  activatedAt, lineageConfidence: 'strong', recordedAt: deactivatedAt ?? activatedAt,
352
353
  };
@@ -424,7 +425,7 @@ export class GovernanceProjectionCollector {
424
425
  if (state !== 'candidate' && state !== 'active' && state !== 'archived' && state !== 'deprecated' && state !== 'probation') {
425
426
  throw new GovernanceProjectionCollectionError('governance_projection_error', 'repair_principle_status');
426
427
  }
427
- return { schemaVersion: '1', family: 'principle', sourceRef: { type: 'principle', id: principleId }, principleId, lineageConfidence: 'strong', recordedAt, state };
428
+ return { schemaVersion: RUNTIME_CONTRACT_SCHEMA_VERSION, family: 'principle', sourceRef: { type: 'principle', id: principleId }, principleId, lineageConfidence: 'strong', recordedAt, state };
428
429
  }
429
430
  static parseStringArrayJson(value) {
430
431
  if (value === undefined)
@@ -557,7 +558,7 @@ export class GovernanceProjectionCollector {
557
558
  static finish(input) {
558
559
  const hasArtifacts = (input.artifactIds?.length ?? 0) > 0;
559
560
  const facts = {
560
- schemaVersion: '1', principleId: input.principleId, asOf: input.asOf,
561
+ schemaVersion: RUNTIME_CONTRACT_SCHEMA_VERSION, principleId: input.principleId, asOf: input.asOf,
561
562
  lineage: {
562
563
  principleId: input.principleId, artifactIds: input.artifactIds ?? [], taskIds: input.taskIds ?? [],
563
564
  revisionIdentities: input.revisionIdentities ?? [],