agentfootprint 7.11.0 → 7.12.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/core/Agent.js +13 -2
- package/dist/core/Agent.js.map +1 -1
- package/dist/debug.js +5 -2
- package/dist/debug.js.map +1 -1
- package/dist/esm/core/Agent.d.ts +6 -2
- package/dist/esm/core/Agent.js +13 -2
- package/dist/esm/core/Agent.js.map +1 -1
- package/dist/esm/core/agent/types.d.ts +25 -1
- package/dist/esm/debug.d.ts +2 -2
- package/dist/esm/debug.js +2 -2
- package/dist/esm/debug.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/context-bisect/index.d.ts +3 -1
- package/dist/esm/lib/context-bisect/index.js +5 -0
- package/dist/esm/lib/context-bisect/index.js.map +1 -1
- package/dist/esm/lib/context-bisect/trajectory.d.ts +8 -0
- package/dist/esm/lib/context-bisect/trajectory.js +10 -3
- package/dist/esm/lib/context-bisect/trajectory.js.map +1 -1
- package/dist/esm/lib/context-bisect/variable-recall.d.ts +171 -0
- package/dist/esm/lib/context-bisect/variable-recall.js +0 -0
- package/dist/esm/lib/context-bisect/variable-recall.js.map +1 -0
- package/dist/esm/lib/context-bisect/variableToBacktrackTrace.d.ts +53 -0
- package/dist/esm/lib/context-bisect/variableToBacktrackTrace.js +142 -0
- package/dist/esm/lib/context-bisect/variableToBacktrackTrace.js.map +1 -0
- package/dist/esm/lib/context-bisect/walk-to-root.d.ts +37 -2
- package/dist/esm/lib/context-bisect/walk-to-root.js +61 -6
- package/dist/esm/lib/context-bisect/walk-to-root.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/context-bisect/index.js +9 -1
- package/dist/lib/context-bisect/index.js.map +1 -1
- package/dist/lib/context-bisect/trajectory.js +10 -3
- package/dist/lib/context-bisect/trajectory.js.map +1 -1
- package/dist/lib/context-bisect/variable-recall.js +0 -0
- package/dist/lib/context-bisect/variable-recall.js.map +1 -0
- package/dist/lib/context-bisect/variableToBacktrackTrace.js +146 -0
- package/dist/lib/context-bisect/variableToBacktrackTrace.js.map +1 -0
- package/dist/lib/context-bisect/walk-to-root.js +61 -6
- package/dist/lib/context-bisect/walk-to-root.js.map +1 -1
- package/dist/types/core/Agent.d.ts +6 -2
- package/dist/types/core/Agent.d.ts.map +1 -1
- package/dist/types/core/agent/types.d.ts +25 -1
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/debug.d.ts +2 -2
- package/dist/types/debug.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/index.d.ts +3 -1
- package/dist/types/lib/context-bisect/index.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/trajectory.d.ts +8 -0
- package/dist/types/lib/context-bisect/trajectory.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/variable-recall.d.ts +172 -0
- package/dist/types/lib/context-bisect/variable-recall.d.ts.map +1 -0
- package/dist/types/lib/context-bisect/variableToBacktrackTrace.d.ts +54 -0
- package/dist/types/lib/context-bisect/variableToBacktrackTrace.d.ts.map +1 -0
- package/dist/types/lib/context-bisect/walk-to-root.d.ts +37 -2
- package/dist/types/lib/context-bisect/walk-to-root.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trajectory.js","sourceRoot":"","sources":["../../../../src/lib/context-bisect/trajectory.ts"],"names":[],"mappings":"AAyBA,OAAO,EACL,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,YAAY,GACb,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE9D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAA8C,MAAM,YAAY,CAAC;AA+FjG;;;;;;;;;;;GAWG;AACH,MAAM,U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AC,MAAM,EAAE,SAAS,EAAE,EAAE,CACzD,YAAY,CACV,SAAS,EACT,SAAS,EACT,SAAS,EACT,OAAO,EACP,MAAM,CAAC,YAAY,EACnB,MAAM,CAAC,OAAO,EACd,YAAY,CACb,CACF,CAAC;IAEF,OAAO;QACL,MAAM;QACN,OAAO;QACP,YAAY,EAAE,EAAE;QAChB,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACxD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* variable-recall — footprintjs's VARIABLE slices, joined to agent vocabulary.
|
|
3
|
+
*
|
|
4
|
+
* footprintjs answers "what happened to this variable?" in the address space it
|
|
5
|
+
* owns: commit indices, runtimeStageIds, state keys (`keyTimeline` /
|
|
6
|
+
* `forwardSliceForKey`, `footprintjs/trace`). An agent debugger asks the same
|
|
7
|
+
* question in a DIFFERENT vocabulary: which LOOP was that, which injected fact
|
|
8
|
+
* or tool result is that write, and what would REMOVING it cost. This module is
|
|
9
|
+
* the join between the two — and nothing more:
|
|
10
|
+
*
|
|
11
|
+
* - **Pure assembly.** Every fact here was already recorded. No new capture,
|
|
12
|
+
* no new scorer, no embedder, no LLM. `joinVariableSlice` re-labels; it
|
|
13
|
+
* never measures.
|
|
14
|
+
* - **Loop lifting.** Each moment gets the `loopIndex` of the frame that
|
|
15
|
+
* contains its `runtimeStageId` (the walk's own `buildWriterFrameIndex` —
|
|
16
|
+
* one resolver, not two).
|
|
17
|
+
* - **Agent identity.** A WRITE whose value the trajectory carries is run
|
|
18
|
+
* through the SAME `defaultSuspectClassifier` the localizer uses, so a
|
|
19
|
+
* write joins 1:1 with a `Suspect` (`injectionId` / `toolName`) and gets
|
|
20
|
+
* the `AblationSpec` that would remove it. Writers the classifier cannot
|
|
21
|
+
* name get NO hook — an honest absence, never a fabricated one.
|
|
22
|
+
* - **Honesty rides along verbatim.** footprintjs's `HonestyNote`s, the
|
|
23
|
+
* missing-reason, and `readsCoverage` are copied, not re-worded.
|
|
24
|
+
*
|
|
25
|
+
* The one JUDGEMENT this module makes is {@link DataflowCoverage} — see the
|
|
26
|
+
* long comment on `dataflowCoverage()`. It is what lets `walkToRoot` replace a
|
|
27
|
+
* text-similarity guess with a recorded dataflow edge, and it is deliberately
|
|
28
|
+
* strict.
|
|
29
|
+
*
|
|
30
|
+
* @beta Beta feature (RFC-003 Part B). The API works and is tested, but may
|
|
31
|
+
* change before GA.
|
|
32
|
+
*/
|
|
33
|
+
import type { ForwardSlice, HonestyNote, KeyMoment, KeyTimeline, MissingSliceReason, ReadsCoverage, StateKey } from 'footprintjs/trace';
|
|
34
|
+
import { type SuspectClassifier } from './localize.js';
|
|
35
|
+
import { type Trajectory } from './trajectory.js';
|
|
36
|
+
import type { AblationSpec, ContextBugArtifacts, SuspectKind } from './types.js';
|
|
37
|
+
/**
|
|
38
|
+
* How exactly this log records what a key's value FED — the one judgement in
|
|
39
|
+
* this module, and the gate on `walkToRoot`'s deterministic hop.
|
|
40
|
+
*
|
|
41
|
+
* - `'exact'` — every recorded `fed` edge for this key carries per-write
|
|
42
|
+
* provenance (`FedBasis: 'per-write'`, the `writeProvenance: 'reads-prefix'`
|
|
43
|
+
* dial): a downstream write is linked to this value BECAUSE that write's
|
|
44
|
+
* recorded read-prefix names the key, and a write whose prefix omits it is
|
|
45
|
+
* excluded exactly.
|
|
46
|
+
* - `'conservative'` — at least one edge is stage-level co-occurrence
|
|
47
|
+
* (`'conservative-fed-edges'`), or the log carries no recorded reads at all.
|
|
48
|
+
* Sound over-approximation; NEVER presented as exact.
|
|
49
|
+
* - `'unknown'` — no forward slice was supplied, OR the key has no recorded
|
|
50
|
+
* `fed` edge at all. The second case is the trap: with zero edges there is
|
|
51
|
+
* also zero conservative edge, so "no conservative edges" would be VACUOUSLY
|
|
52
|
+
* true and a key nothing ever read would masquerade as the most exact key in
|
|
53
|
+
* the run. It is demoted here instead.
|
|
54
|
+
*/
|
|
55
|
+
export type DataflowCoverage = 'exact' | 'conservative' | 'unknown';
|
|
56
|
+
/**
|
|
57
|
+
* One moment in a key's life ({@link KeyMoment}), lifted into agent vocabulary.
|
|
58
|
+
* The footprintjs fields are carried through UNCHANGED — this type only ADDS.
|
|
59
|
+
*/
|
|
60
|
+
export interface AgentKeyMoment {
|
|
61
|
+
readonly kind: 'write' | 'read';
|
|
62
|
+
/** Commit ARRAY position — the write's own, or the READING stage's. */
|
|
63
|
+
readonly commitIdx: number;
|
|
64
|
+
readonly runtimeStageId: string;
|
|
65
|
+
readonly stageId: string;
|
|
66
|
+
readonly stageName: string;
|
|
67
|
+
/** `'write'` moments only: the trace verb. */
|
|
68
|
+
readonly verb?: KeyMoment['verb'];
|
|
69
|
+
/** `'read'` moments only: the commitIdx of the write whose value it saw. */
|
|
70
|
+
readonly fromWriteIdx?: number;
|
|
71
|
+
/**
|
|
72
|
+
* The ReAct loop this moment happened in. ABSENT when the step is not in any
|
|
73
|
+
* frame (run prelude, root-seeded setup) — absence is information, not a gap.
|
|
74
|
+
*/
|
|
75
|
+
readonly loopIndex?: number;
|
|
76
|
+
/**
|
|
77
|
+
* `'write'` moments the classifier recognized: what KIND of agent source this
|
|
78
|
+
* write produced. When one write produced several sources (an injection slot
|
|
79
|
+
* commits an array of records), this is the FIRST one's kind and
|
|
80
|
+
* {@link AgentVariableSlice.ablations} carries them all.
|
|
81
|
+
*/
|
|
82
|
+
readonly suspectKind?: SuspectKind;
|
|
83
|
+
/** The suspect identity (`injectionId` / `toolName`) — joins a `Suspect` 1:1. */
|
|
84
|
+
readonly suspectId?: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The counterfactual attached to one classifiable WRITE: "to test this write,
|
|
88
|
+
* re-run without this source". A HOOK, not a verdict — running it is the
|
|
89
|
+
* consumer's `AblationRunner` (§B2: only ablation verdicts are causal claims).
|
|
90
|
+
*/
|
|
91
|
+
export interface VariableAblationHook {
|
|
92
|
+
/** runtimeStageId of the write that introduced the source. */
|
|
93
|
+
readonly writerId: string;
|
|
94
|
+
/** `injectionId` / `toolName` — the localizer's suspect identity. */
|
|
95
|
+
readonly suspectId: string;
|
|
96
|
+
readonly kind: SuspectKind;
|
|
97
|
+
/** What to remove for the counterfactual re-run. */
|
|
98
|
+
readonly spec: AblationSpec;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* One variable's recorded life, in agent vocabulary — the artifact BOTH a human
|
|
102
|
+
* board ({@link variableToBacktrackTrace}) and the walk read.
|
|
103
|
+
*
|
|
104
|
+
* JSON-safe by construction (flat moments, no graph, no live references): the
|
|
105
|
+
* same object can be persisted, sent over the wire, or handed to an LLM tool.
|
|
106
|
+
*/
|
|
107
|
+
export interface AgentVariableSlice {
|
|
108
|
+
/** The state key asked about (footprintjs's normalised string form). */
|
|
109
|
+
readonly key: string;
|
|
110
|
+
/** Writes and reads in commit order. EMPTY when `missing`. */
|
|
111
|
+
readonly moments: readonly AgentKeyMoment[];
|
|
112
|
+
/** Present ONLY when there are no moments — footprintjs's honest absence. */
|
|
113
|
+
readonly missing?: MissingSliceReason;
|
|
114
|
+
/** How exactly this log records what the value fed — see {@link DataflowCoverage}. */
|
|
115
|
+
readonly coverage: DataflowCoverage;
|
|
116
|
+
/** One per classifiable write — see {@link VariableAblationHook}. */
|
|
117
|
+
readonly ablations: readonly VariableAblationHook[];
|
|
118
|
+
/** footprintjs's honesty notes, VERBATIM (both doors' notes, de-duplicated). */
|
|
119
|
+
readonly notes: readonly HonestyNote[];
|
|
120
|
+
/** Which `KeysReadSource` strategy resolved reads (honesty/debug). */
|
|
121
|
+
readonly keysReadKind: string;
|
|
122
|
+
/** Reads telemetry — `stepsWithReads === 0` means reads were not recorded. */
|
|
123
|
+
readonly readsCoverage?: ReadsCoverage;
|
|
124
|
+
}
|
|
125
|
+
export interface JoinVariableSliceOptions {
|
|
126
|
+
/**
|
|
127
|
+
* The FORWARD slice of the same key (`forwardSliceForKey`) — the ONLY carrier
|
|
128
|
+
* of per-edge exactness (`ForwardEdge.basis`). Without it `coverage` is
|
|
129
|
+
* `'unknown'` and the walk will not take a dataflow hop.
|
|
130
|
+
*/
|
|
131
|
+
readonly forward?: ForwardSlice;
|
|
132
|
+
/** Override the suspect classifier (default `defaultSuspectClassifier`). */
|
|
133
|
+
readonly classify?: SuspectClassifier;
|
|
134
|
+
}
|
|
135
|
+
export interface TraceVariableOptions extends JoinVariableSliceOptions {
|
|
136
|
+
/** Reuse an already-assembled trajectory (avoids re-slicing the run). */
|
|
137
|
+
readonly trajectory?: Trajectory;
|
|
138
|
+
/** Exclusive commit-array-index bound — the variable as it stood BEFORE this idx. */
|
|
139
|
+
readonly before?: number;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Join a footprintjs variable slice to the agent's loops and sources.
|
|
143
|
+
*
|
|
144
|
+
* @param slice A `keyTimeline(...)` result — the flat, JSON-safe life of one
|
|
145
|
+
* key. (Chosen over the backward `sliceForKey` deliberately: the walk needs
|
|
146
|
+
* moments in commit order, and a timeline cannot be mistaken for a DAG.)
|
|
147
|
+
* @param trajectory `assembleTrajectory(artifacts)` — supplies loop frames AND
|
|
148
|
+
* the committed values used for classification.
|
|
149
|
+
* @param opts `forward` (the exactness carrier) and `classify`.
|
|
150
|
+
*
|
|
151
|
+
* Nothing here is measured: every field is a re-label of something already
|
|
152
|
+
* recorded. See the module doc.
|
|
153
|
+
*/
|
|
154
|
+
export declare function joinVariableSlice(slice: KeyTimeline, trajectory: Trajectory, opts?: JoinVariableSliceOptions): AgentVariableSlice;
|
|
155
|
+
/**
|
|
156
|
+
* One call, from a recorded run to a variable's joined life: `keyTimeline` +
|
|
157
|
+
* `forwardSliceForKey` + `assembleTrajectory` + {@link joinVariableSlice}.
|
|
158
|
+
*
|
|
159
|
+
* Reads come from the snapshot's execution tree (zero setup, `readTracking` ≠
|
|
160
|
+
* `'off'`); exactness comes from the run's `writeProvenance` dial. Both facts
|
|
161
|
+
* ride out on the result (`readsCoverage`, `coverage`) rather than being
|
|
162
|
+
* assumed.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```ts
|
|
166
|
+
* const life = traceVariable({ snapshot }, 'systemPromptInjections');
|
|
167
|
+
* life.coverage; // 'exact' | 'conservative' | 'unknown'
|
|
168
|
+
* life.moments.filter((m) => m.kind === 'write').map((m) => m.loopIndex);
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
export declare function traceVariable(artifacts: ContextBugArtifacts, key: StateKey, opts?: TraceVariableOptions): AgentVariableSlice;
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variable-recall.js","sourceRoot":"","sources":["../../../../src/lib/context-bisect/variable-recall.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,yBAAyB,EACzB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAa3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EACL,wBAAwB,GAGzB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAmB,MAAM,iBAAiB,CAAC;AAEtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAkH1D,wEAAwE;AAExE,2EAA2E;AAC3E,SAAS,QAAQ,CAAC,IAA6B;IAC7C,MAAM,KAAK,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC9C,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACrC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAe,CAAC;IACpC,MAAM,KAAK,GAAkB,CAAC,IAAI,CAAC,CAAC;IACpC,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,GAAG,KAA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,iBAAiB,CACtB,WAAW,CAAC,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,EACzC,IAAI,CAAC,UAAU,IAAI,kBAAkB,CAAC,SAAS,CAAC,EAChD;QACE,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,kBAAkB,CAAC,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC;QACzE,GAAG,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;KAChE,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* variableToBacktrackTrace — serialize a JOINED VARIABLE LIFE
|
|
3
|
+
* ({@link AgentVariableSlice}, from `traceVariable` / `joinVariableSlice`) onto
|
|
4
|
+
* the same BacktrackTrace board agentThinkingUI's <BacktrackView> renders.
|
|
5
|
+
*
|
|
6
|
+
* The third sibling of that board, and the most literal one:
|
|
7
|
+
* - `toBacktrackTrace` — a LOCALIZER REPORT (scored suspects, ablation
|
|
8
|
+
* verdicts): proxy ranking, causal stamps.
|
|
9
|
+
* - `sliceToBacktrackTrace` — a footprintjs DEPENDENCY SLICE: exact
|
|
10
|
+
* structure, no influence claims.
|
|
11
|
+
* - THIS ONE — one variable's recorded LIFE: every write and every read, in
|
|
12
|
+
* commit order, labeled with the loop it happened in and the agent source
|
|
13
|
+
* it introduced.
|
|
14
|
+
*
|
|
15
|
+
* Same board, honestly weakest chips:
|
|
16
|
+
* - `mode` is ALWAYS `'correlational'`. Nothing here was ablated — the join
|
|
17
|
+
* measures nothing — so the causal chip is unreachable by construction.
|
|
18
|
+
* - every card is `upperBound: true`: the score is `1/(1+age)` over write
|
|
19
|
+
* recency, a deterministic LAYOUT AID, not evidence of anything.
|
|
20
|
+
* - the claims lines say out loud that these moments are STRUCTURAL FACTS —
|
|
21
|
+
* recorded reads and writes — so a reader can tell this board apart from an
|
|
22
|
+
* influence board at a glance.
|
|
23
|
+
* - footprintjs's honesty notes ride along verbatim, and honest ABSENCE
|
|
24
|
+
* renders an empty board that says why, never a fabricated suspect.
|
|
25
|
+
*
|
|
26
|
+
* Pure mapping, no UI dependency, framework-agnostic JSON on both sides — the
|
|
27
|
+
* human and the LLM triage the SAME artifact.
|
|
28
|
+
*/
|
|
29
|
+
import type { BacktrackTrace } from './toBacktrackTrace.js';
|
|
30
|
+
import type { AgentVariableSlice } from './variable-recall.js';
|
|
31
|
+
export interface VariableToBacktrackTraceOptions {
|
|
32
|
+
/** The visible outcome being questioned (the board's answer bubble). */
|
|
33
|
+
readonly answer: {
|
|
34
|
+
readonly text: string;
|
|
35
|
+
readonly label?: string;
|
|
36
|
+
readonly tone?: 'error' | 'question';
|
|
37
|
+
};
|
|
38
|
+
/** Headline question. Default: `What happened to '<key>'?`. */
|
|
39
|
+
readonly claim?: string;
|
|
40
|
+
/** How the latest writer renders: rule diamond or LLM brain. Default 'rule'. */
|
|
41
|
+
readonly decidedAtKind?: 'llm' | 'rule';
|
|
42
|
+
/** Override the mode chip label. */
|
|
43
|
+
readonly modeLabel?: string;
|
|
44
|
+
readonly agent?: string;
|
|
45
|
+
readonly model?: string;
|
|
46
|
+
/** Max suspect cards (one per write). Default 6. The rest fold into one line. */
|
|
47
|
+
readonly maxSuspects?: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Serialize a joined variable life for agentThinkingUI's BacktrackView.
|
|
51
|
+
* See the module doc — structural honesty is the whole design.
|
|
52
|
+
*/
|
|
53
|
+
export declare function variableToBacktrackTrace(agentSlice: AgentVariableSlice, opts: VariableToBacktrackTraceOptions): BacktrackTrace;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* variableToBacktrackTrace — serialize a JOINED VARIABLE LIFE
|
|
3
|
+
* ({@link AgentVariableSlice}, from `traceVariable` / `joinVariableSlice`) onto
|
|
4
|
+
* the same BacktrackTrace board agentThinkingUI's <BacktrackView> renders.
|
|
5
|
+
*
|
|
6
|
+
* The third sibling of that board, and the most literal one:
|
|
7
|
+
* - `toBacktrackTrace` — a LOCALIZER REPORT (scored suspects, ablation
|
|
8
|
+
* verdicts): proxy ranking, causal stamps.
|
|
9
|
+
* - `sliceToBacktrackTrace` — a footprintjs DEPENDENCY SLICE: exact
|
|
10
|
+
* structure, no influence claims.
|
|
11
|
+
* - THIS ONE — one variable's recorded LIFE: every write and every read, in
|
|
12
|
+
* commit order, labeled with the loop it happened in and the agent source
|
|
13
|
+
* it introduced.
|
|
14
|
+
*
|
|
15
|
+
* Same board, honestly weakest chips:
|
|
16
|
+
* - `mode` is ALWAYS `'correlational'`. Nothing here was ablated — the join
|
|
17
|
+
* measures nothing — so the causal chip is unreachable by construction.
|
|
18
|
+
* - every card is `upperBound: true`: the score is `1/(1+age)` over write
|
|
19
|
+
* recency, a deterministic LAYOUT AID, not evidence of anything.
|
|
20
|
+
* - the claims lines say out loud that these moments are STRUCTURAL FACTS —
|
|
21
|
+
* recorded reads and writes — so a reader can tell this board apart from an
|
|
22
|
+
* influence board at a glance.
|
|
23
|
+
* - footprintjs's honesty notes ride along verbatim, and honest ABSENCE
|
|
24
|
+
* renders an empty board that says why, never a fabricated suspect.
|
|
25
|
+
*
|
|
26
|
+
* Pure mapping, no UI dependency, framework-agnostic JSON on both sides — the
|
|
27
|
+
* human and the LLM triage the SAME artifact.
|
|
28
|
+
*/
|
|
29
|
+
/** The claims-discipline lines every variable board carries. */
|
|
30
|
+
const VARIABLE_CLAIMS_LINES = [
|
|
31
|
+
'every row here is a STRUCTURAL FACT — a recorded read or write from the commit log, not a similarity guess.',
|
|
32
|
+
'scores are write recency (1/(1+age)) — a layout aid, not influence; every card is an upper bound.',
|
|
33
|
+
'only ablation verdicts make causal claims; nothing on this board has been ablated.',
|
|
34
|
+
];
|
|
35
|
+
/** One custody hop per moment — the recorded rewind rail, in commit order. */
|
|
36
|
+
function custodyHop(key, m) {
|
|
37
|
+
const where = m.loopIndex !== undefined ? `loop ${m.loopIndex}` : 'run setup (no loop)';
|
|
38
|
+
const detail = m.kind === 'write'
|
|
39
|
+
? `${m.stageName} wrote '${key}'${m.verb !== undefined ? ` (${m.verb})` : ''} — ${where}` +
|
|
40
|
+
(m.suspectId !== undefined ? ` · introduced ${m.suspectKind} '${m.suspectId}'` : '')
|
|
41
|
+
: `${m.stageName} read '${key}'${m.fromWriteIdx !== undefined
|
|
42
|
+
? ` (the value written at commit ${m.fromWriteIdx})`
|
|
43
|
+
: ' (a value from before the log — initial state / run input / a closure)'} — ${where}`;
|
|
44
|
+
return { step: m.kind, detail, at: m.runtimeStageId, variable: key };
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Serialize a joined variable life for agentThinkingUI's BacktrackView.
|
|
48
|
+
* See the module doc — structural honesty is the whole design.
|
|
49
|
+
*/
|
|
50
|
+
export function variableToBacktrackTrace(agentSlice, opts) {
|
|
51
|
+
const max = opts.maxSuspects ?? 6;
|
|
52
|
+
const key = agentSlice.key;
|
|
53
|
+
const claim = opts.claim ?? `What happened to '${key}'?`;
|
|
54
|
+
const honesty = [];
|
|
55
|
+
if (agentSlice.missing === 'never-written') {
|
|
56
|
+
honesty.push(`⚠ '${key}' was never written in this run — the value came from initial state, frozen run input (args), or a closure; the commit log cannot see those.`);
|
|
57
|
+
}
|
|
58
|
+
else if (agentSlice.missing === 'empty-log') {
|
|
59
|
+
honesty.push('⚠ the commit log is empty — nothing executed.');
|
|
60
|
+
}
|
|
61
|
+
// footprintjs's own notes, VERBATIM (never re-worded, never dropped).
|
|
62
|
+
for (const note of agentSlice.notes)
|
|
63
|
+
honesty.push(`⚠ ${note.detail}`);
|
|
64
|
+
if (agentSlice.readsCoverage &&
|
|
65
|
+
agentSlice.readsCoverage.steps > 1 &&
|
|
66
|
+
agentSlice.readsCoverage.stepsWithReads === 0) {
|
|
67
|
+
honesty.push('⚠ reads were not recorded (readTracking off) — who consumed this value is unknowable, NOT nobody.');
|
|
68
|
+
}
|
|
69
|
+
honesty.push(agentSlice.coverage === 'exact'
|
|
70
|
+
? "this key's dataflow is recorded per-write (writeProvenance: 'reads-prefix') — what it fed is exact, not inferred."
|
|
71
|
+
: agentSlice.coverage === 'conservative'
|
|
72
|
+
? "this key's dataflow is stage-level only — what it fed is a sound over-approximation; turn on writeProvenance: 'reads-prefix' for exact edges."
|
|
73
|
+
: "this key has no recorded dataflow (nothing read it, or no forward slice was supplied) — 'what it fed' is unknown here, not empty.");
|
|
74
|
+
const writes = agentSlice.moments.filter((m) => m.kind === 'write');
|
|
75
|
+
// Honest absence: an empty board whose honesty says why.
|
|
76
|
+
if (writes.length === 0) {
|
|
77
|
+
return {
|
|
78
|
+
claim,
|
|
79
|
+
mode: 'correlational',
|
|
80
|
+
modeLabel: opts.modeLabel ?? 'no recorded writes — see honesty',
|
|
81
|
+
agent: opts.agent,
|
|
82
|
+
model: opts.model,
|
|
83
|
+
answer: opts.answer,
|
|
84
|
+
decidedAt: {
|
|
85
|
+
id: key,
|
|
86
|
+
label: `'${key}' (no recorded writer)`,
|
|
87
|
+
kind: opts.decidedAtKind ?? 'rule',
|
|
88
|
+
},
|
|
89
|
+
suspects: [],
|
|
90
|
+
honesty: [...honesty, ...VARIABLE_CLAIMS_LINES],
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
// Latest write first — the value's current author is the board's decision point.
|
|
94
|
+
const latest = writes[writes.length - 1];
|
|
95
|
+
const ordered = [...writes].reverse();
|
|
96
|
+
const cards = ordered.map((w, age) => {
|
|
97
|
+
const readers = agentSlice.moments.filter((m) => m.kind === 'read' && m.fromWriteIdx === w.commitIdx);
|
|
98
|
+
return {
|
|
99
|
+
kind: w.suspectKind ?? 'stage',
|
|
100
|
+
name: w.suspectId ?? w.stageName,
|
|
101
|
+
score: Number((1 / (1 + age)).toFixed(2)),
|
|
102
|
+
rank: age + 1,
|
|
103
|
+
upperBound: true,
|
|
104
|
+
edge: { key, kind: 'data' },
|
|
105
|
+
bornAt: {
|
|
106
|
+
id: w.runtimeStageId,
|
|
107
|
+
label: w.stageName,
|
|
108
|
+
via: w.loopIndex !== undefined ? `loop ${w.loopIndex} commit` : 'run setup commit',
|
|
109
|
+
},
|
|
110
|
+
custody: [custodyHop(key, w), ...readers.map((r) => custodyHop(key, r))],
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
const selected = cards.slice(0, max);
|
|
114
|
+
const dropped = cards.slice(max);
|
|
115
|
+
const folded = dropped.length > 0
|
|
116
|
+
? `${dropped.length} more write${dropped.length === 1 ? '' : 's'} folded — ` +
|
|
117
|
+
dropped.map((c) => `#${c.rank} ${c.bornAt.id}`).join(' · ') +
|
|
118
|
+
' — every id drillable with the trace toolpack'
|
|
119
|
+
: undefined;
|
|
120
|
+
return {
|
|
121
|
+
claim,
|
|
122
|
+
mode: 'correlational',
|
|
123
|
+
modeLabel: opts.modeLabel ?? 'recorded life of a variable — structure, not influence',
|
|
124
|
+
agent: opts.agent,
|
|
125
|
+
model: opts.model,
|
|
126
|
+
answer: opts.answer,
|
|
127
|
+
decidedAt: {
|
|
128
|
+
id: latest.runtimeStageId,
|
|
129
|
+
label: latest.stageName,
|
|
130
|
+
kind: opts.decidedAtKind ?? 'rule',
|
|
131
|
+
},
|
|
132
|
+
suspects: selected,
|
|
133
|
+
trail: {
|
|
134
|
+
title: `'${key}' — every recorded write and read`,
|
|
135
|
+
custody: agentSlice.moments.map((m) => custodyHop(key, m)),
|
|
136
|
+
claim: 'commit-log facts in order; no influence was measured.',
|
|
137
|
+
},
|
|
138
|
+
folded,
|
|
139
|
+
honesty: [...honesty, ...VARIABLE_CLAIMS_LINES],
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=variableToBacktrackTrace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variableToBacktrackTrace.js","sourceRoot":"","sources":["../../../../src/lib/context-bisect/variableToBacktrackTrace.ts"],"names":[],"mapp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KAAK,EAAE;YACL,KAAK,EAAE,IAAI,GAAG,mCAAmC;YACjD,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAC1D,KAAK,EAAE,uDAAuD;SAC/D;QACD,MAAM;QACN,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,GAAG,qBAAqB,CAAC;KAChD,CAAC;AACJ,CAAC"}
|
|
@@ -20,6 +20,11 @@
|
|
|
20
20
|
* - FLAT charts only for the cross-loop hop — grouped loop frames are scope-isolated (degraded + flagged).
|
|
21
21
|
* - Three first-class honest stops (never silent): `unseparated-siblings`, `overdetermined-or-incomplete`,
|
|
22
22
|
* `untracked-origin`.
|
|
23
|
+
* - THE PROXY IS NOT ALWAYS NEEDED (`variables`, 7.12): where the recording carries per-write
|
|
24
|
+
* provenance, a suspect's state key has an EXACT recorded life — the value this loop read and the
|
|
25
|
+
* write that produced it — so the descent is a commit-log fact, not a similarity guess, and the hop
|
|
26
|
+
* says `narrowedBy: 'dataflow'`. The proxy still picks WHO; dataflow picks WHERE. Anything less than
|
|
27
|
+
* exact (dial off, stage-level edges, no dataflow, scope-isolated frames) falls back to the beam.
|
|
23
28
|
*
|
|
24
29
|
* VALIDATION (the descent edge is now populated on real agents — proposal 008): `assembleTrajectory`
|
|
25
30
|
* surfaces each loop's proximate `lastToolResult` on the WALK-ONLY `LoopFrame.proximateToolSource`
|
|
@@ -38,8 +43,22 @@ import type { Embedder } from '../influence-core/index.js';
|
|
|
38
43
|
import { type SuspectClassifier } from './localize.js';
|
|
39
44
|
import type { Trajectory } from './trajectory.js';
|
|
40
45
|
import type { AblationRerun, AblationVerdict, ContextBugArtifacts, HonestyFlag, SuspectKind } from './types.js';
|
|
46
|
+
import type { AgentVariableSlice } from './variable-recall.js';
|
|
41
47
|
/** One honest stop reason when the walk cannot cleanly descend/convict. */
|
|
42
48
|
export type RootCauseNote = 'unseparated-siblings' | 'overdetermined-or-incomplete' | 'untracked-origin';
|
|
49
|
+
/**
|
|
50
|
+
* How this hop's DESCENT TARGET was chosen:
|
|
51
|
+
*
|
|
52
|
+
* - `'text-similarity'` — the embedding beam picked the suspect and the hop
|
|
53
|
+
* followed that suspect's scraped provenance writer. A PROXY (the default,
|
|
54
|
+
* and the only value when no `variables` are supplied).
|
|
55
|
+
* - `'dataflow'` — the descent came from the RECORDED life of the suspect's
|
|
56
|
+
* state key: the value this loop read, and the write that produced it. No
|
|
57
|
+
* embedding took part in choosing where to go. Only ever stamped when that
|
|
58
|
+
* key's dataflow is per-write EXACT (see `DataflowCoverage`) — a conservative
|
|
59
|
+
* stage-level edge always falls back to the beam.
|
|
60
|
+
*/
|
|
61
|
+
export type HopNarrowedBy = 'text-similarity' | 'dataflow';
|
|
43
62
|
/** One hop of the symptom→root walk. */
|
|
44
63
|
export interface RootCauseHop {
|
|
45
64
|
/** The loop this hop examined. */
|
|
@@ -47,8 +66,8 @@ export interface RootCauseHop {
|
|
|
47
66
|
/** The narrowed culprit at this hop (joins a localizer Suspect 1:1). */
|
|
48
67
|
readonly suspectId: string;
|
|
49
68
|
readonly kind: SuspectKind;
|
|
50
|
-
/**
|
|
51
|
-
readonly narrowedBy:
|
|
69
|
+
/** How the descent target was chosen — see {@link HopNarrowedBy}. */
|
|
70
|
+
readonly narrowedBy: HopNarrowedBy;
|
|
52
71
|
/** The causal convict — present only when a `rerun` ablated this hop's suspect. */
|
|
53
72
|
readonly verdict?: AblationVerdict;
|
|
54
73
|
/** The provenance writer this hop's culprit came from (runtimeStageId). */
|
|
@@ -84,6 +103,22 @@ export interface WalkToRootOptions {
|
|
|
84
103
|
readonly maxAblations?: number;
|
|
85
104
|
readonly classifier?: SuspectClassifier;
|
|
86
105
|
readonly signal?: AbortSignal;
|
|
106
|
+
/**
|
|
107
|
+
* Joined variable lives (`traceVariable` / `joinVariableSlice`), one per state
|
|
108
|
+
* key you want the walk to be able to descend DETERMINISTICALLY along.
|
|
109
|
+
*
|
|
110
|
+
* When the narrowed suspect carries a state key whose {@link DataflowCoverage}
|
|
111
|
+
* is `'exact'`, the hop's descent target is taken from that key's RECORDED
|
|
112
|
+
* ancestry — the write that produced the value this loop read — instead of
|
|
113
|
+
* from the proxy's provenance scrape, and the hop is stamped
|
|
114
|
+
* `narrowedBy: 'dataflow'`. Anything less than exact (dial off, stage-level
|
|
115
|
+
* edges, no dataflow at all, a grouped/scope-isolated frame) falls back to the
|
|
116
|
+
* beam, unchanged.
|
|
117
|
+
*
|
|
118
|
+
* OMIT IT and the walk behaves EXACTLY as before — same hops, same order, same
|
|
119
|
+
* verdicts, every hop stamped `'text-similarity'`.
|
|
120
|
+
*/
|
|
121
|
+
readonly variables?: readonly AgentVariableSlice[];
|
|
87
122
|
}
|
|
88
123
|
/**
|
|
89
124
|
* Resolve every `writerId` to the index of the frame whose `bodyIds` contains it (NOT via
|
|
@@ -18,7 +18,7 @@ export function buildWriterFrameIndex(trajectory) {
|
|
|
18
18
|
});
|
|
19
19
|
return map;
|
|
20
20
|
}
|
|
21
|
-
/** Map each suspectId present in a frame to
|
|
21
|
+
/** Map each suspectId present in a frame to its {@link SuspectOrigin}. */
|
|
22
22
|
function writtenByOf(frame) {
|
|
23
23
|
const map = new Map();
|
|
24
24
|
for (const src of frame.contextSources) {
|
|
@@ -28,7 +28,7 @@ function writtenByOf(frame) {
|
|
|
28
28
|
for (const rec of v) {
|
|
29
29
|
const id = typeof rec.sourceId === 'string' ? rec.sourceId : undefined;
|
|
30
30
|
if (id !== undefined && !map.has(id))
|
|
31
|
-
map.set(id, src.writerId);
|
|
31
|
+
map.set(id, { writerId: src.writerId, stateKey: src.key });
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
else if (v !== null &&
|
|
@@ -37,7 +37,7 @@ function writtenByOf(frame) {
|
|
|
37
37
|
// lastToolResult: a { toolName, result } object → the tool suspect
|
|
38
38
|
const tool = v.toolName;
|
|
39
39
|
if (!map.has(tool))
|
|
40
|
-
map.set(tool, src.writerId);
|
|
40
|
+
map.set(tool, { writerId: src.writerId, stateKey: src.key });
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
// The WALK-ONLY proximate tool source (proposal 008) — the cross-loop descent edge. NOT in
|
|
@@ -46,10 +46,46 @@ function writtenByOf(frame) {
|
|
|
46
46
|
if (tool && typeof tool.value?.toolName === 'string') {
|
|
47
47
|
const name = tool.value.toolName;
|
|
48
48
|
if (!map.has(name))
|
|
49
|
-
map.set(name, tool.writerId);
|
|
49
|
+
map.set(name, { writerId: tool.writerId, stateKey: tool.stateKey });
|
|
50
50
|
}
|
|
51
51
|
return map;
|
|
52
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* The DETERMINISTIC descent: the write that produced the value this loop's
|
|
55
|
+
* `call-llm` read of `stateKey` — straight off the recorded moments, no
|
|
56
|
+
* embedding involved.
|
|
57
|
+
*
|
|
58
|
+
* Preference order, both commit-log facts:
|
|
59
|
+
* 1. the read moment BY this loop's call-llm → its `fromWriteIdx` → that
|
|
60
|
+
* write (exact value identity — footprintjs pins the same rule its forward
|
|
61
|
+
* walk uses);
|
|
62
|
+
* 2. otherwise the last write strictly before the call-llm's commit (the key
|
|
63
|
+
* the call-llm did not read directly — e.g. an inferred proximate).
|
|
64
|
+
*
|
|
65
|
+
* Returns `undefined` unless coverage is EXACT: a conservative (stage-level)
|
|
66
|
+
* edge must never be presented as an exact hop.
|
|
67
|
+
*/
|
|
68
|
+
function dataflowWriter(slice, frame) {
|
|
69
|
+
const coverage = slice?.coverage;
|
|
70
|
+
if (slice === undefined || coverage !== 'exact')
|
|
71
|
+
return undefined;
|
|
72
|
+
// Grouped frames index a subflow's OWN inner log; a run-log slice cannot be
|
|
73
|
+
// joined to them (see LoopFrame.subflowScope).
|
|
74
|
+
if (frame.subflowScope !== undefined)
|
|
75
|
+
return undefined;
|
|
76
|
+
const writes = slice.moments.filter((m) => m.kind === 'write');
|
|
77
|
+
const read = frame.llmCallId !== undefined
|
|
78
|
+
? slice.moments.find((m) => m.kind === 'read' && m.runtimeStageId === frame.llmCallId)
|
|
79
|
+
: undefined;
|
|
80
|
+
if (read?.fromWriteIdx !== undefined) {
|
|
81
|
+
return writes.find((w) => w.commitIdx === read.fromWriteIdx);
|
|
82
|
+
}
|
|
83
|
+
const llmIdx = frame.llmCallArrayIdx;
|
|
84
|
+
if (llmIdx === undefined)
|
|
85
|
+
return undefined;
|
|
86
|
+
const before = writes.filter((w) => w.commitIdx < llmIdx);
|
|
87
|
+
return before.length > 0 ? before[before.length - 1] : undefined;
|
|
88
|
+
}
|
|
53
89
|
/** A minimal Suspect for ablationForSuspect (only kind + detail identity are read). */
|
|
54
90
|
function suspectFor(suspectId, kind) {
|
|
55
91
|
const detail = kind === 'tool' ? { toolName: suspectId } : { injectionId: suspectId };
|
|
@@ -89,6 +125,8 @@ export async function walkTrajectory(trajectory, opts) {
|
|
|
89
125
|
});
|
|
90
126
|
}
|
|
91
127
|
const writerFrame = buildWriterFrameIndex(trajectory);
|
|
128
|
+
const variables = new Map((opts.variables ?? []).map((v) => [v.key, v]));
|
|
129
|
+
const variableOf = (key) => variables.get(key);
|
|
92
130
|
// Baseline stability (the un-ablated scenario must reproduce for any ablation verdict to be trusted).
|
|
93
131
|
let baselineStable = true;
|
|
94
132
|
let ablationsUsed = 0;
|
|
@@ -148,17 +186,34 @@ export async function walkTrajectory(trajectory, opts) {
|
|
|
148
186
|
}
|
|
149
187
|
}
|
|
150
188
|
}
|
|
189
|
+
// NARROW → HOP. The beam picked WHO; this picks WHERE. When the narrowed
|
|
190
|
+
// suspect rode in on a state key whose dataflow is per-write EXACT, WHERE is
|
|
191
|
+
// a commit-log fact — the write that produced the value THIS loop read —
|
|
192
|
+
// instead of a provenance scrape or an inferred proximate. Absent
|
|
193
|
+
// `variables`, `exactWriter` is always undefined and nothing below changes.
|
|
194
|
+
const beamOrigin = writtenBy.get(chosen.suspectId);
|
|
195
|
+
const exactWrite = beamOrigin?.stateKey !== undefined
|
|
196
|
+
? dataflowWriter(variableOf(beamOrigin.stateKey), frame)
|
|
197
|
+
: undefined;
|
|
198
|
+
const exactFrameIdx = exactWrite !== undefined ? writerFrame.get(exactWrite.runtimeStageId) : undefined;
|
|
199
|
+
const exactWriter = exactWrite !== undefined && exactFrameIdx !== undefined && exactFrameIdx < frameIdx
|
|
200
|
+
? exactWrite.runtimeStageId
|
|
201
|
+
: undefined; // strictly backward, or it is no descent at all
|
|
151
202
|
// The proximate tool source (walk-only, proposal 008) is the cross-loop DESCENT edge. When this
|
|
152
203
|
// loop did NOT convict, follow it back to the loop that PRODUCED the tool output the decision was
|
|
153
204
|
// conditioned on — that's where a buried root (e.g. the misdirecting instruction) scores + convicts.
|
|
205
|
+
// It is an INFERRED proximate (`call-llm` read `history`, not this key), so a RECORDED exact edge
|
|
206
|
+
// for the narrowed suspect outranks it: better evidence wins, and the hop says which it used.
|
|
154
207
|
const toolName = !convicted &&
|
|
208
|
+
exactWriter === undefined &&
|
|
155
209
|
frame.proximateToolSource &&
|
|
156
210
|
typeof frame.proximateToolSource.value?.toolName === 'string'
|
|
157
211
|
? frame.proximateToolSource.value.toolName
|
|
158
212
|
: undefined;
|
|
159
213
|
if (toolName !== undefined)
|
|
160
214
|
chosen = { suspectId: toolName, kind: 'tool' };
|
|
161
|
-
const
|
|
215
|
+
const narrowedBy = exactWriter !== undefined ? 'dataflow' : 'text-similarity';
|
|
216
|
+
const writer = exactWriter ?? writtenBy.get(chosen.suspectId)?.writerId;
|
|
162
217
|
const nextFrameIdx = writer !== undefined ? writerFrame.get(writer) : undefined;
|
|
163
218
|
const descendIdx = nextFrameIdx !== undefined && nextFrameIdx < frameIdx ? nextFrameIdx : undefined; // strictly backward
|
|
164
219
|
// Per-hop honest note: untracked-origin (structural — no provenance writer to descend) is set
|
|
@@ -172,7 +227,7 @@ export async function walkTrajectory(trajectory, opts) {
|
|
|
172
227
|
loopIndex: frame.loopIndex,
|
|
173
228
|
suspectId: chosen.suspectId,
|
|
174
229
|
kind: chosen.kind,
|
|
175
|
-
narrowedBy
|
|
230
|
+
narrowedBy,
|
|
176
231
|
...(chosenVerdict ? { verdict: chosenVerdict } : {}),
|
|
177
232
|
...(writer !== undefined ? { writtenBy: writer } : {}),
|
|
178
233
|
...(descendIdx !== undefined ? { cameFrom: trajectory.frames[descendIdx].loopIndex } : {}),
|