@lumenflow/kernel 3.0.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/LICENSE.md +190 -0
- package/README.md +26 -0
- package/dist/canonical-json.d.ts +7 -0
- package/dist/canonical-json.d.ts.map +1 -0
- package/dist/canonical-json.js +50 -0
- package/dist/canonical-json.js.map +1 -0
- package/dist/event-kinds.d.ts +32 -0
- package/dist/event-kinds.d.ts.map +1 -0
- package/dist/event-kinds.js +49 -0
- package/dist/event-kinds.js.map +1 -0
- package/dist/event-store/index.d.ts +64 -0
- package/dist/event-store/index.d.ts.map +1 -0
- package/dist/event-store/index.js +634 -0
- package/dist/event-store/index.js.map +1 -0
- package/dist/evidence/evidence-store.d.ts +78 -0
- package/dist/evidence/evidence-store.d.ts.map +1 -0
- package/dist/evidence/evidence-store.js +409 -0
- package/dist/evidence/evidence-store.js.map +1 -0
- package/dist/evidence/fs-helpers.d.ts +13 -0
- package/dist/evidence/fs-helpers.d.ts.map +1 -0
- package/dist/evidence/fs-helpers.js +38 -0
- package/dist/evidence/fs-helpers.js.map +1 -0
- package/dist/evidence/index.d.ts +3 -0
- package/dist/evidence/index.d.ts.map +1 -0
- package/dist/evidence/index.js +5 -0
- package/dist/evidence/index.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/kernel.schemas.d.ts +642 -0
- package/dist/kernel.schemas.d.ts.map +1 -0
- package/dist/kernel.schemas.js +331 -0
- package/dist/kernel.schemas.js.map +1 -0
- package/dist/pack/hash.d.ts +7 -0
- package/dist/pack/hash.d.ts.map +1 -0
- package/dist/pack/hash.js +56 -0
- package/dist/pack/hash.js.map +1 -0
- package/dist/pack/index.d.ts +4 -0
- package/dist/pack/index.d.ts.map +1 -0
- package/dist/pack/index.js +6 -0
- package/dist/pack/index.js.map +1 -0
- package/dist/pack/manifest.d.ts +100 -0
- package/dist/pack/manifest.d.ts.map +1 -0
- package/dist/pack/manifest.js +50 -0
- package/dist/pack/manifest.js.map +1 -0
- package/dist/pack/pack-loader.d.ts +108 -0
- package/dist/pack/pack-loader.d.ts.map +1 -0
- package/dist/pack/pack-loader.js +282 -0
- package/dist/pack/pack-loader.js.map +1 -0
- package/dist/policy/approval-event.d.ts +29 -0
- package/dist/policy/approval-event.d.ts.map +1 -0
- package/dist/policy/approval-event.js +17 -0
- package/dist/policy/approval-event.js.map +1 -0
- package/dist/policy/index.d.ts +3 -0
- package/dist/policy/index.d.ts.map +1 -0
- package/dist/policy/index.js +5 -0
- package/dist/policy/index.js.map +1 -0
- package/dist/policy/policy-engine.d.ts +52 -0
- package/dist/policy/policy-engine.d.ts.map +1 -0
- package/dist/policy/policy-engine.js +83 -0
- package/dist/policy/policy-engine.js.map +1 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +4 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/kernel-runtime.d.ts +170 -0
- package/dist/runtime/kernel-runtime.d.ts.map +1 -0
- package/dist/runtime/kernel-runtime.js +751 -0
- package/dist/runtime/kernel-runtime.js.map +1 -0
- package/dist/sandbox/bwrap-invocation.d.ts +13 -0
- package/dist/sandbox/bwrap-invocation.d.ts.map +1 -0
- package/dist/sandbox/bwrap-invocation.js +105 -0
- package/dist/sandbox/bwrap-invocation.js.map +1 -0
- package/dist/sandbox/index.d.ts +5 -0
- package/dist/sandbox/index.d.ts.map +1 -0
- package/dist/sandbox/index.js +7 -0
- package/dist/sandbox/index.js.map +1 -0
- package/dist/sandbox/profile.d.ts +32 -0
- package/dist/sandbox/profile.d.ts.map +1 -0
- package/dist/sandbox/profile.js +101 -0
- package/dist/sandbox/profile.js.map +1 -0
- package/dist/sandbox/subprocess-dispatcher.d.ts +38 -0
- package/dist/sandbox/subprocess-dispatcher.d.ts.map +1 -0
- package/dist/sandbox/subprocess-dispatcher.js +145 -0
- package/dist/sandbox/subprocess-dispatcher.js.map +1 -0
- package/dist/sandbox/tool-runner-worker.d.ts +54 -0
- package/dist/sandbox/tool-runner-worker.d.ts.map +1 -0
- package/dist/sandbox/tool-runner-worker.js +159 -0
- package/dist/sandbox/tool-runner-worker.js.map +1 -0
- package/dist/shared-constants.d.ts +48 -0
- package/dist/shared-constants.d.ts.map +1 -0
- package/dist/shared-constants.js +49 -0
- package/dist/shared-constants.js.map +1 -0
- package/dist/state-machine/index.d.ts +30 -0
- package/dist/state-machine/index.d.ts.map +1 -0
- package/dist/state-machine/index.js +92 -0
- package/dist/state-machine/index.js.map +1 -0
- package/dist/tool-host/builtins/capabilities.d.ts +20 -0
- package/dist/tool-host/builtins/capabilities.d.ts.map +1 -0
- package/dist/tool-host/builtins/capabilities.js +211 -0
- package/dist/tool-host/builtins/capabilities.js.map +1 -0
- package/dist/tool-host/builtins/index.d.ts +2 -0
- package/dist/tool-host/builtins/index.d.ts.map +1 -0
- package/dist/tool-host/builtins/index.js +4 -0
- package/dist/tool-host/builtins/index.js.map +1 -0
- package/dist/tool-host/index.d.ts +5 -0
- package/dist/tool-host/index.d.ts.map +1 -0
- package/dist/tool-host/index.js +7 -0
- package/dist/tool-host/index.js.map +1 -0
- package/dist/tool-host/scope-intersection.d.ts +10 -0
- package/dist/tool-host/scope-intersection.d.ts.map +1 -0
- package/dist/tool-host/scope-intersection.js +188 -0
- package/dist/tool-host/scope-intersection.js.map +1 -0
- package/dist/tool-host/subprocess-dispatcher.d.ts +14 -0
- package/dist/tool-host/subprocess-dispatcher.d.ts.map +1 -0
- package/dist/tool-host/subprocess-dispatcher.js +14 -0
- package/dist/tool-host/subprocess-dispatcher.js.map +1 -0
- package/dist/tool-host/tool-host.d.ts +42 -0
- package/dist/tool-host/tool-host.d.ts.map +1 -0
- package/dist/tool-host/tool-host.js +395 -0
- package/dist/tool-host/tool-host.js.map +1 -0
- package/dist/tool-host/tool-registry.d.ts +9 -0
- package/dist/tool-host/tool-registry.d.ts.map +1 -0
- package/dist/tool-host/tool-registry.js +28 -0
- package/dist/tool-host/tool-registry.js.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type ToolTraceEntry } from '../kernel.schemas.js';
|
|
2
|
+
export interface EvidenceStoreOptions {
|
|
3
|
+
evidenceRoot: string;
|
|
4
|
+
lockRetryDelayMs?: number;
|
|
5
|
+
lockMaxRetries?: number;
|
|
6
|
+
/** Byte size threshold for the active JSONL file before rotation. Default: 10 MiB. */
|
|
7
|
+
compactionThresholdBytes?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface PersistDataResult {
|
|
10
|
+
dataHash: string;
|
|
11
|
+
dataRef: string;
|
|
12
|
+
}
|
|
13
|
+
/** @deprecated Use PersistDataResult instead */
|
|
14
|
+
export type PersistInputResult = PersistDataResult;
|
|
15
|
+
export declare class EvidenceStore {
|
|
16
|
+
private readonly tracesDir;
|
|
17
|
+
private readonly tracesFilePath;
|
|
18
|
+
private readonly tracesLockFilePath;
|
|
19
|
+
private readonly inputsDir;
|
|
20
|
+
private readonly lockRetryDelayMs;
|
|
21
|
+
private readonly lockMaxRetries;
|
|
22
|
+
private readonly compactionThresholdBytes;
|
|
23
|
+
private tracesHydrated;
|
|
24
|
+
private orderedTraces;
|
|
25
|
+
private tracesByTaskId;
|
|
26
|
+
private taskIdByReceiptId;
|
|
27
|
+
/** Dedup guard: tracks `receipt_id:kind` keys already indexed (WU-1881). */
|
|
28
|
+
private seenTraceKeys;
|
|
29
|
+
/** Byte offset cursor into the active trace file for incremental reads. */
|
|
30
|
+
private activeFileCursor;
|
|
31
|
+
/** Number of compacted segment files at last hydration. */
|
|
32
|
+
private hydratedSegmentCount;
|
|
33
|
+
constructor(options: EvidenceStoreOptions);
|
|
34
|
+
appendTrace(entry: ToolTraceEntry): Promise<void>;
|
|
35
|
+
readTraces(): Promise<ToolTraceEntry[]>;
|
|
36
|
+
readTracesByTaskId(taskId: string): Promise<ToolTraceEntry[]>;
|
|
37
|
+
pruneTask(taskId: string): Promise<number>;
|
|
38
|
+
getReceiptIndexSize(): Promise<number>;
|
|
39
|
+
private hydrateIndexesIfNeeded;
|
|
40
|
+
/**
|
|
41
|
+
* Full hydration: reads all segment files (sorted ascending) then the active file.
|
|
42
|
+
* Sets cursor to end of active file for subsequent incremental reads.
|
|
43
|
+
*/
|
|
44
|
+
private fullHydrate;
|
|
45
|
+
/**
|
|
46
|
+
* Incremental hydration: only reads new segments (from compaction since last
|
|
47
|
+
* hydration) and new bytes appended to the active file since the cursor.
|
|
48
|
+
* This provides O(1) amortized reads for the hot path.
|
|
49
|
+
*/
|
|
50
|
+
private incrementalHydrate;
|
|
51
|
+
/**
|
|
52
|
+
* Lists compacted segment files sorted in ascending order.
|
|
53
|
+
* Segment files follow the pattern: tool-traces.NNNN.jsonl
|
|
54
|
+
*/
|
|
55
|
+
private listSegmentFiles;
|
|
56
|
+
/**
|
|
57
|
+
* Reads an entire file and applies all trace lines to the indexes.
|
|
58
|
+
*/
|
|
59
|
+
private hydrateFromFile;
|
|
60
|
+
/**
|
|
61
|
+
* Parses newline-delimited JSON lines and applies each to the indexes.
|
|
62
|
+
*/
|
|
63
|
+
private parseAndApplyLines;
|
|
64
|
+
/**
|
|
65
|
+
* Rotates the active JSONL file to a numbered segment if it exceeds the
|
|
66
|
+
* compaction threshold. Called within the file lock after each append.
|
|
67
|
+
* @returns true if compaction (rotation) occurred.
|
|
68
|
+
*/
|
|
69
|
+
private compactIfNeeded;
|
|
70
|
+
private resetIndexes;
|
|
71
|
+
private applyTraceToIndexes;
|
|
72
|
+
persistData(data: unknown): Promise<PersistDataResult>;
|
|
73
|
+
/** @deprecated Use persistData instead */
|
|
74
|
+
persistInput(input: unknown): Promise<PersistDataResult>;
|
|
75
|
+
reconcileOrphanedStarts(): Promise<number>;
|
|
76
|
+
private withFileLock;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=evidence-store.d.ts.map
|
|
@@ -0,0 +1 @@
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c,EAAE,CAAC;IAKvC,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAK7D,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAkB1C,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC;YAK9B,sBAAsB;IASpC;;;OAGG;YACW,WAAW;IA6BzB;;;;OAIG;YACW,kBAAkB;IA2ChC;;;OAGG;YACW,gBAAgB;IAuB9B;;OAEG;YACW,eAAe;IAO7B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAsB1B;;;;OAIG;YACW,eAAe;IA+B7B,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,mBAAmB;IA2BrB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA0B5D,0CAA0C;IACpC,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAIxD,uBAAuB,IAAI,OAAO,CAAC,MAAM,CAAC;YA0ClC,YAAY;CAyC3B"}
|
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
// Copyright (c) 2026 Hellmai Ltd
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { appendFile, mkdir, open, readdir, rename, rm } from 'node:fs/promises';
|
|
4
|
+
import { createHash } from 'node:crypto';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { canonicalStringify } from '../canonical-json.js';
|
|
7
|
+
import { TOOL_TRACE_KINDS } from '../event-kinds.js';
|
|
8
|
+
import { ToolTraceEntrySchema, } from '../kernel.schemas.js';
|
|
9
|
+
import { KERNEL_POLICY_IDS, SHA256_ALGORITHM, UTF8_ENCODING } from '../shared-constants.js';
|
|
10
|
+
import { readFileOrEmpty, statOrNull } from './fs-helpers.js';
|
|
11
|
+
const DEFAULT_LOCK_RETRY_DELAY_MS = 20;
|
|
12
|
+
const DEFAULT_LOCK_MAX_RETRIES = 250;
|
|
13
|
+
const DEFAULT_COMPACTION_THRESHOLD_BYTES = 10 * 1024 * 1024; // 10 MiB
|
|
14
|
+
const ACTIVE_TRACE_FILE_NAME = 'tool-traces.jsonl';
|
|
15
|
+
const SEGMENT_FILE_PATTERN = /^tool-traces\.(\d+)\.jsonl$/;
|
|
16
|
+
function sha256Hex(content) {
|
|
17
|
+
return createHash(SHA256_ALGORITHM).update(content).digest('hex');
|
|
18
|
+
}
|
|
19
|
+
function sleep(ms) {
|
|
20
|
+
return new Promise((resolve) => {
|
|
21
|
+
setTimeout(resolve, ms);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export class EvidenceStore {
|
|
25
|
+
tracesDir;
|
|
26
|
+
tracesFilePath;
|
|
27
|
+
tracesLockFilePath;
|
|
28
|
+
inputsDir;
|
|
29
|
+
lockRetryDelayMs;
|
|
30
|
+
lockMaxRetries;
|
|
31
|
+
compactionThresholdBytes;
|
|
32
|
+
tracesHydrated = false;
|
|
33
|
+
orderedTraces = [];
|
|
34
|
+
tracesByTaskId = new Map();
|
|
35
|
+
taskIdByReceiptId = new Map();
|
|
36
|
+
/** Dedup guard: tracks `receipt_id:kind` keys already indexed (WU-1881). */
|
|
37
|
+
seenTraceKeys = new Set();
|
|
38
|
+
/** Byte offset cursor into the active trace file for incremental reads. */
|
|
39
|
+
activeFileCursor = 0;
|
|
40
|
+
/** Number of compacted segment files at last hydration. */
|
|
41
|
+
hydratedSegmentCount = 0;
|
|
42
|
+
constructor(options) {
|
|
43
|
+
this.tracesDir = join(options.evidenceRoot, 'traces');
|
|
44
|
+
this.tracesFilePath = join(this.tracesDir, ACTIVE_TRACE_FILE_NAME);
|
|
45
|
+
this.tracesLockFilePath = join(this.tracesDir, 'tool-traces.lock');
|
|
46
|
+
this.inputsDir = join(options.evidenceRoot, 'inputs');
|
|
47
|
+
this.lockRetryDelayMs = options.lockRetryDelayMs ?? DEFAULT_LOCK_RETRY_DELAY_MS;
|
|
48
|
+
this.lockMaxRetries = options.lockMaxRetries ?? DEFAULT_LOCK_MAX_RETRIES;
|
|
49
|
+
this.compactionThresholdBytes =
|
|
50
|
+
options.compactionThresholdBytes ?? DEFAULT_COMPACTION_THRESHOLD_BYTES;
|
|
51
|
+
}
|
|
52
|
+
async appendTrace(entry) {
|
|
53
|
+
const validated = ToolTraceEntrySchema.parse(entry);
|
|
54
|
+
let compacted = false;
|
|
55
|
+
await this.withFileLock(async () => {
|
|
56
|
+
await mkdir(this.tracesDir, { recursive: true });
|
|
57
|
+
const serialized = `${JSON.stringify(validated)}\n`;
|
|
58
|
+
await appendFile(this.tracesFilePath, serialized, UTF8_ENCODING);
|
|
59
|
+
compacted = await this.compactIfNeeded();
|
|
60
|
+
});
|
|
61
|
+
if (this.tracesHydrated) {
|
|
62
|
+
this.applyTraceToIndexes(validated);
|
|
63
|
+
if (compacted) {
|
|
64
|
+
// The active file was rotated; cursor resets to 0 because the new
|
|
65
|
+
// active file is now empty (or will be created fresh on next append).
|
|
66
|
+
this.hydratedSegmentCount += 1;
|
|
67
|
+
this.activeFileCursor = 0;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
// Advance cursor past the bytes we just wrote so incremental hydrate
|
|
71
|
+
// does not re-read them.
|
|
72
|
+
const fileStat = await statOrNull(this.tracesFilePath);
|
|
73
|
+
this.activeFileCursor = fileStat?.size ?? 0;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async readTraces() {
|
|
78
|
+
await this.hydrateIndexesIfNeeded();
|
|
79
|
+
return [...this.orderedTraces];
|
|
80
|
+
}
|
|
81
|
+
async readTracesByTaskId(taskId) {
|
|
82
|
+
await this.hydrateIndexesIfNeeded();
|
|
83
|
+
return [...(this.tracesByTaskId.get(taskId) ?? [])];
|
|
84
|
+
}
|
|
85
|
+
async pruneTask(taskId) {
|
|
86
|
+
await this.hydrateIndexesIfNeeded();
|
|
87
|
+
const receiptIdsToDelete = [];
|
|
88
|
+
for (const [receiptId, indexedTaskId] of this.taskIdByReceiptId.entries()) {
|
|
89
|
+
if (indexedTaskId === taskId) {
|
|
90
|
+
receiptIdsToDelete.push(receiptId);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
for (const receiptId of receiptIdsToDelete) {
|
|
94
|
+
this.taskIdByReceiptId.delete(receiptId);
|
|
95
|
+
}
|
|
96
|
+
this.tracesByTaskId.delete(taskId);
|
|
97
|
+
return receiptIdsToDelete.length;
|
|
98
|
+
}
|
|
99
|
+
async getReceiptIndexSize() {
|
|
100
|
+
await this.hydrateIndexesIfNeeded();
|
|
101
|
+
return this.taskIdByReceiptId.size;
|
|
102
|
+
}
|
|
103
|
+
async hydrateIndexesIfNeeded() {
|
|
104
|
+
if (!this.tracesHydrated) {
|
|
105
|
+
return this.fullHydrate();
|
|
106
|
+
}
|
|
107
|
+
// Incremental: check for new segments and new bytes in active file
|
|
108
|
+
await this.incrementalHydrate();
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Full hydration: reads all segment files (sorted ascending) then the active file.
|
|
112
|
+
* Sets cursor to end of active file for subsequent incremental reads.
|
|
113
|
+
*/
|
|
114
|
+
async fullHydrate() {
|
|
115
|
+
this.resetIndexes();
|
|
116
|
+
const dirStat = await statOrNull(this.tracesDir);
|
|
117
|
+
if (!dirStat) {
|
|
118
|
+
this.tracesHydrated = true;
|
|
119
|
+
this.activeFileCursor = 0;
|
|
120
|
+
this.hydratedSegmentCount = 0;
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
// Read compacted segments in order
|
|
124
|
+
const segments = await this.listSegmentFiles();
|
|
125
|
+
for (const segmentFile of segments) {
|
|
126
|
+
const segmentPath = join(this.tracesDir, segmentFile);
|
|
127
|
+
await this.hydrateFromFile(segmentPath);
|
|
128
|
+
}
|
|
129
|
+
this.hydratedSegmentCount = segments.length;
|
|
130
|
+
// Read active file
|
|
131
|
+
const activeContent = await readFileOrEmpty(this.tracesFilePath);
|
|
132
|
+
if (activeContent.length > 0) {
|
|
133
|
+
this.parseAndApplyLines(activeContent);
|
|
134
|
+
}
|
|
135
|
+
this.activeFileCursor = Buffer.byteLength(activeContent, UTF8_ENCODING);
|
|
136
|
+
this.tracesHydrated = true;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Incremental hydration: only reads new segments (from compaction since last
|
|
140
|
+
* hydration) and new bytes appended to the active file since the cursor.
|
|
141
|
+
* This provides O(1) amortized reads for the hot path.
|
|
142
|
+
*/
|
|
143
|
+
async incrementalHydrate() {
|
|
144
|
+
// Check if compaction created new segments since last hydration
|
|
145
|
+
const currentSegments = await this.listSegmentFiles();
|
|
146
|
+
if (currentSegments.length > this.hydratedSegmentCount) {
|
|
147
|
+
// Read unseen segments in order. This is required for multi-instance
|
|
148
|
+
// writers where another process may rotate active traces into segments
|
|
149
|
+
// that this instance has never indexed.
|
|
150
|
+
const unseenSegments = currentSegments.slice(this.hydratedSegmentCount);
|
|
151
|
+
for (const segmentFile of unseenSegments) {
|
|
152
|
+
const segmentPath = join(this.tracesDir, segmentFile);
|
|
153
|
+
await this.hydrateFromFile(segmentPath);
|
|
154
|
+
}
|
|
155
|
+
this.hydratedSegmentCount = currentSegments.length;
|
|
156
|
+
// The active file was rotated, so the cursor resets.
|
|
157
|
+
// Read whatever is now in the new active file from the start.
|
|
158
|
+
this.activeFileCursor = 0;
|
|
159
|
+
}
|
|
160
|
+
// Read only new bytes from the active file
|
|
161
|
+
const activeFileStat = await statOrNull(this.tracesFilePath);
|
|
162
|
+
const activeSize = activeFileStat?.size ?? 0;
|
|
163
|
+
if (activeSize <= this.activeFileCursor) {
|
|
164
|
+
return; // No new data
|
|
165
|
+
}
|
|
166
|
+
// Read only the delta
|
|
167
|
+
const handle = await open(this.tracesFilePath, 'r');
|
|
168
|
+
try {
|
|
169
|
+
const deltaSize = activeSize - this.activeFileCursor;
|
|
170
|
+
const buffer = Buffer.alloc(deltaSize);
|
|
171
|
+
await handle.read(buffer, 0, deltaSize, this.activeFileCursor);
|
|
172
|
+
const deltaContent = buffer.toString(UTF8_ENCODING);
|
|
173
|
+
if (deltaContent.trim().length > 0) {
|
|
174
|
+
this.parseAndApplyLines(deltaContent);
|
|
175
|
+
}
|
|
176
|
+
this.activeFileCursor = activeSize;
|
|
177
|
+
}
|
|
178
|
+
finally {
|
|
179
|
+
await handle.close();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Lists compacted segment files sorted in ascending order.
|
|
184
|
+
* Segment files follow the pattern: tool-traces.NNNN.jsonl
|
|
185
|
+
*/
|
|
186
|
+
async listSegmentFiles() {
|
|
187
|
+
let files;
|
|
188
|
+
try {
|
|
189
|
+
files = await readdir(this.tracesDir);
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
const nodeError = error;
|
|
193
|
+
if (nodeError.code === 'ENOENT') {
|
|
194
|
+
return [];
|
|
195
|
+
}
|
|
196
|
+
throw error;
|
|
197
|
+
}
|
|
198
|
+
return files
|
|
199
|
+
.filter((f) => SEGMENT_FILE_PATTERN.test(f))
|
|
200
|
+
.sort((a, b) => {
|
|
201
|
+
const matchA = a.match(SEGMENT_FILE_PATTERN);
|
|
202
|
+
const matchB = b.match(SEGMENT_FILE_PATTERN);
|
|
203
|
+
const numA = matchA ? parseInt(matchA[1] ?? '0', 10) : 0;
|
|
204
|
+
const numB = matchB ? parseInt(matchB[1] ?? '0', 10) : 0;
|
|
205
|
+
return numA - numB;
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Reads an entire file and applies all trace lines to the indexes.
|
|
210
|
+
*/
|
|
211
|
+
async hydrateFromFile(filePath) {
|
|
212
|
+
const content = await readFileOrEmpty(filePath);
|
|
213
|
+
if (content.trim().length > 0) {
|
|
214
|
+
this.parseAndApplyLines(content);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Parses newline-delimited JSON lines and applies each to the indexes.
|
|
219
|
+
*/
|
|
220
|
+
parseAndApplyLines(content) {
|
|
221
|
+
const lines = content
|
|
222
|
+
.split('\n')
|
|
223
|
+
.map((line) => line.trim())
|
|
224
|
+
.filter(Boolean);
|
|
225
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
226
|
+
const line = lines[index];
|
|
227
|
+
if (!line) {
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
const parsed = (() => {
|
|
231
|
+
try {
|
|
232
|
+
return JSON.parse(line);
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
throw new Error(`Malformed evidence trace JSON at line ${index + 1}`, { cause: error });
|
|
236
|
+
}
|
|
237
|
+
})();
|
|
238
|
+
this.applyTraceToIndexes(ToolTraceEntrySchema.parse(parsed));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Rotates the active JSONL file to a numbered segment if it exceeds the
|
|
243
|
+
* compaction threshold. Called within the file lock after each append.
|
|
244
|
+
* @returns true if compaction (rotation) occurred.
|
|
245
|
+
*/
|
|
246
|
+
async compactIfNeeded() {
|
|
247
|
+
const fileStat = await statOrNull(this.tracesFilePath);
|
|
248
|
+
if (!fileStat) {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
if (fileStat.size < this.compactionThresholdBytes) {
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
// Determine the next segment number
|
|
255
|
+
const segments = await this.listSegmentFiles();
|
|
256
|
+
let nextNumber = 1;
|
|
257
|
+
if (segments.length > 0) {
|
|
258
|
+
const lastSegment = segments[segments.length - 1];
|
|
259
|
+
if (lastSegment) {
|
|
260
|
+
const match = lastSegment.match(SEGMENT_FILE_PATTERN);
|
|
261
|
+
if (match) {
|
|
262
|
+
nextNumber = parseInt(match[1] ?? '0', 10) + 1;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
const segmentName = `tool-traces.${String(nextNumber).padStart(8, '0')}.jsonl`;
|
|
267
|
+
const segmentPath = join(this.tracesDir, segmentName);
|
|
268
|
+
// Atomic rename: active file becomes the new segment
|
|
269
|
+
await rename(this.tracesFilePath, segmentPath);
|
|
270
|
+
return true;
|
|
271
|
+
}
|
|
272
|
+
resetIndexes() {
|
|
273
|
+
this.orderedTraces = [];
|
|
274
|
+
this.tracesByTaskId = new Map();
|
|
275
|
+
this.taskIdByReceiptId = new Map();
|
|
276
|
+
this.seenTraceKeys = new Set();
|
|
277
|
+
}
|
|
278
|
+
applyTraceToIndexes(entry) {
|
|
279
|
+
const traceKey = `${entry.receipt_id}:${entry.kind}`;
|
|
280
|
+
if (this.seenTraceKeys.has(traceKey)) {
|
|
281
|
+
return; // Dedup: already indexed (WU-1881)
|
|
282
|
+
}
|
|
283
|
+
this.seenTraceKeys.add(traceKey);
|
|
284
|
+
this.orderedTraces.push(entry);
|
|
285
|
+
if (entry.kind === TOOL_TRACE_KINDS.TOOL_CALL_STARTED) {
|
|
286
|
+
this.taskIdByReceiptId.set(entry.receipt_id, entry.task_id);
|
|
287
|
+
const bucket = this.tracesByTaskId.get(entry.task_id) ?? [];
|
|
288
|
+
bucket.push(entry);
|
|
289
|
+
this.tracesByTaskId.set(entry.task_id, bucket);
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
const taskId = this.taskIdByReceiptId.get(entry.receipt_id);
|
|
293
|
+
if (!taskId) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
const bucket = this.tracesByTaskId.get(taskId) ?? [];
|
|
297
|
+
bucket.push(entry);
|
|
298
|
+
this.tracesByTaskId.set(taskId, bucket);
|
|
299
|
+
}
|
|
300
|
+
async persistData(data) {
|
|
301
|
+
const serialized = canonicalStringify(data);
|
|
302
|
+
const dataHash = sha256Hex(serialized);
|
|
303
|
+
const dataRef = join(this.inputsDir, dataHash);
|
|
304
|
+
await mkdir(this.inputsDir, { recursive: true });
|
|
305
|
+
try {
|
|
306
|
+
const handle = await open(dataRef, 'wx');
|
|
307
|
+
try {
|
|
308
|
+
await handle.writeFile(serialized, UTF8_ENCODING);
|
|
309
|
+
}
|
|
310
|
+
finally {
|
|
311
|
+
await handle.close();
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
catch (error) {
|
|
315
|
+
const nodeError = error;
|
|
316
|
+
if (nodeError.code !== 'EEXIST') {
|
|
317
|
+
throw error;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return {
|
|
321
|
+
dataHash,
|
|
322
|
+
dataRef,
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
/** @deprecated Use persistData instead */
|
|
326
|
+
async persistInput(input) {
|
|
327
|
+
return this.persistData(input);
|
|
328
|
+
}
|
|
329
|
+
async reconcileOrphanedStarts() {
|
|
330
|
+
const traces = await this.readTraces();
|
|
331
|
+
const started = new Map();
|
|
332
|
+
const finished = new Set();
|
|
333
|
+
for (const trace of traces) {
|
|
334
|
+
if (trace.kind === TOOL_TRACE_KINDS.TOOL_CALL_STARTED) {
|
|
335
|
+
started.set(trace.receipt_id, trace);
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
finished.add(trace.receipt_id);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
let reconciled = 0;
|
|
342
|
+
for (const [receiptId] of started) {
|
|
343
|
+
if (finished.has(receiptId)) {
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
const policyDecisions = [
|
|
347
|
+
{
|
|
348
|
+
policy_id: KERNEL_POLICY_IDS.RECONCILIATION,
|
|
349
|
+
decision: 'deny',
|
|
350
|
+
reason: 'Orphaned started trace without matching finished trace',
|
|
351
|
+
},
|
|
352
|
+
];
|
|
353
|
+
await this.appendTrace({
|
|
354
|
+
schema_version: 1,
|
|
355
|
+
kind: TOOL_TRACE_KINDS.TOOL_CALL_FINISHED,
|
|
356
|
+
receipt_id: receiptId,
|
|
357
|
+
timestamp: new Date().toISOString(),
|
|
358
|
+
result: 'crashed',
|
|
359
|
+
duration_ms: 0,
|
|
360
|
+
scope_enforcement_note: 'Synthetic crashed finish generated by orphan reconciliation.',
|
|
361
|
+
policy_decisions: policyDecisions,
|
|
362
|
+
artifacts_written: [],
|
|
363
|
+
});
|
|
364
|
+
reconciled += 1;
|
|
365
|
+
}
|
|
366
|
+
return reconciled;
|
|
367
|
+
}
|
|
368
|
+
async withFileLock(operation) {
|
|
369
|
+
await mkdir(this.tracesDir, { recursive: true });
|
|
370
|
+
for (let attempt = 0; attempt <= this.lockMaxRetries; attempt += 1) {
|
|
371
|
+
let handle = null;
|
|
372
|
+
try {
|
|
373
|
+
handle = await open(this.tracesLockFilePath, 'wx');
|
|
374
|
+
const result = await operation();
|
|
375
|
+
await handle.close();
|
|
376
|
+
await rm(this.tracesLockFilePath, { force: true });
|
|
377
|
+
return result;
|
|
378
|
+
}
|
|
379
|
+
catch (error) {
|
|
380
|
+
const nodeError = error;
|
|
381
|
+
if (handle) {
|
|
382
|
+
try {
|
|
383
|
+
await handle.close();
|
|
384
|
+
}
|
|
385
|
+
catch {
|
|
386
|
+
// Best-effort cleanup; preserve the original operation error.
|
|
387
|
+
}
|
|
388
|
+
try {
|
|
389
|
+
await rm(this.tracesLockFilePath, { force: true });
|
|
390
|
+
}
|
|
391
|
+
catch {
|
|
392
|
+
// Best-effort cleanup; preserve the original operation error.
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
if (nodeError.code === 'EEXIST') {
|
|
396
|
+
if (attempt < this.lockMaxRetries) {
|
|
397
|
+
await sleep(this.lockRetryDelayMs);
|
|
398
|
+
continue;
|
|
399
|
+
}
|
|
400
|
+
break;
|
|
401
|
+
}
|
|
402
|
+
// Non-lock failures from the operation itself must surface directly.
|
|
403
|
+
throw error;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
throw new Error(`Failed to acquire evidence-store lock at ${this.tracesLockFilePath}`);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
//# sourceMappingURL=evidence-store.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,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;oBACrD,CAAC;oBAAC,MAAM,CAAC;wBACP,8DAA8D;oBAChE,CAAC;gBACH,CAAC;gBAED,IAAI,SAAS,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBAChC,IAAI,OAAO,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;wBAClC,MAAM,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;wBACnC,SAAS;oBACX,CAAC;oBACD,MAAM;gBACR,CAAC;gBAED,qEAAqE;gBACrE,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,4CAA4C,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACzF,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Stats } from 'node:fs';
|
|
2
|
+
/**
|
|
3
|
+
* Reads a file and returns its content as a string.
|
|
4
|
+
* Returns an empty string when the file does not exist (ENOENT).
|
|
5
|
+
* Rethrows all other errors.
|
|
6
|
+
*/
|
|
7
|
+
export declare function readFileOrEmpty(filePath: string): Promise<string>;
|
|
8
|
+
/**
|
|
9
|
+
* Returns the fs.Stats for a path, or null when the path does not exist (ENOENT).
|
|
10
|
+
* Rethrows all other errors.
|
|
11
|
+
*/
|
|
12
|
+
export declare function statOrNull(filePath: string): Promise<Stats | null>;
|
|
13
|
+
//# sourceMappingURL=fs-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-helpers.d.ts","sourceRoot":"","sources":["../../src/evidence/fs-helpers.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGrC;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAUvE;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAUxE"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Copyright (c) 2026 Hellmai Ltd
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { readFile, stat } from 'node:fs/promises';
|
|
4
|
+
import { UTF8_ENCODING } from '../shared-constants.js';
|
|
5
|
+
/**
|
|
6
|
+
* Reads a file and returns its content as a string.
|
|
7
|
+
* Returns an empty string when the file does not exist (ENOENT).
|
|
8
|
+
* Rethrows all other errors.
|
|
9
|
+
*/
|
|
10
|
+
export async function readFileOrEmpty(filePath) {
|
|
11
|
+
try {
|
|
12
|
+
return await readFile(filePath, UTF8_ENCODING);
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
const nodeError = error;
|
|
16
|
+
if (nodeError.code === 'ENOENT') {
|
|
17
|
+
return '';
|
|
18
|
+
}
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns the fs.Stats for a path, or null when the path does not exist (ENOENT).
|
|
24
|
+
* Rethrows all other errors.
|
|
25
|
+
*/
|
|
26
|
+
export async function statOrNull(filePath) {
|
|
27
|
+
try {
|
|
28
|
+
return await stat(filePath);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
const nodeError = error;
|
|
32
|
+
if (nodeError.code === 'ENOENT') {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=fs-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-helpers.js","sourceRoot":"","sources":["../../src/evidence/fs-helpers.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,sCAAsC;AAEtC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,QAAgB;IACpD,IAAI,CAAC;QACH,OAAO,MAAM,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;IACjD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,SAAS,GAAG,KAA8B,CAAC;QACjD,IAAI,SAAS,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAChC,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,QAAgB;IAC/C,IAAI,CAAC;QACH,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,SAAS,GAAG,KAA8B,CAAC;QACjD,IAAI,SAAS,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/evidence/index.ts"],"names":[],"mappings":"AAGA,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/evidence/index.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,sCAAsC;AAEtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @lumenflow/kernel
|
|
3
|
+
* Domain-agnostic runtime contracts for LumenFlow.
|
|
4
|
+
*/
|
|
5
|
+
export * from './canonical-json.js';
|
|
6
|
+
export * from './evidence/index.js';
|
|
7
|
+
export * from './event-kinds.js';
|
|
8
|
+
export * from './event-store/index.js';
|
|
9
|
+
export * from './kernel.schemas.js';
|
|
10
|
+
export * from './pack/index.js';
|
|
11
|
+
export * from './policy/index.js';
|
|
12
|
+
export * from './runtime/index.js';
|
|
13
|
+
export * from './sandbox/index.js';
|
|
14
|
+
export * from './shared-constants.js';
|
|
15
|
+
export * from './state-machine/index.js';
|
|
16
|
+
export * from './tool-host/index.js';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;GAGG;AAEH,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Copyright (c) 2026 Hellmai Ltd
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
/**
|
|
4
|
+
* @lumenflow/kernel
|
|
5
|
+
* Domain-agnostic runtime contracts for LumenFlow.
|
|
6
|
+
*/
|
|
7
|
+
export * from './canonical-json.js';
|
|
8
|
+
export * from './evidence/index.js';
|
|
9
|
+
export * from './event-kinds.js';
|
|
10
|
+
export * from './event-store/index.js';
|
|
11
|
+
export * from './kernel.schemas.js';
|
|
12
|
+
export * from './pack/index.js';
|
|
13
|
+
export * from './policy/index.js';
|
|
14
|
+
export * from './runtime/index.js';
|
|
15
|
+
export * from './sandbox/index.js';
|
|
16
|
+
export * from './shared-constants.js';
|
|
17
|
+
export * from './state-machine/index.js';
|
|
18
|
+
export * from './tool-host/index.js';
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,sCAAsC;AAEtC;;;GAGG;AAEH,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC"}
|