@quolu/lattice 0.113.1 → 0.113.2
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/package.json +1 -1
- package/src/todo-store.mjs +14 -5
- package/src/todo-version-compact.mjs +11 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quolu/lattice",
|
|
3
|
-
"version": "0.113.
|
|
3
|
+
"version": "0.113.2",
|
|
4
4
|
"description": "Schedulability compiler for multi-agent development: observe real code boundaries, refactor the conflicting seam, recompile the plan for parallel execution",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Quo / クオ at kitepon.dev",
|
package/src/todo-store.mjs
CHANGED
|
@@ -1787,11 +1787,13 @@ async function readTodoStoreView(options = {}) {
|
|
|
1787
1787
|
* unreadable. perf-store: validated once per process per unchanged plan.json (todo-version-memo).
|
|
1788
1788
|
*/
|
|
1789
1789
|
async function retainedPlanVersion(repoRoot, base, version) {
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1790
|
+
// m1: only the three digests stay in the memo; the record itself (a whole revision's migration) is dropped after the read.
|
|
1791
|
+
const identity = await memoByFileIdentity([path.resolve(repoRoot, base, version, TODO_VERSION_COMPACT_FILE)], async () => {
|
|
1792
|
+
const compact = await readCompactRecord(repoRoot, base, version, { verify: false }).catch(() => null);
|
|
1793
|
+
return compact === null ? null : { plan_digest: compact.plan_digest, predecessor_plan_digest: compact.predecessor_plan_digest,
|
|
1794
|
+
topology_digest: compact.topology_digest };
|
|
1795
|
+
});
|
|
1796
|
+
if (identity !== null) return { plan: identity, journalRef: `${base}/${version}/journal/active.jsonl` };
|
|
1795
1797
|
const ref = `${base}/${version}/plan.json`;
|
|
1796
1798
|
const plan = await memoByFileIdentity([path.resolve(repoRoot, ref)], async () => {
|
|
1797
1799
|
const value = await readArtifact(repoRoot, ref, {
|
|
@@ -2905,6 +2907,13 @@ function carriedPlanScopedChain(store, previous, plan, journalRef, taskMigration
|
|
|
2905
2907
|
payload: { from, to, reason: event.payload.reason } });
|
|
2906
2908
|
pushPlanScopedEvent(successor.plan_scoped, carried);
|
|
2907
2909
|
}
|
|
2910
|
+
// m1: the declaration travels with the plan, so a read of this version finds it in its own chain instead of walking every
|
|
2911
|
+
// retained predecessor (a plan declared 975 revisions ago opened all 1,649 compact records per read).
|
|
2912
|
+
if (previous.coordination) {
|
|
2913
|
+
const { mode, reason, declared_by: actor, declared_at: recordedAt } = previous.coordination;
|
|
2914
|
+
pushPlanScopedEvent(successor.plan_scoped, buildPlanScopedEvent(successor, { kind: 'coordination_mode', actor,
|
|
2915
|
+
recorded_at: recordedAt, provenance: null, payload: { mode, reason } }));
|
|
2916
|
+
}
|
|
2908
2917
|
// 接続: only the schedule connections still open travel; a settled or removed one equals no connection.
|
|
2909
2918
|
for (const entry of projectTodoScheduleConnections(previous.plan_scoped?.events ?? [])) {
|
|
2910
2919
|
const taskId = ids.get(entry.task_id);
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
import { readFile } from 'node:fs/promises';
|
|
11
11
|
import { gunzipSync, gzipSync } from 'node:zlib';
|
|
12
12
|
import { canonicalizeTodoArtifact, isTodoDigest, isTodoIdentifier, todoSelfDigest } from './todo-contracts.mjs';
|
|
13
|
-
import { memoByFileIdentity } from './todo-version-memo.mjs';
|
|
14
13
|
|
|
15
14
|
export const TODO_VERSION_COMPACT_SCHEMA = 'lattice.todo_version_compact.v1';
|
|
16
15
|
export const TODO_VERSION_COMPACT_FILE = 'compact.json.gz';
|
|
@@ -104,16 +103,15 @@ export const packVersionCompact = (record) => gzipSync(Buffer.from(`${canonicali
|
|
|
104
103
|
* and keeps the shape check: one gunzip and one parse per version, which a read pays for every retained version of a plan.
|
|
105
104
|
*/
|
|
106
105
|
export async function readVersionCompact(directory, maxBytes = 8 * 1024 * 1024, { verify = true } = {}) {
|
|
107
|
-
//
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}, verify ? 'verify' : 'read');
|
|
106
|
+
// Not memoized: a record holds a revision's whole per-task migration, so keeping one per retained version grew RSS with the
|
|
107
|
+
// revision count (m1). Callers memoize the small value they derive (identity, note migration).
|
|
108
|
+
let packed;
|
|
109
|
+
try { packed = await readFile(`${directory}/${TODO_VERSION_COMPACT_FILE}`); } catch (error) {
|
|
110
|
+
if (error?.code === 'ENOENT') return null;
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
const text = gunzipSync(packed, { maxOutputLength: maxBytes }).toString('utf8');
|
|
114
|
+
const value = JSON.parse(text);
|
|
115
|
+
if ((verify && text !== `${canonicalizeTodoArtifact(value)}\n`) || !validateVersionCompact(value, { verify })) throw new Error('compact_record_invalid');
|
|
116
|
+
return value;
|
|
119
117
|
}
|