agentfootprint 18.1.0 → 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/convert/bounds.js +18 -2
- package/dist/esm/time/convert/bounds.js.map +1 -1
- package/dist/esm/time/convert/exact.js +26 -1
- package/dist/esm/time/convert/exact.js.map +1 -1
- package/dist/esm/time/convert.d.ts +2 -2
- package/dist/esm/time/convert.js +2 -2
- 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/convert/bounds.js +18 -2
- package/dist/time/convert/bounds.js.map +1 -1
- package/dist/time/convert/exact.js +26 -1
- package/dist/time/convert/exact.js.map +1 -1
- package/dist/time/convert.js +2 -2
- 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/convert/bounds.d.ts.map +1 -1
- package/dist/types/time/convert/exact.d.ts.map +1 -1
- package/dist/types/time/convert.d.ts +2 -2
- 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,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* recordingParts/source — where a part's text comes from, checked against its
|
|
3
|
+
* index entry before it is handed on.
|
|
4
|
+
*
|
|
5
|
+
* Role: Adapter. Two sources behind one shape: a STORE (a scope-bound
|
|
6
|
+
* `head`/`get`) and MEMORY (the parts a whole recording was cut into on
|
|
7
|
+
* the reader's side). Both answer a part's JSON text or a fixed reason.
|
|
8
|
+
* Reads: the store, through the two verbs it is handed.
|
|
9
|
+
* Emits: N/A.
|
|
10
|
+
*
|
|
11
|
+
* ── Metadata before bytes ───────────────────────────────────────────────────
|
|
12
|
+
* The store source asks `head` first and refuses a part whose kind, media
|
|
13
|
+
* type, byte count, digest or run disagrees with the index before any `get`.
|
|
14
|
+
* After `get` it checks the ticket again, the byte count of the text, and its
|
|
15
|
+
* OWN SHA-256 of the text against the index: a store adapter that does not
|
|
16
|
+
* verify its digests cannot pass a changed part. A store failure that is not
|
|
17
|
+
* a fact about the part (busy, revoked, aborted) is thrown, never renamed.
|
|
18
|
+
*/
|
|
19
|
+
import { computeArtifactDigest } from '../../../artifacts/payload.js';
|
|
20
|
+
import { RECORDING_MEDIA_TYPE, RECORDING_PART_ARTIFACT_KIND, } from '../../../artifacts/recordingArtifact.js';
|
|
21
|
+
import { ArtifactIntegrityError } from '../../../artifacts/types.js';
|
|
22
|
+
import { utf8Length } from '../../../lib/utf8.js';
|
|
23
|
+
const decoder = new TextDecoder('utf-8', { fatal: true });
|
|
24
|
+
/**
|
|
25
|
+
* `get` the artifact `head` described, and refuse it as `changed` when the
|
|
26
|
+
* ticket `get` returns is not the one `head` returned.
|
|
27
|
+
*/
|
|
28
|
+
export async function fetchPayload(artifacts, meta, signal) {
|
|
29
|
+
let record;
|
|
30
|
+
try {
|
|
31
|
+
record = await artifacts.get(meta.ref);
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
if (err instanceof ArtifactIntegrityError)
|
|
35
|
+
return { refused: 'changed' };
|
|
36
|
+
throw err;
|
|
37
|
+
}
|
|
38
|
+
signal?.throwIfAborted();
|
|
39
|
+
if (record === null)
|
|
40
|
+
return { refused: 'missing' };
|
|
41
|
+
const got = record.meta;
|
|
42
|
+
if (got.ref !== meta.ref ||
|
|
43
|
+
got.kind !== meta.kind ||
|
|
44
|
+
got.mediaType !== meta.mediaType ||
|
|
45
|
+
got.bytes !== meta.bytes ||
|
|
46
|
+
got.digest !== meta.digest) {
|
|
47
|
+
return { refused: 'changed' };
|
|
48
|
+
}
|
|
49
|
+
const { data } = record;
|
|
50
|
+
if (typeof data === 'string')
|
|
51
|
+
return { text: data };
|
|
52
|
+
if (data instanceof Uint8Array) {
|
|
53
|
+
try {
|
|
54
|
+
return { text: decoder.decode(data) };
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return { refused: 'changed' };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return { data };
|
|
61
|
+
}
|
|
62
|
+
/** Parts held by a store, each bound to its index entry and the index's run. */
|
|
63
|
+
export function storeSource(artifacts, runId) {
|
|
64
|
+
/** `head` the entry's ref and check its ticket against the entry, before any `get`. */
|
|
65
|
+
const ticket = async (entry, signal) => {
|
|
66
|
+
signal?.throwIfAborted();
|
|
67
|
+
const meta = await artifacts.head(entry.ref);
|
|
68
|
+
signal?.throwIfAborted();
|
|
69
|
+
if (meta === null)
|
|
70
|
+
return { refused: 'missing' };
|
|
71
|
+
if (meta.ref !== entry.ref ||
|
|
72
|
+
meta.kind !== RECORDING_PART_ARTIFACT_KIND ||
|
|
73
|
+
meta.mediaType !== RECORDING_MEDIA_TYPE ||
|
|
74
|
+
meta.bytes !== entry.bytes ||
|
|
75
|
+
(meta.digest !== undefined && meta.digest !== entry.digest) ||
|
|
76
|
+
meta.origin?.runId !== runId) {
|
|
77
|
+
return { refused: 'changed' };
|
|
78
|
+
}
|
|
79
|
+
return meta;
|
|
80
|
+
};
|
|
81
|
+
return {
|
|
82
|
+
async check(entry, signal) {
|
|
83
|
+
const meta = await ticket(entry, signal);
|
|
84
|
+
return 'refused' in meta ? meta : { present: true };
|
|
85
|
+
},
|
|
86
|
+
async fetch(entry, signal) {
|
|
87
|
+
const meta = await ticket(entry, signal);
|
|
88
|
+
if ('refused' in meta)
|
|
89
|
+
return meta;
|
|
90
|
+
const got = await fetchPayload(artifacts, meta, signal);
|
|
91
|
+
if ('refused' in got)
|
|
92
|
+
return got;
|
|
93
|
+
if (!('text' in got))
|
|
94
|
+
return { refused: 'changed' };
|
|
95
|
+
if (utf8Length(got.text) !== entry.bytes)
|
|
96
|
+
return { refused: 'changed' };
|
|
97
|
+
if ((await computeArtifactDigest(got.text)) !== entry.digest)
|
|
98
|
+
return { refused: 'changed' };
|
|
99
|
+
signal?.throwIfAborted();
|
|
100
|
+
return { text: got.text };
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/** Parts cut in memory from a whole recording this reader already read and checked. */
|
|
105
|
+
export function memorySource(texts) {
|
|
106
|
+
return {
|
|
107
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
108
|
+
async fetch(entry, signal) {
|
|
109
|
+
signal?.throwIfAborted();
|
|
110
|
+
const text = texts.get(entry.digest);
|
|
111
|
+
return text === undefined ? { refused: 'missing' } : { text };
|
|
112
|
+
},
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
114
|
+
async check(entry, signal) {
|
|
115
|
+
signal?.throwIfAborted();
|
|
116
|
+
return texts.has(entry.digest) ? { present: true } : { refused: 'missing' };
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source.js","sourceRoot":"","sources":["../../../../../src/recorders/observability/recordingParts/source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EACL,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,yCAAyC,CAAC;AAC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EAAE,CAAC;QAChE,CAAC;QACD,4DAA4D;QAC5D,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM;YACvB,MAAM,EAAE,cAAc,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;QAC9E,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* recordingParts/split — one recording, cut into a base part and invocation
|
|
3
|
+
* parts of about 1 MiB, plus the index that names them.
|
|
4
|
+
*
|
|
5
|
+
* Role: Codec. Pure: no store, no events. Returns each part's JSON text with
|
|
6
|
+
* its byte count and SHA-256, and the index without the refs a store
|
|
7
|
+
* mints. The writer puts the parts first and the index last; the
|
|
8
|
+
* reader of a whole recording runs this same split in memory, so both
|
|
9
|
+
* layouts are served by one cut.
|
|
10
|
+
* Reads: its argument.
|
|
11
|
+
* Emits: N/A.
|
|
12
|
+
*
|
|
13
|
+
* ── The cut ─────────────────────────────────────────────────────────────────
|
|
14
|
+
* • The BASE part is the recording with `snapshot.subflowResults` removed
|
|
15
|
+
* (the key itself, so a reader cannot mistake it for an empty map).
|
|
16
|
+
* • Each recorded invocation's result goes into an invocation part, in the
|
|
17
|
+
* viewer's order (`invocations.ts`). A part takes results while it stays
|
|
18
|
+
* within the target; a result larger than the target is a part of its own.
|
|
19
|
+
* Results no mount reaches follow, then path aliases that are not proven.
|
|
20
|
+
* • A path alias whose JSON text equals one stored result's text is stored
|
|
21
|
+
* only as `{ name, key }`: byte equality is the proof, so nothing the
|
|
22
|
+
* whole recording held is lost.
|
|
23
|
+
*
|
|
24
|
+
* ── Determinism ─────────────────────────────────────────────────────────────
|
|
25
|
+
* Every part's text is a function of the recording, the run id and `packed`
|
|
26
|
+
* alone: fixed key order, compact JSON, the wire rule for Errors
|
|
27
|
+
* (`lib/wireJson.ts · toWireJson`). Two equal recordings give equal parts and
|
|
28
|
+
* equal digests; their indexes differ only in the refs the store mints.
|
|
29
|
+
*/
|
|
30
|
+
import { type IndexDraft } from './format.js';
|
|
31
|
+
/** One part, ready to store. */
|
|
32
|
+
export interface PartText {
|
|
33
|
+
readonly text: string;
|
|
34
|
+
/** UTF-8 bytes of `text`: what the store's `meta.bytes` must say. */
|
|
35
|
+
readonly bytes: number;
|
|
36
|
+
/** `sha-256:<hex>` over those bytes. */
|
|
37
|
+
readonly digest: string;
|
|
38
|
+
}
|
|
39
|
+
/** A recording, cut. Store `base` and `parts`, then `recordingIndexText(draft, refs)`. */
|
|
40
|
+
export interface SplitRecording {
|
|
41
|
+
readonly base: PartText;
|
|
42
|
+
readonly parts: readonly PartText[];
|
|
43
|
+
readonly draft: IndexDraft;
|
|
44
|
+
}
|
|
45
|
+
/** How to cut. */
|
|
46
|
+
export interface SplitRecordingOptions {
|
|
47
|
+
/** The run the recording is filed for: written into every part and the index. */
|
|
48
|
+
readonly runId?: string;
|
|
49
|
+
/** Pack each part on its own (`packRecording`'s codec), so any part reads alone. */
|
|
50
|
+
readonly packed?: boolean;
|
|
51
|
+
/** The part size target. Default {@link RECORDING_PART_TARGET_BYTES}. */
|
|
52
|
+
readonly targetBytes?: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Cut a live recording (`recordRun` · `toRecording()`), through the wire rule
|
|
56
|
+
* first, so the parts hold exactly the bytes the whole recording would.
|
|
57
|
+
*
|
|
58
|
+
* @throws RecordingSplitError — `unserializable`, `not-a-recording`, `over-limit`.
|
|
59
|
+
*/
|
|
60
|
+
export declare function splitRecording(recording: unknown, options?: SplitRecordingOptions): Promise<SplitRecording>;
|
|
61
|
+
/**
|
|
62
|
+
* Cut a recording that is already plain JSON data (parsed from its text).
|
|
63
|
+
*
|
|
64
|
+
* @throws RecordingSplitError — `not-a-recording`, `over-limit`.
|
|
65
|
+
*/
|
|
66
|
+
export declare function splitRecordingData(data: unknown, options?: SplitRecordingOptions): Promise<SplitRecording>;
|
|
67
|
+
/**
|
|
68
|
+
* The index's JSON text once the store has minted every ref: `refs.parts[i]`
|
|
69
|
+
* is the ref of `split.parts[i]`. Fixed key order, compact JSON.
|
|
70
|
+
*/
|
|
71
|
+
export declare function recordingIndexText(draft: IndexDraft, refs: {
|
|
72
|
+
readonly base: string;
|
|
73
|
+
readonly parts: readonly string[];
|
|
74
|
+
}): string;
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* recordingParts/split — one recording, cut into a base part and invocation
|
|
3
|
+
* parts of about 1 MiB, plus the index that names them.
|
|
4
|
+
*
|
|
5
|
+
* Role: Codec. Pure: no store, no events. Returns each part's JSON text with
|
|
6
|
+
* its byte count and SHA-256, and the index without the refs a store
|
|
7
|
+
* mints. The writer puts the parts first and the index last; the
|
|
8
|
+
* reader of a whole recording runs this same split in memory, so both
|
|
9
|
+
* layouts are served by one cut.
|
|
10
|
+
* Reads: its argument.
|
|
11
|
+
* Emits: N/A.
|
|
12
|
+
*
|
|
13
|
+
* ── The cut ─────────────────────────────────────────────────────────────────
|
|
14
|
+
* • The BASE part is the recording with `snapshot.subflowResults` removed
|
|
15
|
+
* (the key itself, so a reader cannot mistake it for an empty map).
|
|
16
|
+
* • Each recorded invocation's result goes into an invocation part, in the
|
|
17
|
+
* viewer's order (`invocations.ts`). A part takes results while it stays
|
|
18
|
+
* within the target; a result larger than the target is a part of its own.
|
|
19
|
+
* Results no mount reaches follow, then path aliases that are not proven.
|
|
20
|
+
* • A path alias whose JSON text equals one stored result's text is stored
|
|
21
|
+
* only as `{ name, key }`: byte equality is the proof, so nothing the
|
|
22
|
+
* whole recording held is lost.
|
|
23
|
+
*
|
|
24
|
+
* ── Determinism ─────────────────────────────────────────────────────────────
|
|
25
|
+
* Every part's text is a function of the recording, the run id and `packed`
|
|
26
|
+
* alone: fixed key order, compact JSON, the wire rule for Errors
|
|
27
|
+
* (`lib/wireJson.ts · toWireJson`). Two equal recordings give equal parts and
|
|
28
|
+
* equal digests; their indexes differ only in the refs the store mints.
|
|
29
|
+
*/
|
|
30
|
+
import { computeArtifactDigest } from '../../../artifacts/payload.js';
|
|
31
|
+
import { utf8Length } from '../../../lib/utf8.js';
|
|
32
|
+
import { toWireJson } from '../../../lib/wireJson.js';
|
|
33
|
+
import { RECORDING_INDEX_FORMAT, RECORDING_PARTS_LIMITS, RECORDING_PART_FORMAT, RECORDING_PART_TARGET_BYTES, assign, isName, isPlainObject, ownValue, } from './format.js';
|
|
34
|
+
import { walkRecordedInvocations } from './invocations.js';
|
|
35
|
+
import { packPart } from './packing.js';
|
|
36
|
+
import { RecordingSplitError } from './splitError.js';
|
|
37
|
+
/** A placeholder ref of the minted length, to measure an index before refs exist. */
|
|
38
|
+
const PLACEHOLDER_REF = `art_${'0'.repeat(22)}`;
|
|
39
|
+
/**
|
|
40
|
+
* Cut a live recording (`recordRun` · `toRecording()`), through the wire rule
|
|
41
|
+
* first, so the parts hold exactly the bytes the whole recording would.
|
|
42
|
+
*
|
|
43
|
+
* @throws RecordingSplitError — `unserializable`, `not-a-recording`, `over-limit`.
|
|
44
|
+
*/
|
|
45
|
+
export async function splitRecording(recording, options = {}) {
|
|
46
|
+
// The bounds first, from the iterative walk's counts, before anything
|
|
47
|
+
// recursive runs: serializing a deep tree overflows the stack at a depth that
|
|
48
|
+
// depends on the runtime, so a recording past a bound would otherwise be
|
|
49
|
+
// `unserializable` on one Node and `over-limit` on another.
|
|
50
|
+
refuseOverLimit(recording);
|
|
51
|
+
let text;
|
|
52
|
+
try {
|
|
53
|
+
text = toWireJson(recording);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
throw new RecordingSplitError('unserializable');
|
|
57
|
+
}
|
|
58
|
+
if (text === undefined)
|
|
59
|
+
throw new RecordingSplitError('unserializable');
|
|
60
|
+
return splitRecordingData(JSON.parse(text), options);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Cut a recording that is already plain JSON data (parsed from its text).
|
|
64
|
+
*
|
|
65
|
+
* @throws RecordingSplitError — `not-a-recording`, `over-limit`.
|
|
66
|
+
*/
|
|
67
|
+
export async function splitRecordingData(data, options = {}) {
|
|
68
|
+
const { runId, packed = false } = options;
|
|
69
|
+
const target = options.targetBytes ?? RECORDING_PART_TARGET_BYTES;
|
|
70
|
+
if (runId !== undefined && !isName(runId)) {
|
|
71
|
+
throw new TypeError('splitRecording: runId must be a non-empty name of at most 4096 characters.');
|
|
72
|
+
}
|
|
73
|
+
if (!Number.isSafeInteger(target) || target < 1) {
|
|
74
|
+
throw new TypeError('splitRecording: targetBytes must be a positive whole number of bytes.');
|
|
75
|
+
}
|
|
76
|
+
if (!isPlainObject(data) || !Array.isArray(ownValue(data, 'events'))) {
|
|
77
|
+
throw new RecordingSplitError('not-a-recording');
|
|
78
|
+
}
|
|
79
|
+
const snapshot = ownValue(data, 'snapshot');
|
|
80
|
+
const walk = walkRecordedInvocations(snapshot);
|
|
81
|
+
const entry = (slot, key, value) => {
|
|
82
|
+
const text = serialize(() => toWireJson(value));
|
|
83
|
+
return { slot, key, value, text, bytes: utf8Length(text) };
|
|
84
|
+
};
|
|
85
|
+
const results = [];
|
|
86
|
+
for (const invocation of walk.invocations) {
|
|
87
|
+
if ('result' in invocation)
|
|
88
|
+
results.push(entry('results', invocation.key, invocation.result));
|
|
89
|
+
}
|
|
90
|
+
for (const { key, result } of walk.unmounted)
|
|
91
|
+
results.push(entry('results', key, result));
|
|
92
|
+
const byText = new Map();
|
|
93
|
+
for (const result of results)
|
|
94
|
+
if (!byText.has(result.text))
|
|
95
|
+
byText.set(result.text, result.key);
|
|
96
|
+
const proven = new Map();
|
|
97
|
+
const stored = [...results];
|
|
98
|
+
for (const { name, value } of walk.aliases) {
|
|
99
|
+
const candidate = entry('aliases', name, value);
|
|
100
|
+
const key = byText.get(candidate.text);
|
|
101
|
+
if (key !== undefined)
|
|
102
|
+
proven.set(name, key);
|
|
103
|
+
else
|
|
104
|
+
stored.push(candidate);
|
|
105
|
+
}
|
|
106
|
+
// Group: whole entries only, in order, each part within the target unless one entry is larger.
|
|
107
|
+
const groups = [];
|
|
108
|
+
let current = [];
|
|
109
|
+
let size = 0;
|
|
110
|
+
for (const item of stored) {
|
|
111
|
+
const cost = utf8Length(toWireJson(item.key)) + item.bytes + 2;
|
|
112
|
+
if (current.length > 0 && size + cost > target) {
|
|
113
|
+
groups.push(current);
|
|
114
|
+
current = [];
|
|
115
|
+
size = 0;
|
|
116
|
+
}
|
|
117
|
+
current.push(item);
|
|
118
|
+
size += cost;
|
|
119
|
+
}
|
|
120
|
+
if (current.length > 0)
|
|
121
|
+
groups.push(current);
|
|
122
|
+
if (groups.length > RECORDING_PARTS_LIMITS.parts) {
|
|
123
|
+
throw new RecordingSplitError('over-limit', 'parts');
|
|
124
|
+
}
|
|
125
|
+
const partOf = new Map();
|
|
126
|
+
groups.forEach((group, at) => {
|
|
127
|
+
for (const item of group)
|
|
128
|
+
if (item.slot === 'results')
|
|
129
|
+
partOf.set(item.key, at);
|
|
130
|
+
});
|
|
131
|
+
const aliasPart = new Map();
|
|
132
|
+
groups.forEach((group, at) => {
|
|
133
|
+
for (const item of group)
|
|
134
|
+
if (item.slot === 'aliases')
|
|
135
|
+
aliasPart.set(item.key, at);
|
|
136
|
+
});
|
|
137
|
+
const resultBytes = new Map(results.map((item) => [item.key, item.bytes]));
|
|
138
|
+
const head = (part) => `{"format":${toWireJson(RECORDING_PART_FORMAT)}` +
|
|
139
|
+
(runId !== undefined ? `,"runId":${toWireJson(runId)}` : '') +
|
|
140
|
+
`,"part":${toWireJson(part)}`;
|
|
141
|
+
const partTexts = groups.map((group, at) => {
|
|
142
|
+
const slot = (name) => group.filter((item) => item.slot === name);
|
|
143
|
+
if (packed) {
|
|
144
|
+
const fold = (items) => {
|
|
145
|
+
const out = {};
|
|
146
|
+
for (const item of items)
|
|
147
|
+
assign(out, item.key, item.value);
|
|
148
|
+
return out;
|
|
149
|
+
};
|
|
150
|
+
return serialize(() => toWireJson(packPart({
|
|
151
|
+
format: RECORDING_PART_FORMAT,
|
|
152
|
+
...(runId !== undefined && { runId }),
|
|
153
|
+
part: at,
|
|
154
|
+
results: fold(slot('results')),
|
|
155
|
+
aliases: fold(slot('aliases')),
|
|
156
|
+
})));
|
|
157
|
+
}
|
|
158
|
+
const members = (items) => items.map((item) => `${toWireJson(item.key)}:${item.text}`).join(',');
|
|
159
|
+
return `${head(at)},"results":{${members(slot('results'))}},"aliases":{${members(slot('aliases'))}}}`;
|
|
160
|
+
});
|
|
161
|
+
const basePayload = {
|
|
162
|
+
format: RECORDING_PART_FORMAT,
|
|
163
|
+
...(runId !== undefined && { runId }),
|
|
164
|
+
part: 'base',
|
|
165
|
+
recording: withoutResults(data, snapshot),
|
|
166
|
+
};
|
|
167
|
+
const baseText = serialize(() => toWireJson(packed ? packPart(basePayload) : basePayload));
|
|
168
|
+
const withDigest = async (text) => ({
|
|
169
|
+
text,
|
|
170
|
+
bytes: utf8Length(text),
|
|
171
|
+
digest: await computeArtifactDigest(text),
|
|
172
|
+
});
|
|
173
|
+
const base = await withDigest(baseText);
|
|
174
|
+
const parts = [];
|
|
175
|
+
for (const text of partTexts)
|
|
176
|
+
parts.push(await withDigest(text));
|
|
177
|
+
const invocations = walk.invocations.map((invocation) => {
|
|
178
|
+
const part = partOf.get(invocation.key);
|
|
179
|
+
return part === undefined
|
|
180
|
+
? { key: invocation.key, path: invocation.path, subflowId: invocation.subflowId, part: null }
|
|
181
|
+
: {
|
|
182
|
+
key: invocation.key,
|
|
183
|
+
path: invocation.path,
|
|
184
|
+
subflowId: invocation.subflowId,
|
|
185
|
+
part,
|
|
186
|
+
bytes: resultBytes.get(invocation.key),
|
|
187
|
+
};
|
|
188
|
+
});
|
|
189
|
+
const unmounted = walk.unmounted.map(({ key }) => ({
|
|
190
|
+
key,
|
|
191
|
+
part: partOf.get(key),
|
|
192
|
+
}));
|
|
193
|
+
const aliases = walk.aliases.map(({ name }) => {
|
|
194
|
+
const key = proven.get(name);
|
|
195
|
+
return key !== undefined ? { name, key } : { name, part: aliasPart.get(name) };
|
|
196
|
+
});
|
|
197
|
+
const draft = {
|
|
198
|
+
...(runId !== undefined && { runId }),
|
|
199
|
+
...(walk.snapshotRunId !== undefined && { snapshotRunId: walk.snapshotRunId }),
|
|
200
|
+
packed,
|
|
201
|
+
complete: walk.complete,
|
|
202
|
+
hasSubflowResults: walk.hasSubflowResults,
|
|
203
|
+
base: { bytes: base.bytes, digest: base.digest },
|
|
204
|
+
parts: parts.map((part, at) => ({
|
|
205
|
+
bytes: part.bytes,
|
|
206
|
+
digest: part.digest,
|
|
207
|
+
results: groups[at].filter((item) => item.slot === 'results').length,
|
|
208
|
+
})),
|
|
209
|
+
invocations,
|
|
210
|
+
aliases,
|
|
211
|
+
unmounted,
|
|
212
|
+
};
|
|
213
|
+
const measured = recordingIndexText(draft, {
|
|
214
|
+
base: PLACEHOLDER_REF,
|
|
215
|
+
parts: parts.map(() => PLACEHOLDER_REF),
|
|
216
|
+
});
|
|
217
|
+
if (utf8Length(measured) > RECORDING_PARTS_LIMITS.indexBytes) {
|
|
218
|
+
throw new RecordingSplitError('over-limit', 'index');
|
|
219
|
+
}
|
|
220
|
+
return { base, parts, draft };
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* The index's JSON text once the store has minted every ref: `refs.parts[i]`
|
|
224
|
+
* is the ref of `split.parts[i]`. Fixed key order, compact JSON.
|
|
225
|
+
*/
|
|
226
|
+
export function recordingIndexText(draft, refs) {
|
|
227
|
+
if (refs.parts.length !== draft.parts.length) {
|
|
228
|
+
throw new TypeError('recordingIndexText: one ref per part is required.');
|
|
229
|
+
}
|
|
230
|
+
const index = {
|
|
231
|
+
format: RECORDING_INDEX_FORMAT,
|
|
232
|
+
...(draft.runId !== undefined && { runId: draft.runId }),
|
|
233
|
+
...(draft.snapshotRunId !== undefined && { snapshotRunId: draft.snapshotRunId }),
|
|
234
|
+
packed: draft.packed,
|
|
235
|
+
complete: draft.complete,
|
|
236
|
+
hasSubflowResults: draft.hasSubflowResults,
|
|
237
|
+
base: { ref: refs.base, bytes: draft.base.bytes, digest: draft.base.digest },
|
|
238
|
+
parts: draft.parts.map((part, at) => ({
|
|
239
|
+
ref: refs.parts[at],
|
|
240
|
+
bytes: part.bytes,
|
|
241
|
+
digest: part.digest,
|
|
242
|
+
results: part.results,
|
|
243
|
+
})),
|
|
244
|
+
invocations: draft.invocations.map((invocation) => invocation.part === null
|
|
245
|
+
? {
|
|
246
|
+
key: invocation.key,
|
|
247
|
+
path: invocation.path,
|
|
248
|
+
subflowId: invocation.subflowId,
|
|
249
|
+
part: null,
|
|
250
|
+
}
|
|
251
|
+
: {
|
|
252
|
+
key: invocation.key,
|
|
253
|
+
path: invocation.path,
|
|
254
|
+
subflowId: invocation.subflowId,
|
|
255
|
+
part: invocation.part,
|
|
256
|
+
bytes: invocation.bytes,
|
|
257
|
+
}),
|
|
258
|
+
aliases: draft.aliases.map((alias) => 'key' in alias
|
|
259
|
+
? { name: alias.name, key: alias.key }
|
|
260
|
+
: { name: alias.name, part: alias.part }),
|
|
261
|
+
unmounted: draft.unmounted.map(({ key, part }) => ({ key, part })),
|
|
262
|
+
};
|
|
263
|
+
return toWireJson(index);
|
|
264
|
+
}
|
|
265
|
+
/** The recording with the snapshot's `subflowResults` key removed; every other key in place. */
|
|
266
|
+
function withoutResults(data, snapshot) {
|
|
267
|
+
const out = {};
|
|
268
|
+
for (const key of Object.keys(data)) {
|
|
269
|
+
const value = ownValue(data, key);
|
|
270
|
+
if (key === 'snapshot' && isPlainObject(snapshot)) {
|
|
271
|
+
const stripped = {};
|
|
272
|
+
for (const field of Object.keys(snapshot)) {
|
|
273
|
+
if (field !== 'subflowResults')
|
|
274
|
+
assign(stripped, field, ownValue(snapshot, field));
|
|
275
|
+
}
|
|
276
|
+
assign(out, key, stripped);
|
|
277
|
+
}
|
|
278
|
+
else
|
|
279
|
+
assign(out, key, value);
|
|
280
|
+
}
|
|
281
|
+
return out;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Write one value as JSON, or refuse the recording as `unserializable`: the one
|
|
285
|
+
* boundary where a value too deep for the serializer's stack (a `RangeError`)
|
|
286
|
+
* or one JSON cannot carry becomes a reason instead of an escaping error.
|
|
287
|
+
*/
|
|
288
|
+
function serialize(write) {
|
|
289
|
+
let text;
|
|
290
|
+
try {
|
|
291
|
+
text = write();
|
|
292
|
+
}
|
|
293
|
+
catch {
|
|
294
|
+
throw new RecordingSplitError('unserializable');
|
|
295
|
+
}
|
|
296
|
+
if (text === undefined)
|
|
297
|
+
throw new RecordingSplitError('unserializable');
|
|
298
|
+
return text;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Throw the walk's `over-limit` refusal for the live recording, if it has one.
|
|
302
|
+
* Only the bounds are decided here: any other verdict (a shape the walk cannot
|
|
303
|
+
* read before the wire rule has run) is left to the walk over the wire form.
|
|
304
|
+
*/
|
|
305
|
+
function refuseOverLimit(recording) {
|
|
306
|
+
if (!isPlainObject(recording))
|
|
307
|
+
return;
|
|
308
|
+
try {
|
|
309
|
+
walkRecordedInvocations(ownValue(recording, 'snapshot'));
|
|
310
|
+
}
|
|
311
|
+
catch (err) {
|
|
312
|
+
if (err instanceof RecordingSplitError && err.code === 'over-limit')
|
|
313
|
+
throw err;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
//# sourceMappingURL=split.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split.js","sourceRoot":"","sources":["../../../../../src/recorders/observability/recordingParts/split.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,M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,KAAK,EAAE,CAAC;IACjB,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IAClD,CAAC;IACD,IAAI,IAAI,KAAK,SAAS;QAAE,MAAM,IAAI,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IACxE,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,SAAS,eAAe,CAAC,SAAkB;IACzC,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC;QAAE,OAAO;IACtC,IAAI,CAAC;QACH,uBAAuB,CAAC,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;IAC3D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,mBAAmB,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY;YAAE,MAAM,GAAG,CAAC;IACjF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* recordingParts/splitError — why a recording could not be split into parts.
|
|
3
|
+
*
|
|
4
|
+
* A fixed code and, past a bound, which bound. The message is a fixed
|
|
5
|
+
* sentence: it never quotes a key, a name or a recorded value, so a caller can
|
|
6
|
+
* put it on a record that other people read.
|
|
7
|
+
*/
|
|
8
|
+
/** Why a split was refused. */
|
|
9
|
+
export type RecordingSplitErrorCode = 'not-a-recording' | 'unserializable' | 'over-limit';
|
|
10
|
+
/** Which bound an `over-limit` split passed. */
|
|
11
|
+
export type RecordingSplitLimit = 'invocations' | 'parts' | 'index' | 'path' | 'tree' | 'name';
|
|
12
|
+
/** Raised by the split: nothing is stored for a recording it refuses. */
|
|
13
|
+
export declare class RecordingSplitError extends Error {
|
|
14
|
+
readonly code: RecordingSplitErrorCode;
|
|
15
|
+
readonly limit?: RecordingSplitLimit;
|
|
16
|
+
constructor(code: RecordingSplitErrorCode, limit?: RecordingSplitLimit);
|
|
17
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* recordingParts/splitError — why a recording could not be split into parts.
|
|
3
|
+
*
|
|
4
|
+
* A fixed code and, past a bound, which bound. The message is a fixed
|
|
5
|
+
* sentence: it never quotes a key, a name or a recorded value, so a caller can
|
|
6
|
+
* put it on a record that other people read.
|
|
7
|
+
*/
|
|
8
|
+
const SENTENCES = {
|
|
9
|
+
'not-a-recording': 'The value is not a recording: it needs an events array, and a snapshot whose subflowResults, when present, is an object.',
|
|
10
|
+
unserializable: 'The recording could not be written as JSON.',
|
|
11
|
+
'over-limit': 'The recording is larger than a saved recording in parts may be',
|
|
12
|
+
};
|
|
13
|
+
/** Raised by the split: nothing is stored for a recording it refuses. */
|
|
14
|
+
export class RecordingSplitError extends Error {
|
|
15
|
+
code;
|
|
16
|
+
limit;
|
|
17
|
+
constructor(code, limit) {
|
|
18
|
+
super(code === 'over-limit' && limit !== undefined
|
|
19
|
+
? `${SENTENCES[code]} (limit: ${limit}).`
|
|
20
|
+
: SENTENCES[code]);
|
|
21
|
+
this.name = 'RecordingSplitError';
|
|
22
|
+
this.code = code;
|
|
23
|
+
if (limit !== undefined)
|
|
24
|
+
this.limit = limit;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=splitError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"splitError.js","sourceRoot":"","sources":["../../../../../src/recorders/observability/recordingParts/splitError.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,MAAM,SAAS,GAAsD;IACnE,iBAAiB,EACf,0HAA0H;IAC5H,cAAc,EAAE,6CAA6C;IAC7D,YAAY,EAAE,gEAAgE;CAC/E,CAAC;AAEF,yEAAyE;AACzE,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACnC,IAAI,CAA0B;IAC9B,KAAK,CAAuB;IAErC,YAAY,IAA6B,EAAE,KAA2B;QACpE,KAAK,CACH,IAAI,KAAK,YAAY,IAAI,KAAK,KAAK,SAAS;YAC1C,CAAC,CAAC,GAAG,SAAS,CAAC,IAAI,CAAC,YAAY,KAAK,IAAI;YACzC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CACpB,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,KAAK,KAAK,SAAS;YAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -86,6 +86,13 @@ function readBound(value, which, as, edge, zone) {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
+
/** The half-open end an inclusive ISO bound names on its written grid; none when it is written past the millisecond. */
|
|
90
|
+
function gridEnd(value) {
|
|
91
|
+
const at = instantOf(value, 'strict');
|
|
92
|
+
if (at === undefined || at.nanos !== 0)
|
|
93
|
+
return undefined;
|
|
94
|
+
return at.ms + (at.precision === 'minute' ? 60_000 : at.precision === 'second' ? 1_000 : 1);
|
|
95
|
+
}
|
|
89
96
|
/** Read each bound on its own declared grid, with ISO cutoffs as exact points when confirmed. */
|
|
90
97
|
function readPeriodBounds(lower, upper, edge, zone, precise) {
|
|
91
98
|
if (precise === true && (lower.as === 'iso' || upper.as === 'iso')) {
|
|
@@ -93,8 +100,17 @@ function readPeriodBounds(lower, upper, edge, zone, precise) {
|
|
|
93
100
|
const from = lower.as === 'iso'
|
|
94
101
|
? lower.value
|
|
95
102
|
: atUtc(readBound(lower.value, 'from', lower.as, 'inclusive', zone));
|
|
96
|
-
|
|
97
|
-
|
|
103
|
+
// An inclusive ISO end a TOOL FORM carries is the last instant inside on the grid it was
|
|
104
|
+
// written at (minute, second, millisecond — the pre-18 wire law, which tool parsers were
|
|
105
|
+
// built against); only one written past the millisecond is an exact point.
|
|
106
|
+
const onGrid = upper.as === 'iso' && edge === 'inclusive' ? gridEnd(upper.value) : undefined;
|
|
107
|
+
const to = onGrid !== undefined
|
|
108
|
+
? atUtc(onGrid)
|
|
109
|
+
: upper.as === 'iso'
|
|
110
|
+
? upper.value
|
|
111
|
+
: atUtc(readBound(upper.value, 'to', upper.as, edge, zone));
|
|
112
|
+
const end = upper.as === 'iso' && onGrid === undefined ? edge : 'exclusive';
|
|
113
|
+
const window = readControlWindow({ from, to, end });
|
|
98
114
|
return window === undefined ? undefined : { from: window.from, to: window.to };
|
|
99
115
|
}
|
|
100
116
|
const from = readBound(lower.value, 'from', lower.as, 'inclusive', zone);
|