@volter/supercode-orchestrator 0.4.146 → 0.4.147
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/board/ztrack.mjs +28 -2
- package/package.json +1 -1
package/board/ztrack.mjs
CHANGED
|
@@ -27,6 +27,14 @@ const sqliteContention = error => [5, 6].includes(Number(error?.errcode) & 255)
|
|
|
27
27
|
|| /^database (?:table |schema )?is locked$/i.test(error?.message ?? '');
|
|
28
28
|
const exportConflict = error => error?.message === 'Hermes wrote during board export; retained its events for the next read';
|
|
29
29
|
const recoveryConflict = error => error?.message === 'document changed during recovery; retry';
|
|
30
|
+
// One-shot verbs open the same board several times. Share byte-keyed codec
|
|
31
|
+
// work across those instances and cap retention for long-running dispatchers.
|
|
32
|
+
const documentCache = new Map(), renderCache = new Map();
|
|
33
|
+
function remember(cache, path, value) {
|
|
34
|
+
cache.delete(path);
|
|
35
|
+
cache.set(path, value);
|
|
36
|
+
while (cache.size > 8) cache.delete(cache.keys().next().value);
|
|
37
|
+
}
|
|
30
38
|
|
|
31
39
|
export function openZtrackBoard(marker, { create = false, document = null, seed = null, init, root, slug, compatPath }) {
|
|
32
40
|
if (!existsSync(marker)) {
|
|
@@ -49,6 +57,9 @@ class ZtrackBoard {
|
|
|
49
57
|
this.runtime = new DatabaseSync(this.runtimePath);
|
|
50
58
|
this.readOnly(()=>{ if (!this.runtime.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='state'").get()) this.runtime.exec('CREATE TABLE IF NOT EXISTS state (key TEXT PRIMARY KEY, value TEXT NOT NULL)'); });
|
|
51
59
|
this.errors = new Map(); this.preserve = new Map();
|
|
60
|
+
// Codec projections depend on document bytes, not runtime revisions. Keep one
|
|
61
|
+
// entry per document across optimistic retries; run/event churn must not
|
|
62
|
+
// repeatedly parse an unchanged board before reaching its version check.
|
|
52
63
|
this.mem = null; this.active = false; this.rows = new RuntimeRows(this.runtime);
|
|
53
64
|
mkdirSync(dirname(this.path), { recursive: true });
|
|
54
65
|
const self = this;
|
|
@@ -325,7 +336,7 @@ class ZtrackBoard {
|
|
|
325
336
|
this.errors.clear(); this.preserve.clear();
|
|
326
337
|
const records = []; this.documentRecords=new Map();
|
|
327
338
|
for (const [text,path] of [[this.text,this.path],[this.archiveText,this.archive]]) {
|
|
328
|
-
const result = this.
|
|
339
|
+
const result = this.inspectDocument(text,path);
|
|
329
340
|
const kept = new Set(result.errors.map(e=>e.id));
|
|
330
341
|
for(const error of result.errors)this.errors.set(nativeId(error.id),error.reason);
|
|
331
342
|
for(const record of result.records) {
|
|
@@ -478,6 +489,21 @@ class ZtrackBoard {
|
|
|
478
489
|
committer() {
|
|
479
490
|
return 'document-editor';
|
|
480
491
|
}
|
|
492
|
+
inspectDocument(text, path) {
|
|
493
|
+
const previous = documentCache.get(path);
|
|
494
|
+
if (previous?.text === text) return previous.result;
|
|
495
|
+
const result = this.codec.inspectBoardDocument(text, path);
|
|
496
|
+
remember(documentCache, path, { text, result });
|
|
497
|
+
return result;
|
|
498
|
+
}
|
|
499
|
+
renderDocument(text, records, path, preserve) {
|
|
500
|
+
const projection = JSON.stringify([records, preserve]);
|
|
501
|
+
const previous = renderCache.get(path);
|
|
502
|
+
if (previous?.text === text && previous.projection === projection) return previous.result;
|
|
503
|
+
const result = this.codec.renderBoardDocument(text, records, path, preserve);
|
|
504
|
+
remember(renderCache, path, { text, projection, result });
|
|
505
|
+
return result;
|
|
506
|
+
}
|
|
481
507
|
documents(changes=null) {
|
|
482
508
|
this.publishedFingerprints = {};
|
|
483
509
|
const allRows = this.mem.prepare('SELECT * FROM tasks ORDER BY created_at, id').all();
|
|
@@ -551,7 +577,7 @@ class ZtrackBoard {
|
|
|
551
577
|
}
|
|
552
578
|
const original=this.documentRecords;
|
|
553
579
|
const changedPath=path=>!affected||[...affected].some(id=>original?.get(id)?.path===path||cards.has(id)&&((states.get(id)?.archived||['done','cancelled'].includes(cards.get(id).status))?this.archive:this.path)===path);
|
|
554
|
-
return { open: !changedPath(this.path)?this.text:this.
|
|
580
|
+
return { open: !changedPath(this.path)?this.text:this.renderDocument(this.text, open, this.path, [...(this.preserve.get(this.path)??[])]), archived: !changedPath(this.archive)?this.archiveText:this.renderDocument(this.archiveText, archived, this.archive, [...(this.preserve.get(this.archive)??[])]) };
|
|
555
581
|
}
|
|
556
582
|
snapshot(documents) {
|
|
557
583
|
const fingerprints = this.fingerprints();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volter/supercode-orchestrator",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.147",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The orchestrator runtime over the Volter Harness ontology: one typed operational model whose folder is its serialization, read and written through the harness orchestration doors (docs/ORCHESTRATOR-IR.md)",
|
|
6
6
|
"exports": {
|