agentfootprint 18.1.1 → 18.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CAPABILITIES.md +7 -3
- package/README.md +3 -3
- package/dist/artifacts/fileArtifacts.js +1 -0
- package/dist/artifacts/fileArtifacts.js.map +1 -1
- package/dist/artifacts/gcsArtifacts.js +1 -0
- package/dist/artifacts/gcsArtifacts.js.map +1 -1
- package/dist/artifacts/inMemoryArtifacts.js +1 -0
- package/dist/artifacts/inMemoryArtifacts.js.map +1 -1
- package/dist/artifacts/index.js +4 -1
- package/dist/artifacts/index.js.map +1 -1
- package/dist/artifacts/recordingArtifact.js +18 -1
- package/dist/artifacts/recordingArtifact.js.map +1 -1
- package/dist/artifacts/retention.js +23 -1
- package/dist/artifacts/retention.js.map +1 -1
- package/dist/artifacts/s3Artifacts.js +5 -6
- package/dist/artifacts/s3Artifacts.js.map +1 -1
- package/dist/artifacts/sqliteArtifacts.js +1 -0
- package/dist/artifacts/sqliteArtifacts.js.map +1 -1
- package/dist/artifacts/types.js +5 -0
- package/dist/artifacts/types.js.map +1 -1
- package/dist/context-bisect/trajectory.js +3 -0
- package/dist/context-bisect/trajectory.js.map +1 -1
- package/dist/core/agent/runtime/configuration/configure.js +2 -0
- package/dist/core/agent/runtime/configuration/configure.js.map +1 -1
- package/dist/core/agent/runtime/recording/recording.js +69 -17
- package/dist/core/agent/runtime/recording/recording.js.map +1 -1
- package/dist/esm/artifacts/conformance/types.d.ts +3 -2
- package/dist/esm/artifacts/fileArtifacts.js +2 -1
- package/dist/esm/artifacts/fileArtifacts.js.map +1 -1
- package/dist/esm/artifacts/gcsArtifacts.js +2 -1
- package/dist/esm/artifacts/gcsArtifacts.js.map +1 -1
- package/dist/esm/artifacts/inMemoryArtifacts.js +2 -1
- package/dist/esm/artifacts/inMemoryArtifacts.js.map +1 -1
- package/dist/esm/artifacts/index.d.ts +2 -2
- package/dist/esm/artifacts/index.js +1 -1
- package/dist/esm/artifacts/index.js.map +1 -1
- package/dist/esm/artifacts/recordingArtifact.d.ts +17 -0
- package/dist/esm/artifacts/recordingArtifact.js +17 -0
- package/dist/esm/artifacts/recordingArtifact.js.map +1 -1
- package/dist/esm/artifacts/retention.d.ts +9 -1
- package/dist/esm/artifacts/retention.js +20 -0
- package/dist/esm/artifacts/retention.js.map +1 -1
- package/dist/esm/artifacts/s3Artifacts.js +6 -7
- package/dist/esm/artifacts/s3Artifacts.js.map +1 -1
- package/dist/esm/artifacts/sqliteArtifacts.js +2 -1
- package/dist/esm/artifacts/sqliteArtifacts.js.map +1 -1
- package/dist/esm/artifacts/types.d.ts +19 -0
- package/dist/esm/artifacts/types.js +5 -0
- package/dist/esm/artifacts/types.js.map +1 -1
- package/dist/esm/context-bisect/trajectory.d.ts +3 -0
- package/dist/esm/context-bisect/trajectory.js +3 -0
- package/dist/esm/context-bisect/trajectory.js.map +1 -1
- package/dist/esm/context-ledger/types.d.ts +3 -1
- package/dist/esm/core/agent/runtime/configuration/configure.js +2 -0
- package/dist/esm/core/agent/runtime/configuration/configure.js.map +1 -1
- package/dist/esm/core/agent/runtime/recording/recording.js +69 -17
- package/dist/esm/core/agent/runtime/recording/recording.js.map +1 -1
- package/dist/esm/core/agent/types/artifacts.d.ts +38 -0
- package/dist/esm/hosting/answerAccounts.d.ts +2 -0
- package/dist/esm/hosting/answerAccounts.js +3 -0
- package/dist/esm/hosting/answerAccounts.js.map +1 -1
- package/dist/esm/hosting/standingAgent/artifacts/accountParts.d.ts +64 -0
- package/dist/esm/hosting/standingAgent/artifacts/accountParts.js +88 -0
- package/dist/esm/hosting/standingAgent/artifacts/accountParts.js.map +1 -0
- package/dist/esm/hosting/standingAgent/artifacts/wire.js +18 -2
- package/dist/esm/hosting/standingAgent/artifacts/wire.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +2 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/observe.d.ts +1 -0
- package/dist/esm/observe.js +3 -0
- package/dist/esm/observe.js.map +1 -1
- package/dist/esm/recorders/observability/recordingParts/file.d.ts +74 -0
- package/dist/esm/recorders/observability/recordingParts/file.js +215 -0
- package/dist/esm/recorders/observability/recordingParts/file.js.map +1 -0
- package/dist/esm/recorders/observability/recordingParts/format.d.ts +124 -0
- package/dist/esm/recorders/observability/recordingParts/format.js +294 -0
- package/dist/esm/recorders/observability/recordingParts/format.js.map +1 -0
- package/dist/esm/recorders/observability/recordingParts/invocations.d.ts +55 -0
- package/dist/esm/recorders/observability/recordingParts/invocations.js +226 -0
- package/dist/esm/recorders/observability/recordingParts/invocations.js.map +1 -0
- package/dist/esm/recorders/observability/recordingParts/open.d.ts +170 -0
- package/dist/esm/recorders/observability/recordingParts/open.js +275 -0
- package/dist/esm/recorders/observability/recordingParts/open.js.map +1 -0
- package/dist/esm/recorders/observability/recordingParts/packing.d.ts +18 -0
- package/dist/esm/recorders/observability/recordingParts/packing.js +23 -0
- package/dist/esm/recorders/observability/recordingParts/packing.js.map +1 -0
- package/dist/esm/recorders/observability/recordingParts/partReader.d.ts +45 -0
- package/dist/esm/recorders/observability/recordingParts/partReader.js +188 -0
- package/dist/esm/recorders/observability/recordingParts/partReader.js.map +1 -0
- package/dist/esm/recorders/observability/recordingParts/source.d.ts +58 -0
- package/dist/esm/recorders/observability/recordingParts/source.js +120 -0
- package/dist/esm/recorders/observability/recordingParts/source.js.map +1 -0
- package/dist/esm/recorders/observability/recordingParts/split.d.ts +74 -0
- package/dist/esm/recorders/observability/recordingParts/split.js +316 -0
- package/dist/esm/recorders/observability/recordingParts/split.js.map +1 -0
- package/dist/esm/recorders/observability/recordingParts/splitError.d.ts +17 -0
- package/dist/esm/recorders/observability/recordingParts/splitError.js +27 -0
- package/dist/esm/recorders/observability/recordingParts/splitError.js.map +1 -0
- package/dist/esm/time-travel/epochs.d.ts +3 -0
- package/dist/esm/time-travel/epochs.js +3 -0
- package/dist/esm/time-travel/epochs.js.map +1 -1
- package/dist/esm/trace-toolpack/openRecording.d.ts +3 -0
- package/dist/esm/trace-toolpack/openRecording.js +3 -0
- package/dist/esm/trace-toolpack/openRecording.js.map +1 -1
- package/dist/hosting/answerAccounts.js +3 -0
- package/dist/hosting/answerAccounts.js.map +1 -1
- package/dist/hosting/standingAgent/artifacts/accountParts.js +92 -0
- package/dist/hosting/standingAgent/artifacts/accountParts.js.map +1 -0
- package/dist/hosting/standingAgent/artifacts/wire.js +17 -1
- package/dist/hosting/standingAgent/artifacts/wire.js.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/observe.js +6 -2
- package/dist/observe.js.map +1 -1
- package/dist/recorders/observability/recordingParts/file.js +219 -0
- package/dist/recorders/observability/recordingParts/file.js.map +1 -0
- package/dist/recorders/observability/recordingParts/format.js +304 -0
- package/dist/recorders/observability/recordingParts/format.js.map +1 -0
- package/dist/recorders/observability/recordingParts/invocations.js +230 -0
- package/dist/recorders/observability/recordingParts/invocations.js.map +1 -0
- package/dist/recorders/observability/recordingParts/open.js +279 -0
- package/dist/recorders/observability/recordingParts/open.js.map +1 -0
- package/dist/recorders/observability/recordingParts/packing.js +28 -0
- package/dist/recorders/observability/recordingParts/packing.js.map +1 -0
- package/dist/recorders/observability/recordingParts/partReader.js +192 -0
- package/dist/recorders/observability/recordingParts/partReader.js.map +1 -0
- package/dist/recorders/observability/recordingParts/source.js +126 -0
- package/dist/recorders/observability/recordingParts/source.js.map +1 -0
- package/dist/recorders/observability/recordingParts/split.js +322 -0
- package/dist/recorders/observability/recordingParts/split.js.map +1 -0
- package/dist/recorders/observability/recordingParts/splitError.js +31 -0
- package/dist/recorders/observability/recordingParts/splitError.js.map +1 -0
- package/dist/time-travel/epochs.js +3 -0
- package/dist/time-travel/epochs.js.map +1 -1
- package/dist/trace-toolpack/openRecording.js +3 -0
- package/dist/trace-toolpack/openRecording.js.map +1 -1
- package/dist/types/artifacts/conformance/types.d.ts +3 -2
- package/dist/types/artifacts/conformance/types.d.ts.map +1 -1
- package/dist/types/artifacts/fileArtifacts.d.ts.map +1 -1
- package/dist/types/artifacts/gcsArtifacts.d.ts.map +1 -1
- package/dist/types/artifacts/inMemoryArtifacts.d.ts.map +1 -1
- package/dist/types/artifacts/index.d.ts +2 -2
- package/dist/types/artifacts/index.d.ts.map +1 -1
- package/dist/types/artifacts/recordingArtifact.d.ts +17 -0
- package/dist/types/artifacts/recordingArtifact.d.ts.map +1 -1
- package/dist/types/artifacts/retention.d.ts +9 -1
- package/dist/types/artifacts/retention.d.ts.map +1 -1
- package/dist/types/artifacts/s3Artifacts.d.ts.map +1 -1
- package/dist/types/artifacts/sqliteArtifacts.d.ts.map +1 -1
- package/dist/types/artifacts/types.d.ts +19 -0
- package/dist/types/artifacts/types.d.ts.map +1 -1
- package/dist/types/context-bisect/trajectory.d.ts +3 -0
- package/dist/types/context-bisect/trajectory.d.ts.map +1 -1
- package/dist/types/context-ledger/types.d.ts +3 -1
- package/dist/types/context-ledger/types.d.ts.map +1 -1
- package/dist/types/core/agent/runtime/configuration/configure.d.ts.map +1 -1
- package/dist/types/core/agent/runtime/recording/recording.d.ts.map +1 -1
- package/dist/types/core/agent/types/artifacts.d.ts +38 -0
- package/dist/types/core/agent/types/artifacts.d.ts.map +1 -1
- package/dist/types/hosting/answerAccounts.d.ts +2 -0
- package/dist/types/hosting/answerAccounts.d.ts.map +1 -1
- package/dist/types/hosting/standingAgent/artifacts/accountParts.d.ts +65 -0
- package/dist/types/hosting/standingAgent/artifacts/accountParts.d.ts.map +1 -0
- package/dist/types/hosting/standingAgent/artifacts/wire.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/observe.d.ts +1 -0
- package/dist/types/observe.d.ts.map +1 -1
- package/dist/types/recorders/observability/recordingParts/file.d.ts +75 -0
- package/dist/types/recorders/observability/recordingParts/file.d.ts.map +1 -0
- package/dist/types/recorders/observability/recordingParts/format.d.ts +125 -0
- package/dist/types/recorders/observability/recordingParts/format.d.ts.map +1 -0
- package/dist/types/recorders/observability/recordingParts/invocations.d.ts +56 -0
- package/dist/types/recorders/observability/recordingParts/invocations.d.ts.map +1 -0
- package/dist/types/recorders/observability/recordingParts/open.d.ts +171 -0
- package/dist/types/recorders/observability/recordingParts/open.d.ts.map +1 -0
- package/dist/types/recorders/observability/recordingParts/packing.d.ts +19 -0
- package/dist/types/recorders/observability/recordingParts/packing.d.ts.map +1 -0
- package/dist/types/recorders/observability/recordingParts/partReader.d.ts +46 -0
- package/dist/types/recorders/observability/recordingParts/partReader.d.ts.map +1 -0
- package/dist/types/recorders/observability/recordingParts/source.d.ts +59 -0
- package/dist/types/recorders/observability/recordingParts/source.d.ts.map +1 -0
- package/dist/types/recorders/observability/recordingParts/split.d.ts +75 -0
- package/dist/types/recorders/observability/recordingParts/split.d.ts.map +1 -0
- package/dist/types/recorders/observability/recordingParts/splitError.d.ts +18 -0
- package/dist/types/recorders/observability/recordingParts/splitError.d.ts.map +1 -0
- package/dist/types/time-travel/epochs.d.ts +3 -0
- package/dist/types/time-travel/epochs.d.ts.map +1 -1
- package/dist/types/trace-toolpack/openRecording.d.ts +3 -0
- package/dist/types/trace-toolpack/openRecording.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* recordingParts/invocations — which invocations a recorded snapshot holds,
|
|
3
|
+
* in the order the lazy viewer lists them.
|
|
4
|
+
*
|
|
5
|
+
* Role: Fold. One walk over a parsed snapshot's execution tree and its
|
|
6
|
+
* `subflowResults`; returns addresses and the results they name.
|
|
7
|
+
* Reads: its argument (plain JSON data).
|
|
8
|
+
* Emits: N/A.
|
|
9
|
+
*
|
|
10
|
+
* ── Why the walk lives here AND in the viewer ───────────────────────────────
|
|
11
|
+
* A nested invocation's address is found inside its PARENT's result
|
|
12
|
+
* (`treeContext.stageContexts`), so an index written without the results must
|
|
13
|
+
* carry every address. This walk mirrors the viewer package's
|
|
14
|
+
* `recordingSourceCodec/nativeIndex.ts` (its `scopeMounts` and
|
|
15
|
+
* `indexNativeRecording`): the same stack order (`next` is visited before
|
|
16
|
+
* `children`, children in their own order), the same depth-first descent into
|
|
17
|
+
* each mount's result, the same canonical execution keys and the same unit
|
|
18
|
+
* shape. Where the viewer refuses a whole recording, this walk keeps what it
|
|
19
|
+
* can address and says `complete: false`, so no recorded result is lost and
|
|
20
|
+
* the reader can answer the viewer's own refusal. The two copies are
|
|
21
|
+
* cross-checked by the host application's test against the viewer's
|
|
22
|
+
* projection; moving the viewer onto this walk is a separate change.
|
|
23
|
+
*/
|
|
24
|
+
/** One invocation the tree mounts. `result` is absent when none was recorded. */
|
|
25
|
+
export interface WalkedInvocation {
|
|
26
|
+
readonly key: string;
|
|
27
|
+
readonly path: readonly string[];
|
|
28
|
+
readonly subflowId: string;
|
|
29
|
+
readonly result?: unknown;
|
|
30
|
+
}
|
|
31
|
+
/** What one snapshot holds, addressed. */
|
|
32
|
+
export interface RecordingWalk {
|
|
33
|
+
readonly invocations: readonly WalkedInvocation[];
|
|
34
|
+
/** Execution-key results no mount reaches, in `subflowResults` order. */
|
|
35
|
+
readonly unmounted: readonly {
|
|
36
|
+
readonly key: string;
|
|
37
|
+
readonly result: unknown;
|
|
38
|
+
}[];
|
|
39
|
+
/** Every other `subflowResults` key (path aliases), in order. */
|
|
40
|
+
readonly aliases: readonly {
|
|
41
|
+
readonly name: string;
|
|
42
|
+
readonly value: unknown;
|
|
43
|
+
}[];
|
|
44
|
+
readonly complete: boolean;
|
|
45
|
+
readonly hasSubflowResults: boolean;
|
|
46
|
+
readonly snapshotRunId?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Walk a parsed snapshot. `snapshot` is `undefined` or not an object when the
|
|
50
|
+
* recording has none; it then holds no invocations.
|
|
51
|
+
*
|
|
52
|
+
* @throws RecordingSplitError (`over-limit`) past the index bounds, which the
|
|
53
|
+
* viewer would refuse as too large too.
|
|
54
|
+
*/
|
|
55
|
+
export declare function walkRecordedInvocations(snapshot: unknown): RecordingWalk;
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* recordingParts/invocations — which invocations a recorded snapshot holds,
|
|
3
|
+
* in the order the lazy viewer lists them.
|
|
4
|
+
*
|
|
5
|
+
* Role: Fold. One walk over a parsed snapshot's execution tree and its
|
|
6
|
+
* `subflowResults`; returns addresses and the results they name.
|
|
7
|
+
* Reads: its argument (plain JSON data).
|
|
8
|
+
* Emits: N/A.
|
|
9
|
+
*
|
|
10
|
+
* ── Why the walk lives here AND in the viewer ───────────────────────────────
|
|
11
|
+
* A nested invocation's address is found inside its PARENT's result
|
|
12
|
+
* (`treeContext.stageContexts`), so an index written without the results must
|
|
13
|
+
* carry every address. This walk mirrors the viewer package's
|
|
14
|
+
* `recordingSourceCodec/nativeIndex.ts` (its `scopeMounts` and
|
|
15
|
+
* `indexNativeRecording`): the same stack order (`next` is visited before
|
|
16
|
+
* `children`, children in their own order), the same depth-first descent into
|
|
17
|
+
* each mount's result, the same canonical execution keys and the same unit
|
|
18
|
+
* shape. Where the viewer refuses a whole recording, this walk keeps what it
|
|
19
|
+
* can address and says `complete: false`, so no recorded result is lost and
|
|
20
|
+
* the reader can answer the viewer's own refusal. The two copies are
|
|
21
|
+
* cross-checked by the host application's test against the viewer's
|
|
22
|
+
* projection; moving the viewer onto this walk is a separate change.
|
|
23
|
+
*/
|
|
24
|
+
import { isExecutionKey } from 'foottrace';
|
|
25
|
+
import { RECORDING_PARTS_LIMITS, isCanonicalExecutionKey, isName, isPlainObject, ownValue, } from './format.js';
|
|
26
|
+
import { RecordingSplitError } from './splitError.js';
|
|
27
|
+
/**
|
|
28
|
+
* Walk a parsed snapshot. `snapshot` is `undefined` or not an object when the
|
|
29
|
+
* recording has none; it then holds no invocations.
|
|
30
|
+
*
|
|
31
|
+
* @throws RecordingSplitError (`over-limit`) past the index bounds, which the
|
|
32
|
+
* viewer would refuse as too large too.
|
|
33
|
+
*/
|
|
34
|
+
export function walkRecordedInvocations(snapshot) {
|
|
35
|
+
const limits = RECORDING_PARTS_LIMITS;
|
|
36
|
+
if (!isPlainObject(snapshot)) {
|
|
37
|
+
// Nothing to address — and the lazy viewer refuses a recording with no snapshot.
|
|
38
|
+
return {
|
|
39
|
+
invocations: [],
|
|
40
|
+
unmounted: [],
|
|
41
|
+
aliases: [],
|
|
42
|
+
complete: false,
|
|
43
|
+
hasSubflowResults: false,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
let complete = true;
|
|
47
|
+
let visits = 0;
|
|
48
|
+
const spend = () => {
|
|
49
|
+
if (++visits > limits.visits)
|
|
50
|
+
throw new RecordingSplitError('over-limit', 'tree');
|
|
51
|
+
};
|
|
52
|
+
const rawResults = ownValue(snapshot, 'subflowResults');
|
|
53
|
+
const hasSubflowResults = rawResults !== undefined;
|
|
54
|
+
if (hasSubflowResults && !isPlainObject(rawResults)) {
|
|
55
|
+
throw new RecordingSplitError('not-a-recording');
|
|
56
|
+
}
|
|
57
|
+
const units = new Map();
|
|
58
|
+
const aliases = [];
|
|
59
|
+
if (isPlainObject(rawResults)) {
|
|
60
|
+
for (const key of Object.keys(rawResults)) {
|
|
61
|
+
spend();
|
|
62
|
+
// An empty key is a malformed recording; only a long one is a bound.
|
|
63
|
+
if (key.length === 0)
|
|
64
|
+
throw new RecordingSplitError('not-a-recording');
|
|
65
|
+
if (!isName(key))
|
|
66
|
+
throw new RecordingSplitError('over-limit', 'name');
|
|
67
|
+
const value = ownValue(rawResults, key);
|
|
68
|
+
if (isCanonicalExecutionKey(key))
|
|
69
|
+
units.set(key, value);
|
|
70
|
+
else {
|
|
71
|
+
// A key spelled like an execution but not canonical: the viewer refuses the whole.
|
|
72
|
+
if (isExecutionKey(key))
|
|
73
|
+
complete = false;
|
|
74
|
+
aliases.push({ name: key, value });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const rawRunId = ownValue(snapshot, 'runId');
|
|
79
|
+
const snapshotRunId = isName(rawRunId) ? rawRunId : undefined;
|
|
80
|
+
if (rawRunId !== undefined && snapshotRunId === undefined)
|
|
81
|
+
complete = false;
|
|
82
|
+
const rootAddress = readLogAddress(ownValue(snapshot, 'logAddress'));
|
|
83
|
+
if (ownValue(snapshot, 'logAddress') !== undefined && rootAddress === undefined)
|
|
84
|
+
complete = false;
|
|
85
|
+
if (ownValue(snapshot, 'executionTree') === undefined)
|
|
86
|
+
complete = false;
|
|
87
|
+
const invocations = [];
|
|
88
|
+
const mounted = new Set();
|
|
89
|
+
const mountsOf = (tree) => {
|
|
90
|
+
const out = [];
|
|
91
|
+
const pending = tree === null || tree === undefined ? [] : [tree];
|
|
92
|
+
const seen = new Set();
|
|
93
|
+
while (pending.length > 0) {
|
|
94
|
+
spend();
|
|
95
|
+
const node = pending.pop();
|
|
96
|
+
if (!isPlainObject(node)) {
|
|
97
|
+
complete = false;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const subflow = ownValue(node, 'subflowId');
|
|
101
|
+
if (subflow !== undefined) {
|
|
102
|
+
const key = ownValue(node, 'runtimeStageId');
|
|
103
|
+
if (!isName(subflow) || !isCanonicalExecutionKey(key) || seen.has(key))
|
|
104
|
+
complete = false;
|
|
105
|
+
else {
|
|
106
|
+
seen.add(key);
|
|
107
|
+
out.push({ key, subflowId: subflow });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const children = ownValue(node, 'children');
|
|
111
|
+
if (children !== undefined && children !== null) {
|
|
112
|
+
if (!Array.isArray(children))
|
|
113
|
+
complete = false;
|
|
114
|
+
else {
|
|
115
|
+
if (children.length > limits.visits)
|
|
116
|
+
throw new RecordingSplitError('over-limit', 'tree');
|
|
117
|
+
for (let i = children.length - 1; i >= 0; i--)
|
|
118
|
+
pending.push(children[i]);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const next = ownValue(node, 'next');
|
|
122
|
+
if (next !== undefined && next !== null)
|
|
123
|
+
pending.push(next);
|
|
124
|
+
}
|
|
125
|
+
return out;
|
|
126
|
+
};
|
|
127
|
+
const walk = (tree, ancestors) => {
|
|
128
|
+
for (const mount of mountsOf(tree)) {
|
|
129
|
+
const path = [...ancestors, mount.key];
|
|
130
|
+
const chars = path.reduce((sum, segment) => sum + segment.length, 0);
|
|
131
|
+
if (path.length > limits.pathSegments || chars > limits.pathChars) {
|
|
132
|
+
throw new RecordingSplitError('over-limit', 'path');
|
|
133
|
+
}
|
|
134
|
+
if (mounted.has(mount.key)) {
|
|
135
|
+
complete = false;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
mounted.add(mount.key);
|
|
139
|
+
if (invocations.length >= limits.invocations) {
|
|
140
|
+
throw new RecordingSplitError('over-limit', 'invocations');
|
|
141
|
+
}
|
|
142
|
+
if (!units.has(mount.key)) {
|
|
143
|
+
complete = false;
|
|
144
|
+
invocations.push({ key: mount.key, path, subflowId: mount.subflowId });
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
const result = units.get(mount.key);
|
|
148
|
+
if (!unitConforms(result, mount.subflowId, path, rootAddress))
|
|
149
|
+
complete = false;
|
|
150
|
+
invocations.push({ key: mount.key, path, subflowId: mount.subflowId, result });
|
|
151
|
+
const context = isPlainObject(result) ? ownValue(result, 'treeContext') : undefined;
|
|
152
|
+
const inner = isPlainObject(context) ? ownValue(context, 'stageContexts') : undefined;
|
|
153
|
+
if (isPlainObject(inner))
|
|
154
|
+
walk(inner, path);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
walk(ownValue(snapshot, 'executionTree'), []);
|
|
158
|
+
const unmounted = [];
|
|
159
|
+
for (const [key, result] of units) {
|
|
160
|
+
if (!mounted.has(key))
|
|
161
|
+
unmounted.push({ key, result });
|
|
162
|
+
}
|
|
163
|
+
if (unmounted.length > 0)
|
|
164
|
+
complete = false;
|
|
165
|
+
if (invocations.length + unmounted.length > limits.invocations) {
|
|
166
|
+
throw new RecordingSplitError('over-limit', 'invocations');
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
invocations,
|
|
170
|
+
unmounted,
|
|
171
|
+
aliases,
|
|
172
|
+
complete,
|
|
173
|
+
hasSubflowResults,
|
|
174
|
+
...(snapshotRunId !== undefined && { snapshotRunId }),
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function readLogAddress(value) {
|
|
178
|
+
if (!isPlainObject(value))
|
|
179
|
+
return undefined;
|
|
180
|
+
const logRunId = ownValue(value, 'logRunId');
|
|
181
|
+
const drillPath = ownValue(value, 'drillPath');
|
|
182
|
+
if (!isName(logRunId) || !Array.isArray(drillPath))
|
|
183
|
+
return undefined;
|
|
184
|
+
if (!drillPath.every((segment) => isCanonicalExecutionKey(segment)))
|
|
185
|
+
return undefined;
|
|
186
|
+
if (!withinPathBounds(drillPath))
|
|
187
|
+
return undefined;
|
|
188
|
+
return { logRunId, drillPath: drillPath };
|
|
189
|
+
}
|
|
190
|
+
/** The viewer's path bounds: at most 128 segments and 8,192 characters. */
|
|
191
|
+
function withinPathBounds(path) {
|
|
192
|
+
const chars = path.reduce((sum, segment) => sum + segment.length, 0);
|
|
193
|
+
return (path.length <= RECORDING_PARTS_LIMITS.pathSegments && chars <= RECORDING_PARTS_LIMITS.pathChars);
|
|
194
|
+
}
|
|
195
|
+
/** The unit shape the viewer admits for one mount (its `completeUnit`). */
|
|
196
|
+
function unitConforms(result, subflowId, path, rootAddress) {
|
|
197
|
+
if (!isPlainObject(result) || ownValue(result, 'subflowId') !== subflowId)
|
|
198
|
+
return false;
|
|
199
|
+
if (!isName(ownValue(result, 'subflowName')) || !isName(ownValue(result, 'parentStageId'))) {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
const context = ownValue(result, 'treeContext');
|
|
203
|
+
if (!isPlainObject(context))
|
|
204
|
+
return false;
|
|
205
|
+
if (!isPlainObject(ownValue(context, 'globalContext')))
|
|
206
|
+
return false;
|
|
207
|
+
if (!isPlainObject(ownValue(context, 'stageContexts')))
|
|
208
|
+
return false;
|
|
209
|
+
if (!Array.isArray(ownValue(context, 'history')))
|
|
210
|
+
return false;
|
|
211
|
+
const rawAddress = ownValue(context, 'logAddress');
|
|
212
|
+
if (rawAddress === undefined)
|
|
213
|
+
return true;
|
|
214
|
+
const address = readLogAddress(rawAddress);
|
|
215
|
+
if (address === undefined)
|
|
216
|
+
return false;
|
|
217
|
+
// Both drill paths are bounded where they are read (`readLogAddress`), so an
|
|
218
|
+
// expected path past the viewer's bound can never equal the unit's own.
|
|
219
|
+
const expected = [...(rootAddress?.drillPath ?? []), ...path];
|
|
220
|
+
if (address.drillPath.length !== expected.length)
|
|
221
|
+
return false;
|
|
222
|
+
if (address.drillPath.some((segment, i) => segment !== expected[i]))
|
|
223
|
+
return false;
|
|
224
|
+
return rootAddress === undefined || address.logRunId === rootAddress.logRunId;
|
|
225
|
+
}
|
|
226
|
+
//# sourceMappingURL=invocations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invocations.js","sourceRoot":"","sources":["../../../../../src/recorders/observability/recordingParts/invocations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,MAAM,EACN,aAAa,EACb,QAAQ,GACT,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AA2BtD;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,QAAiB;IACvD,MAAM,MAAM,GAAG,sBAAsB,CAAC;IACtC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,iFAAiF;QACjF,OAAO;YACL,WAAW,EAAE,EAAE;YACf,SAAS,EAAE,EAAE;YACb,OAAO,EAAE,EAAE;YACX,QAAQ,EAAE,KAAK;YACf,iBAAiB,EAAE,KAAK;SACz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AK,CAAC;IAC/D,IAAI,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAClF,OAAO,WAAW,KAAK,SAAS,IAAI,OAAO,CAAC,QAAQ,KAAK,WAAW,CAAC,QAAQ,CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* recordingParts/open — open a saved recording, then read its root, one
|
|
3
|
+
* invocation, or the whole of it, one checked part at a time.
|
|
4
|
+
*
|
|
5
|
+
* Role: Lens. Serves one reader what one stored recording holds and nothing
|
|
6
|
+
* more: an invocation is read from the part that holds it, after the
|
|
7
|
+
* part's metadata and digest prove it is the part the index names.
|
|
8
|
+
* Reads: the scope-bound `head`/`get` it is handed.
|
|
9
|
+
* Emits: N/A.
|
|
10
|
+
*
|
|
11
|
+
* ── Two layouts, one reader ─────────────────────────────────────────────────
|
|
12
|
+
* A whole recording (`recording/run`) is read once, within `maxRootBytes`, and
|
|
13
|
+
* cut in memory by the same split a writer uses (`recordingParts/split.ts ·
|
|
14
|
+
* splitRecordingData`). A recording saved in parts (`recording/run-index`)
|
|
15
|
+
* reads only its index at open; `readRoot` reads the base part and
|
|
16
|
+
* `readInvocation` the one part holding that invocation. Both layouts answer
|
|
17
|
+
* through the same part reader, so both serve the same values.
|
|
18
|
+
*
|
|
19
|
+
* ── Honesty ─────────────────────────────────────────────────────────────────
|
|
20
|
+
* A missing, changed or oversized part is unavailable for exactly the
|
|
21
|
+
* invocations it holds; every other invocation still reads. Nothing falls
|
|
22
|
+
* back to another source. `readWhole` is all-or-nothing.
|
|
23
|
+
*/
|
|
24
|
+
import type { ArtifactRef } from '../../../artifacts/types.js';
|
|
25
|
+
import type { Recording } from '../recordRun.js';
|
|
26
|
+
import { type SavedRecordingPartUnavailable } from './partReader.js';
|
|
27
|
+
import { type SavedRecordingArtifacts } from './source.js';
|
|
28
|
+
export type { SavedRecordingArtifacts } from './source.js';
|
|
29
|
+
export type { SavedRecordingPartUnavailable } from './partReader.js';
|
|
30
|
+
/** How much {@link openSavedRecording} agrees to read. Every cap is checked from metadata first. */
|
|
31
|
+
export interface OpenSavedRecordingOptions {
|
|
32
|
+
/** Cancels the open, and every later read that is not given its own signal. */
|
|
33
|
+
readonly signal?: AbortSignal;
|
|
34
|
+
/** The largest index, in bytes. Default 2 MiB. */
|
|
35
|
+
readonly maxIndexBytes?: number;
|
|
36
|
+
/**
|
|
37
|
+
* The largest base part, or whole recording, in bytes (a packed one: its plain
|
|
38
|
+
* size). Default 16 MiB. A whole recording within it opens, and the parts it is
|
|
39
|
+
* cut into in memory are not capped again.
|
|
40
|
+
*/
|
|
41
|
+
readonly maxRootBytes?: number;
|
|
42
|
+
/** The largest invocation part, in bytes (a packed one: its plain size). Default 16 MiB. */
|
|
43
|
+
readonly maxPartBytes?: number;
|
|
44
|
+
}
|
|
45
|
+
/** Options for one read from an opened recording. */
|
|
46
|
+
export interface SavedRecordingReadOptions {
|
|
47
|
+
readonly signal?: AbortSignal;
|
|
48
|
+
}
|
|
49
|
+
/** Options for {@link SavedRecording.readWhole}. */
|
|
50
|
+
export interface SavedRecordingWholeOptions extends SavedRecordingReadOptions {
|
|
51
|
+
/**
|
|
52
|
+
* The most plain JSON bytes the whole read may take. Default 64 MiB. The stored
|
|
53
|
+
* total is checked from the index first; then each part may expand only to what
|
|
54
|
+
* the parts before it left, so a packed part is refused before it expands past it.
|
|
55
|
+
*/
|
|
56
|
+
readonly maxBytes?: number;
|
|
57
|
+
}
|
|
58
|
+
/** One recorded invocation, in the order the lazy viewer lists them. */
|
|
59
|
+
export interface SavedInvocation {
|
|
60
|
+
/** The execution key: the mount's runtime stage id and its `subflowResults` key. */
|
|
61
|
+
readonly key: string;
|
|
62
|
+
/** Mount keys from the root down to this invocation (the viewer's `invocationPath`). */
|
|
63
|
+
readonly path: readonly string[];
|
|
64
|
+
readonly subflowId: string;
|
|
65
|
+
/** `false` when the tree mounts it but the recording holds no result for it. */
|
|
66
|
+
readonly recorded: boolean;
|
|
67
|
+
/** Compact JSON bytes of its result, when recorded. */
|
|
68
|
+
readonly bytes?: number;
|
|
69
|
+
}
|
|
70
|
+
/** Sizes known from the index alone, with no part read. */
|
|
71
|
+
export interface SavedRecordingSizes {
|
|
72
|
+
/** Every stored byte of this recording. */
|
|
73
|
+
readonly storedBytes: number;
|
|
74
|
+
/** How many artifacts hold it. */
|
|
75
|
+
readonly artifacts: number;
|
|
76
|
+
/** The index's bytes (parts layout only). */
|
|
77
|
+
readonly index?: number;
|
|
78
|
+
/** The base part's bytes (parts layout only). */
|
|
79
|
+
readonly base?: number;
|
|
80
|
+
/** Each invocation part (parts layout only; empty for a whole recording). */
|
|
81
|
+
readonly parts: readonly {
|
|
82
|
+
readonly part: number;
|
|
83
|
+
readonly bytes: number;
|
|
84
|
+
readonly results: number;
|
|
85
|
+
}[];
|
|
86
|
+
}
|
|
87
|
+
/** Why a saved recording could not be opened. */
|
|
88
|
+
export interface SavedRecordingUnavailable {
|
|
89
|
+
readonly status: 'unavailable';
|
|
90
|
+
readonly reason: 'not-found' | 'not-a-recording' | 'too-large' | 'invalid-index' | 'invalid-recording';
|
|
91
|
+
}
|
|
92
|
+
/** An opened saved recording. Only its index (or, for a whole recording, the whole) has been read. */
|
|
93
|
+
export interface SavedRecording {
|
|
94
|
+
readonly status: 'ready';
|
|
95
|
+
readonly layout: 'whole' | 'parts';
|
|
96
|
+
/** The run the recording was filed for (`origin.runId`). */
|
|
97
|
+
readonly runId?: string;
|
|
98
|
+
/** `snapshot.runId`, the engine's executor id: what a viewer address's `runId` must equal. */
|
|
99
|
+
readonly snapshotRunId?: string;
|
|
100
|
+
/**
|
|
101
|
+
* `false` when the tree and the results disagree, or a result is not in the
|
|
102
|
+
* shape the lazy viewer admits; such a viewer refuses the recording whole.
|
|
103
|
+
* Check it before relying on what `readInvocation` returns.
|
|
104
|
+
*/
|
|
105
|
+
readonly complete: boolean;
|
|
106
|
+
readonly invocations: readonly SavedInvocation[];
|
|
107
|
+
/** Path aliases proven equal to an invocation's result: alias → execution key. */
|
|
108
|
+
readonly aliases: ReadonlyMap<string, string>;
|
|
109
|
+
readonly sizes: SavedRecordingSizes;
|
|
110
|
+
/** The recording without its subflow results: `{ snapshot, events, structure }`. */
|
|
111
|
+
readRoot(options?: SavedRecordingReadOptions): Promise<{
|
|
112
|
+
readonly status: 'ready';
|
|
113
|
+
readonly recording: Recording;
|
|
114
|
+
} | SavedRecordingPartUnavailable>;
|
|
115
|
+
/**
|
|
116
|
+
* One invocation's result, read from the one part that holds it. The result
|
|
117
|
+
* is the stored one, proven by digest and key set. Its SHAPE was checked when
|
|
118
|
+
* the recording was cut: on a recording that is not `complete`, a `ready`
|
|
119
|
+
* result may be one the lazy viewer would refuse, so check `complete` first.
|
|
120
|
+
*/
|
|
121
|
+
readInvocation(key: string, options?: SavedRecordingReadOptions): Promise<{
|
|
122
|
+
readonly status: 'ready';
|
|
123
|
+
readonly invocation: SavedInvocation;
|
|
124
|
+
readonly result: unknown;
|
|
125
|
+
} | SavedRecordingPartUnavailable>;
|
|
126
|
+
/**
|
|
127
|
+
* Whether every stored part is still there as the index names it: a `head`
|
|
128
|
+
* of each, its kind, bytes, digest and run checked against the index, and no
|
|
129
|
+
* byte read. `ready`, or the first part's `part-missing` / `part-changed`.
|
|
130
|
+
* A whole recording has no separate parts: this makes NO store call for it
|
|
131
|
+
* and is always `ready`, so a host must `head` that artifact itself. A host
|
|
132
|
+
* serving something derived from the recording (a cached answer) asks this
|
|
133
|
+
* first, so it never serves past the store's own retention.
|
|
134
|
+
*/
|
|
135
|
+
checkParts(options?: SavedRecordingReadOptions): Promise<{
|
|
136
|
+
readonly status: 'ready';
|
|
137
|
+
} | SavedRecordingPartUnavailable>;
|
|
138
|
+
/**
|
|
139
|
+
* The whole recording, with every result and alias restored; refused whole if
|
|
140
|
+
* any part is. It deep-equals the recording that was saved but is not
|
|
141
|
+
* byte-equal to it: `subflowResults` comes last in the snapshot, its keys are
|
|
142
|
+
* in part order, and a proven alias shares its key's result object.
|
|
143
|
+
*/
|
|
144
|
+
readWhole(options?: SavedRecordingWholeOptions): Promise<{
|
|
145
|
+
readonly status: 'ready';
|
|
146
|
+
readonly recording: Recording;
|
|
147
|
+
} | SavedRecordingPartUnavailable>;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Open a saved recording by its receipt's ref: either layout.
|
|
151
|
+
*
|
|
152
|
+
* `artifacts` is already bound to ONE scope (a tool's `ctx.artifacts`, or a
|
|
153
|
+
* host's per-request binding), so a ref from any other scope is `not-found`.
|
|
154
|
+
* Open reads the index only (for a whole recording: the whole, within
|
|
155
|
+
* `maxRootBytes`). Every cap is checked from `head` metadata before any `get`.
|
|
156
|
+
* A store error that is not a fact about the recording (busy, revoked) and an
|
|
157
|
+
* aborted signal reject; they are never reported as a reason.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```ts
|
|
161
|
+
* import { openSavedRecording } from 'agentfootprint/observe';
|
|
162
|
+
*
|
|
163
|
+
* const saved = await openSavedRecording(ctx.artifacts, receipt.ref);
|
|
164
|
+
* if (saved.status === 'ready') {
|
|
165
|
+
* const root = await saved.readRoot(); // no subflow results
|
|
166
|
+
* const first = await saved.readInvocation(saved.invocations[0].key);
|
|
167
|
+
* }
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
export declare function openSavedRecording(artifacts: SavedRecordingArtifacts, ref: ArtifactRef, options?: OpenSavedRecordingOptions): Promise<SavedRecording | SavedRecordingUnavailable>;
|