wicked-crew 0.18.21 → 0.18.22

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 (255) hide show
  1. package/dist/api/audit.d.ts +28 -1
  2. package/dist/api/audit.d.ts.map +1 -1
  3. package/dist/api/audit.js +90 -9
  4. package/dist/api/audit.js.map +1 -1
  5. package/dist/api/auth.d.ts +7 -0
  6. package/dist/api/auth.d.ts.map +1 -1
  7. package/dist/api/auth.js +53 -10
  8. package/dist/api/auth.js.map +1 -1
  9. package/dist/api/capture.d.ts +11 -2
  10. package/dist/api/capture.d.ts.map +1 -1
  11. package/dist/api/capture.js +7 -2
  12. package/dist/api/capture.js.map +1 -1
  13. package/dist/api/chat-context.d.ts +6 -1
  14. package/dist/api/chat-context.d.ts.map +1 -1
  15. package/dist/api/chat-context.js +45 -11
  16. package/dist/api/chat-context.js.map +1 -1
  17. package/dist/api/chat-proposals.d.ts +24 -7
  18. package/dist/api/chat-proposals.d.ts.map +1 -1
  19. package/dist/api/chat-proposals.js +98 -18
  20. package/dist/api/chat-proposals.js.map +1 -1
  21. package/dist/api/chat-scope.d.ts +6 -2
  22. package/dist/api/chat-scope.d.ts.map +1 -1
  23. package/dist/api/chat-scope.js +13 -7
  24. package/dist/api/chat-scope.js.map +1 -1
  25. package/dist/api/cluster-status.d.ts +17 -0
  26. package/dist/api/cluster-status.d.ts.map +1 -1
  27. package/dist/api/cluster-status.js +70 -3
  28. package/dist/api/cluster-status.js.map +1 -1
  29. package/dist/api/compose-facts.d.ts +35 -0
  30. package/dist/api/compose-facts.d.ts.map +1 -0
  31. package/dist/api/compose-facts.js +46 -0
  32. package/dist/api/compose-facts.js.map +1 -0
  33. package/dist/api/cut-read.d.ts +62 -0
  34. package/dist/api/cut-read.d.ts.map +1 -0
  35. package/dist/api/cut-read.js +101 -0
  36. package/dist/api/cut-read.js.map +1 -0
  37. package/dist/api/desk-snoozes.d.ts +54 -0
  38. package/dist/api/desk-snoozes.d.ts.map +1 -0
  39. package/dist/api/desk-snoozes.js +174 -0
  40. package/dist/api/desk-snoozes.js.map +1 -0
  41. package/dist/api/diagnostics.d.ts +4 -0
  42. package/dist/api/diagnostics.d.ts.map +1 -1
  43. package/dist/api/diagnostics.js +15 -7
  44. package/dist/api/diagnostics.js.map +1 -1
  45. package/dist/api/disk-stores.d.ts +66 -0
  46. package/dist/api/disk-stores.d.ts.map +1 -0
  47. package/dist/api/disk-stores.js +206 -0
  48. package/dist/api/disk-stores.js.map +1 -0
  49. package/dist/api/gate-cache.d.ts +8 -0
  50. package/dist/api/gate-cache.d.ts.map +1 -1
  51. package/dist/api/gate-cache.js +8 -1
  52. package/dist/api/gate-cache.js.map +1 -1
  53. package/dist/api/mcp.d.ts +16 -0
  54. package/dist/api/mcp.d.ts.map +1 -1
  55. package/dist/api/mcp.js +118 -1
  56. package/dist/api/mcp.js.map +1 -1
  57. package/dist/api/needs.d.ts +3 -0
  58. package/dist/api/needs.d.ts.map +1 -1
  59. package/dist/api/needs.js +7 -3
  60. package/dist/api/needs.js.map +1 -1
  61. package/dist/api/post-hoc-deliver.d.ts +7 -0
  62. package/dist/api/post-hoc-deliver.d.ts.map +1 -1
  63. package/dist/api/post-hoc-deliver.js +16 -5
  64. package/dist/api/post-hoc-deliver.js.map +1 -1
  65. package/dist/api/product-publish.d.ts +242 -0
  66. package/dist/api/product-publish.d.ts.map +1 -0
  67. package/dist/api/product-publish.js +902 -0
  68. package/dist/api/product-publish.js.map +1 -0
  69. package/dist/api/product.d.ts +5 -6
  70. package/dist/api/product.d.ts.map +1 -1
  71. package/dist/api/product.js +4 -4
  72. package/dist/api/product.js.map +1 -1
  73. package/dist/api/proposal-cut.d.ts +95 -0
  74. package/dist/api/proposal-cut.d.ts.map +1 -0
  75. package/dist/api/proposal-cut.js +231 -0
  76. package/dist/api/proposal-cut.js.map +1 -0
  77. package/dist/api/requirements.d.ts +3 -3
  78. package/dist/api/requirements.js +3 -3
  79. package/dist/api/routes.d.ts +15 -0
  80. package/dist/api/routes.d.ts.map +1 -1
  81. package/dist/api/routes.js +410 -88
  82. package/dist/api/routes.js.map +1 -1
  83. package/dist/api/run-liveness.d.ts.map +1 -1
  84. package/dist/api/run-liveness.js +3 -1
  85. package/dist/api/run-liveness.js.map +1 -1
  86. package/dist/api/run-timing-index.d.ts +10 -0
  87. package/dist/api/run-timing-index.d.ts.map +1 -1
  88. package/dist/api/run-timing-index.js +29 -9
  89. package/dist/api/run-timing-index.js.map +1 -1
  90. package/dist/api/seat-container-login.d.ts +11 -17
  91. package/dist/api/seat-container-login.d.ts.map +1 -1
  92. package/dist/api/seat-container-login.js +36 -69
  93. package/dist/api/seat-container-login.js.map +1 -1
  94. package/dist/api/system-snapshot.d.ts +2 -1
  95. package/dist/api/system-snapshot.d.ts.map +1 -1
  96. package/dist/api/system-snapshot.js +17 -6
  97. package/dist/api/system-snapshot.js.map +1 -1
  98. package/dist/api/ui-text.d.ts.map +1 -1
  99. package/dist/api/ui-text.js +3 -1
  100. package/dist/api/ui-text.js.map +1 -1
  101. package/dist/apps/store.d.ts +11 -0
  102. package/dist/apps/store.d.ts.map +1 -1
  103. package/dist/apps/store.js +47 -0
  104. package/dist/apps/store.js.map +1 -1
  105. package/dist/apps-server/server/lib/bundle/server.mjs +12 -2
  106. package/dist/cli/index.d.ts.map +1 -1
  107. package/dist/cli/index.js +27 -52
  108. package/dist/cli/index.js.map +1 -1
  109. package/dist/cli/start-stand-ins.d.ts +13 -0
  110. package/dist/cli/start-stand-ins.d.ts.map +1 -0
  111. package/dist/cli/start-stand-ins.js +30 -0
  112. package/dist/cli/start-stand-ins.js.map +1 -0
  113. package/dist/core/adapter.d.ts +43 -6
  114. package/dist/core/adapter.d.ts.map +1 -1
  115. package/dist/core/adapter.js +169 -30
  116. package/dist/core/adapter.js.map +1 -1
  117. package/dist/core/ado-env.d.ts +17 -0
  118. package/dist/core/ado-env.d.ts.map +1 -0
  119. package/dist/core/ado-env.js +34 -0
  120. package/dist/core/ado-env.js.map +1 -0
  121. package/dist/core/deliver-text.d.ts +17 -0
  122. package/dist/core/deliver-text.d.ts.map +1 -1
  123. package/dist/core/deliver-text.js +76 -1
  124. package/dist/core/deliver-text.js.map +1 -1
  125. package/dist/core/deliver.d.ts +6 -0
  126. package/dist/core/deliver.d.ts.map +1 -1
  127. package/dist/core/deliver.js +12 -4
  128. package/dist/core/deliver.js.map +1 -1
  129. package/dist/core/exec.d.ts +1 -10
  130. package/dist/core/exec.d.ts.map +1 -1
  131. package/dist/core/exec.js +4 -17
  132. package/dist/core/exec.js.map +1 -1
  133. package/dist/core/governance-store.d.ts +3 -1
  134. package/dist/core/governance-store.d.ts.map +1 -1
  135. package/dist/core/governance-store.js +7 -2
  136. package/dist/core/governance-store.js.map +1 -1
  137. package/dist/core/repo-clone.d.ts.map +1 -1
  138. package/dist/core/repo-clone.js +2 -1
  139. package/dist/core/repo-clone.js.map +1 -1
  140. package/dist/core/run-log-facts.d.ts +56 -0
  141. package/dist/core/run-log-facts.d.ts.map +1 -0
  142. package/dist/core/run-log-facts.js +230 -0
  143. package/dist/core/run-log-facts.js.map +1 -0
  144. package/dist/core/shutdown.d.ts +27 -0
  145. package/dist/core/shutdown.d.ts.map +1 -1
  146. package/dist/core/shutdown.js +72 -0
  147. package/dist/core/shutdown.js.map +1 -1
  148. package/dist/core/stand-in.d.ts +40 -0
  149. package/dist/core/stand-in.d.ts.map +1 -0
  150. package/dist/core/stand-in.js +118 -0
  151. package/dist/core/stand-in.js.map +1 -0
  152. package/dist/core/types.d.ts +17 -0
  153. package/dist/core/types.d.ts.map +1 -1
  154. package/dist/core/types.js.map +1 -1
  155. package/dist/editors/pack-extras.d.ts +162 -0
  156. package/dist/editors/pack-extras.d.ts.map +1 -0
  157. package/dist/editors/pack-extras.js +596 -0
  158. package/dist/editors/pack-extras.js.map +1 -0
  159. package/dist/editors/pack-install.d.ts +15 -7
  160. package/dist/editors/pack-install.d.ts.map +1 -1
  161. package/dist/editors/pack-install.js +140 -19
  162. package/dist/editors/pack-install.js.map +1 -1
  163. package/dist/editors/registry.d.ts +42 -3
  164. package/dist/editors/registry.d.ts.map +1 -1
  165. package/dist/editors/registry.js +114 -11
  166. package/dist/editors/registry.js.map +1 -1
  167. package/dist/editors/routes.d.ts +10 -5
  168. package/dist/editors/routes.d.ts.map +1 -1
  169. package/dist/editors/routes.js +45 -11
  170. package/dist/editors/routes.js.map +1 -1
  171. package/dist/interactive/bridge-pool.d.ts +5 -2
  172. package/dist/interactive/bridge-pool.d.ts.map +1 -1
  173. package/dist/interactive/bridge-pool.js +4 -1
  174. package/dist/interactive/bridge-pool.js.map +1 -1
  175. package/dist/interactive/landing-guard.d.ts.map +1 -1
  176. package/dist/interactive/landing-guard.js +79 -5
  177. package/dist/interactive/landing-guard.js.map +1 -1
  178. package/dist/knowledge/adapters/toolbox/memory.d.ts.map +1 -1
  179. package/dist/knowledge/adapters/toolbox/memory.js +3 -2
  180. package/dist/knowledge/adapters/toolbox/memory.js.map +1 -1
  181. package/dist/knowledge/trackers/set.d.ts +28 -0
  182. package/dist/knowledge/trackers/set.d.ts.map +1 -1
  183. package/dist/knowledge/trackers/set.js +26 -0
  184. package/dist/knowledge/trackers/set.js.map +1 -1
  185. package/dist/mcp/policies.d.ts +35 -0
  186. package/dist/mcp/policies.d.ts.map +1 -1
  187. package/dist/mcp/policies.js +138 -1
  188. package/dist/mcp/policies.js.map +1 -1
  189. package/dist/mcp/registry-store.d.ts +10 -0
  190. package/dist/mcp/registry-store.d.ts.map +1 -1
  191. package/dist/mcp/registry-store.js.map +1 -1
  192. package/dist/mcp/registry.d.ts +40 -3
  193. package/dist/mcp/registry.d.ts.map +1 -1
  194. package/dist/mcp/registry.js +211 -16
  195. package/dist/mcp/registry.js.map +1 -1
  196. package/dist/mcp/trigger-names.d.ts +32 -0
  197. package/dist/mcp/trigger-names.d.ts.map +1 -0
  198. package/dist/mcp/trigger-names.js +529 -0
  199. package/dist/mcp/trigger-names.js.map +1 -0
  200. package/dist/skills/store.d.ts +11 -1
  201. package/dist/skills/store.d.ts.map +1 -1
  202. package/dist/skills/store.js +37 -3
  203. package/dist/skills/store.js.map +1 -1
  204. package/dist/studio/apps-standalone/fixture.js +3 -3
  205. package/dist/studio/assets/{KnowledgeGraph-yP4WsnST.js → KnowledgeGraph-D6RRLDnV.js} +1 -1
  206. package/dist/studio/assets/{index-DW53FKuT.js → index-BLo9vFQI.js} +324 -310
  207. package/dist/studio/assets/index-xW21Gkam.css +32 -0
  208. package/dist/studio/editors/wicked-apps/editor.json +1 -1
  209. package/dist/studio/editors/wicked-apps/index.html +1 -1
  210. package/dist/studio/editors/wicked-deck/editor.json +1 -1
  211. package/dist/studio/editors/wicked-deck/index.html +1 -1
  212. package/dist/studio/editors/wicked-doc/editor.json +1 -1
  213. package/dist/studio/editors/wicked-doc/index.html +1 -1
  214. package/dist/studio/editors/wicked-insights/editor.json +1 -1
  215. package/dist/studio/editors/wicked-insights/index.html +1 -1
  216. package/dist/studio/editors/wicked-page/editor.json +1 -1
  217. package/dist/studio/editors/wicked-page/index.html +1 -1
  218. package/dist/studio/editors/wicked-video/editor.json +1 -1
  219. package/dist/studio/editors/wicked-video/index.html +1 -1
  220. package/dist/studio/index.html +2 -2
  221. package/dist/studio/testid-inventory.json +539 -5
  222. package/dist/team/routes.d.ts +4 -1
  223. package/dist/team/routes.d.ts.map +1 -1
  224. package/dist/team/routes.js +1 -1
  225. package/dist/team/routes.js.map +1 -1
  226. package/dist/voice/tts.d.ts +6 -0
  227. package/dist/voice/tts.d.ts.map +1 -1
  228. package/dist/voice/tts.js +16 -1
  229. package/dist/voice/tts.js.map +1 -1
  230. package/endpoint-manifest.json +85 -6
  231. package/package.json +4 -4
  232. package/voice-locks/darwin-arm64-cp310.txt +12 -0
  233. package/voice-locks/darwin-arm64-cp311.txt +8 -0
  234. package/voice-locks/darwin-arm64-cp312.txt +8 -0
  235. package/voice-locks/darwin-arm64-cp313.txt +8 -0
  236. package/voice-locks/darwin-arm64-cp314.txt +8 -0
  237. package/voice-locks/darwin-arm64-cp39.txt +12 -0
  238. package/voice-locks/darwin-x64-cp310.txt +12 -0
  239. package/voice-locks/darwin-x64-cp311.txt +12 -0
  240. package/voice-locks/darwin-x64-cp312.txt +12 -0
  241. package/voice-locks/darwin-x64-cp313.txt +12 -0
  242. package/voice-locks/darwin-x64-cp39.txt +12 -0
  243. package/voice-locks/linux-arm64-cp310.txt +12 -0
  244. package/voice-locks/linux-arm64-cp311.txt +8 -0
  245. package/voice-locks/linux-arm64-cp312.txt +8 -0
  246. package/voice-locks/linux-arm64-cp313.txt +8 -0
  247. package/voice-locks/linux-arm64-cp314.txt +8 -0
  248. package/voice-locks/linux-arm64-cp39.txt +12 -0
  249. package/voice-locks/linux-x64-cp310.txt +12 -0
  250. package/voice-locks/linux-x64-cp311.txt +8 -0
  251. package/voice-locks/linux-x64-cp312.txt +8 -0
  252. package/voice-locks/linux-x64-cp313.txt +8 -0
  253. package/voice-locks/linux-x64-cp314.txt +8 -0
  254. package/voice-locks/linux-x64-cp39.txt +12 -0
  255. package/dist/studio/assets/index-DNaLjJ7M.css +0 -32
@@ -14,6 +14,7 @@ import { homedir } from 'node:os';
14
14
  import { randomUUID } from 'node:crypto';
15
15
  import { RunReadLane } from './run-read-lane.js';
16
16
  import { AskError, AskUnsupportedError } from './types.js';
17
+ import { factsFromEvents, runFingerprint, RunFactsFile } from './run-log-facts.js';
17
18
  import { DEFAULT_SETTINGS } from './types.js';
18
19
  import { BASE_SKILL_REF_SHAPE } from '../skills/base-skill.js';
19
20
  import { cloneRepository } from './repo-clone.js';
@@ -951,6 +952,10 @@ export class CoreAdapter {
951
952
  applyGovernanceStoreEnv(this.governanceStore);
952
953
  this.stub = opts.stub === true;
953
954
  this.dbPath = opts.dbPath;
955
+ this.runFactsFile =
956
+ typeof opts.dbPath === 'string' && opts.dbPath !== '' && opts.dbPath !== ':memory:'
957
+ ? new RunFactsFile(`${opts.dbPath}.run-facts.jsonl`, opts.dbPath)
958
+ : null;
954
959
  // The QE acceptance setting's engine mirror (`syncEngineQeSetting`) must hold BEFORE the engine
955
960
  // arms its bus bridge inside `spawn`, or a bus request in between would launch under the
956
961
  // default: hand the boot value over in the engine's own variable, read at spawn.
@@ -1211,6 +1216,10 @@ export class CoreAdapter {
1211
1216
  setDraining(drain) {
1212
1217
  this.drainSince = drain ? (this.drainSince ?? Date.now()) : null;
1213
1218
  }
1219
+ /** Whether new work is refused for maintenance (the launch's stand-in question is not asked of a draining daemon). */
1220
+ isDraining() {
1221
+ return this.drainSince !== null;
1222
+ }
1214
1223
  /** Parked and human-held runs are idle for maintenance, but still hold their repository. */
1215
1224
  async maintenanceState() {
1216
1225
  const active = (await this.sessionsDetail())
@@ -1532,6 +1541,12 @@ export class CoreAdapter {
1532
1541
  if (input.extraReadRoots !== undefined && input.extraReadRoots.length > 0) {
1533
1542
  opts.extraReadRoots = input.extraReadRoots;
1534
1543
  }
1544
+ // wicked-core#1463: an older addon ignores the field, which only keeps every read root
1545
+ // required (today's fail-closed behaviour), so it needs no version gate. Widened locally, as
1546
+ // `primary` and `voice` are, so crew still compiles against an addon's older declarations.
1547
+ if (input.optionalReadRoots !== undefined && input.optionalReadRoots.length > 0) {
1548
+ opts.optionalReadRoots = input.optionalReadRoots;
1549
+ }
1535
1550
  if (input.excludeSeats !== undefined && input.excludeSeats.length > 0) {
1536
1551
  // Fail CLOSED on an old addon (napi ignores undeclared fields): a silently-dropped exclusion
1537
1552
  // would let the seat that wrote the work judge it — the one thing the caller asked to rule out.
@@ -1551,6 +1566,17 @@ export class CoreAdapter {
1551
1566
  }
1552
1567
  opts.reducedAssurance = true;
1553
1568
  }
1569
+ // (DES-STANDIN-001 §3.8, K2a) Fail CLOSED on an addon without stand-ins (napi ignores undeclared fields): the
1570
+ // person's consent would be dropped and the run would hold or fail where they were told it would be checked.
1571
+ if (input.standInAware === true) {
1572
+ if (!this.supportsStandIns()) {
1573
+ throw new Error('stand-in checks need a wicked-core-ts that carries them (Core.independencePreflight and grantStandIns); upgrade the engine');
1574
+ }
1575
+ const o = opts;
1576
+ o.standInAware = true;
1577
+ if (input.standIn !== undefined)
1578
+ o.standInJson = JSON.stringify(input.standIn);
1579
+ }
1554
1580
  // (program DES-POWER-MODE) Fail CLOSED on an addon without power mode (napi ignores an undeclared
1555
1581
  // field): the run would launch phased while its launcher reported power mode on.
1556
1582
  if (input.power === true) {
@@ -1874,9 +1900,11 @@ export class CoreAdapter {
1874
1900
  return Promise.reject(new PlanGateNoteUnsupportedError());
1875
1901
  }
1876
1902
  const core = this.core;
1903
+ // (crew#1698, core#1808) `expectGateSeq`: the opening of the gate the record showed; the engine refuses a
1904
+ // gate that closed and re-opened since (`gate_changed:`), at the same ord too.
1877
1905
  return plan !== undefined
1878
- ? core.confirmGate(runId, true, note ?? null, 'edit_plan', null, JSON.stringify(plan), actorLabel ?? null, expect.ord ?? null, expect.planRev ?? null)
1879
- : core.confirmGate(runId, approve, amend ?? null, action ?? null, amendScope ?? null, null, actorLabel ?? null, expect.ord ?? null, expect.planRev ?? null);
1906
+ ? core.confirmGate(runId, true, note ?? null, 'edit_plan', null, JSON.stringify(plan), actorLabel ?? null, expect.ord ?? null, expect.planRev ?? null, expect.gateSeq ?? null)
1907
+ : core.confirmGate(runId, approve, amend ?? null, action ?? null, amendScope ?? null, null, actorLabel ?? null, expect.ord ?? null, expect.planRev ?? null, expect.gateSeq ?? null);
1880
1908
  }, undefined, resumesWork);
1881
1909
  }
1882
1910
  return this.handedToEngine('run', runId, () => {
@@ -2038,6 +2066,45 @@ export class CoreAdapter {
2038
2066
  const C = Core;
2039
2067
  return typeof C.supportsPlanSendBack === 'function' && C.supportsPlanSendBack() === true;
2040
2068
  }
2069
+ /** (DES-STANDIN-001 §3.9, §3.10; K2a) The linked engine takes stand-in launches: it carries both the preflight and
2070
+ * the gate grant (method presence, as core-ts documents). Read at call time. */
2071
+ supportsStandIns() {
2072
+ const c = this.core;
2073
+ return typeof c.independencePreflight === 'function' && typeof c.grantStandIns === 'function';
2074
+ }
2075
+ /**
2076
+ * (DES-STANDIN-001 §3.9) Which independent roles this launch would be short of, on the shape it would take: the
2077
+ * engine resolves the contract through the launch's own code. Rejects as the launch would refuse the shape.
2078
+ */
2079
+ async independencePreflight(input) {
2080
+ const core = this.core;
2081
+ const shape = {
2082
+ ...(input.workflow !== undefined ? { workflow: input.workflow } : {}),
2083
+ ...(input.projectId !== undefined ? { projectId: input.projectId } : {}),
2084
+ ...(input.plan !== undefined ? { planJson: JSON.stringify(input.plan) } : {}),
2085
+ ...(input.power === true ? { power: true } : {}),
2086
+ ...(input.primary !== undefined ? { primary: input.primary } : {}),
2087
+ ...(input.excludeSeats !== undefined && input.excludeSeats.length > 0 ? { excludeSeats: input.excludeSeats } : {}),
2088
+ ...(input.skipQeAcceptanceReason !== undefined ? { skipQeAcceptanceReason: input.skipQeAcceptanceReason } : {}),
2089
+ ...(input.forceQeAcceptance === true ? { forceQeAcceptance: true } : {}),
2090
+ repoBound: input.repoRef !== undefined,
2091
+ };
2092
+ return core.independencePreflight(engineRosterJson(input.clisJson), JSON.stringify(shape));
2093
+ }
2094
+ /**
2095
+ * (DES-STANDIN-001 §3.10, crew#1856) USE STAND-INS at the run's open `stand_in_needed` gate: the person's consent
2096
+ * (`scope`) goes on the run and the held check continues. `gateSeq` is the open gate's opening (its durable row's
2097
+ * `gate_seq`), `actor` the server's name for the person. The engine refuses a stale opening (`gate_changed:`).
2098
+ */
2099
+ grantStandIns(runId, scope, gateSeq, actor, ord) {
2100
+ const core = this.core;
2101
+ return this.handedToEngine('run', runId, () => {
2102
+ if (!this.supportsStandIns()) {
2103
+ return Promise.reject(new Error('Using stand-ins at a gate needs a wicked-core-ts with Core.grantStandIns; upgrade the engine'));
2104
+ }
2105
+ return core.grantStandIns(runId, scope, gateSeq, actor, ord ?? null);
2106
+ }, undefined, true);
2107
+ }
2041
2108
  /** (workdoc-all-runs; core lane context-block-core) The linked engine keeps a per-run CONTEXT BLOCK it hands every
2042
2109
  * seat it spawns (`Core.supportsRunContext`). Until it does, crew's working document re-sends the person's context
2043
2110
  * before each later worker step (the standing note). Read at call time. */
@@ -2133,41 +2200,108 @@ export class CoreAdapter {
2133
2200
  }
2134
2201
  /**
2135
2202
  * Each run's launch name as the engine RECORDED it — `sessionStarted.workflowId` from its event
2136
- * log (the preset, the registered def, `<run>:plan-<rev>`, or `null` for free text). Immutable
2137
- * once written, so it is read once per run: a run whose log holds no `sessionStarted` is memoized
2138
- * only once it is terminal (a live run's frame may not be flushed yet; a finished run's never
2139
- * will be). Seam X2 — the one input `resolveRunIdentity` needs that the session record lacks.
2140
- */
2141
- launchedWorkflows = new Map();
2142
- async launchedWorkflowOf(view) {
2203
+ * log (the preset, the registered def, `<run>:plan-<rev>`, or `null` for free text). Seam X2 — the one input
2204
+ * `resolveRunIdentity` needs that the session record lacks.
2205
+ *
2206
+ * crew#1880: read through the run's log FACTS (run-log-facts.ts), one read per run answering both this and the
2207
+ * `ended_at` backfill ({@link runEndedFact}). A read made while the run is terminal is FINAL (its facts settle);
2208
+ * one made while it is live keeps only a found launch name (a live run's frame may not be flushed yet). A final
2209
+ * read's positive facts are kept beside the store, so the next start reads no log for them.
2210
+ */
2211
+ runFactsMemo = new Map();
2212
+ /** One in-flight read per run and kind (a terminal-time read is never answered by a live-time one). */
2213
+ runFactsReads = new Map();
2214
+ /** crew#1880: `<db>.run-facts.jsonl`; null for an in-memory or unnamed store. */
2215
+ runFactsFile;
2216
+ /** One read of a run's log, shared by concurrent callers. `null` = no event-log binding; a failed read throws. */
2217
+ readRunFacts(view) {
2143
2218
  const id = view.session.id;
2144
- if (this.launchedWorkflows.has(id))
2145
- return this.launchedWorkflows.get(id);
2146
- let events;
2219
+ const final = TERMINAL_RUN_STATUSES.has(view.session.status);
2220
+ const key = `${final ? 'T' : 'L'}:${id}`;
2221
+ const inFlight = this.runFactsReads.get(key);
2222
+ if (inFlight !== undefined)
2223
+ return inFlight;
2224
+ const read = (async () => {
2225
+ const events = await this.runEvents(id);
2226
+ if (events === null)
2227
+ return null;
2228
+ const facts = { ...factsFromEvents(events), final };
2229
+ if (final) {
2230
+ this.runFactsMemo.set(id, facts);
2231
+ this.runFactsFile?.put(id, runFingerprint(view.session.problem), facts);
2232
+ }
2233
+ else if (facts.launched !== undefined && this.runFactsMemo.get(id)?.final !== true) {
2234
+ this.runFactsMemo.set(id, facts);
2235
+ }
2236
+ return facts;
2237
+ })();
2238
+ this.runFactsReads.set(key, read);
2239
+ const clear = () => {
2240
+ if (this.runFactsReads.get(key) === read)
2241
+ this.runFactsReads.delete(key);
2242
+ };
2243
+ read.then(clear, clear);
2244
+ return read;
2245
+ }
2246
+ /** The facts kept for this run on disk (bound to its problem). A kept launch name is folded into the in-process
2247
+ * memo (so later folds skip the hash); the memo is FINAL only when both facts were kept (a negative never is). */
2248
+ keptRunFacts(view) {
2249
+ if (this.runFactsFile === null)
2250
+ return undefined;
2251
+ const kept = this.runFactsFile.get(view.session.id, runFingerprint(view.session.problem));
2252
+ if (kept?.launched !== undefined) {
2253
+ this.runFactsMemo.set(view.session.id, {
2254
+ launched: kept.launched,
2255
+ endedAt: kept.endedAt ?? null,
2256
+ final: kept.endedAt !== undefined,
2257
+ });
2258
+ }
2259
+ return kept;
2260
+ }
2261
+ async launchedWorkflowOf(view) {
2262
+ const known = this.runFactsMemo.get(view.session.id);
2263
+ if (known !== undefined && (known.final || known.launched !== undefined))
2264
+ return known.launched;
2265
+ const kept = this.keptRunFacts(view);
2266
+ if (kept?.launched !== undefined)
2267
+ return kept.launched;
2147
2268
  try {
2148
- events = await this.runEvents(id);
2269
+ return (await this.readRunFacts(view))?.launched;
2149
2270
  }
2150
2271
  catch {
2151
2272
  return undefined;
2152
2273
  }
2153
- if (events === null)
2274
+ }
2275
+ /**
2276
+ * crew#1880: a terminal run's FIRST terminal frame `ts` (millis), for the `ended_at` backfill — from the in-process
2277
+ * memo, the kept facts, or one read of its log (shared with the identity read). `null` = the log holds no terminal
2278
+ * frame; `undefined` = no event-log binding. A failed read throws (the backfill retries it on a later request).
2279
+ */
2280
+ async runEndedFact(view) {
2281
+ const known = this.runFactsMemo.get(view.session.id);
2282
+ if (known?.final === true)
2283
+ return known.endedAt;
2284
+ const kept = this.keptRunFacts(view);
2285
+ if (kept?.endedAt !== undefined)
2286
+ return kept.endedAt;
2287
+ const facts = await this.readRunFacts(view);
2288
+ if (facts === null)
2154
2289
  return undefined;
2155
- const started = events.find((e) => e.type === 'sessionStarted');
2156
- // The engine spells it `workflowId` on the frame (core-ts `CoreEventJson`).
2157
- const raw = started?.['workflowId'];
2158
- const launched = started === undefined ? undefined : typeof raw === 'string' ? raw : null;
2159
- if (launched !== undefined || TERMINAL_RUN_STATUSES.has(view.session.status)) {
2160
- this.launchedWorkflows.set(id, launched);
2161
- }
2162
- return launched;
2290
+ return facts.final ? facts.endedAt : null;
2291
+ }
2292
+ /** crew#1880: write the kept facts still buffered (tests; `close` flushes too). */
2293
+ flushRunFacts() {
2294
+ return this.runFactsFile?.flush() ?? Promise.resolve();
2163
2295
  }
2164
2296
  /**
2165
2297
  * (DES-CATALOG-002 §2.3) The name one run was launched under, as the engine recorded it (`sessionStarted.workflowId`):
2166
2298
  * the run fence's fallback for a run crew no longer holds in memory. Memoized once found; `undefined` = not known.
2167
2299
  */
2168
2300
  async launchedWorkflowOfRun(runId) {
2169
- if (this.launchedWorkflows.has(runId))
2170
- return this.launchedWorkflows.get(runId);
2301
+ // As before crew#1880: a found launch name, or a terminal run's settled "none", answers without a read.
2302
+ const known = this.runFactsMemo.get(runId);
2303
+ if (known !== undefined && (known.final || known.launched !== undefined))
2304
+ return known.launched;
2171
2305
  let events;
2172
2306
  try {
2173
2307
  events = await this.runEvents(runId);
@@ -2175,13 +2309,14 @@ export class CoreAdapter {
2175
2309
  catch {
2176
2310
  return undefined;
2177
2311
  }
2178
- const started = events?.find((e) => e.type === 'sessionStarted');
2179
- if (started === undefined)
2312
+ if (events === null)
2313
+ return undefined;
2314
+ const facts = factsFromEvents(events);
2315
+ if (facts.launched === undefined)
2180
2316
  return undefined;
2181
- const raw = started['workflowId'];
2182
- const launched = typeof raw === 'string' ? raw : null;
2183
- this.launchedWorkflows.set(runId, launched);
2184
- return launched;
2317
+ if (known === undefined)
2318
+ this.runFactsMemo.set(runId, { ...facts, final: false });
2319
+ return facts.launched;
2185
2320
  }
2186
2321
  /**
2187
2322
  * Every run + its ordered units, each with its `run_identity` (seam X2) resolved from the engine's
@@ -3540,6 +3675,9 @@ export class CoreAdapter {
3540
3675
  // powerModeDefault (program DES-POWER-MODE): a boolean only; anything else reads as the shipped default (on).
3541
3676
  if ('powerModeDefault' in parsed && typeof parsed.powerModeDefault !== 'boolean')
3542
3677
  delete parsed.powerModeDefault;
3678
+ // standInReview (DES-STANDIN-001 §4): 'ask' | 'always' only; anything else reads as unset ('ask', asked each time).
3679
+ if ('standInReview' in parsed && parsed.standInReview !== 'ask' && parsed.standInReview !== 'always')
3680
+ delete parsed.standInReview;
3543
3681
  // newWorkSeats (F1/F2): a list of seat keys, or null. An invalid value is left out of the settings served (they
3544
3682
  // keep the API's type) but KEPT for the next write (`kept`): new work reads it strictly (`readNewWorkSeats`) and
3545
3683
  // refuses it, and an unrelated write that erased it would quietly widen the pool to every seat.
@@ -3651,6 +3789,7 @@ export class CoreAdapter {
3651
3789
  if (this.closed)
3652
3790
  return;
3653
3791
  this.closed = true;
3792
+ void this.runFactsFile?.flush();
3654
3793
  if (this.engineBus !== null && this.busDbPath !== undefined)
3655
3794
  detachEngineBus(this.busDbPath, this.engineBus);
3656
3795
  this.listeners.clear();