agentfootprint 11.0.0 → 11.1.1
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 +2 -0
- package/dist/adapters/observability/cloudwatch.js +101 -110
- package/dist/adapters/observability/cloudwatch.js.map +1 -1
- package/dist/adapters/observability/file.js +48 -71
- package/dist/adapters/observability/file.js.map +1 -1
- package/dist/adapters/observability/outbox.js +217 -0
- package/dist/adapters/observability/outbox.js.map +1 -0
- package/dist/adapters/observability/xray.js +56 -70
- package/dist/adapters/observability/xray.js.map +1 -1
- package/dist/debug.js +5 -3
- package/dist/debug.js.map +1 -1
- package/dist/esm/adapters/observability/cloudwatch.d.ts +6 -2
- package/dist/esm/adapters/observability/cloudwatch.js +101 -110
- package/dist/esm/adapters/observability/cloudwatch.js.map +1 -1
- package/dist/esm/adapters/observability/file.d.ts +8 -4
- package/dist/esm/adapters/observability/file.js +48 -71
- package/dist/esm/adapters/observability/file.js.map +1 -1
- package/dist/esm/adapters/observability/outbox.d.ts +104 -0
- package/dist/esm/adapters/observability/outbox.js +213 -0
- package/dist/esm/adapters/observability/outbox.js.map +1 -0
- package/dist/esm/adapters/observability/xray.js +56 -70
- package/dist/esm/adapters/observability/xray.js.map +1 -1
- package/dist/esm/debug.d.ts +1 -1
- package/dist/esm/debug.js +1 -1
- package/dist/esm/debug.js.map +1 -1
- package/dist/esm/lib/boundedJson.d.ts +1 -1
- package/dist/esm/lib/boundedJson.js +4 -2
- package/dist/esm/lib/boundedJson.js.map +1 -1
- package/dist/esm/trace-toolpack/causeCapture.d.ts +5 -2
- package/dist/esm/trace-toolpack/causeCapture.js +32 -18
- package/dist/esm/trace-toolpack/causeCapture.js.map +1 -1
- package/dist/esm/trace-toolpack/causeContext.d.ts +14 -0
- package/dist/esm/trace-toolpack/causeContext.js +14 -0
- package/dist/esm/trace-toolpack/causeContext.js.map +1 -0
- package/dist/esm/trace-toolpack/causeProjection.d.ts +17 -0
- package/dist/esm/trace-toolpack/causeProjection.js +72 -0
- package/dist/esm/trace-toolpack/causeProjection.js.map +1 -0
- package/dist/esm/trace-toolpack/causeReader.d.ts +2 -3
- package/dist/esm/trace-toolpack/causeReader.js +21 -13
- package/dist/esm/trace-toolpack/causeReader.js.map +1 -1
- package/dist/esm/trace-toolpack/causeResponse.d.ts +5 -2
- package/dist/esm/trace-toolpack/causeResponse.js +26 -9
- package/dist/esm/trace-toolpack/causeResponse.js.map +1 -1
- package/dist/esm/trace-toolpack/causeSnapshot.d.ts +2 -8
- package/dist/esm/trace-toolpack/causeSnapshot.js +3 -63
- package/dist/esm/trace-toolpack/causeSnapshot.js.map +1 -1
- package/dist/esm/trace-toolpack/causeTools.d.ts +8 -1
- package/dist/esm/trace-toolpack/causeTools.js +33 -10
- package/dist/esm/trace-toolpack/causeTools.js.map +1 -1
- package/dist/esm/trace-toolpack/index.d.ts +3 -0
- package/dist/esm/trace-toolpack/index.js +2 -0
- package/dist/esm/trace-toolpack/index.js.map +1 -1
- package/dist/esm/trace-toolpack/storedCause.d.ts +8 -0
- package/dist/esm/trace-toolpack/storedCause.js +58 -0
- package/dist/esm/trace-toolpack/storedCause.js.map +1 -0
- package/dist/esm/trace-toolpack/storedCauseBinding.d.ts +16 -0
- package/dist/esm/trace-toolpack/storedCauseBinding.js +50 -0
- package/dist/esm/trace-toolpack/storedCauseBinding.js.map +1 -0
- package/dist/esm/trace-toolpack/storedCauseOptions.d.ts +5 -0
- package/dist/esm/trace-toolpack/storedCauseOptions.js +53 -0
- package/dist/esm/trace-toolpack/storedCauseOptions.js.map +1 -0
- package/dist/esm/trace-toolpack/storedCauseProjection.d.ts +3 -0
- package/dist/esm/trace-toolpack/storedCauseProjection.js +117 -0
- package/dist/esm/trace-toolpack/storedCauseProjection.js.map +1 -0
- package/dist/esm/trace-toolpack/storedCauseReader.d.ts +3 -0
- package/dist/esm/trace-toolpack/storedCauseReader.js +9 -0
- package/dist/esm/trace-toolpack/storedCauseReader.js.map +1 -0
- package/dist/esm/trace-toolpack/storedCauseSources.d.ts +8 -0
- package/dist/esm/trace-toolpack/storedCauseSources.js +28 -0
- package/dist/esm/trace-toolpack/storedCauseSources.js.map +1 -0
- package/dist/esm/trace-toolpack/storedCauseTypes.d.ts +48 -0
- package/dist/esm/trace-toolpack/storedCauseTypes.js +2 -0
- package/dist/esm/trace-toolpack/storedCauseTypes.js.map +1 -0
- package/dist/esm/trace-toolpack/traceToolpack.js +18 -0
- package/dist/esm/trace-toolpack/traceToolpack.js.map +1 -1
- package/dist/lib/boundedJson.js +4 -2
- package/dist/lib/boundedJson.js.map +1 -1
- package/dist/trace-toolpack/causeCapture.js +35 -20
- package/dist/trace-toolpack/causeCapture.js.map +1 -1
- package/dist/trace-toolpack/causeContext.js +18 -0
- package/dist/trace-toolpack/causeContext.js.map +1 -0
- package/dist/trace-toolpack/causeProjection.js +76 -0
- package/dist/trace-toolpack/causeProjection.js.map +1 -0
- package/dist/trace-toolpack/causeReader.js +21 -13
- package/dist/trace-toolpack/causeReader.js.map +1 -1
- package/dist/trace-toolpack/causeResponse.js +26 -9
- package/dist/trace-toolpack/causeResponse.js.map +1 -1
- package/dist/trace-toolpack/causeSnapshot.js +3 -63
- package/dist/trace-toolpack/causeSnapshot.js.map +1 -1
- package/dist/trace-toolpack/causeTools.js +36 -12
- package/dist/trace-toolpack/causeTools.js.map +1 -1
- package/dist/trace-toolpack/index.js +5 -1
- package/dist/trace-toolpack/index.js.map +1 -1
- package/dist/trace-toolpack/storedCause.js +85 -0
- package/dist/trace-toolpack/storedCause.js.map +1 -0
- package/dist/trace-toolpack/storedCauseBinding.js +55 -0
- package/dist/trace-toolpack/storedCauseBinding.js.map +1 -0
- package/dist/trace-toolpack/storedCauseOptions.js +58 -0
- package/dist/trace-toolpack/storedCauseOptions.js.map +1 -0
- package/dist/trace-toolpack/storedCauseProjection.js +121 -0
- package/dist/trace-toolpack/storedCauseProjection.js.map +1 -0
- package/dist/trace-toolpack/storedCauseReader.js +35 -0
- package/dist/trace-toolpack/storedCauseReader.js.map +1 -0
- package/dist/trace-toolpack/storedCauseSources.js +32 -0
- package/dist/trace-toolpack/storedCauseSources.js.map +1 -0
- package/dist/trace-toolpack/storedCauseTypes.js +3 -0
- package/dist/trace-toolpack/storedCauseTypes.js.map +1 -0
- package/dist/trace-toolpack/traceToolpack.js +18 -0
- package/dist/trace-toolpack/traceToolpack.js.map +1 -1
- package/dist/types/adapters/observability/cloudwatch.d.ts +6 -2
- package/dist/types/adapters/observability/cloudwatch.d.ts.map +1 -1
- package/dist/types/adapters/observability/file.d.ts +8 -4
- package/dist/types/adapters/observability/file.d.ts.map +1 -1
- package/dist/types/adapters/observability/outbox.d.ts +105 -0
- package/dist/types/adapters/observability/outbox.d.ts.map +1 -0
- package/dist/types/adapters/observability/xray.d.ts.map +1 -1
- package/dist/types/debug.d.ts +1 -1
- package/dist/types/debug.d.ts.map +1 -1
- package/dist/types/lib/boundedJson.d.ts +1 -1
- package/dist/types/lib/boundedJson.d.ts.map +1 -1
- package/dist/types/trace-toolpack/causeCapture.d.ts +5 -2
- package/dist/types/trace-toolpack/causeCapture.d.ts.map +1 -1
- package/dist/types/trace-toolpack/causeContext.d.ts +15 -0
- package/dist/types/trace-toolpack/causeContext.d.ts.map +1 -0
- package/dist/types/trace-toolpack/causeProjection.d.ts +18 -0
- package/dist/types/trace-toolpack/causeProjection.d.ts.map +1 -0
- package/dist/types/trace-toolpack/causeReader.d.ts +2 -3
- package/dist/types/trace-toolpack/causeReader.d.ts.map +1 -1
- package/dist/types/trace-toolpack/causeResponse.d.ts +5 -2
- package/dist/types/trace-toolpack/causeResponse.d.ts.map +1 -1
- package/dist/types/trace-toolpack/causeSnapshot.d.ts +2 -8
- package/dist/types/trace-toolpack/causeSnapshot.d.ts.map +1 -1
- package/dist/types/trace-toolpack/causeTools.d.ts +8 -1
- package/dist/types/trace-toolpack/causeTools.d.ts.map +1 -1
- package/dist/types/trace-toolpack/index.d.ts +3 -0
- package/dist/types/trace-toolpack/index.d.ts.map +1 -1
- package/dist/types/trace-toolpack/storedCause.d.ts +9 -0
- package/dist/types/trace-toolpack/storedCause.d.ts.map +1 -0
- package/dist/types/trace-toolpack/storedCauseBinding.d.ts +17 -0
- package/dist/types/trace-toolpack/storedCauseBinding.d.ts.map +1 -0
- package/dist/types/trace-toolpack/storedCauseOptions.d.ts +6 -0
- package/dist/types/trace-toolpack/storedCauseOptions.d.ts.map +1 -0
- package/dist/types/trace-toolpack/storedCauseProjection.d.ts +4 -0
- package/dist/types/trace-toolpack/storedCauseProjection.d.ts.map +1 -0
- package/dist/types/trace-toolpack/storedCauseReader.d.ts +4 -0
- package/dist/types/trace-toolpack/storedCauseReader.d.ts.map +1 -0
- package/dist/types/trace-toolpack/storedCauseSources.d.ts +9 -0
- package/dist/types/trace-toolpack/storedCauseSources.d.ts.map +1 -0
- package/dist/types/trace-toolpack/storedCauseTypes.d.ts +49 -0
- package/dist/types/trace-toolpack/storedCauseTypes.d.ts.map +1 -0
- package/dist/types/trace-toolpack/traceToolpack.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -9,13 +9,13 @@ export function captureOwn(object, key) {
|
|
|
9
9
|
throw new TypeError('cause tools: invalid capture metadata');
|
|
10
10
|
return field.value;
|
|
11
11
|
}
|
|
12
|
-
export function captureAssessment(reason) {
|
|
12
|
+
export function captureAssessment(reason, readSources = 'not-collected') {
|
|
13
13
|
return {
|
|
14
14
|
status: reason === 'captured-root-log' ? 'admitted' : 'incomplete',
|
|
15
15
|
reason,
|
|
16
16
|
scope: 'root-log',
|
|
17
17
|
persistence: 'memory-only',
|
|
18
|
-
readSources
|
|
18
|
+
readSources,
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
const BASE_LIMITATIONS = new Set([
|
|
@@ -27,18 +27,28 @@ const BASE_LIMITATIONS = new Set([
|
|
|
27
27
|
]);
|
|
28
28
|
/** Admit only the native root/current-leg contract. This is not an authenticity or storage check. */
|
|
29
29
|
export function assessCapture(snapshot, commits) {
|
|
30
|
+
return assessCapturePolicy(snapshot, commits, 'not-collected');
|
|
31
|
+
}
|
|
32
|
+
/** Saved-only: the public producer reader has separately admitted source ownership. */
|
|
33
|
+
export function assessSourceCapture(snapshot, commits, sources) {
|
|
34
|
+
return assessCapturePolicy(snapshot, commits, sources);
|
|
35
|
+
}
|
|
36
|
+
function assessCapturePolicy(snapshot, commits, sources) {
|
|
37
|
+
const assessment = (reason) => captureAssessment(reason, sources);
|
|
38
|
+
const exact = sources !== 'not-collected';
|
|
30
39
|
try {
|
|
31
40
|
const note = captureOwn(snapshot, 'capture');
|
|
32
41
|
if (note === undefined)
|
|
33
|
-
return
|
|
34
|
-
if (captureOwn(note, 'version') !==
|
|
35
|
-
|
|
42
|
+
return assessment('missing-attestation');
|
|
43
|
+
if (captureOwn(note, 'version') !== (exact ? 2 : 1) ||
|
|
44
|
+
captureOwn(note, 'persistence') !== 'memory-only')
|
|
45
|
+
return assessment('invalid-attestation');
|
|
36
46
|
const runId = captureOwn(snapshot, 'runId');
|
|
37
47
|
if (typeof runId !== 'string' ||
|
|
38
48
|
runId.length === 0 ||
|
|
39
49
|
runId.length > 128 ||
|
|
40
50
|
captureOwn(note, 'runId') !== runId)
|
|
41
|
-
return
|
|
51
|
+
return assessment('run-mismatch');
|
|
42
52
|
const address = captureAddress(captureOwn(snapshot, 'logAddress'));
|
|
43
53
|
const covered = captureAddress(captureOwn(note, 'logAddress'));
|
|
44
54
|
if (captureOwn(note, 'scope') !== 'root-log' ||
|
|
@@ -46,12 +56,12 @@ export function assessCapture(snapshot, commits) {
|
|
|
46
56
|
!covered ||
|
|
47
57
|
address.logRunId !== runId ||
|
|
48
58
|
covered.logRunId !== address.logRunId)
|
|
49
|
-
return
|
|
59
|
+
return assessment('scope-not-covered');
|
|
50
60
|
const extent = captureOwn(note, 'commits');
|
|
51
61
|
if (captureOwn(extent, 'from') !== 0 || captureOwn(extent, 'to') !== commits)
|
|
52
|
-
return
|
|
62
|
+
return assessment('incomplete-extent');
|
|
53
63
|
if (captureOwn(captureOwn(note, 'boundary'), 'status') !== 'completed')
|
|
54
|
-
return
|
|
64
|
+
return assessment('run-not-completed');
|
|
55
65
|
const modes = captureOwn(note, 'modes');
|
|
56
66
|
const values = captureOwn(modes, 'commitValues');
|
|
57
67
|
if (captureOwn(modes, 'readTracking') !== 'full' ||
|
|
@@ -60,25 +70,29 @@ export function assessCapture(snapshot, commits) {
|
|
|
60
70
|
values !== captureOwn(snapshot, 'commitValues') ||
|
|
61
71
|
captureOwn(modes, 'writeProvenance') !== 'reads-prefix' ||
|
|
62
72
|
captureOwn(snapshot, 'writeProvenance') !== 'reads-prefix')
|
|
63
|
-
return
|
|
73
|
+
return assessment('modes-not-supported');
|
|
64
74
|
const channels = captureOwn(note, 'channels');
|
|
65
75
|
if (!['reads', 'writes', 'attention', 'control'].every((channel) => captureOwn(channels, channel) === 'captured') ||
|
|
66
|
-
captureOwn(channels, 'readSources') !==
|
|
67
|
-
|
|
76
|
+
captureOwn(channels, 'readSources') !== sources ||
|
|
77
|
+
(exact && sources !== 'captured'))
|
|
78
|
+
return assessment('channel-not-captured');
|
|
68
79
|
const limits = captureOwn(note, 'limitations');
|
|
69
|
-
|
|
70
|
-
|
|
80
|
+
const expected = exact
|
|
81
|
+
? new Set([...BASE_LIMITATIONS].filter((limit) => limit !== 'read-sources-not-collected'))
|
|
82
|
+
: BASE_LIMITATIONS;
|
|
83
|
+
if (!Array.isArray(limits) || limits.length !== expected.size)
|
|
84
|
+
return assessment('capture-limited');
|
|
71
85
|
const seen = new Set();
|
|
72
86
|
for (let index = 0; index < limits.length; index++) {
|
|
73
87
|
const limit = captureOwn(limits, String(index));
|
|
74
|
-
if (typeof limit !== 'string' || !
|
|
75
|
-
return
|
|
88
|
+
if (typeof limit !== 'string' || !expected.has(limit) || seen.has(limit))
|
|
89
|
+
return assessment('capture-limited');
|
|
76
90
|
seen.add(limit);
|
|
77
91
|
}
|
|
78
|
-
return
|
|
92
|
+
return assessment('captured-root-log');
|
|
79
93
|
}
|
|
80
94
|
catch {
|
|
81
|
-
return
|
|
95
|
+
return assessment('invalid-attestation');
|
|
82
96
|
}
|
|
83
97
|
}
|
|
84
98
|
/** Root notes never authorize a child address, or a synthetic snapshot namespace. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"causeCapture.js","sourceRoot":"","sources":["../../../src/trace-toolpack/causeCapture.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"causeCapture.js","sourceRoot":"","sources":["../../../src/trace-toolpack/causeCapture.ts"],"names":[],"mappings":"AA2BA,+EAA+E;AAC/E,MAAM,UAAU,UAAU,CAAC,MAAe,EAAE,GAAW;IACrD,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IACpE,MAAM,KAAK,GAAG,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3D,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,IAAI,CAAC,CAAC,OAAO,IAAI,KAAK,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,uCAAuC,CAAC,CAAC;IACtF,OAAO,KAAK,CAAC,KAAK,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,MAAqB,EACrB,cAA8C,eAAe;IAE7D,OAAO;QACL,MAAM,EAAE,MAAM,KAAK,mBAAmB,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY;QAClE,MAAM;QACN,KAAK,EAAE,UAAU;QACjB,WAAW,EAAE,aAAa;QAC1B,WAAW;KACZ,CAAC;AACJ,CAAC;AAED,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC;IAC/B,oBAAoB;IACpB,qBAAqB;IACrB,4BAA4B;IAC5B,2BAA2B;IAC3B,sBAAsB;CACvB,CAAC,CAAC;AAEH,qGAAqG;AACrG,MAAM,UAAU,aAAa,CAAC,QAAiB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QACD,OAAO,UAAU,CAAC,mBAAmB,CAAC,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,UAAU,CAAC,qBAAqB,CAAC,CAAC;IAC3C,CAAC;AACH,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAC/C,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IAC5C,OAAO,OAAO,QAAQ,KAAK,QAAQ;QACjC,QAAQ,CAAC,MAAM,GAAG,CAAC;QACnB,QAAQ,CAAC,MAAM,IAAI,GAAG;QACtB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QACnB,IAAI,CAAC,MAAM,KAAK,CAAC;QACjB,CAAC,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE;QAC7B,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { StageSnapshot } from 'footprintjs/advanced';
|
|
2
|
+
import type { TraceCauseArtifacts } from './causeTypes.js';
|
|
3
|
+
import type { TraceToolpackArtifacts } from './types.js';
|
|
4
|
+
/** The same three questions can read a graph directly or project a native snapshot. */
|
|
5
|
+
export type CauseContext = {
|
|
6
|
+
readonly kind: 'graph';
|
|
7
|
+
readonly cause: TraceCauseArtifacts;
|
|
8
|
+
} | {
|
|
9
|
+
readonly kind: 'snapshot';
|
|
10
|
+
readonly artifacts: TraceToolpackArtifacts;
|
|
11
|
+
readonly nodes: ReadonlyMap<string, StageSnapshot>;
|
|
12
|
+
};
|
|
13
|
+
/** A saved assessment belongs only to graph-only serving, never a mixed snapshot bag. */
|
|
14
|
+
export declare function causeContextAssessment(context: CauseContext): import("./storedCauseBinding.js").StoredCauseAssessment;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { storedCauseAssessment } from './storedCauseBinding.js';
|
|
2
|
+
/** A saved assessment belongs only to graph-only serving, never a mixed snapshot bag. */
|
|
3
|
+
export function causeContextAssessment(context) {
|
|
4
|
+
try {
|
|
5
|
+
const assessed = storedCauseAssessment(context.kind === 'graph' ? context.cause : context.artifacts.cause);
|
|
6
|
+
return context.kind === 'snapshot' && assessed.kind !== 'none'
|
|
7
|
+
? { kind: 'invalid' }
|
|
8
|
+
: assessed;
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return { kind: 'invalid' };
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=causeContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"causeContext.js","sourceRoot":"","sources":["../../../src/trace-toolpack/causeContext.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAWhE,yFAAyF;AACzF,MAAM,UAAU,sBAAsB,CAAC,OAAqB;IAC1D,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,qBAAqB,CACpC,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CACnE,CAAC;QACF,OAAO,OAAO,CAAC,IAAI,KAAK,UAAU,IAAI,QAAQ,CAAC,IAAI,KAAK,MAAM;YAC5D,CAAC,CAAC,EAAE,IAAI,EAAE,SAAkB,EAAE;YAC9B,CAAC,CAAC,QAAQ,CAAC;IACf,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,IAAI,EAAE,SAAkB,EAAE,CAAC;IACtC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type RecordScope } from 'foottrace/cause';
|
|
2
|
+
import type { StageSnapshot } from 'footprintjs/advanced';
|
|
3
|
+
import type { ControlDepLookup } from 'foottrace';
|
|
4
|
+
import type { TraceCauseArtifacts } from './causeTypes.js';
|
|
5
|
+
import { type SnapshotCapture, type SourceCaptureStatus } from './causeCapture.js';
|
|
6
|
+
export interface SnapshotCauseArtifacts extends TraceCauseArtifacts {
|
|
7
|
+
readonly capture: SnapshotCapture;
|
|
8
|
+
}
|
|
9
|
+
/** A snapshot projection, not another dependence walker. The public reader owns all graph reasoning. */
|
|
10
|
+
export declare function projectCauseBasis(snapshot: unknown, nodes: ReadonlyMap<string, StageSnapshot>, controlDeps?: () => ControlDepLookup | undefined, extras?: {
|
|
11
|
+
readonly readKeys?: ReadonlyMap<string, readonly string[]>;
|
|
12
|
+
readonly initialState?: Record<string, unknown>;
|
|
13
|
+
readonly sources?: {
|
|
14
|
+
readonly status: SourceCaptureStatus;
|
|
15
|
+
readonly scope: NonNullable<RecordScope['readSources']>;
|
|
16
|
+
};
|
|
17
|
+
}): SnapshotCauseArtifacts | 'truncated' | undefined;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { createRecordGraph } from 'foottrace/cause';
|
|
2
|
+
import { assessCapture, assessSourceCapture, captureAddress, captureAssessment, captureOwn as own, } from './causeCapture.js';
|
|
3
|
+
import { capturedControl } from './causeControl.js';
|
|
4
|
+
/** A snapshot projection, not another dependence walker. The public reader owns all graph reasoning. */
|
|
5
|
+
export function projectCauseBasis(snapshot, nodes, controlDeps, extras) {
|
|
6
|
+
// A snapshot-local namespace is not a storage address or a service-correlation claim.
|
|
7
|
+
const recordedAddress = own(snapshot, 'logAddress');
|
|
8
|
+
const runId = own(snapshot, 'runId');
|
|
9
|
+
const address = recordedAddress ??
|
|
10
|
+
(typeof runId === 'string' ? { logRunId: `snapshot:${runId}`, drillPath: [] } : undefined);
|
|
11
|
+
if (address === undefined)
|
|
12
|
+
return undefined;
|
|
13
|
+
const log = own(snapshot, 'commitLog');
|
|
14
|
+
if (!Array.isArray(log))
|
|
15
|
+
return undefined;
|
|
16
|
+
if (log.length > 4096)
|
|
17
|
+
return 'truncated';
|
|
18
|
+
let capture = extras?.sources
|
|
19
|
+
? assessSourceCapture(snapshot, log.length, extras.sources.status)
|
|
20
|
+
: assessCapture(snapshot, log.length);
|
|
21
|
+
const nativeControl = capture.status === 'admitted' ? capturedControl(snapshot) : undefined;
|
|
22
|
+
if (capture.status === 'admitted' && nativeControl === undefined)
|
|
23
|
+
capture = captureAssessment('control-not-retained', capture.readSources);
|
|
24
|
+
const reads = Object.create(null);
|
|
25
|
+
const marks = Object.create(null);
|
|
26
|
+
const control = Object.create(null);
|
|
27
|
+
let visited = 0;
|
|
28
|
+
for (const [id, stage] of nodes) {
|
|
29
|
+
if (visited++ >= 4096)
|
|
30
|
+
return 'truncated';
|
|
31
|
+
const capturedReads = own(stage, 'stageReads');
|
|
32
|
+
if (capturedReads !== null && typeof capturedReads === 'object')
|
|
33
|
+
reads[id] = Object.keys(capturedReads);
|
|
34
|
+
else if (capture.status === 'admitted')
|
|
35
|
+
reads[id] = [];
|
|
36
|
+
const omitted = extras?.readKeys?.get(id);
|
|
37
|
+
if (omitted)
|
|
38
|
+
reads[id] = [...new Set([...(reads[id] ?? []), ...omitted])];
|
|
39
|
+
const attention = own(stage, 'attention');
|
|
40
|
+
if (attention !== undefined)
|
|
41
|
+
marks[id] = attention;
|
|
42
|
+
const parent = nativeControl === undefined ? controlDeps?.()?.(id) : nativeControl[id];
|
|
43
|
+
if (parent !== undefined)
|
|
44
|
+
control[id] = { deciderId: parent.deciderId };
|
|
45
|
+
}
|
|
46
|
+
if (capture.status === 'admitted' &&
|
|
47
|
+
log.some((bundle) => !nodes.has(own(bundle, 'runtimeStageId'))))
|
|
48
|
+
capture = captureAssessment('projection-incomplete', capture.readSources);
|
|
49
|
+
const complete = capture.status === 'admitted';
|
|
50
|
+
const scopeAddress = (complete && captureAddress(own(snapshot, 'logAddress'))) || address;
|
|
51
|
+
const scope = {
|
|
52
|
+
address: scopeAddress,
|
|
53
|
+
commitLog: log,
|
|
54
|
+
reads,
|
|
55
|
+
...(complete || Object.keys(marks).length
|
|
56
|
+
? { attention: marks }
|
|
57
|
+
: {}),
|
|
58
|
+
...(nativeControl === undefined && controlDeps?.() === undefined
|
|
59
|
+
? {}
|
|
60
|
+
: { controlDeps: control }),
|
|
61
|
+
complete,
|
|
62
|
+
...(extras?.initialState === undefined ? {} : { initialState: extras.initialState }),
|
|
63
|
+
...(extras?.sources === undefined ? {} : { readSources: extras.sources.scope }),
|
|
64
|
+
};
|
|
65
|
+
const graph = createRecordGraph([scope], { maxCommits: 4096 });
|
|
66
|
+
// The public scope reader admits untrusted commits and creates its own official IDs.
|
|
67
|
+
return {
|
|
68
|
+
graph: { ...graph, roots: (context) => graph.openScope(scopeAddress, context) },
|
|
69
|
+
capture,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=causeProjection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"causeProjection.js","sourceRoot":"","sources":["../../../src/trace-toolpack/causeProjection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAoB,MAAM,iBAAiB,CAAC;AAItE,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,UAAU,IAAI,GAAG,GAGlB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAMpD,wGAAwG;AACxG,MAAM,UAAU,iBAAiB,CAC/B,QAAiB,EACjB,KAAyC,EACzC,WAAgD,EAChD,MAOC;IAED,sFAAsF;IACtF,MAAM,eAAe,GAAG,GAAG,CAAC,QAAQ,EAAE,YAAY,CAAuC,CAAC;IAC1F,MAAM,KAAK,GAAG,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACrC,MAAM,OAAO,GACX,eAAe;QACf,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,SA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ceToolpackArtifacts } from './types.js';
|
|
3
1
|
import type { TraceCauseOperation, TraceCauseQuestion } from './causeTypes.js';
|
|
4
2
|
import type { CauseLimits } from './causeLimits.js';
|
|
3
|
+
import { type CauseContext } from './causeContext.js';
|
|
5
4
|
/** One public query, one cache/deadline/total ceiling. No model, rerun, storage URL or second walker. */
|
|
6
|
-
export declare function readCause(operation: TraceCauseOperation,
|
|
5
|
+
export declare function readCause(operation: TraceCauseOperation, context: CauseContext, question: TraceCauseQuestion, limits: CauseLimits, deadline: number, signal?: AbortSignal): Promise<string>;
|
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
import { attentionList, explain } from 'foottrace/cause';
|
|
2
2
|
import { snapshotCauseArtifacts } from './causeSnapshot.js';
|
|
3
3
|
import { causeGap, causeResponse } from './causeResponse.js';
|
|
4
|
+
import { causeContextAssessment } from './causeContext.js';
|
|
4
5
|
/** One public query, one cache/deadline/total ceiling. No model, rerun, storage URL or second walker. */
|
|
5
|
-
export async function readCause(operation,
|
|
6
|
-
const
|
|
6
|
+
export async function readCause(operation, context, question, limits, deadline, signal) {
|
|
7
|
+
const assessed = causeContextAssessment(context);
|
|
8
|
+
if (assessed.kind === 'invalid')
|
|
9
|
+
return causeGap(operation, 'invalid-data');
|
|
10
|
+
const snapshotOnly = context.kind === 'snapshot' && context.artifacts.cause === undefined ? true : undefined;
|
|
11
|
+
const storedCapture = assessed.kind === 'stored' ? assessed.capture : undefined;
|
|
12
|
+
const storage = assessed.kind === 'stored' ? assessed.admission.storage : undefined;
|
|
7
13
|
if (signal?.aborted)
|
|
8
|
-
return causeGap(operation, 'cancelled', snapshotOnly);
|
|
14
|
+
return causeGap(operation, 'cancelled', storedCapture ?? snapshotOnly, storage, limits.maxChars);
|
|
9
15
|
if (performance.now() >= deadline)
|
|
10
|
-
return causeGap(operation, 'timeout', snapshotOnly);
|
|
11
|
-
const projection =
|
|
12
|
-
|
|
16
|
+
return causeGap(operation, 'timeout', storedCapture ?? snapshotOnly, storage, limits.maxChars);
|
|
17
|
+
const projection = context.kind === 'snapshot' && context.artifacts.cause === undefined
|
|
18
|
+
? snapshotCauseArtifacts(context.artifacts, context.nodes)
|
|
19
|
+
: undefined;
|
|
20
|
+
const source = context.kind === 'graph' ? context.cause : context.artifacts.cause ?? projection;
|
|
13
21
|
if (source === 'truncated')
|
|
14
22
|
return causeGap(operation, 'truncated', snapshotOnly);
|
|
15
23
|
if (source === undefined)
|
|
16
24
|
return causeGap(operation, 'not-collected', snapshotOnly);
|
|
17
|
-
const capture = projection && projection !== 'truncated' ? projection.capture : undefined;
|
|
25
|
+
const capture = storedCapture ?? (projection && projection !== 'truncated' ? projection.capture : undefined);
|
|
18
26
|
const remaining = Math.floor(deadline - performance.now());
|
|
19
27
|
if (signal?.aborted)
|
|
20
|
-
return causeGap(operation, 'cancelled', capture);
|
|
28
|
+
return causeGap(operation, 'cancelled', capture, storage, limits.maxChars);
|
|
21
29
|
if (remaining < 1)
|
|
22
|
-
return causeGap(operation, 'timeout', capture);
|
|
30
|
+
return causeGap(operation, 'timeout', capture, storage, limits.maxChars);
|
|
23
31
|
const { maxChars, backward, impact, maxNodes, maxDepth, maxEdges, maxCalls } = limits;
|
|
24
32
|
const options = { maxNodes, maxDepth, maxEdges, maxCalls, timeoutMs: remaining, signal };
|
|
25
33
|
if (operation === 'attention_list') {
|
|
@@ -37,21 +45,21 @@ export async function readCause(operation, artifacts, nodes, question, limits, d
|
|
|
37
45
|
: result;
|
|
38
46
|
return causeResponse(operation, finding, finding.confidence === 'incomplete'
|
|
39
47
|
? 'Not sure, because coverage is incomplete. An absent mark is not proof of a healthy or reached step.'
|
|
40
|
-
: 'Recorded attention within this query only. Cite the returned node and evidence IDs.', maxChars, capture);
|
|
48
|
+
: 'Recorded attention within this query only. Cite the returned node and evidence IDs.', maxChars, capture, storage);
|
|
41
49
|
}
|
|
42
50
|
// Each invocation projects one bounded query. Separate root/impact calls do not share a result yet.
|
|
43
51
|
if (question.nodeId === undefined)
|
|
44
|
-
return causeGap(operation, 'invalid-data', capture);
|
|
52
|
+
return causeGap(operation, 'invalid-data', capture, storage, limits.maxChars);
|
|
45
53
|
const finding = await explain(source.graph, question.nodeId, { ...options, backward, impact });
|
|
46
54
|
if (operation === 'impact') {
|
|
47
55
|
return causeResponse(operation, finding.impact, finding.impact.confidence === 'incomplete'
|
|
48
56
|
? 'Not sure of the full impact, because the returned gaps limit the recorded forward slice.'
|
|
49
|
-
: 'Recorded reachable impact only; this does not prove effects in unrecorded services or unreached branches.', maxChars, capture);
|
|
57
|
+
: 'Recorded reachable impact only; this does not prove effects in unrecorded services or unreached branches.', maxChars, capture, storage);
|
|
50
58
|
}
|
|
51
59
|
return causeResponse(operation, finding, finding.rootCause !== undefined
|
|
52
60
|
? 'A unique recorded dependency root is supported. Cite its node ID and path; this is not proof of a provider-internal physical cause.'
|
|
53
61
|
: finding.confidence === 'incomplete'
|
|
54
62
|
? 'Not sure, because the returned gaps prevent a unique supported root. Alternatives are not confirmed causes.'
|
|
55
|
-
: 'No unique marked root in the checked graph. Cite alternatives without selecting one as fact.', maxChars, capture);
|
|
63
|
+
: 'No unique marked root in the checked graph. Cite alternatives without selecting one as fact.', maxChars, capture, storage);
|
|
56
64
|
}
|
|
57
65
|
//# sourceMappingURL=causeReader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"causeReader.js","sourceRoot":"","sources":["../../../src/trace-toolpack/causeReader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"causeReader.js","sourceRoot":"","sources":["../../../src/trace-toolpack/causeReader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAGzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAA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CAAC,CAAC,2GAA2G,EAC/G,QAAQ,EACR,OAAO,EACP,OAAO,CACR,CAAC;IACJ,CAAC;IACD,OAAO,aAAa,CAClB,SAAS,EACT,OAAO,EACP,OAAO,CAAC,SAAS,KAAK,SAAS;QAC7B,CAAC,CAAC,qIAAqI;QACvI,CAAC,CAAC,OAAO,CAAC,UAAU,KAAK,YAAY;YACrC,CAAC,CAAC,6GAA6G;YAC/G,CAAC,CAAC,8FAA8F,EAClG,QAAQ,EACR,OAAO,EACP,OAAO,CACR,CAAC;AACJ,CAAC"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { GapCode } from 'foottrace/cause';
|
|
2
2
|
import type { TraceCauseOperation } from './causeTypes.js';
|
|
3
3
|
import type { SnapshotCapture } from './causeCapture.js';
|
|
4
|
+
import type { StoredCauseAdmission } from './storedCauseTypes.js';
|
|
5
|
+
type StoredAssessment = StoredCauseAdmission['storage'];
|
|
4
6
|
/** Fixed wording: no exception messages, state values or provider payloads cross this boundary. */
|
|
5
|
-
export declare function causeGap(tool: TraceCauseOperation, code: GapCode, capture?: SnapshotCapture | true): string;
|
|
7
|
+
export declare function causeGap(tool: TraceCauseOperation, code: GapCode, capture?: SnapshotCapture | true, storage?: StoredAssessment, maxChars?: number): string;
|
|
6
8
|
/** A clipped proof must never leave behind a seemingly supported root or apparently complete empty list. */
|
|
7
|
-
export declare function causeResponse(tool: TraceCauseOperation, finding: unknown, interpretation: string, maxChars: number, capture?: SnapshotCapture | true): string;
|
|
9
|
+
export declare function causeResponse(tool: TraceCauseOperation, finding: unknown, interpretation: string, maxChars: number, capture?: SnapshotCapture | true, storage?: StoredAssessment): string;
|
|
10
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const STORED_LIMITATION = 'The storage adapter acknowledged these saved root-history bytes only. The native note remains memory-only; this receipt is not producer authentication or whole-workflow delivery proof.';
|
|
1
2
|
const SNAPSHOT_LIMITATION = 'Snapshot-only records have no engine-written capture/end attestation. This reader cannot prove a root cause from them, even after a normally finished run.';
|
|
2
3
|
const CAPTURE_REASONS = {
|
|
3
4
|
'captured-root-log': 'Capture covers this in-memory root log only; exact read versions, child scopes and durable delivery remain unproven.',
|
|
@@ -13,33 +14,49 @@ const CAPTURE_REASONS = {
|
|
|
13
14
|
'control-not-retained': 'Same-run captured control-dependency data is missing, partial or ambiguous.',
|
|
14
15
|
'projection-incomplete': 'The execution-tree projection is missing a committed step.',
|
|
15
16
|
};
|
|
16
|
-
function interpretationFor(text, capture) {
|
|
17
|
-
|
|
17
|
+
function interpretationFor(text, capture, storage) {
|
|
18
|
+
const native = capture
|
|
18
19
|
? `${text} ${capture === true
|
|
19
20
|
? 'The capture/end attestation was not inspected. No completeness claim is made.'
|
|
20
|
-
:
|
|
21
|
+
: capture.reason === 'captured-root-log' && capture.readSources !== 'not-collected'
|
|
22
|
+
? 'Capture covers this saved root log segment only. Read-source observations use independently collected native ownership; unavailable reads retain gaps. Child scopes and whole-workflow durable delivery remain unproven.'
|
|
23
|
+
: CAPTURE_REASONS[capture.reason]}`
|
|
21
24
|
: text;
|
|
25
|
+
return storage === undefined ? native : `${native} ${STORED_LIMITATION}`;
|
|
22
26
|
}
|
|
23
27
|
/** Fixed wording: no exception messages, state values or provider payloads cross this boundary. */
|
|
24
|
-
export function causeGap(tool, code, capture) {
|
|
25
|
-
|
|
28
|
+
export function causeGap(tool, code, capture, storage, maxChars) {
|
|
29
|
+
const text = JSON.stringify({
|
|
26
30
|
tool,
|
|
27
31
|
mode: 'recorded-evidence',
|
|
28
32
|
confidence: 'incomplete',
|
|
29
33
|
gaps: [{ code, evidence: [] }],
|
|
30
34
|
...(capture && capture !== true ? { capture } : {}),
|
|
31
|
-
|
|
35
|
+
...(storage === undefined ? {} : { storage }),
|
|
36
|
+
interpretation: interpretationFor('Not sure: the requested evidence is incomplete. No root cause is asserted.', capture, storage),
|
|
32
37
|
});
|
|
38
|
+
// The native + saved assessments can themselves exceed a small output ceiling.
|
|
39
|
+
// Withhold them together with the proof; never clip a label into an apparent root.
|
|
40
|
+
return storage !== undefined && maxChars !== undefined && text.length > maxChars
|
|
41
|
+
? JSON.stringify({
|
|
42
|
+
tool,
|
|
43
|
+
mode: 'recorded-evidence',
|
|
44
|
+
confidence: 'incomplete',
|
|
45
|
+
gaps: [{ code, evidence: [] }],
|
|
46
|
+
interpretation: 'Recorded evidence response: output limit reached. The response contains a gap, no root or full assessment. The storage adapter acknowledged saved root-history bytes only; native capture is memory-only. Producer identity and whole-workflow delivery remain unproven.',
|
|
47
|
+
})
|
|
48
|
+
: text;
|
|
33
49
|
}
|
|
34
50
|
/** A clipped proof must never leave behind a seemingly supported root or apparently complete empty list. */
|
|
35
|
-
export function causeResponse(tool, finding, interpretation, maxChars, capture) {
|
|
51
|
+
export function causeResponse(tool, finding, interpretation, maxChars, capture, storage) {
|
|
36
52
|
const text = JSON.stringify({
|
|
37
53
|
tool,
|
|
38
54
|
mode: 'recorded-evidence',
|
|
39
55
|
finding,
|
|
40
56
|
...(capture && capture !== true ? { capture } : {}),
|
|
41
|
-
|
|
57
|
+
...(storage === undefined ? {} : { storage }),
|
|
58
|
+
interpretation: interpretationFor(interpretation, capture, storage),
|
|
42
59
|
});
|
|
43
|
-
return text.length <= maxChars ? text : causeGap(tool, 'truncated', capture);
|
|
60
|
+
return text.length <= maxChars ? text : causeGap(tool, 'truncated', capture, storage, maxChars);
|
|
44
61
|
}
|
|
45
62
|
//# sourceMappingURL=causeResponse.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"causeResponse.js","sourceRoot":"","sources":["../../../src/trace-toolpack/causeResponse.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"causeResponse.js","sourceRoot":"","sources":["../../../src/trace-toolpack/causeResponse.ts"],"names":[],"mappings":"AAMA,MAAM,iBAAiB,GACrB,0LAA0L,CAAC;AAE7L,MAAM,mBAAmB,GACvB,4JAA4J,CAAC;AAE/J,MAAM,eAAe,GAAkC;IACrD,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WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAClG,CAAC"}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import type { StageSnapshot } from 'footprintjs/advanced';
|
|
2
2
|
import type { TraceToolpackArtifacts } from './types.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
interface SnapshotCauseArtifacts extends TraceCauseArtifacts {
|
|
6
|
-
readonly capture: SnapshotCapture;
|
|
7
|
-
}
|
|
8
|
-
/** A snapshot projection, not another dependence walker. The public reader owns all graph reasoning. */
|
|
9
|
-
export declare function snapshotCauseArtifacts(artifacts: TraceToolpackArtifacts, nodes: ReadonlyMap<string, StageSnapshot>): SnapshotCauseArtifacts | 'truncated' | undefined;
|
|
10
|
-
export {};
|
|
3
|
+
/** Preserve the existing in-memory projection through the shared narrow basis. */
|
|
4
|
+
export declare function snapshotCauseArtifacts(artifacts: TraceToolpackArtifacts, nodes: ReadonlyMap<string, StageSnapshot>): "truncated" | import("./causeProjection.js").SnapshotCauseArtifacts | undefined;
|
|
@@ -1,66 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { capturedControl } from './causeControl.js';
|
|
4
|
-
/** A snapshot projection, not another dependence walker. The public reader owns all graph reasoning. */
|
|
1
|
+
import { projectCauseBasis } from './causeProjection.js';
|
|
2
|
+
/** Preserve the existing in-memory projection through the shared narrow basis. */
|
|
5
3
|
export function snapshotCauseArtifacts(artifacts, nodes) {
|
|
6
|
-
|
|
7
|
-
// A snapshot-local namespace is not a storage address or a service-correlation claim.
|
|
8
|
-
const recordedAddress = own(snapshot, 'logAddress');
|
|
9
|
-
const runId = own(snapshot, 'runId');
|
|
10
|
-
const address = recordedAddress ??
|
|
11
|
-
(typeof runId === 'string' ? { logRunId: `snapshot:${runId}`, drillPath: [] } : undefined);
|
|
12
|
-
if (address === undefined)
|
|
13
|
-
return undefined;
|
|
14
|
-
const log = own(snapshot, 'commitLog');
|
|
15
|
-
if (!Array.isArray(log))
|
|
16
|
-
return undefined;
|
|
17
|
-
if (log.length > 4096)
|
|
18
|
-
return 'truncated';
|
|
19
|
-
let capture = assessCapture(snapshot, log.length);
|
|
20
|
-
const nativeControl = capture.status === 'admitted' ? capturedControl(snapshot) : undefined;
|
|
21
|
-
if (capture.status === 'admitted' && nativeControl === undefined)
|
|
22
|
-
capture = captureAssessment('control-not-retained');
|
|
23
|
-
const reads = Object.create(null);
|
|
24
|
-
const marks = Object.create(null);
|
|
25
|
-
const control = Object.create(null);
|
|
26
|
-
let visited = 0;
|
|
27
|
-
for (const [id, stage] of nodes) {
|
|
28
|
-
if (visited++ >= 4096)
|
|
29
|
-
return 'truncated';
|
|
30
|
-
const capturedReads = own(stage, 'stageReads');
|
|
31
|
-
if (capturedReads !== null && typeof capturedReads === 'object')
|
|
32
|
-
reads[id] = Object.keys(capturedReads);
|
|
33
|
-
else if (capture.status === 'admitted')
|
|
34
|
-
reads[id] = [];
|
|
35
|
-
const attention = own(stage, 'attention');
|
|
36
|
-
if (attention !== undefined)
|
|
37
|
-
marks[id] = attention;
|
|
38
|
-
const parent = nativeControl === undefined ? artifacts.controlDeps?.(id) : nativeControl[id];
|
|
39
|
-
if (parent !== undefined)
|
|
40
|
-
control[id] = { deciderId: parent.deciderId };
|
|
41
|
-
}
|
|
42
|
-
if (capture.status === 'admitted' &&
|
|
43
|
-
log.some((bundle) => !nodes.has(own(bundle, 'runtimeStageId'))))
|
|
44
|
-
capture = captureAssessment('projection-incomplete');
|
|
45
|
-
const complete = capture.status === 'admitted';
|
|
46
|
-
const scopeAddress = (complete && captureAddress(own(snapshot, 'logAddress'))) || address;
|
|
47
|
-
const scope = {
|
|
48
|
-
address: scopeAddress,
|
|
49
|
-
commitLog: log,
|
|
50
|
-
reads,
|
|
51
|
-
...(complete || Object.keys(marks).length
|
|
52
|
-
? { attention: marks }
|
|
53
|
-
: {}),
|
|
54
|
-
...(nativeControl === undefined && artifacts.controlDeps === undefined
|
|
55
|
-
? {}
|
|
56
|
-
: { controlDeps: control }),
|
|
57
|
-
complete,
|
|
58
|
-
};
|
|
59
|
-
const graph = createRecordGraph([scope], { maxCommits: 4096 });
|
|
60
|
-
// The public scope reader admits untrusted commits and creates its own official IDs.
|
|
61
|
-
return {
|
|
62
|
-
graph: { ...graph, roots: (context) => graph.openScope(scopeAddress, context) },
|
|
63
|
-
capture,
|
|
64
|
-
};
|
|
4
|
+
return projectCauseBasis(artifacts.snapshot, nodes, () => artifacts.controlDeps);
|
|
65
5
|
}
|
|
66
6
|
//# sourceMappingURL=causeSnapshot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"causeSnapshot.js","sourceRoot":"","sources":["../../../src/trace-toolpack/causeSnapshot.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"causeSnapshot.js","sourceRoot":"","sources":["../../../src/trace-toolpack/causeSnapshot.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,kFAAkF;AAClF,MAAM,UAAU,sBAAsB,CACpC,SAAiC,EACjC,KAAyC;IAEzC,OAAO,iBAAiB,CAAC,SAAS,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;AACnF,CAAC"}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { StageSnapshot } from 'footprintjs/advanced';
|
|
2
2
|
import { type Tool } from '../tools/tools.js';
|
|
3
3
|
import type { TraceToolpackArtifacts } from './types.js';
|
|
4
|
-
import type { TraceCauseOptions } from './causeTypes.js';
|
|
4
|
+
import type { TraceCauseArtifacts, TraceCauseOptions } from './causeTypes.js';
|
|
5
5
|
/** Model questions select IDs only. The host owns all resource controls. */
|
|
6
6
|
export declare function buildCauseTools(artifacts: TraceToolpackArtifacts, nodes: ReadonlyMap<string, StageSnapshot>, options?: TraceCauseOptions): Tool[];
|
|
7
|
+
/**
|
|
8
|
+
* Serve the three read-only cause questions over one host-authorized graph.
|
|
9
|
+
* Saved evidence must be the exact object returned by `readStoredCauseArtifacts`;
|
|
10
|
+
* copied display assessments do not grant saved-history authority.
|
|
11
|
+
* No snapshot is indexed, no storage is fetched and no business work is rerun.
|
|
12
|
+
*/
|
|
13
|
+
export declare function traceCauseTools(cause: TraceCauseArtifacts, options?: TraceCauseOptions): Tool[];
|