@aionis/substrate 0.1.4 → 0.1.6

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +101 -10
  3. package/dist/candidate-index.d.ts +25 -0
  4. package/dist/candidate-index.d.ts.map +1 -0
  5. package/dist/candidate-index.js +217 -0
  6. package/dist/candidate-index.js.map +1 -0
  7. package/dist/embedding-projection.d.ts +16 -0
  8. package/dist/embedding-projection.d.ts.map +1 -0
  9. package/dist/embedding-projection.js +101 -0
  10. package/dist/embedding-projection.js.map +1 -0
  11. package/dist/file-substrate.d.ts +3 -0
  12. package/dist/file-substrate.d.ts.map +1 -1
  13. package/dist/file-substrate.js +47 -1
  14. package/dist/file-substrate.js.map +1 -1
  15. package/dist/index.d.ts +3 -0
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +3 -0
  18. package/dist/index.js.map +1 -1
  19. package/dist/search.d.ts +11 -2
  20. package/dist/search.d.ts.map +1 -1
  21. package/dist/search.js +78 -7
  22. package/dist/search.js.map +1 -1
  23. package/dist/sqlite-substrate.d.ts +3 -0
  24. package/dist/sqlite-substrate.d.ts.map +1 -1
  25. package/dist/sqlite-substrate.js +61 -6
  26. package/dist/sqlite-substrate.js.map +1 -1
  27. package/dist/types.d.ts +3 -0
  28. package/dist/types.d.ts.map +1 -1
  29. package/dist/zvec-candidate-index.d.ts +42 -0
  30. package/dist/zvec-candidate-index.d.ts.map +1 -0
  31. package/dist/zvec-candidate-index.js +463 -0
  32. package/dist/zvec-candidate-index.js.map +1 -0
  33. package/docs/ADAPTER_CONTRACT.md +12 -2
  34. package/docs/API_USAGE.md +135 -0
  35. package/docs/CLI.md +21 -1
  36. package/docs/PRODUCT_CONTRACT.md +136 -0
  37. package/docs/RUNTIME_DUAL_WRITE_EXPERIMENT.md +14 -0
  38. package/docs/RUNTIME_ZVEC_CANDIDATE_INDEX.md +80 -0
  39. package/docs/STORE_CONTRACT.md +15 -0
  40. package/docs/V0_2_ROADMAP.md +12 -1
  41. package/docs/ZVEC_PROVIDER_EMBEDDING_EVAL.md +216 -0
  42. package/docs/ZVEC_SCALE_MAINTENANCE.md +89 -0
  43. package/examples/live-sidecar/index.mjs +189 -0
  44. package/package.json +16 -1
@@ -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.4",
3
+ "version": "0.1.6",
4
4
  "description": "Durable governed memory substrate for Aionis execution state.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -35,6 +35,9 @@
35
35
  "check:runtime-reference-corpus": "node scripts/runtime-reference-corpus.ts",
36
36
  "check:runtime-sidecar": "node scripts/runtime-sidecar-check.ts",
37
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",
38
41
  "make:runtime-product-reference": "node scripts/runtime-product-reference-fixture.ts",
39
42
  "check:external-admission-parity": "node scripts/external-admission-parity.ts",
40
43
  "check:runtime-dual-write": "node scripts/runtime-dual-write-experiment.ts",
@@ -42,8 +45,11 @@
42
45
  "check:install-smoke": "npm run build && node scripts/install-smoke.ts",
43
46
  "check:registry-install": "node scripts/registry-install-smoke.ts",
44
47
  "check:published-runtime-smoke": "node scripts/published-runtime-smoke.ts",
48
+ "check:published-runtime-bridge": "node scripts/published-runtime-bridge.ts",
45
49
  "check:scale": "node scripts/scale-test.ts",
50
+ "check:zvec-scale": "node scripts/zvec-scale-test.ts",
46
51
  "example:basic": "npm run build && node examples/basic/index.mjs",
52
+ "example:live-sidecar": "npm run build && node examples/live-sidecar/index.mjs",
47
53
  "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"
48
54
  },
49
55
  "repository": {
@@ -67,6 +73,15 @@
67
73
  "license": "Apache-2.0",
68
74
  "devDependencies": {
69
75
  "@types/node": "^26.0.1",
76
+ "@zvec/zvec": "^0.5.0",
70
77
  "typescript": "^6.0.3"
78
+ },
79
+ "peerDependencies": {
80
+ "@zvec/zvec": "^0.5.0"
81
+ },
82
+ "peerDependenciesMeta": {
83
+ "@zvec/zvec": {
84
+ "optional": true
85
+ }
71
86
  }
72
87
  }