agentfootprint 7.1.0 → 7.2.0

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 (37) hide show
  1. package/CLAUDE.md +1 -1
  2. package/dist/esm/lib/context-ledger/contextLedger.d.ts +35 -0
  3. package/dist/esm/lib/context-ledger/contextLedger.js +309 -0
  4. package/dist/esm/lib/context-ledger/contextLedger.js.map +1 -0
  5. package/dist/esm/lib/context-ledger/gates.d.ts +63 -0
  6. package/dist/esm/lib/context-ledger/gates.js +105 -0
  7. package/dist/esm/lib/context-ledger/gates.js.map +1 -0
  8. package/dist/esm/lib/context-ledger/index.d.ts +10 -0
  9. package/dist/esm/lib/context-ledger/index.js +10 -0
  10. package/dist/esm/lib/context-ledger/index.js.map +1 -0
  11. package/dist/esm/lib/context-ledger/types.d.ts +107 -0
  12. package/dist/esm/lib/context-ledger/types.js +28 -0
  13. package/dist/esm/lib/context-ledger/types.js.map +1 -0
  14. package/dist/esm/observe.d.ts +2 -0
  15. package/dist/esm/observe.js +4 -0
  16. package/dist/esm/observe.js.map +1 -1
  17. package/dist/lib/context-ledger/contextLedger.js +313 -0
  18. package/dist/lib/context-ledger/contextLedger.js.map +1 -0
  19. package/dist/lib/context-ledger/gates.js +111 -0
  20. package/dist/lib/context-ledger/gates.js.map +1 -0
  21. package/dist/lib/context-ledger/index.js +17 -0
  22. package/dist/lib/context-ledger/index.js.map +1 -0
  23. package/dist/lib/context-ledger/types.js +29 -0
  24. package/dist/lib/context-ledger/types.js.map +1 -0
  25. package/dist/observe.js +9 -1
  26. package/dist/observe.js.map +1 -1
  27. package/dist/types/lib/context-ledger/contextLedger.d.ts +36 -0
  28. package/dist/types/lib/context-ledger/contextLedger.d.ts.map +1 -0
  29. package/dist/types/lib/context-ledger/gates.d.ts +64 -0
  30. package/dist/types/lib/context-ledger/gates.d.ts.map +1 -0
  31. package/dist/types/lib/context-ledger/index.d.ts +11 -0
  32. package/dist/types/lib/context-ledger/index.d.ts.map +1 -0
  33. package/dist/types/lib/context-ledger/types.d.ts +108 -0
  34. package/dist/types/lib/context-ledger/types.d.ts.map +1 -0
  35. package/dist/types/observe.d.ts +2 -0
  36. package/dist/types/observe.d.ts.map +1 -1
  37. package/package.json +1 -1
@@ -0,0 +1,107 @@
1
+ /**
2
+ * context-ledger/types.ts — the bookkeeper's vocabulary.
3
+ *
4
+ * WHY THIS LIBRARY EXISTS: context engineering fails in one predictable
5
+ * direction — "include everything to be safe". Every injection, skill and
6
+ * tool schema costs tokens EVERY turn, whether or not it ever mattered. The
7
+ * ledger keeps score across runs: which pieces EARNED their tokens (were
8
+ * called, activated, or sat on the answer's dependency slice) and which
9
+ * never did. Its rows feed the L2 gates (gatedTools predicate, skill-graph
10
+ * EntryScorer, injection demotion) so future turns include less — the
11
+ * mechanism that makes lesser models viable.
12
+ *
13
+ * HONESTY (the discipline everything here inherits):
14
+ * - Every counter is a STRUCTURAL fact from the run's own commit log —
15
+ * offers are recorded commits, uses are recorded calls/activations/slice
16
+ * membership. Nothing is inferred from model internals.
17
+ * - Each kind's `used` definition is explicit ({@link UsedSignal}) and rides
18
+ * every count — a consumer can always see WHY a piece counted as used.
19
+ * - Slice membership is slot-granular (all injections sharing a slot share
20
+ * its write) — the signal name says so: `'answer-slice(slot)'`.
21
+ * - `approxTokens*` is a serialized-length estimate (JSON chars ÷ 4), named
22
+ * so nobody mistakes it for a tokenizer count.
23
+ * - The ledger never claims causation. `earnRate` is bookkeeping;
24
+ * ablation (context-bisect) can upgrade individual claims when you pay
25
+ * for it.
26
+ */
27
+ /** What kind of context piece a row tracks. Skills are injections with
28
+ * flavor 'skill' — split out because their `used` signal differs. */
29
+ export type PieceKind = 'injection' | 'skill' | 'tool';
30
+ /**
31
+ * The per-kind structural definition of "used" — explicit, never blended:
32
+ * - `'tool-called'` — an assistant message actually called the tool.
33
+ * - `'skill-activated'` — the run activated the skill
34
+ * (`activatedInjectionIds`).
35
+ * - `'answer-slice(slot)'` — the injection's SLOT write sits on the final
36
+ * answer's backward dependency slice
37
+ * (slot-granular by construction).
38
+ */
39
+ export type UsedSignal = 'tool-called' | 'skill-activated' | 'answer-slice(slot)';
40
+ /** One context piece's accumulated bookkeeping across recorded runs. */
41
+ export interface LedgerRow {
42
+ /** Injection/skill id, or tool name. Unique within its kind. */
43
+ readonly id: string;
44
+ readonly kind: PieceKind;
45
+ /** Offer events — once per iteration the piece was in context, across runs. */
46
+ readonly offered: number;
47
+ /** Serialized-length token ESTIMATE spent on those offers (chars ÷ 4). */
48
+ readonly approxTokensSpent: number;
49
+ /** Structural uses (per-kind definition — see breakdown in usedVia). */
50
+ readonly used: number;
51
+ /** Which signal(s) produced the `used` count, and how many each. */
52
+ readonly usedVia: Readonly<Partial<Record<UsedSignal, number>>>;
53
+ /** Distinct recorded runs in which the piece was offered at least once. */
54
+ readonly runsSeen: number;
55
+ /**
56
+ * Outcome labels of runs where the piece was OFFERED (label → run count).
57
+ * Labels are consumer-supplied via {@link ContextLedger.recordOutcome}
58
+ * (thumbs, eval scores bucketed by the consumer, triage verdicts).
59
+ * Presence-correlation bookkeeping — NOT a causal claim.
60
+ */
61
+ readonly outcomes: Readonly<Record<string, number>>;
62
+ /** used ÷ offered (0 when never offered). THE headline number. */
63
+ readonly earnRate: number;
64
+ }
65
+ /** What `recordRun` extracted from one run — returned for inspection/tests. */
66
+ export interface RecordedRun {
67
+ /** Handle for {@link ContextLedger.recordOutcome}. */
68
+ readonly runRef: string;
69
+ /** Piece ids offered in this run (kind-qualified internal keys). */
70
+ readonly offeredPieces: readonly string[];
71
+ /** True when the answer slice could be computed (finalContent + reads). */
72
+ readonly sliceAvailable: boolean;
73
+ }
74
+ /** JSON-safe persisted shape (consumer owns storage). */
75
+ export interface LedgerJSON {
76
+ readonly version: 1;
77
+ readonly rows: readonly LedgerRow[];
78
+ readonly runsRecorded: number;
79
+ }
80
+ /** Minimal runner surface the ledger reads (any agentfootprint Runner). */
81
+ export interface RunnerLike {
82
+ getLastSnapshot(): unknown;
83
+ }
84
+ export interface ContextLedger {
85
+ /**
86
+ * Ingest one FINISHED run: walk its commit log for offers (activeInjections
87
+ * / dynamicToolSchemas per iteration), uses (assistant tool calls,
88
+ * activatedInjectionIds, the final answer's dependency slice), and
89
+ * accumulate. Accepts a runner (reads `getLastSnapshot()`) or a snapshot.
90
+ */
91
+ recordRun(source: RunnerLike | unknown): RecordedRun | undefined;
92
+ /**
93
+ * Label a recorded run's outcome ('good'/'bad'/any consumer label —
94
+ * thumbs, bucketed eval score, triage verdict). Defaults to the most
95
+ * recently recorded run. Increments the label for every piece OFFERED in
96
+ * that run.
97
+ */
98
+ recordOutcome(label: string, runRef?: string): boolean;
99
+ /** All rows, worst earnRate first (the review order that matters). */
100
+ rows(): readonly LedgerRow[];
101
+ /** One row (by kind + id). */
102
+ row(kind: PieceKind, id: string): LedgerRow | undefined;
103
+ /** JSON-safe export (consumer persists). */
104
+ exportJSON(): LedgerJSON;
105
+ /** Merge a previously exported ledger in (counts add). */
106
+ importJSON(json: LedgerJSON): void;
107
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * context-ledger/types.ts — the bookkeeper's vocabulary.
3
+ *
4
+ * WHY THIS LIBRARY EXISTS: context engineering fails in one predictable
5
+ * direction — "include everything to be safe". Every injection, skill and
6
+ * tool schema costs tokens EVERY turn, whether or not it ever mattered. The
7
+ * ledger keeps score across runs: which pieces EARNED their tokens (were
8
+ * called, activated, or sat on the answer's dependency slice) and which
9
+ * never did. Its rows feed the L2 gates (gatedTools predicate, skill-graph
10
+ * EntryScorer, injection demotion) so future turns include less — the
11
+ * mechanism that makes lesser models viable.
12
+ *
13
+ * HONESTY (the discipline everything here inherits):
14
+ * - Every counter is a STRUCTURAL fact from the run's own commit log —
15
+ * offers are recorded commits, uses are recorded calls/activations/slice
16
+ * membership. Nothing is inferred from model internals.
17
+ * - Each kind's `used` definition is explicit ({@link UsedSignal}) and rides
18
+ * every count — a consumer can always see WHY a piece counted as used.
19
+ * - Slice membership is slot-granular (all injections sharing a slot share
20
+ * its write) — the signal name says so: `'answer-slice(slot)'`.
21
+ * - `approxTokens*` is a serialized-length estimate (JSON chars ÷ 4), named
22
+ * so nobody mistakes it for a tokenizer count.
23
+ * - The ledger never claims causation. `earnRate` is bookkeeping;
24
+ * ablation (context-bisect) can upgrade individual claims when you pay
25
+ * for it.
26
+ */
27
+ export {};
28
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/lib/context-ledger/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG"}
@@ -55,3 +55,5 @@ export { typedEmit } from './recorders/core/typedEmit.js';
55
55
  export * from "./debug.js";
56
56
  export { buildChoiceContext, toolChoiceRecorder, type OfferedTool, type ToolChoiceCall, type ToolChoiceRecorderHandle, type ToolChoiceRecorderOptions, type ToolChoiceSkipReason, type ToolChoiceSummary, } from './recorders/observability/ToolChoiceRecorder.js';
57
57
  export { routeRecorder, formatRouteHop, type RouteRecorderHandle, type RouteRecorderOptions, type RouteHop, type RouteOutcome, type RouteTrip, type RouteTripKind, } from './recorders/observability/RouteRecorder.js';
58
+ export { contextLedger, ledgerToolGate, ledgerEntryScorer, ledgerGated } from './lib/context-ledger/index.js';
59
+ export type { ContextLedger, LedgerJSON, LedgerPolicy, LedgerRow, PieceKind, RecordedRun, UsedSignal, } from './lib/context-ledger/index.js';
@@ -77,4 +77,8 @@ export * from "./debug.js";
77
77
  // LAZILY on first read; flags narrow margins + proxy disagreements.
78
78
  export { buildChoiceContext, toolChoiceRecorder, } from './recorders/observability/ToolChoiceRecorder.js';
79
79
  export { routeRecorder, formatRouteHop, } from './recorders/observability/RouteRecorder.js';
80
+ // context-ledger — which context pieces EARNED their tokens? Post-run
81
+ // bookkeeping (offers/uses/outcomes from the commit log) feeding the gating
82
+ // seams. See src/lib/context-ledger/README.md.
83
+ export { contextLedger, ledgerToolGate, ledgerEntryScorer, ledgerGated } from './lib/context-ledger/index.js';
80
84
  //# sourceMappingURL=observe.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"observe.js","sourceRoot":"","sources":["../../src/observe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,4BAA4B;AAC5B,OAAO,EAAE,eAAe,EAA+B,MAAM,qCAAqC,CAAC;AACnG,OAAO,EAAE,cAAc,EAA8B,MAAM,oCAAoC,CAAC;AAEhG,+BAA+B;AAC/B,OAAO,EACL,mBAAmB,GAEpB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,aAAa,EAA6B,MAAM,mCAAmC,CAAC;AAC7F,OAAO,EACL,gBAAgB,EAChB,gBAAgB,GAgBjB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EACL,aAAa,EACb,eAAe,EACf,eAAe,GAQhB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACL,eAAe,EACf,cAAc,EACd,wBAAwB,GAQzB,MAAM,gDAAgD,CAAC;AAExD,8EAA8E;AAC9E,gFAAgF;AAChF,iEAAiE;AACjE,OAAO,EACL,cAAc,EACd,aAAa,EACb,gBAAgB,GAKjB,MAAM,oCAAoC,CAAC;AAE5C,mFAAmF;AACnF,OAAO,EACL,wBAAwB,GAGzB,MAAM,iDAAiD,CAAC;AAEzD,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,oBAAoB,GAKrB,MAAM,gDAAgD,CAAC;AAExD,6BAA6B;AAC7B,OAAO,EAAE,YAAY,EAA4B,MAAM,kCAAkC,CAAC;AAC1F,OAAO,EAAE,aAAa,EAA6B,MAAM,mCAAmC,CAAC;AAC7F,OAAO,EACL,wBAAwB,GAEzB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,YAAY,EAA4B,MAAM,kCAAkC,CAAC;AAC1F,OAAO,EAAE,cAAc,EAA8B,MAAM,oCAAoC,CAAC;AAChG,OAAO,EACL,kBAAkB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;AACvE,qEAAqE;AACrE,oEAAoE;AACpE,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GAOnB,MAAM,iDAAiD,CAAC;AAEzD,OAAO,EACL,aAAa,EACb,cAAc,GAOf,MAAM,4CAA4C,CAAC;AAEpD,sEAAsE;AACtE,4EAA4E;AAC5E,+CAA+C;AAC/C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,313 @@
1
+ "use strict";
2
+ /**
3
+ * contextLedger — the post-run bookkeeper (see types.ts for the WHY).
4
+ *
5
+ * DESIGN: a pure POST-RUN analyzer over the run's own commit log — no live
6
+ * recorder lifecycle, no event-order coupling. Everything it counts is
7
+ * already durably recorded by the engine (dogfooding: offers come from
8
+ * `commitValueAt` folds, answer attribution from `sliceForKey` — the same
9
+ * canonical queries every triage surface uses):
10
+ *
11
+ * offers — the context IN EFFECT at each LLM call. Call marker: a
12
+ * commit that wrote `totalInputTokens` (monotonic — never
13
+ * net-change-dropped) and did NOT write `userMessage` (which
14
+ * only the seed writes). At each call index, fold
15
+ * `activeInjections` + `dynamicToolSchemas`, and add the
16
+ * STATIC tool registry (duck-read from the runner's public
17
+ * `getUIGroup().extra.toolNames` — static registries live in a
18
+ * closure, never in scope state). NOTE offers are deliberately
19
+ * NOT "per context-key commit": the net-change filter drops
20
+ * identical re-commits, so stable context appears once in the
21
+ * log while still being offered (and paying tokens) per call.
22
+ * Static-registry tools count offers with approxTokens 0 in L1
23
+ * (their schema JSON isn't in the log) — earnRate, the gate
24
+ * signal, is unaffected; dynamicToolSchemas carries real sizes.
25
+ * uses — tool: assistant messages' toolCalls in the final history;
26
+ * skill: `activatedInjectionIds`;
27
+ * injection: its SLOT's write sits on the final answer's
28
+ * backward slice (slot-granular, labeled).
29
+ * outcome — consumer label per run, credited to every offered piece.
30
+ *
31
+ * The slot→slice join needs NO id conventions: for each slot key
32
+ * (INJECTION_KEYS.*), `findLastWriter` names the commit that fed the final
33
+ * LLM call; membership of that writer in the answer slice IS the signal.
34
+ */
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.contextLedger = void 0;
37
+ const trace_1 = require("footprintjs/trace");
38
+ const trace_2 = require("footprintjs/trace");
39
+ const conventions_js_1 = require("../../conventions.js");
40
+ /** chars ÷ 4 — a serialized-length ESTIMATE, deliberately rough and cheap. */
41
+ function approxTokens(value) {
42
+ try {
43
+ return Math.ceil(JSON.stringify(value).length / 4);
44
+ }
45
+ catch {
46
+ return 0;
47
+ }
48
+ }
49
+ /** sf-llm-call mount keys in loop order — grouped-mode iterations live in
50
+ * their own retained inner logs (the same projection context-bisect's
51
+ * assembleGroupedTrajectory uses). */
52
+ function llmCallMountKeys(subflowResults) {
53
+ if (!subflowResults)
54
+ return [];
55
+ return Object.keys(subflowResults)
56
+ .filter((k) => k.includes('#') && (0, trace_2.splitStageId)(k.split('#')[0]).localStageId === conventions_js_1.SUBFLOW_IDS.LLM_CALL)
57
+ .sort((a, b) => (0, trace_2.parseRuntimeStageId)(a).executionIndex - (0, trace_2.parseRuntimeStageId)(b).executionIndex);
58
+ }
59
+ function snapshotOf(source) {
60
+ const maybeRunner = source;
61
+ if (typeof maybeRunner?.getLastSnapshot === 'function') {
62
+ return maybeRunner.getLastSnapshot();
63
+ }
64
+ return source;
65
+ }
66
+ /** Static tool registry names, duck-read from the runner's public UI-group
67
+ * metadata (Agent fills `extra.toolNames`). Empty for non-runner sources. */
68
+ function staticToolNamesOf(source) {
69
+ const maybeRunner = source;
70
+ if (typeof maybeRunner?.getUIGroup !== 'function')
71
+ return [];
72
+ try {
73
+ const names = maybeRunner.getUIGroup()?.extra?.toolNames;
74
+ return Array.isArray(names) ? names.filter((n) => typeof n === 'string') : [];
75
+ }
76
+ catch {
77
+ return [];
78
+ }
79
+ }
80
+ function contextLedger() {
81
+ const table = new Map(); // key: `${kind}:${id}`
82
+ const runOffers = new Map(); // runRef → offered keys
83
+ let runsRecorded = 0;
84
+ let lastRunRef;
85
+ function rowOf(kind, id) {
86
+ const key = `${kind}:${id}`;
87
+ let row = table.get(key);
88
+ if (!row) {
89
+ row = { id, kind, offered: 0, approxTokensSpent: 0, used: 0, usedVia: {}, runsSeen: 0, outcomes: {} };
90
+ table.set(key, row);
91
+ }
92
+ return row;
93
+ }
94
+ function markUsed(kind, id, via) {
95
+ const row = rowOf(kind, id);
96
+ row.used += 1;
97
+ row.usedVia[via] = (row.usedVia[via] ?? 0) + 1;
98
+ }
99
+ function recordRun(source) {
100
+ const snapshot = snapshotOf(source);
101
+ const log = snapshot?.commitLog;
102
+ if (!log?.length)
103
+ return undefined;
104
+ runsRecorded += 1;
105
+ const runRef = `run-${runsRecorded}`;
106
+ const offeredKeys = new Set();
107
+ const offer = (kind, id, tokens) => {
108
+ const row = rowOf(kind, id);
109
+ row.offered += 1;
110
+ row.approxTokensSpent += tokens;
111
+ offeredKeys.add(`${kind}:${id}`);
112
+ };
113
+ // ── OFFERS: the context IN EFFECT at each LLM call ───────────────────
114
+ // Call marker: wrote totalInputTokens (monotonic — survives the
115
+ // net-change filter) and NOT userMessage (the seed's unique write).
116
+ // A SINGLE forward pass per log tracks the latest context values as
117
+ // writes appear (one commitValueAt per actual write — O(N), review
118
+ // finding #3), so each marker reads the context in effect exactly even
119
+ // though identical re-commits are dropped from the log.
120
+ //
121
+ // GROUPED reactMode (review finding #1): call-llm + the slots live
122
+ // INSIDE per-iteration `sf-llm-call#k` subflow logs (their context keys
123
+ // never bubble to the root), so offers fold over each retained inner
124
+ // log — the same projection context-bisect's grouped trajectory uses.
125
+ const staticTools = staticToolNamesOf(source);
126
+ let callMarkers = 0;
127
+ const foldOffersFrom = (bundles) => {
128
+ let injections = [];
129
+ let schemas = [];
130
+ for (let i = 0; i < bundles.length; i++) {
131
+ const paths = new Set(bundles[i].trace.map((t) => t.path));
132
+ if (paths.has('activeInjections')) {
133
+ const v = (0, trace_1.commitValueAt)(bundles, i, 'activeInjections');
134
+ if (Array.isArray(v))
135
+ injections = v;
136
+ }
137
+ if (paths.has('dynamicToolSchemas')) {
138
+ const v = (0, trace_1.commitValueAt)(bundles, i, 'dynamicToolSchemas');
139
+ if (Array.isArray(v))
140
+ schemas = v;
141
+ }
142
+ if (!paths.has('totalInputTokens') || paths.has('userMessage'))
143
+ continue;
144
+ callMarkers += 1;
145
+ for (const inj of injections) {
146
+ if (!inj?.id)
147
+ continue;
148
+ const kind = inj.flavor === 'skill' ? 'skill' : 'injection';
149
+ offer(kind, inj.id, approxTokens(inj));
150
+ }
151
+ // Tools: dynamic schemas (real sizes) + the static registry (offer
152
+ // counted, size unknowable from the log in L1 — earnRate unaffected).
153
+ const offeredToolsThisCall = new Set();
154
+ for (const schema of schemas) {
155
+ if (!schema?.name || offeredToolsThisCall.has(schema.name))
156
+ continue;
157
+ offeredToolsThisCall.add(schema.name);
158
+ offer('tool', schema.name, approxTokens(schema));
159
+ }
160
+ for (const name of staticTools) {
161
+ if (offeredToolsThisCall.has(name))
162
+ continue;
163
+ offeredToolsThisCall.add(name);
164
+ offer('tool', name, 0);
165
+ }
166
+ }
167
+ };
168
+ const mountKeys = llmCallMountKeys(snapshot?.subflowResults);
169
+ if (mountKeys.length > 0) {
170
+ for (const key of mountKeys) {
171
+ const inner = snapshot?.subflowResults?.[key]?.treeContext?.history;
172
+ if (Array.isArray(inner))
173
+ foldOffersFrom(inner);
174
+ }
175
+ }
176
+ else {
177
+ foldOffersFrom(log);
178
+ }
179
+ // A run with NO call markers anywhere is a shape this ledger cannot
180
+ // meter (e.g. the LLMCall runner, which never writes totalInputTokens)
181
+ // — report honestly instead of confidently recording zero offers.
182
+ if (callMarkers === 0) {
183
+ runsRecorded -= 1;
184
+ return undefined;
185
+ }
186
+ // ── USES: tool calls (assistant messages in the final history) ───────
187
+ const lastIdx = log.length - 1;
188
+ const history = (0, trace_1.commitValueAt)(log, lastIdx, 'history');
189
+ if (Array.isArray(history)) {
190
+ for (const msg of history) {
191
+ if (msg?.role !== 'assistant' || !Array.isArray(msg.toolCalls))
192
+ continue;
193
+ for (const call of msg.toolCalls) {
194
+ if (call?.name)
195
+ markUsed('tool', call.name, 'tool-called');
196
+ }
197
+ }
198
+ }
199
+ // ── USES: skill activations ──────────────────────────────────────────
200
+ const activated = (0, trace_1.commitValueAt)(log, lastIdx, 'activatedInjectionIds');
201
+ if (Array.isArray(activated)) {
202
+ for (const id of activated) {
203
+ if (typeof id === 'string' && id.length > 0)
204
+ markUsed('skill', id, 'skill-activated');
205
+ }
206
+ }
207
+ // ── USES: answer-slice membership per slot (slot-granular, honest) ───
208
+ // Slice the final answer; a slot counts as "on the answer's dependency
209
+ // chain" when its key's LAST WRITER is a slice member. Every injection
210
+ // in the FINAL context of that slot gets the (shared) credit.
211
+ let sliceAvailable = false;
212
+ const tree = snapshot?.executionTree;
213
+ if (tree) {
214
+ const reads = (0, trace_1.keysReadFromExecutionTree)(tree);
215
+ const slice = (0, trace_1.sliceForKey)(log, 'finalContent', reads);
216
+ if (slice.root) {
217
+ sliceAvailable = true;
218
+ const memberIds = new Set((0, trace_1.flattenCausalDAG)(slice.root).map((n) => n.runtimeStageId));
219
+ const finalInjections = (0, trace_1.commitValueAt)(log, lastIdx, 'activeInjections');
220
+ const finalBySlotKey = new Map();
221
+ // Which slot carried each injection is projected per-slot into the
222
+ // INJECTION_KEYS records — fold each slot key's final value.
223
+ for (const slotKey of Object.values(conventions_js_1.INJECTION_KEYS)) {
224
+ const writer = (0, trace_1.findLastWriter)(log, slotKey);
225
+ if (!writer || !memberIds.has(writer.runtimeStageId))
226
+ continue;
227
+ const slotRecords = (0, trace_1.commitValueAt)(log, lastIdx, slotKey);
228
+ if (Array.isArray(slotRecords))
229
+ finalBySlotKey.set(slotKey, slotRecords);
230
+ }
231
+ // Credit: injections present in a slice-member slot's final records.
232
+ const activeById = new Map();
233
+ if (Array.isArray(finalInjections)) {
234
+ for (const inj of finalInjections) {
235
+ if (inj?.id)
236
+ activeById.set(inj.id, inj);
237
+ }
238
+ }
239
+ for (const records of finalBySlotKey.values()) {
240
+ for (const rec of records) {
241
+ const id = rec?.id;
242
+ if (!id)
243
+ continue;
244
+ const flavor = activeById.get(id)?.flavor ?? rec.source;
245
+ const kind = flavor === 'skill' ? 'skill' : 'injection';
246
+ markUsed(kind, id, 'answer-slice(slot)');
247
+ }
248
+ }
249
+ }
250
+ }
251
+ // runsSeen: once per run per offered piece.
252
+ for (const key of offeredKeys) {
253
+ const row = table.get(key);
254
+ if (row)
255
+ row.runsSeen += 1;
256
+ }
257
+ runOffers.set(runRef, offeredKeys);
258
+ lastRunRef = runRef;
259
+ return { runRef, offeredPieces: [...offeredKeys], sliceAvailable };
260
+ }
261
+ function recordOutcome(label, runRef) {
262
+ const ref = runRef ?? lastRunRef;
263
+ if (!ref)
264
+ return false;
265
+ const offered = runOffers.get(ref);
266
+ if (!offered)
267
+ return false;
268
+ for (const key of offered) {
269
+ const row = table.get(key);
270
+ if (row)
271
+ row.outcomes[label] = (row.outcomes[label] ?? 0) + 1;
272
+ }
273
+ return true;
274
+ }
275
+ function freeze(row) {
276
+ return {
277
+ ...row,
278
+ usedVia: { ...row.usedVia },
279
+ outcomes: { ...row.outcomes },
280
+ earnRate: row.offered > 0 ? row.used / row.offered : 0,
281
+ };
282
+ }
283
+ return {
284
+ recordRun,
285
+ recordOutcome,
286
+ rows: () => [...table.values()].map(freeze).sort((a, b) => a.earnRate - b.earnRate),
287
+ row: (kind, id) => {
288
+ const row = table.get(`${kind}:${id}`);
289
+ return row ? freeze(row) : undefined;
290
+ },
291
+ exportJSON: () => ({ version: 1, rows: [...table.values()].map(freeze), runsRecorded }),
292
+ importJSON: (json) => {
293
+ if (json?.version !== 1)
294
+ return;
295
+ for (const r of json.rows) {
296
+ const row = rowOf(r.kind, r.id);
297
+ row.offered += r.offered;
298
+ row.approxTokensSpent += r.approxTokensSpent;
299
+ row.used += r.used;
300
+ row.runsSeen += r.runsSeen;
301
+ for (const [via, n] of Object.entries(r.usedVia)) {
302
+ row.usedVia[via] = (row.usedVia[via] ?? 0) + (n ?? 0);
303
+ }
304
+ for (const [label, n] of Object.entries(r.outcomes)) {
305
+ row.outcomes[label] = (row.outcomes[label] ?? 0) + n;
306
+ }
307
+ }
308
+ runsRecorded += json.runsRecorded;
309
+ },
310
+ };
311
+ }
312
+ exports.contextLedger = contextLedger;
313
+ //# sourceMappingURL=contextLedger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contextLedger.js","sourceRoot":"","sources":["../../../src/lib/context-ledger/contextLedger.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;;;AAEH,6CAM2B;AAG3B,6CAAsE;AACtE,yDAAmE;AAUnE,8EAA8E;AAC9E,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACrD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC;AAmBD;;uCAEuC;AACvC,SAAS,gBAAgB,CAAC,cAAmD;IAC3E,IAAI,CAAC,cAAc;QAAE,OAAO,EAAE,CAAC;IAC/B,OAAO,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC;SAC/B,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAA,oBAAY,EAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,KAAK,4BAAW,CAAC,QAAQ,CAAC;SACrG,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAA,2BAAmB,EAAC,CAAC,CAAC,CAAC,cAAc,GAAG,IAAA,2BAAmB,EAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;AACnG,CAAC;AAED,SA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AAO,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;oBACpD,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;gBACvD,CAAC;YACH,CAAC;YACD,YAAY,IAAI,IAAI,CAAC,YAAY,CAAC;QACpC,CAAC;KACF,CAAC;AACJ,CAAC;AAnOD,sCAmOC"}
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ /**
3
+ * context-ledger/gates.ts — L2: the ledger's rows feed what gets included.
4
+ *
5
+ * Three gates, one policy, each hooking an EXISTING seam (no new framework
6
+ * surface): `gatedTools(inner, predicate)` for tools, `skillGraph().entryBy`
7
+ * for skills, and a rule-trigger wrapper for injections.
8
+ *
9
+ * THE POLICY PRINCIPLE — demote, never starve: a piece the ledger judges
10
+ * poorly is demoted, but every `refreshEvery`-th decision lets it through
11
+ * anyway ("parole"), so it keeps generating fresh ledger data. Without
12
+ * parole a piece demoted once could never earn again — a self-fulfilling
13
+ * verdict. And the ledger never judges a piece it barely knows: below
14
+ * `minOffers` everything passes.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.ledgerGated = exports.ledgerEntryScorer = exports.ledgerToolGate = void 0;
18
+ const entryScorer_js_1 = require("../injection-engine/entryScorer.js");
19
+ const DEFAULTS = { minOffers: 5, earnRateFloor: 0.05, refreshEvery: 10 };
20
+ /**
21
+ * The shared verdict: should this piece be included right now?
22
+ * Stateful per gate instance (the parole counter), pure otherwise.
23
+ */
24
+ function makeVerdict(ledger, policy) {
25
+ const p = { ...DEFAULTS, ...policy };
26
+ const demotions = new Map();
27
+ return (kind, id) => {
28
+ const row = ledger.row(kind, id);
29
+ if (!row)
30
+ return true; // unknown to the ledger → always include
31
+ if (row.offered < p.minOffers)
32
+ return true; // not enough data to judge
33
+ if (row.earnRate >= p.earnRateFloor)
34
+ return true; // earning its tokens
35
+ // Demoted — but parole every Nth decision keeps the data flowing.
36
+ const key = `${kind}:${id}`;
37
+ const count = (demotions.get(key) ?? 0) + 1;
38
+ demotions.set(key, count);
39
+ return p.refreshEvery !== Infinity && count % p.refreshEvery === 0;
40
+ };
41
+ }
42
+ /**
43
+ * TOOL GATE — plug into the existing provider combinator:
44
+ *
45
+ * ```ts
46
+ * import { gatedTools, staticTools } from 'agentfootprint/tool-providers';
47
+ * builder.toolProvider(gatedTools(staticTools(tools), ledgerToolGate(ledger)));
48
+ * ```
49
+ *
50
+ * Unused tool schemas are usually the biggest silent token cost — this is
51
+ * the gate to start with.
52
+ */
53
+ function ledgerToolGate(ledger, policy) {
54
+ const verdict = makeVerdict(ledger, policy);
55
+ return (toolName) => verdict('tool', toolName);
56
+ }
57
+ exports.ledgerToolGate = ledgerToolGate;
58
+ /**
59
+ * SKILL GATE — an `EntryScorer` for `skillGraph().entryBy(...)` that wraps
60
+ * another scorer (keyword, embedding, …) and demotes candidates the ledger
61
+ * says never earn. Demotion multiplies the inner score toward the floor —
62
+ * ranking pressure, not exclusion — and parole restores full weight
63
+ * periodically, so a demoted skill can still win when nothing else fits.
64
+ */
65
+ function ledgerEntryScorer(ledger, inner, policy) {
66
+ const verdict = makeVerdict(ledger, policy);
67
+ const DEMOTION_WEIGHT = 0.25;
68
+ return {
69
+ name: `ledger(${inner.name})`,
70
+ async score(input, signal) {
71
+ const base = await inner.score(input, signal);
72
+ // Re-rank through rankEntries so `chosen`, `score` AND `relevance` are
73
+ // recomputed TOGETHER from the demoted scores — preserving the
74
+ // entryScorer contract (argmax-score == argmax-relevance; the "Why
75
+ // this skill?" panel and the pick can never disagree).
76
+ const candidates = base.ranked.map((r) => ({
77
+ id: r.id,
78
+ description: input.candidates.find((c) => c.id === r.id)?.description ?? '',
79
+ }));
80
+ const demotedScores = base.ranked.map((r) => verdict('skill', r.id) ? r.score : r.score * DEMOTION_WEIGHT);
81
+ return (0, entryScorer_js_1.rankEntries)(`ledger(${base.scorer})`, candidates, demotedScores);
82
+ },
83
+ };
84
+ }
85
+ exports.ledgerEntryScorer = ledgerEntryScorer;
86
+ /**
87
+ * INJECTION GATE — wrap ONE injection so the ledger's verdict joins its
88
+ * trigger. `always` becomes a ledger-backed rule; an existing `rule` is
89
+ * AND-ed with the verdict. `on-tool-return` / `llm-activated` are returned
90
+ * UNCHANGED (they are already demand-driven — the ledger has nothing to
91
+ * add). `always` pieces are exempt unless you explicitly wrap them — the
92
+ * safety-first default from the design.
93
+ */
94
+ function ledgerGated(injection, ledger, policy) {
95
+ const verdict = makeVerdict(ledger, policy);
96
+ const kind = injection.flavor === 'skill' ? 'skill' : 'injection';
97
+ const trigger = injection.trigger;
98
+ if (trigger.kind === 'always') {
99
+ return { ...injection, trigger: { kind: 'rule', activeWhen: () => verdict(kind, injection.id) } };
100
+ }
101
+ if (trigger.kind === 'rule') {
102
+ const original = trigger.activeWhen;
103
+ return {
104
+ ...injection,
105
+ trigger: { kind: 'rule', activeWhen: (ctx) => original(ctx) && verdict(kind, injection.id) },
106
+ };
107
+ }
108
+ return injection; // demand-driven triggers pass through untouched
109
+ }
110
+ exports.ledgerGated = ledgerGated;
111
+ //# sourceMappingURL=gates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gates.js","sourceRoot":"","sources":["../../../src/lib/context-ledger/gates.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAEH,uEAAiE;AAuBjE,MAAM,QAAQ,GAA2B,EAAE,SAAS,EAAE,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;AAEjG;;;GAGG;AACH,SAAS,WAAW,CAClB,MAAqB,EACrB,MAAgC;IAEhC,MAAM,CAAC,GAAG,EAAE,GAAG,QAAQ,EAAE,GAAG,MAAM,EAAE,CAAC;IACrC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC5C,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE;QAClB,MA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OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACpG,CAAC;IACD,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;QACpC,OAAO;YACL,GAAG,SAAS;YACZ,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,EAAE;SAC7F,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC,CAAC,gDAAgD;AACpE,CAAC;AAnBD,kCAmBC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ /**
3
+ * context-ledger — which context pieces EARNED their tokens?
4
+ *
5
+ * Post-run bookkeeping over the run's own commit log (offers, structural
6
+ * uses, consumer outcomes) whose rows feed the gating seams so future turns
7
+ * include less. See README.md for the honesty model and the L2 gates.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ledgerGated = exports.ledgerEntryScorer = exports.ledgerToolGate = exports.contextLedger = void 0;
11
+ var contextLedger_js_1 = require("./contextLedger.js");
12
+ Object.defineProperty(exports, "contextLedger", { enumerable: true, get: function () { return contextLedger_js_1.contextLedger; } });
13
+ var gates_js_1 = require("./gates.js");
14
+ Object.defineProperty(exports, "ledgerToolGate", { enumerable: true, get: function () { return gates_js_1.ledgerToolGate; } });
15
+ Object.defineProperty(exports, "ledgerEntryScorer", { enumerable: true, get: function () { return gates_js_1.ledgerEntryScorer; } });
16
+ Object.defineProperty(exports, "ledgerGated", { enumerable: true, get: function () { return gates_js_1.ledgerGated; } });
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/context-ledger/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,uDAAmD;AAA1C,iHAAA,aAAa,OAAA;AAStB,uCAA+F;AAAtF,0GAAA,cAAc,OAAA;AAAE,6GAAA,iBAAiB,OAAA;AAAE,uGAAA,WAAW,OAAA"}