@remnic/core 9.45.0 → 9.45.1
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/dist/access-admin-ops-surface.d.ts +10 -10
- package/dist/access-admin-ops-surface.js +25 -25
- package/dist/access-audit.js +2 -2
- package/dist/access-authorization-probe.d.ts +10 -10
- package/dist/access-authorization-probe.js +26 -26
- package/dist/access-boundary.d.ts +10 -10
- package/dist/access-boundary.js +25 -25
- package/dist/access-cli.js +69 -68
- package/dist/access-cli.js.map +1 -1
- package/dist/access-extraction-force-flush.d.ts +10 -10
- package/dist/access-extraction-force-flush.js +25 -25
- package/dist/access-health-types.d.ts +1 -1
- package/dist/access-http-lcm-compaction.d.ts +10 -10
- package/dist/access-http-lifecycle-flush.d.ts +10 -10
- package/dist/access-http-query.js +25 -25
- package/dist/access-http.d.ts +10 -10
- package/dist/access-http.js +34 -34
- package/dist/access-identity-continuity-surface.d.ts +8 -8
- package/dist/access-identity-continuity-surface.js +25 -25
- package/dist/access-lcm-surface.d.ts +10 -10
- package/dist/access-lcm-surface.js +25 -25
- package/dist/access-mcp.d.ts +10 -10
- package/dist/access-mcp.js +30 -30
- package/dist/access-memory-search-fanout.d.ts +2 -2
- package/dist/{access-namespace-preflight-47dOyty9.d.ts → access-namespace-preflight-5yZ4g6F8.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +3 -3
- package/dist/access-namespace-preflight.js +25 -25
- package/dist/access-observe-write-surface.d.ts +10 -10
- package/dist/access-observe-write-surface.js +25 -25
- package/dist/access-operations-batch.js +27 -27
- package/dist/access-operations.d.ts +13 -13
- package/dist/access-operations.js +29 -29
- package/dist/access-recall-concurrency.d.ts +10 -10
- package/dist/access-recall-concurrency.js +25 -25
- package/dist/access-recall-response.d.ts +10 -10
- package/dist/access-recall-response.js +25 -25
- package/dist/access-recall-surface.d.ts +10 -10
- package/dist/access-recall-surface.js +25 -25
- package/dist/access-schema.d.ts +84 -84
- package/dist/access-schema.js +3 -3
- package/dist/{access-service-DBo88Dmm.d.ts → access-service-CiJRsgAB.d.ts} +7 -7
- package/dist/access-service-helpers.d.ts +10 -10
- package/dist/access-service.d.ts +10 -10
- package/dist/access-service.js +25 -25
- package/dist/access-surface-catalog.d.ts +10 -10
- package/dist/access-wearables-meetings-surface.d.ts +3 -3
- package/dist/action-confidence.d.ts +1 -1
- package/dist/active-memory-bridge.d.ts +1 -1
- package/dist/active-recall.d.ts +1 -1
- package/dist/active-recall.js +3 -2
- package/dist/active-recall.js.map +1 -1
- package/dist/adapters/index.js +4 -4
- package/dist/adapters/registry.js +2 -2
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +8 -8
- package/dist/briefing.d.ts +2 -2
- package/dist/briefing.js +8 -8
- package/dist/buffer-surprise-report.d.ts +1 -1
- package/dist/buffer-turn-helpers.d.ts +1 -1
- package/dist/buffer.d.ts +2 -2
- package/dist/bulk-import/index.d.ts +3 -3
- package/dist/calibration.d.ts +1 -1
- package/dist/capabilities.d.ts +1 -1
- package/dist/{catalog-DPQynQZG.d.ts → catalog-scBmy0sO.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-behavior.js +2 -2
- package/dist/causal-chain.js +2 -2
- package/dist/causal-consolidation.d.ts +1 -1
- package/dist/causal-consolidation.js +11 -11
- package/dist/causal-retrieval.js +2 -2
- package/dist/causal-trajectory-graph.d.ts +1 -1
- package/dist/causal-trajectory-graph.js +2 -2
- package/dist/causal-trajectory.js +1 -1
- package/dist/{chunk-GBJJUPNV.js → chunk-33PLLLL7.js} +2 -2
- package/dist/{chunk-ZAB5PG65.js → chunk-3F2LKUMU.js} +2 -2
- package/dist/{chunk-TXBU7YDV.js → chunk-3TBLDMJA.js} +2 -2
- package/dist/{chunk-FLBPATMZ.js → chunk-4UH4BTGK.js} +33 -33
- package/dist/{chunk-TVVEYCNW.js → chunk-7K5Q6COX.js} +4 -4
- package/dist/{chunk-K6OTW3TP.js → chunk-A5OJCXZL.js} +2 -2
- package/dist/{chunk-QQ3NDJOM.js → chunk-AAIUERNB.js} +2 -2
- package/dist/{chunk-C7EI7CA6.js → chunk-BJKPPZ6Z.js} +2 -2
- package/dist/{chunk-65V4K4MT.js → chunk-CJ2ZR7UA.js} +17 -17
- package/dist/{chunk-TM72UOX2.js → chunk-CUM2BBPN.js} +5 -1
- package/dist/chunk-CUM2BBPN.js.map +1 -0
- package/dist/{chunk-GQBZ7EVF.js → chunk-D3J5SLQK.js} +2 -2
- package/dist/{chunk-3HLCRYBV.js → chunk-DL7ZD3JH.js} +3 -3
- package/dist/{chunk-ZPJJE7MF.js → chunk-DNWXFTLD.js} +2 -2
- package/dist/{chunk-YQQK7W7T.js → chunk-E53DSZEN.js} +2 -2
- package/dist/{chunk-6OLQJJYE.js → chunk-E5UK4VPE.js} +2 -2
- package/dist/{chunk-3HKQOFOV.js → chunk-E6PNLPGJ.js} +19 -19
- package/dist/{chunk-Z54EM5YZ.js → chunk-GF22HWS2.js} +4 -4
- package/dist/chunk-HBVPYRDW.js +39 -0
- package/dist/chunk-HBVPYRDW.js.map +1 -0
- package/dist/{chunk-W6ROK2KU.js → chunk-HNZKVLAN.js} +2 -2
- package/dist/{chunk-GDC4INBF.js → chunk-HO3QBJEY.js} +2 -2
- package/dist/{chunk-U5G66ORD.js → chunk-HREE4JHI.js} +48 -48
- package/dist/{chunk-GSL47NPM.js → chunk-J7VGGECD.js} +1 -1
- package/dist/chunk-J7VGGECD.js.map +1 -0
- package/dist/{chunk-RKNJBZ55.js → chunk-JBPKEARU.js} +4 -4
- package/dist/{chunk-7PVFOFPJ.js → chunk-JE7EK33X.js} +2 -2
- package/dist/{chunk-WG2PI44B.js → chunk-JVLCVFQ4.js} +2 -2
- package/dist/{chunk-UZGJFIIG.js → chunk-JYIFGGEM.js} +2 -2
- package/dist/{chunk-6UWB5PTR.js → chunk-K442KOID.js} +54 -24
- package/dist/chunk-K442KOID.js.map +1 -0
- package/dist/{chunk-IPLYGWQF.js → chunk-KQAFEZQX.js} +5 -5
- package/dist/{chunk-3SHB4YAW.js → chunk-L2DPF4DF.js} +4 -4
- package/dist/{chunk-VRYJSKOM.js → chunk-LZ4LDKHZ.js} +2 -2
- package/dist/{chunk-PO5LSKQO.js → chunk-MU7ZHSZE.js} +2 -2
- package/dist/{chunk-CAGPP5NB.js → chunk-NRV4Y3PM.js} +1 -1
- package/dist/{chunk-SS7YWVPF.js → chunk-OAEQLRCY.js} +2 -2
- package/dist/{chunk-FVGQ5LIS.js → chunk-OQ5PRDDS.js} +2 -2
- package/dist/{chunk-5YGO5VEH.js → chunk-P4DRWEYC.js} +2 -2
- package/dist/{chunk-XMZV27S5.js → chunk-PDLBLTOK.js} +2 -2
- package/dist/{chunk-VCGPO2VD.js → chunk-PKNLM44P.js} +4 -4
- package/dist/{chunk-XFQRFWVS.js → chunk-QN25OCUF.js} +2 -2
- package/dist/{chunk-J4OKD6QX.js → chunk-RN7DY3FC.js} +5 -5
- package/dist/{chunk-7JO6RVBI.js → chunk-S2NCTZGJ.js} +4 -4
- package/dist/{chunk-R4Q7CQGZ.js → chunk-TDHTVMPG.js} +2 -2
- package/dist/{chunk-FXGLFGIG.js → chunk-TIHMZFIV.js} +3 -3
- package/dist/{chunk-ZS5UZU5M.js → chunk-U7GW7NE7.js} +7 -7
- package/dist/{chunk-WC4SPYHX.js → chunk-UVIKWC7M.js} +10 -10
- package/dist/{chunk-2QR2RRH6.js → chunk-UYLMNVY6.js} +4 -4
- package/dist/{chunk-G24XIK6H.js → chunk-VUPTKTDV.js} +2 -2
- package/dist/{chunk-GOPWZYZH.js → chunk-VWAXN2BN.js} +8 -8
- package/dist/{chunk-JZ7SSAQ5.js → chunk-XYTOI63Z.js} +3 -3
- package/dist/{cli-DQ4VhjqX.d.ts → cli-BUGN3d6_.d.ts} +5 -5
- package/dist/cli.d.ts +12 -12
- package/dist/cli.js +52 -51
- package/dist/compounding/engine.d.ts +2 -2
- package/dist/compounding/engine.js +8 -8
- package/dist/compounding/preference-consolidator.d.ts +1 -1
- package/dist/compression-optimizer.d.ts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +3 -2
- package/dist/connectors/codex-materialize-runner.d.ts +1 -1
- package/dist/connectors/codex-materialize-runner.js +8 -8
- package/dist/connectors/codex-materialize.d.ts +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.js +8 -8
- package/dist/consolidation-provenance-check.d.ts +2 -2
- package/dist/consolidation-undo.d.ts +2 -2
- package/dist/contradiction/index.d.ts +2 -2
- package/dist/converge-config.d.ts +11 -0
- package/dist/converge-config.js +12 -0
- package/dist/convergence-refresh.d.ts +2 -2
- package/dist/convergence-refresh.js +10 -10
- package/dist/conversation-index/backend.d.ts +1 -1
- package/dist/conversation-index/chunker.d.ts +1 -1
- package/dist/conversation-index/faiss-adapter.d.ts +1 -1
- package/dist/conversation-index/indexer.d.ts +1 -1
- package/dist/conversation-index/search.d.ts +1 -1
- package/dist/corpus-watermark.d.ts +1 -1
- package/dist/corpus-watermark.js +10 -10
- package/dist/day-summary.d.ts +1 -1
- package/dist/delinearize.d.ts +1 -1
- package/dist/direct-answer-wiring.d.ts +1 -1
- package/dist/direct-answer.d.ts +1 -1
- package/dist/embedding-fallback.d.ts +1 -1
- package/dist/enrichment/index.d.ts +1 -1
- package/dist/entity-retrieval.d.ts +2 -2
- package/dist/entity-retrieval.js +8 -8
- package/dist/entity-schema.d.ts +1 -1
- package/dist/explicit-capture.d.ts +8 -8
- package/dist/extraction-error-classification.d.ts +1 -1
- package/dist/extraction-faithfulness.d.ts +1 -1
- package/dist/extraction-judge-telemetry.d.ts +1 -1
- package/dist/extraction-judge-training.d.ts +1 -1
- package/dist/extraction-judge.d.ts +1 -1
- package/dist/extraction-liveness.d.ts +1 -1
- package/dist/extraction-source-grounding-rules.d.ts +1 -1
- package/dist/extraction-source-grounding.d.ts +1 -1
- package/dist/extraction.d.ts +1 -1
- package/dist/extraction.js +10 -10
- package/dist/fallback-llm.d.ts +1 -1
- package/dist/graph-dashboard-diff.d.ts +1 -1
- package/dist/graph-dashboard-key.d.ts +1 -1
- package/dist/graph-dashboard-parser.d.ts +1 -1
- package/dist/{graph-edge-decay-GF3ZSGSP.js → graph-edge-decay-Z6ENALU2.js} +4 -4
- package/dist/graph-edge-decay-Z6ENALU2.js.map +1 -0
- package/dist/graph-edge-reinforcement.d.ts +1 -1
- package/dist/graph-snapshot.d.ts +1 -1
- package/dist/graph-snapshot.js +3 -3
- package/dist/graph.d.ts +1 -1
- package/dist/graph.js +2 -2
- package/dist/importance.d.ts +1 -1
- package/dist/importers/index.d.ts +1 -1
- package/dist/in-flight-reads.d.ts +1 -1
- package/dist/index.d.ts +408 -407
- package/dist/index.js +77 -71
- package/dist/intent.d.ts +1 -1
- package/dist/lcm/engine.d.ts +1 -1
- package/dist/lcm/engine.js +2 -2
- package/dist/lcm/index.d.ts +1 -1
- package/dist/lcm/index.js +4 -4
- package/dist/lcm/tools.d.ts +1 -1
- package/dist/lifecycle.d.ts +1 -1
- package/dist/live-connectors-runner.d.ts +1 -1
- package/dist/local-llm.d.ts +1 -1
- package/dist/local-model-endpoint.d.ts +1 -1
- package/dist/maintenance/memory-governance.d.ts +1 -1
- package/dist/maintenance/memory-governance.js +8 -8
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +8 -8
- package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-projection.js +9 -9
- package/dist/{maintenance-_RV38GlE.d.ts → maintenance-LbuS2rUA.d.ts} +3 -3
- package/dist/mcp-memory-inspector-app.d.ts +10 -10
- package/dist/memory-action-policy.d.ts +1 -1
- package/dist/memory-cache.d.ts +1 -1
- package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
- package/dist/memory-projection-store.d.ts +1 -1
- package/dist/memory-provenance.d.ts +1 -1
- package/dist/memory-worth-outcomes.d.ts +2 -2
- package/dist/models-json.d.ts +1 -1
- package/dist/namespaces/migrate.d.ts +3 -3
- package/dist/namespaces/migrate.js +9 -9
- package/dist/namespaces/principal.d.ts +1 -1
- package/dist/namespaces/search.d.ts +1 -1
- package/dist/namespaces/storage.d.ts +3 -3
- package/dist/namespaces/storage.js +8 -8
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/offline-sync-impression-drain.d.ts +1 -1
- package/dist/operator-doctor-corpus.d.ts +1 -1
- package/dist/operator-doctor-corpus.js +11 -11
- package/dist/operator-doctor-replica.d.ts +1 -1
- package/dist/operator-toolkit.d.ts +3 -3
- package/dist/operator-toolkit.js +19 -18
- package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
- package/dist/orchestration/maintenance.d.ts +4 -4
- package/dist/orchestration/maintenance.js +13 -13
- package/dist/{orchestrator-B2ecFpRO.d.ts → orchestrator-rHiWt32X.d.ts} +7 -7
- package/dist/orchestrator.d.ts +8 -8
- package/dist/orchestrator.js +69 -68
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/{pipeline-Cs76XC-p.d.ts → pipeline-W_97O8BV.d.ts} +1 -1
- package/dist/policy-runtime.d.ts +1 -1
- package/dist/proactive-contention.d.ts +1 -1
- package/dist/provenance.d.ts +1 -1
- package/dist/{qmd-WJwvBgiF.d.ts → qmd-LWtMofAf.d.ts} +1 -1
- package/dist/qmd-preflight.d.ts +2 -2
- package/dist/qmd-recall-cache.d.ts +1 -1
- package/dist/qmd.d.ts +2 -2
- package/dist/recall-concurrency-config.d.ts +1 -1
- package/dist/recall-disclosure-escalation.d.ts +1 -1
- package/dist/recall-explain-renderer.d.ts +1 -1
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-memory-map.d.ts +1 -1
- package/dist/recall-planner-llm.d.ts +1 -1
- package/dist/recall-state.d.ts +1 -1
- package/dist/recall-tag-filter.d.ts +1 -1
- package/dist/recall-timings.d.ts +1 -1
- package/dist/recall-xray-cli.d.ts +1 -1
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.d.ts +1 -1
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.d.ts +1 -1
- package/dist/recall-xray.js +2 -2
- package/dist/reconcile/manifest.d.ts +1 -1
- package/dist/reconcile/manifest.js +2 -1
- package/dist/reconcile/manifest.js.map +1 -1
- package/dist/reconcile/plan.d.ts +18 -23
- package/dist/reconcile/plan.js +2 -1
- package/dist/replay/normalizers/chatgpt.d.ts +1 -1
- package/dist/replay/normalizers/claude.d.ts +1 -1
- package/dist/replay/normalizers/openclaw.d.ts +1 -1
- package/dist/replay/normalizers/shared.d.ts +1 -1
- package/dist/replay/runner.d.ts +1 -1
- package/dist/replay/types.d.ts +1 -1
- package/dist/replica-divergence.d.ts +1 -1
- package/dist/replica-peers-config.d.ts +1 -1
- package/dist/resolve-auth-token.d.ts +1 -1
- package/dist/resume-bundles.js +4 -3
- package/dist/retrieval-agents.d.ts +2 -2
- package/dist/retrieval-tiers.d.ts +1 -1
- package/dist/routing/engine.d.ts +1 -1
- package/dist/routing/store.d.ts +1 -1
- package/dist/salvage-envelope.d.ts +1 -1
- package/dist/schemas.d.ts +76 -76
- package/dist/{scope-profiles-CQ0NAleS.d.ts → scope-profiles-BiQKOE-p.d.ts} +1 -1
- package/dist/search/embed-helper.d.ts +1 -1
- package/dist/search/factory.d.ts +1 -1
- package/dist/search/index.d.ts +1 -1
- package/dist/search/lancedb-backend.d.ts +1 -1
- package/dist/search/meilisearch-backend.d.ts +1 -1
- package/dist/search/noop-backend.d.ts +1 -1
- package/dist/search/orama-backend.d.ts +1 -1
- package/dist/search/port.d.ts +1 -1
- package/dist/search/remote-backend.d.ts +1 -1
- package/dist/{semantic-consolidation-BWxOBMtz.d.ts → semantic-consolidation-dHYCyqgh.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-consolidation.js +9 -9
- package/dist/semantic-rule-promotion.js +8 -8
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +8 -8
- package/dist/{service-DW06sY3P.d.ts → service-DJG3KCQ4.d.ts} +2 -2
- package/dist/session-observer-bands.d.ts +1 -1
- package/dist/session-observer-state.d.ts +1 -1
- package/dist/shared-context/manager.d.ts +9 -9
- package/dist/signal.d.ts +1 -1
- package/dist/source-agent-qualifier.d.ts +1 -1
- package/dist/source-agent-qualifier.js +8 -8
- package/dist/{storage-qRIQPA6F.d.ts → storage-F9FVh-w9.d.ts} +1 -1
- package/dist/storage.d.ts +2 -2
- package/dist/storage.js +7 -7
- package/dist/summarizer.d.ts +1 -1
- package/dist/summary-snapshot.d.ts +1 -1
- package/dist/temporal-supersession.d.ts +2 -2
- package/dist/temporal-timeline-recall.d.ts +1 -1
- package/dist/temporal-validity.d.ts +1 -1
- package/dist/threading.d.ts +1 -1
- package/dist/tier-migration.d.ts +2 -2
- package/dist/tier-routing.d.ts +1 -1
- package/dist/topics.d.ts +1 -1
- package/dist/transcript.d.ts +1 -1
- package/dist/transfer/autodetect.js +1 -1
- package/dist/transfer/backup.js +1 -1
- package/dist/transfer/capsule-export.js +2 -2
- package/dist/transfer/types.d.ts +66 -66
- package/dist/trust-score-stage.d.ts +1 -1
- package/dist/trust-score.d.ts +1 -1
- package/dist/{types-CqWwMPr_.d.ts → types-rEwubvim.d.ts} +6 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/utility-runtime.d.ts +1 -1
- package/dist/verified-recall.js +8 -8
- package/dist/write-envelope.d.ts +1 -1
- package/package.json +2 -2
- package/src/config.test.ts +24 -0
- package/src/config.ts +3 -0
- package/src/converge-config.ts +39 -0
- package/src/index.ts +1 -2
- package/src/reconcile/plan.test.ts +40 -52
- package/src/reconcile/plan.ts +78 -63
- package/src/types.ts +5 -0
- package/dist/chunk-6UWB5PTR.js.map +0 -1
- package/dist/chunk-GSL47NPM.js.map +0 -1
- package/dist/chunk-TM72UOX2.js.map +0 -1
- /package/dist/{chunk-GBJJUPNV.js.map → chunk-33PLLLL7.js.map} +0 -0
- /package/dist/{chunk-ZAB5PG65.js.map → chunk-3F2LKUMU.js.map} +0 -0
- /package/dist/{chunk-TXBU7YDV.js.map → chunk-3TBLDMJA.js.map} +0 -0
- /package/dist/{chunk-FLBPATMZ.js.map → chunk-4UH4BTGK.js.map} +0 -0
- /package/dist/{chunk-TVVEYCNW.js.map → chunk-7K5Q6COX.js.map} +0 -0
- /package/dist/{chunk-K6OTW3TP.js.map → chunk-A5OJCXZL.js.map} +0 -0
- /package/dist/{chunk-QQ3NDJOM.js.map → chunk-AAIUERNB.js.map} +0 -0
- /package/dist/{chunk-C7EI7CA6.js.map → chunk-BJKPPZ6Z.js.map} +0 -0
- /package/dist/{chunk-65V4K4MT.js.map → chunk-CJ2ZR7UA.js.map} +0 -0
- /package/dist/{chunk-GQBZ7EVF.js.map → chunk-D3J5SLQK.js.map} +0 -0
- /package/dist/{chunk-3HLCRYBV.js.map → chunk-DL7ZD3JH.js.map} +0 -0
- /package/dist/{chunk-ZPJJE7MF.js.map → chunk-DNWXFTLD.js.map} +0 -0
- /package/dist/{chunk-YQQK7W7T.js.map → chunk-E53DSZEN.js.map} +0 -0
- /package/dist/{chunk-6OLQJJYE.js.map → chunk-E5UK4VPE.js.map} +0 -0
- /package/dist/{chunk-3HKQOFOV.js.map → chunk-E6PNLPGJ.js.map} +0 -0
- /package/dist/{chunk-Z54EM5YZ.js.map → chunk-GF22HWS2.js.map} +0 -0
- /package/dist/{chunk-W6ROK2KU.js.map → chunk-HNZKVLAN.js.map} +0 -0
- /package/dist/{chunk-GDC4INBF.js.map → chunk-HO3QBJEY.js.map} +0 -0
- /package/dist/{chunk-U5G66ORD.js.map → chunk-HREE4JHI.js.map} +0 -0
- /package/dist/{chunk-RKNJBZ55.js.map → chunk-JBPKEARU.js.map} +0 -0
- /package/dist/{chunk-7PVFOFPJ.js.map → chunk-JE7EK33X.js.map} +0 -0
- /package/dist/{chunk-WG2PI44B.js.map → chunk-JVLCVFQ4.js.map} +0 -0
- /package/dist/{chunk-UZGJFIIG.js.map → chunk-JYIFGGEM.js.map} +0 -0
- /package/dist/{chunk-IPLYGWQF.js.map → chunk-KQAFEZQX.js.map} +0 -0
- /package/dist/{chunk-3SHB4YAW.js.map → chunk-L2DPF4DF.js.map} +0 -0
- /package/dist/{chunk-VRYJSKOM.js.map → chunk-LZ4LDKHZ.js.map} +0 -0
- /package/dist/{chunk-PO5LSKQO.js.map → chunk-MU7ZHSZE.js.map} +0 -0
- /package/dist/{chunk-CAGPP5NB.js.map → chunk-NRV4Y3PM.js.map} +0 -0
- /package/dist/{chunk-SS7YWVPF.js.map → chunk-OAEQLRCY.js.map} +0 -0
- /package/dist/{chunk-FVGQ5LIS.js.map → chunk-OQ5PRDDS.js.map} +0 -0
- /package/dist/{chunk-5YGO5VEH.js.map → chunk-P4DRWEYC.js.map} +0 -0
- /package/dist/{chunk-XMZV27S5.js.map → chunk-PDLBLTOK.js.map} +0 -0
- /package/dist/{chunk-VCGPO2VD.js.map → chunk-PKNLM44P.js.map} +0 -0
- /package/dist/{chunk-XFQRFWVS.js.map → chunk-QN25OCUF.js.map} +0 -0
- /package/dist/{chunk-J4OKD6QX.js.map → chunk-RN7DY3FC.js.map} +0 -0
- /package/dist/{chunk-7JO6RVBI.js.map → chunk-S2NCTZGJ.js.map} +0 -0
- /package/dist/{chunk-R4Q7CQGZ.js.map → chunk-TDHTVMPG.js.map} +0 -0
- /package/dist/{chunk-FXGLFGIG.js.map → chunk-TIHMZFIV.js.map} +0 -0
- /package/dist/{chunk-ZS5UZU5M.js.map → chunk-U7GW7NE7.js.map} +0 -0
- /package/dist/{chunk-WC4SPYHX.js.map → chunk-UVIKWC7M.js.map} +0 -0
- /package/dist/{chunk-2QR2RRH6.js.map → chunk-UYLMNVY6.js.map} +0 -0
- /package/dist/{chunk-G24XIK6H.js.map → chunk-VUPTKTDV.js.map} +0 -0
- /package/dist/{chunk-GOPWZYZH.js.map → chunk-VWAXN2BN.js.map} +0 -0
- /package/dist/{chunk-JZ7SSAQ5.js.map → chunk-XYTOI63Z.js.map} +0 -0
- /package/dist/{graph-edge-decay-GF3ZSGSP.js.map → converge-config.js.map} +0 -0
package/src/config.test.ts
CHANGED
|
@@ -2416,3 +2416,27 @@ test("parseConfig forwards bridgeMode as a raw passthrough (validation is in res
|
|
|
2416
2416
|
test("parseConfig leaves the OpenClaw delegate timeout to the plugin parser", () => {
|
|
2417
2417
|
assert.equal("bridgeHealthTimeoutMs" in parseConfig({ bridgeHealthTimeoutMs: 7_500 }), false);
|
|
2418
2418
|
});
|
|
2419
|
+
|
|
2420
|
+
test("parseConfig validates converge conflict policy and defaults to newest-wins", () => {
|
|
2421
|
+
assert.deepEqual(parseConfig({}).converge, { conflictPolicy: "newest-wins" });
|
|
2422
|
+
|
|
2423
|
+
for (const conflictPolicy of ["newest-wins", "manual"] as const) {
|
|
2424
|
+
assert.equal(parseConfig({ converge: { conflictPolicy } }).converge.conflictPolicy, conflictPolicy);
|
|
2425
|
+
}
|
|
2426
|
+
|
|
2427
|
+
for (const conflictPolicy of ["keep-both", "", "unknown", 0, false, null]) {
|
|
2428
|
+
assert.throws(
|
|
2429
|
+
() => parseConfig({ converge: { conflictPolicy } }),
|
|
2430
|
+
/converge\.conflictPolicy.*newest-wins.*manual/,
|
|
2431
|
+
);
|
|
2432
|
+
}
|
|
2433
|
+
|
|
2434
|
+
for (const converge of [0, null, [], new Date(), new Map()]) {
|
|
2435
|
+
assert.throws(() => parseConfig({ converge }), /converge must be a plain object/);
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2438
|
+
assert.throws(
|
|
2439
|
+
() => parseConfig({ converge: { conflictPolciy: "manual" } }),
|
|
2440
|
+
/converge contains unknown key "conflictPolciy"/,
|
|
2441
|
+
);
|
|
2442
|
+
});
|
package/src/config.ts
CHANGED
|
@@ -26,6 +26,7 @@ import type {
|
|
|
26
26
|
TriggerMode,
|
|
27
27
|
TrustWeights,
|
|
28
28
|
} from "./types.js";
|
|
29
|
+
import { parseConvergeConfig } from "./converge-config.js";
|
|
29
30
|
import { log } from "./logger.js";
|
|
30
31
|
import { cloneDefaultSessionObserverBands } from "./session-observer-bands.js";
|
|
31
32
|
import { readEnvVar, resolveHomeDir } from "./runtime/env.js";
|
|
@@ -80,6 +81,7 @@ const DEFAULT_WORKSPACE_DIR = path.join(
|
|
|
80
81
|
);
|
|
81
82
|
|
|
82
83
|
const DEFAULT_INIT_GATE_TIMEOUT_MS = 30_000;
|
|
84
|
+
|
|
83
85
|
const CLIENT_SECRET_FIELD = ["client", "Secret"].join("") as "clientSecret";
|
|
84
86
|
const REFRESH_TOKEN_FIELD = ["refresh", "Token"].join("") as "refreshToken";
|
|
85
87
|
const LEGACY_ACTIVE_RECALL_CUSTOM_FIELD = [
|
|
@@ -2332,6 +2334,7 @@ export function parseConfig(
|
|
|
2332
2334
|
procedural,
|
|
2333
2335
|
extractionLiveness: parseExtractionLivenessConfig(cfg),
|
|
2334
2336
|
replicaPeers: parseReplicaPeersConfig(cfg),
|
|
2337
|
+
converge: parseConvergeConfig(cfg.converge),
|
|
2335
2338
|
wearables,
|
|
2336
2339
|
meetings,
|
|
2337
2340
|
activity,
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ConvergeConfig, ConvergeConflictPolicy } from "./types.js";
|
|
2
|
+
|
|
3
|
+
export const CONVERGE_CONFLICT_POLICIES = [
|
|
4
|
+
"newest-wins",
|
|
5
|
+
"manual",
|
|
6
|
+
] as const satisfies readonly ConvergeConflictPolicy[];
|
|
7
|
+
|
|
8
|
+
export const DEFAULT_CONVERGE_CONFLICT_POLICY: ConvergeConflictPolicy = "newest-wins";
|
|
9
|
+
|
|
10
|
+
export function parseConvergeConfig(block: unknown): ConvergeConfig {
|
|
11
|
+
if (block === undefined) {
|
|
12
|
+
return { conflictPolicy: DEFAULT_CONVERGE_CONFLICT_POLICY };
|
|
13
|
+
}
|
|
14
|
+
if (block === null || typeof block !== "object" || Array.isArray(block)) {
|
|
15
|
+
throw new Error("converge must be a plain object");
|
|
16
|
+
}
|
|
17
|
+
const prototype = Object.getPrototypeOf(block);
|
|
18
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
19
|
+
throw new Error("converge must be a plain object");
|
|
20
|
+
}
|
|
21
|
+
const { conflictPolicy, ...unknown } = block as Record<string, unknown>;
|
|
22
|
+
const unknownKey = Object.keys(unknown)[0];
|
|
23
|
+
if (unknownKey !== undefined) {
|
|
24
|
+
throw new Error(`converge contains unknown key ${JSON.stringify(unknownKey)}`);
|
|
25
|
+
}
|
|
26
|
+
if (conflictPolicy === undefined) {
|
|
27
|
+
return { conflictPolicy: DEFAULT_CONVERGE_CONFLICT_POLICY };
|
|
28
|
+
}
|
|
29
|
+
if (
|
|
30
|
+
typeof conflictPolicy === "string" &&
|
|
31
|
+
CONVERGE_CONFLICT_POLICIES.includes(conflictPolicy as ConvergeConflictPolicy)
|
|
32
|
+
) {
|
|
33
|
+
return { conflictPolicy: conflictPolicy as ConvergeConflictPolicy };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
throw new Error(
|
|
37
|
+
`converge.conflictPolicy must be one of ${CONVERGE_CONFLICT_POLICIES.join(", ")}; got ${JSON.stringify(conflictPolicy)}`
|
|
38
|
+
);
|
|
39
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1394,8 +1394,7 @@ export type {
|
|
|
1394
1394
|
CalendarSource,
|
|
1395
1395
|
RecallDisclosure,
|
|
1396
1396
|
} from "./types.js";
|
|
1397
|
-
|
|
1398
|
-
// Recall disclosure depth (issue #677).
|
|
1397
|
+
export { CONVERGE_CONFLICT_POLICIES, DEFAULT_CONVERGE_CONFLICT_POLICY } from "./converge-config.js";
|
|
1399
1398
|
export {
|
|
1400
1399
|
DEFAULT_RECALL_DISCLOSURE,
|
|
1401
1400
|
RECALL_DISCLOSURE_LEVELS,
|
|
@@ -60,7 +60,7 @@ test("a bootstrap merge moves unique data both ways and deletes nothing", () =>
|
|
|
60
60
|
);
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
test("
|
|
63
|
+
test("newest-wins is the default policy", () => {
|
|
64
64
|
const entries = planNamespaceReconciliation({
|
|
65
65
|
namespace: "default",
|
|
66
66
|
local: [file("facts/a.md", "local", 2000)],
|
|
@@ -69,7 +69,7 @@ test("manual is the default policy: a both-modified path is reported, never auto
|
|
|
69
69
|
const conflict = entryFor(entries, "facts/a.md");
|
|
70
70
|
assert.equal(conflict.action, "conflict");
|
|
71
71
|
assert.equal(conflict.reason, "both_modified");
|
|
72
|
-
assert.equal(conflict.resolution, "
|
|
72
|
+
assert.equal(conflict.resolution, "local-wins");
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
test("newest-wins picks the later side by mtime", () => {
|
|
@@ -101,17 +101,6 @@ test("newest-wins degrades to keeping both when the order is not decidable", ()
|
|
|
101
101
|
assert.equal(entryFor(entries, "facts/tied.md").resolution, "supersede-link");
|
|
102
102
|
});
|
|
103
103
|
|
|
104
|
-
test("keep-both never designates a loser", () => {
|
|
105
|
-
const entries = planNamespaceReconciliation(
|
|
106
|
-
{
|
|
107
|
-
namespace: "default",
|
|
108
|
-
local: [file("facts/a.md", "local", 2000)],
|
|
109
|
-
peer: [file("facts/a.md", "peer", 1000)],
|
|
110
|
-
},
|
|
111
|
-
{ conflictPolicy: "keep-both" },
|
|
112
|
-
);
|
|
113
|
-
assert.equal(entryFor(entries, "facts/a.md").resolution, "supersede-link");
|
|
114
|
-
});
|
|
115
104
|
|
|
116
105
|
test("a base turns a one-sided change back into an ordinary transfer", () => {
|
|
117
106
|
const base = [file("facts/a.md", "v1"), file("facts/b.md", "v1")];
|
|
@@ -200,6 +189,41 @@ test("delete-versus-modify stays a conflict in both directions", () => {
|
|
|
200
189
|
assert.equal(peerEdited.resolution, "unresolved");
|
|
201
190
|
});
|
|
202
191
|
|
|
192
|
+
test("newest-wins compares delete revision times with surviving modifications", () => {
|
|
193
|
+
const entries = planNamespaceReconciliation(
|
|
194
|
+
{
|
|
195
|
+
namespace: "default",
|
|
196
|
+
local: [
|
|
197
|
+
file("facts/local-modification-wins.md", "local-v2", 4000),
|
|
198
|
+
file("facts/peer-deletion-wins.md", "local-v2", 2000),
|
|
199
|
+
],
|
|
200
|
+
peer: [
|
|
201
|
+
file("facts/peer-modification-wins.md", "peer-v2", 4000),
|
|
202
|
+
file("facts/local-deletion-wins.md", "peer-v2", 2000),
|
|
203
|
+
],
|
|
204
|
+
base: [
|
|
205
|
+
file("facts/local-modification-wins.md", "v1"),
|
|
206
|
+
file("facts/peer-deletion-wins.md", "v1"),
|
|
207
|
+
file("facts/peer-modification-wins.md", "v1"),
|
|
208
|
+
file("facts/local-deletion-wins.md", "v1"),
|
|
209
|
+
],
|
|
210
|
+
localDeletionMtimeMs: new Map([
|
|
211
|
+
["facts/peer-modification-wins.md", 3000],
|
|
212
|
+
["facts/local-deletion-wins.md", 3000],
|
|
213
|
+
]),
|
|
214
|
+
peerDeletionMtimeMs: new Map([
|
|
215
|
+
["facts/local-modification-wins.md", 3000],
|
|
216
|
+
["facts/peer-deletion-wins.md", 3000],
|
|
217
|
+
]),
|
|
218
|
+
},
|
|
219
|
+
{ conflictPolicy: "newest-wins" },
|
|
220
|
+
);
|
|
221
|
+
assert.equal(entryFor(entries, "facts/local-modification-wins.md").resolution, "local-wins");
|
|
222
|
+
assert.equal(entryFor(entries, "facts/peer-deletion-wins.md").resolution, "peer-wins");
|
|
223
|
+
assert.equal(entryFor(entries, "facts/peer-modification-wins.md").resolution, "peer-wins");
|
|
224
|
+
assert.equal(entryFor(entries, "facts/local-deletion-wins.md").resolution, "local-wins");
|
|
225
|
+
});
|
|
226
|
+
|
|
203
227
|
test("namespaces are planned independently and reported separately", () => {
|
|
204
228
|
const plan = planReconciliation([
|
|
205
229
|
{ namespace: "alpha", local: [file("facts/a.md", "x")], peer: [] },
|
|
@@ -774,29 +798,6 @@ test("Win32-aliasing path segments are rejected", () => {
|
|
|
774
798
|
}
|
|
775
799
|
});
|
|
776
800
|
|
|
777
|
-
test("a supersede link names the newer revision", () => {
|
|
778
|
-
// Without a direction transport must re-derive it or guess which side is
|
|
779
|
-
// linked as superseding the other.
|
|
780
|
-
const newerPeer = planNamespaceReconciliation(
|
|
781
|
-
{
|
|
782
|
-
namespace: "default",
|
|
783
|
-
local: [file("facts/a.md", "local", 1000)],
|
|
784
|
-
peer: [file("facts/a.md", "peer", 2000)],
|
|
785
|
-
},
|
|
786
|
-
{ conflictPolicy: "keep-both" },
|
|
787
|
-
);
|
|
788
|
-
assert.equal(entryFor(newerPeer, "facts/a.md").newerSide, "peer");
|
|
789
|
-
|
|
790
|
-
const newerLocal = planNamespaceReconciliation(
|
|
791
|
-
{
|
|
792
|
-
namespace: "default",
|
|
793
|
-
local: [file("facts/a.md", "local", 2000)],
|
|
794
|
-
peer: [file("facts/a.md", "peer", 1000)],
|
|
795
|
-
},
|
|
796
|
-
{ conflictPolicy: "keep-both" },
|
|
797
|
-
);
|
|
798
|
-
assert.equal(entryFor(newerLocal, "facts/a.md").newerSide, "local");
|
|
799
|
-
});
|
|
800
801
|
|
|
801
802
|
test("an unorderable supersede link says so instead of picking a side", () => {
|
|
802
803
|
for (const pair of [
|
|
@@ -805,11 +806,10 @@ test("an unorderable supersede link says so instead of picking a side", () => {
|
|
|
805
806
|
] as const) {
|
|
806
807
|
const entries = planNamespaceReconciliation(
|
|
807
808
|
{ namespace: "default", local: [pair[0]], peer: [pair[1]] },
|
|
808
|
-
{ conflictPolicy: "
|
|
809
|
+
{ conflictPolicy: "newest-wins" },
|
|
809
810
|
);
|
|
810
811
|
const entry = entryFor(entries, "facts/a.md");
|
|
811
812
|
assert.equal(entry.resolution, "supersede-link");
|
|
812
|
-
assert.equal(entry.newerSide, undefined, "an unordered link must be visibly unordered");
|
|
813
813
|
}
|
|
814
814
|
});
|
|
815
815
|
|
|
@@ -845,25 +845,13 @@ test("a directionless supersede link is reported as unresolved", () => {
|
|
|
845
845
|
local: [file("facts/a.md", "local", 5000)],
|
|
846
846
|
peer: [file("facts/a.md", "peer", 5000)],
|
|
847
847
|
},
|
|
848
|
-
{ conflictPolicy: "
|
|
848
|
+
{ conflictPolicy: "newest-wins" },
|
|
849
849
|
);
|
|
850
|
-
assert.equal(entryFor(entries, "facts/a.md").newerSide, undefined);
|
|
851
850
|
assert.deepEqual(summarizeReconcilePlan(entries), [
|
|
852
851
|
{ namespace: "default", pull: 0, push: 0, identical: 0, conflict: 1, suppress: 0, unresolved: 1 },
|
|
853
852
|
]);
|
|
854
853
|
});
|
|
855
854
|
|
|
856
|
-
test("an ordered supersede link is not counted as unresolved", () => {
|
|
857
|
-
const entries = planNamespaceReconciliation(
|
|
858
|
-
{
|
|
859
|
-
namespace: "default",
|
|
860
|
-
local: [file("facts/a.md", "local", 1000)],
|
|
861
|
-
peer: [file("facts/a.md", "peer", 2000)],
|
|
862
|
-
},
|
|
863
|
-
{ conflictPolicy: "keep-both" },
|
|
864
|
-
);
|
|
865
|
-
assert.equal(summarizeReconcilePlan(entries)[0]?.unresolved, 0);
|
|
866
|
-
});
|
|
867
855
|
|
|
868
856
|
test("superscript COM and LPT device aliases are rejected", () => {
|
|
869
857
|
for (const bad of ["facts/COM\u00b9.txt", "facts/LPT\u00b2", "facts/com\u00b3.md"]) {
|
|
@@ -926,7 +914,7 @@ test("an empty namespace list still validates its options", () => {
|
|
|
926
914
|
`options ${Object.prototype.toString.call(bad)}`,
|
|
927
915
|
);
|
|
928
916
|
}
|
|
929
|
-
assert.equal(planReconciliation([], { conflictPolicy: "
|
|
917
|
+
assert.equal(planReconciliation([], { conflictPolicy: "manual" }).converged, true);
|
|
930
918
|
});
|
|
931
919
|
|
|
932
920
|
test("sharp-S aliases fold together", () => {
|
package/src/reconcile/plan.ts
CHANGED
|
@@ -2,6 +2,11 @@ import { normalizeNamespaceIdentity } from "../namespaces/identity.js";
|
|
|
2
2
|
import { OFFLINE_SYNC_MAX_MTIME_MS } from "../offline-sync.js";
|
|
3
3
|
import { validateArchiveRelativePath } from "../transfer/fs-utils.js";
|
|
4
4
|
import type { OfflineSyncFileState } from "../offline-sync.js";
|
|
5
|
+
import {
|
|
6
|
+
CONVERGE_CONFLICT_POLICIES,
|
|
7
|
+
DEFAULT_CONVERGE_CONFLICT_POLICY,
|
|
8
|
+
} from "../converge-config.js";
|
|
9
|
+
import type { ConvergeConflictPolicy } from "../types.js";
|
|
5
10
|
|
|
6
11
|
/**
|
|
7
12
|
* Bootstrap reconciliation planner for two peer daemons whose corpora have
|
|
@@ -24,21 +29,11 @@ import type { OfflineSyncFileState } from "../offline-sync.js";
|
|
|
24
29
|
/** Which way a path must move for the two corpora to agree. */
|
|
25
30
|
export type ReconcileAction = "pull" | "push" | "identical" | "conflict" | "suppress";
|
|
26
31
|
|
|
27
|
-
/**
|
|
28
|
-
* How a path present on BOTH sides with different content is settled.
|
|
29
|
-
*
|
|
30
|
-
* `manual` is the safe default: on a bootstrap merge the two sides are equally
|
|
31
|
-
* authoritative, so silently picking one is data loss with extra steps. An
|
|
32
|
-
* operator opts into an automatic rule once they know the shape of their split.
|
|
33
|
-
*/
|
|
34
|
-
export type ReconcileConflictPolicy = "manual" | "newest-wins" | "keep-both";
|
|
35
|
-
|
|
36
32
|
/**
|
|
37
33
|
* What the planner decided for a conflicting path.
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* fact neither corpus has seen.
|
|
34
|
+
* `supersede-link` records that both revisions need durable preservation when
|
|
35
|
+
* timestamps cannot safely select a winner. Apply must stop until transport
|
|
36
|
+
* can assign distinct durable identities to both revisions.
|
|
42
37
|
*/
|
|
43
38
|
export type ReconcileResolution = "local-wins" | "peer-wins" | "supersede-link" | "unresolved";
|
|
44
39
|
|
|
@@ -61,15 +56,6 @@ export interface ReconcilePlanEntry {
|
|
|
61
56
|
* delete the live copy instead of the retracted one.
|
|
62
57
|
*/
|
|
63
58
|
suppressSide?: "local" | "peer" | "both";
|
|
64
|
-
/**
|
|
65
|
-
* Which revision is newer, set only for a `supersede-link` resolution.
|
|
66
|
-
*
|
|
67
|
-
* The contract is that the older revision is linked as superseded by the
|
|
68
|
-
* newer one, so transport needs the direction. Absent when the timestamps
|
|
69
|
-
* cannot order the two - which is exactly when `newest-wins` degrades to
|
|
70
|
-
* `supersede-link` - and the link direction is then an operator decision.
|
|
71
|
-
*/
|
|
72
|
-
newerSide?: "local" | "peer";
|
|
73
59
|
}
|
|
74
60
|
|
|
75
61
|
export type ReconcileReason =
|
|
@@ -131,6 +117,14 @@ export interface ReconcileNamespaceInput {
|
|
|
131
117
|
* read as "never seen" rather than "deleted".
|
|
132
118
|
*/
|
|
133
119
|
base?: Iterable<ReconcileFileState>;
|
|
120
|
+
/**
|
|
121
|
+
* Revision timestamps for paths deleted locally since the base cursor.
|
|
122
|
+
* A deletion is a revision and must carry a comparable time for
|
|
123
|
+
* `newest-wins`; absence alone has no timestamp.
|
|
124
|
+
*/
|
|
125
|
+
localDeletionMtimeMs?: ReadonlyMap<string, number>;
|
|
126
|
+
/** Revision timestamps for paths deleted by the peer since the base cursor. */
|
|
127
|
+
peerDeletionMtimeMs?: ReadonlyMap<string, number>;
|
|
134
128
|
/**
|
|
135
129
|
* Digests of FILES this side has retracted, in the same form as
|
|
136
130
|
* `ReconcileFileState.sha256` — a hash of the serialized file.
|
|
@@ -163,7 +157,7 @@ export interface ReconcileNamespaceInput {
|
|
|
163
157
|
}
|
|
164
158
|
|
|
165
159
|
export interface ReconcileOptions {
|
|
166
|
-
conflictPolicy?:
|
|
160
|
+
conflictPolicy?: ConvergeConflictPolicy;
|
|
167
161
|
}
|
|
168
162
|
|
|
169
163
|
/**
|
|
@@ -473,13 +467,11 @@ function indexDigestsByPath(
|
|
|
473
467
|
return index;
|
|
474
468
|
}
|
|
475
469
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
if (value === undefined) return "manual";
|
|
480
|
-
if (!RECONCILE_CONFLICT_POLICIES.includes(value)) {
|
|
470
|
+
function assertConflictPolicy(value: ConvergeConflictPolicy | undefined): ConvergeConflictPolicy {
|
|
471
|
+
if (value === undefined) return DEFAULT_CONVERGE_CONFLICT_POLICY;
|
|
472
|
+
if (!CONVERGE_CONFLICT_POLICIES.includes(value)) {
|
|
481
473
|
throw new ReconcilePlanInputError(
|
|
482
|
-
`reconcile: unknown conflictPolicy ${JSON.stringify(value)}; expected one of ${
|
|
474
|
+
`reconcile: unknown conflictPolicy ${JSON.stringify(value)}; expected one of ${CONVERGE_CONFLICT_POLICIES.join(", ")}`,
|
|
483
475
|
);
|
|
484
476
|
}
|
|
485
477
|
return value;
|
|
@@ -497,36 +489,42 @@ function compareEntries(a: ReconcilePlanEntry, b: ReconcilePlanEntry): number {
|
|
|
497
489
|
return 0;
|
|
498
490
|
}
|
|
499
491
|
|
|
500
|
-
/**
|
|
501
|
-
* Direction for a supersede link, when the timestamps can order the pair.
|
|
502
|
-
* Omitted otherwise so an unordered link is visibly unordered rather than
|
|
503
|
-
* silently defaulted to one side.
|
|
504
|
-
*/
|
|
505
|
-
function newerSideOf(
|
|
506
|
-
local: ReconcileFileState,
|
|
507
|
-
peer: ReconcileFileState,
|
|
508
|
-
): { newerSide?: "local" | "peer" } {
|
|
509
|
-
const localMs = local.mtimeMs;
|
|
510
|
-
const peerMs = peer.mtimeMs;
|
|
511
|
-
if (typeof localMs !== "number" || typeof peerMs !== "number" || localMs === peerMs) return {};
|
|
512
|
-
return { newerSide: localMs > peerMs ? "local" : "peer" };
|
|
513
|
-
}
|
|
514
492
|
|
|
515
493
|
function resolveConflict(
|
|
516
|
-
policy:
|
|
517
|
-
|
|
518
|
-
|
|
494
|
+
policy: ConvergeConflictPolicy,
|
|
495
|
+
localMtimeMs: number | undefined,
|
|
496
|
+
peerMtimeMs: number | undefined,
|
|
497
|
+
missingTimestampResolution: ReconcileResolution,
|
|
519
498
|
): ReconcileResolution {
|
|
520
|
-
if (policy === "keep-both") return "supersede-link";
|
|
521
499
|
if (policy !== "newest-wins") return "unresolved";
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
500
|
+
if (localMtimeMs === undefined || peerMtimeMs === undefined || localMtimeMs === peerMtimeMs) {
|
|
501
|
+
return missingTimestampResolution;
|
|
502
|
+
}
|
|
503
|
+
return localMtimeMs > peerMtimeMs ? "local-wins" : "peer-wins";
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
function parseDeletionMtimes(
|
|
507
|
+
value: ReadonlyMap<string, number> | undefined,
|
|
508
|
+
side: string,
|
|
509
|
+
namespace: string,
|
|
510
|
+
): ReadonlyMap<string, number> {
|
|
511
|
+
if (value === undefined) return new Map();
|
|
512
|
+
if (!(value instanceof Map)) {
|
|
513
|
+
throw new ReconcilePlanInputError(
|
|
514
|
+
`reconcile: ${side} deletion mtimes for namespace ${namespace} must be a Map`,
|
|
515
|
+
);
|
|
516
|
+
}
|
|
517
|
+
const parsed = new Map<string, number>();
|
|
518
|
+
for (const [path, mtimeMs] of value) {
|
|
519
|
+
try {
|
|
520
|
+
validateArchiveRelativePath(path, `reconcile: ${side} deletion mtimes for namespace ${namespace}`);
|
|
521
|
+
} catch (err) {
|
|
522
|
+
throw new ReconcilePlanInputError(err instanceof Error ? err.message : String(err));
|
|
523
|
+
}
|
|
524
|
+
assertPortablePathSegments(path, side, namespace);
|
|
525
|
+
parsed.set(path, assertMtimeMs(mtimeMs, `${side} deletion for namespace ${namespace} entry ${path}`));
|
|
526
|
+
}
|
|
527
|
+
return parsed;
|
|
530
528
|
}
|
|
531
529
|
|
|
532
530
|
/**
|
|
@@ -572,6 +570,8 @@ export function planNamespaceReconciliation(
|
|
|
572
570
|
namespace,
|
|
573
571
|
"peerTombstonedFileSha256",
|
|
574
572
|
);
|
|
573
|
+
const localDeletionMtimeMs = parseDeletionMtimes(input.localDeletionMtimeMs, "local", namespace);
|
|
574
|
+
const peerDeletionMtimeMs = parseDeletionMtimes(input.peerDeletionMtimeMs, "peer", namespace);
|
|
575
575
|
const entries: ReconcilePlanEntry[] = [];
|
|
576
576
|
|
|
577
577
|
// Path -> digest only, never the file objects: enough to make the stream
|
|
@@ -639,7 +639,14 @@ export function planNamespaceReconciliation(
|
|
|
639
639
|
reason: baseSha256 === localFile.sha256 ? "peer_deleted" : "local_modified_peer_deleted",
|
|
640
640
|
localSha256: localFile.sha256,
|
|
641
641
|
baseSha256,
|
|
642
|
-
resolution:
|
|
642
|
+
resolution: baseSha256 === localFile.sha256
|
|
643
|
+
? "unresolved"
|
|
644
|
+
: resolveConflict(
|
|
645
|
+
policy,
|
|
646
|
+
localFile.mtimeMs,
|
|
647
|
+
peerDeletionMtimeMs.get(path),
|
|
648
|
+
"unresolved",
|
|
649
|
+
),
|
|
643
650
|
});
|
|
644
651
|
continue;
|
|
645
652
|
}
|
|
@@ -690,7 +697,12 @@ export function planNamespaceReconciliation(
|
|
|
690
697
|
});
|
|
691
698
|
continue;
|
|
692
699
|
}
|
|
693
|
-
const resolution = resolveConflict(
|
|
700
|
+
const resolution = resolveConflict(
|
|
701
|
+
policy,
|
|
702
|
+
localFile.mtimeMs,
|
|
703
|
+
peerFile.mtimeMs,
|
|
704
|
+
"supersede-link",
|
|
705
|
+
);
|
|
694
706
|
entries.push({
|
|
695
707
|
path,
|
|
696
708
|
namespace,
|
|
@@ -700,7 +712,6 @@ export function planNamespaceReconciliation(
|
|
|
700
712
|
peerSha256: peerFile.sha256,
|
|
701
713
|
...(baseSha256 === undefined ? {} : { baseSha256 }),
|
|
702
714
|
resolution,
|
|
703
|
-
...(resolution === "supersede-link" ? newerSideOf(localFile, peerFile) : {}),
|
|
704
715
|
});
|
|
705
716
|
}
|
|
706
717
|
|
|
@@ -732,7 +743,14 @@ export function planNamespaceReconciliation(
|
|
|
732
743
|
reason: baseSha256 === peerFile.sha256 ? "local_deleted" : "local_deleted_peer_modified",
|
|
733
744
|
peerSha256: peerFile.sha256,
|
|
734
745
|
baseSha256,
|
|
735
|
-
resolution:
|
|
746
|
+
resolution: baseSha256 === peerFile.sha256
|
|
747
|
+
? "unresolved"
|
|
748
|
+
: resolveConflict(
|
|
749
|
+
policy,
|
|
750
|
+
localDeletionMtimeMs.get(path),
|
|
751
|
+
peerFile.mtimeMs,
|
|
752
|
+
"unresolved",
|
|
753
|
+
),
|
|
736
754
|
});
|
|
737
755
|
continue;
|
|
738
756
|
}
|
|
@@ -758,12 +776,9 @@ export function summarizeReconcilePlan(entries: readonly ReconcilePlanEntry[]):
|
|
|
758
776
|
byNamespace.set(entry.namespace, report);
|
|
759
777
|
}
|
|
760
778
|
report[entry.action] += 1;
|
|
761
|
-
// A supersede link with no `newerSide` could not be ordered, and the link
|
|
762
|
-
// direction is then an operator decision - so it counts as unresolved even
|
|
763
|
-
// though the policy nominally settled it.
|
|
764
779
|
const needsOperator =
|
|
765
780
|
entry.resolution === "unresolved"
|
|
766
|
-
||
|
|
781
|
+
|| entry.resolution === "supersede-link";
|
|
767
782
|
if (entry.action === "conflict" && needsOperator) report.unresolved += 1;
|
|
768
783
|
}
|
|
769
784
|
return [...byNamespace.values()].sort((a, b) => (a.namespace === b.namespace ? 0 : a.namespace < b.namespace ? -1 : 1));
|
package/src/types.ts
CHANGED
|
@@ -8,6 +8,10 @@ import type { ReplicaPeersConfig } from "./replica-peers-config.js";
|
|
|
8
8
|
import type { BufferTurnOwner } from "./buffer-turn-helpers.js";
|
|
9
9
|
export type ReasoningEffort = "none" | "low" | "medium" | "high";
|
|
10
10
|
export type TriggerMode = "smart" | "every_n" | "time_based";
|
|
11
|
+
export type ConvergeConflictPolicy = "newest-wins" | "manual";
|
|
12
|
+
export interface ConvergeConfig {
|
|
13
|
+
conflictPolicy: ConvergeConflictPolicy;
|
|
14
|
+
}
|
|
11
15
|
export type SignalLevel = "none" | "low" | "medium" | "high";
|
|
12
16
|
export type MemoryCategory = "fact" | "preference" | "correction" | "entity" | "decision" | "relationship" | "principle" | "commitment" | "moment" | "skill" | "rule" | "procedure" | "reasoning_trace";
|
|
13
17
|
export type ConsolidationAction = "ADD" | "MERGE" | "UPDATE" | "INVALIDATE" | "SKIP";
|
|
@@ -1208,6 +1212,7 @@ export interface PluginConfig extends BoundedJsonlStateConfig {
|
|
|
1208
1212
|
procedural: ProceduralConfig;
|
|
1209
1213
|
extractionLiveness: ExtractionLivenessConfig;
|
|
1210
1214
|
replicaPeers: ReplicaPeersConfig;
|
|
1215
|
+
converge: ConvergeConfig;
|
|
1211
1216
|
/** Claim-level provenance spans (#1575); see `ProvenanceConfig` for defaults. */
|
|
1212
1217
|
provenance: ProvenanceConfig;
|
|
1213
1218
|
/**
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/reconcile/plan.ts"],"sourcesContent":["import { normalizeNamespaceIdentity } from \"../namespaces/identity.js\";\nimport { OFFLINE_SYNC_MAX_MTIME_MS } from \"../offline-sync.js\";\nimport { validateArchiveRelativePath } from \"../transfer/fs-utils.js\";\nimport type { OfflineSyncFileState } from \"../offline-sync.js\";\n\n/**\n * Bootstrap reconciliation planner for two peer daemons whose corpora have\n * already diverged (issue #2150).\n *\n * The offline-sync protocol assumes a satellite that shares a common base with\n * one daemon: every path it does not know about is a pull, and a conflict is\n * rare. Two long-lived daemons are the opposite case — each side holds months\n * of history the other never saw, both sides are authoritative, and there is\n * NO common base on the first run. That is a different decision problem, so it\n * gets its own planner rather than another mode flag inside `applyOfflineSync*`.\n *\n * This module is deliberately pure: it takes two file censuses and returns what\n * to do. No I/O, no transport, no clock. Everything that makes reconciliation\n * risky — which side wins, what counts as converged, what is reported — is\n * decided here where it can be exhaustively tested, and the transport layer is\n * left to carry out an already-settled plan.\n */\n\n/** Which way a path must move for the two corpora to agree. */\nexport type ReconcileAction = \"pull\" | \"push\" | \"identical\" | \"conflict\" | \"suppress\";\n\n/**\n * How a path present on BOTH sides with different content is settled.\n *\n * `manual` is the safe default: on a bootstrap merge the two sides are equally\n * authoritative, so silently picking one is data loss with extra steps. An\n * operator opts into an automatic rule once they know the shape of their split.\n */\nexport type ReconcileConflictPolicy = \"manual\" | \"newest-wins\" | \"keep-both\";\n\n/**\n * What the planner decided for a conflicting path.\n *\n * `keep-both` never overwrites: the older side is retained and linked as\n * superseded by the newer one, which is the only resolution that cannot lose a\n * fact neither corpus has seen.\n */\nexport type ReconcileResolution = \"local-wins\" | \"peer-wins\" | \"supersede-link\" | \"unresolved\";\n\nexport interface ReconcilePlanEntry {\n path: string;\n namespace: string;\n action: ReconcileAction;\n /** Stable machine-readable cause, safe to assert on and to aggregate. */\n reason: ReconcileReason;\n localSha256?: string;\n peerSha256?: string;\n /** Present only when a prior converged run left a cursor covering this path. */\n baseSha256?: string;\n /** Set only when `action` is `conflict`. */\n resolution?: ReconcileResolution;\n /**\n * Which side holds the retracted revision. Set only when `action` is\n * `suppress`: with different digests on each side and only one retracted,\n * the entry would otherwise be identical either way and transport could\n * delete the live copy instead of the retracted one.\n */\n suppressSide?: \"local\" | \"peer\" | \"both\";\n /**\n * Which revision is newer, set only for a `supersede-link` resolution.\n *\n * The contract is that the older revision is linked as superseded by the\n * newer one, so transport needs the direction. Absent when the timestamps\n * cannot order the two - which is exactly when `newest-wins` degrades to\n * `supersede-link` - and the link direction is then an operator decision.\n */\n newerSide?: \"local\" | \"peer\";\n}\n\nexport type ReconcileReason =\n | \"peer_only\"\n | \"local_only\"\n /** Cursor showed only that side moved since agreement; both still hold the path. */\n | \"peer_changed\"\n | \"local_changed\"\n | \"same_content\"\n | \"semantic_duplicate\"\n | \"both_modified\"\n | \"peer_deleted\"\n | \"local_deleted\"\n /** Peer deleted it while this side edited it — the offline-sync delete/modify pair. */\n | \"local_modified_peer_deleted\"\n | \"local_deleted_peer_modified\"\n | \"tombstoned\";\n\nexport interface ReconcileNamespaceReport {\n namespace: string;\n pull: number;\n push: number;\n identical: number;\n conflict: number;\n /** Local retractions the peer must be told about before the pair agrees. */\n suppress: number;\n /**\n * Conflicts still needing an operator: those the policy declined to settle,\n * plus supersede links whose direction could not be determined.\n */\n unresolved: number;\n}\n\nexport interface ReconcilePlan {\n entries: ReconcilePlanEntry[];\n byNamespace: ReconcileNamespaceReport[];\n /**\n * True when the two corpora already agree — every shared path matches and\n * neither side holds a path the other lacks.\n *\n * This is the idempotency contract from #2150: running reconciliation against\n * an already-converged peer must be a no-op, and a caller can skip the whole\n * transfer phase on this flag alone.\n */\n converged: boolean;\n}\n\n/** Minimal shape the planner needs; `OfflineSyncFileState` satisfies it. */\nexport type ReconcileFileState = Pick<OfflineSyncFileState, \"path\" | \"sha256\"> &\n Partial<Pick<OfflineSyncFileState, \"mtimeMs\" | \"bytes\">>;\n\nexport interface ReconcileNamespaceInput {\n namespace: string;\n local: Iterable<ReconcileFileState>;\n peer: Iterable<ReconcileFileState>;\n /**\n * File states agreed at the end of the last converged run with THIS peer.\n * Absent on a bootstrap merge, which is why a path missing from one side is\n * read as \"never seen\" rather than \"deleted\".\n */\n base?: Iterable<ReconcileFileState>;\n /**\n * Digests of FILES this side has retracted, in the same form as\n * `ReconcileFileState.sha256` — a hash of the serialized file.\n *\n * Deliberately NOT `TombstoneEntry.contentHash`, which hashes the canonical\n * raw fact text and therefore never equals a file digest (§13: one content\n * form, everywhere). Mapping retracted fact hashes onto the file digests that\n * carry them is the caller's job, because only the caller can read its own\n * corpus; handing this the wrong form would silently plan `pull` and\n * resurrect every retracted fact, so the parameter name states the form.\n */\n tombstonedFileSha256?: Iterable<string>;\n /**\n * Digests the PEER has retracted, same form.\n *\n * Without this a bootstrap merge cannot tell \"the peer never had it\" from\n * \"the peer deliberately retracted it\": the peer census simply omits both,\n * so a file we still hold is planned `push` and the peer's retraction is\n * undone. Reconciliation is symmetric, so retraction has to be too.\n *\n * SCOPE: these sets decide what happens to files that still EXIST on one\n * side. Sharing the retraction records themselves is not modelled here -\n * tombstones are corpus files (`state/tombstones.jsonl`), so they reconcile\n * as ordinary paths through this same plan. A digest both censuses have\n * already dropped therefore produces no entry, by design: there is no file\n * left to act on, and synthesizing a path-less entry would hand transport\n * something it cannot apply.\n */\n peerTombstonedFileSha256?: Iterable<string>;\n}\n\nexport interface ReconcileOptions {\n conflictPolicy?: ReconcileConflictPolicy;\n}\n\n/**\n * A census the planner refuses to reason about.\n *\n * Dropping a malformed or contradictory record would let the planner return\n * `converged: true` for a corpus it could not actually read, and transport is\n * invited to skip everything on that flag — so bad input fails loudly instead\n * (§1/§39).\n */\nexport class ReconcilePlanInputError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ReconcilePlanInputError\";\n }\n}\n\n/** Matches `assertSha256` in offline-sync so both surfaces reject the same values (§40). */\nconst SHA256_PATTERN = /^[a-f0-9]{64}$/i;\n\n/**\n * Validate a census record's identity fields.\n *\n * The digest matters as much as the path: two records that both omit `sha256`\n * compare `undefined === undefined` and plan as `identical`, converging a\n * corpus the planner never actually read.\n */\nfunction assertCensusRecord(\n file: ReconcileFileState | undefined,\n side: string,\n namespace: string,\n): ReconcileFileState {\n const path = file?.path;\n if (typeof path !== \"string\" || path.length === 0) {\n throw new ReconcilePlanInputError(\n `reconcile: ${side} census for namespace ${namespace} contains a record with no path`,\n );\n }\n // Same boundary offline-sync applies to this field: a peer census is\n // untrusted input, and an absolute or traversal path would otherwise become\n // a transfer instruction pointing outside the corpus root.\n try {\n validateArchiveRelativePath(path, `reconcile: ${side} census for namespace ${namespace}`);\n } catch (err) {\n throw new ReconcilePlanInputError(err instanceof Error ? err.message : String(err));\n }\n assertPortablePathSegments(path, side, namespace);\n return {\n ...file,\n path,\n sha256: assertDigest(file?.sha256, `${side} census for namespace ${namespace} entry ${path}`),\n ...(file?.mtimeMs === undefined\n ? {}\n : { mtimeMs: assertMtimeMs(file.mtimeMs, `${side} census for namespace ${namespace} entry ${path}`) }),\n };\n}\n\n/**\n * `newest-wins` decides which corpus keeps its history from this number, so a\n * NaN, an Infinity or a value past the Date range must not pick the winner.\n *\n * Fractional values ARE valid: `fs.stat()` reports sub-millisecond mtimes on\n * common filesystems and offline-sync forwards them unrounded, so this matches\n * its `assertOfflineSyncMtimeMs` — non-negative finite within Date range — and\n * deliberately does not require an integer.\n */\nfunction assertMtimeMs(value: unknown, context: string): number {\n if (\n typeof value !== \"number\"\n || !Number.isFinite(value)\n || value < 0\n || value > OFFLINE_SYNC_MAX_MTIME_MS\n ) {\n throw new ReconcilePlanInputError(\n `reconcile: ${context} has an out-of-range mtimeMs; expected a finite value between 0 and ${OFFLINE_SYNC_MAX_MTIME_MS}`,\n );\n }\n return value;\n}\n\n/**\n * Digests are canonicalized to lowercase, exactly as offline-sync's\n * `assertSha256` does. Keeping the caller's spelling would make two forms of\n * one digest compare unequal, so identical files would plan `both_modified`\n * and tombstone lookups would silently miss.\n */\nfunction assertDigest(value: unknown, context: string): string {\n if (typeof value !== \"string\" || !SHA256_PATTERN.test(value)) {\n throw new ReconcilePlanInputError(\n `reconcile: ${context} must carry a 64-character sha256 hex digest`,\n );\n }\n return value.toLowerCase();\n}\n\nfunction isPlainObject(value: unknown): boolean {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) return false;\n const proto: unknown = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null;\n}\n\nfunction assertNamespace(namespace: unknown): string {\n if (typeof namespace !== \"string\" || namespace.length === 0) {\n throw new ReconcilePlanInputError(\"reconcile: every namespace input needs a non-empty namespace\");\n }\n // `team` and ` team ` are one namespace to the rest of core, so accepting\n // both here would slip two inputs past the duplicate check and let them plan\n // contradictory actions for the same path. Rejected rather than silently\n // rewritten, so the namespace on every entry is the caller's own string.\n if (LONE_SURROGATE.test(namespace)) {\n // `namespaceIdentityToken()` encodes through TextEncoder, so a lone\n // surrogate and a literal U+FFFD collapse to ONE storage identity while\n // comparing as two here - slipping both past the duplicate-namespace guard.\n throw new ReconcilePlanInputError(\n \"reconcile: namespace contains an unpaired surrogate; it would collide with another namespace on disk\",\n );\n }\n if (normalizeNamespaceIdentity(namespace) !== namespace) {\n throw new ReconcilePlanInputError(\n `reconcile: namespace ${JSON.stringify(namespace)} is not canonical; pass ${JSON.stringify(normalizeNamespaceIdentity(namespace))}`,\n );\n }\n return namespace;\n}\n\nfunction assertIterable(value: unknown, side: string, namespace: string): Iterable<ReconcileFileState> {\n if (value === null || typeof value !== \"object\" || typeof (value as Iterable<ReconcileFileState>)[Symbol.iterator] !== \"function\") {\n throw new ReconcilePlanInputError(`reconcile: ${side} census for namespace ${namespace} must be iterable`);\n }\n return value as Iterable<ReconcileFileState>;\n}\n\n/**\n * Two paths that a participant's filesystem resolves to ONE file must not draw\n * separate push/pull work, or application order decides which revision\n * survives. Remnic is explicitly multi-platform, so all three aliasing rules\n * are folded together and a collision is rejected rather than raced:\n * case (macOS, Windows), Unicode normalization (macOS stores decomposed and\n * compares canonically), and Win32 trailing dots/spaces, which the Windows API\n * strips before touching disk.\n */\n// eslint-disable-next-line no-control-regex -- control characters are exactly what this rejects\nconst WIN32_INVALID_CHARS = /[<>:\"|?*\\u0000-\\u001f]/;\n// Windows treats the superscripts as their digits in COM/LPT device names.\nconst LONE_SURROGATE = /[\\ud800-\\udbff](?![\\udc00-\\udfff])|(?<![\\ud800-\\udbff])[\\udc00-\\udfff]/;\nconst WIN32_RESERVED_NAMES = /^(con|prn|aux|nul|(com|lpt)[1-9\\u00b9\\u00b2\\u00b3])$/i;\n\nfunction assertPortablePathSegments(path: string, side: string, namespace: string): void {\n for (const segment of path.split(\"/\")) {\n if (segment.length === 0) continue;\n if (segment.endsWith(\".\") || segment.endsWith(\" \")) {\n throw new ReconcilePlanInputError(\n `reconcile: ${side} census for namespace ${namespace} path ${path} has a segment ending in a dot or space; ` +\n \"Windows strips those and would alias it onto another file\",\n );\n }\n // `:` opens an alternate data stream, the rest cannot be created at all,\n // and a reserved device name resolves to hardware. A plan containing any of\n // them cannot be applied on a Windows participant.\n if (LONE_SURROGATE.test(segment)) {\n // Node encodes an unpaired surrogate as U+FFFD, so this path and a\n // literal U+FFFD path are one file on disk while comparing as distinct.\n throw new ReconcilePlanInputError(\n `reconcile: ${side} census for namespace ${namespace} path ${path} contains an unpaired surrogate`,\n );\n }\n if (WIN32_INVALID_CHARS.test(segment)) {\n throw new ReconcilePlanInputError(\n `reconcile: ${side} census for namespace ${namespace} path ${path} contains a character Windows cannot store`,\n );\n }\n if (WIN32_RESERVED_NAMES.test(segment.split(\".\")[0] ?? \"\")) {\n throw new ReconcilePlanInputError(\n `reconcile: ${side} census for namespace ${namespace} path ${path} uses a reserved Windows device name`,\n );\n }\n }\n}\n\nfunction assertNoPathAlias(\n seen: Map<string, string>,\n path: string,\n namespace: string,\n): void {\n // NFC first: macOS stores decomposed names and compares canonically, so\n // `é` (U+00E9) and `é` (e + U+0301) are ONE file there. Then a FULL caseless\n // fold - upper-then-lower, which collapses forms a bare toLowerCase() keeps\n // apart, such as final sigma `ς` against `σ`. Lowercasing alone would leave\n // those distinct and the planner would emit both a push and a pull.\n // `ß` upper-folds to `ss` while `ẞ` folds to `ß`, so one more pass equalizes\n // the pair that a single upper-then-lower still leaves apart.\n const folded = path.normalize(\"NFC\").toUpperCase().toLowerCase().replace(/\\u00df/g, \"ss\");\n const existing = seen.get(folded);\n if (existing !== undefined && existing !== path) {\n throw new ReconcilePlanInputError(\n `reconcile: namespace ${namespace} has aliasing paths (${existing}, ${path}); ` +\n \"they resolve to one file on a case-insensitive or Unicode-normalizing peer\",\n );\n }\n seen.set(folded, path);\n}\n\n/**\n * Duplicate paths are accepted only when they agree. Two digests for one path\n * make the plan depend on which record arrived last, which would break the\n * byte-stable ordering the convergence report relies on.\n */\nfunction rejectConflictingDuplicate(\n existing: { sha256: string; mtimeMs?: number } | undefined,\n incoming: { sha256: string; mtimeMs?: number },\n path: string,\n side: string,\n namespace: string,\n): boolean {\n if (!existing) return false;\n if (existing.sha256 !== incoming.sha256) {\n throw new ReconcilePlanInputError(\n `reconcile: ${side} census for namespace ${namespace} lists ${path} twice with different digests`,\n );\n }\n // Same bytes but a different mtime is still ambiguous: `newest-wins` reads\n // that timestamp, so accepting the first arrival would let input order decide\n // the winner.\n if (existing.mtimeMs !== incoming.mtimeMs) {\n throw new ReconcilePlanInputError(\n `reconcile: ${side} census for namespace ${namespace} lists ${path} twice with different mtimeMs`,\n );\n }\n return true;\n}\n\nfunction indexByPath(\n files: Iterable<ReconcileFileState>,\n side: string,\n namespace: string,\n): Map<string, ReconcileFileState> {\n const index = new Map<string, ReconcileFileState>();\n for (const raw of files) {\n const file = assertCensusRecord(raw, side, namespace);\n if (rejectConflictingDuplicate(index.get(file.path), file, file.path, side, namespace)) continue;\n index.set(file.path, file);\n }\n return index;\n}\n\n/**\n * A bare string satisfies `Iterable<string>`, and `new Set(\"abc…\")` would split\n * it into 64 one-character members — every membership test then misses and each\n * retracted file is planned as `pull` and resurrected. Reject the scalar and\n * canonicalize every member.\n */\nfunction parseTombstonedDigests(\n value: Iterable<string> | undefined,\n namespace: string,\n field = \"tombstonedFileSha256\",\n): Set<string> {\n if (value === undefined) return new Set();\n if (typeof value === \"string\") {\n throw new ReconcilePlanInputError(\n `reconcile: ${field} for namespace ${namespace} must be a collection of digests, not a single string`,\n );\n }\n if (value === null || typeof value !== \"object\" || typeof value[Symbol.iterator] !== \"function\") {\n // Otherwise the for...of below throws a raw TypeError and a caller handling\n // ReconcilePlanInputError cannot tell a bad request from a planner bug.\n throw new ReconcilePlanInputError(\n `reconcile: ${field} for namespace ${namespace} must be an iterable collection of digests`,\n );\n }\n const digests = new Set<string>();\n for (const entry of value) {\n digests.add(assertDigest(entry, `${field} for namespace ${namespace}`));\n }\n return digests;\n}\n\n/**\n * Validate a census while keeping ONLY path -> digest.\n *\n * The base cursor is read for digests alone, so indexing full records and\n * compacting afterwards would hold a corpus-sized record map and its copy at\n * once - the peak this avoids.\n */\nfunction indexDigestsByPath(\n files: Iterable<ReconcileFileState>,\n side: string,\n namespace: string,\n): Map<string, string> {\n const index = new Map<string, string>();\n for (const raw of files) {\n const file = assertCensusRecord(raw, side, namespace);\n const existing = index.get(file.path);\n // One map, not a parallel `seen`: the base's own mtimeMs is never a\n // decision input (only the local and peer timestamps order a conflict), so\n // a duplicate that agrees on the digest is unambiguous here regardless of\n // its timestamp, and the digest alone is enough to detect a real clash.\n if (existing !== undefined) {\n if (existing !== file.sha256) {\n throw new ReconcilePlanInputError(\n `reconcile: ${side} census for namespace ${namespace} lists ${file.path} twice with different digests`,\n );\n }\n continue;\n }\n index.set(file.path, file.sha256);\n }\n return index;\n}\n\nconst RECONCILE_CONFLICT_POLICIES: readonly ReconcileConflictPolicy[] = [\"manual\", \"newest-wins\", \"keep-both\"];\n\nfunction assertConflictPolicy(value: ReconcileConflictPolicy | undefined): ReconcileConflictPolicy {\n if (value === undefined) return \"manual\";\n if (!RECONCILE_CONFLICT_POLICIES.includes(value)) {\n throw new ReconcilePlanInputError(\n `reconcile: unknown conflictPolicy ${JSON.stringify(value)}; expected one of ${RECONCILE_CONFLICT_POLICIES.join(\", \")}`,\n );\n }\n return value;\n}\n\n/**\n * Total ordering for plan entries (§12): namespace, then path. Both are unique\n * per entry, so equal keys are impossible and the comparator never has to\n * return 0 for distinct rows — the output is byte-identical across runs, which\n * is what makes a convergence report diffable.\n */\nfunction compareEntries(a: ReconcilePlanEntry, b: ReconcilePlanEntry): number {\n if (a.namespace !== b.namespace) return a.namespace < b.namespace ? -1 : 1;\n if (a.path !== b.path) return a.path < b.path ? -1 : 1;\n return 0;\n}\n\n/**\n * Direction for a supersede link, when the timestamps can order the pair.\n * Omitted otherwise so an unordered link is visibly unordered rather than\n * silently defaulted to one side.\n */\nfunction newerSideOf(\n local: ReconcileFileState,\n peer: ReconcileFileState,\n): { newerSide?: \"local\" | \"peer\" } {\n const localMs = local.mtimeMs;\n const peerMs = peer.mtimeMs;\n if (typeof localMs !== \"number\" || typeof peerMs !== \"number\" || localMs === peerMs) return {};\n return { newerSide: localMs > peerMs ? \"local\" : \"peer\" };\n}\n\nfunction resolveConflict(\n policy: ReconcileConflictPolicy,\n local: ReconcileFileState,\n peer: ReconcileFileState,\n): ReconcileResolution {\n if (policy === \"keep-both\") return \"supersede-link\";\n if (policy !== \"newest-wins\") return \"unresolved\";\n const localMs = typeof local.mtimeMs === \"number\" && Number.isFinite(local.mtimeMs) ? local.mtimeMs : null;\n const peerMs = typeof peer.mtimeMs === \"number\" && Number.isFinite(peer.mtimeMs) ? peer.mtimeMs : null;\n // Without a usable timestamp on both sides \"newest\" is not decidable, and a\n // coin flip here silently discards one side's history. Fall back to keeping\n // both rather than inventing an order.\n if (localMs === null || peerMs === null) return \"supersede-link\";\n if (localMs === peerMs) return \"supersede-link\";\n return localMs > peerMs ? \"local-wins\" : \"peer-wins\";\n}\n\n/**\n * Plan one namespace. Exposed for callers that stream namespaces one at a time.\n *\n * Residency is one peer index + a set of local paths + the entry list. The\n * local census is consumed as a stream and never materialized, so a 100k-file\n * corpus does not hold two full censuses at once — but this is NOT constant\n * memory, and a caller holding its own census arrays adds to that.\n */\nexport function planNamespaceReconciliation(\n input: ReconcileNamespaceInput,\n options: ReconcileOptions = {},\n): ReconcilePlanEntry[] {\n if (!isPlainObject(input)) {\n throw new ReconcilePlanInputError(\"reconcile: namespace input must be a plain object\");\n }\n if (!isPlainObject(options)) {\n // A Date, Map or RegExp passes a bare typeof check, exposes no\n // `conflictPolicy`, and would silently take the default policy - hiding a\n // malformed request behind `manual`.\n throw new ReconcilePlanInputError(\"reconcile: options must be a plain object\");\n }\n const namespace = assertNamespace(input.namespace);\n const policy = assertConflictPolicy(options.conflictPolicy);\n const localCensus = assertIterable(input.local, \"local\", namespace);\n const caseFold = new Map<string, string>();\n // Index the peer census only, then stream the local one against it, removing\n // each match as it is consumed. Peak residency is one index plus the entry\n // list rather than two full censuses (round 2, codex P2).\n const peer = indexByPath(assertIterable(input.peer, \"peer\", namespace), \"peer\", namespace);\n // Only `base.sha256` is ever read, so the base is compacted to path -> digest\n // instead of a second full record index (round 7, codex P2).\n // Only an ABSENT base means bootstrap. A null/invalid cursor silently read as\n // \"no prior agreement\" would turn a peer-side deletion into a push and\n // resurrect it.\n const base = input.base === undefined\n ? null\n : indexDigestsByPath(assertIterable(input.base, \"base\", namespace), \"base\", namespace);\n const tombstoned = parseTombstonedDigests(input.tombstonedFileSha256, namespace);\n const peerTombstoned = parseTombstonedDigests(\n input.peerTombstonedFileSha256,\n namespace,\n \"peerTombstonedFileSha256\",\n );\n const entries: ReconcilePlanEntry[] = [];\n\n // Path -> digest only, never the file objects: enough to make the stream\n // idempotent and to catch contradictory duplicates without materializing the\n // second census.\n // Base paths participate in the collision check: a base `Facts/A.md` against\n // a local `facts/a.md` is the same delete/change ambiguity on a\n // case-insensitive participant.\n if (base) for (const basePath of base.keys()) assertNoPathAlias(caseFold, basePath, namespace);\n // Path -> decision-relevant fields only, never the whole record: enough to\n // make the stream idempotent and to catch contradictory duplicates without\n // materializing the second census.\n const seenLocal = new Map<string, { sha256: string; mtimeMs?: number }>();\n for (const rawLocal of localCensus) {\n const localFile = assertCensusRecord(rawLocal, \"local\", namespace);\n const path = localFile.path;\n assertNoPathAlias(caseFold, path, namespace);\n const seen = seenLocal.get(path);\n if (seen !== undefined) {\n // Same rule the indexed censuses get: mtimeMs is decision-relevant under\n // `newest-wins`, so a duplicate that disagrees on it is ambiguous too.\n if (rejectConflictingDuplicate(seen, localFile, path, \"local\", namespace)) continue;\n }\n seenLocal.set(path, { sha256: localFile.sha256, mtimeMs: localFile.mtimeMs });\n const peerFile = peer.get(path);\n // Consumed: whatever remains in the index afterwards is peer-only.\n peer.delete(path);\n const baseSha256 = base?.get(path);\n // Retraction outranks every other decision for this path, on EITHER side.\n // Checked before hash comparison and conflict resolution: a retracted peer\n // revision reaching the conflict ladder can win under `newest-wins`, and a\n // retracted LOCAL revision would otherwise be pushed - which is also how a\n // suppression undoes itself on the next run, since the local copy survives\n // the peer-side delete (round 4).\n // Either side's retraction removes the copy that carries the digest, so a\n // peer retraction of something we still hold suppresses OUR copy rather\n // than pushing it back.\n const localRetracted = tombstoned.has(localFile.sha256) || peerTombstoned.has(localFile.sha256);\n const peerRetracted =\n peerFile !== undefined && (tombstoned.has(peerFile.sha256) || peerTombstoned.has(peerFile.sha256));\n if (localRetracted || peerRetracted) {\n entries.push({\n path,\n namespace,\n action: \"suppress\",\n reason: \"tombstoned\",\n localSha256: localFile.sha256,\n ...(peerFile ? { peerSha256: peerFile.sha256 } : {}),\n ...(baseSha256 === undefined ? {} : { baseSha256 }),\n suppressSide: localRetracted && peerRetracted ? \"both\" : localRetracted ? \"local\" : \"peer\",\n });\n continue;\n }\n if (!peerFile) {\n // Base PRESENCE is what proves a deletion, not equality with whatever the\n // surviving side now holds. If we also edited since the base, this is\n // delete-versus-modify: still a conflict, and pushing it would resurrect\n // a deliberate deletion. Without a base the peer simply never saw the\n // path, and a bootstrap merge must push — both sides hold unique data.\n if (baseSha256 !== undefined) {\n entries.push({\n path,\n namespace,\n action: \"conflict\",\n reason: baseSha256 === localFile.sha256 ? \"peer_deleted\" : \"local_modified_peer_deleted\",\n localSha256: localFile.sha256,\n baseSha256,\n resolution: \"unresolved\",\n });\n continue;\n }\n entries.push({\n path,\n namespace,\n action: \"push\",\n reason: \"local_only\",\n localSha256: localFile.sha256,\n });\n continue;\n }\n if (peerFile.sha256 === localFile.sha256) {\n entries.push({\n path,\n namespace,\n action: \"identical\",\n reason: \"same_content\",\n localSha256: localFile.sha256,\n peerSha256: peerFile.sha256,\n ...(baseSha256 === undefined ? {} : { baseSha256 }),\n });\n continue;\n }\n // A base that matches one side turns a \"conflict\" into an ordinary\n // one-sided change: that side is the only one that moved since agreement.\n if (baseSha256 !== undefined && baseSha256 === localFile.sha256) {\n entries.push({\n path,\n namespace,\n action: \"pull\",\n reason: \"peer_changed\",\n localSha256: localFile.sha256,\n peerSha256: peerFile.sha256,\n baseSha256,\n });\n continue;\n }\n if (baseSha256 !== undefined && baseSha256 === peerFile.sha256) {\n entries.push({\n path,\n namespace,\n action: \"push\",\n reason: \"local_changed\",\n localSha256: localFile.sha256,\n peerSha256: peerFile.sha256,\n baseSha256,\n });\n continue;\n }\n const resolution = resolveConflict(policy, localFile, peerFile);\n entries.push({\n path,\n namespace,\n action: \"conflict\",\n reason: \"both_modified\",\n localSha256: localFile.sha256,\n peerSha256: peerFile.sha256,\n ...(baseSha256 === undefined ? {} : { baseSha256 }),\n resolution,\n ...(resolution === \"supersede-link\" ? newerSideOf(localFile, peerFile) : {}),\n });\n }\n\n for (const [path, peerFile] of peer) {\n assertNoPathAlias(caseFold, path, namespace);\n const baseSha256 = base?.get(path);\n if (tombstoned.has(peerFile.sha256) || peerTombstoned.has(peerFile.sha256)) {\n // Retracted here on purpose, and the peer still serves it. Pulling it\n // back would undo the retraction; calling it `identical` would be worse,\n // because a converged plan lets transport skip everything and the peer\n // keeps serving the retracted fact forever. It is work: propagate the\n // tombstone.\n entries.push({\n path,\n namespace,\n action: \"suppress\",\n reason: \"tombstoned\",\n peerSha256: peerFile.sha256,\n ...(baseSha256 === undefined ? {} : { baseSha256 }),\n suppressSide: \"peer\",\n });\n continue;\n }\n if (baseSha256 !== undefined) {\n entries.push({\n path,\n namespace,\n action: \"conflict\",\n reason: baseSha256 === peerFile.sha256 ? \"local_deleted\" : \"local_deleted_peer_modified\",\n peerSha256: peerFile.sha256,\n baseSha256,\n resolution: \"unresolved\",\n });\n continue;\n }\n entries.push({\n path,\n namespace,\n action: \"pull\",\n reason: \"peer_only\",\n peerSha256: peerFile.sha256,\n });\n }\n\n return entries.sort(compareEntries);\n}\n\n/** Aggregate entries into the per-namespace convergence report (#2150). */\nexport function summarizeReconcilePlan(entries: readonly ReconcilePlanEntry[]): ReconcileNamespaceReport[] {\n const byNamespace = new Map<string, ReconcileNamespaceReport>();\n for (const entry of entries) {\n let report = byNamespace.get(entry.namespace);\n if (!report) {\n report = { namespace: entry.namespace, pull: 0, push: 0, identical: 0, conflict: 0, suppress: 0, unresolved: 0 };\n byNamespace.set(entry.namespace, report);\n }\n report[entry.action] += 1;\n // A supersede link with no `newerSide` could not be ordered, and the link\n // direction is then an operator decision - so it counts as unresolved even\n // though the policy nominally settled it.\n const needsOperator =\n entry.resolution === \"unresolved\"\n || (entry.resolution === \"supersede-link\" && entry.newerSide === undefined);\n if (entry.action === \"conflict\" && needsOperator) report.unresolved += 1;\n }\n return [...byNamespace.values()].sort((a, b) => (a.namespace === b.namespace ? 0 : a.namespace < b.namespace ? -1 : 1));\n}\n\n/**\n * Plan a full reconciliation across namespaces.\n *\n * `converged` is an affirmative claim that nothing needs to move, so it is\n * derived from the entries rather than tracked alongside them: any action other\n * than `identical` disproves it.\n */\nexport function planReconciliation(\n namespaces: readonly ReconcileNamespaceInput[],\n options: ReconcileOptions = {},\n): ReconcilePlan {\n if (!Array.isArray(namespaces)) {\n throw new ReconcilePlanInputError(\"reconcile: planReconciliation expects an array of namespace inputs\");\n }\n // Validated here too: with an empty array the per-namespace path never runs,\n // and a malformed options envelope would return `converged` instead of\n // raising - the same call failing or succeeding based on list length.\n if (!isPlainObject(options)) {\n throw new ReconcilePlanInputError(\"reconcile: options must be a plain object\");\n }\n assertConflictPolicy(options.conflictPolicy);\n const entries: ReconcilePlanEntry[] = [];\n // Two inputs for one namespace are planned independently, so the same\n // (namespace, path) can draw contradictory actions - and because those\n // entries also sort equal, batch order would decide which revision survives.\n const seenNamespaces = new Set<string>();\n for (const namespace of namespaces) {\n const name = assertNamespace(namespace?.namespace);\n if (seenNamespaces.has(name)) {\n throw new ReconcilePlanInputError(\n `reconcile: namespace ${name} appears twice; merge its censuses before planning`,\n );\n }\n seenNamespaces.add(name);\n entries.push(...planNamespaceReconciliation(namespace, options));\n }\n entries.sort(compareEntries);\n return {\n entries,\n byNamespace: summarizeReconcilePlan(entries),\n converged: entries.every((entry) => entry.action === \"identical\"),\n };\n}\n"],"mappings":";;;;;;;;;;;AAgLO,IAAM,0BAAN,cAAsC,MAAM;AAAA,EACjD,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAGA,IAAM,iBAAiB;AASvB,SAAS,mBACP,MACA,MACA,WACoB;AACpB,QAAM,OAAO,MAAM;AACnB,MAAI,OAAO,SAAS,YAAY,K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