@indigoai-us/hq-cli 5.345.251 → 5.345.252

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 (160) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/assets/scaffold/core/scripts/hq-session.sh +9 -0
  3. package/contracts/host-canary-release.json +9 -3
  4. package/dist/command-catalog.generated.d.ts +121 -1
  5. package/dist/command-catalog.generated.js +148 -1
  6. package/dist/commands/bot.js +7 -2
  7. package/dist/commands/core-bucket-c-work-mesh-offer-native.js +1 -1
  8. package/dist/commands/core-hq-session-binding.d.ts +140 -0
  9. package/dist/commands/core-hq-session-binding.js +363 -0
  10. package/dist/commands/core-hq-session-native.d.ts +23 -0
  11. package/dist/commands/core-hq-session-native.js +59 -9
  12. package/dist/commands/core-stop-autosave.js +1 -1
  13. package/dist/commands/core.js +10 -0
  14. package/dist/commands/doctor.d.ts +5 -1
  15. package/dist/commands/doctor.js +42 -5
  16. package/dist/commands/files.js +1 -1
  17. package/dist/commands/install-global.js +4 -2
  18. package/dist/commands/logout.js +4 -0
  19. package/dist/commands/ontology-graph.d.ts +2 -0
  20. package/dist/commands/ontology-graph.js +33 -0
  21. package/dist/commands/report.js +35 -2
  22. package/dist/commands/storage-gate.js +1 -1
  23. package/dist/commands/vault-retention-flag.js +2 -1
  24. package/dist/commands/whoami.js +1 -1
  25. package/dist/hq-cloud-sync-runner/bin/sync-runner.js +238 -221
  26. package/dist/hq-cloud-sync-runner/package.json +1 -1
  27. package/dist/index.js +3 -1
  28. package/dist/lib/agent-kit/inbox-poll-backoff-flag.js +1 -1
  29. package/dist/lib/agent-kit/mcp/tools.js +48 -0
  30. package/dist/lib/bot/fleet-bots-update-pass.js +1 -1
  31. package/dist/lib/bot/fleet-cron.d.ts +35 -0
  32. package/dist/lib/bot/fleet-cron.js +54 -12
  33. package/dist/lib/bot/fleet-local.d.ts +18 -0
  34. package/dist/lib/bot/fleet-local.js +51 -5
  35. package/dist/lib/bot/inbox-poll-backoff-flag.js +1 -1
  36. package/dist/lib/bot/signals-engine-flag.d.ts +1 -1
  37. package/dist/lib/bot/signals-engine-flag.js +1 -1
  38. package/dist/lib/cli-invite-nudge.js +1 -1
  39. package/dist/lib/client-version.d.ts +2 -0
  40. package/dist/lib/client-version.js +24 -0
  41. package/dist/lib/company-flag-gate.d.ts +30 -0
  42. package/dist/lib/company-flag-gate.js +104 -0
  43. package/dist/lib/core-utils/hook-timeout-debug-context-flag.js +1 -1
  44. package/dist/lib/daemon/flag.js +2 -1
  45. package/dist/lib/daemon/legacy-journal-gate.js +3 -1
  46. package/dist/lib/daemon/shared-flag-reads.js +1 -1
  47. package/dist/lib/doctor/checks/host-core.js +22 -4
  48. package/dist/lib/doctor/checks/jq.d.ts +27 -6
  49. package/dist/lib/doctor/checks/jq.js +46 -8
  50. package/dist/lib/doctor/client-health-reason-codes-flag.js +1 -1
  51. package/dist/lib/doctor/fix/refresh-sync-handoff.d.ts +1 -1
  52. package/dist/lib/doctor/fix/refresh-sync-handoff.js +1 -1
  53. package/dist/lib/flag-client-gate-headers.d.ts +38 -0
  54. package/dist/lib/flag-client-gate-headers.js +62 -0
  55. package/dist/lib/flag-client-headers.d.ts +15 -0
  56. package/dist/lib/flag-client-headers.js +25 -0
  57. package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
  58. package/dist/lib/flag-registry-worker-source.generated.js +1 -1
  59. package/dist/lib/flag-registry-worker.js +35 -0
  60. package/dist/lib/flag-registry.d.ts +1 -20
  61. package/dist/lib/flag-registry.js +5 -81
  62. package/dist/lib/hook-engine/adapter-core-pin.d.ts +29 -0
  63. package/dist/lib/hook-engine/adapter-core-pin.js +29 -0
  64. package/dist/lib/hook-engine/coverage.d.ts +50 -1
  65. package/dist/lib/hook-engine/coverage.js +111 -7
  66. package/dist/lib/hook-engine/reconcile.js +3 -2
  67. package/dist/lib/hot-channels/prompts/signals-pass.md +20 -0
  68. package/dist/lib/hot-channels/signal-changes.d.ts +228 -0
  69. package/dist/lib/hot-channels/signal-changes.js +683 -0
  70. package/dist/lib/hot-channels/signals-pass.d.ts +24 -0
  71. package/dist/lib/hot-channels/signals-pass.js +232 -12
  72. package/dist/lib/lanes/outpost-worktree-pruner-flag.d.ts +1 -1
  73. package/dist/lib/lanes/outpost-worktree-pruner-flag.js +1 -1
  74. package/dist/lib/lanes/registry-flag.js +2 -1
  75. package/dist/lib/lanes/spawn.js +11 -1
  76. package/dist/lib/mesh/live/binding-intent.d.ts +61 -0
  77. package/dist/lib/mesh/live/binding-intent.js +201 -0
  78. package/dist/lib/mesh/live/binding-receipt.d.ts +157 -0
  79. package/dist/lib/mesh/live/binding-receipt.js +365 -0
  80. package/dist/lib/mesh/live/company-flag-refresh.js +1 -1
  81. package/dist/lib/mesh/live/daemon/doctor-telemetry.d.ts +39 -0
  82. package/dist/lib/mesh/live/daemon/doctor-telemetry.js +58 -0
  83. package/dist/lib/mesh/live/daemon/install.js +2 -1
  84. package/dist/lib/mesh/live/daemon/presence.js +9 -0
  85. package/dist/lib/mesh/live/daemon/run.d.ts +3 -0
  86. package/dist/lib/mesh/live/daemon/run.js +33 -1
  87. package/dist/lib/ontology-graph/lineage/index.d.ts +401 -0
  88. package/dist/lib/ontology-graph/lineage/index.js +1027 -0
  89. package/dist/lib/ontology-graph/model/index.d.ts +54 -0
  90. package/dist/lib/ontology-graph/model/index.js +112 -0
  91. package/dist/lib/ontology-graph/model/pass-tasks.d.ts +75 -0
  92. package/dist/lib/ontology-graph/model/pass-tasks.js +166 -0
  93. package/dist/lib/ontology-graph/model/pass.d.ts +6 -0
  94. package/dist/lib/ontology-graph/model/pass.js +9 -2
  95. package/dist/lib/ontology-graph/model/pending-items.d.ts +8 -0
  96. package/dist/lib/ontology-graph/model/pending-items.js +24 -1
  97. package/dist/lib/ontology-graph/model/step.d.ts +1 -1
  98. package/dist/lib/ontology-graph/model/tasks.d.ts +11 -3
  99. package/dist/lib/ontology-graph/model/tasks.js +20 -7
  100. package/dist/lib/ontology-graph/read/brief.js +41 -6
  101. package/dist/lib/ontology-graph/read/index.d.ts +4 -0
  102. package/dist/lib/ontology-graph/read/index.js +173 -29
  103. package/dist/lib/ontology-graph/read/lineage.d.ts +101 -0
  104. package/dist/lib/ontology-graph/read/lineage.js +262 -0
  105. package/dist/lib/ontology-graph/replay/buffered-store.js +17 -0
  106. package/dist/lib/ontology-graph/replay/engine.d.ts +32 -1
  107. package/dist/lib/ontology-graph/replay/engine.js +213 -8
  108. package/dist/lib/ontology-graph/replay/extractors.d.ts +26 -0
  109. package/dist/lib/ontology-graph/replay/extractors.js +25 -1
  110. package/dist/lib/ontology-graph/replay/index.d.ts +2 -0
  111. package/dist/lib/ontology-graph/replay/index.js +9 -3
  112. package/dist/lib/ontology-graph/replay/signal-changes.d.ts +118 -0
  113. package/dist/lib/ontology-graph/replay/signal-changes.js +687 -0
  114. package/dist/lib/ontology-graph/schema/decision-status.d.ts +18 -0
  115. package/dist/lib/ontology-graph/schema/decision-status.js +20 -0
  116. package/dist/lib/ontology-graph/schema/index.d.ts +1 -0
  117. package/dist/lib/ontology-graph/schema/index.js +1 -0
  118. package/dist/lib/ontology-graph/setup/index.js +13 -3
  119. package/dist/lib/search-index/index.d.ts +33 -1
  120. package/dist/lib/search-index/index.js +180 -25
  121. package/dist/lib/search-index/qmd-exit-diagnostics.d.ts +7 -0
  122. package/dist/lib/search-index/qmd-exit-diagnostics.js +25 -1
  123. package/dist/lib/signals/adapters-catalog.js +1 -1
  124. package/dist/lib/sync-core/engine-holds.d.ts +1 -0
  125. package/dist/lib/sync-core/engine-holds.js +26 -0
  126. package/dist/lib/sync-core/engine-home.d.ts +3 -0
  127. package/dist/lib/sync-core/engine-home.js +41 -1
  128. package/dist/lib/sync-core/flag.js +2 -1
  129. package/dist/lib/sync-core/legacy-journal-export-child.js +5 -3
  130. package/dist/lib/sync-core/legacy-journal-export.d.ts +23 -4
  131. package/dist/lib/sync-core/legacy-journal-export.js +120 -55
  132. package/dist/lib/sync-core/reconcile.d.ts +2 -1
  133. package/dist/lib/sync-core/reconcile.js +30 -5
  134. package/dist/lib/sync-invalid-entity-warning.js +2 -1
  135. package/dist/lib/windows/install-followup.d.ts +41 -0
  136. package/dist/lib/windows/install-followup.js +87 -0
  137. package/dist/lib/windows/jq.d.ts +59 -0
  138. package/dist/lib/windows/jq.js +154 -3
  139. package/dist/lib/windows/user-path.d.ts +5 -0
  140. package/dist/lib/windows/user-path.js +1 -1
  141. package/dist/lib/work-context/auto-bind.d.ts +12 -0
  142. package/dist/lib/work-context/auto-bind.js +49 -3
  143. package/dist/lib/work-context/organize.d.ts +4 -2
  144. package/dist/lib/work-context/organize.js +18 -8
  145. package/dist/lib/work-context/reconcile.js +16 -1
  146. package/dist/main.js +12 -1
  147. package/dist/utils/client-health-contract.d.ts +30 -0
  148. package/dist/utils/client-health-contract.js +111 -0
  149. package/dist/utils/client-health.d.ts +5 -2
  150. package/dist/utils/client-health.js +74 -5
  151. package/dist/utils/exclusive-lock.d.ts +5 -1
  152. package/dist/utils/exclusive-lock.js +9 -2
  153. package/dist/utils/host-registration.d.ts +7 -0
  154. package/dist/utils/host-registration.js +10 -1
  155. package/dist/utils/pid.d.ts +31 -0
  156. package/dist/utils/pid.js +65 -0
  157. package/dist/utils/resident-package-preload.js +12 -4
  158. package/dist/utils/sentry-fingerprint.js +3 -0
  159. package/package.json +8 -8
  160. package/scripts/install-hook-engine.mjs +5 -3
@@ -0,0 +1,262 @@
1
+ /**
2
+ * WP-E: decision lineage for the read commands and the brief.
3
+ *
4
+ * A decision that a later decision replaced carries an open `superseded_by`
5
+ * edge; the later one carries the inverse `supersedes` edge. The readers use
6
+ * this module to say so on every line that shows a decision, so a replaced
7
+ * decision is never printed as the current one.
8
+ *
9
+ * Rules only. Nothing here calls a model or writes to the graph: it reads the
10
+ * open edges the caller is allowed to see and reports them.
11
+ *
12
+ * - Several edges to the same decision count once. The row with the strongest
13
+ * origin is kept, then the earliest date, then the lowest row id.
14
+ * - A chain is followed from each replacing decision along the same verb, one
15
+ * decision per step (the earliest replacement), for at most
16
+ * `LINEAGE_MAX_STEPS` steps. A step that returns to a decision already on
17
+ * the chain ends it and is reported as a loop.
18
+ *
19
+ * With the status rows of the decisions (`LineageFacts`) it also says
20
+ *
21
+ * - the kind of a link the rule `signal-changes` wrote: `replaced`, or
22
+ * `reversed` when the status row the same signal wrote says so;
23
+ * - that a decision was withdrawn (an open `withdrawn` status the rule wrote),
24
+ * which has a source and may have no replacing decision;
25
+ * - that a link no longer stands: a person or a record wrote, on or after the
26
+ * day of a link a rule or a model wrote, a status that says the decision
27
+ * stands (`decided`, `active`, ...). Such a link is not reported as a
28
+ * replacement. It is listed under `earlier`, with the status that set the
29
+ * decision back and who wrote it. A status that says the decision ended
30
+ * (`endsDecision` in schema/decision-status.ts: superseded, reversed,
31
+ * withdrawn, replaced) agrees with the link, which is reported as before.
32
+ */
33
+ import { endsDecision, originTier } from "../schema/index.js";
34
+ import { COMPANY_AUDIENCE } from "../types.js";
35
+ /** The origin of rows the rule `signal-changes` writes (replay/signal-changes.ts). */
36
+ export const SIGNAL_CHANGES_ORIGIN = "rule:signal-changes";
37
+ /**
38
+ * Appended to the citation of a row that rule wrote. The rule applies an entry a model wrote after reading a
39
+ * document, checked only by a quote; the note tells a reader the row is that reading, not a record.
40
+ */
41
+ export const SIGNAL_QUOTE_NOTE = "from a signal quote";
42
+ /** `, from a signal quote` for a row the rule `signal-changes` wrote, else nothing. */
43
+ export function originNote(by) {
44
+ return by === SIGNAL_CHANGES_ORIGIN ? `, ${SIGNAL_QUOTE_NOTE}` : "";
45
+ }
46
+ /** Most decisions on one lineage line: the direct one plus the chain after it. */
47
+ export const LINEAGE_MAX_STEPS = 5;
48
+ export const NO_LINEAGE = { replacedBy: [], replaces: [] };
49
+ export function isDecisionRef(ref) {
50
+ return ref.startsWith("decision/");
51
+ }
52
+ function byCode(a, b) {
53
+ return a < b ? -1 : a > b ? 1 : 0;
54
+ }
55
+ /** One step per distinct target of `verb`, earliest first. */
56
+ function distinctSteps(edges, from, verb) {
57
+ const best = new Map();
58
+ for (const stored of edges) {
59
+ const row = stored.row;
60
+ if (row.verb !== verb || row.valid.to || row.target === from || !isDecisionRef(row.target))
61
+ continue;
62
+ const held = best.get(row.target);
63
+ if (!held ||
64
+ (originTier(row.by) - originTier(held.row.by) || byCode(row.valid.from, held.row.valid.from) || byCode(stored.id, held.id)) < 0) {
65
+ best.set(row.target, stored);
66
+ }
67
+ }
68
+ return [...best.values()]
69
+ .map((stored) => ({
70
+ id: stored.row.target,
71
+ date: stored.row.valid.from,
72
+ source: stored.row.src,
73
+ by: stored.row.by,
74
+ conf: stored.row.conf,
75
+ audience: stored.audience,
76
+ }))
77
+ .sort((a, b) => byCode(a.date, b.date) || byCode(a.id, b.id));
78
+ }
79
+ function links(edgesOf, ref, own, verb) {
80
+ return distinctSteps(own, ref, verb).map((first) => {
81
+ const link = { ...first, chain: [] };
82
+ const seen = new Set([ref, first.id]);
83
+ let at = first.id;
84
+ for (;;) {
85
+ const next = distinctSteps(edgesOf(at), at, verb)[0];
86
+ if (!next)
87
+ break;
88
+ if (link.chain.length + 1 >= LINEAGE_MAX_STEPS) {
89
+ link.chainEnd = "limit";
90
+ break;
91
+ }
92
+ link.chain.push(next);
93
+ if (seen.has(next.id)) {
94
+ link.chainEnd = "loop";
95
+ break;
96
+ }
97
+ seen.add(next.id);
98
+ at = next.id;
99
+ }
100
+ return link;
101
+ });
102
+ }
103
+ const RULE_TIER = originTier(SIGNAL_CHANGES_ORIGIN);
104
+ function asStatus(stored) {
105
+ return { status: stored.row.value, date: stored.row.valid.from, source: stored.row.src, by: stored.row.by, conf: stored.row.conf, audience: stored.audience };
106
+ }
107
+ /** The current status a person or a record wrote on a decision, the latest one, or null. */
108
+ function heldStatus(facts, ref) {
109
+ let held = null;
110
+ for (const stored of facts.statusRows(ref)) {
111
+ if (originTier(stored.row.by) >= RULE_TIER || !facts.live(stored.row))
112
+ continue;
113
+ if (!held || byCode(stored.row.valid.from, held.row.valid.from) > 0 || (stored.row.valid.from === held.row.valid.from && stored.id < held.id))
114
+ held = stored;
115
+ }
116
+ return held;
117
+ }
118
+ /** `reversed` when the signal that wrote the link also wrote that status on the earlier decision, else `replaced`. */
119
+ function kindOf(facts, replaced, step) {
120
+ if (step.by !== SIGNAL_CHANGES_ORIGIN)
121
+ return "replaced";
122
+ const said = facts.statusRows(replaced).some((stored) => stored.row.by === SIGNAL_CHANGES_ORIGIN && stored.row.src === step.source && stored.row.value === "reversed");
123
+ return said ? "reversed" : "replaced";
124
+ }
125
+ /**
126
+ * True when a person or a record wrote, on or after the day of a rule's or a model's link, a status on the earlier
127
+ * decision that disagrees with the link: one that says the decision stands. A status that says it ended confirms
128
+ * the link, and the link is kept.
129
+ */
130
+ function setAside(held, step) {
131
+ return held !== null && originTier(step.by) >= RULE_TIER && held.row.valid.from >= step.date && !endsDecision(held.row.value);
132
+ }
133
+ /**
134
+ * The lineage of one entity. Anything that is not a decision has none, and
135
+ * its edges are not read. Without `facts` every link is reported as it is
136
+ * stored and its kind is not set.
137
+ */
138
+ export function decisionLineage(edgesOf, ref, facts) {
139
+ if (!isDecisionRef(ref))
140
+ return NO_LINEAGE;
141
+ const own = edgesOf(ref);
142
+ let replacedBy = links(edgesOf, ref, own, "superseded_by");
143
+ let replaces = links(edgesOf, ref, own, "supersedes");
144
+ if (!facts)
145
+ return replacedBy.length === 0 && replaces.length === 0 ? NO_LINEAGE : { replacedBy, replaces };
146
+ const held = heldStatus(facts, ref);
147
+ const earlier = [];
148
+ const stands = [];
149
+ for (const link of replacedBy) {
150
+ const kind = kindOf(facts, ref, link);
151
+ if (setAside(held, link)) {
152
+ const { chain: _chain, chainEnd: _chainEnd, ...step } = link;
153
+ earlier.push({ ...step, kind, setBack: asStatus(held) });
154
+ }
155
+ else {
156
+ stands.push({ ...link, kind, chain: link.chain.map((step, index) => ({ ...step, kind: kindOf(facts, index === 0 ? link.id : link.chain[index - 1].id, step) })) });
157
+ }
158
+ }
159
+ replacedBy = stands;
160
+ // A link the rule closed because the person's or record's status came after it is still part of the story.
161
+ if (held && !endsDecision(held.row.value) && facts.allEdges) {
162
+ for (const stored of facts.allEdges(ref)) {
163
+ const row = stored.row;
164
+ if (row.verb !== "superseded_by" || row.by !== SIGNAL_CHANGES_ORIGIN || !row.closed || row.closed.by !== held.row.src || !isDecisionRef(row.target))
165
+ continue;
166
+ if (earlier.some((link) => link.id === row.target))
167
+ continue;
168
+ const step = { id: row.target, date: row.valid.from, source: row.src, by: row.by, conf: row.conf, audience: stored.audience };
169
+ earlier.push({ ...step, kind: kindOf(facts, ref, step), setBack: asStatus(held) });
170
+ }
171
+ earlier.sort((a, b) => byCode(a.date, b.date) || byCode(a.id, b.id));
172
+ }
173
+ // The newer decision does not claim a decision whose status a person or a record has set since.
174
+ replaces = replaces
175
+ .filter((link) => !setAside(heldStatus(facts, link.id), link))
176
+ .map((link) => ({ ...link, kind: kindOf(facts, link.id, link), chain: link.chain.map((step) => ({ ...step, kind: kindOf(facts, step.id, step) })) }));
177
+ const lineage = { replacedBy, replaces };
178
+ if (held) {
179
+ // A person or a record says the decision was withdrawn: that is the withdrawal, cited to them.
180
+ if (held.row.value.trim().toLowerCase() === "withdrawn")
181
+ lineage.withdrawn = asStatus(held);
182
+ }
183
+ else {
184
+ const withdrawn = facts
185
+ .statusRows(ref)
186
+ .filter((stored) => stored.row.by === SIGNAL_CHANGES_ORIGIN && stored.row.value === "withdrawn" && facts.live(stored.row))
187
+ .sort((a, b) => byCode(b.row.valid.from, a.row.valid.from) || byCode(a.id, b.id))[0];
188
+ if (withdrawn)
189
+ lineage.withdrawn = asStatus(withdrawn);
190
+ }
191
+ if (earlier.length > 0)
192
+ lineage.earlier = earlier;
193
+ return replacedBy.length === 0 && replaces.length === 0 && !lineage.withdrawn && !lineage.earlier ? NO_LINEAGE : lineage;
194
+ }
195
+ /** `[<by> <conf>]`, with ` @<key>` when the row is not company-wide and the note for a row the signal rule wrote. */
196
+ function shortCite(step) {
197
+ const scope = step.audience === COMPANY_AUDIENCE ? "" : ` @${step.audience}`;
198
+ return `[${step.by} ${step.conf.toFixed(2)}${scope}${originNote(step.by)}]`;
199
+ }
200
+ /**
201
+ * The short marker a list line carries for a decision that no longer stands:
202
+ * ` | replaced <date> by <id> [<by> <conf>]` (or ` | reversed ...`), with
203
+ * ` (+N more)` when several decisions replaced it, and
204
+ * ` | withdrawn <date> [<by> <conf>, from a signal quote]` for a withdrawal.
205
+ * The bracket holds the origin and confidence of the row that says so, with
206
+ * ` @<key>` when it is not company-wide, so a reader can tell a model's
207
+ * reading (`agent:sonnet 0.60`) from a rule's. A link a person's or a
208
+ * record's later status set aside carries no marker. Empty for a decision
209
+ * that stands.
210
+ */
211
+ export function replacedMarker(lineage) {
212
+ const first = lineage.replacedBy[0];
213
+ const more = lineage.replacedBy.length - 1;
214
+ const replaced = first ? ` | ${first.kind ?? "replaced"} ${first.date} by ${first.id} ${shortCite(first)}${more > 0 ? ` (+${String(more)} more)` : ""}` : "";
215
+ const withdrawn = lineage.withdrawn ? ` | withdrawn ${lineage.withdrawn.date} ${shortCite(lineage.withdrawn)}` : "";
216
+ return `${replaced}${withdrawn}`;
217
+ }
218
+ /** The fields `--json` carries for each replacing or replaced decision. */
219
+ export function lineageJson(list, nameOf, fileOf = () => null) {
220
+ return list.map((link) => {
221
+ const file = fileOf(link.source);
222
+ return {
223
+ id: link.id,
224
+ name: nameOf(link.id),
225
+ kind: link.kind ?? "replaced",
226
+ date: link.date,
227
+ source: link.source,
228
+ ...(file ? { file } : {}),
229
+ by: link.by,
230
+ conf: link.conf,
231
+ audience: link.audience,
232
+ chain: link.chain.map((step) => ({ id: step.id, name: nameOf(step.id), date: step.date, source: step.source })),
233
+ ...(link.chainEnd ? { chainEnd: link.chainEnd } : {}),
234
+ };
235
+ });
236
+ }
237
+ /** `[{id, kind, date, source, by, conf}]` for a list line: the short form of `lineageJson`. */
238
+ export function replacedByShortJson(lineage) {
239
+ return lineage.replacedBy.map((link) => ({ id: link.id, kind: link.kind ?? "replaced", date: link.date, source: link.source, by: link.by, conf: link.conf }));
240
+ }
241
+ /** `withdrawn` and `earlierLinks` for `--json`, present only when the decision has them. */
242
+ export function lineageStatusJson(lineage, nameOf) {
243
+ return {
244
+ ...(lineage.withdrawn ? { withdrawn: { ...lineage.withdrawn } } : {}),
245
+ ...(lineage.earlier
246
+ ? {
247
+ earlierLinks: lineage.earlier.map((link) => ({
248
+ id: link.id,
249
+ name: nameOf(link.id),
250
+ kind: link.kind ?? "replaced",
251
+ date: link.date,
252
+ source: link.source,
253
+ by: link.by,
254
+ conf: link.conf,
255
+ audience: link.audience,
256
+ setBack: { ...link.setBack },
257
+ })),
258
+ }
259
+ : {}),
260
+ };
261
+ }
262
+ //# sourceMappingURL=lineage.js.map
@@ -23,6 +23,23 @@ export function bufferStore(real) {
23
23
  open();
24
24
  return real.closeRow(ref, audience, id, closure);
25
25
  },
26
+ // Present only when the store underneath can take a closure back (the file store can).
27
+ ...(typeof real.reopenRow === "function"
28
+ ? {
29
+ reopenRow(ref, audience, id) {
30
+ open();
31
+ return real.reopenRow?.(ref, audience, id) ?? false;
32
+ },
33
+ }
34
+ : {}),
35
+ ...(typeof real.removeRows === "function"
36
+ ? {
37
+ removeRows(ref, audience, ids) {
38
+ open();
39
+ return real.removeRows?.(ref, audience, ids) ?? 0;
40
+ },
41
+ }
42
+ : {}),
26
43
  listEntitiesWithRows: (audiences) => real.listEntitiesWithRows(audiences),
27
44
  appendLog(entry) {
28
45
  open();
@@ -1,6 +1,7 @@
1
1
  import { importLegacy as defaultImportLegacy } from "../legacy/index.js";
2
+ import { type ModelTasksSetting } from "../model/index.js";
2
3
  import { compilePages as defaultCompilePages } from "../pages/index.js";
3
- import { type AudienceKey, type EntityRef, type GraphContext, type GraphSchema, type GraphStore, type IngestRow, type IsoDate, type LegacyImportResult, type MemberIdentity, type Contradiction, type ModelRunner, type ModelStep, type Origin, type RebuildOptions, type ReplayRunResult, type Resolver, type RuleExtractor, type SourceRef, type UpdateOptions } from "../types.js";
4
+ import { type AudienceKey, type EntityRef, type GraphContext, type GraphSchema, type GraphStore, type IngestRow, type IsoDate, type LedgerEntry, type LegacyImportResult, type MemberIdentity, type Contradiction, type ModelRunner, type ModelStep, type Origin, type RebuildOptions, type ReplayRunResult, type Resolver, type RuleExtractor, type SourceRef, type UpdateOptions } from "../types.js";
4
5
  import { briefCommand as defaultBriefCommand } from "../read/index.js";
5
6
  import { type ClassedInput, type Corpus } from "./readers.js";
6
7
  export declare const TYPING_PROMPT_VERSION = "replay-typing-v1";
@@ -35,6 +36,32 @@ export declare function resolveDayBudget(options?: {
35
36
  outputTokens: number;
36
37
  overridden: boolean;
37
38
  };
39
+ /**
40
+ * What a run revised: lineage the day's signals state (`changes`), written by the rule `signal-changes`.
41
+ * Summed from the counters the rule leaves on each replayed day's ledger entry.
42
+ */
43
+ export interface RevisedReport {
44
+ /** `changes` entries the run's signals stated. */
45
+ stated: number;
46
+ /** Earlier decisions whose status became `superseded`, `reversed`, `withdrawn`. */
47
+ replaced: number;
48
+ reversed: number;
49
+ withdrawn: number;
50
+ /** Status rows closed on earlier decisions. */
51
+ statusClosed: number;
52
+ /** `supersedes` edges written. */
53
+ links: number;
54
+ /** Model-written links that pointed the other way and were closed in favor of the rule's. */
55
+ modelLinksClosed: number;
56
+ /** Rows taken out because the signal that stated them no longer does. */
57
+ rowsRemoved: number;
58
+ /** Entries the rule left alone, by reason. */
59
+ leftAlone: Record<string, number>;
60
+ }
61
+ /** The revision summary of a set of ledger entries, or null when none of them saw a `changes` entry. */
62
+ export declare function revisedFrom(entries: readonly Pick<LedgerEntry, "counters">[]): RevisedReport | null;
63
+ /** The lines a run summary prints for what it revised: one for what was written, one for what was left alone. */
64
+ export declare function revisedLines(revised: RevisedReport): string[];
38
65
  /** What the run's model step was allowed, what it used, and whether a cap stopped it. */
39
66
  export interface ModelCapReport {
40
67
  /** The cap per day this run ran under. */
@@ -64,6 +91,8 @@ export interface ReplayDeps {
64
91
  modelRunner?: ModelRunner;
65
92
  /** Model name stamped on `by agent:<model>` rows. */
66
93
  modelName?: string;
94
+ /** Which model tasks run. Default: `model_tasks` in the company's `settings/ontology.yaml`, every task on when absent. */
95
+ modelTasks?: ModelTasksSetting;
67
96
  importLegacy?: typeof defaultImportLegacy | null;
68
97
  /**
69
98
  * How the legacy import gets the org layer (reporting lines, workspace
@@ -127,6 +156,8 @@ export interface ReplayReport extends ReplayRunResult {
127
156
  notes: string[];
128
157
  /** Present when the run had a model step that reports totals. */
129
158
  modelCap?: ModelCapReport;
159
+ /** What the run's days revised by rule from the `changes` their signals state. Absent when no signal stated one. */
160
+ revised?: RevisedReport;
130
161
  }
131
162
  interface TypingItem {
132
163
  ref: SourceRef;