agentfootprint 9.75.0 → 9.76.1

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 (118) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/CLAUDE.md +22 -18
  3. package/dist/artifacts/index.js +3 -1
  4. package/dist/artifacts/index.js.map +1 -1
  5. package/dist/artifacts/recordingArtifact.js +47 -1
  6. package/dist/artifacts/recordingArtifact.js.map +1 -1
  7. package/dist/core/Agent.js +30 -0
  8. package/dist/core/Agent.js.map +1 -1
  9. package/dist/core/agent/stages/toolCalls.js +42 -0
  10. package/dist/core/agent/stages/toolCalls.js.map +1 -1
  11. package/dist/core/agent/toolDispatch.js +101 -0
  12. package/dist/core/agent/toolDispatch.js.map +1 -0
  13. package/dist/core/flowchartAsTool.js +9 -2
  14. package/dist/core/flowchartAsTool.js.map +1 -1
  15. package/dist/core/runbook/coverage.js +162 -0
  16. package/dist/core/runbook/coverage.js.map +1 -0
  17. package/dist/core/runbook/dispatch.js +119 -0
  18. package/dist/core/runbook/dispatch.js.map +1 -0
  19. package/dist/core/runbook/index.js +24 -0
  20. package/dist/core/runbook/index.js.map +1 -0
  21. package/dist/core/runbook/report.js +69 -0
  22. package/dist/core/runbook/report.js.map +1 -0
  23. package/dist/core/runbook/runbookAsTool.js +381 -0
  24. package/dist/core/runbook/runbookAsTool.js.map +1 -0
  25. package/dist/core/runbook/types.js +22 -0
  26. package/dist/core/runbook/types.js.map +1 -0
  27. package/dist/core/runbook/verdicts.js +156 -0
  28. package/dist/core/runbook/verdicts.js.map +1 -0
  29. package/dist/core/runbook/walk.js +115 -0
  30. package/dist/core/runbook/walk.js.map +1 -0
  31. package/dist/core/tools.js +55 -1
  32. package/dist/core/tools.js.map +1 -1
  33. package/dist/esm/artifacts/index.d.ts +1 -1
  34. package/dist/esm/artifacts/index.js +1 -1
  35. package/dist/esm/artifacts/index.js.map +1 -1
  36. package/dist/esm/artifacts/recordingArtifact.d.ts +36 -0
  37. package/dist/esm/artifacts/recordingArtifact.js +45 -0
  38. package/dist/esm/artifacts/recordingArtifact.js.map +1 -1
  39. package/dist/esm/core/Agent.js +30 -0
  40. package/dist/esm/core/Agent.js.map +1 -1
  41. package/dist/esm/core/agent/stages/toolCalls.js +42 -0
  42. package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
  43. package/dist/esm/core/agent/toolDispatch.d.ts +50 -0
  44. package/dist/esm/core/agent/toolDispatch.js +97 -0
  45. package/dist/esm/core/agent/toolDispatch.js.map +1 -0
  46. package/dist/esm/core/flowchartAsTool.d.ts +6 -0
  47. package/dist/esm/core/flowchartAsTool.js +9 -2
  48. package/dist/esm/core/flowchartAsTool.js.map +1 -1
  49. package/dist/esm/core/runbook/coverage.d.ts +69 -0
  50. package/dist/esm/core/runbook/coverage.js +155 -0
  51. package/dist/esm/core/runbook/coverage.js.map +1 -0
  52. package/dist/esm/core/runbook/dispatch.d.ts +69 -0
  53. package/dist/esm/core/runbook/dispatch.js +112 -0
  54. package/dist/esm/core/runbook/dispatch.js.map +1 -0
  55. package/dist/esm/core/runbook/index.d.ts +9 -0
  56. package/dist/esm/core/runbook/index.js +9 -0
  57. package/dist/esm/core/runbook/index.js.map +1 -0
  58. package/dist/esm/core/runbook/report.d.ts +52 -0
  59. package/dist/esm/core/runbook/report.js +64 -0
  60. package/dist/esm/core/runbook/report.js.map +1 -0
  61. package/dist/esm/core/runbook/runbookAsTool.d.ts +90 -0
  62. package/dist/esm/core/runbook/runbookAsTool.js +377 -0
  63. package/dist/esm/core/runbook/runbookAsTool.js.map +1 -0
  64. package/dist/esm/core/runbook/types.d.ts +203 -0
  65. package/dist/esm/core/runbook/types.js +21 -0
  66. package/dist/esm/core/runbook/types.js.map +1 -0
  67. package/dist/esm/core/runbook/verdicts.d.ts +78 -0
  68. package/dist/esm/core/runbook/verdicts.js +148 -0
  69. package/dist/esm/core/runbook/verdicts.js.map +1 -0
  70. package/dist/esm/core/runbook/walk.d.ts +72 -0
  71. package/dist/esm/core/runbook/walk.js +110 -0
  72. package/dist/esm/core/runbook/walk.js.map +1 -0
  73. package/dist/esm/core/tools.d.ts +112 -0
  74. package/dist/esm/core/tools.js +52 -0
  75. package/dist/esm/core/tools.js.map +1 -1
  76. package/dist/esm/index.d.ts +4 -3
  77. package/dist/esm/index.js +19 -2
  78. package/dist/esm/index.js.map +1 -1
  79. package/dist/esm/lib/mcp/toolExtras.d.ts +8 -0
  80. package/dist/esm/lib/mcp/toolExtras.js +7 -1
  81. package/dist/esm/lib/mcp/toolExtras.js.map +1 -1
  82. package/dist/index.js +97 -66
  83. package/dist/index.js.map +1 -1
  84. package/dist/lib/mcp/toolExtras.js +6 -0
  85. package/dist/lib/mcp/toolExtras.js.map +1 -1
  86. package/dist/types/artifacts/index.d.ts +1 -1
  87. package/dist/types/artifacts/index.d.ts.map +1 -1
  88. package/dist/types/artifacts/recordingArtifact.d.ts +36 -0
  89. package/dist/types/artifacts/recordingArtifact.d.ts.map +1 -1
  90. package/dist/types/core/Agent.d.ts.map +1 -1
  91. package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
  92. package/dist/types/core/agent/toolDispatch.d.ts +51 -0
  93. package/dist/types/core/agent/toolDispatch.d.ts.map +1 -0
  94. package/dist/types/core/flowchartAsTool.d.ts +6 -0
  95. package/dist/types/core/flowchartAsTool.d.ts.map +1 -1
  96. package/dist/types/core/runbook/coverage.d.ts +70 -0
  97. package/dist/types/core/runbook/coverage.d.ts.map +1 -0
  98. package/dist/types/core/runbook/dispatch.d.ts +70 -0
  99. package/dist/types/core/runbook/dispatch.d.ts.map +1 -0
  100. package/dist/types/core/runbook/index.d.ts +10 -0
  101. package/dist/types/core/runbook/index.d.ts.map +1 -0
  102. package/dist/types/core/runbook/report.d.ts +53 -0
  103. package/dist/types/core/runbook/report.d.ts.map +1 -0
  104. package/dist/types/core/runbook/runbookAsTool.d.ts +91 -0
  105. package/dist/types/core/runbook/runbookAsTool.d.ts.map +1 -0
  106. package/dist/types/core/runbook/types.d.ts +204 -0
  107. package/dist/types/core/runbook/types.d.ts.map +1 -0
  108. package/dist/types/core/runbook/verdicts.d.ts +79 -0
  109. package/dist/types/core/runbook/verdicts.d.ts.map +1 -0
  110. package/dist/types/core/runbook/walk.d.ts +73 -0
  111. package/dist/types/core/runbook/walk.d.ts.map +1 -0
  112. package/dist/types/core/tools.d.ts +112 -0
  113. package/dist/types/core/tools.d.ts.map +1 -1
  114. package/dist/types/index.d.ts +4 -3
  115. package/dist/types/index.d.ts.map +1 -1
  116. package/dist/types/lib/mcp/toolExtras.d.ts +8 -0
  117. package/dist/types/lib/mcp/toolExtras.d.ts.map +1 -1
  118. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"flowchartAsTool.d.ts","sourceRoot":"","sources":["../../../src/core/flowchartAsTool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqHG;AAEH,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,eAAe,EACrB,MAAM,aAAa,CAAC;AAYrB,OAAO,KAAK,EAAE,IAAI,EAAwB,MAAM,YAAY,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,SAAS;QAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACnF;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,QAAQ,EAAE,qBAAqB,KA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;;;;;;;GAuBG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,sBAAsB,GAAG,IAAI,CAsJlE"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * runbook/coverage — the spine's ledger: inner folds + chart-declared
3
+ * entries + the bridge's own, and the sentence naming the rules.
4
+ *
5
+ * Pattern: pure fold over three sources, reusing the coverage primitives'
6
+ * own recognizer and merge — no second grammar.
7
+ * Role: core/runbook.
8
+ * Emits: N/A.
9
+ *
10
+ * The three sources, in the order they land:
11
+ * 1. INNER LEDGERS — every recorded inner call's result is read by the
12
+ * same `readCoverageResult` funnel the dispatch loop uses, and its
13
+ * three lists fold upward. An inner tool's honesty is carried, never
14
+ * re-authored.
15
+ * 2. THE CHART'S OWN — the procedure states run-specific coverage by
16
+ * writing a `coverage` state key (`{ checked?, not_checked?,
17
+ * cannot_cover? }`, items as `{what, why?}` bags or bare strings).
18
+ * This is the app's vocabulary (which counters mean "not assessed" is
19
+ * the chart's to know); the ENVELOPE is the bridge's.
20
+ * 3. THE BRIDGE'S OWN — one `checked` entry naming the procedure, its
21
+ * recorded step count and the rule set it ran under; and, for a
22
+ * verdict-shaped runbook, a `not_checked` entry counting DECLINED rows
23
+ * (the three-outcome honesty: a row that reached no classification is
24
+ * ground the answer does not cover).
25
+ */
26
+ import type { CoverageItem } from '../agent/coverage/types.js';
27
+ import type { InnerCallRecord } from './dispatch.js';
28
+ import type { RunbookRules } from './types.js';
29
+ /** The three lists, mid-fold. */
30
+ export interface LedgerLists {
31
+ readonly checked: readonly CoverageItem[];
32
+ readonly notChecked: readonly CoverageItem[];
33
+ readonly cannotCover: readonly CoverageItem[];
34
+ }
35
+ /** Fold every recorded inner call's declared coverage upward. */
36
+ export declare function foldInnerCoverage(records: readonly InnerCallRecord[]): LedgerLists;
37
+ /** The chart-declared lists, read off the final state's `coverage` key.
38
+ * Accepts both spellings of the two-word keys (state is often snake_case,
39
+ * the declaration camelCase) — one reader, no drift. */
40
+ export declare function chartCoverageOf(state: Readonly<Record<string, unknown>>): LedgerLists;
41
+ /** What the composed ledger needs to know about this run. */
42
+ export interface LedgerFacts {
43
+ readonly chartName: string;
44
+ readonly stepsExecuted: number;
45
+ readonly rules?: RunbookRules;
46
+ /** Rowset facts — present only for a verdict-shaped runbook. */
47
+ readonly rowsTotal?: number;
48
+ readonly declinedRows?: number;
49
+ }
50
+ /** The composed `af_coverage` value: three merged lists + the static law
51
+ * note + this run's own sentence. */
52
+ export interface ComposedLedger {
53
+ readonly checked?: readonly CoverageItem[];
54
+ readonly not_checked?: readonly CoverageItem[];
55
+ readonly cannot_cover?: readonly CoverageItem[];
56
+ readonly note: string;
57
+ readonly sentence: string;
58
+ }
59
+ /** Compose the whole ledger. Inner folds land first, chart-declared second,
60
+ * the bridge's own last — provenance order, so a reader meets the sources
61
+ * before the summary. */
62
+ export declare function composeLedger(inner: LedgerLists, chart: LedgerLists, facts: LedgerFacts): ComposedLedger;
63
+ /**
64
+ * The carried provenance stamp: the FIRST inner result that declared an
65
+ * `af_provenance` (on its unwrapped payload, or at its top level — both are
66
+ * read, in that order). A derived answer is still an answer, and a source's
67
+ * confession (`source: 'LOCAL SEED'`) must survive composition.
68
+ */
69
+ export declare function carriedProvenanceOf(records: readonly InnerCallRecord[]): Record<string, unknown> | undefined;
70
+ //# sourceMappingURL=coverage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coverage.d.ts","sourceRoot":"","sources":["../../../../src/core/runbook/coverage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,iCAAiC;AACjC,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,CAAC;IAC1C,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,70 @@
1
+ /**
2
+ * runbook/dispatch — the bridge's wrapper over `ctx.tools`.
3
+ *
4
+ * Pattern: decorator over {@link ToolDispatch}. The RAW dispatch (delivered
5
+ * by the agent) returns every result untouched; POLICY about what a
6
+ * result means belongs to the consumer — and this is the runbook's
7
+ * policy: every inner outcome is RECORDED (for the coverage fold and
8
+ * the provenance carry), and an inner ABSENCE short-circuits the
9
+ * procedure unless the call site declared it survivable.
10
+ * Role: core/runbook, pure.
11
+ * Emits: N/A.
12
+ *
13
+ * WHY an absence short-circuits: "the inventory found nothing" IS the
14
+ * runbook's answer, and it must go back EXACTLY as it arrived so the
15
+ * framework still reads it as an absence — a verdict reached over a source
16
+ * that answered "nothing here" would be the confident-partial-answer failure
17
+ * this whole envelope exists to prevent. A stage that can genuinely carry on
18
+ * without the source says so at the call site (`{ allowAbsent: true }`) and
19
+ * owns stating the gap (usually as a coverage entry).
20
+ */
21
+ import type { ToolAbsence } from '../agent/coverage/types.js';
22
+ import type { ToolDispatch } from '../tools.js';
23
+ /** One inner call, as the bridge recorded it. */
24
+ export interface InnerCallRecord {
25
+ readonly tool: string;
26
+ readonly outcome: 'ok' | 'absent' | 'error';
27
+ /** The raw returned value (`'ok'` and `'absent'` outcomes). */
28
+ readonly result?: unknown;
29
+ }
30
+ /** The marker property that survives any error wrapping between a stage and
31
+ * the bridge's catch. */
32
+ declare const ABSENCE_SIGNAL: "af_runbook_absence";
33
+ /**
34
+ * The control signal an un-survivable inner absence throws through the
35
+ * chart. The engine commits staged state and rethrows (commit-on-error is
36
+ * the law upstream), so the bridge catches this at `executor.run` and
37
+ * returns the absence verbatim.
38
+ */
39
+ export declare class RunbookAbsenceSignal extends Error {
40
+ readonly absence: ToolAbsence;
41
+ readonly [ABSENCE_SIGNAL] = true;
42
+ constructor(absence: ToolAbsence, innerTool: string);
43
+ }
44
+ /** Recognize the signal on an error OR anywhere down its `cause` chain — an
45
+ * engine layer that wraps the stage's throw must not defeat the pass-through. */
46
+ export declare function absenceSignalOf(err: unknown): RunbookAbsenceSignal | undefined;
47
+ /** What `recordingDispatch` hands back: the dispatch the procedure closes
48
+ * over, and the record the envelope folds. */
49
+ export interface RecordedDispatch {
50
+ readonly tools: ToolDispatch;
51
+ readonly records: readonly InnerCallRecord[];
52
+ }
53
+ /**
54
+ * Wrap the delivered dispatch (or its absence) for one runbook invocation.
55
+ *
56
+ * With NO dispatch delivered (`ctx.tools` absent — a hand-built context, a
57
+ * door with no dispatch map) the wrapper is the fail-closed teacher: `has`
58
+ * answers false and `call` refuses naming the fix, so a procedure that needs
59
+ * inner tools fails loudly at its first call instead of half-running.
60
+ */
61
+ export declare function recordingDispatch(delivered: ToolDispatch | undefined, runbookName: string): RecordedDispatch;
62
+ /**
63
+ * The definition-time probe dispatch — handed to the procedure factory ONCE
64
+ * at `runbookAsTool(...)` so the bridge can read the chart's declared
65
+ * contract. Stage bodies do not run at build; a factory that calls tools at
66
+ * build time hears exactly why that cannot work.
67
+ */
68
+ export declare function probeDispatch(runbookName: string): ToolDispatch;
69
+ export {};
70
+ //# sourceMappingURL=dispatch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../../../src/core/runbook/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAA2B,MAAM,aAAa,CAAC;AAEzE,iDAAiD;AACjD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,IAAI,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC5C,+DAA+D;IAC/D,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;0BAC0B;AAC1B,QAAA,MAAM,cAAc,sBAAgC,CAAC;AAErD;;;;;GAKG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAEjC,QAAQ,CAAC,OAAO,EAAE,WAAW;IADzC,QAAQ,CAAC,CAAC,cAAc,CAAC,QAAQ;gBACZ,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM;CAQ7D;AAED;kFACkF;AAClF,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,oBAAoB,GAAG,SAAS,CAS9E;AAED;+CAC+C;AAC/C,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;CAC9C;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,YAAY,GAAG,SAAS,EACnC,WAAW,EAAE,MAAM,GAClB,gBAAgB,CAiClB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,YAAY,CAW/D"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * runbook — the standard bridge from a footprintjs procedure to an Agent
3
+ * tool with the mandatory honesty spine. See README.md in this folder.
4
+ */
5
+ export { runbookAsTool } from './runbookAsTool.js';
6
+ export { absenceSignalOf, probeDispatch, recordingDispatch, RunbookAbsenceSignal, type InnerCallRecord, type RecordedDispatch, } from './dispatch.js';
7
+ export { DECLINED_VERDICT, DEFAULT_MAX_ROWS, renderVerdictTable, VERDICT_RENDER_NOTE, verdictRowsOf, } from './verdicts.js';
8
+ export { DEFAULT_WALK_CAP, projectWalk, type ProjectedWalk, type WalkRow } from './walk.js';
9
+ export type { RunbookAsToolOptions, RunbookEnvelope, RunbookProcedure, RunbookRules, RunbookVerdictsOptions, RunbookWalkOptions, VerdictRow, WalkDescriptor, } from './types.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/runbook/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACpB,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,GACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,KAAK,aAAa,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAC5F,YAAY,EACV,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,sBAAsB,EACtB,kBAAkB,EAClB,UAAU,EACV,cAAc,GACf,MAAM,YAAY,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * runbook/report — the chart's own `report` bag, admitted UNDER the envelope.
3
+ *
4
+ * Pattern: one pure partition (admitted fields / refused names) plus the
5
+ * sentence that names what was refused. No behavior beyond the law.
6
+ * Role: core/runbook. `runbookAsTool.ts` consumes at assembly time.
7
+ * Emits: N/A.
8
+ *
9
+ * THE PRECEDENCE LAW: the names the envelope itself assembles — the honesty
10
+ * spine, and the projection keys this run actually produced — are RESERVED.
11
+ * A chart's `report` may add fields BESIDE them; it may never replace one.
12
+ * The spine is the boundary of the answer, and a boundary a chart can
13
+ * overwrite is a boundary that reports whatever the chart says about itself:
14
+ * a seeded number could arrive stamped as a sourced one, or an answer
15
+ * produced under one reading of the rules could name a version it never ran.
16
+ * A `report` key spelled `af_coverage` is refused too — it lands one level
17
+ * under the real ledger, which is exactly where a decoy would want to sit.
18
+ *
19
+ * AND WHY THE REFUSAL IS SPOKEN, not silent: every other reduction this
20
+ * envelope performs is declared out loud — the walk's `projection`, the
21
+ * rowset's `rows_complete`, declined rows counted into the ledger. Dropping
22
+ * a field the chart wrote with no trace would be the one silent edit in an
23
+ * envelope whose whole argument is that reductions are declared, and the
24
+ * author would debug "where did my field go?" against a shape that never
25
+ * mentions it. So a collision costs one `report_note` naming every refused
26
+ * field — present ONLY when something was actually refused, so the clean
27
+ * path (every real runbook) pays nothing.
28
+ */
29
+ /** The ledger's key. It lives at the ENVELOPE's top level, and is reserved
30
+ * inside `result` too — see the module header. */
31
+ export declare const LEDGER_KEY = "af_coverage";
32
+ /** The key the refusal note ships under — itself reserved, because a
33
+ * chart-authored `report_note` is a forged receipt for a refusal that
34
+ * never happened. */
35
+ export declare const REPORT_NOTE_KEY = "report_note";
36
+ /** The chart's `report`, partitioned against the names the envelope owns. */
37
+ export interface AdmittedReport {
38
+ /** The fields that may be spread into `result`, in the chart's own order. */
39
+ readonly fields: Record<string, unknown>;
40
+ /** The names refused, in the chart's own order — empty on the clean path. */
41
+ readonly refused: readonly string[];
42
+ }
43
+ /**
44
+ * Partition the chart's `report` against the names this envelope assembled.
45
+ * `assembled` is read from the actual spine and projection objects, never
46
+ * from a hand-listed copy — a spine field added later is protected the day
47
+ * it lands.
48
+ */
49
+ export declare function admitReport(report: Readonly<Record<string, unknown>>, assembled: Iterable<string>): AdmittedReport;
50
+ /** The sentence for a refused collision: which fields were discarded, whose
51
+ * the surviving values are, and what is safe to read. */
52
+ export declare function shadowedFieldsNote(refused: readonly string[]): string;
53
+ //# sourceMappingURL=report.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../../src/core/runbook/report.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;mDACmD;AACnD,eAAO,MAAM,UAAU,gBAAgB,CAAC;AAExC;;sBAEsB;AACtB,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAE7C,6EAA6E;AAC7E,MAAM,WAAW,cAAc;IAC7B,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,GAC1B,cAAc,CAUhB;AAED;0DAC0D;AAC1D,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAUrE"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * runbookAsTool — turn a written operational procedure into a tool whose
3
+ * every answer is EVIDENCE: who decided what, against which threshold, on
4
+ * which rule version, with the recorded walk to check it against.
5
+ *
6
+ * The standard bridge from a footprintjs chart to the Agent's tool surface.
7
+ * Where `flowchartAsTool` returns bare `JSON.stringify(values)`,
8
+ * runbookAsTool supplies the missing middle — the honesty envelope every
9
+ * hand-rolled triage tool was building for itself:
10
+ *
11
+ * THE MANDATORY SPINE (every runbook, whatever its shape):
12
+ * - `af_coverage` — the three-list ledger, with every INNER tool's own
13
+ * ledger folded upward through the run's dispatch, plus the sentence
14
+ * naming the rule set and version;
15
+ * - `result.af_provenance` — re-emitted FIRST (a carried `LOCAL SEED`
16
+ * confession survives composition);
17
+ * - `result.rule_version` — the declared rules' version, or the honest
18
+ * `'undeclared'`;
19
+ * - `result.walk` — the recorded walk's descriptor. The walk itself
20
+ * ships as an artifact ticket (kind `recording/chart-walk`), never as
21
+ * bytes; when it does not fit, the CONTROL FLOW survives and the
22
+ * projection is declared.
23
+ *
24
+ * THE OPTIONAL PROJECTION (selected by `resultKind: 'verdict/*'`):
25
+ * verdict rows off the chart's `verdicts` state key, capped with
26
+ * truthful counters, a pre-rendered table over the SAME rows, and
27
+ * `verdict_meanings` GENERATED from the decider's declared branches +
28
+ * the rule labels this run's decide() evidence carried.
29
+ *
30
+ * THREE OUTCOMES, honestly: a clean envelope; an inner ABSENCE passed
31
+ * through verbatim (the framework still reads it as an absence); and
32
+ * DECLINED rows counted into the ledger as not-checked ground.
33
+ *
34
+ * The procedure is a FACTORY invoked per call with the run's own tool
35
+ * dispatch (`ctx.tools`) — fresh chart every run, stages close over the
36
+ * dispatch, and every inner tool's honesty ledger folds into this tool's
37
+ * answer.
38
+ *
39
+ * Reserved state keys the bridge reads off the final scope:
40
+ * - `verdicts` — the rowset (verdict projection only);
41
+ * - `coverage` — chart-declared coverage entries (`{checked?, not_checked?,
42
+ * cannot_cover?}`);
43
+ * - `report` — the app's own result fields, spread into `result` verbatim
44
+ * BESIDE the spine, never over it: the envelope's own names (the spine
45
+ * plus the projection this run assembled) are reserved, and a report
46
+ * field spelling one of them is discarded and NAMED in `report_note`.
47
+ *
48
+ * Pause: NOT yet bridged. A paused inner chart throws with the checkpoint
49
+ * attached, exactly like `flowchartAsTool` — the approval-gate integration
50
+ * is the next phase of the runbook program.
51
+ *
52
+ * @example the smallest legal call — still yields the honest spine
53
+ * const tool = runbookAsTool({
54
+ * name: 'restart_check',
55
+ * description: 'Run the restart-safety procedure.',
56
+ * procedure: () =>
57
+ * flowChart<{ safe: boolean }>('restart-safety', (scope) => {
58
+ * scope.safe = true;
59
+ * }, 'check').build(),
60
+ * });
61
+ *
62
+ * @example a triage runbook with rules, verdicts, and an inner tool
63
+ * const triage = runbookAsTool({
64
+ * name: 'backup_triage',
65
+ * description: 'Assess backup protection posture for every subject.',
66
+ * resultKind: 'verdict/backup-posture',
67
+ * rules: { name: 'health-signal', version: 'v1' },
68
+ * verdicts: { decider: 'posture' },
69
+ * composedOf: ['backup_inventory'],
70
+ * procedure: (tools) =>
71
+ * flowChart<TriageState>('backup-triage', async (scope) => {
72
+ * const inner = (await tools.call('backup_inventory', {})) as InventoryResult;
73
+ * scope.subjects = inner.result.rows;
74
+ * }, 'inventory')
75
+ * .addDeciderFunction('Posture', postureDecider, 'posture')
76
+ * .addFunctionBranch('protected', 'Protected', landProtected)
77
+ * .addFunctionBranch('unprotected', 'Unprotected', landUnprotected)
78
+ * .end()
79
+ * .build(),
80
+ * });
81
+ */
82
+ import { type Tool } from '../tools.js';
83
+ import type { RunbookAsToolOptions } from './types.js';
84
+ /**
85
+ * Wrap a footprintjs procedure as a `Tool` whose every answer carries the
86
+ * honesty spine. See the module header for the envelope; see
87
+ * {@link RunbookAsToolOptions} for the full options bag. The smallest legal
88
+ * call is `{ name, description, procedure }`.
89
+ */
90
+ export declare function runbookAsTool(opts: RunbookAsToolOptions): Tool;
91
+ //# sourceMappingURL=runbookAsTool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runbookAsTool.d.ts","sourceRoot":"","sources":["../../../../src/core/runbook/runbookAsTool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgFG;AAaH,OAAO,EAAc,KAAK,IAAI,EAA6B,MAAM,aAAa,CAAC;AAS/E,OAAO,KAAK,EAAE,oBAAoB,EAA+B,MAAM,YAAY,CAAC;AAuCpF;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,oBAAoB,GAAG,IAAI,CAsS9D"}
@@ -0,0 +1,204 @@
1
+ /**
2
+ * runbook/types — the vocabulary of the runbook bridge.
3
+ *
4
+ * Pattern: one options bag, four concerns (declarations, procedure, evidence
5
+ * policy, walk policy) + one envelope type split into a MANDATORY
6
+ * SPINE and an OPTIONAL projection. Pure data, no behavior.
7
+ * Role: core/ layer. `runbookAsTool.ts` consumes; consumers read the
8
+ * envelope types when they assert on results.
9
+ * Emits: N/A.
10
+ *
11
+ * The SPINE / PROJECTION split is load-bearing honesty, not taste: the spine
12
+ * (coverage, provenance, rule version, the recorded walk) is what EVERY
13
+ * runbook ships whatever its shape, so an answer can never arrive without its
14
+ * boundary; the verdict/rowset projection is one shape of answer (a triage),
15
+ * selected by `resultKind: 'verdict/*'` — an action-taking runbook ships the
16
+ * spine plus its own `report` payload and no rowset. The spine's wire shape
17
+ * is explicitly PROVISIONAL until a second, differently-shaped consumer has
18
+ * shipped through it.
19
+ */
20
+ import type { CombinedRecorder, FlowChart, RedactionPolicy } from 'footprintjs';
21
+ import type { CoverageItem } from '../agent/coverage/types.js';
22
+ import type { ToolDispatch, ToolOwner, ToolResultCeiling } from '../tools.js';
23
+ import type { ToolResultClass } from '../../lib/semantics/types.js';
24
+ import type { ToolWants } from '../../artifacts/wants.js';
25
+ /**
26
+ * The procedure: a factory invoked PER CALL with the run's own tool dispatch
27
+ * (`ctx.tools`), returning a FRESH chart whose stages close over it.
28
+ *
29
+ * Per call for two reasons that are really one: a chart shared between two
30
+ * runs is a chart whose closures belong to whichever run built it last, and
31
+ * the dispatch only exists at execute time — so the factory is both the
32
+ * fresh-chart law and the delivery mechanism.
33
+ *
34
+ * It is ALSO invoked once at definition time, with a probe dispatch whose
35
+ * `has` answers false and whose `call` refuses — to read the chart's declared
36
+ * contract (input schema, the named decider's branches). Stage bodies do not
37
+ * run at build, so a well-formed factory pays nothing; a factory with side
38
+ * effects at build time is a factory that lies about being a declaration.
39
+ */
40
+ export type RunbookProcedure = (tools: ToolDispatch) => FlowChart;
41
+ /** Rule provenance — threaded bridge → envelope → coverage sentence, so an
42
+ * answer produced under one reading of the rules can be told apart from an
43
+ * answer produced under the next. */
44
+ export interface RunbookRules {
45
+ /** The rule set's name ('health-signal'). Non-empty. */
46
+ readonly name: string;
47
+ /** Its version stamp ('v1'). Non-empty; bump when the READING changes,
48
+ * never for wording. */
49
+ readonly version: string;
50
+ }
51
+ /** The verdict/rowset projection's dials. */
52
+ export interface RunbookVerdictsOptions {
53
+ /**
54
+ * The decider stage (by id or name) whose declared branch labels generate
55
+ * `verdict_meanings`. Branch descriptions come from the chart's own
56
+ * structure when the decider is statically declared; rule labels observed
57
+ * in this run's decide() evidence refine them (and are the only source
58
+ * when the decider lives inside a dynamically generated fan-out branch,
59
+ * where build-time structure cannot see it).
60
+ */
61
+ readonly decider: string;
62
+ /** Cap on `verdicts` rows AND the rendered table — ONE number for both
63
+ * halves (a longer list beside a shorter table is an invitation to retype
64
+ * identifiers). Default 50. */
65
+ readonly maxRows?: number;
66
+ }
67
+ /** The walk policy. */
68
+ export interface RunbookWalkOptions {
69
+ /** Row cap on the minted walk (default 500). When the full walk does not
70
+ * fit, the CONTROL FLOW survives — see `walk.ts` for the projection law. */
71
+ readonly cap?: number;
72
+ }
73
+ /** Everything `runbookAsTool` accepts. Smallest legal call:
74
+ * `{ name, description, procedure }` — and it still yields the spine. */
75
+ export interface RunbookAsToolOptions {
76
+ /** Tool name the LLM dispatches by. */
77
+ readonly name: string;
78
+ /** REQUIRED — a description-less tool is invisible to the model. */
79
+ readonly description: string;
80
+ /** The procedure factory — see {@link RunbookProcedure}. */
81
+ readonly procedure: RunbookProcedure;
82
+ /** Selects the envelope projection (`'verdict/*'` gets the rowset) AND is
83
+ * the artifact kind a placed result is minted under. */
84
+ readonly resultKind?: string;
85
+ readonly resultClass?: ToolResultClass;
86
+ readonly owner?: ToolOwner;
87
+ readonly resultCeiling?: ToolResultCeiling;
88
+ readonly wants?: ToolWants;
89
+ readonly argumentsFrom?: readonly string[];
90
+ /** The named ingredient tools the procedure calls through `ctx.tools` —
91
+ * drift-checked at agent build. */
92
+ readonly composedOf?: readonly string[];
93
+ /** Explicit input schema wins; otherwise the chart's `.contract()` input
94
+ * is lifted when it is a plain JSON-Schema object (a parseable schema —
95
+ * zod et al. — cannot be serialized for the model and falls back to the
96
+ * empty-object default). */
97
+ readonly inputSchema?: Readonly<Record<string, unknown>>;
98
+ /** Rule provenance — see {@link RunbookRules}. */
99
+ readonly rules?: RunbookRules;
100
+ /** The verdict projection's dials — see {@link RunbookVerdictsOptions}. */
101
+ readonly verdicts?: RunbookVerdictsOptions;
102
+ /** The walk policy — see {@link RunbookWalkOptions}. */
103
+ readonly walk?: RunbookWalkOptions;
104
+ /** Observers attached to each invocation's fresh inner executor. */
105
+ readonly recorders?: ReadonlyArray<CombinedRecorder>;
106
+ /** Keep each invocation's inner record for `inspect_tool_run` descent. */
107
+ readonly keepRecord?: boolean;
108
+ /** Bounded LRU size for kept records (requires `keepRecord: true`). */
109
+ readonly keepRecordLimit?: number;
110
+ /** Redaction policy for the inner run (commit-time scrub). */
111
+ readonly redact?: RedactionPolicy;
112
+ }
113
+ /**
114
+ * The recorded-walk descriptor — ALWAYS on the spine. The walk itself ships
115
+ * as an artifact ticket (`ref`), never as bytes in the envelope; with no
116
+ * store attached (or a failed mint) the descriptor still states its
117
+ * counters and the `note` names why there is no ticket — a missing walk must
118
+ * never be mistaken for a short run.
119
+ */
120
+ export interface WalkDescriptor {
121
+ /** The claim-ticket ref of the minted walk artifact. Absent when no store
122
+ * is attached or the mint failed — `note` says which. */
123
+ readonly ref?: string;
124
+ /** The artifact kind (`'recording/chart-walk'`). Present with `ref`. */
125
+ readonly kind?: string;
126
+ /** Rows in the minted artifact. */
127
+ readonly rows: number;
128
+ /** Total execution steps the narrative recorder counted — spans isolated
129
+ * subflow logs, which the root commit log cannot. */
130
+ readonly steps_executed: number;
131
+ /** `'full'` — every narrative entry fit under the cap; `'control-flow'` —
132
+ * it did not, and the stages/forks/subflows/decisions survived while the
133
+ * per-key reads and writes were dropped. */
134
+ readonly projection: 'full' | 'control-flow';
135
+ readonly shown: number;
136
+ readonly total: number;
137
+ readonly complete: boolean;
138
+ /**
139
+ * WHICH SEGMENT of the run this walk covers. `'full'` for an un-gated run
140
+ * (all of phase 1). When approval gates land, a resumed run's recorders
141
+ * start empty on the fresh executor — its walk will say `'post-resume'`
142
+ * and its counters will count only that segment; the discriminant ships
143
+ * NOW so the wire does not break then.
144
+ */
145
+ readonly walk_segment: 'full' | 'pre-pause' | 'post-resume';
146
+ /** The human sentence: what the walk is, and (when projected) what the
147
+ * control-flow projection kept and dropped, or why there is no ticket. */
148
+ readonly note: string;
149
+ }
150
+ /** One verdict row, as the chart wrote it. The bridge reads rows from the
151
+ * final state's `verdicts` key and requires only `verdict`; every other
152
+ * column is the app's own vocabulary. */
153
+ export interface VerdictRow {
154
+ readonly verdict: string;
155
+ readonly [column: string]: unknown;
156
+ }
157
+ /** The mandatory-spine + optional-projection envelope every runbook returns
158
+ * (unless an inner absence passed through — then the answer IS that absence,
159
+ * verbatim). Recognized by the framework's coverage funnel at the dispatch
160
+ * boundary like any `coverage()` ledger. */
161
+ export interface RunbookEnvelope {
162
+ readonly af_coverage: {
163
+ readonly checked?: readonly CoverageItem[];
164
+ readonly not_checked?: readonly CoverageItem[];
165
+ readonly cannot_cover?: readonly CoverageItem[];
166
+ /** The static coverage law sentence (the `coverage()` note). */
167
+ readonly note: string;
168
+ /** The run's own sentence — names the rule set and version. */
169
+ readonly sentence: string;
170
+ };
171
+ readonly result: {
172
+ /** Re-emitted FIRST: the carried inner provenance stamp (if any inner
173
+ * tool declared one — a LOCAL SEED confession survives composition)
174
+ * plus this call's own `{tool, toolCallId}`. */
175
+ readonly af_provenance: Readonly<Record<string, unknown>>;
176
+ /** `rules.version`, or the honest `'undeclared'` when no rules were
177
+ * declared — the field never silently vanishes. */
178
+ readonly rule_version: string;
179
+ /** The recorded walk — always present. */
180
+ readonly walk: WalkDescriptor;
181
+ readonly verdicts?: readonly VerdictRow[];
182
+ readonly rows_shown?: number;
183
+ readonly rows_total?: number;
184
+ readonly rows_complete?: boolean;
185
+ /** Pre-rendered markdown table over the SAME rows as `verdicts`. */
186
+ readonly table?: string;
187
+ /** The render law, stated to the model. Present with `table`. */
188
+ readonly render_note?: string;
189
+ /** branch → meaning, GENERATED from the decider's declared branches and
190
+ * the rule labels this run's evidence carried — never hand-restated. */
191
+ readonly verdict_meanings?: Readonly<Record<string, string>>;
192
+ /** Present ONLY when the chart's `report` spelled one of the envelope's
193
+ * own names: it names every discarded field and says the values under
194
+ * those names are the bridge's. Absent on the clean path. */
195
+ readonly report_note?: string;
196
+ /** Everything the chart put in its `report` state key — the app's own
197
+ * result fields, spread here verbatim BESIDE the spine. Spine keys win:
198
+ * a report field spelling `af_coverage`, `af_provenance`, `rule_version`,
199
+ * `walk`, `report_note`, or a projection key this run assembled is
200
+ * discarded and named in `report_note`. */
201
+ readonly [appField: string]: unknown;
202
+ };
203
+ }
204
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/core/runbook/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,SAAS,CAAC;AAElE;;sCAEsC;AACtC,MAAM,WAAW,YAAY;IAC3B,wDAAwD;IACxD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;6BACyB;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,6CAA6C;AAC7C,MAAM,WAAW,sBAAsB;IACrC;;;;;;;OAOG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;oCAEgC;IAChC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,uBAAuB;AACvB,MAAM,WAAW,kBAAkB;IACjC;iFAC6E;IAC7E,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;0EAC0E;AAC1E,MAAM,WAAW,oBAAoB;IACnC,uCAAuC;IACvC,QAA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,CAAC,CAAC;QAC1D;4DACoD;QACpD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;QAC9B,0CAA0C;QAC1C,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;QAE9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;QAC1C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAC7B,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;QACjC,oEAAoE;QACpE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QACxB,iEAAiE;QACjE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAC9B;iFACyE;QACzE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QAC7D;;sEAE8D;QAC9D,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAC9B;;;;oDAI4C;QAC5C,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;KACtC,CAAC;CACH"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * runbook/verdicts — the OPTIONAL verdict/rowset projection.
3
+ *
4
+ * Pattern: pure selection + rendering over the run's final state, plus one
5
+ * tiny recorder that harvests decide() evidence for generated
6
+ * meanings. Selected by `resultKind: 'verdict/*'`; a runbook of any
7
+ * other kind never sees this module.
8
+ * Role: core/runbook.
9
+ * Emits: N/A.
10
+ *
11
+ * THE ONE-NUMBER LAW: the rendered table and the structured `verdicts` list
12
+ * show the SAME rows under the SAME cap. A rendered table beside a longer
13
+ * structured list is an invitation that gets accepted — rows come back
14
+ * retyped with subtly wrong identifiers.
15
+ *
16
+ * GENERATED MEANINGS, never hand-restated: `verdict_meanings` is composed
17
+ * from (a) the named decider's declared branches in the chart's own structure
18
+ * (branch description, falling back to branch name), overlaid by (b) the rule
19
+ * LABELS this run's decide() evidence carried — the rule speaking for itself.
20
+ * A decider inside a dynamically generated fan-out branch is invisible to (a)
21
+ * by construction (the branch chart does not exist at build time); (b) still
22
+ * covers every verdict an executed rule produced.
23
+ */
24
+ import type { CombinedRecorder } from 'footprintjs';
25
+ import type { FlowChart } from 'footprintjs';
26
+ import type { VerdictRow } from './types.js';
27
+ /** Default cap on `verdicts` rows and the rendered table. */
28
+ export declare const DEFAULT_MAX_ROWS = 50;
29
+ /** The render law, stated to the model beside every table. */
30
+ export declare const VERDICT_RENDER_NOTE: string;
31
+ /** The reserved verdict word for "no classification was reached" — rows
32
+ * carrying it are counted into the coverage ledger as not-checked ground
33
+ * (the three-outcome honesty: reached, reached-and-clear, DECLINED). */
34
+ export declare const DECLINED_VERDICT = "declined";
35
+ /** Read the rowset off the final state's `verdicts` key — an array of bags
36
+ * each carrying a string `verdict`. Anything else reads as "no rowset". */
37
+ export declare function verdictRowsOf(state: Readonly<Record<string, unknown>>): VerdictRow[];
38
+ /**
39
+ * Render the shown rows as one markdown table. Columns are the FIRST row's
40
+ * own keys in declaration order — the chart writes its rows, so the chart
41
+ * owns the column vocabulary; the bridge only renders it.
42
+ */
43
+ export declare function renderVerdictTable(rows: readonly VerdictRow[]): string;
44
+ /** The two spellings of the configured decider, once the static walk has
45
+ * (maybe) resolved it — flow events report the decider by name. */
46
+ export interface DeciderIdentity {
47
+ readonly spellings: ReadonlySet<string>;
48
+ /** branch → declared meaning, from the chart's own structure. */
49
+ readonly declared: ReadonlyMap<string, string>;
50
+ }
51
+ /**
52
+ * Find the named decider in the chart's static structure (root graph plus
53
+ * statically declared subflows) and read its branches. Loop-ref stubs are
54
+ * skipped FIRST — they deliberately violate node-id uniqueness.
55
+ */
56
+ export declare function resolveDecider(chart: FlowChart, decider: string): DeciderIdentity;
57
+ /** The evidence harvest: rule labels observed in this run, branch → label. */
58
+ export interface MeaningsHarvest {
59
+ readonly recorder: CombinedRecorder;
60
+ readonly observed: ReadonlyMap<string, string>;
61
+ }
62
+ /**
63
+ * A tiny flow recorder capturing the named decider's decide() evidence as it
64
+ * fires — collected DURING the traversal, never reconstructed after. Rule
65
+ * labels are harvested for every rule the evidence lists (matched or not):
66
+ * a rule that was evaluated has spoken its label, whichever branch won.
67
+ *
68
+ * A decider inside a subflow (including a generated fan-out branch) reports
69
+ * itself PATH-PREFIXED (`per-subject~0/Protection posture`), so the match is
70
+ * on the LAST `/`-segment — the same last-delimiter reading every upstream
71
+ * parser of these paths uses, which is what keeps the generated-branch
72
+ * marker opaque here.
73
+ */
74
+ export declare function meaningsRecorder(identity: DeciderIdentity): MeaningsHarvest;
75
+ /** Compose the final meanings: declared branches first, observed rule labels
76
+ * winning where both speak (the rule is the sharper sentence). Undefined
77
+ * when neither source produced anything — absent, never `{}`. */
78
+ export declare function composeMeanings(identity: DeciderIdentity, observed: ReadonlyMap<string, string>): Record<string, string> | undefined;
79
+ //# sourceMappingURL=verdicts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verdicts.d.ts","sourceRoot":"","sources":["../../../../src/core/runbook/verdicts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAqB,MAAM,aAAa,CAAC;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,6DAA6D;AAC7D,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC,8DAA8D;AAC9D,eAAO,MAAM,mBAAmB,QAGoB,CAAC;AAErD;;yEAEyE;AACzE,eAAO,MAAM,gBAAgB,aAAa,CAAC;AAE3C;4EAC4E;AAC5E,wBAAgB,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,UAAU,EAAE,CAUpF;AAWD;;;;G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