omp-fabric 1.9.1 → 1.10.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/CHANGELOG.md +12 -0
- package/dist/commands/fabric.d.ts.map +1 -1
- package/dist/compaction/lcm-maintenance.d.ts +8 -1
- package/dist/compaction/lcm-maintenance.d.ts.map +1 -1
- package/dist/compaction/lcm-runtime.d.ts +26 -0
- package/dist/compaction/lcm-runtime.d.ts.map +1 -1
- package/dist/compaction/lcm-runtime.js +81 -4
- package/dist/compaction/lcm-runtime.js.map +2 -2
- package/dist/fabric-runtime-state.d.ts +47 -0
- package/dist/fabric-runtime-state.d.ts.map +1 -1
- package/dist/fabric-runtime-state.js.map +2 -2
- package/dist/index.js +2 -51
- package/dist/index.js.map +3 -3
- package/dist/storage/lcm-ledger.d.ts +8 -0
- package/dist/storage/lcm-ledger.d.ts.map +1 -1
- package/dist/ui/controller.d.ts.map +1 -1
- package/dist/ui/dashboard-model.d.ts +1 -1
- package/dist/ui/dashboard-model.d.ts.map +1 -1
- package/dist/ui/dashboard.d.ts +18 -0
- package/dist/ui/dashboard.d.ts.map +1 -1
- package/dist/ui/dashboard.js +498 -64
- package/dist/ui/dashboard.js.map +4 -4
- package/dist/ui/lcm-panel.d.ts +38 -0
- package/dist/ui/lcm-panel.d.ts.map +1 -0
- package/docs/compaction.md +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.10.0
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- The dashboard carries the LCM ledger on key `3`. It shows the coverage band for the active branch, the node graph paged in bounded requests, the text a compaction would assemble right now beside the session payload it draws from, and a node detail that opens the exact stored raw entry behind any source. A node whose excerpt was later replaced by a model summary shows both, so the upgrade can be judged rather than assumed.
|
|
8
|
+
- Summary nodes keep their replaced text. `summary_node_revisions` records the prior text and model hash whenever maintenance rewrites a node, which is what makes the excerpt-versus-summary comparison possible.
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- `/fabric lcm` is gone; the dashboard view replaces it. The single-line summary in `/fabric status` stays.
|
|
13
|
+
- The ledger read paths that feed the view are aggregates rather than row walks. Measured on a live 5,392-entry session: the coverage scan reads identity columns in 15.7 ms against 150.7 ms for the previous full-row walk, and session payload size is one aggregate at 35.2 ms against roughly 620 ms for the per-entry loop it replaces. Preview, coverage, and the coverage map now share a single frontier walk, and node listing pages in SQL rather than slicing an oversized read.
|
|
14
|
+
|
|
3
15
|
## 1.9.1
|
|
4
16
|
|
|
5
17
|
### Fixed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fabric.d.ts","sourceRoot":"","sources":["../../src/commands/fabric.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAErF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAKtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AA8C9D,UAAU,iBAAiB;IACzB,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,aAAa,EAAE,mBAAmB,CAAC;IACnC,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAC/B,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,0BAA0B,CAAC,EAAE,MAAM,IAAI,CAAC;IACxC,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;CACjC;AA6HD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,iBAAiB,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"fabric.d.ts","sourceRoot":"","sources":["../../src/commands/fabric.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAErF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAKtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AA8C9D,UAAU,iBAAiB;IACzB,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,aAAa,EAAE,mBAAmB,CAAC;IACnC,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAC/B,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,0BAA0B,CAAC,EAAE,MAAM,IAAI,CAAC;IACxC,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;CACjC;AA6HD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,iBAAiB,GAAG,IAAI,CAw+BtF"}
|
|
@@ -76,10 +76,17 @@ export declare class LcmMaintenance {
|
|
|
76
76
|
private readonly modelTimeoutMs;
|
|
77
77
|
constructor(ledger: LcmLedger, options?: LcmMaintenanceOptions);
|
|
78
78
|
budgetPolicy(): LcmBudgetPolicy;
|
|
79
|
+
private recordRevision;
|
|
80
|
+
revisionsOf(nodeId: string): Array<{
|
|
81
|
+
revision: number;
|
|
82
|
+
text: string;
|
|
83
|
+
modelHash: string;
|
|
84
|
+
createdAt: number;
|
|
85
|
+
}>;
|
|
79
86
|
selectUpgrades(sessionId?: string, activeSources?: ReadonlySet<string>, branch?: string | null, limit?: number): LcmNode[];
|
|
80
87
|
ancestorsOf(nodeId: string): string[];
|
|
81
88
|
reopen(nodeId: string, force?: boolean): LcmJob;
|
|
82
|
-
listNodes(limit?: number): LcmNode[];
|
|
89
|
+
listNodes(limit?: number, offset?: number): LcmNode[];
|
|
83
90
|
getNode(nodeId: string): LcmNode | undefined;
|
|
84
91
|
getFrontier(sessionId?: string, branch?: string | null, activeSources?: ReadonlySet<string>): LcmNode[];
|
|
85
92
|
listJobs(limit?: number): LcmJob[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lcm-maintenance.d.ts","sourceRoot":"","sources":["../../src/compaction/lcm-maintenance.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"lcm-maintenance.d.ts","sourceRoot":"","sources":["../../src/compaction/lcm-maintenance.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAmC,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE1G,KAAK,YAAY,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;AAC/D,KAAK,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;AAClE,MAAM,WAAW,YAAY;IAAG,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;CAAE;AAE5G,MAAM,WAAW,OAAO;IAAG,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CA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EAAC,MAAM,GAAG,OAAO;IACnD,IAAI,CAAC,GAAG,EAAC,MAAM,EAAC,KAAK,EAAC,MAAM,GAAG,MAAM;IAC/B,GAAG,CAAC,GAAG,EAAC,MAAM,EAAE,KAAK,EAAC,aAAa,EAAE,KAAK,EAAC,MAAM,EAAE,MAAM,cAA6B,GAAG,OAAO,CAAC,OAAO,CAAC;IAC/G,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,MAAM;CACf"}
|
|
@@ -2,6 +2,14 @@ import type { ExtensionContext } from "@oh-my-pi/pi-coding-agent";
|
|
|
2
2
|
import { LcmLedger, type RawEntry } from "../storage/lcm-ledger.js";
|
|
3
3
|
import { LcmMaintenance, type LcmNode } from "./lcm-maintenance.js";
|
|
4
4
|
import type { LcmCompactionInput, LcmCompactionOutput } from "./hook.js";
|
|
5
|
+
export interface LcmPreview {
|
|
6
|
+
text: string;
|
|
7
|
+
nodes: number;
|
|
8
|
+
summaryBytes: number;
|
|
9
|
+
sourceBytes: number;
|
|
10
|
+
coveredSources: number;
|
|
11
|
+
activeSources: number;
|
|
12
|
+
}
|
|
5
13
|
export interface LcmReport {
|
|
6
14
|
projectKey: string;
|
|
7
15
|
sessionId: string | undefined;
|
|
@@ -74,6 +82,24 @@ export declare class LcmRuntime {
|
|
|
74
82
|
private runMaintenance;
|
|
75
83
|
compact(input: LcmCompactionInput): LcmCompactionOutput;
|
|
76
84
|
report(): LcmReport;
|
|
85
|
+
private frontierCache;
|
|
86
|
+
/** One frontier walk shared by preview, coverage, and the coverage map. */
|
|
87
|
+
private frontierSnapshot;
|
|
88
|
+
private sourceKey;
|
|
89
|
+
/** Assembles what a compaction would serve now. Reads only; it never persists a node. */
|
|
90
|
+
preview(): LcmPreview;
|
|
91
|
+
/** Ordered coverage of the active branch: each entry says whether a ready node holds it. */
|
|
92
|
+
coverageMap(limit?: number): Array<{
|
|
93
|
+
key: string;
|
|
94
|
+
covered: boolean;
|
|
95
|
+
}>;
|
|
96
|
+
nodes(limit?: number, offset?: number): LcmNode[];
|
|
97
|
+
node(nodeId: string): {
|
|
98
|
+
node: LcmNode;
|
|
99
|
+
revisions: ReturnType<LcmMaintenance["revisionsOf"]>;
|
|
100
|
+
ancestors: string[];
|
|
101
|
+
} | undefined;
|
|
102
|
+
source(sessionId: string, entryId: string, revision: number): RawEntry | undefined;
|
|
77
103
|
coverage(): {
|
|
78
104
|
active: number;
|
|
79
105
|
covered: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lcm-runtime.d.ts","sourceRoot":"","sources":["../../src/compaction/lcm-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAiE,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGnI,OAAO,EAAE,cAAc,EAAqC,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACvG,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEzE,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAA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AE,MAAM,GAAG,IAAI;IAInD,GAAG,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,QAAQ,EAAE;IAE7B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAQhC"}
|
|
@@ -36,6 +36,7 @@ CREATE TABLE IF NOT EXISTS project_aliases (alias TEXT PRIMARY KEY, project_key
|
|
|
36
36
|
CREATE TABLE IF NOT EXISTS sessions (project_key TEXT NOT NULL, session_id TEXT NOT NULL, created_at INTEGER NOT NULL, PRIMARY KEY(project_key, session_id));
|
|
37
37
|
CREATE TABLE IF NOT EXISTS raw_entries (project_key TEXT NOT NULL, session_id TEXT NOT NULL, entry_id TEXT NOT NULL, revision INTEGER NOT NULL, role TEXT NOT NULL, content TEXT NOT NULL, content_hash TEXT NOT NULL, payload_json TEXT NOT NULL, parent_entry_id TEXT, branch TEXT, created_at INTEGER NOT NULL, PRIMARY KEY(project_key, session_id, entry_id, revision), UNIQUE(project_key, session_id, entry_id, content_hash));
|
|
38
38
|
CREATE TABLE IF NOT EXISTS summary_nodes (node_id TEXT PRIMARY KEY, project_key TEXT NOT NULL, payload TEXT NOT NULL, created_at INTEGER NOT NULL);
|
|
39
|
+
CREATE TABLE IF NOT EXISTS summary_node_revisions (node_id TEXT NOT NULL, revision INTEGER NOT NULL, project_key TEXT NOT NULL, text TEXT NOT NULL, model_hash TEXT NOT NULL, created_at INTEGER NOT NULL, PRIMARY KEY(node_id, revision));
|
|
39
40
|
CREATE TABLE IF NOT EXISTS summary_edges (parent_id TEXT NOT NULL, child_id TEXT NOT NULL, PRIMARY KEY(parent_id, child_id));
|
|
40
41
|
CREATE TABLE IF NOT EXISTS frontiers (project_key TEXT NOT NULL, frontier_id TEXT NOT NULL, node_id TEXT NOT NULL, created_at INTEGER NOT NULL, PRIMARY KEY(project_key, frontier_id, node_id));
|
|
41
42
|
CREATE TABLE IF NOT EXISTS maintenance_jobs (job_id TEXT PRIMARY KEY, project_key TEXT NOT NULL, status TEXT NOT NULL, payload TEXT NOT NULL, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL);
|
|
@@ -198,6 +199,20 @@ var LcmLedger = class {
|
|
|
198
199
|
const row = this.db.prepare("SELECT * FROM raw_entries WHERE project_key=? AND session_id=? AND entry_id=? AND revision=?").get(projectKey, sessionId, entryId, revision);
|
|
199
200
|
return row ? { projectKey: row.project_key, sessionId: row.session_id, entryId: row.entry_id, revision: row.revision, role: row.role, content: row.content, contentHash: row.content_hash, payloadHash: row.content_hash, payloadJson: row.payload_json, parentEntryId: row.parent_entry_id, branch: row.branch, createdAt: row.created_at } : void 0;
|
|
200
201
|
}
|
|
202
|
+
/** Identity columns only, so a coverage scan never loads payloads. */
|
|
203
|
+
readRawKeys(projectKey = this.project.key, sessionId, limit = 1e5) {
|
|
204
|
+
this.guard();
|
|
205
|
+
this.assertProjectKey(projectKey);
|
|
206
|
+
const rows = sessionId ? this.db.prepare("SELECT session_id, entry_id, revision FROM raw_entries WHERE project_key=? AND session_id=? ORDER BY created_at,revision LIMIT ?").all(projectKey, sessionId, limit) : this.db.prepare("SELECT session_id, entry_id, revision FROM raw_entries WHERE project_key=? ORDER BY created_at,session_id,entry_id,revision LIMIT ?").all(projectKey, limit);
|
|
207
|
+
return rows.map((row) => ({ sessionId: row.session_id, entryId: row.entry_id, revision: Number(row.revision) }));
|
|
208
|
+
}
|
|
209
|
+
/** Total stored payload bytes for one session, as a single aggregate. */
|
|
210
|
+
payloadBytes(projectKey = this.project.key, sessionId) {
|
|
211
|
+
this.guard();
|
|
212
|
+
this.assertProjectKey(projectKey);
|
|
213
|
+
const row = sessionId ? this.db.prepare("SELECT coalesce(sum(length(payload_json)),0) n FROM raw_entries WHERE project_key=? AND session_id=?").get(projectKey, sessionId) : this.db.prepare("SELECT coalesce(sum(length(payload_json)),0) n FROM raw_entries WHERE project_key=?").get(projectKey);
|
|
214
|
+
return Number(row.n);
|
|
215
|
+
}
|
|
201
216
|
readOnly(fn) {
|
|
202
217
|
this.guard();
|
|
203
218
|
return fn(this.db);
|
|
@@ -610,6 +625,14 @@ var LcmMaintenance = class {
|
|
|
610
625
|
budgetPolicy() {
|
|
611
626
|
return { ...this.budget };
|
|
612
627
|
}
|
|
628
|
+
recordRevision(db, node) {
|
|
629
|
+
if (!node.text) return;
|
|
630
|
+
const row = db.prepare("SELECT coalesce(max(revision),0) n FROM summary_node_revisions WHERE node_id=?").get(node.nodeId);
|
|
631
|
+
db.prepare("INSERT OR IGNORE INTO summary_node_revisions(node_id,revision,project_key,text,model_hash,created_at) VALUES(?,?,?,?,?,?)").run(node.nodeId, Number(row.n) + 1, this.projectKey, node.text, node.modelHash, this.now());
|
|
632
|
+
}
|
|
633
|
+
revisionsOf(nodeId) {
|
|
634
|
+
return this.ledger.readOnly((db) => db.prepare("SELECT revision, text, model_hash, created_at FROM summary_node_revisions WHERE node_id=? AND project_key=? ORDER BY revision").all(nodeId, this.projectKey).map((row) => ({ revision: Number(row.revision), text: row.text, modelHash: row.model_hash, createdAt: Number(row.created_at) })));
|
|
635
|
+
}
|
|
613
636
|
selectUpgrades(sessionId, activeSources, branch, limit = 1) {
|
|
614
637
|
return this.listNodes(1e5).filter((node) => node.state === "ready" && node.modelHash === "emergency" && node.policyHash === this.policyHash && (!sessionId || node.sessionId === sessionId) && (branch === void 0 || node.branch === branch || node.branch === null) && (!activeSources || node.sources.every((source) => activeSources.has(this.sourceKey(source))))).sort((left, right) => left.depth - right.depth || left.nodeId.localeCompare(right.nodeId)).slice(0, limit);
|
|
615
638
|
}
|
|
@@ -644,8 +667,8 @@ var LcmMaintenance = class {
|
|
|
644
667
|
return job;
|
|
645
668
|
});
|
|
646
669
|
}
|
|
647
|
-
listNodes(limit = 100) {
|
|
648
|
-
return this.ledger.readOnly((db) => db.prepare("SELECT payload FROM summary_nodes WHERE project_key=? ORDER BY created_at,node_id LIMIT ?").all(this.projectKey, limit).map((r) => {
|
|
670
|
+
listNodes(limit = 100, offset = 0) {
|
|
671
|
+
return this.ledger.readOnly((db) => db.prepare("SELECT payload FROM summary_nodes WHERE project_key=? ORDER BY created_at,node_id LIMIT ? OFFSET ?").all(this.projectKey, limit, offset).map((r) => {
|
|
649
672
|
const node = parse(r.payload);
|
|
650
673
|
if (node.projectKey !== this.projectKey) throw new Error("node project does not match ledger project");
|
|
651
674
|
return node;
|
|
@@ -827,6 +850,7 @@ var LcmMaintenance = class {
|
|
|
827
850
|
const projectUsage = this.usage(db, this.day(this.now()));
|
|
828
851
|
const sessionUsage = this.usage(db, this.day(this.now()), node.sessionId);
|
|
829
852
|
if (projectUsage.calls + 1 > this.budget.calls || projectUsage.inputTokens + result.inputTokens > this.budget.inputTokens || projectUsage.outputTokens + result.outputTokens > this.budget.outputTokens || projectUsage.cost + result.cost > this.budget.cost || projectUsage.wallMs + result.wallMs > this.budget.wallMs || sessionUsage.calls + 1 > this.budget.sessionCalls) throw new Error("budget exhausted");
|
|
853
|
+
this.recordRevision(db, node);
|
|
830
854
|
const out = { ...node, state: "ready", text: result.text, modelHash: result.modelHash };
|
|
831
855
|
this.account(db, node.sessionId, result);
|
|
832
856
|
db.prepare("UPDATE summary_nodes SET payload=? WHERE node_id=? AND project_key=?").run(JSON.stringify(out), node.nodeId, this.projectKey);
|
|
@@ -850,6 +874,7 @@ var LcmMaintenance = class {
|
|
|
850
874
|
const raw = db.prepare("SELECT payload_json,session_id FROM raw_entries WHERE project_key=? AND session_id=? AND entry_id=? AND revision=?").get(this.projectKey, source.sessionId, source.entryId, source.revision);
|
|
851
875
|
if (!raw?.payload_json || hash3(parse(raw.payload_json)) !== source.payloadHash || raw.session_id !== source.sessionId) throw new Error("stale source");
|
|
852
876
|
}
|
|
877
|
+
this.recordRevision(db, node);
|
|
853
878
|
const out = { ...node, state: "ready", text, modelHash: "emergency" };
|
|
854
879
|
db.prepare("UPDATE summary_nodes SET payload=? WHERE node_id=? AND project_key=?").run(JSON.stringify(out), node.nodeId, this.projectKey);
|
|
855
880
|
const { ownerId: _ownerId, leaseToken: _leaseToken, leaseUntil: _leaseUntil, ...base } = current;
|
|
@@ -1226,10 +1251,62 @@ var LcmRuntime = class {
|
|
|
1226
1251
|
};
|
|
1227
1252
|
});
|
|
1228
1253
|
}
|
|
1254
|
+
frontierCache;
|
|
1255
|
+
/** One frontier walk shared by preview, coverage, and the coverage map. */
|
|
1256
|
+
frontierSnapshot() {
|
|
1257
|
+
const sessionId = this.activeSessionId ?? "";
|
|
1258
|
+
const branch = this.context.sessionManager.getLeafId();
|
|
1259
|
+
const cached = this.frontierCache;
|
|
1260
|
+
if (cached && cached.sessionId === sessionId && cached.branch === branch && Date.now() - cached.at < 250) {
|
|
1261
|
+
return { nodes: cached.nodes, covered: cached.covered };
|
|
1262
|
+
}
|
|
1263
|
+
const nodes = sessionId ? this.maintenance.getFrontier(sessionId, branch, this.activeSources) : [];
|
|
1264
|
+
const covered = new Set(nodes.flatMap((node) => node.sources.map((source) => this.sourceKey(source))));
|
|
1265
|
+
this.frontierCache = { at: Date.now(), sessionId, branch, nodes, covered };
|
|
1266
|
+
return { nodes, covered };
|
|
1267
|
+
}
|
|
1268
|
+
sourceKey(source) {
|
|
1269
|
+
return `${source.sessionId}:${source.entryId}:${source.revision}`;
|
|
1270
|
+
}
|
|
1271
|
+
/** Assembles what a compaction would serve now. Reads only; it never persists a node. */
|
|
1272
|
+
preview() {
|
|
1273
|
+
const sessionId = this.activeSessionId;
|
|
1274
|
+
if (!sessionId) return { text: "", nodes: 0, summaryBytes: 0, sourceBytes: 0, coveredSources: 0, activeSources: 0 };
|
|
1275
|
+
const { nodes, covered } = this.frontierSnapshot();
|
|
1276
|
+
const text = nodes.map((node) => node.text ?? "").filter(Boolean).join("\n\n");
|
|
1277
|
+
return {
|
|
1278
|
+
text,
|
|
1279
|
+
nodes: nodes.length,
|
|
1280
|
+
summaryBytes: Buffer.byteLength(text, "utf8"),
|
|
1281
|
+
sourceBytes: this.ledger.payloadBytes(this.projectKey, sessionId),
|
|
1282
|
+
coveredSources: covered.size,
|
|
1283
|
+
activeSources: this.activeSources.size
|
|
1284
|
+
};
|
|
1285
|
+
}
|
|
1286
|
+
/** Ordered coverage of the active branch: each entry says whether a ready node holds it. */
|
|
1287
|
+
coverageMap(limit = 2e3) {
|
|
1288
|
+
const sessionId = this.activeSessionId;
|
|
1289
|
+
if (!sessionId) return [];
|
|
1290
|
+
const { covered } = this.frontierSnapshot();
|
|
1291
|
+
return this.ledger.readRawKeys(this.projectKey, sessionId, limit).map((entry) => {
|
|
1292
|
+
const key = this.sourceKey(entry);
|
|
1293
|
+
return { key, covered: covered.has(key) };
|
|
1294
|
+
});
|
|
1295
|
+
}
|
|
1296
|
+
nodes(limit = 200, offset = 0) {
|
|
1297
|
+
return this.maintenance.listNodes(limit, offset);
|
|
1298
|
+
}
|
|
1299
|
+
node(nodeId) {
|
|
1300
|
+
const node = this.maintenance.getNode(nodeId);
|
|
1301
|
+
if (!node) return void 0;
|
|
1302
|
+
return { node, revisions: this.maintenance.revisionsOf(nodeId), ancestors: this.maintenance.ancestorsOf(nodeId) };
|
|
1303
|
+
}
|
|
1304
|
+
source(sessionId, entryId, revision) {
|
|
1305
|
+
return this.ledger.readRawEntry(this.projectKey, sessionId, entryId, revision);
|
|
1306
|
+
}
|
|
1229
1307
|
coverage() {
|
|
1230
1308
|
if (!this.activeSessionId) return { active: 0, covered: 0 };
|
|
1231
|
-
const
|
|
1232
|
-
const covered = new Set(frontier.flatMap((node) => node.sources.map((source) => `${source.sessionId}:${source.entryId}:${source.revision}`)));
|
|
1309
|
+
const { covered } = this.frontierSnapshot();
|
|
1233
1310
|
let hits = 0;
|
|
1234
1311
|
for (const key of this.activeSources) if (covered.has(key)) hits += 1;
|
|
1235
1312
|
return { active: this.activeSources.size, covered: hits };
|