agentfootprint 6.24.0 → 6.26.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 (87) hide show
  1. package/README.md +31 -0
  2. package/bin/agentfootprint-lint-tools.mjs +14 -0
  3. package/dist/esm/lib/context-bisect/ablation.js +183 -0
  4. package/dist/esm/lib/context-bisect/ablation.js.map +1 -0
  5. package/dist/esm/lib/context-bisect/bisect.js +129 -0
  6. package/dist/esm/lib/context-bisect/bisect.js.map +1 -0
  7. package/dist/esm/lib/context-bisect/index.js +22 -0
  8. package/dist/esm/lib/context-bisect/index.js.map +1 -0
  9. package/dist/esm/lib/context-bisect/llmEdgeWeigher.js +0 -0
  10. package/dist/esm/lib/context-bisect/llmEdgeWeigher.js.map +1 -0
  11. package/dist/esm/lib/context-bisect/localize.js +555 -0
  12. package/dist/esm/lib/context-bisect/localize.js.map +1 -0
  13. package/dist/esm/lib/context-bisect/types.js +56 -0
  14. package/dist/esm/lib/context-bisect/types.js.map +1 -0
  15. package/dist/esm/lib/tool-lint/analyze.js +235 -0
  16. package/dist/esm/lib/tool-lint/analyze.js.map +1 -0
  17. package/dist/esm/lib/tool-lint/cli.js +198 -0
  18. package/dist/esm/lib/tool-lint/cli.js.map +1 -0
  19. package/dist/esm/lib/tool-lint/format.js +61 -0
  20. package/dist/esm/lib/tool-lint/format.js.map +1 -0
  21. package/dist/esm/lib/tool-lint/index.js +23 -0
  22. package/dist/esm/lib/tool-lint/index.js.map +1 -0
  23. package/dist/esm/lib/tool-lint/rules.js +249 -0
  24. package/dist/esm/lib/tool-lint/rules.js.map +1 -0
  25. package/dist/esm/lib/tool-lint/types.js +25 -0
  26. package/dist/esm/lib/tool-lint/types.js.map +1 -0
  27. package/dist/esm/observe.js +20 -0
  28. package/dist/esm/observe.js.map +1 -1
  29. package/dist/esm/recorders/observability/ToolChoiceRecorder.js +261 -0
  30. package/dist/esm/recorders/observability/ToolChoiceRecorder.js.map +1 -0
  31. package/dist/lib/context-bisect/ablation.js +192 -0
  32. package/dist/lib/context-bisect/ablation.js.map +1 -0
  33. package/dist/lib/context-bisect/bisect.js +133 -0
  34. package/dist/lib/context-bisect/bisect.js.map +1 -0
  35. package/dist/lib/context-bisect/index.js +40 -0
  36. package/dist/lib/context-bisect/index.js.map +1 -0
  37. package/dist/lib/context-bisect/llmEdgeWeigher.js +0 -0
  38. package/dist/lib/context-bisect/llmEdgeWeigher.js.map +1 -0
  39. package/dist/lib/context-bisect/localize.js +563 -0
  40. package/dist/lib/context-bisect/localize.js.map +1 -0
  41. package/dist/lib/context-bisect/types.js +59 -0
  42. package/dist/lib/context-bisect/types.js.map +1 -0
  43. package/dist/lib/tool-lint/analyze.js +242 -0
  44. package/dist/lib/tool-lint/analyze.js.map +1 -0
  45. package/dist/lib/tool-lint/cli.js +203 -0
  46. package/dist/lib/tool-lint/cli.js.map +1 -0
  47. package/dist/lib/tool-lint/format.js +65 -0
  48. package/dist/lib/tool-lint/format.js.map +1 -0
  49. package/dist/lib/tool-lint/index.js +43 -0
  50. package/dist/lib/tool-lint/index.js.map +1 -0
  51. package/dist/lib/tool-lint/rules.js +256 -0
  52. package/dist/lib/tool-lint/rules.js.map +1 -0
  53. package/dist/lib/tool-lint/types.js +26 -0
  54. package/dist/lib/tool-lint/types.js.map +1 -0
  55. package/dist/observe.js +56 -1
  56. package/dist/observe.js.map +1 -1
  57. package/dist/recorders/observability/ToolChoiceRecorder.js +266 -0
  58. package/dist/recorders/observability/ToolChoiceRecorder.js.map +1 -0
  59. package/dist/types/lib/context-bisect/ablation.d.ts +97 -0
  60. package/dist/types/lib/context-bisect/ablation.d.ts.map +1 -0
  61. package/dist/types/lib/context-bisect/bisect.d.ts +76 -0
  62. package/dist/types/lib/context-bisect/bisect.d.ts.map +1 -0
  63. package/dist/types/lib/context-bisect/index.d.ts +22 -0
  64. package/dist/types/lib/context-bisect/index.d.ts.map +1 -0
  65. package/dist/types/lib/context-bisect/llmEdgeWeigher.d.ts +125 -0
  66. package/dist/types/lib/context-bisect/llmEdgeWeigher.d.ts.map +1 -0
  67. package/dist/types/lib/context-bisect/localize.d.ts +119 -0
  68. package/dist/types/lib/context-bisect/localize.d.ts.map +1 -0
  69. package/dist/types/lib/context-bisect/types.d.ts +356 -0
  70. package/dist/types/lib/context-bisect/types.d.ts.map +1 -0
  71. package/dist/types/lib/tool-lint/analyze.d.ts +84 -0
  72. package/dist/types/lib/tool-lint/analyze.d.ts.map +1 -0
  73. package/dist/types/lib/tool-lint/cli.d.ts +44 -0
  74. package/dist/types/lib/tool-lint/cli.d.ts.map +1 -0
  75. package/dist/types/lib/tool-lint/format.d.ts +19 -0
  76. package/dist/types/lib/tool-lint/format.d.ts.map +1 -0
  77. package/dist/types/lib/tool-lint/index.d.ts +24 -0
  78. package/dist/types/lib/tool-lint/index.d.ts.map +1 -0
  79. package/dist/types/lib/tool-lint/rules.d.ts +86 -0
  80. package/dist/types/lib/tool-lint/rules.d.ts.map +1 -0
  81. package/dist/types/lib/tool-lint/types.d.ts +156 -0
  82. package/dist/types/lib/tool-lint/types.d.ts.map +1 -0
  83. package/dist/types/observe.d.ts +3 -0
  84. package/dist/types/observe.d.ts.map +1 -1
  85. package/dist/types/recorders/observability/ToolChoiceRecorder.d.ts +165 -0
  86. package/dist/types/recorders/observability/ToolChoiceRecorder.d.ts.map +1 -0
  87. package/package.json +4 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolChoiceRecorder.js","sourceRoot":"","sources":["../../../src/recorders/observability/ToolChoiceRecorder.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;;;AAGH,6CAA+C;AAC/C,gEAK2C;AAC3C,+DAAmE;AA2FnE;0EAC0E;AAC1E,SAAgB,kBAAkB,CAAC,IAIlC;IACC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC;IACtC,MAA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EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,MAAM;aACvE,CAAC;QACJ,CAAC;QAED,KAAK;YACH,KAAK,EAAE,CAAC;QACV,CAAC;KACF,CAAC;AACJ,CAAC;AA7LD,gDA6LC"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Ablation — the counterfactual seam (RFC-003 Part B, D8 stage 4 + the
3
+ * D9 stats engine).
4
+ *
5
+ * Three pieces:
6
+ *
7
+ * 1. **Adapters** — `ablationForSuspect` maps a classified suspect to
8
+ * the spec that removes it (tool → drop from catalog; injection /
9
+ * fact / skill → exclude the `Injection.id`; memory → filter the
10
+ * `MemoryEntry.id`; arg → consumer-override note).
11
+ *
12
+ * 2. **The seam** — `applyAblations` filters the inputs an agent is
13
+ * BUILT from. Documented here because the seam did not previously
14
+ * exist: `AgentOptions` has no `ignoredTools` runtime kill-switch, so
15
+ * tool ablation happens at construction (the consumer's
16
+ * `AblationRunner` rebuilds the agent from filtered inputs). Same for
17
+ * injections and memory entries.
18
+ *
19
+ * 3. **The probe engine** — `runAblationProbe` calls the consumer's
20
+ * runner N seeded times, measures embedding similarity to the
21
+ * original output, counts outcome flips, and returns variance —
22
+ * never a single-run verdict (D9 discipline).
23
+ *
24
+ * §B2: only `runAblationProbe`-derived verdicts are causal claims; every
25
+ * score elsewhere is a correlational proxy.
26
+ */
27
+ import type { Embedder } from '../influence-core/index.js';
28
+ import type { AblationRerun, AblationRunStats, AblationSpec, AblationVerdict, OutcomeComparator, Suspect } from './types.js';
29
+ /**
30
+ * The spec that removes one suspect — or `undefined` for kind `'stage'`
31
+ * (plain pipeline stages have no removable input; re-rank or refactor).
32
+ */
33
+ export declare function ablationForSuspect(suspect: Suspect): AblationSpec | undefined;
34
+ /** Anything with a stable id — `Injection` and `MemoryEntry` both fit. */
35
+ interface Identified {
36
+ readonly id: string;
37
+ }
38
+ /** Anything with a named schema — the library's `Tool` fits. */
39
+ interface NamedTool {
40
+ readonly schema: {
41
+ readonly name: string;
42
+ };
43
+ }
44
+ export interface AblationTargets<TTool extends NamedTool = NamedTool, TInjection extends Identified = Identified, TMemoryEntry extends Identified = Identified> {
45
+ readonly tools?: readonly TTool[];
46
+ readonly injections?: readonly TInjection[];
47
+ readonly memoryEntries?: readonly TMemoryEntry[];
48
+ }
49
+ /**
50
+ * Apply ablation specs to the inputs an agent is constructed from —
51
+ * THE documented seam (see module docs). Generic over the concrete tool /
52
+ * injection / memory-entry types so it filters without importing them.
53
+ *
54
+ * `'arg'` specs are deliberately NOT handled here: run input belongs to
55
+ * the consumer's runner (`spec.note` says so).
56
+ *
57
+ * @example inside an AblationRunner
58
+ * ```ts
59
+ * const { tools, injections } = applyAblations(specs, {
60
+ * tools: ALL_TOOLS, injections: ALL_FACTS,
61
+ * });
62
+ * const agent = Agent.create({ provider: freshProvider(), model })
63
+ * .tools([...tools]);
64
+ * for (const inj of injections) agent.fact(inj);
65
+ * ```
66
+ */
67
+ export declare function applyAblations<TTool extends NamedTool, TInjection extends Identified, TMemoryEntry extends Identified>(specs: readonly AblationSpec[], targets: AblationTargets<TTool, TInjection, TMemoryEntry>): {
68
+ tools: readonly TTool[];
69
+ injections: readonly TInjection[];
70
+ memoryEntries: readonly TMemoryEntry[];
71
+ };
72
+ /** The default comparator: embedding similarity below the threshold. */
73
+ export declare function defaultOutcomeComparator(embedder: Embedder, flipThreshold: number): OutcomeComparator;
74
+ /** Resolved probe configuration shared by D8 and D9. */
75
+ export interface ProbeConfig {
76
+ readonly rerun: AblationRerun;
77
+ readonly embedder: Embedder;
78
+ }
79
+ /**
80
+ * Run ONE probe: call the consumer's runner with `specs` once per seed
81
+ * (0..samples-1), measure each output's embedding similarity to the
82
+ * original, and count outcome flips. Variance is always reported.
83
+ *
84
+ * `samples` is clamped to ≥ 2 — D9: never single-run verdicts.
85
+ */
86
+ export declare function runAblationProbe(config: ProbeConfig, specs: readonly AblationSpec[]): Promise<AblationRunStats>;
87
+ /** Majority-flip rule shared by D8 verdicts and D9 probes. */
88
+ export declare function probeFlipped(stats: AblationRunStats): boolean;
89
+ /**
90
+ * Translate probe evidence into the verdict — the ONLY causal claim tier
91
+ * (§B2). `baselineStable=false` (the un-ablated scenario itself flipped)
92
+ * forces `'inconclusive'`: no ablation verdict is trustworthy on an
93
+ * unstable baseline.
94
+ */
95
+ export declare function verdictFor(label: string, stats: AblationRunStats, baselineStable: boolean): AblationVerdict;
96
+ export {};
97
+ //# sourceMappingURL=ablation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ablation.d.ts","sourceRoot":"","sources":["../../../../src/lib/context-bisect/ablation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,iBAAiB,EAEjB,OAAO,EACR,MAAM,YAAY,CAAC;AAKpB;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,GAAG,SAAS,CAyB7E;AAID,0EAA0E;AAC1E,UAAU,UAAU;IAClB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAED,gEAAgE;AAChE,UAAU,SAAS;IACjB,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5C;AAED,MAAM,WAAW,eAAe,CAC9B,KAAK,SAAS,SAAS,GAAG,SAAS,EACnC,UAAU,SAAS,UAAU,GAAG,UAAU,EAC1C,YAAY,SAAS,UAAU,GAAG,UAAU;IAE5C,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,KAAK,EAAE,CAAC;IAClC,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;CAClD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAC5B,KAAK,SAAS,SAAS,EACvB,UAAU,SAAS,UAAU,EAC7B,YAAY,SAAS,UAAU,EAE/B,KAAK,EAAE,SAAS,YAAY,EAAE,EAC9B,OAAO,EAAE,eAAe,CAAC,KAAK,EAAE,UAAU,EAAE,YAAY,CAAC,GACxD;IACD,KAAK,EAAE,SAAS,KAAK,EAAE,CAAC;IACxB,UAAU,EAAE,SAAS,UAAU,EAAE,CAAC;IAClC,aAAa,EAAE,SAAS,YAAY,EAAE,CAAC;CACxC,CAiBA;AAgBD,wEAAwE;AACxE,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,MAAM,GACpB,iBAAiB,CAQnB;AAED,wDAAwD;AACxD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,SAAS,YAAY,EAAE,GAC7B,OAAO,CAAC,gBAAgB,CAAC,CAgB3B;AAED,8DAA8D;AAC9D,wBAAgB,YAAY,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAE7D;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,gBAAgB,EACvB,cAAc,EAAE,OAAO,GACtB,eAAe,CAgCjB"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * bisectCulprits — multi-culprit bisection over the ranked suspect set
3
+ * (RFC-003 Part B, block D9). The "git bisect" of the localizer.
4
+ *
5
+ * When single-suspect ablations don't flip the outcome — redundant causes
6
+ * (two facts that EACH justify the wrong answer), or interacting ones —
7
+ * the culprit is a SET. This harness finds a minimal culprit set by
8
+ * recursive halving over the ranked suspects (delta-debugging style,
9
+ * Zeller's ddmin specialized to two-way splits), then keeps searching the
10
+ * remainder for INDEPENDENT culprits until the remainder stops flipping.
11
+ *
12
+ * Probe semantics (the D9 discipline):
13
+ * - every probe = N seeded reruns of the consumer's `AblationRunner`
14
+ * with the probe's combined specs; "flipped" = MAJORITY of runs
15
+ * changed outcome; similarity mean ± spread is always reported —
16
+ * never single-run verdicts;
17
+ * - probe 0 is the BASELINE (no ablation): if it flips, the scenario
18
+ * itself is unstable and the result is honestly `'inconclusive'`;
19
+ * - probes are cached by spec-set, and budgeted (`maxProbes`) — running
20
+ * out of budget yields `'inconclusive'`, never a partial claim
21
+ * dressed up as a finding.
22
+ *
23
+ * §B2: the returned `verdict`/`culprits` are CAUSAL claims — they rest
24
+ * exclusively on counterfactual reruns. The input ranking only chooses
25
+ * the SEARCH ORDER (better ranking = fewer probes), it never decides the
26
+ * outcome.
27
+ */
28
+ import type { AblationRerun, AblationRunStats, Embedder, Suspect } from './types.js';
29
+ /** One executed probe — full variance evidence, kept for the report. */
30
+ export interface BisectionProbe {
31
+ /** Labels of the suspects ablated together ([] = the baseline probe). */
32
+ readonly ablated: readonly string[];
33
+ readonly stats: AblationRunStats;
34
+ /** Majority-of-N outcome flip. */
35
+ readonly flipped: boolean;
36
+ }
37
+ export interface BisectionResult {
38
+ /**
39
+ * `'confirmed'` — a minimal culprit set was found and verified by
40
+ * counterfactual reruns. `'not-reproducible'` — ablating EVERY ranked
41
+ * suspect together does not flip the outcome: the bug's cause is not
42
+ * in the ranked set (look at the report's honesty flags — the slice
43
+ * may be incomplete). `'inconclusive'` — unstable baseline or probe
44
+ * budget exhausted.
45
+ */
46
+ readonly verdict: 'confirmed' | 'not-reproducible' | 'inconclusive';
47
+ /**
48
+ * Minimal culprit set(s): each inner array is one minimal set whose
49
+ * JOINT ablation flips the outcome. Independent culprits appear as
50
+ * separate sets; redundant/interacting causes appear together in one.
51
+ */
52
+ readonly culprits: readonly (readonly Suspect[])[];
53
+ /** Every probe executed, in order (baseline first). */
54
+ readonly probes: readonly BisectionProbe[];
55
+ /** Total consumer-runner invocations (probes × samples). */
56
+ readonly runsUsed: number;
57
+ }
58
+ export interface BisectCulpritsOptions {
59
+ /** Ranked suspects — only those carrying an applicable ablation spec
60
+ * participate ('arg' and 'stage' suspects are skipped: nothing the
61
+ * harness can remove for the consumer). */
62
+ readonly suspects: readonly Suspect[];
63
+ readonly rerun: AblationRerun;
64
+ /** Embedder for similarity stats (and the default flip comparator). */
65
+ readonly embedder: Embedder;
66
+ /** Probe budget. Default 24. Exhaustion → 'inconclusive'. */
67
+ readonly maxProbes?: number;
68
+ /** Max independent culprit sets to search for. Default 4. */
69
+ readonly maxCulprits?: number;
70
+ }
71
+ /**
72
+ * Find minimal culprit set(s) by seeded counterfactual bisection. See
73
+ * module docs for semantics and the §B2 claim tier.
74
+ */
75
+ export declare function bisectCulprits(options: BisectCulpritsOptions): Promise<BisectionResult>;
76
+ //# sourceMappingURL=bisect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bisect.d.ts","sourceRoot":"","sources":["../../../../src/lib/context-bisect/bisect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAMrF,wEAAwE;AACxE,MAAM,WAAW,cAAc;IAC7B,yEAAyE;IACzE,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IACjC,kCAAkC;IAClC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B;;;;;;;OAOG;IACH,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,kBAAkB,GAAG,cAAc,CAAC;IACpE;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,SAAS,OAAO,EAAE,CAAC,EAAE,CAAC;IACnD,uDAAuD;IACvD,QAAQ,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,CAAC;IAC3C,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC;;gDAE4C;IAC5C,QAAQ,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,uEAAuE;IACvE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,6DAA6D;IAC7D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,6DAA6D;IAC7D,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAUD;;;GAGG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,CA+F7F"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * context-bisect — RFC-003 Part B: the contextual-bug LOCALIZER,
3
+ * "git bisect for context".
4
+ *
5
+ * Assembly over shipped pieces: footprintjs 9.8.0's complete causal DAG
6
+ * (control edges, honesty markers, `EdgeWeigher` hook) × influence-core
7
+ * scoring (D6) × consumer-run counterfactual ablation.
8
+ *
9
+ * D7 — `llmEdgeWeigher` influence-weighted LLM-call slice edges
10
+ * D8 — `localizeContextBug` trigger → slice → ranked suspects → ablation
11
+ * D9 — `bisectCulprits` seeded multi-culprit bisection + variance
12
+ *
13
+ * §B2 claim tiers (spelled out on every type): weights/scores are
14
+ * embedding-geometry PROXIES; ablation verdicts are the ONLY causal
15
+ * claims; slice completeness is bounded by tracking — and says so.
16
+ */
17
+ export { llmEdgeWeigher, stepOutputText, type LlmEdgeWeigherHandle, type LlmEdgeWeigherOptions, type RankedParentEdge, } from './llmEdgeWeigher.js';
18
+ export { defaultSuspectClassifier, formatContextBugReport, llmCallIdsFromEvents, localizeContextBug, suspectLabel, type ClassifyContext, type LocalizeContextBugOptions, type SuspectClassifier, type SuspectSeed, } from './localize.js';
19
+ export { ablationForSuspect, applyAblations, defaultOutcomeComparator, probeFlipped, runAblationProbe, verdictFor, type AblationTargets, type ProbeConfig, } from './ablation.js';
20
+ export { bisectCulprits, type BisectCulpritsOptions, type BisectionProbe, type BisectionResult, } from './bisect.js';
21
+ export { CONTEXT_BISECT_DEFAULTS, type AblationRerun, type AblationRunner, type AblationRunStats, type AblationSpec, type AblationVerdict, type AblationVerdictKind, type CapturedEventLike, type ContextBugArtifacts, type ContextBugReport, type EdgePathStep, type HonestyFlag, type HonestyFlagKind, type OutcomeComparator, type QualityTriggerLookup, type SimilarityStats, type SliceStats, type Suspect, type SuspectDetail, type SuspectKind, } from './types.js';
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/context-bisect/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,cAAc,EACd,cAAc,EACd,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,YAAY,EACZ,KAAK,eAAe,EACpB,KAAK,yBAAyB,EAC9B,KAAK,iBAAiB,EACtB,KAAK,WAAW,GACjB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,wBAAwB,EACxB,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,KAAK,eAAe,EACpB,KAAK,WAAW,GACjB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,cAAc,EACd,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,KAAK,eAAe,GACrB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,uBAAuB,EACvB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,aAAa,EAClB,KAAK,WAAW,GACjB,MAAM,YAAY,CAAC"}
@@ -0,0 +1,125 @@
1
+ /**
2
+ * llmEdgeWeigher — influence-scored `EdgeWeigher` for LLM-call slice edges
3
+ * (RFC-003 Part B, block D7).
4
+ *
5
+ * The gap this fills: footprintjs's causal slice treats every parent of an
6
+ * LLM call equally — a 12-parent hairball (system prompt, history, tool
7
+ * results, cache markers, counters …) gives a debugger 12 equally-plausible
8
+ * leads. D7 turns the hairball into a RANKED shortlist by weighing each
9
+ * parent edge with influence-core's composite (D6): the parent's WRITTEN
10
+ * content vs the LLM call's OUTPUT.
11
+ *
12
+ * Pattern: two-pass adapter over footprintjs's synchronous `EdgeWeigher`
13
+ * hook (A3). Embedding is async, the hook is sync — so the handle
14
+ * PRIMES first (walk an unweighted slice, embed every needed text
15
+ * in deduplicated batches, memoize composites), and `weigh` then
16
+ * answers synchronously from the primed map. `localizeContextBug`
17
+ * drives the two passes; standalone consumers call
18
+ * `prime(dag)` themselves and re-run `causalChain({ weigh })`.
19
+ * Role: `src/lib/context-bisect/` leaf. The engine stays zero-dep — the
20
+ * weigher is consumer-injected exactly as A3 intended.
21
+ *
22
+ * ## Honest claim (§B2)
23
+ *
24
+ * Weights are CORRELATIONAL proxies: deterministic embedding geometry
25
+ * between texts the run already committed — never model internals, never
26
+ * causal attribution (ablation is the causal tier). A weight of 0.93 means
27
+ * "this parent's content is semantically close to what the LLM produced",
28
+ * not "the LLM used it".
29
+ *
30
+ * ## Determinism
31
+ *
32
+ * Same artifacts + same (deterministic) embedder → same weights and same
33
+ * ranking, run after run: texts are built from the commit log in commit
34
+ * order, embedded via influence-core's deduplicated batch, and ties in
35
+ * `rankedParents` keep first-seen (slice BFS) order. Wrap the embedder in
36
+ * `embeddingCache(...)` to also make repeat localizations embed nothing.
37
+ *
38
+ * ## What is weighed
39
+ *
40
+ * DATA edges whose CHILD is an LLM call (`llmCallIds`). Everything else —
41
+ * non-LLM children, control edges (a routing decision's influence is not a
42
+ * semantic-content question) — returns `undefined`, which footprintjs
43
+ * stamps as the default 1.0.
44
+ *
45
+ * ## Redaction posture
46
+ *
47
+ * Texts come exclusively from the COMMIT LOG, which footprintjs scrubs at
48
+ * commit time — a redacted key's committed value IS the placeholder, so
49
+ * the embedder never sees the raw secret.
50
+ */
51
+ import type { CommitBundle } from 'footprintjs/advanced';
52
+ import type { CausalNode, EdgeWeigher } from 'footprintjs/trace';
53
+ import { type Embedder, type InfluenceWeights } from '../influence-core/index.js';
54
+ export interface LlmEdgeWeigherOptions {
55
+ /**
56
+ * Injected embedder (D6 contract). Wrap in `embeddingCache(...)` so the
57
+ * weigher, the suspect refinement, and any margin/lint consumer share
58
+ * one embedding spend.
59
+ */
60
+ readonly embedder: Embedder;
61
+ /**
62
+ * runtimeStageIds of LLM-call executions — the children whose parent
63
+ * edges get weighed. Provide explicitly, or extract from captured
64
+ * events with `llmCallIdsFromEvents` (the `stream.llm_start` ids).
65
+ */
66
+ readonly llmCallIds: Iterable<string>;
67
+ /** The run's commit log — where edge texts are read from. */
68
+ readonly commitLog: readonly CommitBundle[];
69
+ /** Char cap per embedded text. Default 2000. */
70
+ readonly maxTextChars?: number;
71
+ /** Composite weights forwarded to influence-core. Default: paper priors. */
72
+ readonly weights?: InfluenceWeights;
73
+ /**
74
+ * Override the CHILD text (the LLM call's output). Default: the values
75
+ * the child committed, serialized `key=value` in trace order, capped.
76
+ */
77
+ readonly childTextOf?: (runtimeStageId: string) => string | undefined;
78
+ /**
79
+ * Override the PARENT text for one edge. Default: the value the parent
80
+ * committed for the edge's key, serialized + capped.
81
+ */
82
+ readonly parentTextOf?: (runtimeStageId: string, key: string) => string | undefined;
83
+ }
84
+ /** One ranked parent edge of an LLM call (descending weight). */
85
+ export interface RankedParentEdge {
86
+ readonly parentId: string;
87
+ readonly stageName: string;
88
+ readonly key: string;
89
+ /** Influence composite clamped to [0, 1] — a correlational proxy (§B2). */
90
+ readonly weight: number;
91
+ }
92
+ export interface LlmEdgeWeigherHandle {
93
+ /**
94
+ * Pass 1 — walk an (unweighted) causal DAG, embed every LLM-edge text in
95
+ * one deduplicated batch, and memoize composite weights. Idempotent;
96
+ * call again with a different DAG to extend the map.
97
+ */
98
+ prime(root: CausalNode): Promise<void>;
99
+ /**
100
+ * Pass 2 — the synchronous footprintjs `EdgeWeigher`. Returns the primed
101
+ * weight for (LLM child, parent, data key); `undefined` (→ engine
102
+ * default 1.0) for control edges, non-LLM children, and unprimed pairs.
103
+ */
104
+ readonly weigh: EdgeWeigher;
105
+ /**
106
+ * The D7 acceptance view: an LLM call's parents ranked by weight,
107
+ * descending; ties keep first-seen (slice BFS) order. Empty until
108
+ * `prime` ran over a DAG containing the call.
109
+ */
110
+ rankedParents(llmCallId: string): readonly RankedParentEdge[];
111
+ /** Texts the embedder was given — exposed for security audits/tests. */
112
+ embeddedTexts(): readonly string[];
113
+ }
114
+ /**
115
+ * Default child text: everything the step committed, `key=value` in trace
116
+ * order. For an agent's LLM call this carries the assistant content +
117
+ * tool-call intents — the step's observable OUTPUT.
118
+ */
119
+ export declare function stepOutputText(commitLog: readonly CommitBundle[], lastIdxOf: Map<string, number>, runtimeStageId: string, maxChars: number): string | undefined;
120
+ /**
121
+ * Build the D7 weigher. See module docs for the two-pass contract, the
122
+ * determinism guarantee, and the §B2 honest claim (weights = proxies).
123
+ */
124
+ export declare function llmEdgeWeigher(options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GAAG,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,KAAK,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B;;;;OAIG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,gBAAgB,EAAE,CAAC;IAC9D,wEAAwE;IACxE,aAAa,IAAI,SAAS,MAAM,EAAE,CAAC;CACpC;AAeD;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,SAAS,YAAY,EAAE,EAClC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,MAAM,GACf,MAAM,GAAG,SAAS,CAepB;AAmBD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,oBAAoB,CA+FnF"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * localizeContextBug — the contextual-bug LOCALIZER, "git bisect for
3
+ * context" (RFC-003 Part B, block D8).
4
+ *
5
+ * The five-stage pipeline (each stage is a shipped piece — this file only
6
+ * ASSEMBLES):
7
+ *
8
+ * 1. TRIGGER — an explicit `atStep`, a custom trigger strategy, or
9
+ * the QualityRecorder's lowest-scoring step.
10
+ * 2. SLICE — footprintjs `causalChain` over the commit log, WITH
11
+ * control-dependence edges (D3) and honesty markers
12
+ * (A2/A4) when the artifacts carry them.
13
+ * 3. WEIGH — D7's `llmEdgeWeigher` stamps influence weights on
14
+ * every LLM-call parent edge (two-pass: prime, re-slice).
15
+ * 4. RANK — suspects = slice nodes classified into ablatable
16
+ * context sources (tool / injection / memory / arg),
17
+ * scored by max-product path weight × per-item semantic
18
+ * refinement. CORRELATIONAL tier — and marked so.
19
+ * 5. ABLATE — optional: the consumer's `AblationRunner` re-runs the
20
+ * scenario without each top suspect, N seeded times.
21
+ * Verdicts (the ONLY causal claims, §B2) + variance.
22
+ *
23
+ * Without a runner the report stops at stage 4 with
24
+ * `mode: 'correlational'` — explicitly a ranking of proxies, no causal
25
+ * claim anywhere.
26
+ *
27
+ * Every `source` / `step` id in the report is a plain runtimeStageId —
28
+ * drill any of them with the trace-toolpack tools (`trace_node`,
29
+ * `trace_slice`, `get_value`) over the same artifacts bag.
30
+ */
31
+ import type { CausalNode } from 'footprintjs/trace';
32
+ import { type Embedder } from '../influence-core/index.js';
33
+ import type { AblationRerun, ContextBugArtifacts, ContextBugReport, Suspect, SuspectDetail, SuspectKind } from './types.js';
34
+ /**
35
+ * Extract LLM-call step ids from captured typed events: the
36
+ * `meta.runtimeStageId` of every `agentfootprint.stream.llm_start`
37
+ * envelope, deduplicated in event order. Collect events with
38
+ * `agent.on('*', (e) => events.push(e))`.
39
+ */
40
+ export declare function llmCallIdsFromEvents(events: readonly {
41
+ readonly type: string;
42
+ readonly meta: {
43
+ readonly runtimeStageId: string;
44
+ };
45
+ }[]): string[];
46
+ /** A classified-but-unscored suspect produced by a classifier. */
47
+ export interface SuspectSeed {
48
+ readonly kind: SuspectKind;
49
+ readonly detail?: SuspectDetail;
50
+ }
51
+ /** What a classifier sees for one slice node. */
52
+ export interface ClassifyContext {
53
+ readonly node: CausalNode;
54
+ /** Keys this node committed. */
55
+ readonly keysWritten: readonly string[];
56
+ /** Verb-aware value of a key as of this node's last commit. */
57
+ readonly valueOf: (key: string) => unknown;
58
+ }
59
+ /**
60
+ * Pluggable classifier: map one slice node to its ablatable context
61
+ * sources. Return `undefined` to fall through to the default (which
62
+ * understands the agent chart's committed shapes); return `[]` to
63
+ * suppress the node entirely.
64
+ */
65
+ export type SuspectClassifier = (ctx: ClassifyContext) => readonly SuspectSeed[] | undefined;
66
+ /**
67
+ * The default classifier — reads the node's COMMITTED values (already
68
+ * redaction-scrubbed) and recognizes the agent chart's shapes:
69
+ *
70
+ * - `systemPromptInjections` / `messagesInjections` / `toolsInjections`
71
+ * records with an engineered source → one suspect per `Injection.id`
72
+ * (kind `'memory'` for source `'memory'`, else `'injection'`).
73
+ * - `lastToolResult` → a `'tool'` suspect for the tool that ran.
74
+ * - footprintjs A2 honesty marker `args` → an `'arg'` suspect (the
75
+ * consumer's runner must override the input — nothing to filter).
76
+ * - anything else → the honest `'stage'` fallback (no ablation spec).
77
+ */
78
+ export declare function defaultSuspectClassifier(ctx: ClassifyContext): readonly SuspectSeed[];
79
+ export interface LocalizeContextBugOptions {
80
+ readonly artifacts: ContextBugArtifacts;
81
+ /** Injected embedder (D6) — wrap in `embeddingCache(...)`. */
82
+ readonly embedder: Embedder;
83
+ /** Explicit trigger step (runtimeStageId). Wins over everything. */
84
+ readonly atStep?: string;
85
+ /** Custom trigger strategy — consulted when `atStep` is absent. */
86
+ readonly trigger?: (artifacts: ContextBugArtifacts) => string | undefined;
87
+ /**
88
+ * The counterfactual tier: supply a runner (+ the original output) and
89
+ * top suspects get ablation verdicts. Absent → the report stops at the
90
+ * ranking, marked `mode: 'correlational'`.
91
+ */
92
+ readonly rerun?: AblationRerun;
93
+ /** Slice depth budget. Default 12. */
94
+ readonly maxDepth?: number;
95
+ /** Slice node budget. Default 80. */
96
+ readonly maxNodes?: number;
97
+ /** Ranked suspects kept on the report. Default 12. */
98
+ readonly maxSuspects?: number;
99
+ /** Override / extend the suspect classifier. */
100
+ readonly classify?: SuspectClassifier;
101
+ }
102
+ /**
103
+ * Localize a contextual bug: trigger → causal slice → influence-weighted
104
+ * ranking → (optional) counterfactual ablation. See module docs for the
105
+ * pipeline and the §B2 claim tiers.
106
+ *
107
+ * @throws when no trigger can be resolved (no `atStep`, no custom
108
+ * strategy hit, no `artifacts.quality`), or when the trigger step
109
+ * is not in the commit log.
110
+ */
111
+ export declare function localizeContextBug(options: LocalizeContextBugOptions): Promise<ContextBugReport>;
112
+ export declare function suspectLabel(suspect: Suspect): string;
113
+ /**
114
+ * Human-readable report. The claim tiers are spelled out in the output
115
+ * itself (§B2): scores are proxies; verdict lines are the only causal
116
+ * claims; every ⚠ honesty flag prints.
117
+ */
118
+ export declare function formatContextBugReport(report: ContextBugReport): string;
119
+ //# sourceMappingURL=localize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localize.d.ts","sourceRoot":"","sources":["../../../../src/lib/context-bisect/localize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAAkB,KAAK,QAAQ,EAAsB,MAAM,4BAA4B,CAAC;AAG/F,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAIhB,OAAO,EACP,aAAa,EACb,WAAW,EACZ,MAAM,YAAY,CAAC;AAKpB;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE;QAAE,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EAAE,GAC/F,MAAM,EAAE,CAWV;AAID,kEAAkE;AAClE,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC;CACjC;AAED,iDAAiD;AACjD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,gCAAgC;IAChC,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;CAC5C;AAED;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GA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