@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.
Files changed (298) hide show
  1. package/README.md +90 -0
  2. package/dist/commands/artifact.d.ts +14 -0
  3. package/dist/commands/artifact.d.ts.map +1 -0
  4. package/dist/commands/artifact.js +67 -0
  5. package/dist/commands/artifact.js.map +1 -0
  6. package/dist/commands/candidate.d.ts +83 -0
  7. package/dist/commands/candidate.d.ts.map +1 -0
  8. package/dist/commands/candidate.js +891 -0
  9. package/dist/commands/candidate.js.map +1 -0
  10. package/dist/commands/central-sync.d.ts +10 -0
  11. package/dist/commands/central-sync.d.ts.map +1 -0
  12. package/dist/commands/central-sync.js +32 -0
  13. package/dist/commands/central-sync.js.map +1 -0
  14. package/dist/commands/console.d.ts +9 -0
  15. package/dist/commands/console.d.ts.map +1 -0
  16. package/dist/commands/console.js +114 -0
  17. package/dist/commands/console.js.map +1 -0
  18. package/dist/commands/context.d.ts +7 -0
  19. package/dist/commands/context.d.ts.map +1 -0
  20. package/dist/commands/context.js +55 -0
  21. package/dist/commands/context.js.map +1 -0
  22. package/dist/commands/demo-story-a.d.ts +12 -0
  23. package/dist/commands/demo-story-a.d.ts.map +1 -0
  24. package/dist/commands/demo-story-a.js +175 -0
  25. package/dist/commands/demo-story-a.js.map +1 -0
  26. package/dist/commands/diagnose.d.ts +35 -0
  27. package/dist/commands/diagnose.d.ts.map +1 -0
  28. package/dist/commands/diagnose.js +390 -0
  29. package/dist/commands/diagnose.js.map +1 -0
  30. package/dist/commands/evolution-tasks-list.d.ts +15 -0
  31. package/dist/commands/evolution-tasks-list.d.ts.map +1 -0
  32. package/dist/commands/evolution-tasks-list.js +34 -0
  33. package/dist/commands/evolution-tasks-list.js.map +1 -0
  34. package/dist/commands/evolution-tasks-show.d.ts +14 -0
  35. package/dist/commands/evolution-tasks-show.d.ts.map +1 -0
  36. package/dist/commands/evolution-tasks-show.js +52 -0
  37. package/dist/commands/evolution-tasks-show.js.map +1 -0
  38. package/dist/commands/flow.d.ts +7 -0
  39. package/dist/commands/flow.d.ts.map +1 -0
  40. package/dist/commands/flow.js +57 -0
  41. package/dist/commands/flow.js.map +1 -0
  42. package/dist/commands/health.d.ts +16 -0
  43. package/dist/commands/health.d.ts.map +1 -0
  44. package/dist/commands/health.js +150 -0
  45. package/dist/commands/health.js.map +1 -0
  46. package/dist/commands/history.d.ts +11 -0
  47. package/dist/commands/history.d.ts.map +1 -0
  48. package/dist/commands/history.js +50 -0
  49. package/dist/commands/history.js.map +1 -0
  50. package/dist/commands/legacy-cleanup.d.ts +27 -0
  51. package/dist/commands/legacy-cleanup.d.ts.map +1 -0
  52. package/dist/commands/legacy-cleanup.js +171 -0
  53. package/dist/commands/legacy-cleanup.js.map +1 -0
  54. package/dist/commands/legacy-import.d.ts +7 -0
  55. package/dist/commands/legacy-import.d.ts.map +1 -0
  56. package/dist/commands/legacy-import.js +86 -0
  57. package/dist/commands/legacy-import.js.map +1 -0
  58. package/dist/commands/pain-record.d.ts +10 -0
  59. package/dist/commands/pain-record.d.ts.map +1 -0
  60. package/dist/commands/pain-record.js +162 -0
  61. package/dist/commands/pain-record.js.map +1 -0
  62. package/dist/commands/proven-channel-baseline.d.ts +12 -0
  63. package/dist/commands/proven-channel-baseline.d.ts.map +1 -0
  64. package/dist/commands/proven-channel-baseline.js +97 -0
  65. package/dist/commands/proven-channel-baseline.js.map +1 -0
  66. package/dist/commands/remediation-output.d.ts +40 -0
  67. package/dist/commands/remediation-output.d.ts.map +1 -0
  68. package/dist/commands/remediation-output.js +23 -0
  69. package/dist/commands/remediation-output.js.map +1 -0
  70. package/dist/commands/run.d.ts +10 -0
  71. package/dist/commands/run.d.ts.map +1 -0
  72. package/dist/commands/run.js +68 -0
  73. package/dist/commands/run.js.map +1 -0
  74. package/dist/commands/runtime-activation.d.ts +11 -0
  75. package/dist/commands/runtime-activation.d.ts.map +1 -0
  76. package/dist/commands/runtime-activation.js +150 -0
  77. package/dist/commands/runtime-activation.js.map +1 -0
  78. package/dist/commands/runtime-canary.d.ts +30 -0
  79. package/dist/commands/runtime-canary.d.ts.map +1 -0
  80. package/dist/commands/runtime-canary.js +343 -0
  81. package/dist/commands/runtime-canary.js.map +1 -0
  82. package/dist/commands/runtime-diagnostics-export.d.ts +20 -0
  83. package/dist/commands/runtime-diagnostics-export.d.ts.map +1 -0
  84. package/dist/commands/runtime-diagnostics-export.js +177 -0
  85. package/dist/commands/runtime-diagnostics-export.js.map +1 -0
  86. package/dist/commands/runtime-features.d.ts +26 -0
  87. package/dist/commands/runtime-features.d.ts.map +1 -0
  88. package/dist/commands/runtime-features.js +70 -0
  89. package/dist/commands/runtime-features.js.map +1 -0
  90. package/dist/commands/runtime-gfi-snapshot.d.ts +7 -0
  91. package/dist/commands/runtime-gfi-snapshot.d.ts.map +1 -0
  92. package/dist/commands/runtime-gfi-snapshot.js +101 -0
  93. package/dist/commands/runtime-gfi-snapshot.js.map +1 -0
  94. package/dist/commands/runtime-health-snapshot.d.ts +7 -0
  95. package/dist/commands/runtime-health-snapshot.d.ts.map +1 -0
  96. package/dist/commands/runtime-health-snapshot.js +93 -0
  97. package/dist/commands/runtime-health-snapshot.js.map +1 -0
  98. package/dist/commands/runtime-idle-trigger.d.ts +12 -0
  99. package/dist/commands/runtime-idle-trigger.d.ts.map +1 -0
  100. package/dist/commands/runtime-idle-trigger.js +102 -0
  101. package/dist/commands/runtime-idle-trigger.js.map +1 -0
  102. package/dist/commands/runtime-internalization-enqueue-successors.d.ts +9 -0
  103. package/dist/commands/runtime-internalization-enqueue-successors.d.ts.map +1 -0
  104. package/dist/commands/runtime-internalization-enqueue-successors.js +393 -0
  105. package/dist/commands/runtime-internalization-enqueue-successors.js.map +1 -0
  106. package/dist/commands/runtime-internalization-integrity-repair.d.ts +9 -0
  107. package/dist/commands/runtime-internalization-integrity-repair.d.ts.map +1 -0
  108. package/dist/commands/runtime-internalization-integrity-repair.js +54 -0
  109. package/dist/commands/runtime-internalization-integrity-repair.js.map +1 -0
  110. package/dist/commands/runtime-internalization-integrity.d.ts +7 -0
  111. package/dist/commands/runtime-internalization-integrity.d.ts.map +1 -0
  112. package/dist/commands/runtime-internalization-integrity.js +53 -0
  113. package/dist/commands/runtime-internalization-integrity.js.map +1 -0
  114. package/dist/commands/runtime-internalization-queue.d.ts +7 -0
  115. package/dist/commands/runtime-internalization-queue.d.ts.map +1 -0
  116. package/dist/commands/runtime-internalization-queue.js +85 -0
  117. package/dist/commands/runtime-internalization-queue.js.map +1 -0
  118. package/dist/commands/runtime-internalization-run-once.d.ts +12 -0
  119. package/dist/commands/runtime-internalization-run-once.d.ts.map +1 -0
  120. package/dist/commands/runtime-internalization-run-once.js +546 -0
  121. package/dist/commands/runtime-internalization-run-once.js.map +1 -0
  122. package/dist/commands/runtime-internalization-wake-once.d.ts +8 -0
  123. package/dist/commands/runtime-internalization-wake-once.d.ts.map +1 -0
  124. package/dist/commands/runtime-internalization-wake-once.js +72 -0
  125. package/dist/commands/runtime-internalization-wake-once.js.map +1 -0
  126. package/dist/commands/runtime-pain-flood-simulation.d.ts +10 -0
  127. package/dist/commands/runtime-pain-flood-simulation.d.ts.map +1 -0
  128. package/dist/commands/runtime-pain-flood-simulation.js +104 -0
  129. package/dist/commands/runtime-pain-flood-simulation.js.map +1 -0
  130. package/dist/commands/runtime-pruning.d.ts +45 -0
  131. package/dist/commands/runtime-pruning.d.ts.map +1 -0
  132. package/dist/commands/runtime-pruning.js +355 -0
  133. package/dist/commands/runtime-pruning.js.map +1 -0
  134. package/dist/commands/runtime-recovery.d.ts +9 -0
  135. package/dist/commands/runtime-recovery.d.ts.map +1 -0
  136. package/dist/commands/runtime-recovery.js +94 -0
  137. package/dist/commands/runtime-recovery.js.map +1 -0
  138. package/dist/commands/runtime-synthetic-baseline.d.ts +7 -0
  139. package/dist/commands/runtime-synthetic-baseline.d.ts.map +1 -0
  140. package/dist/commands/runtime-synthetic-baseline.js +59 -0
  141. package/dist/commands/runtime-synthetic-baseline.js.map +1 -0
  142. package/dist/commands/runtime-uat.d.ts +52 -0
  143. package/dist/commands/runtime-uat.d.ts.map +1 -0
  144. package/dist/commands/runtime-uat.js +274 -0
  145. package/dist/commands/runtime-uat.js.map +1 -0
  146. package/dist/commands/runtime.d.ts +20 -0
  147. package/dist/commands/runtime.d.ts.map +1 -0
  148. package/dist/commands/runtime.js +256 -0
  149. package/dist/commands/runtime.js.map +1 -0
  150. package/dist/commands/samples-list.d.ts +11 -0
  151. package/dist/commands/samples-list.d.ts.map +1 -0
  152. package/dist/commands/samples-list.js +37 -0
  153. package/dist/commands/samples-list.js.map +1 -0
  154. package/dist/commands/samples-review.d.ts +14 -0
  155. package/dist/commands/samples-review.d.ts.map +1 -0
  156. package/dist/commands/samples-review.js +22 -0
  157. package/dist/commands/samples-review.js.map +1 -0
  158. package/dist/commands/task.d.ts +14 -0
  159. package/dist/commands/task.d.ts.map +1 -0
  160. package/dist/commands/task.js +92 -0
  161. package/dist/commands/task.js.map +1 -0
  162. package/dist/commands/trace.d.ts +19 -0
  163. package/dist/commands/trace.d.ts.map +1 -0
  164. package/dist/commands/trace.js +154 -0
  165. package/dist/commands/trace.js.map +1 -0
  166. package/dist/commands/trajectory.d.ts +11 -0
  167. package/dist/commands/trajectory.d.ts.map +1 -0
  168. package/dist/commands/trajectory.js +47 -0
  169. package/dist/commands/trajectory.js.map +1 -0
  170. package/dist/index.d.ts +9 -0
  171. package/dist/index.d.ts.map +1 -0
  172. package/dist/index.js +736 -0
  173. package/dist/index.js.map +1 -0
  174. package/dist/legacy/legacy-import.d.ts +15 -0
  175. package/dist/legacy/legacy-import.d.ts.map +1 -0
  176. package/dist/legacy/legacy-import.js +141 -0
  177. package/dist/legacy/legacy-import.js.map +1 -0
  178. package/dist/legacy/session-history-import.d.ts +26 -0
  179. package/dist/legacy/session-history-import.d.ts.map +1 -0
  180. package/dist/legacy/session-history-import.js +151 -0
  181. package/dist/legacy/session-history-import.js.map +1 -0
  182. package/dist/principle-tree-ledger-adapter.d.ts +12 -0
  183. package/dist/principle-tree-ledger-adapter.d.ts.map +1 -0
  184. package/dist/principle-tree-ledger-adapter.js +12 -0
  185. package/dist/principle-tree-ledger-adapter.js.map +1 -0
  186. package/dist/resolve-workspace.d.ts +12 -0
  187. package/dist/resolve-workspace.d.ts.map +1 -0
  188. package/dist/resolve-workspace.js +20 -0
  189. package/dist/resolve-workspace.js.map +1 -0
  190. package/dist/services/demo-story-a-runner.d.ts +8 -0
  191. package/dist/services/demo-story-a-runner.d.ts.map +1 -0
  192. package/dist/services/demo-story-a-runner.js +369 -0
  193. package/dist/services/demo-story-a-runner.js.map +1 -0
  194. package/dist/services/feature-flag-loader.d.ts +6 -0
  195. package/dist/services/feature-flag-loader.d.ts.map +1 -0
  196. package/dist/services/feature-flag-loader.js +54 -0
  197. package/dist/services/feature-flag-loader.js.map +1 -0
  198. package/dist/services/pain-flood-simulation-runner.d.ts +10 -0
  199. package/dist/services/pain-flood-simulation-runner.d.ts.map +1 -0
  200. package/dist/services/pain-flood-simulation-runner.js +289 -0
  201. package/dist/services/pain-flood-simulation-runner.js.map +1 -0
  202. package/dist/services/proven-channel-baseline-runner.d.ts +12 -0
  203. package/dist/services/proven-channel-baseline-runner.d.ts.map +1 -0
  204. package/dist/services/proven-channel-baseline-runner.js +114 -0
  205. package/dist/services/proven-channel-baseline-runner.js.map +1 -0
  206. package/dist/services/synthetic-baseline-runner.d.ts +8 -0
  207. package/dist/services/synthetic-baseline-runner.d.ts.map +1 -0
  208. package/dist/services/synthetic-baseline-runner.js +251 -0
  209. package/dist/services/synthetic-baseline-runner.js.map +1 -0
  210. package/package.json +35 -0
  211. package/src/commands/artifact.ts +82 -0
  212. package/src/commands/candidate.ts +1117 -0
  213. package/src/commands/central-sync.ts +44 -0
  214. package/src/commands/console.ts +121 -0
  215. package/src/commands/context.ts +72 -0
  216. package/src/commands/demo-story-a.ts +195 -0
  217. package/src/commands/diagnose.ts +452 -0
  218. package/src/commands/evolution-tasks-list.ts +44 -0
  219. package/src/commands/evolution-tasks-show.ts +60 -0
  220. package/src/commands/flow.ts +60 -0
  221. package/src/commands/health.ts +189 -0
  222. package/src/commands/history.ts +63 -0
  223. package/src/commands/legacy-cleanup.ts +206 -0
  224. package/src/commands/legacy-import.ts +104 -0
  225. package/src/commands/pain-record.ts +167 -0
  226. package/src/commands/proven-channel-baseline.ts +113 -0
  227. package/src/commands/remediation-output.ts +66 -0
  228. package/src/commands/run.ts +89 -0
  229. package/src/commands/runtime-activation.ts +176 -0
  230. package/src/commands/runtime-canary.ts +371 -0
  231. package/src/commands/runtime-diagnostics-export.ts +229 -0
  232. package/src/commands/runtime-features.ts +103 -0
  233. package/src/commands/runtime-gfi-snapshot.ts +135 -0
  234. package/src/commands/runtime-health-snapshot.ts +106 -0
  235. package/src/commands/runtime-internalization-enqueue-successors.ts +479 -0
  236. package/src/commands/runtime-internalization-integrity-repair.ts +69 -0
  237. package/src/commands/runtime-internalization-integrity.ts +63 -0
  238. package/src/commands/runtime-internalization-queue.ts +106 -0
  239. package/src/commands/runtime-internalization-run-once.ts +658 -0
  240. package/src/commands/runtime-internalization-wake-once.ts +87 -0
  241. package/src/commands/runtime-pain-flood-simulation.ts +121 -0
  242. package/src/commands/runtime-pruning.ts +438 -0
  243. package/src/commands/runtime-recovery.ts +107 -0
  244. package/src/commands/runtime-synthetic-baseline.ts +70 -0
  245. package/src/commands/runtime-uat.ts +339 -0
  246. package/src/commands/runtime.ts +281 -0
  247. package/src/commands/samples-list.ts +43 -0
  248. package/src/commands/samples-review.ts +32 -0
  249. package/src/commands/task.ts +130 -0
  250. package/src/commands/trace.ts +174 -0
  251. package/src/commands/trajectory.ts +64 -0
  252. package/src/index.ts +829 -0
  253. package/src/legacy/legacy-import.ts +179 -0
  254. package/src/legacy/session-history-import.ts +231 -0
  255. package/src/principle-tree-ledger-adapter.ts +13 -0
  256. package/src/resolve-workspace.ts +20 -0
  257. package/src/services/demo-story-a-runner.ts +472 -0
  258. package/src/services/feature-flag-loader.ts +73 -0
  259. package/src/services/pain-flood-simulation-runner.ts +354 -0
  260. package/src/services/proven-channel-baseline-runner.ts +150 -0
  261. package/src/services/synthetic-baseline-runner.ts +291 -0
  262. package/tests/commands/candidate-audit-repair.test.ts +338 -0
  263. package/tests/commands/candidate-intake.test.ts +589 -0
  264. package/tests/commands/candidate-internalization-backfill.test.ts +480 -0
  265. package/tests/commands/candidate-internalize.test.ts +272 -0
  266. package/tests/commands/candidate-route.test.ts +328 -0
  267. package/tests/commands/candidate-show.test.ts +95 -0
  268. package/tests/commands/cli-command-tree.test.ts +64 -0
  269. package/tests/commands/context.test.ts +114 -0
  270. package/tests/commands/demo-story-a.test.ts +255 -0
  271. package/tests/commands/diagnose.test.ts +792 -0
  272. package/tests/commands/health.test.ts +330 -0
  273. package/tests/commands/pain-record.test.ts +316 -0
  274. package/tests/commands/plugin-config-resolution-cutover.test.ts +220 -0
  275. package/tests/commands/proven-channel-baseline.test.ts +441 -0
  276. package/tests/commands/runtime-activation.test.ts +168 -0
  277. package/tests/commands/runtime-canary.test.ts +369 -0
  278. package/tests/commands/runtime-diagnostics-export.test.ts +170 -0
  279. package/tests/commands/runtime-features.test.ts +114 -0
  280. package/tests/commands/runtime-health-snapshot.test.ts +357 -0
  281. package/tests/commands/runtime-internalization-enqueue-successors.test.ts +803 -0
  282. package/tests/commands/runtime-internalization-integrity-repair.test.ts +169 -0
  283. package/tests/commands/runtime-internalization-integrity.test.ts +102 -0
  284. package/tests/commands/runtime-internalization-queue.test.ts +252 -0
  285. package/tests/commands/runtime-internalization-run-once.test.ts +1318 -0
  286. package/tests/commands/runtime-internalization-wake-once.test.ts +170 -0
  287. package/tests/commands/runtime-internalization.test.ts +52 -0
  288. package/tests/commands/runtime-pain-flood-simulation.test.ts +418 -0
  289. package/tests/commands/runtime-pruning.test.ts +693 -0
  290. package/tests/commands/runtime-recovery.test.ts +96 -0
  291. package/tests/commands/runtime-synthetic-baseline.test.ts +249 -0
  292. package/tests/commands/runtime-uat.test.ts +397 -0
  293. package/tests/commands/runtime.test.ts +262 -0
  294. package/tests/commands/trace.test.ts +314 -0
  295. package/tests/e2e/candidate-intake-e2e.test.ts +316 -0
  296. package/tests/services/feature-flag-loader.test.ts +207 -0
  297. package/tests/services/proven-channel-baseline-runner.test.ts +30 -0
  298. package/tsconfig.json +26 -0
@@ -0,0 +1,369 @@
1
+ import { RuntimeStateManager, ActivationDispatcher, PromptWriter, DeferArchiveWriter, RuleHostWriter, SqliteActivationStateStore, SqliteApprovalQueueStore, STORY_A_CHANNELS, makeRunId, makePrincipleArtifactRecord, makeRuleArtifactRecord, computeDemoStatus, buildFollowUpObservation, buildDemoNarrative, validateDemoChannels, evaluateDemoGoldenTrace, } from '@principles/core/runtime-v2';
2
+ function toSnapshot(record) {
3
+ return {
4
+ artifactId: record.artifactId,
5
+ artifactKind: record.artifactKind,
6
+ sourceTaskId: record.sourceTaskId,
7
+ sourcePrincipleId: record.sourcePrincipleId,
8
+ sourceRuleId: record.sourceRuleId,
9
+ lineageArtifactIds: record.lineageArtifactIds,
10
+ validationStatus: record.validationStatus,
11
+ contentJson: record.contentJson,
12
+ createdAt: record.createdAt,
13
+ updatedAt: record.updatedAt,
14
+ };
15
+ }
16
+ function makeArtifactReadModel(ctx) {
17
+ return {
18
+ getArtifactById: async (id) => {
19
+ const cached = ctx.snapshotCache.get(id);
20
+ if (cached)
21
+ return cached;
22
+ const record = await ctx.stateManager.piArtifactStore.getArtifactById(id);
23
+ if (!record)
24
+ return null;
25
+ const snapshot = toSnapshot(record);
26
+ ctx.snapshotCache.set(id, snapshot);
27
+ return snapshot;
28
+ },
29
+ };
30
+ }
31
+ async function dispatchChannel(channel, artifactRecord, ctx) {
32
+ const snapshot = toSnapshot(artifactRecord);
33
+ ctx.snapshotCache.set(artifactRecord.artifactId, snapshot);
34
+ const artifactReadModel = makeArtifactReadModel(ctx);
35
+ const activationStateStore = new SqliteActivationStateStore(ctx.stateManager.connection);
36
+ const approvalStore = new SqliteApprovalQueueStore(ctx.stateManager.connection);
37
+ const writers = channel === 'code_tool_hook'
38
+ ? [new RuleHostWriter({ gateDeps: { evaluateInSandbox: () => ({ success: true, failedCases: [], executionTimeMs: 1, forbiddenPatternViolations: [] }) } })]
39
+ : channel === 'prompt'
40
+ ? [new PromptWriter()]
41
+ : [new DeferArchiveWriter()];
42
+ const dispatcher = new ActivationDispatcher(artifactReadModel, activationStateStore, { writers, approvalQueueStore: approvalStore });
43
+ const dispatchInput = {
44
+ artifactId: artifactRecord.artifactId,
45
+ channel,
46
+ rolloutDecision: channel === 'code_tool_hook' ? 'require_approval' : 'auto_activate',
47
+ actor: { kind: 'human', userId: 'demo-owner' },
48
+ idempotencyKey: `story-a-${ctx.runId}::${channel}`,
49
+ now: new Date().toISOString(),
50
+ confirm: true,
51
+ };
52
+ const decision = await dispatcher.dispatch(dispatchInput);
53
+ const { approvalId } = decision;
54
+ return { dispatchDecision: decision, approvalId };
55
+ }
56
+ // Post-approval direct activation: the dispatcher routes code_tool_hook through the
57
+ // approval queue every time (isLowRiskChannel is false). No re-dispatch mechanism
58
+ // currently exists for approved items. Production will need an approval-completion
59
+ // orchestrator that re-dispatches or directly activates. This demo uses direct
60
+ // writer.activate() + recordActivation() to complete the flow after real approval.
61
+ // What this proves: SqliteApprovalQueueStore.approve() + RuleHostWriter.activate()
62
+ // + SqliteActivationStateStore.recordActivation() all work with real DB I/O.
63
+ // What this does NOT prove: that a production approval-completion orchestrator exists.
64
+ async function completePostApprovalActivation(approvalId, input) {
65
+ const { channel, artifactRecord, ctx } = input;
66
+ const approvalStore = new SqliteApprovalQueueStore(ctx.stateManager.connection);
67
+ const approveResult = await approvalStore.approve(approvalId, 'demo-owner', 'Demo: owner approves RuleHost activation');
68
+ if (!approveResult.ok) {
69
+ return { decision: 'refused', reason: `approval_failed: ${approveResult.error}`, channel };
70
+ }
71
+ const snapshot = toSnapshot(artifactRecord);
72
+ ctx.snapshotCache.set(artifactRecord.artifactId, snapshot);
73
+ const writer = new RuleHostWriter({ gateDeps: { evaluateInSandbox: () => ({ success: true, failedCases: [], executionTimeMs: 1, forbiddenPatternViolations: [] }) } });
74
+ const activationStateStore = new SqliteActivationStateStore(ctx.stateManager.connection);
75
+ const idempotencyKey = `story-a-${ctx.runId}::${channel}::post-approval`;
76
+ const now = new Date().toISOString();
77
+ const principleId = artifactRecord.sourcePrincipleId ?? 'unknown';
78
+ const writerResult = await writer.activate({ artifactId: artifactRecord.artifactId, channel, principleId, idempotencyKey, now }, snapshot);
79
+ await activationStateStore.recordActivation({
80
+ activationId: writerResult.activationId,
81
+ idempotencyKey,
82
+ artifactId: artifactRecord.artifactId,
83
+ channel,
84
+ action: writerResult.action,
85
+ targetRef: writerResult.targetRef,
86
+ activatedAt: now,
87
+ });
88
+ return {
89
+ decision: 'activated',
90
+ activationId: writerResult.activationId,
91
+ action: writerResult.action,
92
+ targetRef: writerResult.targetRef,
93
+ };
94
+ }
95
+ function classifyDecision(decision) {
96
+ if (decision.decision === 'activated' || decision.decision === 'would_activate')
97
+ return 'activated';
98
+ if (decision.decision === 'queued_for_approval')
99
+ return 'queued';
100
+ if (decision.decision === 'refused' || decision.decision === 'invalid_artifact')
101
+ return 'refused';
102
+ if (decision.decision === 'already_activated')
103
+ return 'already';
104
+ return 'other';
105
+ }
106
+ async function runChannelOutcome(input) {
107
+ const { channel, principleRecord, ruleRecord, ctx } = input;
108
+ const artifactRecord = channel === 'code_tool_hook' ? ruleRecord : principleRecord;
109
+ const principleId = principleRecord.sourcePrincipleId ?? 'unknown';
110
+ const riskLevel = channel === 'code_tool_hook' ? 'high' : 'low';
111
+ try {
112
+ const { dispatchDecision: firstDecision, approvalId } = await dispatchChannel(channel, artifactRecord, ctx);
113
+ // For code_tool_hook: first dispatch queues for approval.
114
+ // Demo explicitly approves and activates to complete activation.
115
+ if (channel === 'code_tool_hook' && classifyDecision(firstDecision) === 'queued' && approvalId) {
116
+ const postApprovalDecision = await completePostApprovalActivation(approvalId, { channel, artifactRecord, ctx });
117
+ if (classifyDecision(postApprovalDecision) === 'activated') {
118
+ return {
119
+ channel,
120
+ status: 'passed',
121
+ activationDecision: postApprovalDecision,
122
+ canActivateResult: { ok: true, riskLevel },
123
+ evidence: {
124
+ approvalId,
125
+ approvedBy: 'demo-owner',
126
+ activationId: postApprovalDecision.activationId,
127
+ path: 'dispatch→queued → real_approve → direct_activate→record',
128
+ note: 'Post-approval uses direct writer.activate() (no production orchestrator yet)',
129
+ },
130
+ evidenceSource: `ActivationDispatcher.dispatch→queued + SqliteApprovalQueueStore.approve + RuleHostWriter.activate + SqliteActivationStateStore.recordActivation`,
131
+ principleId,
132
+ };
133
+ }
134
+ // Approval succeeded but activation failed
135
+ return {
136
+ channel,
137
+ status: 'degraded',
138
+ activationDecision: postApprovalDecision,
139
+ canActivateResult: { ok: true, riskLevel },
140
+ evidence: {
141
+ approvalId,
142
+ approvedBy: 'demo-owner',
143
+ activationDecision: postApprovalDecision.decision,
144
+ },
145
+ evidenceSource: 'ActivationDispatcher.dispatch→queued + SqliteApprovalQueueStore.approve + RuleHostWriter.activate (activation incomplete)',
146
+ principleId,
147
+ failureReason: `RuleHost approved but post-activation dispatch returned: ${postApprovalDecision.decision}`,
148
+ nextAction: 'Check RuleHost writer canActivate and artifact contract',
149
+ };
150
+ }
151
+ const kind = classifyDecision(firstDecision);
152
+ if (kind === 'activated') {
153
+ return {
154
+ channel,
155
+ status: 'passed',
156
+ activationDecision: firstDecision,
157
+ canActivateResult: { ok: true, riskLevel },
158
+ evidence: {
159
+ activationId: firstDecision.activationId,
160
+ },
161
+ evidenceSource: `ActivationDispatcher.dispatch → ${channel === 'prompt' ? 'PromptWriter' : 'DeferArchiveWriter'}`,
162
+ principleId,
163
+ };
164
+ }
165
+ if (kind === 'already') {
166
+ return {
167
+ channel,
168
+ status: 'passed',
169
+ activationDecision: firstDecision,
170
+ canActivateResult: { ok: true, riskLevel },
171
+ evidence: { activationId: firstDecision.activationId },
172
+ evidenceSource: `ActivationDispatcher.dispatch → ${channel} (idempotent)`,
173
+ principleId,
174
+ };
175
+ }
176
+ // refused or other
177
+ const refusedReason = firstDecision.decision === 'refused'
178
+ ? firstDecision.reason
179
+ : firstDecision.decision;
180
+ return {
181
+ channel,
182
+ status: 'failed',
183
+ activationDecision: firstDecision,
184
+ canActivateResult: { ok: false, reason: refusedReason, riskLevel },
185
+ evidence: { decision: firstDecision },
186
+ evidenceSource: 'ActivationDispatcher.dispatch',
187
+ principleId,
188
+ failureReason: `Channel ${channel} dispatch refused: ${refusedReason}`,
189
+ nextAction: `Check ${channel} writer canActivate and artifact contract`,
190
+ };
191
+ }
192
+ catch (err) {
193
+ const msg = err instanceof Error ? err.message : String(err);
194
+ return {
195
+ channel,
196
+ status: 'failed',
197
+ activationDecision: { decision: 'refused', reason: 'demo_exception', channel },
198
+ canActivateResult: { ok: false, reason: 'exception', riskLevel },
199
+ evidence: { error: msg },
200
+ evidenceSource: 'exception',
201
+ principleId,
202
+ failureReason: `Channel ${channel} threw: ${msg}`,
203
+ nextAction: `Inspect ${channel} demo exception`,
204
+ };
205
+ }
206
+ }
207
+ export async function runStoryADemo(opts) {
208
+ const runId = makeRunId(opts);
209
+ const generatedAt = new Date().toISOString();
210
+ const channels = opts.channels ?? [...STORY_A_CHANNELS];
211
+ // Input validation
212
+ const validationFailure = validateDemoChannels(channels);
213
+ if (validationFailure) {
214
+ const isUnknown = validationFailure.reason === 'unknown_channels';
215
+ return {
216
+ status: 'failed',
217
+ generatedAt,
218
+ narrative: `Story A' demo failed: ${validationFailure.reason}.`,
219
+ storyDescription: isUnknown ? `Unknown channels: ${validationFailure.unknownChannels.join(', ')}` : 'Demo requires at least one MVP channel.',
220
+ stages: [],
221
+ channelOutcomes: [],
222
+ isRuntimeV2Exclusive: true,
223
+ workspaceDir: opts.workspaceDir,
224
+ inputValidationFailure: validationFailure,
225
+ };
226
+ }
227
+ const stateManager = new RuntimeStateManager({ workspaceDir: opts.workspaceDir });
228
+ await stateManager.initialize();
229
+ try {
230
+ // Persist artifacts to real workspace DB
231
+ const principleRecord = makePrincipleArtifactRecord(runId);
232
+ const ruleRecord = makeRuleArtifactRecord(runId, principleRecord);
233
+ await stateManager.piArtifactStore.createArtifact(principleRecord);
234
+ await stateManager.piArtifactStore.createArtifact(ruleRecord);
235
+ const principleId = principleRecord.sourcePrincipleId ?? `demo-principle-${runId}`;
236
+ const snapshotCache = new Map();
237
+ const ctx = { stateManager, snapshotCache, runId };
238
+ const stages = [];
239
+ // Stage 1: Evidence seed — verify artifacts exist in DB
240
+ const storedPrinciple = await stateManager.piArtifactStore.getArtifactById(principleRecord.artifactId);
241
+ stages.push({
242
+ name: 'evidence_seed',
243
+ status: storedPrinciple ? 'passed' : 'failed',
244
+ evidenceRef: `pain://demo-${runId}`,
245
+ evidence: {
246
+ painId: `demo-${runId}`,
247
+ reason: 'Agent repeatedly wrote to /etc/passwd despite owner corrections',
248
+ occurrenceCount: 3,
249
+ evidenceType: 'repeated_owner_correction',
250
+ artifactPersisted: !!storedPrinciple,
251
+ artifactId: principleRecord.artifactId,
252
+ simulated: true,
253
+ simulatedNote: 'Pain evidence is a narrative fixture; artifact persistence is real DB I/O',
254
+ },
255
+ ...(storedPrinciple ? {} : {
256
+ reason: 'Failed to persist principle artifact to workspace DB',
257
+ nextAction: 'Check workspace directory permissions and state.db',
258
+ }),
259
+ });
260
+ // Stage 2: Principle proposal — verify both artifacts queryable
261
+ const storedRule = await stateManager.piArtifactStore.getArtifactById(ruleRecord.artifactId);
262
+ stages.push({
263
+ name: 'principle_proposal',
264
+ status: storedRule ? 'passed' : 'failed',
265
+ evidenceRef: principleRecord.artifactId,
266
+ evidence: {
267
+ artifactId: principleRecord.artifactId,
268
+ principleId,
269
+ principleText: 'Prevent writing to system-critical directories',
270
+ confidence: 0.95,
271
+ ruleArtifactId: ruleRecord.artifactId,
272
+ rulePersisted: !!storedRule,
273
+ },
274
+ ...(storedRule ? {} : {
275
+ reason: 'Failed to persist rule artifact to workspace DB',
276
+ nextAction: 'Check workspace directory permissions and state.db',
277
+ }),
278
+ });
279
+ // Stage 3: Owner review (demo owner approves)
280
+ stages.push({
281
+ name: 'owner_review',
282
+ status: 'passed',
283
+ evidenceRef: `review-${runId}`,
284
+ evidence: {
285
+ ownerDecided: true,
286
+ decidedBy: 'demo-owner',
287
+ decision: 'approve',
288
+ availableChannels: ['prompt', 'code_tool_hook', 'defer_archive'],
289
+ note: 'Demo: owner approves the principle for all three MVP channels',
290
+ simulated: true,
291
+ simulatedNote: 'Owner decision is a scripted approval; no real human review',
292
+ },
293
+ });
294
+ // Stage 4: Activation (per channel, with real dispatcher + real DB)
295
+ const channelOutcomes = [];
296
+ for (const channel of channels) {
297
+ channelOutcomes.push(await runChannelOutcome({ channel, principleRecord, ruleRecord, ctx }));
298
+ }
299
+ const activationPassed = channelOutcomes.every(o => o.status === 'passed');
300
+ stages.push({
301
+ name: 'activation',
302
+ status: activationPassed ? 'passed' : channelOutcomes.some(o => o.status === 'failed') ? 'failed' : 'degraded',
303
+ evidenceRef: `activation-${runId}`,
304
+ evidence: {
305
+ channelsActivated: channelOutcomes.map(o => ({
306
+ channel: o.channel,
307
+ decision: o.activationDecision.decision,
308
+ evidenceSource: o.evidenceSource,
309
+ })),
310
+ simulated: false,
311
+ },
312
+ ...(activationPassed ? {} : {
313
+ reason: `Some channels did not pass: ${channelOutcomes.filter(o => o.status !== 'passed').map(o => o.channel).join(', ')}`,
314
+ nextAction: 'Check individual channel outcomes for failure details',
315
+ }),
316
+ });
317
+ // Stage 5: Follow-up observation
318
+ const followUpEvidences = channelOutcomes.map(o => {
319
+ const sandboxResult = o.channel === 'code_tool_hook'
320
+ ? evaluateDemoGoldenTrace(ruleRecord)
321
+ : undefined;
322
+ return {
323
+ channel: o.channel,
324
+ ...buildFollowUpObservation(o.channel, o, sandboxResult).evidence,
325
+ };
326
+ });
327
+ const followUpPassed = channelOutcomes.every(o => o.status === 'passed');
328
+ stages.push({
329
+ name: 'follow_up_observation',
330
+ status: followUpPassed ? 'passed' : 'degraded',
331
+ evidenceRef: `followup-${runId}`,
332
+ evidence: { observations: followUpEvidences, simulated: false },
333
+ ...(followUpPassed ? {} : {
334
+ reason: 'Some follow-up observations degraded',
335
+ nextAction: 'Check channel outcomes',
336
+ }),
337
+ });
338
+ // Stage 6: Rollback proof
339
+ stages.push({
340
+ name: 'rollback_proof',
341
+ status: 'passed',
342
+ evidenceRef: `rollback-${runId}`,
343
+ evidence: {
344
+ rollbackAvailable: true,
345
+ paths: [
346
+ { channel: 'prompt', method: 'Principle can be deactivated via ledger update' },
347
+ { channel: 'code_tool_hook', method: 'Rule can be removed from tool hook registry' },
348
+ { channel: 'defer_archive', method: 'Archived principle can be reactivated if needed' },
349
+ ],
350
+ },
351
+ });
352
+ const status = computeDemoStatus(stages, channelOutcomes);
353
+ const narrative = buildDemoNarrative({ runId, principleId, channels, channelOutcomes });
354
+ return {
355
+ status,
356
+ generatedAt,
357
+ narrative,
358
+ storyDescription: 'Demo proves: (1) artifact persistence via SqlitePIArtifactStore, (2) activation dispatch via ActivationDispatcher.dispatch() with real gate logic, (3) approval queue via SqliteApprovalQueueStore.approve() + direct writer activation, (4) sandbox enforcement via evaluateInRefinerSandbox against golden trace. Evidence seed and owner review are narrative fixtures (simulated: true).',
359
+ stages,
360
+ channelOutcomes,
361
+ isRuntimeV2Exclusive: true,
362
+ workspaceDir: opts.workspaceDir,
363
+ };
364
+ }
365
+ finally {
366
+ await stateManager.close();
367
+ }
368
+ }
369
+ //# sourceMappingURL=demo-story-a-runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"demo-story-a-runner.js","sourceRoot":"","sources":["../../src/services/demo-story-a-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,0BAA0B,EAC1B,wBAAwB,EACxB,gBAAgB,EAChB,SAAS,EACT,2BAA2B,EAC3B,sBAAsB,EACtB,iBAAiB,EACjB,wBAAwB,EACx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export declare const FEATURE_FLAGS_CONFIG_FILENAME = "feature-flags.yaml";
3
+ export declare const FEATURE_FLAGS_CONFIG_DIR = ".pd";
4
+ export declare function getFeatureFlagsConfigPath(workspaceDir: string): string;
5
+ export declare function loadEffectiveFeatureFlags(workspaceDir: string): EffectiveFeatureFlags;
6
+ //# sourceMappingURL=feature-flag-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature-flag-loader.d.ts","sourceRoot":"","sources":["../../src/services/feature-flag-loader.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEzE,eAAO,MAAM,6BAA6B,uBAAuB,CAAC;AAClE,eAAO,MAAM,wBAAwB,QAAQ,CAAC;AAQ9C,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,GAAG,qBAAqB,CAkDrF"}
@@ -0,0 +1,54 @@
1
+ import * as path from 'path';
2
+ import * as fs from 'fs';
3
+ import * as yaml from 'js-yaml';
4
+ import { computeEffectiveFlags, DEFAULT_FEATURE_FLAGS, } from '@principles/core/runtime-v2';
5
+ export const FEATURE_FLAGS_CONFIG_FILENAME = 'feature-flags.yaml';
6
+ export const FEATURE_FLAGS_CONFIG_DIR = '.pd';
7
+ const DANGEROUS_KEYS = new Set(['__proto__', 'constructor', 'prototype']);
8
+ function isRecord(value) {
9
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
10
+ }
11
+ export function getFeatureFlagsConfigPath(workspaceDir) {
12
+ return path.join(workspaceDir, FEATURE_FLAGS_CONFIG_DIR, FEATURE_FLAGS_CONFIG_FILENAME);
13
+ }
14
+ export function loadEffectiveFeatureFlags(workspaceDir) {
15
+ const configPath = getFeatureFlagsConfigPath(workspaceDir);
16
+ if (!fs.existsSync(configPath)) {
17
+ return computeEffectiveFlags({}, DEFAULT_FEATURE_FLAGS, configPath);
18
+ }
19
+ const raw = fs.readFileSync(configPath, 'utf8');
20
+ // eslint-disable-next-line @typescript-eslint/init-declarations -- reassigned in try block below
21
+ let parsed;
22
+ try {
23
+ parsed = yaml.load(raw, { schema: yaml.JSON_SCHEMA });
24
+ }
25
+ catch {
26
+ return {
27
+ ...computeEffectiveFlags({}, DEFAULT_FEATURE_FLAGS, configPath),
28
+ warnings: ['feature-flags.yaml: YAML parse error, using defaults'],
29
+ };
30
+ }
31
+ if (parsed === null || parsed === undefined || typeof parsed !== 'object' || Array.isArray(parsed)) {
32
+ return {
33
+ ...computeEffectiveFlags({}, DEFAULT_FEATURE_FLAGS, configPath),
34
+ warnings: ['feature-flags.yaml: expected a mapping, using defaults'],
35
+ };
36
+ }
37
+ const parsedRecord = Object.create(null);
38
+ const warnings = [];
39
+ for (const key of Object.keys(parsed)) {
40
+ if (DANGEROUS_KEYS.has(key)) {
41
+ warnings.push(`feature-flags.yaml: dangerous key '${key}' rejected`);
42
+ continue;
43
+ }
44
+ if (Object.hasOwn(parsed, key) && isRecord(parsed)) {
45
+ parsedRecord[key] = parsed[key];
46
+ }
47
+ }
48
+ const result = computeEffectiveFlags(parsedRecord, DEFAULT_FEATURE_FLAGS, configPath);
49
+ if (warnings.length > 0) {
50
+ result.warnings = [...warnings, ...result.warnings];
51
+ }
52
+ return result;
53
+ }
54
+ //# sourceMappingURL=feature-flag-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature-flag-loader.js","sourceRoot":"","sources":["../../src/services/feature-flag-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAChC,OAAO,EACL,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,6BAA6B,CAAC;AAGrC,MAAM,CAAC,MAAM,6BAA6B,GAAG,oBAAoB,CAAC;AAClE,MAAM,CAAC,MAAM,wB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L,GAAG,qBAAqB,CAAC,EAAE,EAAE,qBAAqB,EAAE,UAAU,CAAC;YAC/D,QAAQ,EAAE,CAAC,wDAAwD,CAAC;SACrE,CAAC;IACJ,CAAC;IAED,MAAM,YAAY,GAA4B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClE,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,IAAI,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAC5B,QAAQ,CAAC,IAAI,CAAC,sCAAsC,GAAG,YAAY,CAAC,CAAC;YACrE,SAAS;QACX,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACnD,YAAY,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG,qBAAqB,CAClC,YAAY,EACZ,qBAAqB,EACrB,UAAU,CACX,CAAC;IAEF,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,CAAC,QAAQ,GAAG,CAAC,GAAG,QAAQ,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { PainFloodSimulationSummary } from '@principles/core/runtime-v2';
2
+ export interface PainFloodSimulationRunnerOptions {
3
+ workspaceDir: string;
4
+ workspaceMode: 'temp' | 'explicit_workspace';
5
+ identicalCount?: number;
6
+ similarCount?: number;
7
+ stressCount?: number;
8
+ }
9
+ export declare function runPainFloodSimulation(opts: PainFloodSimulationRunnerOptions): Promise<PainFloodSimulationSummary>;
10
+ //# sourceMappingURL=pain-flood-simulation-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pain-flood-simulation-runner.d.ts","sourceRoot":"","sources":["../../src/services/pain-flood-simulation-runner.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACV,0BAA0B,EAG3B,MAAM,6BAA6B,CAAC;AAarC,MAAM,WAAW,gCAAgC;IAC/C,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,GAAG,oBAAoB,CAAC;IAC7C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AA4GD,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,gCAAgC,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAgNxH"}