chainlesschain 0.166.150 → 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 +45 -29
- package/package.json +2 -2
- 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/assets/web-panel/assets/{AIOps-bYMRw36k.js → AIOps-CraNGNgc.js} +1 -1
- package/src/assets/web-panel/assets/{ActionButton-xprOFj7C.js → ActionButton-C0jn6sgg.js} +1 -1
- package/src/assets/web-panel/assets/{Analytics-BRZ6F3vk.js → Analytics-DVrR_wjl.js} +1 -1
- package/src/assets/web-panel/assets/{AppLayout-C_volo3Y.js → AppLayout-CeKP8mgC.js} +1 -1
- package/src/assets/web-panel/assets/{Artifacts-Db0iD_H2.js → Artifacts-OHCS9wLN.js} +1 -1
- package/src/assets/web-panel/assets/{Audit-Bzp7NOA9.js → Audit-C77b6pDl.js} +1 -1
- package/src/assets/web-panel/assets/{BackgroundAgents-CPa5KqjU.js → BackgroundAgents-CefiwCgM.js} +1 -1
- package/src/assets/web-panel/assets/{Backup-BraBbkcd.js → Backup-B-5KmWNA.js} +1 -1
- package/src/assets/web-panel/assets/{BaseInput-D8LlXxCM.js → BaseInput-C3bJ1Qlc.js} +1 -1
- package/src/assets/web-panel/assets/{Chat-FWtdQ7HW.js → Chat-DBahPz9B.js} +1 -1
- package/src/assets/web-panel/assets/{ChatBubbleRenderer-DtxhjGV3.js → ChatBubbleRenderer-J4BVVrXZ.js} +1 -1
- package/src/assets/web-panel/assets/{Checkbox-BoCeVuib.js → Checkbox-w856fzfY.js} +1 -1
- package/src/assets/web-panel/assets/{Codegen-C58CW3JB.js → Codegen-XKmsL_C3.js} +1 -1
- package/src/assets/web-panel/assets/{Col-BlkVpYfD.js → Col-B37-gr7d.js} +1 -1
- package/src/assets/web-panel/assets/{Community-BmQ95FuI.js → Community-DdahlN0f.js} +1 -1
- package/src/assets/web-panel/assets/{Compact-BzWphLgo.js → Compact-oKnoE-9_.js} +1 -1
- package/src/assets/web-panel/assets/{Compliance-CG1Plf7v.js → Compliance-CnCRlOB_.js} +1 -1
- package/src/assets/web-panel/assets/{Cowork-CS8_XrAS.js → Cowork-D3Vr5R3E.js} +1 -1
- package/src/assets/web-panel/assets/{Cron-C1m-mGo0.js → Cron-X46CdLRQ.js} +1 -1
- package/src/assets/web-panel/assets/{Crosschain-TU1UPo_V.js → Crosschain-CV3_6jVw.js} +1 -1
- package/src/assets/web-panel/assets/{DID-bhbIsq__.js → DID-Kr6H4WKr.js} +1 -1
- package/src/assets/web-panel/assets/{Dashboard-B0wCsqTw.js → Dashboard-Bj4usrhx.js} +1 -1
- package/src/assets/web-panel/assets/{Dropdown-CVokY3lt.js → Dropdown-V3DPV21D.js} +1 -1
- package/src/assets/web-panel/assets/{EmailListRenderer-CfatTKx0.js → EmailListRenderer-8MCX0Y4b.js} +1 -1
- package/src/assets/web-panel/assets/{EvolutionSettings-DnT_Uiag.js → EvolutionSettings-SUoykpjc.js} +1 -1
- package/src/assets/web-panel/assets/{FamilyGuardDashboard-Dyahx8jQ.js → FamilyGuardDashboard-C0iE0T9x.js} +1 -1
- package/src/assets/web-panel/assets/{Federation-DuJ39hyj.js → Federation-CSU3kpK2.js} +1 -1
- package/src/assets/web-panel/assets/{FormItemContext-V4Ic5oQ_.js → FormItemContext-Bcv2XJNw.js} +1 -1
- package/src/assets/web-panel/assets/{GenericCardRenderer-UlZdAl_W.js → GenericCardRenderer-PdEqwQZd.js} +1 -1
- package/src/assets/web-panel/assets/{Git-B_363OIs.js → Git-CVZ0MSRN.js} +1 -1
- package/src/assets/web-panel/assets/{Governance-C61_SW_q.js → Governance-CF64-eGc.js} +1 -1
- package/src/assets/web-panel/assets/{Inference-CU80t_tb.js → Inference-DJ1J40Th.js} +1 -1
- package/src/assets/web-panel/assets/{KnowledgeGraph-BEtPQz8C.js → KnowledgeGraph-Cf3ULXmf.js} +1 -1
- package/src/assets/web-panel/assets/{Logs-CXqWvdFk.js → Logs-DM_RbXG_.js} +1 -1
- package/src/assets/web-panel/assets/{MarkdownRenderer-BFgkiBfA.js → MarkdownRenderer-B2wey_j8.js} +1 -1
- package/src/assets/web-panel/assets/{Marketplace-oKgzevz2.js → Marketplace-tqdANxLa.js} +1 -1
- package/src/assets/web-panel/assets/{McpTools-DHcNKyfb.js → McpTools-BiSYAtKB.js} +1 -1
- package/src/assets/web-panel/assets/{Memory-DEVpDL-x.js → Memory-hOvA-Tqp.js} +1 -1
- package/src/assets/web-panel/assets/{MobileBridge-D92T6ztp.js → MobileBridge-CIpwBK6G.js} +1 -1
- package/src/assets/web-panel/assets/{MobileProjects-B2Y7xpPw.js → MobileProjects-DMpV98oD.js} +1 -1
- package/src/assets/web-panel/assets/{Mtc-VOiGefD2.js → Mtc-CVoJZMuY.js} +1 -1
- package/src/assets/web-panel/assets/{MtcAudit-CAnmf1Im.js → MtcAudit-Dz9YsrvV.js} +1 -1
- package/src/assets/web-panel/assets/{Multisig-BCPOmJxC.js → Multisig-CamW3sTK.js} +1 -1
- package/src/assets/web-panel/assets/{NLProgramming-DYFqTLhe.js → NLProgramming-DlZo8q6W.js} +1 -1
- package/src/assets/web-panel/assets/{Notes--N-8WbHM.js → Notes-DZJSYibx.js} +1 -1
- package/src/assets/web-panel/assets/{NotificationSettings-Dka_XX0P.js → NotificationSettings-BSlIIGOM.js} +1 -1
- package/src/assets/web-panel/assets/{OrderTableRenderer-CIVkknQY.js → OrderTableRenderer-Bo9vImgU.js} +1 -1
- package/src/assets/web-panel/assets/{Organization-MToqvn2N.js → Organization-B1sBf0Kk.js} +1 -1
- package/src/assets/web-panel/assets/{Overflow-DgYLr6Hh.js → Overflow-CD8GUNOV.js} +1 -1
- package/src/assets/web-panel/assets/{P2P-DiRHC93-.js → P2P-CeaIuSa9.js} +1 -1
- package/src/assets/web-panel/assets/{PdhVaultBrowser-Cw8MYDt-.js → PdhVaultBrowser-DCOkcRse.js} +2 -2
- package/src/assets/web-panel/assets/{Permissions-JhxdHQqC.js → Permissions-DQCZnN_y.js} +1 -1
- package/src/assets/web-panel/assets/{PersonalDataHub-CcEeur_W.js → PersonalDataHub-D_9PtVvT.js} +1 -1
- package/src/assets/web-panel/assets/{Pipeline-Dau0R1tw.js → Pipeline-BawUxj0i.js} +1 -1
- package/src/assets/web-panel/assets/{Privacy-UF1HoZ-q.js → Privacy-CPyw19Ai.js} +1 -1
- package/src/assets/web-panel/assets/{ProjectInit-DyPmrkmp.js → ProjectInit-GDtYLbL6.js} +1 -1
- package/src/assets/web-panel/assets/{ProjectSettings-DZ4DQBbI.js → ProjectSettings-DhmGKXVL.js} +1 -1
- package/src/assets/web-panel/assets/{Projects-BRhaPrL4.js → Projects-O2spSrud.js} +1 -1
- package/src/assets/web-panel/assets/Providers-CNKCrJbY.css +1 -0
- package/src/assets/web-panel/assets/Providers-lEDu4Qdj.js +1 -0
- package/src/assets/web-panel/assets/{QrScannerModal-Dgvs6EGu.js → QrScannerModal-Dcqm-i6j.js} +1 -1
- package/src/assets/web-panel/assets/{QuickAsk-DqKybfXf.js → QuickAsk-C6uPAeAE.js} +1 -1
- package/src/assets/web-panel/assets/{Recommend-BGQDw5cu.js → Recommend-ClVlhga7.js} +1 -1
- package/src/assets/web-panel/assets/{RemoteSession-KE-6VZN0.js → RemoteSession-2raJDKUb.js} +1 -1
- package/src/assets/web-panel/assets/{Reputation-Ifxvbk7U.js → Reputation-BYWC8k3t.js} +1 -1
- package/src/assets/web-panel/assets/{Row-DoD3nauz.js → Row-Bv7Y68ai.js} +1 -1
- package/src/assets/web-panel/assets/{RssFeed-BlMKhrqt.js → RssFeed-Ba54MKvz.js} +1 -1
- package/src/assets/web-panel/assets/{Search-D4MaHzRS.js → Search-B9EkRkZK.js} +1 -1
- package/src/assets/web-panel/assets/{Security-DMpqDgSc.js → Security-DuXQGU4o.js} +1 -1
- package/src/assets/web-panel/assets/{Services-C9yzBSd8.js → Services-DJnCtY8x.js} +1 -1
- package/src/assets/web-panel/assets/{Skeleton-h8kJILZh.js → Skeleton-BVDdtf_S.js} +1 -1
- package/src/assets/web-panel/assets/{Skills-jXdYN4vu.js → Skills-DGkYCesm.js} +1 -1
- package/src/assets/web-panel/assets/{Sla-Cuk7apSe.js → Sla-CHND6lwC.js} +1 -1
- package/src/assets/web-panel/assets/{SpeechSettings-B5hPI4N_.js → SpeechSettings-Bg0Bgy9c.js} +1 -1
- package/src/assets/web-panel/assets/{SyncSettings-MGyaOfUD.js → SyncSettings-DwtcZ2Ml.js} +1 -1
- package/src/assets/web-panel/assets/{Tasks-BSqf89Jx.js → Tasks-BoHc0cP2.js} +1 -1
- package/src/assets/web-panel/assets/{Templates-BYjHba7u.js → Templates-DAMs4m8X.js} +1 -1
- package/src/assets/web-panel/assets/{Tenant-CEkhV7yX.js → Tenant-DkVQbOzT.js} +1 -1
- package/src/assets/web-panel/assets/{Terminal-D2deCxuf.js → Terminal-BTOLM8Yu.js} +1 -1
- package/src/assets/web-panel/assets/{TimelineRenderer-C8YVFoC3.js → TimelineRenderer-BO5ZyxUU.js} +1 -1
- package/src/assets/web-panel/assets/{Tokens-DN-S9EsT.js → Tokens-D0LjCtSA.js} +1 -1
- package/src/assets/web-panel/assets/{Trigger-F6LwAuyn.js → Trigger-DgGXg9VB.js} +1 -1
- package/src/assets/web-panel/assets/{Trust-Cx8jhn1i.js → Trust-BAEQrND-.js} +1 -1
- package/src/assets/web-panel/assets/{UkeySign-BN--f0JV.js → UkeySign-TtBclFRw.js} +1 -1
- package/src/assets/web-panel/assets/{VideoEditing-i32OtN88.js → VideoEditing-ByxvpIpS.js} +1 -1
- package/src/assets/web-panel/assets/{Wallet-DQImHu1X.js → Wallet-CTa7jqur.js} +1 -1
- package/src/assets/web-panel/assets/{WebAuthn-5waEqMup.js → WebAuthn-oHbCSjrD.js} +1 -1
- package/src/assets/web-panel/assets/{WorkflowEditor-Bh0xyyOO.js → WorkflowEditor-DQKQAdUS.js} +1 -1
- package/src/assets/web-panel/assets/{chat-EXJ3Usf5.js → chat-BcCU2FuK.js} +1 -1
- package/src/assets/web-panel/assets/{colors-Cdoap8Z7.js → colors-BcXAFjHT.js} +1 -1
- package/src/assets/web-panel/assets/{compact-item-QPjKEhW_.js → compact-item-GhZzQppm.js} +1 -1
- package/src/assets/web-panel/assets/{createContext-BOGUY650.js → createContext-Bc6nwTUy.js} +1 -1
- package/src/assets/web-panel/assets/{hasIn-DRN_I25i.js → hasIn-DRH8Xt0Y.js} +1 -1
- package/src/assets/web-panel/assets/{index-BoDNVZfc.js → index-60aCmptm.js} +1 -1
- package/src/assets/web-panel/assets/{index-B_J_PUwW.js → index-B7hScRVB.js} +1 -1
- package/src/assets/web-panel/assets/{index-BeRxNc4x.js → index-BDIN9KWp.js} +1 -1
- package/src/assets/web-panel/assets/{index-DAuglUM-.js → index-BEQha9Ur.js} +1 -1
- package/src/assets/web-panel/assets/{index-BFh62a_Z.js → index-BFFyqn3k.js} +1 -1
- package/src/assets/web-panel/assets/{index-jo9saD-R.js → index-BOquBdmK.js} +1 -1
- package/src/assets/web-panel/assets/{index-9hwjpOFE.js → index-BQ6b5kJR.js} +1 -1
- package/src/assets/web-panel/assets/{index-BvX72fLD.js → index-BaUmYzDB.js} +1 -1
- package/src/assets/web-panel/assets/{index-Dusibyek.js → index-Bb5XCEKT.js} +1 -1
- package/src/assets/web-panel/assets/{index-D_pIGWDh.js → index-BdOccG1D.js} +1 -1
- package/src/assets/web-panel/assets/{index-shByGhT7.js → index-Bebe5WYu.js} +1 -1
- package/src/assets/web-panel/assets/index-BlS3EjXM.js +1 -0
- package/src/assets/web-panel/assets/{index-DULwfIin.js → index-BsRmNZCk.js} +1 -1
- package/src/assets/web-panel/assets/{index-15P436aq.js → index-CB1Thk9t.js} +1 -1
- package/src/assets/web-panel/assets/{index-B_pCKR-k.js → index-CSHz8UnK.js} +1 -1
- package/src/assets/web-panel/assets/{index-_fW5KelD.js → index-Cexk6Y1r.js} +1 -1
- package/src/assets/web-panel/assets/{index-BRo2j8Jz.js → index-CtC-B6Zy.js} +1 -1
- package/src/assets/web-panel/assets/{index-DID83zEQ.js → index-D08s-CJ_.js} +1 -1
- package/src/assets/web-panel/assets/{index-DzUL46rU.js → index-D6B_ELy6.js} +1 -1
- package/src/assets/web-panel/assets/{index-CXP_MepL.js → index-D6pWvvp-.js} +1 -1
- package/src/assets/web-panel/assets/{index-BmVIyCgf.js → index-D9QfJDQg.js} +1 -1
- package/src/assets/web-panel/assets/{index-DISFHFjT.js → index-DCCEt-pU.js} +1 -1
- package/src/assets/web-panel/assets/{index-iYCp3otx.js → index-DCgr2bDL.js} +1 -1
- package/src/assets/web-panel/assets/{index-DBb3W3bA.js → index-DNi_t23H.js} +1 -1
- package/src/assets/web-panel/assets/{index-DfXsHnc0.js → index-DOBzu5UO.js} +1 -1
- package/src/assets/web-panel/assets/{index-BFXhCqpm.js → index-DOtNt1m7.js} +1 -1
- package/src/assets/web-panel/assets/{index-FBoQQHLy.js → index-DQnXn3vs.js} +1 -1
- package/src/assets/web-panel/assets/{index-Lwktngzr.js → index-DXip1xUj.js} +1 -1
- package/src/assets/web-panel/assets/{index-C33cfAQE.js → index-DoRIPzwv.js} +1 -1
- package/src/assets/web-panel/assets/index-DwIMwROa.js +1 -0
- package/src/assets/web-panel/assets/{index-hmILMYKF.js → index-Dzh9Ud2R.js} +3 -3
- package/src/assets/web-panel/assets/{index-kc4lgpMy.js → index-DzhMohzV.js} +1 -1
- package/src/assets/web-panel/assets/{index-6KPTDWDG.js → index-IW9dUJK_.js} +1 -1
- package/src/assets/web-panel/assets/{index-6nTP4-QK.js → index-WrMfehhj.js} +1 -1
- package/src/assets/web-panel/assets/{index-DNpnprSx.js → index-gvsatTPZ.js} +1 -1
- package/src/assets/web-panel/assets/{index-CafxYv7t.js → index-lEDZUWRO.js} +1 -1
- package/src/assets/web-panel/assets/{index-CVJG_i6e.js → index-mqlLcSgP.js} +1 -1
- package/src/assets/web-panel/assets/{index-L3zdSmTh.js → index-owU4npmQ.js} +1 -1
- package/src/assets/web-panel/assets/{index-CKfdYM3I.js → index-wnmY4P7_.js} +1 -1
- package/src/assets/web-panel/assets/{initDefaultProps-Bno49hyl.js → initDefaultProps-DfHPrIA5.js} +1 -1
- package/src/assets/web-panel/assets/{motion-Cs9KpFRZ.js → motion-CCzrK3c5.js} +1 -1
- package/src/assets/web-panel/assets/{move-DN2kt6Fk.js → move-B2uu6I9f.js} +1 -1
- package/src/assets/web-panel/assets/{mtc-parser-IXnfFKcF.js → mtc-parser-DtFu2-C_.js} +1 -1
- package/src/assets/web-panel/assets/{omit-ULuXK3m0.js → omit-BFjLuAHb.js} +1 -1
- package/src/assets/web-panel/assets/{pickAttrs-B3f1sg_2.js → pickAttrs-DfsjYq45.js} +1 -1
- package/src/assets/web-panel/assets/{placementArrow-CB3ISXbH.js → placementArrow-CDdYIVXw.js} +1 -1
- package/src/assets/web-panel/assets/{responsiveObserve-BhRD48Wz.js → responsiveObserve-CfrplFjn.js} +1 -1
- package/src/assets/web-panel/assets/{slide-B4qkLP8K.js → slide-DHNX5Xwt.js} +1 -1
- package/src/assets/web-panel/assets/{statusUtils-KfItOu2F.js → statusUtils-BI-C3SSk.js} +1 -1
- package/src/assets/web-panel/assets/{styleChecker-BeLQUf-Z.js → styleChecker-C5Y3Oyy2.js} +1 -1
- package/src/assets/web-panel/assets/{useFlexGapSupport-CPIJfd28.js → useFlexGapSupport-atF45w0U.js} +1 -1
- package/src/assets/web-panel/assets/{useFs-CUBjOVdy.js → useFs-C4M8-xm9.js} +1 -1
- package/src/assets/web-panel/assets/{usePersonalDataHub-DEKScTxs.js → usePersonalDataHub-jjZdnfs_.js} +1 -1
- package/src/assets/web-panel/assets/{vnode-DhNnfLeH.js → vnode-BRTSCmU3.js} +1 -1
- package/src/assets/web-panel/assets/{zoom-D5rdpCyb.js → zoom-BaS5ZYRC.js} +1 -1
- package/src/assets/web-panel/index.html +1 -1
- package/src/data/changelog.json +91 -0
- package/src/lib/evolution/evolution-artifact-ports.js +304 -0
- package/src/lib/evolution/evolution-deployment-loader.js +15 -18
- package/src/lib/evolution/evolution-file-retained-segment-backend.js +291 -0
- package/src/lib/evolution/evolution-file-witness.js +46 -4
- package/src/lib/evolution/evolution-immutable-ledger-segment-store.js +112 -0
- package/src/lib/evolution/evolution-ledger-manifest-chain.js +65 -1
- package/src/lib/evolution/evolution-ledger-manifest-witness-adapter.js +19 -2
- package/src/lib/evolution/evolution-ledger-storage-audit.js +222 -0
- package/src/lib/evolution/evolution-ledger-v2-journal.js +115 -0
- package/src/lib/evolution/evolution-ledger-v2-manifest-backend.js +242 -1
- package/src/lib/evolution/evolution-ledger.js +215 -27
- package/src/lib/evolution/evolution-witness-contracts.js +5 -0
- package/src/lib/evolution/evolution-witness-segments.js +2 -0
- package/src/lib/evolution/rrsi-observed-text-index.js +187 -9
- package/src/lib/evolution/rrsi-tenant-index-anchor-history.js +20 -0
- package/src/lib/lk-account-api.cjs +14 -2
- package/src/lib/lk-model-catalog.json +324 -289
- package/src/lib/llm-channel-presets.js +27 -8
- package/src/lib/llm-connection-config.js +6 -1
- package/src/lib/llm-connection-resolution.js +3 -1
- package/src/lib/llm-onboarding-catalog.json +16 -16
- package/src/lib/read-file-loop-guard.js +36 -12
- package/src/assets/web-panel/assets/Providers-DVyNl0mO.css +0 -1
- package/src/assets/web-panel/assets/Providers-TFpSkyej.js +0 -1
- package/src/assets/web-panel/assets/index-BFYVw5aJ.js +0 -1
- package/src/assets/web-panel/assets/index-wtySft9h.js +0 -1
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { types as utilTypes } from "node:util";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
captureImmutableLedgerSegmentStorePort,
|
|
6
|
+
captureImmutableLedgerSegmentStoreDirectoryBoundary,
|
|
7
|
+
captureImmutableLedgerSegmentStoreFileInventory,
|
|
8
|
+
} from "./evolution-immutable-ledger-segment-store.js";
|
|
5
9
|
import {
|
|
6
10
|
captureEvolutionLedgerManifestAuthority,
|
|
7
11
|
deriveEvolutionLedgerManifestHead,
|
|
8
12
|
sealEvolutionLedgerManifestSegment,
|
|
9
13
|
verifyEvolutionLedgerManifestChain,
|
|
10
14
|
readEvolutionLedgerManifestEvents,
|
|
15
|
+
inspectEvolutionLedgerReferencedSegmentInventory,
|
|
11
16
|
} from "./evolution-ledger-manifest-chain.js";
|
|
12
17
|
import {
|
|
13
18
|
captureEvolutionLedgerManifestHeadStore,
|
|
@@ -23,6 +28,7 @@ import {
|
|
|
23
28
|
captureEvolutionLedgerManifestWitnessAdapter,
|
|
24
29
|
captureEvolutionLedgerManifestWitnessDirectoryBoundaries,
|
|
25
30
|
hasEvolutionLedgerManifestWitnessDirectoryBoundaries,
|
|
31
|
+
getEvolutionLedgerManifestWitnessReadOnlyReader,
|
|
26
32
|
} from "./evolution-ledger-manifest-witness-adapter.js";
|
|
27
33
|
|
|
28
34
|
export const EVOLUTION_LEDGER_V2_MANIFEST_BACKEND_SCHEMA =
|
|
@@ -65,6 +71,7 @@ const APPEND_KEYS = new Set([
|
|
|
65
71
|
const VERIFY_KEYS = new Set();
|
|
66
72
|
const BACKENDS = new WeakSet();
|
|
67
73
|
const ORIGINAL_MANIFEST_COMPONENTS = new WeakMap();
|
|
74
|
+
const READ_ONLY_EVENT_READERS = new WeakMap();
|
|
68
75
|
|
|
69
76
|
export class EvolutionLedgerV2ManifestBackendError extends Error {
|
|
70
77
|
constructor(code, message, options = undefined) {
|
|
@@ -619,11 +626,122 @@ export function createEvolutionLedgerV2ManifestBackend(options = undefined) {
|
|
|
619
626
|
catalog,
|
|
620
627
|
headStore,
|
|
621
628
|
witnessAdapter,
|
|
629
|
+
segmentStore,
|
|
622
630
|
boundaries: null,
|
|
631
|
+
captureReferencedInventory() {
|
|
632
|
+
// Inspection must not repair a partial checkpoint or publish any state.
|
|
633
|
+
const read = () => {
|
|
634
|
+
const boundaries = hasEvolutionLedgerV2ManifestDirectoryBoundaries(
|
|
635
|
+
backend,
|
|
636
|
+
)
|
|
637
|
+
? captureEvolutionLedgerV2ManifestDirectoryBoundaries(backend)
|
|
638
|
+
: null;
|
|
639
|
+
const witness =
|
|
640
|
+
captureEvolutionLedgerV2ManifestWitnessDirectoryBoundaries(backend);
|
|
641
|
+
const retained =
|
|
642
|
+
captureEvolutionLedgerV2RetainedSegmentDirectoryBoundary(backend);
|
|
643
|
+
const recheckDirectories = () => {
|
|
644
|
+
boundaries?.catalog.recheck();
|
|
645
|
+
boundaries?.head.recheck();
|
|
646
|
+
witness?.recheck();
|
|
647
|
+
retained?.recheck();
|
|
648
|
+
};
|
|
649
|
+
const before = coherentSnapshot(catalog, headStore, witnessAdapter);
|
|
650
|
+
if (before.head === null)
|
|
651
|
+
throw failure(
|
|
652
|
+
EVOLUTION_LEDGER_V2_MANIFEST_INVALID_CODE,
|
|
653
|
+
"an empty manifest chain has no referenced inventory",
|
|
654
|
+
);
|
|
655
|
+
const snapshot = inspectEvolutionLedgerReferencedSegmentInventory({
|
|
656
|
+
authority: manifestAuthority,
|
|
657
|
+
descriptor: normalizedDescriptor,
|
|
658
|
+
head: before.head,
|
|
659
|
+
manifests: catalog.list(),
|
|
660
|
+
segmentStore,
|
|
661
|
+
});
|
|
662
|
+
const after = coherentSnapshot(catalog, headStore, witnessAdapter);
|
|
663
|
+
if (canonical(before) !== canonical(after))
|
|
664
|
+
throw failure(
|
|
665
|
+
EVOLUTION_LEDGER_V2_MANIFEST_CORRUPT_CODE,
|
|
666
|
+
"manifest checkpoint changed during referenced inventory readback",
|
|
667
|
+
);
|
|
668
|
+
recheckDirectories();
|
|
669
|
+
return snapshot;
|
|
670
|
+
};
|
|
671
|
+
const snapshot = read();
|
|
672
|
+
return Object.freeze({
|
|
673
|
+
snapshot,
|
|
674
|
+
recheck(...args) {
|
|
675
|
+
if (args.length)
|
|
676
|
+
throw new TypeError(
|
|
677
|
+
"referenced inventory takes no replacement context",
|
|
678
|
+
);
|
|
679
|
+
if (read().inventoryDigest !== snapshot.inventoryDigest)
|
|
680
|
+
throw failure(
|
|
681
|
+
EVOLUTION_LEDGER_V2_MANIFEST_CORRUPT_CODE,
|
|
682
|
+
"referenced segment inventory changed after capture",
|
|
683
|
+
);
|
|
684
|
+
return true;
|
|
685
|
+
},
|
|
686
|
+
});
|
|
687
|
+
},
|
|
623
688
|
});
|
|
689
|
+
const readOnlyWitness =
|
|
690
|
+
getEvolutionLedgerManifestWitnessReadOnlyReader(witnessAdapter);
|
|
691
|
+
if (
|
|
692
|
+
readOnlyWitness !== null &&
|
|
693
|
+
hasEvolutionLedgerV2ManifestDirectoryBoundaries(backend)
|
|
694
|
+
)
|
|
695
|
+
READ_ONLY_EVENT_READERS.set(
|
|
696
|
+
backend,
|
|
697
|
+
Object.freeze((...args) => {
|
|
698
|
+
if (args.length)
|
|
699
|
+
throw new TypeError(
|
|
700
|
+
"read-only manifest events take no replacement context",
|
|
701
|
+
);
|
|
702
|
+
const retention =
|
|
703
|
+
captureEvolutionLedgerV2RetainedSegmentDirectoryBoundary(backend);
|
|
704
|
+
if (retention === null) return null;
|
|
705
|
+
const directories =
|
|
706
|
+
captureEvolutionLedgerV2ManifestDirectoryBoundaries(backend);
|
|
707
|
+
const witnessDirectories =
|
|
708
|
+
captureEvolutionLedgerV2ManifestWitnessDirectoryBoundaries(backend);
|
|
709
|
+
const observer = Object.freeze({ read: readOnlyWitness });
|
|
710
|
+
const before = coherentSnapshot(catalog, headStore, observer);
|
|
711
|
+
if (before.head === null)
|
|
712
|
+
throw failure(
|
|
713
|
+
EVOLUTION_LEDGER_V2_MANIFEST_INVALID_CODE,
|
|
714
|
+
"read-only manifest events require a committed head",
|
|
715
|
+
);
|
|
716
|
+
const result = readEvolutionLedgerManifestEvents({
|
|
717
|
+
authority: manifestAuthority,
|
|
718
|
+
descriptor: normalizedDescriptor,
|
|
719
|
+
head: before.head,
|
|
720
|
+
manifests: catalog.list(),
|
|
721
|
+
segmentStore,
|
|
722
|
+
});
|
|
723
|
+
const after = coherentSnapshot(catalog, headStore, observer);
|
|
724
|
+
if (canonical(before) !== canonical(after))
|
|
725
|
+
throw failure(
|
|
726
|
+
EVOLUTION_LEDGER_V2_MANIFEST_CORRUPT_CODE,
|
|
727
|
+
"manifest checkpoint changed during read-only event capture",
|
|
728
|
+
);
|
|
729
|
+
directories.catalog.recheck();
|
|
730
|
+
directories.head.recheck();
|
|
731
|
+
witnessDirectories.recheck();
|
|
732
|
+
retention.recheck();
|
|
733
|
+
return result;
|
|
734
|
+
}),
|
|
735
|
+
);
|
|
624
736
|
return backend;
|
|
625
737
|
}
|
|
626
738
|
|
|
739
|
+
export function getEvolutionLedgerV2ReadOnlyEventsReader(value) {
|
|
740
|
+
if (arguments.length !== 1 || !ORIGINAL_MANIFEST_COMPONENTS.has(value))
|
|
741
|
+
throw new TypeError("one original v2 manifest backend is required");
|
|
742
|
+
return READ_ONLY_EVENT_READERS.get(value) ?? null;
|
|
743
|
+
}
|
|
744
|
+
|
|
627
745
|
/** Local metadata only. Capturing these components does not authenticate state. */
|
|
628
746
|
export function hasEvolutionLedgerV2ManifestDirectoryBoundaries(value) {
|
|
629
747
|
const components = ORIGINAL_MANIFEST_COMPONENTS.get(value);
|
|
@@ -673,3 +791,126 @@ export function captureEvolutionLedgerV2ManifestBackend(value) {
|
|
|
673
791
|
export function isEvolutionLedgerV2ManifestBackend(value) {
|
|
674
792
|
return BACKENDS.has(value);
|
|
675
793
|
}
|
|
794
|
+
|
|
795
|
+
export function captureEvolutionLedgerV2RetainedSegmentDirectoryBoundary(
|
|
796
|
+
value,
|
|
797
|
+
) {
|
|
798
|
+
if (arguments.length !== 1 || !ORIGINAL_MANIFEST_COMPONENTS.has(value))
|
|
799
|
+
throw new TypeError("one original v2 manifest backend is required");
|
|
800
|
+
return captureImmutableLedgerSegmentStoreDirectoryBoundary(
|
|
801
|
+
ORIGINAL_MANIFEST_COMPONENTS.get(value).segmentStore,
|
|
802
|
+
);
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
/** Original factory chain only; caller-supplied manifests cannot trim inventory. */
|
|
806
|
+
export function captureEvolutionLedgerV2ReferencedSegmentInventory(value) {
|
|
807
|
+
if (arguments.length !== 1 || !ORIGINAL_MANIFEST_COMPONENTS.has(value))
|
|
808
|
+
throw new TypeError("one original v2 manifest backend is required");
|
|
809
|
+
return ORIGINAL_MANIFEST_COMPONENTS.get(value).captureReferencedInventory();
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
/** Full local retention audit is explicit; ordinary referenced replay is unchanged. */
|
|
813
|
+
export function captureEvolutionLedgerV2LocalRetentionInventory(value) {
|
|
814
|
+
if (arguments.length !== 1 || !ORIGINAL_MANIFEST_COMPONENTS.has(value))
|
|
815
|
+
throw new TypeError("one original v2 manifest backend is required");
|
|
816
|
+
const components = ORIGINAL_MANIFEST_COMPONENTS.get(value);
|
|
817
|
+
const read = () => {
|
|
818
|
+
const files = captureImmutableLedgerSegmentStoreFileInventory(
|
|
819
|
+
components.segmentStore,
|
|
820
|
+
);
|
|
821
|
+
if (files === null) return null;
|
|
822
|
+
const before = coherentSnapshot(
|
|
823
|
+
components.catalog,
|
|
824
|
+
components.headStore,
|
|
825
|
+
components.witnessAdapter,
|
|
826
|
+
);
|
|
827
|
+
const references = components.captureReferencedInventory();
|
|
828
|
+
const after = coherentSnapshot(
|
|
829
|
+
components.catalog,
|
|
830
|
+
components.headStore,
|
|
831
|
+
components.witnessAdapter,
|
|
832
|
+
);
|
|
833
|
+
if (
|
|
834
|
+
canonical(before) !== canonical(after) ||
|
|
835
|
+
before.head?.headDigest !== references.snapshot.head.headDigest
|
|
836
|
+
)
|
|
837
|
+
throw failure(
|
|
838
|
+
EVOLUTION_LEDGER_V2_MANIFEST_CORRUPT_CODE,
|
|
839
|
+
"manifest checkpoint changed during local retention audit",
|
|
840
|
+
);
|
|
841
|
+
const referenced = new Map(
|
|
842
|
+
references.snapshot.entries.map((entry) => [entry.segmentRef, entry]),
|
|
843
|
+
);
|
|
844
|
+
const entries = files.snapshot.entries.map((entry) => {
|
|
845
|
+
const reference = referenced.get(entry.segmentRef);
|
|
846
|
+
if (reference) {
|
|
847
|
+
if (
|
|
848
|
+
[
|
|
849
|
+
"contentDigest",
|
|
850
|
+
"proofDigest",
|
|
851
|
+
"storageVersion",
|
|
852
|
+
"sequenceStart",
|
|
853
|
+
"sequenceEnd",
|
|
854
|
+
"payloadBytes",
|
|
855
|
+
].some((field) => reference[field] !== entry[field])
|
|
856
|
+
)
|
|
857
|
+
throw failure(
|
|
858
|
+
EVOLUTION_LEDGER_V2_MANIFEST_CORRUPT_CODE,
|
|
859
|
+
"referenced segment differs from the complete local file inventory",
|
|
860
|
+
);
|
|
861
|
+
referenced.delete(entry.segmentRef);
|
|
862
|
+
}
|
|
863
|
+
return Object.freeze({
|
|
864
|
+
...entry,
|
|
865
|
+
disposition: reference ? "referenced" : "unreferenced-retained",
|
|
866
|
+
manifestDigest: reference?.manifestDigest ?? null,
|
|
867
|
+
});
|
|
868
|
+
});
|
|
869
|
+
if (referenced.size)
|
|
870
|
+
throw failure(
|
|
871
|
+
EVOLUTION_LEDGER_V2_MANIFEST_CORRUPT_CODE,
|
|
872
|
+
"referenced segments are missing from local file inventory",
|
|
873
|
+
);
|
|
874
|
+
// After ALL signing/verifier callbacks, check captured files without invoking
|
|
875
|
+
// those callbacks again. This is still a sequential, local state window.
|
|
876
|
+
files.recheckPhysicalSnapshot();
|
|
877
|
+
const core = Object.freeze({
|
|
878
|
+
schema: "chainlesschain.evolution-local-retention-audit/v1",
|
|
879
|
+
scope: "original-local-retention-directory-and-current-manifest-chain",
|
|
880
|
+
head: references.snapshot.head,
|
|
881
|
+
directoryInventoryDigest: files.snapshot.inventoryDigest,
|
|
882
|
+
referencedInventoryDigest: references.snapshot.inventoryDigest,
|
|
883
|
+
entries: Object.freeze(entries),
|
|
884
|
+
fileCount: entries.length,
|
|
885
|
+
referencedCount: references.snapshot.segmentCount,
|
|
886
|
+
unreferencedCount: entries.length - references.snapshot.segmentCount,
|
|
887
|
+
totalEncodedBytes: files.snapshot.totalEncodedBytes,
|
|
888
|
+
totalPayloadBytes: files.snapshot.totalPayloadBytes,
|
|
889
|
+
localDirectoryInventoryVerified: true,
|
|
890
|
+
externalWormVerified: false,
|
|
891
|
+
fullPhysicalStorageGraphVerified: false,
|
|
892
|
+
grantsMutationOrPromotionAuthority: false,
|
|
893
|
+
});
|
|
894
|
+
return Object.freeze({
|
|
895
|
+
...core,
|
|
896
|
+
auditDigest: `sha256:${createHash("sha256").update(`${core.schema}\0`).update(canonical(core)).digest("hex")}`,
|
|
897
|
+
});
|
|
898
|
+
};
|
|
899
|
+
const snapshot = read();
|
|
900
|
+
if (snapshot === null) return null;
|
|
901
|
+
return Object.freeze({
|
|
902
|
+
snapshot,
|
|
903
|
+
recheck(...args) {
|
|
904
|
+
if (args.length)
|
|
905
|
+
throw new TypeError(
|
|
906
|
+
"local retention audit takes no replacement context",
|
|
907
|
+
);
|
|
908
|
+
if (read().auditDigest !== snapshot.auditDigest)
|
|
909
|
+
throw failure(
|
|
910
|
+
EVOLUTION_LEDGER_V2_MANIFEST_CORRUPT_CODE,
|
|
911
|
+
"local retention inventory changed after capture",
|
|
912
|
+
);
|
|
913
|
+
return true;
|
|
914
|
+
},
|
|
915
|
+
});
|
|
916
|
+
}
|
|
@@ -17,6 +17,15 @@ import {
|
|
|
17
17
|
import { withFileLock } from "../with-file-lock.js";
|
|
18
18
|
import { isLocalUiEvolutionFileSystem } from "./evolution-windows-directory-durability.js";
|
|
19
19
|
import { isProductionEvolutionFileSystem } from "./evolution-private-storage.js";
|
|
20
|
+
import { getEvolutionFileWitnessReadOnlyReader } from "./evolution-file-witness.js";
|
|
21
|
+
import {
|
|
22
|
+
EVOLUTION_LEDGER_WITNESS_SCHEMA,
|
|
23
|
+
EVOLUTION_LEDGER_WITNESS_ANCESTRY_SCHEMA,
|
|
24
|
+
} from "./evolution-witness-contracts.js";
|
|
25
|
+
export {
|
|
26
|
+
EVOLUTION_LEDGER_WITNESS_SCHEMA,
|
|
27
|
+
EVOLUTION_LEDGER_WITNESS_ANCESTRY_SCHEMA,
|
|
28
|
+
};
|
|
20
29
|
import {
|
|
21
30
|
assertKnowledgeWikiSourceAdmission,
|
|
22
31
|
WIKI_SOURCE_ADMISSION_INVALID_CODE,
|
|
@@ -39,10 +48,6 @@ export const EVOLUTION_LEDGER_VERIFICATION_SCHEMA =
|
|
|
39
48
|
"chainlesschain.evolution-ledger-verification/v2";
|
|
40
49
|
export const EVOLUTION_LEDGER_QUERY_SCHEMA =
|
|
41
50
|
"chainlesschain.evolution-ledger-query-result/v1";
|
|
42
|
-
export const EVOLUTION_LEDGER_WITNESS_SCHEMA =
|
|
43
|
-
"chainlesschain.evolution-ledger-witness/v1";
|
|
44
|
-
export const EVOLUTION_LEDGER_WITNESS_ANCESTRY_SCHEMA =
|
|
45
|
-
"chainlesschain.evolution-ledger-witness-ancestry/v1";
|
|
46
51
|
export const EVOLUTION_LEDGER_STORE_MARKER_SCHEMA =
|
|
47
52
|
"chainlesschain.evolution-ledger-store-marker/v1";
|
|
48
53
|
export const EVOLUTION_LEDGER_AUDIT_EXPORT_SCHEMA =
|
|
@@ -65,6 +70,10 @@ export const EVOLUTION_LEDGER_V2_MIGRATION_INTENT =
|
|
|
65
70
|
export const EVOLUTION_LEDGER_V2_CUTOVER_COMPLETED =
|
|
66
71
|
"evolution.ledger-v2.cutover-completed";
|
|
67
72
|
const MIGRATION_SOURCES = new WeakMap();
|
|
73
|
+
const READ_ONLY_HISTORY_READERS = new WeakMap();
|
|
74
|
+
export const EVOLUTION_LEDGER_READ_ONLY_HELD_CODE =
|
|
75
|
+
"CC_EVOLUTION_LEDGER_READ_ONLY_HELD";
|
|
76
|
+
export const EVOLUTION_LEDGER_READ_ONLY_MAX_EVENTS = 10_000;
|
|
68
77
|
const DIRECTORY_BOUNDARIES = new WeakMap();
|
|
69
78
|
const VERIFIED_HISTORY_READERS = new WeakMap();
|
|
70
79
|
const DEFAULT_APPEND_PORTS = new WeakSet();
|
|
@@ -569,7 +578,7 @@ function isUnsafeAsyncResult(value) {
|
|
|
569
578
|
const descriptor = Object.getOwnPropertyDescriptor(value, "then");
|
|
570
579
|
return Boolean(
|
|
571
580
|
descriptor &&
|
|
572
|
-
|
|
581
|
+
(!("value" in descriptor) || typeof descriptor.value === "function"),
|
|
573
582
|
);
|
|
574
583
|
}
|
|
575
584
|
|
|
@@ -1975,6 +1984,7 @@ export class EvolutionLedger {
|
|
|
1975
1984
|
#verifySignature;
|
|
1976
1985
|
#verifyWitnessSignature;
|
|
1977
1986
|
#witness;
|
|
1987
|
+
#readOnlyWitness;
|
|
1978
1988
|
#witnessTrust;
|
|
1979
1989
|
|
|
1980
1990
|
constructor({
|
|
@@ -2046,6 +2056,7 @@ export class EvolutionLedger {
|
|
|
2046
2056
|
this.#trust = normalizeTrust(trust);
|
|
2047
2057
|
this.#witnessTrust = normalizeTrust(witnessTrust);
|
|
2048
2058
|
this.#witness = captureWitness(witness);
|
|
2059
|
+
this.#readOnlyWitness = getEvolutionFileWitnessReadOnlyReader(witness);
|
|
2049
2060
|
this.#clock = Object.freeze((...args) => clock(...args));
|
|
2050
2061
|
this.#lockClock = Object.freeze((...args) => lockClock(...args));
|
|
2051
2062
|
this.#random = Object.freeze((...args) => random(...args));
|
|
@@ -2352,6 +2363,48 @@ export class EvolutionLedger {
|
|
|
2352
2363
|
) {
|
|
2353
2364
|
DEFAULT_APPEND_PORTS.add(this);
|
|
2354
2365
|
}
|
|
2366
|
+
if (new.target === EvolutionLedger && this.#readOnlyWitness !== null)
|
|
2367
|
+
READ_ONLY_HISTORY_READERS.set(
|
|
2368
|
+
this,
|
|
2369
|
+
Object.freeze((...args) => {
|
|
2370
|
+
if (args.length)
|
|
2371
|
+
throw new TypeError(
|
|
2372
|
+
"read-only source history takes no replacement context",
|
|
2373
|
+
);
|
|
2374
|
+
const state = this.#loadState({ readOnly: true });
|
|
2375
|
+
const frontier = deepFreeze({
|
|
2376
|
+
ledgerId: state.identity.ledgerId,
|
|
2377
|
+
identityDigest: state.identity.identityDigest,
|
|
2378
|
+
epoch: state.identity.epoch,
|
|
2379
|
+
sequence: state.head.sequence,
|
|
2380
|
+
headDigest: state.head.headDigest,
|
|
2381
|
+
anchorDigest: state.head.anchorDigest,
|
|
2382
|
+
storeMarkerDigest: state.identity.storeMarkerDigest,
|
|
2383
|
+
storeMarkerEntryDigest: state.identity.storeMarkerEntryDigest,
|
|
2384
|
+
witnessId: this.#witness.id,
|
|
2385
|
+
witnessDigest: state.witness.witnessDigest,
|
|
2386
|
+
witnessGeneration: state.witness.generation,
|
|
2387
|
+
});
|
|
2388
|
+
const hash = crypto
|
|
2389
|
+
.createHash("sha256")
|
|
2390
|
+
.update("chainlesschain.evolution-read-only-source-events/v1\0")
|
|
2391
|
+
.update(`${state.events.length}\0`);
|
|
2392
|
+
for (const event of state.events) {
|
|
2393
|
+
const json = canonicalJson(event);
|
|
2394
|
+
hash.update(`${Buffer.byteLength(json)}:`).update(json);
|
|
2395
|
+
}
|
|
2396
|
+
return deepFreeze({
|
|
2397
|
+
schema: "chainlesschain.evolution-read-only-source-history/v1",
|
|
2398
|
+
frontier,
|
|
2399
|
+
events: state.events,
|
|
2400
|
+
eventsDigest: `sha256:${hash.digest("hex")}`,
|
|
2401
|
+
readOnlyOpen: true,
|
|
2402
|
+
recoveryPerformed: false,
|
|
2403
|
+
fullPhysicalStorageGraphVerified: false,
|
|
2404
|
+
grantsMutationOrPromotionAuthority: false,
|
|
2405
|
+
});
|
|
2406
|
+
}),
|
|
2407
|
+
);
|
|
2355
2408
|
Object.freeze(this);
|
|
2356
2409
|
}
|
|
2357
2410
|
|
|
@@ -2936,7 +2989,30 @@ export class EvolutionLedger {
|
|
|
2936
2989
|
return proof;
|
|
2937
2990
|
}
|
|
2938
2991
|
|
|
2939
|
-
#readWitness() {
|
|
2992
|
+
#readWitness(readOnly = false) {
|
|
2993
|
+
if (readOnly) {
|
|
2994
|
+
if (this.#readOnlyWitness === null)
|
|
2995
|
+
throw ledgerError(
|
|
2996
|
+
EVOLUTION_LEDGER_READ_ONLY_HELD_CODE,
|
|
2997
|
+
"source witness has no original read-only reader",
|
|
2998
|
+
);
|
|
2999
|
+
let record;
|
|
3000
|
+
try {
|
|
3001
|
+
record = this.#readOnlyWitness();
|
|
3002
|
+
} catch (cause) {
|
|
3003
|
+
throw ledgerError(
|
|
3004
|
+
"CC_EVOLUTION_LEDGER_WITNESS_UNAVAILABLE",
|
|
3005
|
+
"read-only source witness failed closed",
|
|
3006
|
+
{ cause },
|
|
3007
|
+
);
|
|
3008
|
+
}
|
|
3009
|
+
if (isUnsafeAsyncResult(record))
|
|
3010
|
+
throw ledgerError(
|
|
3011
|
+
"CC_EVOLUTION_LEDGER_WITNESS_UNAVAILABLE",
|
|
3012
|
+
"read-only witness must be synchronous",
|
|
3013
|
+
);
|
|
3014
|
+
return this.#verifyWitnessRecord(record);
|
|
3015
|
+
}
|
|
2940
3016
|
return this.#callWitness("read", {
|
|
2941
3017
|
ledgerTrust: this.#trust,
|
|
2942
3018
|
witnessTrust: this.#witnessTrust,
|
|
@@ -4429,18 +4505,78 @@ export class EvolutionLedger {
|
|
|
4429
4505
|
return state;
|
|
4430
4506
|
}
|
|
4431
4507
|
|
|
4432
|
-
#loadState({
|
|
4508
|
+
#loadState({
|
|
4509
|
+
allowInitialize = false,
|
|
4510
|
+
incremental = false,
|
|
4511
|
+
readOnly = false,
|
|
4512
|
+
} = {}) {
|
|
4433
4513
|
this.#assertBoundaries();
|
|
4434
|
-
|
|
4435
|
-
|
|
4514
|
+
const held = (message) => {
|
|
4515
|
+
throw ledgerError(EVOLUTION_LEDGER_READ_ONLY_HELD_CODE, message);
|
|
4516
|
+
};
|
|
4517
|
+
const noDebris = () => {
|
|
4518
|
+
for (const directory of [
|
|
4519
|
+
this.#paths.rootDir,
|
|
4520
|
+
this.#paths.segmentDir,
|
|
4521
|
+
this.#paths.authorityRootDir,
|
|
4522
|
+
this.#paths.anchorDir,
|
|
4523
|
+
])
|
|
4524
|
+
for (const entry of this.#fs.readdirSync(directory, {
|
|
4525
|
+
withFileTypes: true,
|
|
4526
|
+
}))
|
|
4527
|
+
if (
|
|
4528
|
+
entry.name.startsWith(".stage-") ||
|
|
4529
|
+
entry.name.startsWith(".replace-") ||
|
|
4530
|
+
entry.name.endsWith(".tmp")
|
|
4531
|
+
)
|
|
4532
|
+
held("read-only source history encountered recovery debris");
|
|
4533
|
+
};
|
|
4534
|
+
const observedFiles = [];
|
|
4535
|
+
const readFile = (file, maximum, label, options = {}) => {
|
|
4536
|
+
if (!readOnly)
|
|
4537
|
+
return this.#readCanonicalFile(file, maximum, label, options);
|
|
4538
|
+
let before = null;
|
|
4539
|
+
try {
|
|
4540
|
+
before = this.#fs.lstatSync(file, { bigint: true });
|
|
4541
|
+
} catch (cause) {
|
|
4542
|
+
if (!(options.allowMissing && cause?.code === "ENOENT"))
|
|
4543
|
+
throw ledgerError(
|
|
4544
|
+
"CC_EVOLUTION_LEDGER_STORE_UNSAFE",
|
|
4545
|
+
"read-only source file is unavailable",
|
|
4546
|
+
{ cause },
|
|
4547
|
+
);
|
|
4548
|
+
}
|
|
4549
|
+
const value = this.#readCanonicalFile(file, maximum, label, options);
|
|
4550
|
+
if (value === null) {
|
|
4551
|
+
if (before !== null)
|
|
4552
|
+
held("source file disappeared during read-only capture");
|
|
4553
|
+
return null;
|
|
4554
|
+
}
|
|
4555
|
+
if (before === null)
|
|
4556
|
+
held("source file appeared during read-only capture");
|
|
4557
|
+
assertPhysicalFile(before, maximum, label);
|
|
4558
|
+
const after = this.#fs.lstatSync(file, { bigint: true });
|
|
4559
|
+
assertPhysicalFile(after, maximum, label);
|
|
4560
|
+
if (!samePhysicalFile(before, after))
|
|
4561
|
+
held("source file changed during read-only capture");
|
|
4562
|
+
observedFiles.push({
|
|
4563
|
+
file,
|
|
4564
|
+
maximum,
|
|
4565
|
+
fingerprint: physicalFileFingerprint(after),
|
|
4566
|
+
});
|
|
4567
|
+
return value;
|
|
4568
|
+
};
|
|
4569
|
+
if (readOnly) noDebris();
|
|
4570
|
+
else this.#cleanupDebris();
|
|
4571
|
+
let witnessed = this.#readWitness(readOnly);
|
|
4436
4572
|
|
|
4437
|
-
const identityFile =
|
|
4573
|
+
const identityFile = readFile(
|
|
4438
4574
|
this.#paths.identityPath,
|
|
4439
4575
|
64 * 1024,
|
|
4440
4576
|
"ledger identity",
|
|
4441
4577
|
{ allowMissing: true },
|
|
4442
4578
|
);
|
|
4443
|
-
let storeMarkerFile =
|
|
4579
|
+
let storeMarkerFile = readFile(
|
|
4444
4580
|
this.#paths.storeMarkerPath,
|
|
4445
4581
|
64 * 1024,
|
|
4446
4582
|
"store incarnation marker",
|
|
@@ -4456,12 +4592,9 @@ export class EvolutionLedger {
|
|
|
4456
4592
|
SEGMENT_FILE_PATTERN,
|
|
4457
4593
|
"segment directory",
|
|
4458
4594
|
);
|
|
4459
|
-
let headFile = this.#
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
"ledger HEAD",
|
|
4463
|
-
{ allowMissing: true },
|
|
4464
|
-
);
|
|
4595
|
+
let headFile = readFile(this.#paths.headPath, 64 * 1024, "ledger HEAD", {
|
|
4596
|
+
allowMissing: true,
|
|
4597
|
+
});
|
|
4465
4598
|
|
|
4466
4599
|
if (!identityFile) {
|
|
4467
4600
|
if (
|
|
@@ -4520,6 +4653,7 @@ export class EvolutionLedger {
|
|
|
4520
4653
|
}
|
|
4521
4654
|
if (anchorNames.length === 0 || !headFile) {
|
|
4522
4655
|
if (witnessed.status === "absent") {
|
|
4656
|
+
if (readOnly) held("source bootstrap requires recovery");
|
|
4523
4657
|
this.#recoverUnwitnessedBootstrap(
|
|
4524
4658
|
identity,
|
|
4525
4659
|
anchorNames,
|
|
@@ -4537,7 +4671,13 @@ export class EvolutionLedger {
|
|
|
4537
4671
|
);
|
|
4538
4672
|
}
|
|
4539
4673
|
|
|
4540
|
-
if (
|
|
4674
|
+
if (
|
|
4675
|
+
anchorNames.length >
|
|
4676
|
+
(readOnly
|
|
4677
|
+
? EVOLUTION_LEDGER_READ_ONLY_MAX_EVENTS
|
|
4678
|
+
: EVOLUTION_LEDGER_MAX_EVENTS) +
|
|
4679
|
+
1
|
|
4680
|
+
) {
|
|
4541
4681
|
throw ledgerError(
|
|
4542
4682
|
"CC_EVOLUTION_LEDGER_CAPACITY_EXCEEDED",
|
|
4543
4683
|
"anchor chain exceeds ledger capacity",
|
|
@@ -4550,13 +4690,10 @@ export class EvolutionLedger {
|
|
|
4550
4690
|
identity,
|
|
4551
4691
|
{ standalone: true },
|
|
4552
4692
|
);
|
|
4553
|
-
const cached =
|
|
4554
|
-
|
|
4555
|
-
anchorNames,
|
|
4556
|
-
|
|
4557
|
-
incremental,
|
|
4558
|
-
);
|
|
4559
|
-
if (!cached) {
|
|
4693
|
+
const cached = readOnly
|
|
4694
|
+
? null
|
|
4695
|
+
: this.#cachedPrefix(identity, anchorNames, segmentNames, incremental);
|
|
4696
|
+
if (!cached && !readOnly) {
|
|
4560
4697
|
const snapshotted = this.#tryStateSnapshot(
|
|
4561
4698
|
identity,
|
|
4562
4699
|
storeMarker,
|
|
@@ -4591,7 +4728,7 @@ export class EvolutionLedger {
|
|
|
4591
4728
|
}
|
|
4592
4729
|
continue;
|
|
4593
4730
|
}
|
|
4594
|
-
const anchorFile =
|
|
4731
|
+
const anchorFile = readFile(
|
|
4595
4732
|
path.join(this.#paths.anchorDir, name),
|
|
4596
4733
|
64 * 1024,
|
|
4597
4734
|
`anchor ${index}`,
|
|
@@ -4617,7 +4754,7 @@ export class EvolutionLedger {
|
|
|
4617
4754
|
|
|
4618
4755
|
const segmentName = segmentFileName(index, anchor.segmentDigest);
|
|
4619
4756
|
expectedSegments.add(segmentName);
|
|
4620
|
-
const segmentFile =
|
|
4757
|
+
const segmentFile = readFile(
|
|
4621
4758
|
path.join(this.#paths.segmentDir, segmentName),
|
|
4622
4759
|
EVOLUTION_LEDGER_MAX_EVENT_BYTES,
|
|
4623
4760
|
`event segment ${index}`,
|
|
@@ -4652,6 +4789,7 @@ export class EvolutionLedger {
|
|
|
4652
4789
|
let removedOrphan = false;
|
|
4653
4790
|
for (const name of segmentNames) {
|
|
4654
4791
|
if (expectedSegments.has(name)) continue;
|
|
4792
|
+
if (readOnly) held("unanchored source segment requires recovery");
|
|
4655
4793
|
const match = SEGMENT_FILE_PATTERN.exec(name);
|
|
4656
4794
|
const sequence = Number(match[1]);
|
|
4657
4795
|
if (sequence !== events.length + 1) {
|
|
@@ -4702,6 +4840,7 @@ export class EvolutionLedger {
|
|
|
4702
4840
|
}
|
|
4703
4841
|
let authoritativeHead = head;
|
|
4704
4842
|
if (witnessed.status === "absent") {
|
|
4843
|
+
if (readOnly) held("source witness initialization requires recovery");
|
|
4705
4844
|
if (
|
|
4706
4845
|
anchors.length !== 1 ||
|
|
4707
4846
|
events.length !== 0 ||
|
|
@@ -4749,6 +4888,7 @@ export class EvolutionLedger {
|
|
|
4749
4888
|
witnessedEvent,
|
|
4750
4889
|
);
|
|
4751
4890
|
if (witnessed.sequence < maximumAnchor.sequence) {
|
|
4891
|
+
if (readOnly) held("unwitnessed source tail requires recovery");
|
|
4752
4892
|
if (
|
|
4753
4893
|
head.anchorDigest !== witnessed.anchorDigest ||
|
|
4754
4894
|
maximumAnchor.sequence !== witnessed.sequence + 1
|
|
@@ -4802,6 +4942,7 @@ export class EvolutionLedger {
|
|
|
4802
4942
|
maximumEvent,
|
|
4803
4943
|
);
|
|
4804
4944
|
if (head.sequence < maximumAnchor.sequence) {
|
|
4945
|
+
if (readOnly) held("source HEAD requires recovery");
|
|
4805
4946
|
const bytes = serializeRecord(maximumAnchor, 64 * 1024, "head anchor");
|
|
4806
4947
|
this.#replaceHead(bytes);
|
|
4807
4948
|
authoritativeHead = maximumAnchor;
|
|
@@ -4820,6 +4961,46 @@ export class EvolutionLedger {
|
|
|
4820
4961
|
storeMarker,
|
|
4821
4962
|
witness: witnessed,
|
|
4822
4963
|
});
|
|
4964
|
+
if (readOnly) {
|
|
4965
|
+
const currentWitness = this.#readWitness(true);
|
|
4966
|
+
if (currentWitness.witnessDigest !== witnessed.witnessDigest)
|
|
4967
|
+
held("source witness changed during read-only capture");
|
|
4968
|
+
const currentHead = readFile(
|
|
4969
|
+
this.#paths.headPath,
|
|
4970
|
+
64 * 1024,
|
|
4971
|
+
"read-only source HEAD",
|
|
4972
|
+
);
|
|
4973
|
+
if (
|
|
4974
|
+
canonicalJson(currentHead.record) !== canonicalJson(authoritativeHead)
|
|
4975
|
+
)
|
|
4976
|
+
held("source HEAD changed during read-only capture");
|
|
4977
|
+
if (
|
|
4978
|
+
JSON.stringify(
|
|
4979
|
+
this.#listFiles(
|
|
4980
|
+
this.#paths.anchorDir,
|
|
4981
|
+
ANCHOR_FILE_PATTERN,
|
|
4982
|
+
"anchor directory",
|
|
4983
|
+
),
|
|
4984
|
+
) !== JSON.stringify(anchorNames) ||
|
|
4985
|
+
JSON.stringify(
|
|
4986
|
+
this.#listFiles(
|
|
4987
|
+
this.#paths.segmentDir,
|
|
4988
|
+
SEGMENT_FILE_PATTERN,
|
|
4989
|
+
"segment directory",
|
|
4990
|
+
),
|
|
4991
|
+
) !== JSON.stringify(segmentNames)
|
|
4992
|
+
)
|
|
4993
|
+
held("source immutable inventory changed during read-only capture");
|
|
4994
|
+
noDebris();
|
|
4995
|
+
for (const observed of observedFiles) {
|
|
4996
|
+
const stat = this.#fs.lstatSync(observed.file, { bigint: true });
|
|
4997
|
+
assertPhysicalFile(stat, observed.maximum, "read-only source release");
|
|
4998
|
+
if (physicalFileFingerprint(stat) !== observed.fingerprint)
|
|
4999
|
+
held("source file changed before read-only history release");
|
|
5000
|
+
}
|
|
5001
|
+
this.#assertBoundaries();
|
|
5002
|
+
return verifiedState;
|
|
5003
|
+
}
|
|
4823
5004
|
return this.#rememberState(
|
|
4824
5005
|
verifiedState,
|
|
4825
5006
|
anchorNames,
|
|
@@ -5808,6 +5989,13 @@ export function getEvolutionLedgerVerifiedHistoryReader(ledger) {
|
|
|
5808
5989
|
return VERIFIED_HISTORY_READERS.get(ledger) ?? null;
|
|
5809
5990
|
}
|
|
5810
5991
|
|
|
5992
|
+
/** A cold authenticated prefix with no lock, cleanup, snapshot fallback or recovery. */
|
|
5993
|
+
export function getEvolutionLedgerReadOnlyHistoryReader(ledger) {
|
|
5994
|
+
if (arguments.length !== 1)
|
|
5995
|
+
throw new TypeError("read-only history capture takes one original ledger");
|
|
5996
|
+
return READ_ONLY_HISTORY_READERS.get(ledger) ?? null;
|
|
5997
|
+
}
|
|
5998
|
+
|
|
5811
5999
|
/** Construction identity only: custom filesystem/lock/crash ports keep phases. */
|
|
5812
6000
|
export function hasEvolutionLedgerDefaultAppendPorts(ledger) {
|
|
5813
6001
|
return DEFAULT_APPEND_PORTS.has(ledger);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Shared wire constants keep witness readers independent of ledger factories. */
|
|
2
|
+
export const EVOLUTION_LEDGER_WITNESS_SCHEMA =
|
|
3
|
+
"chainlesschain.evolution-ledger-witness/v1";
|
|
4
|
+
export const EVOLUTION_LEDGER_WITNESS_ANCESTRY_SCHEMA =
|
|
5
|
+
"chainlesschain.evolution-ledger-witness-ancestry/v1";
|
|
@@ -168,6 +168,8 @@ export function createEvolutionWitnessSegments({
|
|
|
168
168
|
const bytes = readBytes(
|
|
169
169
|
segmentPath(digest),
|
|
170
170
|
maximumHistoryBytes - storedBytes,
|
|
171
|
+
false,
|
|
172
|
+
options.readOnly === true,
|
|
171
173
|
);
|
|
172
174
|
storedBytes += bytes.length;
|
|
173
175
|
if (hash(bytes) !== digest)
|