@aragon-agent/cli 0.6.44 → 0.6.45

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 (236) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +69 -2
  3. package/dist/agent/controller.d.ts +69 -0
  4. package/dist/agent/controller.js +224 -11
  5. package/dist/agent/governance-view.d.ts +40 -0
  6. package/dist/agent/governance-view.js +40 -0
  7. package/dist/agent/governance-wiring.d.ts +162 -0
  8. package/dist/agent/governance-wiring.js +470 -0
  9. package/dist/agent/plan-prompt.d.ts +7 -0
  10. package/dist/agent/plan-prompt.js +2 -1
  11. package/dist/agent/reducer.d.ts +33 -1
  12. package/dist/agent/reducer.js +45 -9
  13. package/dist/agent/system-prompt.d.ts +19 -0
  14. package/dist/agent/system-prompt.js +9 -1
  15. package/dist/cli.js +45 -1
  16. package/dist/commands/builtins.js +10 -4
  17. package/dist/commands/governance-command.d.ts +35 -0
  18. package/dist/commands/governance-command.js +292 -0
  19. package/dist/commands/governance-runs-table.d.ts +40 -0
  20. package/dist/commands/governance-runs-table.js +130 -0
  21. package/dist/commands/registry.d.ts +12 -0
  22. package/dist/config/app-paths.d.ts +10 -0
  23. package/dist/config/app-paths.js +12 -0
  24. package/dist/config/cli-commands.d.ts +18 -0
  25. package/dist/config/cli-commands.js +47 -1
  26. package/dist/config/env.d.ts +2 -1
  27. package/dist/config/env.js +10 -1
  28. package/dist/config/governance-config.d.ts +125 -0
  29. package/dist/config/governance-config.js +164 -0
  30. package/dist/config/governance-launch.d.ts +71 -0
  31. package/dist/config/governance-launch.js +58 -0
  32. package/dist/config/load.d.ts +15 -0
  33. package/dist/config/load.js +26 -1
  34. package/dist/config/model-profile-store.d.ts +4 -2
  35. package/dist/config/schema.d.ts +22 -0
  36. package/dist/config/schema.js +6 -0
  37. package/dist/config/store.js +14 -1
  38. package/dist/config/ui-state.d.ts +11 -0
  39. package/dist/config/ui-state.js +11 -0
  40. package/dist/diagnostics/doctor.js +20 -0
  41. package/dist/governance/card-normalize.d.ts +24 -0
  42. package/dist/governance/card-normalize.js +76 -0
  43. package/dist/governance/copy.d.ts +109 -0
  44. package/dist/governance/copy.js +223 -0
  45. package/dist/governance/engine/aftermath.d.ts +49 -0
  46. package/dist/governance/engine/aftermath.js +134 -0
  47. package/dist/governance/engine/artifact-persist.d.ts +35 -0
  48. package/dist/governance/engine/artifact-persist.js +86 -0
  49. package/dist/governance/engine/budget.d.ts +52 -0
  50. package/dist/governance/engine/budget.js +112 -0
  51. package/dist/governance/engine/cards.d.ts +18 -0
  52. package/dist/governance/engine/cards.js +186 -0
  53. package/dist/governance/engine/digest.d.ts +32 -0
  54. package/dist/governance/engine/digest.js +63 -0
  55. package/dist/governance/engine/engine-core.d.ts +219 -0
  56. package/dist/governance/engine/engine-core.js +562 -0
  57. package/dist/governance/engine/engine.d.ts +68 -0
  58. package/dist/governance/engine/engine.js +314 -0
  59. package/dist/governance/engine/estimate.d.ts +38 -0
  60. package/dist/governance/engine/estimate.js +46 -0
  61. package/dist/governance/engine/inspector.d.ts +16 -0
  62. package/dist/governance/engine/inspector.js +396 -0
  63. package/dist/governance/engine/integration.d.ts +35 -0
  64. package/dist/governance/engine/integration.js +220 -0
  65. package/dist/governance/engine/lifecycle.d.ts +29 -0
  66. package/dist/governance/engine/lifecycle.js +656 -0
  67. package/dist/governance/engine/pause.d.ts +56 -0
  68. package/dist/governance/engine/pause.js +107 -0
  69. package/dist/governance/engine/phase-members.d.ts +15 -0
  70. package/dist/governance/engine/phase-members.js +34 -0
  71. package/dist/governance/engine/phase-planner.d.ts +53 -0
  72. package/dist/governance/engine/phase-planner.js +282 -0
  73. package/dist/governance/engine/rebuild.d.ts +27 -0
  74. package/dist/governance/engine/rebuild.js +57 -0
  75. package/dist/governance/engine/report.d.ts +66 -0
  76. package/dist/governance/engine/report.js +220 -0
  77. package/dist/governance/engine/run-digest.d.ts +20 -0
  78. package/dist/governance/engine/run-digest.js +42 -0
  79. package/dist/governance/engine/spec-builder.d.ts +117 -0
  80. package/dist/governance/engine/spec-builder.js +321 -0
  81. package/dist/governance/engine/stage-runner.d.ts +22 -0
  82. package/dist/governance/engine/stage-runner.js +664 -0
  83. package/dist/governance/engine/start-input.d.ts +19 -0
  84. package/dist/governance/engine/start-input.js +111 -0
  85. package/dist/governance/engine/state-machine.d.ts +101 -0
  86. package/dist/governance/engine/state-machine.js +586 -0
  87. package/dist/governance/engine/submission-queries.d.ts +42 -0
  88. package/dist/governance/engine/submission-queries.js +97 -0
  89. package/dist/governance/engine/submission-render.d.ts +12 -0
  90. package/dist/governance/engine/submission-render.js +92 -0
  91. package/dist/governance/engine/submissions.d.ts +27 -0
  92. package/dist/governance/engine/submissions.js +455 -0
  93. package/dist/governance/engine/visibility.d.ts +104 -0
  94. package/dist/governance/engine/visibility.js +223 -0
  95. package/dist/governance/governed-dispatch.d.ts +19 -0
  96. package/dist/governance/governed-dispatch.js +17 -0
  97. package/dist/governance/limits.d.ts +107 -0
  98. package/dist/governance/limits.js +131 -0
  99. package/dist/governance/posture-transition.d.ts +38 -0
  100. package/dist/governance/posture-transition.js +44 -0
  101. package/dist/governance/posture.d.ts +35 -0
  102. package/dist/governance/posture.js +59 -0
  103. package/dist/governance/profiles.d.ts +48 -0
  104. package/dist/governance/profiles.js +140 -0
  105. package/dist/governance/prompts/orchestrator-block.d.ts +40 -0
  106. package/dist/governance/prompts/orchestrator-block.js +128 -0
  107. package/dist/governance/prompts/plan-addendum.d.ts +22 -0
  108. package/dist/governance/prompts/plan-addendum.js +60 -0
  109. package/dist/governance/prompts/refusals.d.ts +48 -0
  110. package/dist/governance/prompts/refusals.js +82 -0
  111. package/dist/governance/prompts/role-blocks.d.ts +40 -0
  112. package/dist/governance/prompts/role-blocks.js +255 -0
  113. package/dist/governance/report-reader.d.ts +31 -0
  114. package/dist/governance/report-reader.js +57 -0
  115. package/dist/governance/roles.d.ts +83 -0
  116. package/dist/governance/roles.js +142 -0
  117. package/dist/governance/rules/claims.d.ts +83 -0
  118. package/dist/governance/rules/claims.js +250 -0
  119. package/dist/governance/rules/elimination.d.ts +66 -0
  120. package/dist/governance/rules/elimination.js +105 -0
  121. package/dist/governance/rules/events-table.d.ts +46 -0
  122. package/dist/governance/rules/events-table.js +94 -0
  123. package/dist/governance/rules/failure-analysis.d.ts +28 -0
  124. package/dist/governance/rules/failure-analysis.js +93 -0
  125. package/dist/governance/rules/ledger-replay.d.ts +53 -0
  126. package/dist/governance/rules/ledger-replay.js +53 -0
  127. package/dist/governance/rules/ledger-state.d.ts +85 -0
  128. package/dist/governance/rules/ledger-state.js +175 -0
  129. package/dist/governance/rules/ledger.d.ts +228 -0
  130. package/dist/governance/rules/ledger.js +560 -0
  131. package/dist/governance/rules/rca.d.ts +68 -0
  132. package/dist/governance/rules/rca.js +220 -0
  133. package/dist/governance/rules/settlement.d.ts +129 -0
  134. package/dist/governance/rules/settlement.js +363 -0
  135. package/dist/governance/rules/suspicion.d.ts +66 -0
  136. package/dist/governance/rules/suspicion.js +169 -0
  137. package/dist/governance/store/artifacts.d.ts +81 -0
  138. package/dist/governance/store/artifacts.js +173 -0
  139. package/dist/governance/store/atomic.d.ts +79 -0
  140. package/dist/governance/store/atomic.js +119 -0
  141. package/dist/governance/store/events-log.d.ts +35 -0
  142. package/dist/governance/store/events-log.js +86 -0
  143. package/dist/governance/store/run-lock.d.ts +51 -0
  144. package/dist/governance/store/run-lock.js +122 -0
  145. package/dist/governance/store/run-store.d.ts +229 -0
  146. package/dist/governance/store/run-store.js +644 -0
  147. package/dist/governance/store/scoreboard-export.d.ts +53 -0
  148. package/dist/governance/store/scoreboard-export.js +65 -0
  149. package/dist/governance/tools/child-tools.d.ts +31 -0
  150. package/dist/governance/tools/child-tools.js +65 -0
  151. package/dist/governance/tools/guard.d.ts +71 -0
  152. package/dist/governance/tools/guard.js +194 -0
  153. package/dist/governance/tools/inspector-tools.d.ts +63 -0
  154. package/dist/governance/tools/inspector-tools.js +424 -0
  155. package/dist/governance/tools/lead-tools.d.ts +42 -0
  156. package/dist/governance/tools/lead-tools.js +226 -0
  157. package/dist/governance/tools/normalize-util.d.ts +101 -0
  158. package/dist/governance/tools/normalize-util.js +230 -0
  159. package/dist/governance/tools/scan-incomplete.d.ts +79 -0
  160. package/dist/governance/tools/scan-incomplete.js +486 -0
  161. package/dist/governance/tools/shared-tools.d.ts +44 -0
  162. package/dist/governance/tools/shared-tools.js +125 -0
  163. package/dist/governance/tools/submit-normalizers.d.ts +28 -0
  164. package/dist/governance/tools/submit-normalizers.js +474 -0
  165. package/dist/governance/tools/submit-tools.d.ts +26 -0
  166. package/dist/governance/tools/submit-tools.js +171 -0
  167. package/dist/governance/types.d.ts +661 -0
  168. package/dist/governance/types.js +27 -0
  169. package/dist/session/validate-session.js +32 -1
  170. package/dist/team/runtime.d.ts +8 -0
  171. package/dist/team/runtime.js +9 -0
  172. package/dist/team/subagent.d.ts +23 -0
  173. package/dist/team/subagent.js +14 -3
  174. package/dist/team/types.d.ts +6 -0
  175. package/dist/tools/index.d.ts +30 -7
  176. package/dist/tools/index.js +14 -0
  177. package/dist/tools/plan-tools.d.ts +14 -2
  178. package/dist/tools/plan-tools.js +5 -2
  179. package/dist/ui/App.js +145 -25
  180. package/dist/ui/BottomStatusRow.js +1 -1
  181. package/dist/ui/Composer.d.ts +7 -1
  182. package/dist/ui/Composer.js +9 -6
  183. package/dist/ui/GovernancePanel.d.ts +50 -0
  184. package/dist/ui/GovernancePanel.js +77 -0
  185. package/dist/ui/GovernanceRun.d.ts +18 -0
  186. package/dist/ui/GovernanceRun.js +11 -0
  187. package/dist/ui/StatusBar.d.ts +15 -2
  188. package/dist/ui/StatusBar.js +10 -4
  189. package/dist/ui/Transcript.js +3 -0
  190. package/dist/ui/entries/GovernanceCard.d.ts +30 -0
  191. package/dist/ui/entries/GovernanceCard.js +32 -0
  192. package/dist/ui/governance-copy.d.ts +69 -0
  193. package/dist/ui/governance-copy.js +104 -0
  194. package/dist/ui/governance-status.d.ts +145 -0
  195. package/dist/ui/governance-status.js +326 -0
  196. package/dist/ui/interaction-copy.d.ts +4 -0
  197. package/dist/ui/interaction-copy.js +5 -0
  198. package/dist/ui/interaction-hints.d.ts +17 -0
  199. package/dist/ui/interaction-hints.js +14 -2
  200. package/dist/ui/layout/governance-board.d.ts +121 -0
  201. package/dist/ui/layout/governance-board.js +382 -0
  202. package/dist/ui/layout/governance-card.d.ts +53 -0
  203. package/dist/ui/layout/governance-card.js +134 -0
  204. package/dist/ui/layout/governance-chip.d.ts +38 -0
  205. package/dist/ui/layout/governance-chip.js +64 -0
  206. package/dist/ui/layout/governance-panel.d.ts +85 -0
  207. package/dist/ui/layout/governance-panel.js +358 -0
  208. package/dist/ui/layout/governance-roster.d.ts +65 -0
  209. package/dist/ui/layout/governance-roster.js +275 -0
  210. package/dist/ui/layout/status-detail-layout.js +3 -3
  211. package/dist/ui/layout/status-layout.d.ts +5 -2
  212. package/dist/ui/layout/status-layout.js +10 -6
  213. package/dist/ui/layout/virtual-window.js +11 -0
  214. package/dist/ui/overlays/GovernanceBoardOverlay.d.ts +41 -0
  215. package/dist/ui/overlays/GovernanceBoardOverlay.js +76 -0
  216. package/dist/ui/overlays/GovernanceSettingsPage.d.ts +48 -0
  217. package/dist/ui/overlays/GovernanceSettingsPage.js +93 -0
  218. package/dist/ui/overlays/HelpOverlay.js +4 -3
  219. package/dist/ui/overlays/QuestionOverlay.d.ts +9 -1
  220. package/dist/ui/overlays/QuestionOverlay.js +4 -2
  221. package/dist/ui/overlays/SettingsScreen.d.ts +7 -0
  222. package/dist/ui/overlays/SettingsScreen.js +21 -1
  223. package/dist/ui/overlays/governance-settings.d.ts +79 -0
  224. package/dist/ui/overlays/governance-settings.js +140 -0
  225. package/dist/ui/overlays/model-profile-state.d.ts +6 -1
  226. package/dist/ui/overlays/model-profile-state.js +10 -0
  227. package/dist/ui/palettes.d.ts +17 -0
  228. package/dist/ui/palettes.js +9 -0
  229. package/dist/ui/scrollback/live-preview.js +2 -0
  230. package/dist/ui/scrollback/settled-boundary.js +3 -0
  231. package/dist/ui/shortcuts.js +2 -2
  232. package/dist/ui/theme.d.ts +7 -0
  233. package/dist/ui/theme.js +1 -0
  234. package/dist/ui/transcript-text.js +9 -0
  235. package/dist/ui/use-wheel-routing.js +3 -1
  236. package/package.json +2 -2
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Digest assembly shared by the lifecycle and the stage runner (governance-mode D-16).
3
+ *
4
+ * ASCII ONLY (`governance/` is glyph-scanned).
5
+ *
6
+ * Every `gov_run` / `gov_dispatch` answer is built here from the same four parts: a
7
+ * headline that starts with `OK:` / `NOT ACCEPTED:` / `ESCALATION:` / `PAUSED:`, the result
8
+ * lines, a footer with the limits and the TEAM-token line, and `NEXT:`. One builder means
9
+ * one place that guarantees the prefix, the byte budget and the footer wording.
10
+ */
11
+ import { GOV_LIMITS } from '../limits.js';
12
+ import { nextActions } from './state-machine.js';
13
+ import { budgetLine, budgetNotice } from './budget.js';
14
+ import { buildDigest, renderStandings } from './report.js';
15
+ /** The footer every digest carries: limits, then team tokens (never the session total). */
16
+ export function footerLines(core) {
17
+ const run = core.run;
18
+ if (run === null)
19
+ return [];
20
+ const budget = core.config().budgetTokens;
21
+ const lines = [
22
+ `Limits: rework <= ${run.limits.maxRework} per WP, fix cycles <= ${run.limits.maxFixCycles} ` +
23
+ `per phase, stage width <= ${core.deps.getTeamCeiling()}, ` +
24
+ `dispatch ${run.dispatches}/${GOV_LIMITS.hardMaxDispatches}.`,
25
+ budgetLine(run.usage, budget),
26
+ ];
27
+ const notice = budgetNotice(run.usage, budget);
28
+ if (notice !== null && notice.startsWith('BUDGET WARNING'))
29
+ lines.push(notice);
30
+ return lines;
31
+ }
32
+ /**
33
+ * What a digest says to do next while the USER has paused the run (`/gov pause`). The usual
34
+ * `paused` answer is `gov_run resume`, which would invite the Orchestrator to resume a run
35
+ * its human just stopped; only the human resumes it (their `/gov resume` is what sends the
36
+ * Orchestrator to call `gov_run resume`).
37
+ */
38
+ export const USER_PAUSED_NEXT = 'wait for the user: only they resume this run (/gov resume). Do not dispatch.';
39
+ /** Compose a complete tool answer for the current run state. */
40
+ export function composeDigest(core, parts) {
41
+ const run = core.run;
42
+ const waitingOnUser = core.userPaused && run?.status === 'paused';
43
+ const next = run === null
44
+ ? []
45
+ : waitingOnUser
46
+ ? [USER_PAUSED_NEXT]
47
+ : nextActions(run, { teamCeiling: core.deps.getTeamCeiling() });
48
+ return buildDigest({
49
+ headline: parts.headline,
50
+ results: parts.results ?? [],
51
+ ledger: parts.ledger ?? [],
52
+ ...(parts.standings === true && run !== null
53
+ ? { standings: renderStandings(core.standingRows(), core.health()) }
54
+ : {}),
55
+ warnings: parts.warnings ?? [],
56
+ nextActions: next,
57
+ footer: footerLines(core),
58
+ });
59
+ }
60
+ /** A refusal with the legal next moves attached (no run needed). */
61
+ export function refusal(core, reason) {
62
+ return composeDigest(core, { headline: `NOT ACCEPTED: ${reason}` });
63
+ }
@@ -0,0 +1,219 @@
1
+ /**
2
+ * EngineCore - the state, persistence and event plumbing every engine module shares
3
+ * (governance-mode 8.6, 12.1, 14.1).
4
+ *
5
+ * ASCII ONLY (`governance/` is glyph-scanned).
6
+ *
7
+ * WHY MEMORY IS AUTHORITATIVE AND DISK IS A QUEUE. The child tools (`gov_submit_*`,
8
+ * `ledger_*`) are synchronous: a model's tool call returns text, and the executor does not
9
+ * wait for a disk round trip. The run store is asynchronous (atomic rename, fsync, a FIFO
10
+ * mutex). So every mutation lands in memory synchronously and is appended to ONE promise
11
+ * chain that preserves order; `flush()` is awaited at every point where the orchestrator
12
+ * is waiting anyway (end of a stage, start, close). The event log stays the truth: the
13
+ * engine owns the sequence counter and stamps each event BEFORE the write resolves, which
14
+ * is also what lets a ledger entry carry the same `seq` as the event that produced it
15
+ * (replay equivalence, I-G2).
16
+ *
17
+ * LEDGER MUTATIONS GO THROUGH `ledgerOp` AND NOWHERE ELSE (I-G1 / I-G7): one function that
18
+ * logs the op, applies it with the pure ledger, and reports the entries it booked. Nothing
19
+ * else in the tree touches `core.ledger`.
20
+ */
21
+ import { type LedgerOp } from '../rules/ledger-replay.js';
22
+ import type { LedgerState } from '../types.js';
23
+ import type { DispatchOutcome, TeamEventListener } from '../../team/types.js';
24
+ import type { SubagentSpec } from '../../team/types.js';
25
+ import type { GovernanceConfig } from '../../config/governance-config.js';
26
+ import type { ArtifactStore } from '../store/artifacts.js';
27
+ import type { RunStore } from '../store/run-store.js';
28
+ import type { GovAgentState, GovernanceEvent, GovernanceEventListener, GovernanceSnapshot, InspectorReport, LedgerEntry, PipelineStep, RunState, StandingRow, StoredEventType, Submission, WorkPackage } from '../types.js';
29
+ import type { ModelCost } from '@aragon-agent/core';
30
+ /** The slice of `TeamRuntime` the engine drives. A seam so tests inject a scripted runtime. */
31
+ export interface TeamRuntimeLike {
32
+ dispatch(specs: SubagentSpec[], requested: number, signal?: AbortSignal): Promise<DispatchOutcome>;
33
+ subscribe(listener: TeamEventListener): () => void;
34
+ abortAll(): void;
35
+ isBusy(): boolean;
36
+ }
37
+ export interface EngineDeps {
38
+ runtime: TeamRuntimeLike;
39
+ store: RunStore;
40
+ artifacts: ArtifactStore;
41
+ /** Read LIVE every call: the user may change a limit mid-run. */
42
+ getConfig: () => GovernanceConfig;
43
+ /** `min(team.maxSubagents, TEAM_LIMITS.hardMaxSubagents)`, read live (D-24). */
44
+ getTeamCeiling: () => number;
45
+ getCwd: () => string;
46
+ getSessionId: () => string | undefined;
47
+ withPausedWatchdog: <T>(fn: () => Promise<T>) => Promise<T>;
48
+ hasApiKey: () => boolean;
49
+ modelCost?: () => ModelCost | undefined;
50
+ /** PLAN+GOVERN: take (and clear) the approved plan snapshot, if one is pending. */
51
+ takeApprovedPlan?: () => string | null;
52
+ /** Non-consuming read of the same snapshot, so a refused `start` does not lose the plan. */
53
+ peekApprovedPlan?: () => string | null;
54
+ /**
55
+ * `confirmCharter`: show the charter through the existing plan-review overlay. Resolves
56
+ * `null` on cancel / unavailable. Absent => no confirmation step.
57
+ */
58
+ confirmCharter?: (charter: CharterPlanInput, signal?: AbortSignal) => Promise<{
59
+ decision: 'approved' | 'revise' | 'dismissed';
60
+ feedback?: string;
61
+ } | null>;
62
+ now: () => number;
63
+ }
64
+ /** What the charter confirmation needs; the wiring turns it into a `NormalizedPlan`. */
65
+ export interface CharterPlanInput {
66
+ title: string;
67
+ summary: string;
68
+ steps: Array<{
69
+ title: string;
70
+ detail: string;
71
+ }>;
72
+ filesTouched: string[];
73
+ risks: string[];
74
+ }
75
+ /** One ledger entry a `ledgerOp` booked, with the agent that holds it. */
76
+ export interface BookedEntry {
77
+ agentId: string;
78
+ entry: LedgerEntry;
79
+ }
80
+ /** What the inspector's `ledger_settle` produced, for the digest and the next legal moves. */
81
+ export interface InspectorOutcome {
82
+ kind: 'settle' | 'integrate';
83
+ phase: number;
84
+ /** For integrate: did integration pass (or get accepted)? */
85
+ passed: boolean;
86
+ headline: string;
87
+ }
88
+ export interface LedgerOpResult {
89
+ seq: number;
90
+ booked: BookedEntry[];
91
+ }
92
+ /** Give an op the stored-event seq so replay stamps exactly what the live path stamped. */
93
+ export declare function stampOp(op: LedgerOp, seq: number): LedgerOp;
94
+ export declare class EngineCore {
95
+ readonly deps: EngineDeps;
96
+ run: RunState | null;
97
+ ledger: LedgerState;
98
+ /** Monotone event counter; the engine owns it (see file header). */
99
+ seq: number;
100
+ /** True once the user left the run in a state a new `start` may replace. */
101
+ readOnly: boolean;
102
+ /** WP ids (or `insp`) that received a valid submission during the CURRENT stage run. */
103
+ stageSubmitted: Set<string>;
104
+ /** `${identity}|${wpId}` -> consecutive validation failures (>= maxValidationFailures => absent). */
105
+ validationFailures: Map<string, number>;
106
+ /** One line per result produced this stage (digest body). */
107
+ stageResults: string[];
108
+ /** One line per ledger booking this stage (digest ledger section). */
109
+ stageLedgerLines: string[];
110
+ /** Warnings to print under the digest (caps, escalations, tripwires). */
111
+ stageWarnings: string[];
112
+ /** Set by `ledger_settle`; consumed (and cleared) by the stage runner. */
113
+ inspectorOutcome: InspectorOutcome | null;
114
+ /**
115
+ * Accepted submissions and inspector reports by artifact id (adjudication half). The
116
+ * store is async but a child's tool call is not, so reads during a run come from here;
117
+ * the resume path repopulates it from the artifact store.
118
+ */
119
+ submissionCache: Map<string, Submission | InspectorReport>;
120
+ /** Set when an artifact write was refused for the 20 MB budget (spec 12.1). */
121
+ storageExhausted: boolean;
122
+ /** Mechanical suspicion flags per 0-based phase (ownership violations), for the inspector. */
123
+ phaseFlags: Map<number, string[]>;
124
+ /** `gov_view` requests used per identity (D-9: at most one each). */
125
+ viewRequests: Map<string, number>;
126
+ /** Files each identity has written so far, from the team stream (best effort, 6.4). */
127
+ touchedFiles: Map<string, string[]>;
128
+ /** `gov_view` grants / denials per 0-based phase, shown to the inspector at settle. */
129
+ viewLog: Map<number, string[]>;
130
+ /** Set by whoever emitted this stage's `stage_ended` (exactly one per stage). */
131
+ stageEndedEmitted: boolean;
132
+ /** Set once the lazy retention prune ran for this engine instance. */
133
+ pruned: boolean;
134
+ /**
135
+ * `/gov pause` is waiting for the running stage to finish (governance-mode-v1-1 V-2).
136
+ * MEMORY ONLY: a request is never persisted, so a restart cannot surprise anyone with a
137
+ * run that "paused itself". Cleared when it is redeemed, cancelled, or the stage ends.
138
+ */
139
+ pauseRequested: boolean;
140
+ /**
141
+ * The current `paused` status came from `/gov pause`. Memory only, like the request; it
142
+ * lets `gov_dispatch` answer a user pause with the explicit "stop and wait" text while an
143
+ * Esc pause keeps its original refusal. Cleared by resume, a new run and close.
144
+ */
145
+ userPaused: boolean;
146
+ private chain;
147
+ private readonly listeners;
148
+ private rev;
149
+ private lastEmitAt;
150
+ private emitTimer;
151
+ private readonly agentStates;
152
+ private readonly activity;
153
+ private readonly lastDelta;
154
+ private stageAbort;
155
+ private teamUnsubscribe;
156
+ private persistError;
157
+ constructor(deps: EngineDeps);
158
+ now(): number;
159
+ config(): GovernanceConfig;
160
+ requireRun(): RunState;
161
+ wp(id: string): WorkPackage | undefined;
162
+ /** Public queue entry for modules that persist their own files in order with the rest. */
163
+ enqueueTask(job: () => Promise<unknown>): void;
164
+ private enqueue;
165
+ /** Append one event to the truth log. Returns the seq it was stamped with. */
166
+ log(type: StoredEventType, actor: string, payload: Record<string, unknown>): number;
167
+ /** Queue checkpoint writes for the current run and ledger. */
168
+ checkpoint(): void;
169
+ /** Queue a projection file write (`board.md`, reports, scoreboard). */
170
+ writeFile(rel: string, text: string): void;
171
+ exportScoreboard(): void;
172
+ /** Wait for every queued write. Returns a note when a write failed (and clears it). */
173
+ flush(): Promise<string | null>;
174
+ ledgerOp(op: LedgerOp, actor?: string): LedgerOpResult;
175
+ /** Append ledger lines for a digest (call after `ledgerOp`). */
176
+ noteBooked(booked: readonly BookedEntry[]): void;
177
+ resetStageScratch(): void;
178
+ private entriesAt;
179
+ private noteDelta;
180
+ standingRows(): StandingRow[];
181
+ health(): number | null;
182
+ /** Rebuild the ledger from an op log (used by `RunStore.load` replay). */
183
+ static replayLedger(events: ReadonlyArray<{
184
+ seq: number;
185
+ type: string;
186
+ payload: Record<string, unknown>;
187
+ }>, tailSeq: number): LedgerState;
188
+ setAgentState(id: string, state: GovAgentState): void;
189
+ agentState(id: string): GovAgentState | undefined;
190
+ /** Subscribe to the team stream for the duration of the engine (activity lines). */
191
+ attachTeam(): void;
192
+ detachTeam(): void;
193
+ clearActivity(): void;
194
+ beginStage(external?: AbortSignal): AbortController;
195
+ endStage(): void;
196
+ isStageRunning(): boolean;
197
+ /**
198
+ * A `gov_dispatch` call is in flight from `beginStage` until `endStage`: wider than
199
+ * `isStageRunning`, which is false while the stage is being set up and again while it
200
+ * writes its last checkpoint. A pause requested in either gap must wait, not fire.
201
+ */
202
+ isStageActive(): boolean;
203
+ abortStage(): void;
204
+ subscribe(listener: GovernanceEventListener): () => void;
205
+ emit(build: (snapshot: GovernanceSnapshot) => GovernanceEvent): void;
206
+ /** Coalesce chatty updates (activity lines) to one snapshot per interval (8.6). */
207
+ scheduleEmit(): void;
208
+ private cancelPendingEmit;
209
+ dispose(): void;
210
+ snapshot(): GovernanceSnapshot | null;
211
+ private rosterRows;
212
+ private wpOf;
213
+ private recent;
214
+ private alerts;
215
+ static schemaVersion(): number;
216
+ }
217
+ /** The phase to display: the first not-integrated one, else the last. */
218
+ export declare function currentDisplayPhase(run: RunState): number;
219
+ export declare function buildPipeline(run: RunState, phaseIndex: number): PipelineStep[];