@aragon-agent/cli 0.6.43 → 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.
- package/CHANGELOG.md +44 -0
- package/README.md +69 -2
- package/dist/agent/controller.d.ts +69 -0
- package/dist/agent/controller.js +224 -11
- package/dist/agent/governance-view.d.ts +40 -0
- package/dist/agent/governance-view.js +40 -0
- package/dist/agent/governance-wiring.d.ts +162 -0
- package/dist/agent/governance-wiring.js +470 -0
- package/dist/agent/plan-prompt.d.ts +7 -0
- package/dist/agent/plan-prompt.js +2 -1
- package/dist/agent/reducer.d.ts +33 -1
- package/dist/agent/reducer.js +45 -9
- package/dist/agent/system-prompt.d.ts +19 -0
- package/dist/agent/system-prompt.js +9 -1
- package/dist/cli.js +45 -1
- package/dist/commands/builtins.js +10 -4
- package/dist/commands/governance-command.d.ts +35 -0
- package/dist/commands/governance-command.js +292 -0
- package/dist/commands/governance-runs-table.d.ts +40 -0
- package/dist/commands/governance-runs-table.js +130 -0
- package/dist/commands/registry.d.ts +12 -0
- package/dist/config/app-paths.d.ts +10 -0
- package/dist/config/app-paths.js +12 -0
- package/dist/config/cli-commands.d.ts +18 -0
- package/dist/config/cli-commands.js +47 -1
- package/dist/config/env.d.ts +2 -1
- package/dist/config/env.js +10 -1
- package/dist/config/governance-config.d.ts +125 -0
- package/dist/config/governance-config.js +164 -0
- package/dist/config/governance-launch.d.ts +71 -0
- package/dist/config/governance-launch.js +58 -0
- package/dist/config/load.d.ts +15 -0
- package/dist/config/load.js +26 -1
- package/dist/config/model-profile-store.d.ts +4 -2
- package/dist/config/schema.d.ts +22 -0
- package/dist/config/schema.js +6 -0
- package/dist/config/store.js +14 -1
- package/dist/config/ui-state.d.ts +11 -0
- package/dist/config/ui-state.js +11 -0
- package/dist/diagnostics/doctor.js +20 -0
- package/dist/governance/card-normalize.d.ts +24 -0
- package/dist/governance/card-normalize.js +76 -0
- package/dist/governance/copy.d.ts +109 -0
- package/dist/governance/copy.js +223 -0
- package/dist/governance/engine/aftermath.d.ts +49 -0
- package/dist/governance/engine/aftermath.js +134 -0
- package/dist/governance/engine/artifact-persist.d.ts +35 -0
- package/dist/governance/engine/artifact-persist.js +86 -0
- package/dist/governance/engine/budget.d.ts +52 -0
- package/dist/governance/engine/budget.js +112 -0
- package/dist/governance/engine/cards.d.ts +18 -0
- package/dist/governance/engine/cards.js +186 -0
- package/dist/governance/engine/digest.d.ts +32 -0
- package/dist/governance/engine/digest.js +63 -0
- package/dist/governance/engine/engine-core.d.ts +219 -0
- package/dist/governance/engine/engine-core.js +562 -0
- package/dist/governance/engine/engine.d.ts +68 -0
- package/dist/governance/engine/engine.js +314 -0
- package/dist/governance/engine/estimate.d.ts +38 -0
- package/dist/governance/engine/estimate.js +46 -0
- package/dist/governance/engine/inspector.d.ts +16 -0
- package/dist/governance/engine/inspector.js +396 -0
- package/dist/governance/engine/integration.d.ts +35 -0
- package/dist/governance/engine/integration.js +220 -0
- package/dist/governance/engine/lifecycle.d.ts +29 -0
- package/dist/governance/engine/lifecycle.js +656 -0
- package/dist/governance/engine/pause.d.ts +56 -0
- package/dist/governance/engine/pause.js +107 -0
- package/dist/governance/engine/phase-members.d.ts +15 -0
- package/dist/governance/engine/phase-members.js +34 -0
- package/dist/governance/engine/phase-planner.d.ts +53 -0
- package/dist/governance/engine/phase-planner.js +282 -0
- package/dist/governance/engine/rebuild.d.ts +27 -0
- package/dist/governance/engine/rebuild.js +57 -0
- package/dist/governance/engine/report.d.ts +66 -0
- package/dist/governance/engine/report.js +220 -0
- package/dist/governance/engine/run-digest.d.ts +20 -0
- package/dist/governance/engine/run-digest.js +42 -0
- package/dist/governance/engine/spec-builder.d.ts +117 -0
- package/dist/governance/engine/spec-builder.js +321 -0
- package/dist/governance/engine/stage-runner.d.ts +22 -0
- package/dist/governance/engine/stage-runner.js +664 -0
- package/dist/governance/engine/start-input.d.ts +19 -0
- package/dist/governance/engine/start-input.js +111 -0
- package/dist/governance/engine/state-machine.d.ts +101 -0
- package/dist/governance/engine/state-machine.js +586 -0
- package/dist/governance/engine/submission-queries.d.ts +42 -0
- package/dist/governance/engine/submission-queries.js +97 -0
- package/dist/governance/engine/submission-render.d.ts +12 -0
- package/dist/governance/engine/submission-render.js +92 -0
- package/dist/governance/engine/submissions.d.ts +27 -0
- package/dist/governance/engine/submissions.js +455 -0
- package/dist/governance/engine/visibility.d.ts +104 -0
- package/dist/governance/engine/visibility.js +223 -0
- package/dist/governance/governed-dispatch.d.ts +19 -0
- package/dist/governance/governed-dispatch.js +17 -0
- package/dist/governance/limits.d.ts +107 -0
- package/dist/governance/limits.js +131 -0
- package/dist/governance/posture-transition.d.ts +38 -0
- package/dist/governance/posture-transition.js +44 -0
- package/dist/governance/posture.d.ts +35 -0
- package/dist/governance/posture.js +59 -0
- package/dist/governance/profiles.d.ts +48 -0
- package/dist/governance/profiles.js +140 -0
- package/dist/governance/prompts/orchestrator-block.d.ts +40 -0
- package/dist/governance/prompts/orchestrator-block.js +128 -0
- package/dist/governance/prompts/plan-addendum.d.ts +22 -0
- package/dist/governance/prompts/plan-addendum.js +60 -0
- package/dist/governance/prompts/refusals.d.ts +48 -0
- package/dist/governance/prompts/refusals.js +82 -0
- package/dist/governance/prompts/role-blocks.d.ts +40 -0
- package/dist/governance/prompts/role-blocks.js +255 -0
- package/dist/governance/report-reader.d.ts +31 -0
- package/dist/governance/report-reader.js +57 -0
- package/dist/governance/roles.d.ts +83 -0
- package/dist/governance/roles.js +142 -0
- package/dist/governance/rules/claims.d.ts +83 -0
- package/dist/governance/rules/claims.js +250 -0
- package/dist/governance/rules/elimination.d.ts +66 -0
- package/dist/governance/rules/elimination.js +105 -0
- package/dist/governance/rules/events-table.d.ts +46 -0
- package/dist/governance/rules/events-table.js +94 -0
- package/dist/governance/rules/failure-analysis.d.ts +28 -0
- package/dist/governance/rules/failure-analysis.js +93 -0
- package/dist/governance/rules/ledger-replay.d.ts +53 -0
- package/dist/governance/rules/ledger-replay.js +53 -0
- package/dist/governance/rules/ledger-state.d.ts +85 -0
- package/dist/governance/rules/ledger-state.js +175 -0
- package/dist/governance/rules/ledger.d.ts +228 -0
- package/dist/governance/rules/ledger.js +560 -0
- package/dist/governance/rules/rca.d.ts +68 -0
- package/dist/governance/rules/rca.js +220 -0
- package/dist/governance/rules/settlement.d.ts +129 -0
- package/dist/governance/rules/settlement.js +363 -0
- package/dist/governance/rules/suspicion.d.ts +66 -0
- package/dist/governance/rules/suspicion.js +169 -0
- package/dist/governance/store/artifacts.d.ts +81 -0
- package/dist/governance/store/artifacts.js +173 -0
- package/dist/governance/store/atomic.d.ts +79 -0
- package/dist/governance/store/atomic.js +119 -0
- package/dist/governance/store/events-log.d.ts +35 -0
- package/dist/governance/store/events-log.js +86 -0
- package/dist/governance/store/run-lock.d.ts +51 -0
- package/dist/governance/store/run-lock.js +122 -0
- package/dist/governance/store/run-store.d.ts +229 -0
- package/dist/governance/store/run-store.js +644 -0
- package/dist/governance/store/scoreboard-export.d.ts +53 -0
- package/dist/governance/store/scoreboard-export.js +65 -0
- package/dist/governance/tools/child-tools.d.ts +31 -0
- package/dist/governance/tools/child-tools.js +65 -0
- package/dist/governance/tools/guard.d.ts +71 -0
- package/dist/governance/tools/guard.js +194 -0
- package/dist/governance/tools/inspector-tools.d.ts +63 -0
- package/dist/governance/tools/inspector-tools.js +424 -0
- package/dist/governance/tools/lead-tools.d.ts +42 -0
- package/dist/governance/tools/lead-tools.js +226 -0
- package/dist/governance/tools/normalize-util.d.ts +101 -0
- package/dist/governance/tools/normalize-util.js +230 -0
- package/dist/governance/tools/scan-incomplete.d.ts +79 -0
- package/dist/governance/tools/scan-incomplete.js +486 -0
- package/dist/governance/tools/shared-tools.d.ts +44 -0
- package/dist/governance/tools/shared-tools.js +125 -0
- package/dist/governance/tools/submit-normalizers.d.ts +28 -0
- package/dist/governance/tools/submit-normalizers.js +474 -0
- package/dist/governance/tools/submit-tools.d.ts +26 -0
- package/dist/governance/tools/submit-tools.js +171 -0
- package/dist/governance/types.d.ts +661 -0
- package/dist/governance/types.js +27 -0
- package/dist/proc/kill-tree.d.ts +19 -1
- package/dist/proc/kill-tree.js +32 -5
- package/dist/proc/limits.d.ts +19 -0
- package/dist/proc/limits.js +19 -0
- package/dist/proc/supervisor.js +8 -1
- package/dist/session/validate-session.js +32 -1
- package/dist/team/runtime.d.ts +8 -0
- package/dist/team/runtime.js +9 -0
- package/dist/team/subagent.d.ts +23 -0
- package/dist/team/subagent.js +14 -3
- package/dist/team/types.d.ts +6 -0
- package/dist/tools/bounded-spawn.d.ts +56 -0
- package/dist/tools/bounded-spawn.js +76 -0
- package/dist/tools/index.d.ts +30 -7
- package/dist/tools/index.js +14 -0
- package/dist/tools/plan-tools.d.ts +14 -2
- package/dist/tools/plan-tools.js +5 -2
- package/dist/tools/search-tools.js +52 -44
- package/dist/ui/App.js +145 -25
- package/dist/ui/BottomStatusRow.js +1 -1
- package/dist/ui/Composer.d.ts +7 -1
- package/dist/ui/Composer.js +9 -6
- package/dist/ui/GovernancePanel.d.ts +50 -0
- package/dist/ui/GovernancePanel.js +77 -0
- package/dist/ui/GovernanceRun.d.ts +18 -0
- package/dist/ui/GovernanceRun.js +11 -0
- package/dist/ui/ScrollbackShell.d.ts +35 -7
- package/dist/ui/ScrollbackShell.js +1 -1
- package/dist/ui/StatusBar.d.ts +15 -2
- package/dist/ui/StatusBar.js +10 -4
- package/dist/ui/Transcript.js +3 -0
- package/dist/ui/entries/GovernanceCard.d.ts +30 -0
- package/dist/ui/entries/GovernanceCard.js +32 -0
- package/dist/ui/governance-copy.d.ts +69 -0
- package/dist/ui/governance-copy.js +104 -0
- package/dist/ui/governance-status.d.ts +145 -0
- package/dist/ui/governance-status.js +326 -0
- package/dist/ui/interaction-copy.d.ts +4 -0
- package/dist/ui/interaction-copy.js +5 -0
- package/dist/ui/interaction-hints.d.ts +17 -0
- package/dist/ui/interaction-hints.js +14 -2
- package/dist/ui/layout/governance-board.d.ts +121 -0
- package/dist/ui/layout/governance-board.js +382 -0
- package/dist/ui/layout/governance-card.d.ts +53 -0
- package/dist/ui/layout/governance-card.js +134 -0
- package/dist/ui/layout/governance-chip.d.ts +38 -0
- package/dist/ui/layout/governance-chip.js +64 -0
- package/dist/ui/layout/governance-panel.d.ts +85 -0
- package/dist/ui/layout/governance-panel.js +358 -0
- package/dist/ui/layout/governance-roster.d.ts +65 -0
- package/dist/ui/layout/governance-roster.js +275 -0
- package/dist/ui/layout/status-detail-layout.js +3 -3
- package/dist/ui/layout/status-layout.d.ts +5 -2
- package/dist/ui/layout/status-layout.js +10 -6
- package/dist/ui/layout/virtual-window.js +11 -0
- package/dist/ui/overlays/GovernanceBoardOverlay.d.ts +41 -0
- package/dist/ui/overlays/GovernanceBoardOverlay.js +76 -0
- package/dist/ui/overlays/GovernanceSettingsPage.d.ts +48 -0
- package/dist/ui/overlays/GovernanceSettingsPage.js +93 -0
- package/dist/ui/overlays/HelpOverlay.js +4 -3
- package/dist/ui/overlays/QuestionOverlay.d.ts +9 -1
- package/dist/ui/overlays/QuestionOverlay.js +4 -2
- package/dist/ui/overlays/SettingsScreen.d.ts +7 -0
- package/dist/ui/overlays/SettingsScreen.js +21 -1
- package/dist/ui/overlays/governance-settings.d.ts +79 -0
- package/dist/ui/overlays/governance-settings.js +140 -0
- package/dist/ui/overlays/model-profile-state.d.ts +6 -1
- package/dist/ui/overlays/model-profile-state.js +10 -0
- package/dist/ui/palettes.d.ts +17 -0
- package/dist/ui/palettes.js +9 -0
- package/dist/ui/scrollback/LiveTail.d.ts +3 -1
- package/dist/ui/scrollback/budget.d.ts +12 -6
- package/dist/ui/scrollback/budget.js +11 -4
- package/dist/ui/scrollback/live-preview.js +2 -0
- package/dist/ui/scrollback/settled-boundary.js +3 -0
- package/dist/ui/scrollback/tail-anchor.d.ts +5 -2
- package/dist/ui/scrollback/tail-anchor.js +3 -1
- package/dist/ui/shortcuts.js +2 -2
- package/dist/ui/theme.d.ts +7 -0
- package/dist/ui/theme.js +1 -0
- package/dist/ui/transcript-text.js +9 -0
- package/dist/ui/use-wheel-routing.js +3 -1
- package/package.json +2 -2
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Ledger - the ONE accounting path (governance-mode 5.3 / 5.8 / 5.10, I-G7).
|
|
3
|
+
*
|
|
4
|
+
* ASCII ONLY (`governance/` is glyph-scanned).
|
|
5
|
+
*
|
|
6
|
+
* Engine-booked events (settlement, RCA expansion, claim rulings) and inspector-booked
|
|
7
|
+
* events (`ledger_apply`) all arrive here as a `LedgerEvent`, are looked up in the same
|
|
8
|
+
* catalogue and are held to the same per-event and per-incident limits. There is no second
|
|
9
|
+
* way to change a balance, which is what makes the audit trail believable.
|
|
10
|
+
*
|
|
11
|
+
* EVERY FUNCTION IS PURE AND DETERMINISTIC (I-G2). A function takes a `LedgerState` and
|
|
12
|
+
* returns a NEW one; it never mutates its input, never reads a clock and never draws a
|
|
13
|
+
* random number - `at` travels inside the event. Replaying the stored event list therefore
|
|
14
|
+
* reproduces the checkpoint byte-for-byte. `governance-ledger.test.ts` proves it with a
|
|
15
|
+
* seeded random-sequence property test run on deep-frozen states.
|
|
16
|
+
*
|
|
17
|
+
* KILL READS `confirmed` ONLY (I-G3). A clawback shrinks `provisional`, so a primary DEV
|
|
18
|
+
* can lose most of their TOTAL without being eliminated; only a depleted `confirmed`
|
|
19
|
+
* pool, or the tail rule, removes an agent.
|
|
20
|
+
*
|
|
21
|
+
* Related modules: `ledger-state.ts` (construction + queries), `failure-analysis.ts`
|
|
22
|
+
* (successor brief), `ledger-replay.ts` (op log), `elimination.ts` (tail rule).
|
|
23
|
+
*/
|
|
24
|
+
import type { AgentRecord, FailureAnalysis, LedgerEntry, LedgerState } from '../types.js';
|
|
25
|
+
import { type EventCode, type EventDef, type Settlement } from './events-table.js';
|
|
26
|
+
export * from './ledger-state.js';
|
|
27
|
+
/** C2 for an agent that is not the primary cause of the failed integration (5.7). */
|
|
28
|
+
export declare const C2_RELIEF_DELTA = -2;
|
|
29
|
+
/** One booking request. `delta` is never supplied: it comes from the catalogue. */
|
|
30
|
+
export interface LedgerEvent {
|
|
31
|
+
code: EventCode;
|
|
32
|
+
agentId: string;
|
|
33
|
+
at: number;
|
|
34
|
+
phase: number;
|
|
35
|
+
by: LedgerEntry['by'];
|
|
36
|
+
reason: string;
|
|
37
|
+
wpId?: string;
|
|
38
|
+
incidentId?: string;
|
|
39
|
+
evidence?: string;
|
|
40
|
+
/** C2 only: book the relieved -2 instead of -5 (non-primary agent). */
|
|
41
|
+
relief?: boolean;
|
|
42
|
+
/** Stored-event seq to stamp; absent => `state.seq + 1`. */
|
|
43
|
+
seq?: number;
|
|
44
|
+
}
|
|
45
|
+
export type RejectCode = 'INSPECTOR_NOT_SCORED' | 'UNKNOWN_CODE' | 'UNKNOWN_AGENT' | 'AGENT_ELIMINATED' | 'ROLE_MISMATCH' | 'RELIEF_NOT_ALLOWED';
|
|
46
|
+
export interface Rejection {
|
|
47
|
+
code: RejectCode;
|
|
48
|
+
message: string;
|
|
49
|
+
}
|
|
50
|
+
export interface ApplyOutcome {
|
|
51
|
+
/** The new state; the INPUT state, untouched, when the event was rejected. */
|
|
52
|
+
state: LedgerState;
|
|
53
|
+
booked: boolean;
|
|
54
|
+
rejected?: Rejection;
|
|
55
|
+
entry?: LedgerEntry;
|
|
56
|
+
/** Magnitude trimmed by the event limit, the incident cap or the floor at 0. */
|
|
57
|
+
clipped: number;
|
|
58
|
+
/** True when this booking depleted `confirmed` and removed the agent (KILL). */
|
|
59
|
+
eliminated: boolean;
|
|
60
|
+
}
|
|
61
|
+
export interface ApplyOptions {
|
|
62
|
+
/**
|
|
63
|
+
* Catalogue override, for tests only (a settlement value outside the three known ones
|
|
64
|
+
* must make `apply` throw, and the real table cannot hold one). Production callers
|
|
65
|
+
* never pass it.
|
|
66
|
+
*/
|
|
67
|
+
catalogue?: Readonly<Record<string, EventDef>>;
|
|
68
|
+
}
|
|
69
|
+
export type Pool = 'provisional' | 'confirmed' | 'deduct';
|
|
70
|
+
/**
|
|
71
|
+
* Which pool a booking lands in. EXHAUSTIVE over the three settlements, with a throwing
|
|
72
|
+
* default: a silent fallthrough into "some pool" would corrupt balances with no trace.
|
|
73
|
+
*
|
|
74
|
+
* - provisional + positive -> escrow (clawback-able).
|
|
75
|
+
* - confirmed / immediate + positive -> `confirmed` (RV-9: an "immediate" reward is
|
|
76
|
+
* credited at once; the only difference from escrow is that it cannot be clawed back).
|
|
77
|
+
* - any negative -> deducted from `confirmed`, whatever the label says.
|
|
78
|
+
*
|
|
79
|
+
* The switch runs BEFORE the sign test so an invalid label fails even on a zero delta.
|
|
80
|
+
*/
|
|
81
|
+
export declare function settlementPool(settlement: Settlement, delta: number): Pool;
|
|
82
|
+
/** Order in which one incident's events are applied so a cap truncates the right one. */
|
|
83
|
+
export declare function incidentPriority(code: EventCode): number;
|
|
84
|
+
/**
|
|
85
|
+
* Book one event.
|
|
86
|
+
*
|
|
87
|
+
* Order of operations (each step can only SHRINK the magnitude): catalogue delta ->
|
|
88
|
+
* per-event limit (+20 / -40) -> incident cap (-50 cumulative) -> floor at 0. The entry
|
|
89
|
+
* records `capped: { requested, applied }` whenever any step trimmed the amount, so the
|
|
90
|
+
* inspector can say why a figure is smaller than the catalogue's.
|
|
91
|
+
*/
|
|
92
|
+
export declare function apply(state: LedgerState, event: LedgerEvent, options?: ApplyOptions): ApplyOutcome;
|
|
93
|
+
/** Apply a list in order; a rejected event is skipped (its outcome says why). */
|
|
94
|
+
export declare function applyAll(state: LedgerState, events: readonly LedgerEvent[], options?: ApplyOptions): {
|
|
95
|
+
state: LedgerState;
|
|
96
|
+
outcomes: ApplyOutcome[];
|
|
97
|
+
};
|
|
98
|
+
export interface CollectiveSpec {
|
|
99
|
+
code: 'C1' | 'C2' | 'C3' | 'C4';
|
|
100
|
+
at: number;
|
|
101
|
+
phase: number;
|
|
102
|
+
by: LedgerEntry['by'];
|
|
103
|
+
reason: string;
|
|
104
|
+
incidentId?: string;
|
|
105
|
+
wpId?: string;
|
|
106
|
+
seq?: number;
|
|
107
|
+
/** Restrict to these ids (the phase's members); absent => every active scored agent. */
|
|
108
|
+
participants?: readonly string[];
|
|
109
|
+
/** C2 only: agents that get the relieved -2 (everyone who is not a primary). */
|
|
110
|
+
reliefIds?: readonly string[];
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Expand a collective event into one `LedgerEvent` per ACTIVE scored agent, in roster
|
|
114
|
+
* order. The inspector is never present because it is never in `state.agents`.
|
|
115
|
+
*/
|
|
116
|
+
export declare function expandCollective(state: LedgerState, spec: CollectiveSpec): LedgerEvent[];
|
|
117
|
+
export declare function applyCollective(state: LedgerState, spec: CollectiveSpec): {
|
|
118
|
+
state: LedgerState;
|
|
119
|
+
outcomes: ApplyOutcome[];
|
|
120
|
+
};
|
|
121
|
+
export interface EscrowReleaseOutcome {
|
|
122
|
+
state: LedgerState;
|
|
123
|
+
released: Array<{
|
|
124
|
+
agentId: string;
|
|
125
|
+
amount: number;
|
|
126
|
+
}>;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Integration passed: move every active agent's remaining escrow for `phase` into
|
|
130
|
+
* `confirmed`. Whatever a clawback already took is gone, so only the unreclaimed balance
|
|
131
|
+
* is released. An eliminated agent's escrow was forfeited when it was removed.
|
|
132
|
+
*/
|
|
133
|
+
export declare function confirmEscrow(state: LedgerState, phase: number, at: number, seqOverride?: number): EscrowReleaseOutcome;
|
|
134
|
+
export interface ClawbackRequest {
|
|
135
|
+
agentId: string;
|
|
136
|
+
phase: number;
|
|
137
|
+
reason: string;
|
|
138
|
+
incidentId?: string;
|
|
139
|
+
at: number;
|
|
140
|
+
by?: LedgerEntry['by'];
|
|
141
|
+
seq?: number;
|
|
142
|
+
}
|
|
143
|
+
export interface ClawbackOutcome {
|
|
144
|
+
state: LedgerState;
|
|
145
|
+
/** Escrow actually reclaimed (positive number). */
|
|
146
|
+
clawed: number;
|
|
147
|
+
/** Escrow that existed for the phase before the cap was applied. */
|
|
148
|
+
requested: number;
|
|
149
|
+
capped: boolean;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Integration failed: reclaim the culprit's escrow for `phase`. The amount counts against
|
|
153
|
+
* the same (agent, incident) -50 cap as the deductions and is applied LAST, so the cap
|
|
154
|
+
* truncates the clawback rather than the D13/D14/D15 the inspector asked for.
|
|
155
|
+
* Only `provisional` shrinks: `confirmed` (and so KILL) is untouched (I-G3).
|
|
156
|
+
*/
|
|
157
|
+
export declare function clawback(state: LedgerState, request: ClawbackRequest): ClawbackOutcome;
|
|
158
|
+
export interface IncidentInput {
|
|
159
|
+
events: readonly LedgerEvent[];
|
|
160
|
+
clawbacks?: readonly ClawbackRequest[];
|
|
161
|
+
}
|
|
162
|
+
export interface IncidentOutcome {
|
|
163
|
+
state: LedgerState;
|
|
164
|
+
outcomes: ApplyOutcome[];
|
|
165
|
+
clawbacks: ClawbackOutcome[];
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Apply one incident in the priority order D13 -> D14/D15 -> C2/C3/C4 -> clawback
|
|
169
|
+
* (5.3), so a cap that bites trims the LAST thing in that chain. Stable within a rank.
|
|
170
|
+
*/
|
|
171
|
+
export declare function applyIncident(state: LedgerState, input: IncidentInput): IncidentOutcome;
|
|
172
|
+
export interface ReverseRequest {
|
|
173
|
+
agentId: string;
|
|
174
|
+
code: EventCode;
|
|
175
|
+
wpId?: string;
|
|
176
|
+
at: number;
|
|
177
|
+
reason: string;
|
|
178
|
+
seq?: number;
|
|
179
|
+
}
|
|
180
|
+
export interface ReverseOutcome {
|
|
181
|
+
state: LedgerState;
|
|
182
|
+
reversed: boolean;
|
|
183
|
+
entry?: LedgerEntry;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Credit back the newest un-reversed deduction of `code`: the AC-24 "withdraw undoes the
|
|
187
|
+
* D5". It re-credits exactly what was DEDUCTED (a capped D5 is refunded at its capped
|
|
188
|
+
* amount) and is itself a ledger row, so the audit trail shows both halves. Does nothing
|
|
189
|
+
* when the original has been folded out of the bounded history.
|
|
190
|
+
*/
|
|
191
|
+
export declare function reverseEntry(state: LedgerState, request: ReverseRequest): ReverseOutcome;
|
|
192
|
+
export interface EliminateRequest {
|
|
193
|
+
agentId: string;
|
|
194
|
+
reason: FailureAnalysis['reason'];
|
|
195
|
+
at: number;
|
|
196
|
+
seq?: number;
|
|
197
|
+
}
|
|
198
|
+
export interface EliminateOutcome {
|
|
199
|
+
state: LedgerState;
|
|
200
|
+
eliminated: boolean;
|
|
201
|
+
analysis: FailureAnalysis | null;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Remove an active agent (tail rule or an explicit clawback decision). KILL by depletion
|
|
205
|
+
* happens inside `apply`; this is the entry point for the other two reasons. A no-op for
|
|
206
|
+
* an unknown or already-eliminated id, so replaying it twice is harmless.
|
|
207
|
+
*/
|
|
208
|
+
export declare function eliminate(state: LedgerState, request: EliminateRequest): EliminateOutcome;
|
|
209
|
+
export interface RespawnRequest {
|
|
210
|
+
agentId: string;
|
|
211
|
+
phase: number;
|
|
212
|
+
at: number;
|
|
213
|
+
seq?: number;
|
|
214
|
+
}
|
|
215
|
+
export interface RespawnOutcome {
|
|
216
|
+
state: LedgerState;
|
|
217
|
+
successor: AgentRecord | null;
|
|
218
|
+
analysis: FailureAnalysis | null;
|
|
219
|
+
}
|
|
220
|
+
/** `dev2` -> `dev2-r1` -> `dev2-r2`: the suffix tracks the generation. */
|
|
221
|
+
export declare function successorId(predecessor: AgentRecord): string;
|
|
222
|
+
/**
|
|
223
|
+
* Replace an eliminated agent with a fresh identity at `GOV_LIMITS.respawnTokens`
|
|
224
|
+
* (all confirmed, no escrow). The successor inherits NO code - only the predecessor's
|
|
225
|
+
* `FailureAnalysis`, returned for the brief. Subagent labels are capped at 12 characters,
|
|
226
|
+
* so an over-long id is a bug in the roster naming and throws.
|
|
227
|
+
*/
|
|
228
|
+
export declare function respawn(state: LedgerState, request: RespawnRequest): RespawnOutcome;
|