@aionis/substrate 0.1.3 → 0.1.5
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 +21 -0
- package/README.md +120 -13
- package/dist/candidate-index.d.ts +25 -0
- package/dist/candidate-index.d.ts.map +1 -0
- package/dist/candidate-index.js +217 -0
- package/dist/candidate-index.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +160 -2
- package/dist/cli.js.map +1 -1
- package/dist/embedding-projection.d.ts +16 -0
- package/dist/embedding-projection.d.ts.map +1 -0
- package/dist/embedding-projection.js +101 -0
- package/dist/embedding-projection.js.map +1 -0
- package/dist/file-substrate.d.ts +3 -0
- package/dist/file-substrate.d.ts.map +1 -1
- package/dist/file-substrate.js +47 -1
- package/dist/file-substrate.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/runtime-live-sidecar.d.ts +79 -0
- package/dist/runtime-live-sidecar.d.ts.map +1 -0
- package/dist/runtime-live-sidecar.js +382 -0
- package/dist/runtime-live-sidecar.js.map +1 -0
- package/dist/search.d.ts +11 -2
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +78 -7
- package/dist/search.js.map +1 -1
- package/dist/sqlite-substrate.d.ts +3 -0
- package/dist/sqlite-substrate.d.ts.map +1 -1
- package/dist/sqlite-substrate.js +61 -6
- package/dist/sqlite-substrate.js.map +1 -1
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/zvec-candidate-index.d.ts +42 -0
- package/dist/zvec-candidate-index.d.ts.map +1 -0
- package/dist/zvec-candidate-index.js +463 -0
- package/dist/zvec-candidate-index.js.map +1 -0
- package/docs/ADAPTER_CONTRACT.md +12 -2
- package/docs/API_USAGE.md +135 -0
- package/docs/CLI.md +76 -1
- package/docs/RUNTIME_DUAL_WRITE_EXPERIMENT.md +14 -0
- package/docs/RUNTIME_LIVE_SIDECAR.md +142 -0
- package/docs/RUNTIME_SNAPSHOT_IMPORT.md +3 -0
- package/docs/RUNTIME_ZVEC_CANDIDATE_INDEX.md +80 -0
- package/docs/STORE_CONTRACT.md +15 -0
- package/docs/V0_2_ROADMAP.md +15 -3
- package/docs/ZVEC_PROVIDER_EMBEDDING_EVAL.md +216 -0
- package/docs/ZVEC_SCALE_MAINTENANCE.md +89 -0
- package/examples/live-sidecar/index.mjs +189 -0
- package/package.json +17 -2
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Zvec Scale Maintenance Check
|
|
2
|
+
|
|
3
|
+
This check validates the optional Zvec candidate sidecar under Substrate-scale write and maintenance operations.
|
|
4
|
+
|
|
5
|
+
It proves a storage/index contract:
|
|
6
|
+
|
|
7
|
+
- SQLite remains the truth store.
|
|
8
|
+
- Zvec receives write-through node upserts while nodes are written.
|
|
9
|
+
- `verify()` reports no missing, orphan, or stale entries after writes.
|
|
10
|
+
- reopening the store rebuilds the sidecar from SQLite truth.
|
|
11
|
+
- wide-window Zvec candidate search preserves canonical Substrate search ids.
|
|
12
|
+
- narrow-window Zvec candidate search recovers seeded exact-node probes.
|
|
13
|
+
- lifecycle transitions update the sidecar fingerprint.
|
|
14
|
+
- checkpoint compaction and post-compaction reopen keep the sidecar verifiable.
|
|
15
|
+
|
|
16
|
+
The check uses the same deterministic local text projection as the Runtime Zvec validation. It validates storage/index maintenance and candidate-window safety. It does not evaluate embedding-provider semantic quality.
|
|
17
|
+
|
|
18
|
+
## Run
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm run check:zvec-scale -- \
|
|
22
|
+
--nodes 10000 \
|
|
23
|
+
--scopes 10 \
|
|
24
|
+
--relations 2000 \
|
|
25
|
+
--feedback 1000 \
|
|
26
|
+
--probes 100 \
|
|
27
|
+
--narrow-candidate-limit 20
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The command writes a report under `reports/zvec-scale-*` unless `--output` is supplied.
|
|
31
|
+
|
|
32
|
+
## Options
|
|
33
|
+
|
|
34
|
+
- `--nodes <n>`: generated memory nodes.
|
|
35
|
+
- `--scopes <n>`: generated scopes.
|
|
36
|
+
- `--relations <n>`: generated relation rows.
|
|
37
|
+
- `--feedback <n>`: generated feedback rows.
|
|
38
|
+
- `--probes <n>`: exact-node search probes.
|
|
39
|
+
- `--narrow-candidate-limit <n>`: Zvec candidate window for narrow seeded recovery probes.
|
|
40
|
+
- `--transitions <n>`: lifecycle transitions to apply after reopen.
|
|
41
|
+
- `--output <dir>`: report directory.
|
|
42
|
+
- `--keep-store`: keep the temporary SQLite and Zvec files for inspection.
|
|
43
|
+
|
|
44
|
+
## Report Interpretation
|
|
45
|
+
|
|
46
|
+
Important fields:
|
|
47
|
+
|
|
48
|
+
- `zvec_health.after_write`: write-through index health.
|
|
49
|
+
- `zvec_health.after_reopen`: rebuild-on-open health.
|
|
50
|
+
- `zvec_health.after_transitions`: lifecycle transition sync health.
|
|
51
|
+
- `zvec_health.after_compact` and `after_compact_reopen`: compaction and reopen health.
|
|
52
|
+
- `wide_parity_rate`: wide-window Zvec search matched canonical Substrate search.
|
|
53
|
+
- `narrow_seed_hit_rate`: narrow-window Zvec search recovered seeded nodes.
|
|
54
|
+
- `sqlite_bytes` and `zvec_bytes`: local storage footprint for the generated run.
|
|
55
|
+
|
|
56
|
+
Any missing, orphan, stale, parity, or seeded-recovery failure means the Zvec sidecar needs maintenance work before it should be used for larger Substrate candidate preselection.
|
|
57
|
+
|
|
58
|
+
## Local Validation Snapshot
|
|
59
|
+
|
|
60
|
+
On 2026-06-26, the check was run locally with a 10k-node SQLite truth store and Zvec sidecar:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npm run check:zvec-scale -- \
|
|
64
|
+
--nodes 10000 \
|
|
65
|
+
--scopes 10 \
|
|
66
|
+
--relations 2000 \
|
|
67
|
+
--feedback 1000 \
|
|
68
|
+
--probes 100 \
|
|
69
|
+
--narrow-candidate-limit 20
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Result:
|
|
73
|
+
|
|
74
|
+
- nodes: 10,000
|
|
75
|
+
- relations: 2,000
|
|
76
|
+
- feedback records: 1,000
|
|
77
|
+
- lifecycle transitions: 100
|
|
78
|
+
- probes: 100
|
|
79
|
+
- Zvec health after write/reopen/transitions/compact/compact-reopen: pass
|
|
80
|
+
- wide candidate parity: 100%
|
|
81
|
+
- narrow seeded recovery: 100%
|
|
82
|
+
- SQLite bytes: 17,657,856
|
|
83
|
+
- Zvec sidecar bytes: 19,528,279
|
|
84
|
+
- write nodes with Zvec: 2,335 ms
|
|
85
|
+
- close after write, including manifest flush: 171 ms
|
|
86
|
+
- reopen and rebuild: 1,855 ms
|
|
87
|
+
- post-compaction reopen and rebuild: 1,783 ms
|
|
88
|
+
|
|
89
|
+
This validates the sidecar maintenance path at package scale: write-through indexing, rebuild, lifecycle-transition synchronization, compaction, and candidate-window safety all remain consistent with the SQLite truth store.
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdtemp, rm } from "node:fs/promises";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { DatabaseSync } from "node:sqlite";
|
|
6
|
+
import {
|
|
7
|
+
openSqliteAionisSubstrate,
|
|
8
|
+
runRuntimeLiveSidecarOnce,
|
|
9
|
+
} from "../../dist/index.js";
|
|
10
|
+
|
|
11
|
+
const scope = "repo-a";
|
|
12
|
+
const workspace = await mkdtemp(join(tmpdir(), "aionis-substrate-live-sidecar-"));
|
|
13
|
+
|
|
14
|
+
function createRuntimeLiteSource(path) {
|
|
15
|
+
const db = new DatabaseSync(path);
|
|
16
|
+
try {
|
|
17
|
+
db.exec(`
|
|
18
|
+
CREATE TABLE lite_memory_nodes (
|
|
19
|
+
id TEXT PRIMARY KEY,
|
|
20
|
+
scope TEXT NOT NULL,
|
|
21
|
+
client_id TEXT,
|
|
22
|
+
type TEXT NOT NULL,
|
|
23
|
+
tier TEXT NOT NULL,
|
|
24
|
+
title TEXT,
|
|
25
|
+
text_summary TEXT,
|
|
26
|
+
slots_json TEXT NOT NULL,
|
|
27
|
+
raw_ref TEXT,
|
|
28
|
+
evidence_ref TEXT,
|
|
29
|
+
embedding_vector_json TEXT,
|
|
30
|
+
embedding_model TEXT,
|
|
31
|
+
memory_lane TEXT NOT NULL,
|
|
32
|
+
producer_agent_id TEXT,
|
|
33
|
+
owner_agent_id TEXT,
|
|
34
|
+
owner_team_id TEXT,
|
|
35
|
+
embedding_status TEXT NOT NULL,
|
|
36
|
+
embedding_last_error TEXT,
|
|
37
|
+
salience REAL NOT NULL,
|
|
38
|
+
importance REAL NOT NULL,
|
|
39
|
+
confidence REAL NOT NULL,
|
|
40
|
+
redaction_version INTEGER NOT NULL,
|
|
41
|
+
commit_id TEXT NOT NULL,
|
|
42
|
+
created_at TEXT NOT NULL
|
|
43
|
+
);
|
|
44
|
+
`);
|
|
45
|
+
} finally {
|
|
46
|
+
db.close();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function insertRuntimeNode(path, row) {
|
|
51
|
+
const db = new DatabaseSync(path);
|
|
52
|
+
try {
|
|
53
|
+
db.prepare(`
|
|
54
|
+
INSERT INTO lite_memory_nodes (
|
|
55
|
+
id, scope, client_id, type, tier, title, text_summary, slots_json, raw_ref, evidence_ref,
|
|
56
|
+
embedding_vector_json, embedding_model, memory_lane, producer_agent_id, owner_agent_id,
|
|
57
|
+
owner_team_id, embedding_status, embedding_last_error, salience, importance, confidence,
|
|
58
|
+
redaction_version, commit_id, created_at
|
|
59
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
60
|
+
`).run(
|
|
61
|
+
row.id,
|
|
62
|
+
scope,
|
|
63
|
+
`client-${row.id}`,
|
|
64
|
+
row.type,
|
|
65
|
+
row.tier,
|
|
66
|
+
row.title,
|
|
67
|
+
row.summary,
|
|
68
|
+
JSON.stringify(row.slots),
|
|
69
|
+
row.rawRef ?? null,
|
|
70
|
+
row.evidenceRef ?? null,
|
|
71
|
+
null,
|
|
72
|
+
"demo-embedding",
|
|
73
|
+
"execution",
|
|
74
|
+
"agent-a",
|
|
75
|
+
"agent-a",
|
|
76
|
+
"team-a",
|
|
77
|
+
"ready",
|
|
78
|
+
null,
|
|
79
|
+
0.8,
|
|
80
|
+
0.85,
|
|
81
|
+
row.confidence,
|
|
82
|
+
1,
|
|
83
|
+
"demo-commit",
|
|
84
|
+
row.createdAt,
|
|
85
|
+
);
|
|
86
|
+
} finally {
|
|
87
|
+
db.close();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
const runtimeSource = join(workspace, "runtime-lite.sqlite");
|
|
93
|
+
const substrateTarget = join(workspace, "substrate.sqlite");
|
|
94
|
+
const checkpoint = join(workspace, "runtime-live-checkpoint.json");
|
|
95
|
+
createRuntimeLiteSource(runtimeSource);
|
|
96
|
+
|
|
97
|
+
insertRuntimeNode(runtimeSource, {
|
|
98
|
+
id: "current-route",
|
|
99
|
+
type: "procedure",
|
|
100
|
+
tier: "hot",
|
|
101
|
+
title: "Current route",
|
|
102
|
+
summary: "Use src/runtime.ts after verifier passed.",
|
|
103
|
+
confidence: 0.95,
|
|
104
|
+
createdAt: "2026-06-26T00:00:00.000Z",
|
|
105
|
+
slots: {
|
|
106
|
+
summary_kind: "workflow_anchor",
|
|
107
|
+
contract_trust: "trusted",
|
|
108
|
+
target_files: ["src/runtime.ts", "tests/runtime.test.ts"],
|
|
109
|
+
execution_result_summary: { status: "passed" },
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
insertRuntimeNode(runtimeSource, {
|
|
114
|
+
id: "failed-branch",
|
|
115
|
+
type: "procedure",
|
|
116
|
+
tier: "hot",
|
|
117
|
+
title: "Failed branch",
|
|
118
|
+
summary: "The legacy src/legacy.ts path failed the verifier and should not steer the next turn.",
|
|
119
|
+
confidence: 0.9,
|
|
120
|
+
createdAt: "2026-06-26T00:01:00.000Z",
|
|
121
|
+
slots: {
|
|
122
|
+
summary_kind: "workflow_anchor",
|
|
123
|
+
contract_trust: "rejected",
|
|
124
|
+
target_files: ["src/legacy.ts"],
|
|
125
|
+
execution_result_summary: { status: "failed" },
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
insertRuntimeNode(runtimeSource, {
|
|
130
|
+
id: "raw-trace",
|
|
131
|
+
type: "trace_pointer",
|
|
132
|
+
tier: "cold",
|
|
133
|
+
title: "Raw terminal trace",
|
|
134
|
+
summary: "Full terminal trace is retained as payload evidence but should only be rehydrated on demand.",
|
|
135
|
+
rawRef: "file://trace.log",
|
|
136
|
+
confidence: 0.88,
|
|
137
|
+
createdAt: "2026-06-26T00:02:00.000Z",
|
|
138
|
+
slots: {
|
|
139
|
+
summary_kind: "raw_trace_pointer",
|
|
140
|
+
target_files: ["src/runtime.ts"],
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
const store = await openSqliteAionisSubstrate({ path: substrateTarget });
|
|
145
|
+
try {
|
|
146
|
+
const first = await runRuntimeLiveSidecarOnce({
|
|
147
|
+
sourcePath: runtimeSource,
|
|
148
|
+
target: store,
|
|
149
|
+
checkpointPath: checkpoint,
|
|
150
|
+
scope,
|
|
151
|
+
});
|
|
152
|
+
const second = await runRuntimeLiveSidecarOnce({
|
|
153
|
+
sourcePath: runtimeSource,
|
|
154
|
+
target: store,
|
|
155
|
+
checkpointPath: checkpoint,
|
|
156
|
+
scope,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
const context = await store.previewContext({
|
|
160
|
+
scope,
|
|
161
|
+
query: "continue the current runtime implementation route",
|
|
162
|
+
maxPerBucket: 8,
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
assert.equal(first.apply_summary.nodes.applied, 3);
|
|
166
|
+
assert.equal(second.apply_summary.nodes.applied, 0);
|
|
167
|
+
assert.deepEqual(context.use_now.map((node) => node.id), ["current-route"]);
|
|
168
|
+
assert.deepEqual(context.do_not_use.map((node) => node.id), ["failed-branch"]);
|
|
169
|
+
assert.deepEqual(context.rehydrate.map((node) => node.id), ["raw-trace"]);
|
|
170
|
+
|
|
171
|
+
console.log(JSON.stringify({
|
|
172
|
+
ok: true,
|
|
173
|
+
runtime_source: runtimeSource,
|
|
174
|
+
substrate_target: substrateTarget,
|
|
175
|
+
first_sidecar_run: first.apply_summary.nodes,
|
|
176
|
+
second_sidecar_run: second.apply_summary.nodes,
|
|
177
|
+
governed_context: {
|
|
178
|
+
use_now: context.use_now.map((node) => node.id),
|
|
179
|
+
inspect_before_use: context.inspect_before_use.map((node) => node.id),
|
|
180
|
+
do_not_use: context.do_not_use.map((node) => node.id),
|
|
181
|
+
rehydrate: context.rehydrate.map((node) => node.id),
|
|
182
|
+
},
|
|
183
|
+
}, null, 2));
|
|
184
|
+
} finally {
|
|
185
|
+
await store.close();
|
|
186
|
+
}
|
|
187
|
+
} finally {
|
|
188
|
+
await rm(workspace, { recursive: true, force: true });
|
|
189
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aionis/substrate",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Durable governed memory substrate for Aionis execution state.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -34,6 +34,10 @@
|
|
|
34
34
|
"check:runtime-corpus": "node scripts/runtime-snapshot-corpus.ts",
|
|
35
35
|
"check:runtime-reference-corpus": "node scripts/runtime-reference-corpus.ts",
|
|
36
36
|
"check:runtime-sidecar": "node scripts/runtime-sidecar-check.ts",
|
|
37
|
+
"check:runtime-live-sidecar-soak": "node scripts/runtime-live-sidecar-soak.ts",
|
|
38
|
+
"check:runtime-product-bridge": "node scripts/runtime-product-bridge-gate.ts",
|
|
39
|
+
"check:runtime-zvec-index": "node scripts/runtime-zvec-candidate-index-check.ts",
|
|
40
|
+
"check:zvec-provider-embedding": "node scripts/zvec-provider-embedding-eval.ts",
|
|
37
41
|
"make:runtime-product-reference": "node scripts/runtime-product-reference-fixture.ts",
|
|
38
42
|
"check:external-admission-parity": "node scripts/external-admission-parity.ts",
|
|
39
43
|
"check:runtime-dual-write": "node scripts/runtime-dual-write-experiment.ts",
|
|
@@ -42,8 +46,10 @@
|
|
|
42
46
|
"check:registry-install": "node scripts/registry-install-smoke.ts",
|
|
43
47
|
"check:published-runtime-smoke": "node scripts/published-runtime-smoke.ts",
|
|
44
48
|
"check:scale": "node scripts/scale-test.ts",
|
|
49
|
+
"check:zvec-scale": "node scripts/zvec-scale-test.ts",
|
|
45
50
|
"example:basic": "npm run build && node examples/basic/index.mjs",
|
|
46
|
-
"
|
|
51
|
+
"example:live-sidecar": "npm run build && node examples/live-sidecar/index.mjs",
|
|
52
|
+
"check:release": "npm run typecheck && npm test && npm run bench:contract && npm run example:basic && npm run check:runtime-live-sidecar-soak && npm run check:pack && npm run check:install-smoke"
|
|
47
53
|
},
|
|
48
54
|
"repository": {
|
|
49
55
|
"type": "git",
|
|
@@ -66,6 +72,15 @@
|
|
|
66
72
|
"license": "Apache-2.0",
|
|
67
73
|
"devDependencies": {
|
|
68
74
|
"@types/node": "^26.0.1",
|
|
75
|
+
"@zvec/zvec": "^0.5.0",
|
|
69
76
|
"typescript": "^6.0.3"
|
|
77
|
+
},
|
|
78
|
+
"peerDependencies": {
|
|
79
|
+
"@zvec/zvec": "^0.5.0"
|
|
80
|
+
},
|
|
81
|
+
"peerDependenciesMeta": {
|
|
82
|
+
"@zvec/zvec": {
|
|
83
|
+
"optional": true
|
|
84
|
+
}
|
|
70
85
|
}
|
|
71
86
|
}
|