wicked-crew 0.7.46 → 0.7.48

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 (263) hide show
  1. package/dist/api/capture.d.ts +2 -2
  2. package/dist/api/chat-citations.d.ts +10 -1
  3. package/dist/api/chat-citations.d.ts.map +1 -1
  4. package/dist/api/chat-citations.js +28 -0
  5. package/dist/api/chat-citations.js.map +1 -1
  6. package/dist/api/chat-scope.d.ts +4 -2
  7. package/dist/api/chat-scope.d.ts.map +1 -1
  8. package/dist/api/chat-scope.js +35 -3
  9. package/dist/api/chat-scope.js.map +1 -1
  10. package/dist/api/chat-transcripts.d.ts +23 -1
  11. package/dist/api/chat-transcripts.d.ts.map +1 -1
  12. package/dist/api/chat-transcripts.js +61 -6
  13. package/dist/api/chat-transcripts.js.map +1 -1
  14. package/dist/api/delivery-index.d.ts +21 -0
  15. package/dist/api/delivery-index.d.ts.map +1 -1
  16. package/dist/api/delivery-index.js +36 -0
  17. package/dist/api/delivery-index.js.map +1 -1
  18. package/dist/api/elicitation-cache.d.ts +12 -0
  19. package/dist/api/elicitation-cache.d.ts.map +1 -1
  20. package/dist/api/elicitation-cache.js +17 -1
  21. package/dist/api/elicitation-cache.js.map +1 -1
  22. package/dist/api/eval-sample.d.ts +12 -12
  23. package/dist/api/governance-steering.d.ts.map +1 -1
  24. package/dist/api/governance-steering.js +1 -0
  25. package/dist/api/governance-steering.js.map +1 -1
  26. package/dist/api/mcp.d.ts +4 -4
  27. package/dist/api/policy-landing.d.ts +55 -0
  28. package/dist/api/policy-landing.d.ts.map +1 -0
  29. package/dist/api/policy-landing.js +174 -0
  30. package/dist/api/policy-landing.js.map +1 -0
  31. package/dist/api/recording.d.ts +228 -0
  32. package/dist/api/recording.d.ts.map +1 -0
  33. package/dist/api/recording.js +1140 -0
  34. package/dist/api/recording.js.map +1 -0
  35. package/dist/api/routes.d.ts +42 -39
  36. package/dist/api/routes.d.ts.map +1 -1
  37. package/dist/api/routes.js +362 -107
  38. package/dist/api/routes.js.map +1 -1
  39. package/dist/api/run-timing-index.d.ts +17 -0
  40. package/dist/api/run-timing-index.d.ts.map +1 -1
  41. package/dist/api/run-timing-index.js +43 -1
  42. package/dist/api/run-timing-index.js.map +1 -1
  43. package/dist/api/server.d.ts +27 -0
  44. package/dist/api/server.d.ts.map +1 -1
  45. package/dist/api/server.js +168 -4
  46. package/dist/api/server.js.map +1 -1
  47. package/dist/api/testing.d.ts +4 -4
  48. package/dist/api/testing.d.ts.map +1 -1
  49. package/dist/api/testing.js +3 -0
  50. package/dist/api/testing.js.map +1 -1
  51. package/dist/api/watch-routes.d.ts +30 -0
  52. package/dist/api/watch-routes.d.ts.map +1 -0
  53. package/dist/api/watch-routes.js +104 -0
  54. package/dist/api/watch-routes.js.map +1 -0
  55. package/dist/campaigns/routes.d.ts +2 -2
  56. package/dist/cli/index.d.ts.map +1 -1
  57. package/dist/cli/index.js +20 -2
  58. package/dist/cli/index.js.map +1 -1
  59. package/dist/core/adapter.d.ts +52 -1
  60. package/dist/core/adapter.d.ts.map +1 -1
  61. package/dist/core/adapter.js +193 -5
  62. package/dist/core/adapter.js.map +1 -1
  63. package/dist/core/run-identity.js +1 -1
  64. package/dist/core/run-identity.js.map +1 -1
  65. package/dist/core/walkthrough-root.d.ts +21 -0
  66. package/dist/core/walkthrough-root.d.ts.map +1 -0
  67. package/dist/core/walkthrough-root.js +66 -0
  68. package/dist/core/walkthrough-root.js.map +1 -0
  69. package/dist/decisions/chat-recorder.d.ts +129 -0
  70. package/dist/decisions/chat-recorder.d.ts.map +1 -0
  71. package/dist/decisions/chat-recorder.js +367 -0
  72. package/dist/decisions/chat-recorder.js.map +1 -0
  73. package/dist/decisions/consider.d.ts +102 -0
  74. package/dist/decisions/consider.d.ts.map +1 -0
  75. package/dist/decisions/consider.js +207 -0
  76. package/dist/decisions/consider.js.map +1 -0
  77. package/dist/decisions/derive.d.ts +79 -0
  78. package/dist/decisions/derive.d.ts.map +1 -0
  79. package/dist/decisions/derive.js +282 -0
  80. package/dist/decisions/derive.js.map +1 -0
  81. package/dist/decisions/events.d.ts +25 -0
  82. package/dist/decisions/events.d.ts.map +1 -0
  83. package/dist/decisions/events.js +24 -0
  84. package/dist/decisions/events.js.map +1 -0
  85. package/dist/decisions/ingest.d.ts +51 -0
  86. package/dist/decisions/ingest.d.ts.map +1 -0
  87. package/dist/decisions/ingest.js +100 -0
  88. package/dist/decisions/ingest.js.map +1 -0
  89. package/dist/decisions/land.d.ts +100 -0
  90. package/dist/decisions/land.d.ts.map +1 -0
  91. package/dist/decisions/land.js +466 -0
  92. package/dist/decisions/land.js.map +1 -0
  93. package/dist/decisions/ledger.d.ts +60 -0
  94. package/dist/decisions/ledger.d.ts.map +1 -0
  95. package/dist/decisions/ledger.js +246 -0
  96. package/dist/decisions/ledger.js.map +1 -0
  97. package/dist/decisions/routes.d.ts +10 -0
  98. package/dist/decisions/routes.d.ts.map +1 -0
  99. package/dist/decisions/routes.js +141 -0
  100. package/dist/decisions/routes.js.map +1 -0
  101. package/dist/decisions/rules-text.d.ts +21 -0
  102. package/dist/decisions/rules-text.d.ts.map +1 -0
  103. package/dist/decisions/rules-text.js +50 -0
  104. package/dist/decisions/rules-text.js.map +1 -0
  105. package/dist/decisions/types.d.ts +120 -0
  106. package/dist/decisions/types.d.ts.map +1 -0
  107. package/dist/decisions/types.js +19 -0
  108. package/dist/decisions/types.js.map +1 -0
  109. package/dist/editors/csp.d.ts +31 -0
  110. package/dist/editors/csp.d.ts.map +1 -0
  111. package/dist/editors/csp.js +46 -0
  112. package/dist/editors/csp.js.map +1 -0
  113. package/dist/editors/pack-install.d.ts +28 -0
  114. package/dist/editors/pack-install.d.ts.map +1 -0
  115. package/dist/editors/pack-install.js +153 -0
  116. package/dist/editors/pack-install.js.map +1 -0
  117. package/dist/editors/registry.d.ts +142 -0
  118. package/dist/editors/registry.d.ts.map +1 -0
  119. package/dist/editors/registry.js +255 -0
  120. package/dist/editors/registry.js.map +1 -0
  121. package/dist/editors/routes.d.ts +46 -0
  122. package/dist/editors/routes.d.ts.map +1 -0
  123. package/dist/editors/routes.js +166 -0
  124. package/dist/editors/routes.js.map +1 -0
  125. package/dist/interactive/bridge-pool.d.ts +7 -2
  126. package/dist/interactive/bridge-pool.d.ts.map +1 -1
  127. package/dist/interactive/bridge-pool.js +6 -1
  128. package/dist/interactive/bridge-pool.js.map +1 -1
  129. package/dist/interactive/draft-events.d.ts.map +1 -1
  130. package/dist/interactive/draft-events.js +1 -0
  131. package/dist/interactive/draft-events.js.map +1 -1
  132. package/dist/interactive/theme-events.d.ts +119 -0
  133. package/dist/interactive/theme-events.d.ts.map +1 -0
  134. package/dist/interactive/theme-events.js +606 -0
  135. package/dist/interactive/theme-events.js.map +1 -0
  136. package/dist/projects/events.d.ts.map +1 -1
  137. package/dist/projects/events.js +2 -1
  138. package/dist/projects/events.js.map +1 -1
  139. package/dist/projects/routes.d.ts +2 -2
  140. package/dist/projects/state-home-preflight.d.ts.map +1 -1
  141. package/dist/projects/state-home-preflight.js +3 -0
  142. package/dist/projects/state-home-preflight.js.map +1 -1
  143. package/dist/projects/state-home-registry.d.ts.map +1 -1
  144. package/dist/projects/state-home-registry.js +2 -0
  145. package/dist/projects/state-home-registry.js.map +1 -1
  146. package/dist/projects/state-home.d.ts +6 -0
  147. package/dist/projects/state-home.d.ts.map +1 -1
  148. package/dist/projects/state-home.js +28 -1
  149. package/dist/projects/state-home.js.map +1 -1
  150. package/dist/qe/acceptance.d.ts +45 -4
  151. package/dist/qe/acceptance.d.ts.map +1 -1
  152. package/dist/qe/acceptance.js +93 -4
  153. package/dist/qe/acceptance.js.map +1 -1
  154. package/dist/qe/ledger.d.ts +20 -0
  155. package/dist/qe/ledger.d.ts.map +1 -1
  156. package/dist/qe/ledger.js +34 -0
  157. package/dist/qe/ledger.js.map +1 -1
  158. package/dist/qe/walkthrough-acceptance.d.ts +82 -0
  159. package/dist/qe/walkthrough-acceptance.d.ts.map +1 -0
  160. package/dist/qe/walkthrough-acceptance.js +248 -0
  161. package/dist/qe/walkthrough-acceptance.js.map +1 -0
  162. package/dist/skills/base-skill.d.ts.map +1 -1
  163. package/dist/skills/base-skill.js +3 -2
  164. package/dist/skills/base-skill.js.map +1 -1
  165. package/dist/skills/plugin-source.d.ts +19 -1
  166. package/dist/skills/plugin-source.d.ts.map +1 -1
  167. package/dist/skills/plugin-source.js +31 -2
  168. package/dist/skills/plugin-source.js.map +1 -1
  169. package/dist/skills/runtime.d.ts +11 -2
  170. package/dist/skills/runtime.d.ts.map +1 -1
  171. package/dist/skills/runtime.js +29 -1
  172. package/dist/skills/runtime.js.map +1 -1
  173. package/dist/skills/store.d.ts +14 -1
  174. package/dist/skills/store.d.ts.map +1 -1
  175. package/dist/skills/store.js +19 -5
  176. package/dist/skills/store.js.map +1 -1
  177. package/dist/standing-orders/routes.d.ts +22 -22
  178. package/dist/standing-orders/store.d.ts +10 -10
  179. package/dist/watch/checks/check-failed.d.ts +24 -0
  180. package/dist/watch/checks/check-failed.d.ts.map +1 -0
  181. package/dist/watch/checks/check-failed.js +56 -0
  182. package/dist/watch/checks/check-failed.js.map +1 -0
  183. package/dist/watch/checks/claim-vs-evidence.d.ts +30 -0
  184. package/dist/watch/checks/claim-vs-evidence.d.ts.map +1 -0
  185. package/dist/watch/checks/claim-vs-evidence.js +152 -0
  186. package/dist/watch/checks/claim-vs-evidence.js.map +1 -0
  187. package/dist/watch/checks/deliver-audit.d.ts +19 -0
  188. package/dist/watch/checks/deliver-audit.d.ts.map +1 -0
  189. package/dist/watch/checks/deliver-audit.js +129 -0
  190. package/dist/watch/checks/deliver-audit.js.map +1 -0
  191. package/dist/watch/checks/index.d.ts +8 -0
  192. package/dist/watch/checks/index.d.ts.map +1 -0
  193. package/dist/watch/checks/index.js +24 -0
  194. package/dist/watch/checks/index.js.map +1 -0
  195. package/dist/watch/checks/lag.d.ts +24 -0
  196. package/dist/watch/checks/lag.d.ts.map +1 -0
  197. package/dist/watch/checks/lag.js +55 -0
  198. package/dist/watch/checks/lag.js.map +1 -0
  199. package/dist/watch/checks/quiet-after-claim.d.ts +17 -0
  200. package/dist/watch/checks/quiet-after-claim.d.ts.map +1 -0
  201. package/dist/watch/checks/quiet-after-claim.js +89 -0
  202. package/dist/watch/checks/quiet-after-claim.js.map +1 -0
  203. package/dist/watch/checks/ungated.d.ts +12 -0
  204. package/dist/watch/checks/ungated.d.ts.map +1 -0
  205. package/dist/watch/checks/ungated.js +64 -0
  206. package/dist/watch/checks/ungated.js.map +1 -0
  207. package/dist/watch/checks/warned-rule.d.ts +26 -0
  208. package/dist/watch/checks/warned-rule.d.ts.map +1 -0
  209. package/dist/watch/checks/warned-rule.js +126 -0
  210. package/dist/watch/checks/warned-rule.js.map +1 -0
  211. package/dist/watch/emit.d.ts +122 -0
  212. package/dist/watch/emit.d.ts.map +1 -0
  213. package/dist/watch/emit.js +443 -0
  214. package/dist/watch/emit.js.map +1 -0
  215. package/dist/watch/events.d.ts +21 -0
  216. package/dist/watch/events.d.ts.map +1 -0
  217. package/dist/watch/events.js +21 -0
  218. package/dist/watch/events.js.map +1 -0
  219. package/dist/watch/keys.d.ts +15 -0
  220. package/dist/watch/keys.d.ts.map +1 -0
  221. package/dist/watch/keys.js +23 -0
  222. package/dist/watch/keys.js.map +1 -0
  223. package/dist/watch/lanes.d.ts +41 -0
  224. package/dist/watch/lanes.d.ts.map +1 -0
  225. package/dist/watch/lanes.js +73 -0
  226. package/dist/watch/lanes.js.map +1 -0
  227. package/dist/watch/loader.d.ts +47 -0
  228. package/dist/watch/loader.d.ts.map +1 -0
  229. package/dist/watch/loader.js +178 -0
  230. package/dist/watch/loader.js.map +1 -0
  231. package/dist/watch/registry.d.ts +166 -0
  232. package/dist/watch/registry.d.ts.map +1 -0
  233. package/dist/watch/registry.js +589 -0
  234. package/dist/watch/registry.js.map +1 -0
  235. package/dist/watch/ring.d.ts +32 -0
  236. package/dist/watch/ring.d.ts.map +1 -0
  237. package/dist/watch/ring.js +90 -0
  238. package/dist/watch/ring.js.map +1 -0
  239. package/dist/watch/router.d.ts +25 -0
  240. package/dist/watch/router.d.ts.map +1 -0
  241. package/dist/watch/router.js +87 -0
  242. package/dist/watch/router.js.map +1 -0
  243. package/dist/watch/sources.d.ts +42 -0
  244. package/dist/watch/sources.d.ts.map +1 -0
  245. package/dist/watch/sources.js +104 -0
  246. package/dist/watch/sources.js.map +1 -0
  247. package/dist/watch/types.d.ts +129 -0
  248. package/dist/watch/types.d.ts.map +1 -0
  249. package/dist/watch/types.js +6 -0
  250. package/dist/watch/types.js.map +1 -0
  251. package/endpoint-manifest.json +272 -1
  252. package/package.json +3 -2
  253. package/watch/entries/claim-vs-evidence.json +13 -0
  254. package/watch/entries/deliver-audit.json +17 -0
  255. package/watch/entries/quiet-after-claim.json +16 -0
  256. package/watch/entries/registry-check-failed.json +12 -0
  257. package/watch/entries/registry-lagging.json +12 -0
  258. package/watch/entries/risky-call.json +12 -0
  259. package/watch/entries/ungated.json +13 -0
  260. package/dist/api/demo.d.ts +0 -90
  261. package/dist/api/demo.d.ts.map +0 -1
  262. package/dist/api/demo.js +0 -492
  263. package/dist/api/demo.js.map +0 -1
@@ -0,0 +1,174 @@
1
+ /**
2
+ * THE policy-rule landing (DES-MEM-FACETED-001 §5.2; DC-S3 probe + read-back; DC-S4a one path).
3
+ *
4
+ * `POST /proposals/:id/approve` (an ordinary policy proposal) and the decision landing
5
+ * (`decisions/land.ts remember()`) both end here, so the probe, the read-back and the audit cannot
6
+ * drift between them:
7
+ *
8
+ * 1. probe: a project-scoped (or superseding) rule on an engine without project rules fails loud
9
+ * and writes nothing — the engine would accept the fields and drop them, landing it everywhere;
10
+ * 2. upsert through the single-writer actor;
11
+ * 3. read-back: the stored rule must still carry `targets.project`, the proposal ref and every
12
+ * `supersedes` id; a mismatch RETIRES the just-written rule (retire, never delete) and fails loud;
13
+ * 4. audit `governance.rule.upserted` with the caller's `via`.
14
+ *
15
+ * Failures are returned in-band (`outcome:"failed"`, the crew#388 anti-silent-loss doctrine).
16
+ */
17
+ import { STEERING_TYPE_VALUES, STEERING_TYPES } from './governance-steering.js';
18
+ const V = '/api/v1';
19
+ /**
20
+ * Map an APPROVED policy proposal (estate `proposal.approve` → `handed_off`) into a steering
21
+ * ConformanceRule (DES-MEM-FACETED-001 §5.2). A policy proposal's `kind_type` is
22
+ * `policy:<steering_type>` and its `payload` is `{ rule, severity }`; estate writes NOTHING for it
23
+ * (the AW-11 "no rules.write on estate" invariant) and hands the payload back for crew — the ONE
24
+ * governed rules-write path — to land. Returns the rule to upsert plus the resolved steering type,
25
+ * or a loud `error` string when the proposal cannot be shaped into a valid rule (a malformed
26
+ * `kind_type` / missing `rule` / out-of-enum `severity`) — the caller reports it as a failed
27
+ * landing, never a silent drop (the crew#388 anti-silent-loss doctrine).
28
+ *
29
+ * The rule id is DETERMINISTIC (`proposal:<id>`) so a re-driven landing UPSERTS the same rule
30
+ * (idempotent) instead of minting a duplicate; it sits OUTSIDE the reserved `PAT-/POL-` namespace,
31
+ * which UI/chat/proposal-authored rules are free to do (INV-C1). The rule carries NO `effect`
32
+ * (recall-only — exactly what `{rule, severity}` supports: an enforcement rule would need a
33
+ * non-blank `applies_to`, which the payload does not carry, and INV-S3 fails such a rule closed).
34
+ * `steering_type` is validated against the vocabulary here so the engine's INV-S1 never rejects it
35
+ * as an unknown page.
36
+ */
37
+ export function policyProposalToRule(proposalId, kindType, payload, facets) {
38
+ const steeringType = kindType.startsWith('policy:') ? kindType.slice('policy:'.length) : '';
39
+ if (!STEERING_TYPES.has(steeringType)) {
40
+ return {
41
+ error: `the approved proposal's kind_type ${JSON.stringify(kindType)} does not name a steering ` +
42
+ `type — expected \`policy:<${STEERING_TYPE_VALUES.join('|')}>\``,
43
+ };
44
+ }
45
+ const body = typeof payload === 'object' && payload !== null && !Array.isArray(payload)
46
+ ? payload
47
+ : {};
48
+ const statement = typeof body['rule'] === 'string' ? body['rule'].trim() : '';
49
+ if (statement === '') {
50
+ return {
51
+ error: 'the approved policy proposal payload has no `rule` string to make a rule statement from',
52
+ };
53
+ }
54
+ const rawSeverity = body['severity'];
55
+ // Normalize common LLM drift before the enum check: a model naturally writes the English word
56
+ // "warning", but the engine's enum is the short "warn" (info/error/critical are already the
57
+ // natural words). Tolerate case/whitespace too. A capture worker that says "warning" must still
58
+ // land its policy — otherwise every derived policy at the middle band silently fails to land.
59
+ const normSeverity = typeof rawSeverity === 'string'
60
+ ? (() => {
61
+ const s = rawSeverity.trim().toLowerCase();
62
+ return s === 'warning' ? 'warn' : s;
63
+ })()
64
+ : rawSeverity;
65
+ const severity = normSeverity === 'info' || normSeverity === 'warn' || normSeverity === 'error' || normSeverity === 'critical'
66
+ ? normSeverity
67
+ : undefined;
68
+ if (rawSeverity !== undefined && severity === undefined) {
69
+ return {
70
+ error: `the approved policy proposal payload has an invalid severity ${JSON.stringify(rawSeverity)} — ` +
71
+ 'expected info|warn|error|critical (or the natural "warning" for warn)',
72
+ };
73
+ }
74
+ const language = facets?.['language'];
75
+ const project = facets?.['project'];
76
+ const targets = {};
77
+ if (typeof language === 'string' && language !== '')
78
+ targets.language = language;
79
+ // DC-S3: the `project` facet is the rule's `targets.project` — a project decision lands scoped to
80
+ // that project, never everywhere (E3). The caller probes the engine and reads the rule back.
81
+ if (typeof project === 'string' && project !== '')
82
+ targets.project = project;
83
+ const rule = {
84
+ id: `proposal:${proposalId}`,
85
+ rule_type: 'policy',
86
+ statement,
87
+ // A policy proposal SHOULD carry severity; a missing one defaults to `warn` (the middle band)
88
+ // rather than failing the landing, but a present-but-garbage one fails loud above.
89
+ severity: severity ?? 'warn',
90
+ // REQUIRED engine-side (f32, no serde default, INV-C2 `[0,1]`); the payload carries none, so a
91
+ // fixed authority — the same 0.8 the steering-author landing defaults to.
92
+ confidence: 0.8,
93
+ // `language` and `project` map onto the engine's Targets; a `repo` facet has no rule slot.
94
+ targets,
95
+ // The landed rule names the proposal it came from (DC-S3), the same id it is keyed on.
96
+ provenance: { source: 'proposal', ref: `proposal:${proposalId}`, source_kinds: [] },
97
+ steering_type: steeringType,
98
+ };
99
+ return { rule, steeringType: steeringType };
100
+ }
101
+ function message(err) {
102
+ return err instanceof Error ? err.message : String(err);
103
+ }
104
+ export async function landPolicyRule(deps, built, actor, detail) {
105
+ const { adapter, audit } = deps;
106
+ const project = built.rule.targets.project;
107
+ const supersedes = built.rule.supersedes ?? [];
108
+ if ((project !== undefined || supersedes.length > 0) && !adapter.projectRulesSupported()) {
109
+ return {
110
+ outcome: 'failed',
111
+ error: project !== undefined
112
+ ? `the approved policy proposal is scoped to project \`${project}\`, but the installed engine ` +
113
+ 'cannot keep a rule\'s project and would land it everywhere; upgrade wicked-core-ts (>= 0.7.35)'
114
+ : 'the rule replaces other rules (`supersedes`), but the installed engine would drop the field; ' +
115
+ 'upgrade wicked-core-ts (>= 0.7.35)',
116
+ };
117
+ }
118
+ try {
119
+ await adapter.upsertConformanceRule(built.rule);
120
+ }
121
+ catch (err) {
122
+ return {
123
+ outcome: 'failed',
124
+ error: `the store refused the steering rule derived from the approved policy proposal: ${message(err)}`,
125
+ };
126
+ }
127
+ let lost;
128
+ try {
129
+ const stored = await adapter.readConformanceRule(built.rule.id);
130
+ const storedSupersedes = new Set(stored?.supersedes ?? []);
131
+ const missing = supersedes.filter((s) => !storedSupersedes.has(s));
132
+ lost =
133
+ stored === null
134
+ ? 'the rule is not in the store'
135
+ : (stored.targets?.project ?? undefined) !== project
136
+ ? `targets.project reads back ${JSON.stringify(stored.targets?.project ?? null)}, not ${JSON.stringify(project ?? null)}`
137
+ : stored.provenance?.ref !== built.rule.provenance.ref
138
+ ? `provenance.ref reads back ${JSON.stringify(stored.provenance?.ref ?? null)}, not ${JSON.stringify(built.rule.provenance.ref)}`
139
+ : missing.length > 0
140
+ ? `supersedes reads back without ${JSON.stringify(missing)}`
141
+ : null;
142
+ }
143
+ catch (err) {
144
+ lost = `the rule could not be read back (${message(err)})`;
145
+ }
146
+ if (lost !== null) {
147
+ let retired;
148
+ try {
149
+ await adapter.retireConformanceRule(built.rule.id);
150
+ retired = `rule ${built.rule.id} was retired`;
151
+ }
152
+ catch (err) {
153
+ retired = `retiring rule ${built.rule.id} FAILED (${message(err)}); retire it by hand via DELETE ${V}/governance/rules/${built.rule.id}`;
154
+ }
155
+ return { outcome: 'failed', error: `the engine did not keep the landed rule as written: ${lost}; ${retired}` };
156
+ }
157
+ audit.record('governance.rule.upserted', actor, {
158
+ detail: {
159
+ id: built.rule.id,
160
+ source: 'proposal',
161
+ steeringType: built.steeringType,
162
+ ...detail,
163
+ ...(project !== undefined ? { project } : {}),
164
+ ...(supersedes.length > 0 ? { supersedes } : {}),
165
+ },
166
+ });
167
+ return {
168
+ outcome: 'landed',
169
+ ruleId: built.rule.id,
170
+ steering_type: built.steeringType,
171
+ ...(project !== undefined ? { project } : {}),
172
+ };
173
+ }
174
+ //# sourceMappingURL=policy-landing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy-landing.js","sourceRoot":"","sources":["../../src/api/policy-landing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAEhF,MAAM,CAAC,GAAG,SAAS,CAAC;AAEpB;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,oBAAoB,CAClC,UAAkB,EAClB,QAAgB,EAChB,OAAgB,EAChB,MAA0C;IAE1C,MAAM,YAAY,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5F,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;QACtC,OAAO;YACL,KAAK,EACH,qCAAqC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,4BAA4B;gBACzF,6BAA6B,oBAAoB,CAAC,IAAI,CAA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,KAAK,CAAC,MAAM,CAAC,0BAA0B,EAAE,KAAK,EAAE;QAC9C,MAAM,EAAE;YACN,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE;YACjB,MAAM,EAAE,UAAU;YAClB,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,GAAG,MAAM;YACT,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7C,GAAG,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACjD;KACF,CAAC,CAAC;IACH,OAAO;QACL,OAAO,EAAE,QAAQ;QACjB,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE;QACrB,aAAa,EAAE,KAAK,CAAC,YAAY;QACjC,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,228 @@
1
+ /**
2
+ * The recording views (DES-walkthrough-proof §4.10: `api/demo.ts` renamed `api/recording.ts`) — the
3
+ * Demo experience and the walkthrough, which share `parseChapters`, `parseMarkers` and
4
+ * `containedPath`.
5
+ *
6
+ * ## Demo
7
+ *
8
+ * The Demo experience (wicked-studio#373, migration M9b): a demo of a local app, made by a governed
9
+ * run of the built-in `demo` preset — the wicked-garden demo skill's plan → record → review.
10
+ *
11
+ * POST /projects/:id/demo mints the run's DEMO ROOT (a per-run directory on the daemon host),
12
+ * writes the brief there, and launches `demo` THROUGH `POST /runs`
13
+ * (one launch path), with the root as the run's only extra write root.
14
+ * GET /runs/:id/demo what studio shows: the stage, the presenter script and chapter list
15
+ * (the plan gate), per-chapter record progress, the contact sheets and
16
+ * the reviewer's verdicts (the review gate), and the chaptered MP4.
17
+ * GET /runs/:id/demo/file one file of the root (a contact sheet, the MP4 — with Range).
18
+ * PUT /runs/:id/demo/script the presenter's edit of `script.md` while the plan gate is open.
19
+ * POST /runs/:id/demo/export a GIF (`demo-video/demo.gif`) or a poster frame (`demo-video/poster.jpg`)
20
+ * of the stitched MP4, encoded by ffmpeg with an ASYNC spawn and a
21
+ * timeout (EP-C3): the daemon keeps answering while it encodes.
22
+ *
23
+ * The gates are the run's ordinary gates (`POST /runs/:id/gate`): approve, or `request_changes` with a
24
+ * note — at the plan gate it re-runs `plan`, at the review gate it rewinds to `record` (re-record one
25
+ * chapter). Nothing here decides a gate.
26
+ *
27
+ * Every file is read from the root the daemon minted for THIS run id, never from a path a caller or a
28
+ * worker names: `path` is resolved inside it, symlinks included, and only the deliverable types studio
29
+ * renders are served.
30
+ *
31
+ * ## Walkthrough (WT-W1)
32
+ *
33
+ * Every repo-bound run gets an EVIDENCE ROOT (`walkthroughRootDir`, minted by `CoreAdapter.launchRun`
34
+ * and persisted by the engine as `session.evidence_root`). Under it, `author/<plan step>/` is the
35
+ * walkthrough author's write dir and `<review step>/` is the PROOF ROOT only the jailed
36
+ * `walkthrough_review` Tool writes.
37
+ *
38
+ * GET /runs/:id/walkthrough?step= the `WalkthroughView` of the newest (or the named) pair.
39
+ * GET /runs/:id/walkthrough/file?step=&path= one file of that pair's proof root (Range for the MP4).
40
+ *
41
+ * What the view reads from a proof root (the recorder's files, DES-walkthrough-proof §4.4):
42
+ *
43
+ * result.json `{overall, cause?, reason?, tree?, chapters: [{key, title?, verdict, takes?,
44
+ * failed_at_sec?, failed_frame?, proves?, legs?, checks?: [{id, kind, sentence,
45
+ * passed, at_sec, evidence?, vault_entry?, detail?}]}]}` — the engine itself writes
46
+ * `{overall: INCONCLUSIVE, cause, reason, chapters: []}` when it cannot record.
47
+ * progress.json `{state: 'starting_app' | 'recording' | 'judging', chapter?}` while it runs.
48
+ * chapters.json the chapter list (the demo shape), before the judge has written verdicts.
49
+ * demo-video/ `demo.mp4`, `poster.jpg`, `chapters.md` (markers), `segments/<key>/segment.mp4`.
50
+ *
51
+ * The proof root is read only when it is a plain directory directly under the evidence root (a link
52
+ * planted at the step path is never followed — the engine's `check_proof_root` rule), and every file
53
+ * inside it through `containedPath`.
54
+ */
55
+ import type { FastifyInstance } from 'fastify';
56
+ import { z } from 'zod';
57
+ import type { DemoChapter, DemoExportFormat, DemoFinding, DemoMarker, DemoStage, DemoView, WalkthroughView } from 'wicked-crew-api-types';
58
+ import type { CoreAdapter } from '../core/adapter.js';
59
+ import type { SessionView, WorkUnit } from '../core/types.js';
60
+ import type { AuditLog } from './audit.js';
61
+ import { type WalkthroughGate } from '../qe/walkthrough-acceptance.js';
62
+ import type { WalkthroughStepState } from 'wicked-crew-api-types';
63
+ /** The preset a demo run launches (wicked-core `builtin_presets`). */
64
+ export declare const DEMO_PRESET = "demo";
65
+ /** The biggest script studio shows or accepts back: a presenter script is prose. */
66
+ export declare const DEMO_SCRIPT_MAX_BYTES: number;
67
+ /** Where a demo run's files live: one directory per run, outside every sandbox and state home. */
68
+ export declare function demoRootDir(runId: string): string;
69
+ /**
70
+ * The demo root of each demo launch in flight, keyed by the run id the demo route minted. `POST /runs`
71
+ * takes no write roots from its body; it reads this in-process entry, so the root is never something a
72
+ * caller can ask for (the capture route's pattern).
73
+ */
74
+ export declare const demoLaunchRoots: Map<string, string>;
75
+ export declare const DemoLaunchSchema: z.ZodObject<{
76
+ url: z.ZodEffects<z.ZodString, string, string>;
77
+ audience: z.ZodString;
78
+ show: z.ZodString;
79
+ clisJson: z.ZodOptional<z.ZodString>;
80
+ }, "strict", z.ZodTypeAny, {
81
+ url: string;
82
+ audience: string;
83
+ show: string;
84
+ clisJson?: string | undefined;
85
+ }, {
86
+ url: string;
87
+ audience: string;
88
+ show: string;
89
+ clisJson?: string | undefined;
90
+ }>;
91
+ export declare const DemoScriptSchema: z.ZodObject<{
92
+ content: z.ZodString;
93
+ }, "strict", z.ZodTypeAny, {
94
+ content: string;
95
+ }, {
96
+ content: string;
97
+ }>;
98
+ export declare const DemoExportSchema: z.ZodEffects<z.ZodObject<{
99
+ format: z.ZodEnum<["gif", "poster"]>;
100
+ /** The poster's frame, in seconds from the start. Poster only. */
101
+ atSec: z.ZodOptional<z.ZodNumber>;
102
+ }, "strict", z.ZodTypeAny, {
103
+ format: "gif" | "poster";
104
+ atSec?: number | undefined;
105
+ }, {
106
+ format: "gif" | "poster";
107
+ atSec?: number | undefined;
108
+ }>, {
109
+ format: "gif" | "poster";
110
+ atSec?: number | undefined;
111
+ }, {
112
+ format: "gif" | "poster";
113
+ atSec?: number | undefined;
114
+ }>;
115
+ /**
116
+ * How long one encode may run before it is killed (EP-C3). A GIF re-encodes the whole video (the bound
117
+ * interactive's encoder uses); a poster decodes one frame. Mutable only so a test can shorten it.
118
+ */
119
+ export declare const DEMO_EXPORT_TIMEOUT_MS: Record<DemoExportFormat, number>;
120
+ /** Interactive's GIF filter (`src/service/demo.js` `ffmpegGifEncoder`): two-pass palette so colours do not band, 10 fps, 720 px. */
121
+ export declare const DEMO_GIF_FILTER = "fps=10,scale=720:-1:flags=lanczos,split[s0][s1];[s0]palettegen=stats_mode=diff[p];[s1][p]paletteuse=dither=bayer:bayer_scale=3";
122
+ export declare const DEMO_FFMPEG_HINT = "install ffmpeg (e.g. `brew install ffmpeg` / `apt install ffmpeg`) on the daemon host, or set WICKED_FFMPEG to its path";
123
+ type FfmpegOutcome = {
124
+ kind: 'ok';
125
+ } | {
126
+ kind: 'missing';
127
+ } | {
128
+ kind: 'timeout';
129
+ } | {
130
+ kind: 'failed';
131
+ code: number | null;
132
+ stderr: string;
133
+ };
134
+ /**
135
+ * Run ffmpeg without blocking the event loop: an async `spawn`, its stderr tail kept for the error,
136
+ * SIGKILL past `timeoutMs`. Never `spawnSync` (review N6: a 180 s synchronous encode would stall
137
+ * every route the daemon serves, `/health` included).
138
+ */
139
+ export declare function runFfmpeg(args: string[], timeoutMs: number): Promise<FfmpegOutcome>;
140
+ /** The brief the demo run reads (the problem statement stays one short line: worker prompts are capped). */
141
+ export declare function demoBrief(root: string, b: {
142
+ url: string;
143
+ audience: string;
144
+ show: string;
145
+ }): string;
146
+ /** A demo run: launched from the `demo` preset — read off the engine's plan state, or, before the
147
+ * launch is scored and `team_plan` exists, off the run's identity (resolved from the launch record). */
148
+ export declare function isDemoRun(view: SessionView): boolean;
149
+ /** Where the run stands, in the Demo experience's words. */
150
+ export declare function demoStage(view: SessionView): DemoStage;
151
+ /** `chapters.json` → the chapter list, or `[]` when it is missing or not the plan's shape. */
152
+ export declare function parseChapters(raw: string | null): Omit<DemoChapter, 'recorded'>[];
153
+ /** `chapters.md` (record.mjs's `| m:ss | Title |` table) → the MP4's chapter markers. */
154
+ export declare function parseMarkers(raw: string | null): DemoMarker[];
155
+ /** The reviewer's output → its verdict block (the LAST fenced ```json block), or nothing. */
156
+ export declare function parseReview(output: string | null): {
157
+ verdict: 'accept' | 'changes' | null;
158
+ findings: DemoFinding[];
159
+ };
160
+ /** Everything studio renders for a demo run, read from its root and its units. */
161
+ export declare function demoView(adapter: CoreAdapter, view: SessionView): Promise<DemoView>;
162
+ /** A single `Range: bytes=a-b` → the inclusive span, `null` for no header, `'bad'` for one we cannot serve. */
163
+ export declare function parseRange(header: string | undefined, size: number): {
164
+ start: number;
165
+ end: number;
166
+ } | null | 'bad';
167
+ export declare function registerDemoRoutes(app: FastifyInstance, adapter: CoreAdapter): void;
168
+ /** The catalog id of the walkthrough author (an evaluator agent step). */
169
+ export declare const WALKTHROUGH_PLAN_CATALOG = "walkthrough_plan";
170
+ /** The catalog id of the walkthrough recorder (the jailed, engine-run Tool step). */
171
+ export declare const WALKTHROUGH_REVIEW_CATALOG = "walkthrough_review";
172
+ export { WALKTHROUGH_AUTHOR_SUBDIR, walkthroughRootDir } from '../core/walkthrough-root.js';
173
+ /** One walkthrough pair of a run: the recorder unit and the author unit it records. */
174
+ interface WalkthroughPair {
175
+ review: WorkUnit | null;
176
+ plan: WorkUnit | null;
177
+ }
178
+ /**
179
+ * The run's walkthrough pairs in plan order. A recorder pairs with the author its `depends_on` names,
180
+ * else the nearest author before it (the engine's `author_step_for`); an author with no recorder after
181
+ * it yet is a pair of its own (the walkthrough is still being written).
182
+ */
183
+ export declare function walkthroughPairs(view: SessionView): WalkthroughPair[];
184
+ /**
185
+ * The walkthrough half of `GET /runs/:id/acceptance` (WT-W2): one gate per `walkthrough_review` step
186
+ * the requirement names (`phases`, step ids), and the per-creator-step check states from the NEWEST
187
+ * walkthrough (only a sealed one proves anything).
188
+ */
189
+ export declare function walkthroughAcceptance(adapter: Pick<CoreAdapter, 'workOutput'>, view: SessionView, phases: string[]): Promise<{
190
+ gates: WalkthroughGate[];
191
+ steps: WalkthroughStepState[];
192
+ newest: WalkthroughGate | null;
193
+ }>;
194
+ /** Everything studio renders for one walkthrough pair (the newest, or the one `step` names). */
195
+ export declare function walkthroughView(view: SessionView, step?: string, adapter?: Pick<CoreAdapter, 'workOutput'>): Promise<WalkthroughView | null>;
196
+ /** The biggest storyline the operator may PUT (the demo module shape is a few KB). */
197
+ export declare const STORYLINE_MAX_BYTES: number;
198
+ /** The storyline file the author writes, and crew's edit marker beside it (WT-W3). */
199
+ export declare const STORYLINE_FILE = "storyline.mjs";
200
+ export declare const STORYLINE_EDIT_FILE = "storyline.edit.json";
201
+ /** What crew writes beside an operator-edited storyline: who edited it, when, and what. */
202
+ export interface StorylineEditMarker {
203
+ edited_by: 'human';
204
+ actor: string;
205
+ at: string;
206
+ sha256: string;
207
+ /** The escalated unit the edit answers (its `ord`). */
208
+ ord: number;
209
+ }
210
+ /** A refusal whose message is safe to return (relative names only, never an absolute path). */
211
+ export declare class StorylineWriteError extends Error {
212
+ }
213
+ /**
214
+ * WT-W3 (DES-walkthrough-proof §4.8 "Edit the check"): write the operator's storyline for the pair's
215
+ * author step — `<evidence_root>/author/<plan step>/storyline.mjs` plus `storyline.edit.json`
216
+ * (`edited_by: "human"`) — atomically (temp file + rename), refusing any path that does not resolve
217
+ * to a plain directory under the evidence root's `author/` (a planted link cannot redirect the write).
218
+ */
219
+ export declare function writeStoryline(evidenceRoot: string, planStepId: string, text: string, marker: Omit<StorylineEditMarker, 'sha256' | 'edited_by'>): Promise<StorylineEditMarker>;
220
+ export interface WalkthroughRouteDeps {
221
+ /** The run's open gate (the routes' shared resolution); `'no-log'` = this build cannot say. */
222
+ resolveOpenGate?: (runId: string) => Promise<{
223
+ ord: number;
224
+ } | null | 'no-log'>;
225
+ audit?: AuditLog;
226
+ }
227
+ export declare function registerWalkthroughRoutes(app: FastifyInstance, adapter: CoreAdapter, deps?: WalkthroughRouteDeps): void;
228
+ //# sourceMappingURL=recording.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recording.d.ts","sourceRoot":"","sources":["../../src/api/recording.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAOH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EACV,WAAW,EACX,gBAAgB,EAEhB,WAAW,EACX,UAAU,EACV,SAAS,EACT,QAAQ,EAMR,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAA+B,WAAW,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAM3F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAkD,KAAK,eAAe,EAAE,MAAM,iCAAiC,CAAC;AACvH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAIlE,sEAAsE;AACtE,eAAO,MAAM,WAAW,SAAS,CAAC;AAKlC,oFAAoF;AACpF,eAAO,MAAM,qBAAqB,QAAa,CAAC;AAYhD,kGAAkG;AAClG,wBAAgB,WAAW,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