chainlesschain 0.166.156 → 0.166.157
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/README.md +31 -29
- package/package.json +1 -1
- package/src/assets/linux-subreaper/linux-arm64/manifest.json +1 -1
- package/src/assets/linux-subreaper/linux-x64/manifest.json +3 -3
- package/src/assets/linux-subreaper/linux-x64/supervisor +0 -0
- package/src/assets/web-panel/.build-hash +1 -1
- package/src/data/changelog.json +13 -0
- package/src/lib/evolution/evolution-deployment-loader.js +15 -18
- package/src/lib/evolution/evolution-ledger-storage-audit.js +222 -0
- package/src/lib/evolution/rrsi-observed-text-index.js +16 -0
- package/src/lib/lk-model-catalog.json +202 -619
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/** Explicit, read-only composition of the original local v2 storage checks. */
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { isProxy } from "node:util/types";
|
|
4
|
+
import {
|
|
5
|
+
captureEvolutionLedgerFileBackend,
|
|
6
|
+
captureEvolutionLedgerFileBackendBinding,
|
|
7
|
+
captureEvolutionLedgerFileBackendSourceDirectoryBoundary,
|
|
8
|
+
captureEvolutionLedgerFileBackendWitnessDirectoryBoundaries,
|
|
9
|
+
} from "./evolution-ledger-file-backend.js";
|
|
10
|
+
import {
|
|
11
|
+
captureEvolutionLedgerArtifactResolverBinding,
|
|
12
|
+
captureEvolutionArtifactStoreDirectoryBoundary,
|
|
13
|
+
captureEvolutionArtifactStoreLocalInventory,
|
|
14
|
+
} from "./evolution-artifact-ports.js";
|
|
15
|
+
import {
|
|
16
|
+
isEvolutionLedgerV2Journal,
|
|
17
|
+
captureEvolutionLedgerV2JournalManifestDirectoryBoundaries,
|
|
18
|
+
captureEvolutionLedgerV2JournalWitnessDirectoryBoundaries,
|
|
19
|
+
captureEvolutionLedgerV2JournalRetainedSegmentDirectoryBoundary,
|
|
20
|
+
captureEvolutionLedgerV2JournalLocalRetentionInventory,
|
|
21
|
+
captureEvolutionLedgerV2JournalSourceConsistency,
|
|
22
|
+
} from "./evolution-ledger-v2-journal.js";
|
|
23
|
+
|
|
24
|
+
export const EVOLUTION_LEDGER_STORAGE_AUDIT_SCHEMA =
|
|
25
|
+
"chainlesschain.evolution-local-storage-audit/v1";
|
|
26
|
+
export const EVOLUTION_LEDGER_STORAGE_AUDIT_HELD_CODE =
|
|
27
|
+
"CC_EVOLUTION_STORAGE_AUDIT_HELD";
|
|
28
|
+
|
|
29
|
+
function held(message, cause) {
|
|
30
|
+
throw Object.assign(new Error(message, cause ? { cause } : undefined), {
|
|
31
|
+
code: EVOLUTION_LEDGER_STORAGE_AUDIT_HELD_CODE,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function canonical(value) {
|
|
36
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
37
|
+
if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
|
|
38
|
+
return `{${Object.keys(value)
|
|
39
|
+
.sort()
|
|
40
|
+
.map((key) => `${JSON.stringify(key)}:${canonical(value[key])}`)
|
|
41
|
+
.join(",")}}`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function digest(value) {
|
|
45
|
+
return `sha256:${createHash("sha256")
|
|
46
|
+
.update(`${EVOLUTION_LEDGER_STORAGE_AUDIT_SCHEMA}\0`)
|
|
47
|
+
.update(canonical(value))
|
|
48
|
+
.digest("hex")}`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function frozen(value) {
|
|
52
|
+
if (value && typeof value === "object") {
|
|
53
|
+
Object.values(value).forEach(frozen);
|
|
54
|
+
Object.freeze(value);
|
|
55
|
+
}
|
|
56
|
+
return value;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function ports(input) {
|
|
60
|
+
const keys = ["backend", "artifactPorts", "ledgerArtifactResolver"];
|
|
61
|
+
if (
|
|
62
|
+
!input ||
|
|
63
|
+
isProxy(input) ||
|
|
64
|
+
Object.getPrototypeOf(input) !== Object.prototype ||
|
|
65
|
+
Reflect.ownKeys(input).length !== keys.length
|
|
66
|
+
)
|
|
67
|
+
throw new TypeError("storage audit requires exactly three original ports");
|
|
68
|
+
return Object.fromEntries(
|
|
69
|
+
keys.map((key) => {
|
|
70
|
+
const field = Object.getOwnPropertyDescriptor(input, key);
|
|
71
|
+
if (!field?.enumerable || !("value" in field))
|
|
72
|
+
throw new TypeError("storage audit ports must be own data properties");
|
|
73
|
+
return [key, field.value];
|
|
74
|
+
}),
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* No caller paths, inventory filters, recovery, installation or trust defaults.
|
|
80
|
+
* Separate component read windows do not constitute an atomic disk snapshot.
|
|
81
|
+
*/
|
|
82
|
+
export function captureEvolutionLedgerStorageAudit(input) {
|
|
83
|
+
if (arguments.length !== 1)
|
|
84
|
+
throw new TypeError("storage audit takes one original composition");
|
|
85
|
+
const options = ports(input);
|
|
86
|
+
const backend = captureEvolutionLedgerFileBackend(options.backend);
|
|
87
|
+
const binding = captureEvolutionLedgerFileBackendBinding(backend);
|
|
88
|
+
const resolver = captureEvolutionLedgerArtifactResolverBinding(
|
|
89
|
+
options.ledgerArtifactResolver,
|
|
90
|
+
);
|
|
91
|
+
const journal = backend.ledger;
|
|
92
|
+
if (
|
|
93
|
+
!binding.matchesArtifactResolver(options.ledgerArtifactResolver) ||
|
|
94
|
+
!resolver.matchesArtifactPorts(options.artifactPorts)
|
|
95
|
+
)
|
|
96
|
+
held("storage audit requires the same original backend and artifact ports");
|
|
97
|
+
if (!isEvolutionLedgerV2Journal(journal))
|
|
98
|
+
held("storage audit requires an original v2 journal");
|
|
99
|
+
if (
|
|
100
|
+
resolver.tenantId !== journal.descriptor.artifactTenantId ||
|
|
101
|
+
resolver.audience !== journal.descriptor.audience ||
|
|
102
|
+
resolver.purpose !== "evolution-ledger"
|
|
103
|
+
)
|
|
104
|
+
held("storage audit artifact scope differs from the original journal");
|
|
105
|
+
|
|
106
|
+
function capture() {
|
|
107
|
+
const sourceBoundary =
|
|
108
|
+
captureEvolutionLedgerFileBackendSourceDirectoryBoundary(backend);
|
|
109
|
+
const sourceWitnessBoundary =
|
|
110
|
+
captureEvolutionLedgerFileBackendWitnessDirectoryBoundaries(backend);
|
|
111
|
+
const manifestBoundaries =
|
|
112
|
+
captureEvolutionLedgerV2JournalManifestDirectoryBoundaries(journal);
|
|
113
|
+
const manifestWitnessBoundary =
|
|
114
|
+
captureEvolutionLedgerV2JournalWitnessDirectoryBoundaries(journal);
|
|
115
|
+
const retentionBoundary =
|
|
116
|
+
captureEvolutionLedgerV2JournalRetainedSegmentDirectoryBoundary(journal);
|
|
117
|
+
const artifactBoundary = captureEvolutionArtifactStoreDirectoryBoundary(
|
|
118
|
+
options.artifactPorts,
|
|
119
|
+
);
|
|
120
|
+
if (!manifestBoundaries || !manifestWitnessBoundary || !retentionBoundary)
|
|
121
|
+
held(
|
|
122
|
+
"storage audit requires original physical manifest and retention ports",
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
const boundaries = [
|
|
126
|
+
sourceBoundary,
|
|
127
|
+
sourceWitnessBoundary,
|
|
128
|
+
manifestBoundaries.catalog,
|
|
129
|
+
manifestBoundaries.head,
|
|
130
|
+
manifestWitnessBoundary,
|
|
131
|
+
retentionBoundary,
|
|
132
|
+
artifactBoundary,
|
|
133
|
+
];
|
|
134
|
+
const recheckDirectories = () => {
|
|
135
|
+
for (const boundary of boundaries) boundary.recheck();
|
|
136
|
+
};
|
|
137
|
+
recheckDirectories();
|
|
138
|
+
// These explicit readers never call journal.verify()/recover(), take a
|
|
139
|
+
// source lock, advance a witness or finalize an outstanding WAL suffix.
|
|
140
|
+
const source = captureEvolutionLedgerV2JournalSourceConsistency(journal);
|
|
141
|
+
if (source === null)
|
|
142
|
+
held("storage audit requires a finalized read-only source/v2 history");
|
|
143
|
+
const retention =
|
|
144
|
+
captureEvolutionLedgerV2JournalLocalRetentionInventory(journal);
|
|
145
|
+
const artifacts = captureEvolutionArtifactStoreLocalInventory(
|
|
146
|
+
options.artifactPorts,
|
|
147
|
+
);
|
|
148
|
+
if (retention === null || artifacts === null)
|
|
149
|
+
held("storage audit cannot substitute custom or incomplete inventories");
|
|
150
|
+
|
|
151
|
+
const head = source.snapshot.manifestHead;
|
|
152
|
+
if (
|
|
153
|
+
canonical(head) !== canonical(retention.snapshot.head) ||
|
|
154
|
+
artifacts.snapshot.tenantId !== journal.descriptor.artifactTenantId ||
|
|
155
|
+
artifacts.snapshot.audience !== journal.descriptor.audience
|
|
156
|
+
)
|
|
157
|
+
held("storage audit components do not share one journal head and scope");
|
|
158
|
+
|
|
159
|
+
// Re-read all three components rather than trusting their reported hashes.
|
|
160
|
+
// Retention includes unreferenced files; artifacts includes the full index.
|
|
161
|
+
source.recheck();
|
|
162
|
+
retention.recheck();
|
|
163
|
+
artifacts.recheck();
|
|
164
|
+
recheckDirectories();
|
|
165
|
+
const core = frozen({
|
|
166
|
+
schema: EVOLUTION_LEDGER_STORAGE_AUDIT_SCHEMA,
|
|
167
|
+
scope: "original-v2-source-witnesses-local-retention-and-artifact-store",
|
|
168
|
+
tenantId: journal.descriptor.tenantId,
|
|
169
|
+
artifactTenantId: journal.descriptor.artifactTenantId,
|
|
170
|
+
audience: journal.descriptor.audience,
|
|
171
|
+
head,
|
|
172
|
+
directories: {
|
|
173
|
+
source: sourceBoundary.descriptor,
|
|
174
|
+
sourceWitness: sourceWitnessBoundary.descriptor,
|
|
175
|
+
manifestCatalog: manifestBoundaries.catalog.descriptor,
|
|
176
|
+
manifestHead: manifestBoundaries.head.descriptor,
|
|
177
|
+
manifestWitness: manifestWitnessBoundary.descriptor,
|
|
178
|
+
retention: retentionBoundary.descriptor,
|
|
179
|
+
artifacts: artifactBoundary.descriptor,
|
|
180
|
+
},
|
|
181
|
+
source: source.snapshot,
|
|
182
|
+
retention: retention.snapshot,
|
|
183
|
+
artifacts: artifacts.snapshot,
|
|
184
|
+
readOnlyOpen: true,
|
|
185
|
+
recoveryPerformed: false,
|
|
186
|
+
originalCompositionVerified: true,
|
|
187
|
+
sourceEventsExactlyMirrored: true,
|
|
188
|
+
localRetentionInventoryVerified: true,
|
|
189
|
+
localArtifactInventoryVerified: true,
|
|
190
|
+
independentInstallationVerified: false,
|
|
191
|
+
crossProcessRollbackProtectionVerified: false,
|
|
192
|
+
atomicSnapshotVerified: false,
|
|
193
|
+
fullPhysicalStorageGraphVerified: false,
|
|
194
|
+
externalWormVerified: false,
|
|
195
|
+
productionAuthorityVerified: false,
|
|
196
|
+
generationProvenanceVerified: false,
|
|
197
|
+
grantsMutationOrPromotionAuthority: false,
|
|
198
|
+
decision: "HOLD",
|
|
199
|
+
});
|
|
200
|
+
return frozen({ ...core, storageAuditDigest: digest(core) });
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function guardedCapture() {
|
|
204
|
+
try {
|
|
205
|
+
return capture();
|
|
206
|
+
} catch (cause) {
|
|
207
|
+
if (cause?.code === EVOLUTION_LEDGER_STORAGE_AUDIT_HELD_CODE) throw cause;
|
|
208
|
+
held("original local storage audit could not be authenticated", cause);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
const snapshot = guardedCapture();
|
|
212
|
+
return Object.freeze({
|
|
213
|
+
snapshot,
|
|
214
|
+
recheck(...args) {
|
|
215
|
+
if (args.length)
|
|
216
|
+
throw new TypeError("storage audit takes no replacement context");
|
|
217
|
+
if (guardedCapture().storageAuditDigest !== snapshot.storageAuditDigest)
|
|
218
|
+
held("original local storage changed after audit capture");
|
|
219
|
+
return true;
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** Retained observations and prohibitions, never proof of causal generation. */
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import { isProxy } from "node:util/types";
|
|
4
|
+
import { captureEvolutionLedgerStorageAudit } from "./evolution-ledger-storage-audit.js";
|
|
4
5
|
import {
|
|
5
6
|
captureEvolutionLedgerV2JournalManifestDirectoryBoundaries,
|
|
6
7
|
captureEvolutionLedgerV2JournalWitnessDirectoryBoundaries,
|
|
@@ -1201,6 +1202,14 @@ export function createRrsiObservedTextIndex(input) {
|
|
|
1201
1202
|
},
|
|
1202
1203
|
});
|
|
1203
1204
|
}),
|
|
1205
|
+
captureStorageAudit: () =>
|
|
1206
|
+
guarded(() =>
|
|
1207
|
+
captureEvolutionLedgerStorageAudit({
|
|
1208
|
+
backend,
|
|
1209
|
+
artifactPorts: options.artifactPorts,
|
|
1210
|
+
ledgerArtifactResolver: options.ledgerArtifactResolver,
|
|
1211
|
+
}),
|
|
1212
|
+
),
|
|
1204
1213
|
}),
|
|
1205
1214
|
);
|
|
1206
1215
|
return index;
|
|
@@ -1218,3 +1227,10 @@ export function captureRrsiObservedTextArtifactInventory(value) {
|
|
|
1218
1227
|
throw new TypeError("one original observed text index is required");
|
|
1219
1228
|
return INDEXES.get(value).captureArtifactInventory();
|
|
1220
1229
|
}
|
|
1230
|
+
|
|
1231
|
+
/** Explicit full local component audit; ordinary text reads stay unchanged. */
|
|
1232
|
+
export function captureRrsiObservedTextStorageAudit(value) {
|
|
1233
|
+
if (arguments.length !== 1 || !INDEXES.has(value))
|
|
1234
|
+
throw new TypeError("one original observed text index is required");
|
|
1235
|
+
return INDEXES.get(value).captureStorageAudit();
|
|
1236
|
+
}
|