agentfootprint 6.30.0 → 6.32.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.
- package/dist/esm/lib/context-bisect/ablation.js +40 -2
- package/dist/esm/lib/context-bisect/ablation.js.map +1 -1
- package/dist/esm/lib/context-bisect/cost.js +61 -0
- package/dist/esm/lib/context-bisect/cost.js.map +1 -0
- package/dist/esm/lib/context-bisect/index.js +10 -1
- package/dist/esm/lib/context-bisect/index.js.map +1 -1
- package/dist/esm/lib/context-bisect/localize.js +43 -4
- package/dist/esm/lib/context-bisect/localize.js.map +1 -1
- package/dist/esm/lib/context-bisect/loop-recall.js +108 -0
- package/dist/esm/lib/context-bisect/loop-recall.js.map +1 -0
- package/dist/esm/lib/context-bisect/trajectory.js +221 -0
- package/dist/esm/lib/context-bisect/trajectory.js.map +1 -0
- package/dist/esm/lib/context-bisect/types.js.map +1 -1
- package/dist/esm/lib/context-bisect/walk-to-root.js +170 -0
- package/dist/esm/lib/context-bisect/walk-to-root.js.map +1 -0
- package/dist/esm/lib/influence-core/contrastive.js +89 -0
- package/dist/esm/lib/influence-core/contrastive.js.map +1 -0
- package/dist/esm/lib/influence-core/index.js +1 -0
- package/dist/esm/lib/influence-core/index.js.map +1 -1
- package/dist/esm/lib/influence-core/signals.js +9 -4
- package/dist/esm/lib/influence-core/signals.js.map +1 -1
- package/dist/esm/observe.js +2 -2
- package/dist/esm/observe.js.map +1 -1
- package/dist/lib/context-bisect/ablation.js +43 -3
- package/dist/lib/context-bisect/ablation.js.map +1 -1
- package/dist/lib/context-bisect/cost.js +66 -0
- package/dist/lib/context-bisect/cost.js.map +1 -0
- package/dist/lib/context-bisect/index.js +23 -1
- package/dist/lib/context-bisect/index.js.map +1 -1
- package/dist/lib/context-bisect/localize.js +43 -4
- package/dist/lib/context-bisect/localize.js.map +1 -1
- package/dist/lib/context-bisect/loop-recall.js +112 -0
- package/dist/lib/context-bisect/loop-recall.js.map +1 -0
- package/dist/lib/context-bisect/trajectory.js +227 -0
- package/dist/lib/context-bisect/trajectory.js.map +1 -0
- package/dist/lib/context-bisect/types.js.map +1 -1
- package/dist/lib/context-bisect/walk-to-root.js +176 -0
- package/dist/lib/context-bisect/walk-to-root.js.map +1 -0
- package/dist/lib/influence-core/contrastive.js +93 -0
- package/dist/lib/influence-core/contrastive.js.map +1 -0
- package/dist/lib/influence-core/index.js +3 -1
- package/dist/lib/influence-core/index.js.map +1 -1
- package/dist/lib/influence-core/signals.js +11 -4
- package/dist/lib/influence-core/signals.js.map +1 -1
- package/dist/observe.js +14 -2
- package/dist/observe.js.map +1 -1
- package/dist/types/lib/context-bisect/ablation.d.ts +6 -1
- package/dist/types/lib/context-bisect/ablation.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/cost.d.ts +38 -0
- package/dist/types/lib/context-bisect/cost.d.ts.map +1 -0
- package/dist/types/lib/context-bisect/index.d.ts +6 -2
- package/dist/types/lib/context-bisect/index.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/localize.d.ts +8 -0
- package/dist/types/lib/context-bisect/localize.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/loop-recall.d.ts +98 -0
- package/dist/types/lib/context-bisect/loop-recall.d.ts.map +1 -0
- package/dist/types/lib/context-bisect/trajectory.d.ts +153 -0
- package/dist/types/lib/context-bisect/trajectory.d.ts.map +1 -0
- package/dist/types/lib/context-bisect/types.d.ts +68 -1
- package/dist/types/lib/context-bisect/types.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/walk-to-root.d.ts +103 -0
- package/dist/types/lib/context-bisect/walk-to-root.d.ts.map +1 -0
- package/dist/types/lib/influence-core/contrastive.d.ts +27 -0
- package/dist/types/lib/influence-core/contrastive.d.ts.map +1 -0
- package/dist/types/lib/influence-core/index.d.ts +1 -0
- package/dist/types/lib/influence-core/index.d.ts.map +1 -1
- package/dist/types/lib/influence-core/signals.d.ts +8 -0
- package/dist/types/lib/influence-core/signals.d.ts.map +1 -1
- package/dist/types/observe.d.ts +2 -2
- package/dist/types/observe.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assembleTrajectory = exports.findLoopHeads = exports.bucketByAnchors = void 0;
|
|
4
|
+
const trace_1 = require("footprintjs/trace");
|
|
5
|
+
const conventions_js_1 = require("../../conventions.js");
|
|
6
|
+
const llmEdgeWeigher_js_1 = require("./llmEdgeWeigher.js");
|
|
7
|
+
const types_js_1 = require("./types.js");
|
|
8
|
+
/**
|
|
9
|
+
* Partition a commit log by a list of HEAD runtimeStageIds (taken as data — no agent
|
|
10
|
+
* knowledge). Each frame is the half-open range `[head[k], head[k+1])`; commits before
|
|
11
|
+
* the first head are the `prelude`. TOTAL: every commit lands in exactly one frame OR
|
|
12
|
+
* the prelude. Heads not found in the log are ignored; ordering follows the log, not the
|
|
13
|
+
* input list (an out-of-order or duplicate head list cannot reorder/duplicate commits).
|
|
14
|
+
*
|
|
15
|
+
* A head is anchored at the FIRST commit bearing its runtimeStageId — a single stage
|
|
16
|
+
* execution can flush MORE THAN ONE commit bundle under one runtimeStageId (parallel
|
|
17
|
+
* fork merges, multi-flush stages), and those repeats stay INSIDE the frame they open
|
|
18
|
+
* rather than each spawning a spurious one-commit frame.
|
|
19
|
+
*/
|
|
20
|
+
function bucketByAnchors(commitLog, headRuntimeStageIds) {
|
|
21
|
+
const headSet = new Set(headRuntimeStageIds);
|
|
22
|
+
const headIdx = [];
|
|
23
|
+
const anchored = new Set();
|
|
24
|
+
for (let i = 0; i < commitLog.length; i++) {
|
|
25
|
+
const id = commitLog[i].runtimeStageId;
|
|
26
|
+
if (headSet.has(id) && !anchored.has(id)) {
|
|
27
|
+
headIdx.push(i);
|
|
28
|
+
anchored.add(id); // later commits sharing this id belong to the frame it opened
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (headIdx.length === 0) {
|
|
32
|
+
return { frames: [], prelude: commitLog.map((b) => b.runtimeStageId) };
|
|
33
|
+
}
|
|
34
|
+
const prelude = commitLog.slice(0, headIdx[0]).map((b) => b.runtimeStageId);
|
|
35
|
+
const frames = headIdx.map((head, k) => {
|
|
36
|
+
const end = k + 1 < headIdx.length ? headIdx[k + 1] : commitLog.length;
|
|
37
|
+
return { headArrayIdx: head, bodyIds: commitLog.slice(head, end).map((b) => b.runtimeStageId) };
|
|
38
|
+
});
|
|
39
|
+
return { frames, prelude };
|
|
40
|
+
}
|
|
41
|
+
exports.bucketByAnchors = bucketByAnchors;
|
|
42
|
+
// ─── findLoopHeads — flat-chart loop-head detection ──────────────────
|
|
43
|
+
/** True when a commit lives inside the injection-engine subflow (the loop head region). */
|
|
44
|
+
function inInjectionEngine(bundle) {
|
|
45
|
+
const { localStageId, subflowPath } = (0, trace_1.splitStageId)(bundle.stageId);
|
|
46
|
+
if (localStageId === conventions_js_1.SUBFLOW_IDS.INJECTION_ENGINE)
|
|
47
|
+
return true; // the mount commit, if any
|
|
48
|
+
if (subflowPath === undefined)
|
|
49
|
+
return false;
|
|
50
|
+
// a commit nested anywhere under sf-injection-engine (handles nested subflow prefixes)
|
|
51
|
+
return subflowPath === conventions_js_1.SUBFLOW_IDS.INJECTION_ENGINE || subflowPath.startsWith(conventions_js_1.SUBFLOW_IDS.INJECTION_ENGINE + '/');
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The flat-chart loop heads: the FIRST commit of each injection-engine ENTRY (one per
|
|
55
|
+
* ReAct iteration, since the loop is branch-sourced back to the injection engine). A head
|
|
56
|
+
* is a commit that is in the injection engine while the previous commit was not — so a
|
|
57
|
+
* multi-commit injection-engine body yields exactly one head per loop.
|
|
58
|
+
*
|
|
59
|
+
* Returns the runtimeStageIds to feed `bucketByAnchors`. Empty when the run never enters
|
|
60
|
+
* the injection engine (e.g. the grouped chart, where the loop lives in sf-llm-call —
|
|
61
|
+
* the caller degrades with an honesty flag).
|
|
62
|
+
*/
|
|
63
|
+
function findLoopHeads(commitLog) {
|
|
64
|
+
const heads = [];
|
|
65
|
+
let wasIn = false;
|
|
66
|
+
for (const bundle of commitLog) {
|
|
67
|
+
const isIn = inInjectionEngine(bundle);
|
|
68
|
+
if (isIn && !wasIn)
|
|
69
|
+
heads.push(bundle.runtimeStageId);
|
|
70
|
+
wasIn = isIn;
|
|
71
|
+
}
|
|
72
|
+
return heads;
|
|
73
|
+
}
|
|
74
|
+
exports.findLoopHeads = findLoopHeads;
|
|
75
|
+
/** Build the per-runtimeStageId read-key map from the snapshot execution tree
|
|
76
|
+
* (same walk as the localizer's `buildArtifactIndex`). */
|
|
77
|
+
function buildReadsOf(executionTree) {
|
|
78
|
+
const readsOf = new Map();
|
|
79
|
+
const visit = (node) => {
|
|
80
|
+
if (!node)
|
|
81
|
+
return;
|
|
82
|
+
const id = node.runtimeStageId;
|
|
83
|
+
if (id && !readsOf.has(id))
|
|
84
|
+
readsOf.set(id, node.stageReads ? Object.keys(node.stageReads) : []);
|
|
85
|
+
for (const child of node.children ?? [])
|
|
86
|
+
visit(child);
|
|
87
|
+
visit(node.next);
|
|
88
|
+
};
|
|
89
|
+
visit(executionTree);
|
|
90
|
+
return readsOf;
|
|
91
|
+
}
|
|
92
|
+
function safeStringify(value) {
|
|
93
|
+
if (typeof value === 'string')
|
|
94
|
+
return value;
|
|
95
|
+
try {
|
|
96
|
+
return JSON.stringify(value) ?? String(value);
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return String(value);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Project ONE loop frame from a given commit log + readsOf — the shared core used by BOTH
|
|
104
|
+
* the flat path (over the run commit log) and the grouped path (over a subflow's OWN inner
|
|
105
|
+
* commit log). `headArrayIdx`/`bodyIds` bound the frame WITHIN `log`; `subflowScope`, when
|
|
106
|
+
* set, records that all indices are relative to that subflow's inner log.
|
|
107
|
+
*/
|
|
108
|
+
function projectFrame(loopIndex, log, lastIdxOf, readsOf, headArrayIdx, bodyIds, maxTextChars, subflowScope) {
|
|
109
|
+
// Locate the call-llm commit WITHIN this frame's body (the LLM-step pointer).
|
|
110
|
+
let llmCallId;
|
|
111
|
+
let llmCallArrayIdx;
|
|
112
|
+
let llmBundle;
|
|
113
|
+
for (let i = headArrayIdx; i < headArrayIdx + bodyIds.length; i++) {
|
|
114
|
+
if ((0, trace_1.splitStageId)(log[i].stageId).localStageId === conventions_js_1.STAGE_IDS.CALL_LLM) {
|
|
115
|
+
llmCallId = log[i].runtimeStageId;
|
|
116
|
+
llmCallArrayIdx = i;
|
|
117
|
+
llmBundle = log[i];
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const intermediateText = llmCallId !== undefined ? (0, llmEdgeWeigher_js_1.stepOutputText)(log, lastIdxOf, llmCallId, maxTextChars) : undefined;
|
|
122
|
+
const keys = llmCallId !== undefined ? (readsOf.get(llmCallId) ?? []) : [];
|
|
123
|
+
const contextSources = keys.map((key) => {
|
|
124
|
+
// EXCLUSIVE beforeIdx — finds the PRIOR writer, never call-llm's own write-back.
|
|
125
|
+
const writer = llmCallArrayIdx !== undefined ? (0, trace_1.findLastWriter)(log, key, llmCallArrayIdx) : undefined;
|
|
126
|
+
const writerId = writer?.runtimeStageId;
|
|
127
|
+
const writerArrayIdx = writerId !== undefined ? lastIdxOf.get(writerId) : undefined;
|
|
128
|
+
const value = writerArrayIdx !== undefined ? (0, trace_1.commitValueAt)(log, writerArrayIdx, key) : undefined;
|
|
129
|
+
const text = value === undefined ? '' : safeStringify(value).slice(0, maxTextChars);
|
|
130
|
+
return {
|
|
131
|
+
key,
|
|
132
|
+
writerId,
|
|
133
|
+
writerArrayIdx,
|
|
134
|
+
value,
|
|
135
|
+
evidence: { id: `${llmCallId}::${key}`, text, ancestorTexts: [] },
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
const incompleteSources = llmBundle?.untrackedSources;
|
|
139
|
+
const untrackedReadsPresent = incompleteSources !== undefined && incompleteSources.length > 0;
|
|
140
|
+
return {
|
|
141
|
+
loopIndex,
|
|
142
|
+
llmCallId,
|
|
143
|
+
llmCallArrayIdx,
|
|
144
|
+
headArrayIdx,
|
|
145
|
+
bodyIds,
|
|
146
|
+
intermediateText,
|
|
147
|
+
contextSources,
|
|
148
|
+
...(subflowScope !== undefined ? { subflowScope } : {}),
|
|
149
|
+
...(untrackedReadsPresent ? { incompleteSources } : {}),
|
|
150
|
+
untrackedReadsPresent,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/** The sf-llm-call mount keys in `subflowResults`, in loop order (by execution index). */
|
|
154
|
+
function llmCallMountKeys(subflowResults) {
|
|
155
|
+
return Object.keys(subflowResults)
|
|
156
|
+
.filter((k) => k.includes('#') && (0, trace_1.splitStageId)(k.split('#')[0]).localStageId === conventions_js_1.SUBFLOW_IDS.LLM_CALL)
|
|
157
|
+
.sort((a, b) => (0, trace_1.parseRuntimeStageId)(a).executionIndex - (0, trace_1.parseRuntimeStageId)(b).executionIndex);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* GROUPED chart projection (`reactMode: 'dynamic-grouped'`). The LLM turn runs inside an
|
|
161
|
+
* `sf-llm-call` subflow, so its `call-llm` + slot writes live in the subflow's OWN commit log
|
|
162
|
+
* — retained per-iteration under `subflowResults['sf-llm-call#k']` (footprintjs
|
|
163
|
+
* subflow-commit-visibility). Each loop is a frame projected PER-SCOPE over its inner log; no
|
|
164
|
+
* cross-scope merge, so `findLastWriter`/`commitValueAt` run correctly over the isolated log.
|
|
165
|
+
*/
|
|
166
|
+
function assembleGroupedTrajectory(artifacts, mountKeys, maxTextChars, maxFrames) {
|
|
167
|
+
const sr = (artifacts.snapshot.subflowResults ?? {});
|
|
168
|
+
const runLog = (artifacts.snapshot.commitLog ?? []);
|
|
169
|
+
// Run-level prelude: commits before the first sf-llm-call mount (seed / memory-read setup).
|
|
170
|
+
const firstMountRunIdx = runLog.findIndex((b) => b.runtimeStageId === mountKeys[0]);
|
|
171
|
+
const prelude = firstMountRunIdx > 0 ? runLog.slice(0, firstMountRunIdx).map((b) => b.runtimeStageId) : [];
|
|
172
|
+
const kept = maxFrames !== undefined ? mountKeys.slice(0, maxFrames) : mountKeys;
|
|
173
|
+
const truncated = maxFrames !== undefined && mountKeys.length > maxFrames;
|
|
174
|
+
const frames = kept.map((key, loopIndex) => {
|
|
175
|
+
const innerLog = (sr[key]?.treeContext?.history ?? []);
|
|
176
|
+
const innerReadsOf = buildReadsOf(sr[key]?.treeContext?.stageContexts);
|
|
177
|
+
const innerLastIdxOf = new Map();
|
|
178
|
+
for (let i = 0; i < innerLog.length; i++)
|
|
179
|
+
innerLastIdxOf.set(innerLog[i].runtimeStageId, i);
|
|
180
|
+
const bodyIds = innerLog.map((b) => b.runtimeStageId);
|
|
181
|
+
return projectFrame(loopIndex, innerLog, innerLastIdxOf, innerReadsOf, 0, bodyIds, maxTextChars, key);
|
|
182
|
+
});
|
|
183
|
+
return { frames, prelude, honestyFlags: [], ...(truncated ? { truncated: { byFrames: true } } : {}) };
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Slice a recorded agent run into a {@link Trajectory} — one {@link LoopFrame} per ReAct
|
|
187
|
+
* iteration, each carrying its `call-llm` pointer, the call's output text, and the live
|
|
188
|
+
* {@link ContextSource}s that fed it (traced via `findLastWriter` + `commitValueAt` from the
|
|
189
|
+
* SAME commit log — zero new capture).
|
|
190
|
+
*
|
|
191
|
+
* Takes the SAME `ContextBugArtifacts` bag the localizer takes — adopter call is just
|
|
192
|
+
* `assembleTrajectory(artifacts)`.
|
|
193
|
+
*
|
|
194
|
+
* Handles BOTH chart shapes:
|
|
195
|
+
* - FLAT (`reactMode: 'dynamic'`, default): `call-llm` is a parent-level stage; frames are
|
|
196
|
+
* bucketed over the run commit log by the `sf-injection-engine` loop heads.
|
|
197
|
+
* - GROUPED (`reactMode: 'dynamic-grouped'`): the LLM turn runs in an `sf-llm-call` subflow;
|
|
198
|
+
* each loop is projected PER-SCOPE over its own inner commit log (retained per-iteration by
|
|
199
|
+
* footprintjs subflow-commit-visibility). Such frames carry `subflowScope` and their array
|
|
200
|
+
* indices are inner-log-relative.
|
|
201
|
+
*
|
|
202
|
+
* Standing caveat on every result: contextSources show only sources re-committed to tracked
|
|
203
|
+
* state; context the model retained internally (carried in its own reasoning, never
|
|
204
|
+
* re-committed) leaves no read→write edge and is NOT represented.
|
|
205
|
+
*/
|
|
206
|
+
function assembleTrajectory(artifacts, opts = {}) {
|
|
207
|
+
const maxTextChars = opts.maxTextChars ?? types_js_1.CONTEXT_BISECT_DEFAULTS.maxTextChars;
|
|
208
|
+
// Grouped agent ⟺ the LLM turn is wrapped in sf-llm-call (its mounts appear in subflowResults).
|
|
209
|
+
const mountKeys = llmCallMountKeys((artifacts.snapshot.subflowResults ?? {}));
|
|
210
|
+
if (mountKeys.length > 0) {
|
|
211
|
+
return assembleGroupedTrajectory(artifacts, mountKeys, maxTextChars, opts.maxFrames);
|
|
212
|
+
}
|
|
213
|
+
// FLAT path: project over the run commit log, bucketed by injection-engine loop heads.
|
|
214
|
+
const commitLog = (artifacts.snapshot.commitLog ?? []);
|
|
215
|
+
const lastIdxOf = new Map();
|
|
216
|
+
for (let i = 0; i < commitLog.length; i++)
|
|
217
|
+
lastIdxOf.set(commitLog[i].runtimeStageId, i);
|
|
218
|
+
const readsOf = buildReadsOf(artifacts.snapshot.executionTree);
|
|
219
|
+
const heads = findLoopHeads(commitLog);
|
|
220
|
+
const { frames: buckets, prelude } = bucketByAnchors(commitLog, heads);
|
|
221
|
+
const kept = opts.maxFrames !== undefined ? buckets.slice(0, opts.maxFrames) : buckets;
|
|
222
|
+
const truncated = opts.maxFrames !== undefined && buckets.length > opts.maxFrames;
|
|
223
|
+
const frames = kept.map((bucket, loopIndex) => projectFrame(loopIndex, commitLog, lastIdxOf, readsOf, bucket.headArrayIdx, bucket.bodyIds, maxTextChars));
|
|
224
|
+
return { frames, prelude, honestyFlags: [], ...(truncated ? { truncated: { byFrames: true } } : {}) };
|
|
225
|
+
}
|
|
226
|
+
exports.assembleTrajectory = assembleTrajectory;
|
|
227
|
+
//# sourceMappingURL=trajectory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trajectory.js","sourceRoot":"","sources":["../../../src/lib/context-bisect/trajectory.ts"],"names":[],"mappings":";;;AAyBA,6CAAqG;AAErG,yDAA8D;AAE9D,2DAAqD;AACrD,yCAAiG;AA8EjG;;;;;;;;;;;GAWG;AACH,SAAgB,eAAe,CAC7B,SAAkC,EAClC,mBAAsC;IAEtC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAC7C,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1C,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC;QACvC,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAChB,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,8DAA8D;QAClF,CAAC;IACH,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,EAAE,CAAC;IACzE,CAAC;IACD,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAA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C,YAAY,EAAE,MAAM,CAAC,OAAO,EAAE,YAAY,CAAC,CAC1G,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AACxG,CAAC;AA5BD,gDA4BC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lib/context-bisect/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lib/context-bisect/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;;;AAyZH,wEAAwE;AAE3D,QAAA,uBAAuB,GAAG;IACrC,uDAAuD;IACvD,QAAQ,EAAE,EAAE;IACZ,sDAAsD;IACtD,QAAQ,EAAE,EAAE;IACZ,0CAA0C;IAC1C,WAAW,EAAE,EAAE;IACf,4DAA4D;IAC5D,YAAY,EAAE,IAAI;IAClB,yEAAyE;IACzE,OAAO,EAAE,CAAC;IACV,mEAAmE;IACnE,aAAa,EAAE,GAAG;IAClB,mDAAmD;IACnD,SAAS,EAAE,EAAE;IACb,8DAA8D;IAC9D,WAAW,EAAE,CAAC;CACN,CAAC"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.walkTrajectory = exports.walkToRoot = exports.buildWriterFrameIndex = void 0;
|
|
4
|
+
const ablation_js_1 = require("./ablation.js");
|
|
5
|
+
const localize_js_1 = require("./localize.js");
|
|
6
|
+
const loop_recall_js_1 = require("./loop-recall.js");
|
|
7
|
+
const trajectory_js_1 = require("./trajectory.js");
|
|
8
|
+
/** Margin under which the top-2 narrowed candidates are "unseparated" (mirrors the toBacktrackTrace pattern). */
|
|
9
|
+
const UNSEPARATED_MARGIN = 0.05;
|
|
10
|
+
/**
|
|
11
|
+
* Resolve every `writerId` to the index of the frame whose `bodyIds` contains it (NOT via
|
|
12
|
+
* `parseRuntimeStageId` — that yields executionIndex, not loopIndex). A writer not in any frame
|
|
13
|
+
* (run prelude / root-seeded) maps to `undefined`. Invariant: each id lands in exactly one frame.
|
|
14
|
+
*/
|
|
15
|
+
function buildWriterFrameIndex(trajectory) {
|
|
16
|
+
const map = new Map();
|
|
17
|
+
trajectory.frames.forEach((frame, idx) => {
|
|
18
|
+
for (const id of frame.bodyIds)
|
|
19
|
+
if (!map.has(id))
|
|
20
|
+
map.set(id, idx);
|
|
21
|
+
});
|
|
22
|
+
return map;
|
|
23
|
+
}
|
|
24
|
+
exports.buildWriterFrameIndex = buildWriterFrameIndex;
|
|
25
|
+
/** Map each suspectId present in a frame to the runtimeStageId that WROTE its slot (cross-loop provenance). */
|
|
26
|
+
function writtenByOf(frame) {
|
|
27
|
+
const map = new Map();
|
|
28
|
+
for (const src of frame.contextSources) {
|
|
29
|
+
const v = src.value;
|
|
30
|
+
if (Array.isArray(v)) {
|
|
31
|
+
// injection slots: an array of records keyed by sourceId
|
|
32
|
+
for (const rec of v) {
|
|
33
|
+
const id = typeof rec.sourceId === 'string' ? rec.sourceId : undefined;
|
|
34
|
+
if (id !== undefined && !map.has(id))
|
|
35
|
+
map.set(id, src.writerId);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else if (v !== null && typeof v === 'object' && typeof v.toolName === 'string') {
|
|
39
|
+
// lastToolResult: a { toolName, result } object → the tool suspect
|
|
40
|
+
const tool = v.toolName;
|
|
41
|
+
if (!map.has(tool))
|
|
42
|
+
map.set(tool, src.writerId);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return map;
|
|
46
|
+
}
|
|
47
|
+
/** A minimal Suspect for ablationForSuspect (only kind + detail identity are read). */
|
|
48
|
+
function suspectFor(suspectId, kind) {
|
|
49
|
+
const detail = kind === 'tool' ? { toolName: suspectId } : { injectionId: suspectId };
|
|
50
|
+
return {
|
|
51
|
+
source: suspectId, stageName: suspectId, kind, detail,
|
|
52
|
+
score: 0, structuralScore: 0, hasContentEvidence: false, edgePath: [],
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Walk backward from the symptom to the root context source — from a recorded run.
|
|
57
|
+
* Thin wrapper: `assembleTrajectory` then {@link walkTrajectory}. See module docs for the honesty model.
|
|
58
|
+
*/
|
|
59
|
+
async function walkToRoot(artifacts, opts) {
|
|
60
|
+
return walkTrajectory((0, trajectory_js_1.assembleTrajectory)(artifacts), opts);
|
|
61
|
+
}
|
|
62
|
+
exports.walkToRoot = walkToRoot;
|
|
63
|
+
/**
|
|
64
|
+
* The walk itself, over an already-assembled {@link Trajectory} (composable + directly testable).
|
|
65
|
+
* FLAT charts only for the cross-loop hop; grouped charts degrade (within-loop) with a flag.
|
|
66
|
+
*/
|
|
67
|
+
async function walkTrajectory(trajectory, opts) {
|
|
68
|
+
const beamK = opts.beamK ?? 2;
|
|
69
|
+
const maxHops = opts.maxHops ?? 8;
|
|
70
|
+
const maxAblations = opts.maxAblations ?? 24;
|
|
71
|
+
const classify = opts.classifier ?? localize_js_1.defaultSuspectClassifier;
|
|
72
|
+
const honestyFlags = [...trajectory.honestyFlags];
|
|
73
|
+
const grouped = trajectory.frames.some((f) => f.subflowScope !== undefined);
|
|
74
|
+
if (grouped) {
|
|
75
|
+
honestyFlags.push({
|
|
76
|
+
flag: 'untracked-sources',
|
|
77
|
+
note: 'cross-loop hop unavailable for the grouped chart — loop frames are scope-isolated; the walk degrades to within one loop.',
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const writerFrame = buildWriterFrameIndex(trajectory);
|
|
81
|
+
// Baseline stability (the un-ablated scenario must reproduce for any ablation verdict to be trusted).
|
|
82
|
+
let baselineStable = true;
|
|
83
|
+
let ablationsUsed = 0;
|
|
84
|
+
if (opts.rerun) {
|
|
85
|
+
const baseline = await (0, ablation_js_1.runAblationProbe)({ embedder: opts.embedder, rerun: opts.rerun }, []);
|
|
86
|
+
ablationsUsed++;
|
|
87
|
+
baselineStable = !(0, ablation_js_1.probeFlipped)(baseline);
|
|
88
|
+
}
|
|
89
|
+
const hops = [];
|
|
90
|
+
const visited = new Set();
|
|
91
|
+
let frameIdx = trajectory.frames.length - 1; // start at the symptom (final loop)
|
|
92
|
+
let byHops = false;
|
|
93
|
+
let byAblations = false;
|
|
94
|
+
while (frameIdx >= 0) {
|
|
95
|
+
if (hops.length >= maxHops) {
|
|
96
|
+
byHops = true;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
const frame = trajectory.frames[frameIdx];
|
|
100
|
+
// NARROW: rank THIS loop's suspects by per-loop influence (single-frame sub-trajectory).
|
|
101
|
+
const sub = { frames: [frame], prelude: [], honestyFlags: [] };
|
|
102
|
+
const shortlist = await (0, loop_recall_js_1.shortlistEarlyCulprits)(sub, {
|
|
103
|
+
embedder: opts.embedder,
|
|
104
|
+
...(opts.recencyDecay !== undefined ? { recencyDecay: opts.recencyDecay } : {}),
|
|
105
|
+
...(opts.k !== undefined ? { k: opts.k } : {}),
|
|
106
|
+
...(opts.signal ? { signal: opts.signal } : {}),
|
|
107
|
+
classifier: classify,
|
|
108
|
+
});
|
|
109
|
+
const beam = shortlist.candidates.slice(0, beamK);
|
|
110
|
+
if (beam.length === 0)
|
|
111
|
+
break;
|
|
112
|
+
const writtenBy = writtenByOf(frame);
|
|
113
|
+
const unseparated = beam.length >= 2 && Math.abs(beam[0].recallScore - beam[1].recallScore) < UNSEPARATED_MARGIN;
|
|
114
|
+
// ISOLATE: run-wide ablation of each beam candidate; ablation is the only discriminator.
|
|
115
|
+
let chosen = beam[0];
|
|
116
|
+
let chosenVerdict;
|
|
117
|
+
let convicted = false;
|
|
118
|
+
if (opts.rerun) {
|
|
119
|
+
for (const cand of beam) {
|
|
120
|
+
if (ablationsUsed >= maxAblations) {
|
|
121
|
+
byAblations = true;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
const spec = (0, ablation_js_1.ablationForSuspect)(suspectFor(cand.suspectId, cand.kind));
|
|
125
|
+
if (spec === undefined)
|
|
126
|
+
continue;
|
|
127
|
+
const stats = await (0, ablation_js_1.runAblationProbe)({ embedder: opts.embedder, rerun: opts.rerun }, [spec]);
|
|
128
|
+
ablationsUsed++;
|
|
129
|
+
const flipped = baselineStable && (0, ablation_js_1.probeFlipped)(stats);
|
|
130
|
+
if (flipped) {
|
|
131
|
+
chosen = cand;
|
|
132
|
+
chosenVerdict = (0, ablation_js_1.verdictFor)(`ablate ${cand.suspectId}`, stats, baselineStable);
|
|
133
|
+
convicted = true;
|
|
134
|
+
break; // ablation picked this hop's culprit
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const writer = writtenBy.get(chosen.suspectId);
|
|
139
|
+
const nextFrameIdx = writer !== undefined ? writerFrame.get(writer) : undefined;
|
|
140
|
+
// Cross-loop only: descend strictly backward to an unvisited earlier frame.
|
|
141
|
+
const descendIdx = nextFrameIdx !== undefined && nextFrameIdx < frameIdx ? nextFrameIdx : undefined;
|
|
142
|
+
const note = writer === undefined ? 'untracked-origin'
|
|
143
|
+
: opts.rerun && !convicted ? 'overdetermined-or-incomplete'
|
|
144
|
+
: unseparated ? 'unseparated-siblings'
|
|
145
|
+
: undefined;
|
|
146
|
+
hops.push({
|
|
147
|
+
loopIndex: frame.loopIndex,
|
|
148
|
+
suspectId: chosen.suspectId,
|
|
149
|
+
kind: chosen.kind,
|
|
150
|
+
narrowedBy: 'text-similarity',
|
|
151
|
+
...(chosenVerdict ? { verdict: chosenVerdict } : {}),
|
|
152
|
+
...(writer !== undefined ? { writtenBy: writer } : {}),
|
|
153
|
+
...(descendIdx !== undefined ? { cameFrom: trajectory.frames[descendIdx].loopIndex } : {}),
|
|
154
|
+
...(note ? { note } : {}),
|
|
155
|
+
});
|
|
156
|
+
// Stop conditions: root-seeded origin, no earlier frame, or a visited cycle.
|
|
157
|
+
const visitKey = `${chosen.suspectId}@${frame.loopIndex}`;
|
|
158
|
+
if (descendIdx === undefined || visited.has(visitKey))
|
|
159
|
+
break;
|
|
160
|
+
visited.add(visitKey);
|
|
161
|
+
frameIdx = descendIdx;
|
|
162
|
+
}
|
|
163
|
+
// root = the DEEPEST (last-walked) hop convicted by ablation.
|
|
164
|
+
let root;
|
|
165
|
+
for (const hop of hops)
|
|
166
|
+
if (hop.verdict?.verdict === 'confirmed')
|
|
167
|
+
root = hop;
|
|
168
|
+
return {
|
|
169
|
+
hops,
|
|
170
|
+
...(root ? { root } : {}),
|
|
171
|
+
honestyFlags,
|
|
172
|
+
...(byHops || byAblations ? { truncated: { byHops, byAblations } } : {}),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
exports.walkTrajectory = walkTrajectory;
|
|
176
|
+
//# sourceMappingURL=walk-to-root.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walk-to-root.js","sourceRoot":"","sources":["../../../src/lib/context-bisect/walk-to-root.ts"],"names":[],"mappings":";;;AAoCA,+CAA+F;AAC/F,+CAAiF;AACjF,qDAA0D;AAC1D,mDAAqD;AA2DrD,iHAAiH;AACjH,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAEhC;;;;GAIG;AACH,SAAgB,qBAAqB,CAAC,UAAsB;IAC1D,MAAM,GAAG,GAAG,IAAI,GAAG,EAAkB,CAAC;IACtC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACvC,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,OAAO;YAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBAAE,GAAG,CAAC,GAAG,CAAC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__esModule", { value: true });
|
|
3
|
+
exports.scoreContrastiveInfluence = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* contrastive — influence scoring against a REFERENCE output (RFC-003).
|
|
6
|
+
*
|
|
7
|
+
* Pattern: a SEPARATE, opt-in second stage over the four-signal scorer — not a
|
|
8
|
+
* modification of `scoreInfluence`. Same `InfluenceScore[]` return, so
|
|
9
|
+
* `rankingConfidence` and the rest compose on it unchanged.
|
|
10
|
+
* Role: `src/lib/influence-core/` leaf, sibling to `scoreInfluence`.
|
|
11
|
+
*
|
|
12
|
+
* ## Why this exists (the topical-innocent confound)
|
|
13
|
+
*
|
|
14
|
+
* Plain output-similarity (`scoreInfluence`'s FA) ranks a source by how much it
|
|
15
|
+
* resembles the actual answer. That is confounded by **topically-central
|
|
16
|
+
* innocents**: the policy a refund decision is *about* resembles ANY refund
|
|
17
|
+
* output — right or wrong — so it can out-rank the source that actually caused
|
|
18
|
+
* the wrong one. The fix: score by CONTRAST against a reference output (a
|
|
19
|
+
* known-good / expected / prior-good run). A topical innocent is similar to
|
|
20
|
+
* BOTH outputs, so it cancels (~0 contrast); the real culprit is similar to the
|
|
21
|
+
* WRONG output specifically, so it stands out.
|
|
22
|
+
*
|
|
23
|
+
* contrastive FA(e) = sim(e, answer) − sim(e, reference)
|
|
24
|
+
*
|
|
25
|
+
* Everything else (the AVG / PERSIST / DEPTH reasoning-trace signals, the
|
|
26
|
+
* composite, adaptive weights) is shared with `scoreInfluence` verbatim — only
|
|
27
|
+
* the FA term is contrastive.
|
|
28
|
+
*
|
|
29
|
+
* Honest claim (RFC-002 §2): still an embedding-geometry PROXY, never causal —
|
|
30
|
+
* the contrast removes a confound, it does not prove causation. Ablation is the
|
|
31
|
+
* causal tier. And it is OPT-IN: it needs a reference output, so it is for
|
|
32
|
+
* regression / eval debugging (you have a prior-good or expected output), not
|
|
33
|
+
* cold localization — without a reference, use `scoreInfluence`.
|
|
34
|
+
*/
|
|
35
|
+
const cosine_js_1 = require("../../memory/embedding/cosine.js");
|
|
36
|
+
const signals_js_1 = require("./signals.js");
|
|
37
|
+
const types_js_1 = require("./types.js");
|
|
38
|
+
/**
|
|
39
|
+
* Score evidence by CONTRASTIVE influence: `sim(e, answer) − sim(e, reference)`
|
|
40
|
+
* for the FA term, the four-signal composite otherwise. Returns `InfluenceScore[]`
|
|
41
|
+
* sorted descending — drop-in compatible with `scoreInfluence` consumers
|
|
42
|
+
* (`rankingConfidence`, etc.).
|
|
43
|
+
*
|
|
44
|
+
* @throws when an evidence id is duplicated (same contract as `scoreInfluence`).
|
|
45
|
+
*/
|
|
46
|
+
async function scoreContrastiveInfluence(args) {
|
|
47
|
+
const weights = args.weights ?? types_js_1.DEFAULT_INFLUENCE_WEIGHTS;
|
|
48
|
+
const threshold = args.persistenceThreshold ?? types_js_1.DEFAULT_PERSISTENCE_THRESHOLD;
|
|
49
|
+
assertUniqueIds(args.evidence);
|
|
50
|
+
(0, signals_js_1.assertValidWeights)(weights, 'scoreContrastiveInfluence');
|
|
51
|
+
// ONE deduplicated embedding pass over every distinct text (answer + reference
|
|
52
|
+
// + evidence + ancestors).
|
|
53
|
+
const texts = new Set([args.answerText, args.referenceText]);
|
|
54
|
+
for (const item of args.evidence) {
|
|
55
|
+
texts.add(item.text);
|
|
56
|
+
for (const ancestor of item.ancestorTexts)
|
|
57
|
+
texts.add(ancestor);
|
|
58
|
+
}
|
|
59
|
+
const vectorByText = await (0, signals_js_1.embedAll)(args.embedder, [...texts], args.signal);
|
|
60
|
+
const answerVec = vectorByText.get(args.answerText);
|
|
61
|
+
const referenceVec = vectorByText.get(args.referenceText);
|
|
62
|
+
const scored = args.evidence.map((item) => {
|
|
63
|
+
const evidenceVec = vectorByText.get(item.text);
|
|
64
|
+
const ancestorVecs = item.ancestorTexts.map((t) => vectorByText.get(t));
|
|
65
|
+
// The only contrastive term: answer-similarity MINUS reference-similarity.
|
|
66
|
+
const faContrast = (0, cosine_js_1.cosineSimilarity)(evidenceVec, answerVec) - (0, cosine_js_1.cosineSimilarity)(evidenceVec, referenceVec);
|
|
67
|
+
const signals = {
|
|
68
|
+
fa: faContrast,
|
|
69
|
+
avg: (0, signals_js_1.averageRelevancy)(evidenceVec, ancestorVecs),
|
|
70
|
+
persist: (0, signals_js_1.persistence)(evidenceVec, ancestorVecs, threshold),
|
|
71
|
+
depth: (0, signals_js_1.structuralProximity)(ancestorVecs.length),
|
|
72
|
+
};
|
|
73
|
+
const effective = (0, signals_js_1.adaptWeights)(weights, ancestorVecs.length);
|
|
74
|
+
return {
|
|
75
|
+
id: item.id,
|
|
76
|
+
signals,
|
|
77
|
+
weights: effective.weights,
|
|
78
|
+
adapted: effective.adapted,
|
|
79
|
+
score: (0, signals_js_1.compositeScore)(signals, effective.weights),
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
return scored.sort((a, b) => b.score - a.score);
|
|
83
|
+
}
|
|
84
|
+
exports.scoreContrastiveInfluence = scoreContrastiveInfluence;
|
|
85
|
+
function assertUniqueIds(evidence) {
|
|
86
|
+
const seen = new Set();
|
|
87
|
+
for (const e of evidence) {
|
|
88
|
+
if (seen.has(e.id))
|
|
89
|
+
throw new Error(`scoreContrastiveInfluence: duplicate evidence id "${e.id}"`);
|
|
90
|
+
seen.add(e.id);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=contrastive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contrastive.js","sourceRoot":"","sources":["../../../src/lib/influence-core/contrastive.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,gEAAoE;AACpE,6CAQsB;AAEtB,yCAAsF;AAmBtF;;;;;;;GAOG;AACI,KAAK,UAAU,yBAAyB,CAC7C,IAAmC;IAEnC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,oCAAyB,CAAC;IAC1D,MAAM,SAAS,GAAG,IAAI,CAAC,oBAAoB,IAAI,wCAA6B,C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pairwiseSimilarity = exports.structuralProximity = exports.scoreInfluence = exports.persistence = exports.finalAnswerSimilarity = exports.compositeScore = exports.averageRelevancy = exports.adaptWeights = exports.embeddingCache = exports.EmbeddingCache = exports.contentHash = exports.ratioStrategy = exports.rankingConfidence = exports.marginStrategy = exports.DEFAULT_SHORTLIST_BAND = exports.DEFAULT_PERSISTENCE_THRESHOLD = exports.DEFAULT_MARGIN_THRESHOLD = exports.DEFAULT_INFLUENCE_WEIGHTS = exports.DEFAULT_CLEAR_WINNER_RATIO = exports.DEFAULT_CLEAR_WINNER_MARGIN = void 0;
|
|
29
|
+
exports.scoreMargin = exports.pairwiseSimilarity = exports.structuralProximity = exports.scoreInfluence = exports.persistence = exports.finalAnswerSimilarity = exports.compositeScore = exports.averageRelevancy = exports.adaptWeights = exports.embeddingCache = exports.EmbeddingCache = exports.contentHash = exports.scoreContrastiveInfluence = exports.ratioStrategy = exports.rankingConfidence = exports.marginStrategy = exports.DEFAULT_SHORTLIST_BAND = exports.DEFAULT_PERSISTENCE_THRESHOLD = exports.DEFAULT_MARGIN_THRESHOLD = exports.DEFAULT_INFLUENCE_WEIGHTS = exports.DEFAULT_CLEAR_WINNER_RATIO = exports.DEFAULT_CLEAR_WINNER_MARGIN = void 0;
|
|
30
30
|
var types_js_1 = require("./types.js");
|
|
31
31
|
Object.defineProperty(exports, "DEFAULT_CLEAR_WINNER_MARGIN", { enumerable: true, get: function () { return types_js_1.DEFAULT_CLEAR_WINNER_MARGIN; } });
|
|
32
32
|
Object.defineProperty(exports, "DEFAULT_CLEAR_WINNER_RATIO", { enumerable: true, get: function () { return types_js_1.DEFAULT_CLEAR_WINNER_RATIO; } });
|
|
@@ -38,6 +38,8 @@ var attributability_js_1 = require("./attributability.js");
|
|
|
38
38
|
Object.defineProperty(exports, "marginStrategy", { enumerable: true, get: function () { return attributability_js_1.marginStrategy; } });
|
|
39
39
|
Object.defineProperty(exports, "rankingConfidence", { enumerable: true, get: function () { return attributability_js_1.rankingConfidence; } });
|
|
40
40
|
Object.defineProperty(exports, "ratioStrategy", { enumerable: true, get: function () { return attributability_js_1.ratioStrategy; } });
|
|
41
|
+
var contrastive_js_1 = require("./contrastive.js");
|
|
42
|
+
Object.defineProperty(exports, "scoreContrastiveInfluence", { enumerable: true, get: function () { return contrastive_js_1.scoreContrastiveInfluence; } });
|
|
41
43
|
var cache_js_1 = require("./cache.js");
|
|
42
44
|
Object.defineProperty(exports, "contentHash", { enumerable: true, get: function () { return cache_js_1.contentHash; } });
|
|
43
45
|
Object.defineProperty(exports, "EmbeddingCache", { enumerable: true, get: function () { return cache_js_1.EmbeddingCache; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/influence-core/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AAmBH,uCAOoB;AANlB,uHAAA,2BAA2B,OAAA;AAC3B,sHAAA,0BAA0B,OAAA;AAC1B,qHAAA,yBAAyB,OAAA;AACzB,oHAAA,wBAAwB,OAAA;AACxB,yHAAA,6BAA6B,OAAA;AAC7B,kHAAA,sBAAsB,OAAA;AAGxB,2DAK8B;AAJ5B,oHAAA,cAAc,OAAA;AACd,uHAAA,iBAAiB,OAAA;AACjB,mHAAA,aAAa,OAAA;AAIf,uCAMoB;AALlB,uGAAA,WAAW,OAAA;AACX,0GAAA,cAAc,OAAA;AACd,0GAAA,cAAc,OAAA;AAKhB,2CASsB;AARpB,0GAAA,YAAY,OAAA;AACZ,8GAAA,gBAAgB,OAAA;AAChB,4GAAA,cAAc,OAAA;AACd,mHAAA,qBAAqB,OAAA;AACrB,yGAAA,WAAW,OAAA;AACX,4GAAA,cAAc,OAAA;AACd,iHAAA,mBAAmB,OAAA;AAIrB,iDAAkF;AAAzE,mHAAA,kBAAkB,OAAA;AAE3B,yCAAgE;AAAvD,wGAAA,WAAW,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/influence-core/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AAmBH,uCAOoB;AANlB,uHAAA,2BAA2B,OAAA;AAC3B,sHAAA,0BAA0B,OAAA;AAC1B,qHAAA,yBAAyB,OAAA;AACzB,oHAAA,wBAAwB,OAAA;AACxB,yHAAA,6BAA6B,OAAA;AAC7B,kHAAA,sBAAsB,OAAA;AAGxB,2DAK8B;AAJ5B,oHAAA,cAAc,OAAA;AACd,uHAAA,iBAAiB,OAAA;AACjB,mHAAA,aAAa,OAAA;AAIf,mDAAiG;AAAxF,2HAAA,yBAAyB,OAAA;AAElC,uCAMoB;AALlB,uGAAA,WAAW,OAAA;AACX,0GAAA,cAAc,OAAA;AACd,0GAAA,cAAc,OAAA;AAKhB,2CASsB;AARpB,0GAAA,YAAY,OAAA;AACZ,8GAAA,gBAAgB,OAAA;AAChB,4GAAA,cAAc,OAAA;AACd,mHAAA,qBAAqB,OAAA;AACrB,yGAAA,WAAW,OAAA;AACX,4GAAA,cAAc,OAAA;AACd,iHAAA,mBAAmB,OAAA;AAIrB,iDAAkF;AAAzE,mHAAA,kBAAkB,OAAA;AAE3B,yCAAgE;AAAvD,wGAAA,WAAW,OAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.scoreInfluence = exports.compositeScore = exports.adaptWeights = exports.structuralProximity = exports.persistence = exports.averageRelevancy = exports.finalAnswerSimilarity = void 0;
|
|
3
|
+
exports.assertValidWeights = exports.embedAll = exports.scoreInfluence = exports.compositeScore = exports.adaptWeights = exports.structuralProximity = exports.persistence = exports.averageRelevancy = exports.finalAnswerSimilarity = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* FDL influence signals — the four-signal composite from the Visible
|
|
6
6
|
* Reasoning paper (Eq. 1–6), extracted verbatim as RFC-003 block D6.
|
|
@@ -213,6 +213,7 @@ async function embedAll(embedder, texts, signal) {
|
|
|
213
213
|
byText.set(texts[i], vectors[i]);
|
|
214
214
|
return byText;
|
|
215
215
|
}
|
|
216
|
+
exports.embedAll = embedAll;
|
|
216
217
|
async function sequentialEmbed(embedder, texts, signal) {
|
|
217
218
|
const out = [];
|
|
218
219
|
for (const text of texts) {
|
|
@@ -220,16 +221,22 @@ async function sequentialEmbed(embedder, texts, signal) {
|
|
|
220
221
|
}
|
|
221
222
|
return out;
|
|
222
223
|
}
|
|
223
|
-
|
|
224
|
+
/**
|
|
225
|
+
* Validate composite weights: every weight finite & non-negative, and not all
|
|
226
|
+
* zero. Shared by `scoreInfluence` and `scoreContrastiveInfluence` — `fnName`
|
|
227
|
+
* attributes the error to the actual caller.
|
|
228
|
+
*/
|
|
229
|
+
function assertValidWeights(weights, fnName = 'scoreInfluence') {
|
|
224
230
|
for (const [name, value] of Object.entries(weights)) {
|
|
225
231
|
if (!Number.isFinite(value) || value < 0) {
|
|
226
|
-
throw new Error(
|
|
232
|
+
throw new Error(`${fnName}: weight '${name}' must be a finite non-negative number (got ${value})`);
|
|
227
233
|
}
|
|
228
234
|
}
|
|
229
235
|
if (weights.fa + weights.avg + weights.persist + weights.depth === 0) {
|
|
230
|
-
throw new Error(
|
|
236
|
+
throw new Error(`${fnName}: all weights are zero — the composite would always be 0`);
|
|
231
237
|
}
|
|
232
238
|
}
|
|
239
|
+
exports.assertValidWeights = assertValidWeights;
|
|
233
240
|
function assertUniqueIds(evidence) {
|
|
234
241
|
const seen = new Set();
|
|
235
242
|
for (const item of evidence) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signals.js","sourceRoot":"","sources":["../../../src/lib/influence-core/signals.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,gEAAoE;AAQpE,yCAAsF;AAEtF;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CACnC,WAA8B,EAC9B,cAAiC;IAEjC,OAAO,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