@remnic/core 9.44.0 → 9.45.0
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 +5 -5
- package/dist/access-admin-ops-surface.js +14 -13
- package/dist/access-authorization-probe.d.ts +5 -5
- package/dist/access-authorization-probe.js +15 -14
- package/dist/access-boundary.d.ts +5 -5
- package/dist/access-boundary.js +14 -13
- package/dist/access-cli.js +37 -36
- package/dist/access-cli.js.map +1 -1
- package/dist/access-extraction-force-flush.d.ts +5 -5
- package/dist/access-extraction-force-flush.js +14 -13
- package/dist/access-http-lcm-compaction.d.ts +5 -5
- package/dist/access-http-lifecycle-flush.d.ts +5 -5
- package/dist/access-http-query.js +14 -13
- package/dist/access-http.d.ts +5 -5
- package/dist/access-http.js +21 -20
- package/dist/access-identity-continuity-surface.d.ts +4 -4
- package/dist/access-identity-continuity-surface.js +14 -13
- package/dist/access-lcm-surface.d.ts +5 -5
- package/dist/access-lcm-surface.js +14 -13
- package/dist/access-mcp.d.ts +5 -5
- package/dist/access-mcp.js +19 -18
- package/dist/access-namespace-preflight.js +14 -13
- package/dist/access-observe-write-surface.d.ts +5 -5
- package/dist/access-observe-write-surface.js +14 -13
- package/dist/access-operations-batch.js +16 -15
- package/dist/access-operations.d.ts +8 -8
- package/dist/access-operations.js +18 -17
- package/dist/access-recall-concurrency.d.ts +5 -5
- package/dist/access-recall-concurrency.js +14 -13
- package/dist/access-recall-response.d.ts +5 -5
- package/dist/access-recall-response.js +14 -13
- package/dist/access-recall-surface.d.ts +5 -5
- package/dist/access-recall-surface.js +14 -13
- package/dist/access-schema.d.ts +84 -84
- package/dist/access-schema.js +3 -3
- package/dist/{access-service-BCZJbX0f.d.ts → access-service-DBo88Dmm.d.ts} +3 -3
- package/dist/access-service-helpers.d.ts +5 -5
- package/dist/access-service.d.ts +5 -5
- package/dist/access-service.js +14 -13
- package/dist/access-surface-catalog.d.ts +5 -5
- package/dist/access-wearables-meetings-surface.d.ts +2 -2
- package/dist/bootstrap.d.ts +4 -4
- package/dist/briefing.d.ts +1 -1
- package/dist/briefing.js +4 -3
- package/dist/buffer.d.ts +1 -1
- package/dist/causal-consolidation.js +5 -4
- package/dist/causal-consolidation.js.map +1 -1
- package/dist/{chunk-OHLNFI6Z.js → chunk-3HKQOFOV.js} +7 -5
- package/dist/{chunk-OHLNFI6Z.js.map → chunk-3HKQOFOV.js.map} +1 -1
- package/dist/{chunk-PJUHQC4T.js → chunk-3HLCRYBV.js} +3 -3
- package/dist/{chunk-N7LPS4Z3.js → chunk-5SM35XZR.js} +2 -2
- package/dist/{chunk-E6JYVPBK.js → chunk-5YGO5VEH.js} +2 -2
- package/dist/{chunk-EUVPB5TA.js → chunk-65V4K4MT.js} +8 -8
- package/dist/{chunk-WX6KOVVK.js → chunk-6OLQJJYE.js} +2 -2
- package/dist/chunk-6UWB5PTR.js +413 -0
- package/dist/chunk-6UWB5PTR.js.map +1 -0
- package/dist/{chunk-G24HJJ67.js → chunk-7JO6RVBI.js} +6 -6
- package/dist/{chunk-WUDWRUGK.js → chunk-7PVFOFPJ.js} +2 -2
- package/dist/{chunk-UUQLB2HJ.js → chunk-C7EI7CA6.js} +2 -2
- package/dist/{chunk-MUKLQDJP.js → chunk-FLBPATMZ.js} +18 -18
- package/dist/{chunk-HGFILS2Q.js → chunk-FVGQ5LIS.js} +2 -2
- package/dist/{chunk-OPVOUBHT.js → chunk-G24XIK6H.js} +2 -2
- package/dist/{chunk-CH2WTP6R.js → chunk-GBJJUPNV.js} +2 -2
- package/dist/{chunk-HXTUA7QM.js → chunk-GOPWZYZH.js} +6 -6
- package/dist/{chunk-WMHO3WLC.js → chunk-GQBZ7EVF.js} +2 -2
- package/dist/{chunk-KQAFEZQX.js → chunk-IPLYGWQF.js} +5 -5
- package/dist/{chunk-OZL7KB6B.js → chunk-J4OKD6QX.js} +2 -2
- package/dist/{chunk-TRBIJS2T.js → chunk-JZ7SSAQ5.js} +3 -3
- package/dist/{chunk-YUOKZ3LJ.js → chunk-K6OTW3TP.js} +2 -2
- package/dist/{chunk-I22U5YYD.js → chunk-QQ3NDJOM.js} +2 -2
- package/dist/{chunk-2FTRRQKZ.js → chunk-RVLJEII5.js} +30 -511
- package/dist/chunk-RVLJEII5.js.map +1 -0
- package/dist/chunk-S5SLVSVY.js +517 -0
- package/dist/chunk-S5SLVSVY.js.map +1 -0
- package/dist/{chunk-7PLHD7EO.js → chunk-SS7YWVPF.js} +2 -2
- package/dist/{chunk-J43XN7N3.js → chunk-U5G66ORD.js} +18 -18
- package/dist/{chunk-EMC5GT4H.js → chunk-VCGPO2VD.js} +4 -4
- package/dist/{chunk-JDDTNK5P.js → chunk-VRYJSKOM.js} +2 -2
- package/dist/{chunk-PLQCPMJA.js → chunk-WC4SPYHX.js} +7 -7
- package/dist/{chunk-IADUAH35.js → chunk-WG2PI44B.js} +2 -2
- package/dist/{chunk-35IC3EVP.js → chunk-XFQRFWVS.js} +2 -2
- package/dist/{chunk-MYFFOPO2.js → chunk-XMZV27S5.js} +2 -2
- package/dist/{chunk-IXFI6E3Q.js → chunk-YQQK7W7T.js} +2 -2
- package/dist/{chunk-3F2LKUMU.js → chunk-ZAB5PG65.js} +2 -2
- package/dist/{chunk-O4BADU6R.js → chunk-ZPJJE7MF.js} +2 -2
- package/dist/{chunk-U5SX74DV.js → chunk-ZS5UZU5M.js} +3 -3
- package/dist/{cli-U30A3jyx.d.ts → cli-DQ4VhjqX.d.ts} +3 -3
- package/dist/cli.d.ts +6 -6
- package/dist/cli.js +31 -30
- package/dist/compounding/engine.d.ts +1 -1
- package/dist/compounding/engine.js +4 -3
- package/dist/connectors/codex-materialize-runner.js +4 -3
- package/dist/connectors/index.js +4 -3
- package/dist/consolidation-provenance-check.d.ts +1 -1
- package/dist/consolidation-undo.d.ts +1 -1
- package/dist/contradiction/index.d.ts +1 -1
- package/dist/convergence-refresh.d.ts +1 -1
- package/dist/convergence-refresh.js +6 -5
- package/dist/corpus-watermark.js +6 -5
- package/dist/entity-retrieval.d.ts +1 -1
- package/dist/entity-retrieval.js +4 -3
- package/dist/explicit-capture.d.ts +4 -4
- package/dist/explicit-capture.js +3 -2
- package/dist/extraction.js +4 -3
- package/dist/index.d.ts +398 -398
- package/dist/index.js +37 -36
- package/dist/maintenance/memory-governance.js +4 -3
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +1 -1
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +4 -3
- package/dist/maintenance/rebuild-memory-projection.d.ts +1 -1
- package/dist/maintenance/rebuild-memory-projection.js +5 -4
- package/dist/{maintenance-DVBLXkFw.d.ts → maintenance-_RV38GlE.d.ts} +1 -1
- package/dist/mcp-memory-inspector-app.d.ts +5 -5
- package/dist/memory-worth-outcomes.d.ts +1 -1
- package/dist/namespaces/migrate.d.ts +1 -1
- package/dist/namespaces/migrate.js +5 -4
- package/dist/namespaces/storage.d.ts +1 -1
- package/dist/namespaces/storage.js +4 -3
- package/dist/operator-doctor-corpus.js +7 -6
- package/dist/operator-toolkit.d.ts +1 -1
- package/dist/operator-toolkit.js +11 -10
- package/dist/orchestration/compression-guideline-coordinator.d.ts +1 -1
- package/dist/orchestration/maintenance.d.ts +2 -2
- package/dist/orchestration/maintenance.js +9 -8
- package/dist/{orchestrator-DUxbhhqO.d.ts → orchestrator-B2ecFpRO.d.ts} +3 -3
- package/dist/orchestrator.d.ts +4 -4
- package/dist/orchestrator.js +37 -36
- package/dist/reconcile/manifest.d.ts +33 -0
- package/dist/reconcile/manifest.js +248 -0
- package/dist/reconcile/manifest.js.map +1 -0
- package/dist/reconcile/plan.d.ts +1 -1
- package/dist/reconcile/plan.js +8 -404
- package/dist/reconcile/plan.js.map +1 -1
- package/dist/schemas.d.ts +76 -76
- package/dist/semantic-consolidation.js +5 -4
- package/dist/semantic-rule-promotion.js +4 -3
- package/dist/semantic-rule-verifier.js +4 -3
- package/dist/{service-CLuMO-pa.d.ts → service-DW06sY3P.d.ts} +1 -1
- package/dist/shared-context/manager.d.ts +8 -8
- package/dist/source-agent-qualifier.js +4 -3
- package/dist/{storage-Blr71GpS.d.ts → storage-qRIQPA6F.d.ts} +12 -0
- package/dist/storage.d.ts +1 -1
- package/dist/storage.js +3 -2
- package/dist/temporal-supersession.d.ts +1 -1
- package/dist/tier-migration.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/verified-recall.js +4 -3
- package/package.json +12 -2
- package/src/reconcile/manifest.test.ts +261 -0
- package/src/reconcile/manifest.ts +278 -0
- package/src/reconcile/plan.ts +1 -0
- package/src/storage/content-hash-index.ts +26 -0
- package/dist/chunk-2FTRRQKZ.js.map +0 -1
- /package/dist/{chunk-PJUHQC4T.js.map → chunk-3HLCRYBV.js.map} +0 -0
- /package/dist/{chunk-N7LPS4Z3.js.map → chunk-5SM35XZR.js.map} +0 -0
- /package/dist/{chunk-E6JYVPBK.js.map → chunk-5YGO5VEH.js.map} +0 -0
- /package/dist/{chunk-EUVPB5TA.js.map → chunk-65V4K4MT.js.map} +0 -0
- /package/dist/{chunk-WX6KOVVK.js.map → chunk-6OLQJJYE.js.map} +0 -0
- /package/dist/{chunk-G24HJJ67.js.map → chunk-7JO6RVBI.js.map} +0 -0
- /package/dist/{chunk-WUDWRUGK.js.map → chunk-7PVFOFPJ.js.map} +0 -0
- /package/dist/{chunk-UUQLB2HJ.js.map → chunk-C7EI7CA6.js.map} +0 -0
- /package/dist/{chunk-MUKLQDJP.js.map → chunk-FLBPATMZ.js.map} +0 -0
- /package/dist/{chunk-HGFILS2Q.js.map → chunk-FVGQ5LIS.js.map} +0 -0
- /package/dist/{chunk-OPVOUBHT.js.map → chunk-G24XIK6H.js.map} +0 -0
- /package/dist/{chunk-CH2WTP6R.js.map → chunk-GBJJUPNV.js.map} +0 -0
- /package/dist/{chunk-HXTUA7QM.js.map → chunk-GOPWZYZH.js.map} +0 -0
- /package/dist/{chunk-WMHO3WLC.js.map → chunk-GQBZ7EVF.js.map} +0 -0
- /package/dist/{chunk-KQAFEZQX.js.map → chunk-IPLYGWQF.js.map} +0 -0
- /package/dist/{chunk-OZL7KB6B.js.map → chunk-J4OKD6QX.js.map} +0 -0
- /package/dist/{chunk-TRBIJS2T.js.map → chunk-JZ7SSAQ5.js.map} +0 -0
- /package/dist/{chunk-YUOKZ3LJ.js.map → chunk-K6OTW3TP.js.map} +0 -0
- /package/dist/{chunk-I22U5YYD.js.map → chunk-QQ3NDJOM.js.map} +0 -0
- /package/dist/{chunk-7PLHD7EO.js.map → chunk-SS7YWVPF.js.map} +0 -0
- /package/dist/{chunk-J43XN7N3.js.map → chunk-U5G66ORD.js.map} +0 -0
- /package/dist/{chunk-EMC5GT4H.js.map → chunk-VCGPO2VD.js.map} +0 -0
- /package/dist/{chunk-JDDTNK5P.js.map → chunk-VRYJSKOM.js.map} +0 -0
- /package/dist/{chunk-PLQCPMJA.js.map → chunk-WC4SPYHX.js.map} +0 -0
- /package/dist/{chunk-IADUAH35.js.map → chunk-WG2PI44B.js.map} +0 -0
- /package/dist/{chunk-35IC3EVP.js.map → chunk-XFQRFWVS.js.map} +0 -0
- /package/dist/{chunk-MYFFOPO2.js.map → chunk-XMZV27S5.js.map} +0 -0
- /package/dist/{chunk-IXFI6E3Q.js.map → chunk-YQQK7W7T.js.map} +0 -0
- /package/dist/{chunk-3F2LKUMU.js.map → chunk-ZAB5PG65.js.map} +0 -0
- /package/dist/{chunk-O4BADU6R.js.map → chunk-ZPJJE7MF.js.map} +0 -0
- /package/dist/{chunk-U5SX74DV.js.map → chunk-ZS5UZU5M.js.map} +0 -0
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "./chunk-T4WDJPEZ.js";
|
|
13
13
|
import {
|
|
14
14
|
validateRequest
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-ZAB5PG65.js";
|
|
16
16
|
import {
|
|
17
17
|
MCP_ADMIN_OPS_TOOLS,
|
|
18
18
|
MCP_GIT_CONTEXT_SCHEMA_PROPS_IGNORED
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
} from "./chunk-IKKWIPYN.js";
|
|
23
23
|
import {
|
|
24
24
|
getOperation
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-65V4K4MT.js";
|
|
26
26
|
import {
|
|
27
27
|
assertOperationAllowed,
|
|
28
28
|
capabilityAllowsOp,
|
|
@@ -3755,4 +3755,4 @@ export {
|
|
|
3755
3755
|
MCP_SUPPORTED_PROTOCOL_VERSIONS,
|
|
3756
3756
|
EngramMcpServer
|
|
3757
3757
|
};
|
|
3758
|
-
//# sourceMappingURL=chunk-
|
|
3758
|
+
//# sourceMappingURL=chunk-3HLCRYBV.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
buildExplicitCaptureDedupKey,
|
|
3
3
|
isTombstoneBlockedCaptureWriteLockBusy,
|
|
4
4
|
normalizeExplicitCaptureContent
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-RVLJEII5.js";
|
|
6
6
|
import {
|
|
7
7
|
TAG_LIMITS,
|
|
8
8
|
composeMemoryEnvelope
|
|
@@ -783,4 +783,4 @@ export {
|
|
|
783
783
|
shouldProcessInlineExplicitCapture,
|
|
784
784
|
InlineExplicitCaptureProcessor
|
|
785
785
|
};
|
|
786
|
-
//# sourceMappingURL=chunk-
|
|
786
|
+
//# sourceMappingURL=chunk-5SM35XZR.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
OPERATION_NAMES,
|
|
3
3
|
getOperation,
|
|
4
4
|
operationRequiresAuthorizedNamespace
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-65V4K4MT.js";
|
|
6
6
|
import {
|
|
7
7
|
assertOperationAuthorizationAllowed
|
|
8
8
|
} from "./chunk-MZWSOLMT.js";
|
|
@@ -49,4 +49,4 @@ export {
|
|
|
49
49
|
probeOperationAuthorization,
|
|
50
50
|
authorizationProbeNamespaces
|
|
51
51
|
};
|
|
52
|
-
//# sourceMappingURL=chunk-
|
|
52
|
+
//# sourceMappingURL=chunk-5YGO5VEH.js.map
|
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
} from "./chunk-R4Q7CQGZ.js";
|
|
46
46
|
import {
|
|
47
47
|
readAggregateExtractionWatermark
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-GQBZ7EVF.js";
|
|
49
49
|
import {
|
|
50
50
|
ReplicaDivergenceMonitor
|
|
51
51
|
} from "./chunk-XOQSEF7X.js";
|
|
@@ -89,7 +89,7 @@ import {
|
|
|
89
89
|
persistExplicitCapture,
|
|
90
90
|
queueExplicitCaptureForReview,
|
|
91
91
|
validateExplicitCaptureInput
|
|
92
|
-
} from "./chunk-
|
|
92
|
+
} from "./chunk-5SM35XZR.js";
|
|
93
93
|
import {
|
|
94
94
|
lcmEvidenceIdentity
|
|
95
95
|
} from "./chunk-C37ZRXX7.js";
|
|
@@ -100,11 +100,11 @@ import {
|
|
|
100
100
|
listMemoryGovernanceRuns,
|
|
101
101
|
readMemoryGovernanceRunArtifact,
|
|
102
102
|
runMemoryGovernance
|
|
103
|
-
} from "./chunk-
|
|
103
|
+
} from "./chunk-XMZV27S5.js";
|
|
104
104
|
import {
|
|
105
105
|
CorpusWatermarkCache,
|
|
106
106
|
computeServiceCorpusCensus
|
|
107
|
-
} from "./chunk-
|
|
107
|
+
} from "./chunk-7PVFOFPJ.js";
|
|
108
108
|
import {
|
|
109
109
|
namespaceCollectionName
|
|
110
110
|
} from "./chunk-HLPD7B7P.js";
|
|
@@ -139,13 +139,13 @@ import {
|
|
|
139
139
|
enqueuePassiveCorrectionNotification,
|
|
140
140
|
parseBriefingFocus,
|
|
141
141
|
parseBriefingWindow
|
|
142
|
-
} from "./chunk-
|
|
142
|
+
} from "./chunk-XFQRFWVS.js";
|
|
143
143
|
import {
|
|
144
144
|
parseEntityFile,
|
|
145
145
|
qmdCollectionPathParts,
|
|
146
146
|
qmdResultPathCandidates,
|
|
147
147
|
selfDeps
|
|
148
|
-
} from "./chunk-
|
|
148
|
+
} from "./chunk-3HKQOFOV.js";
|
|
149
149
|
import {
|
|
150
150
|
DEFAULT_RECALL_DISCLOSURE,
|
|
151
151
|
isRecallDisclosure
|
|
@@ -234,7 +234,7 @@ import {
|
|
|
234
234
|
} from "./chunk-N5Z4EVOR.js";
|
|
235
235
|
import {
|
|
236
236
|
exportCapsule
|
|
237
|
-
} from "./chunk-
|
|
237
|
+
} from "./chunk-IPLYGWQF.js";
|
|
238
238
|
import {
|
|
239
239
|
evaluateActionConfidence
|
|
240
240
|
} from "./chunk-Z2YFLXHU.js";
|
|
@@ -13362,4 +13362,4 @@ export {
|
|
|
13362
13362
|
EngramAccessService,
|
|
13363
13363
|
AccessAdminOpsSurface
|
|
13364
13364
|
};
|
|
13365
|
-
//# sourceMappingURL=chunk-
|
|
13365
|
+
//# sourceMappingURL=chunk-65V4K4MT.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
resolveDefaultNamespaceRoot,
|
|
6
6
|
resolveNamespaceStorageRoot
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-VRYJSKOM.js";
|
|
8
8
|
import {
|
|
9
9
|
namespaceIdentityFromToken,
|
|
10
10
|
namespaceIdentityToken,
|
|
@@ -2204,4 +2204,4 @@ export {
|
|
|
2204
2204
|
runNamespaceMaintenancePlan,
|
|
2205
2205
|
runNamespaceMaintenanceBatchPlan
|
|
2206
2206
|
};
|
|
2207
|
-
//# sourceMappingURL=chunk-
|
|
2207
|
+
//# sourceMappingURL=chunk-6OLQJJYE.js.map
|
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeNamespaceIdentity
|
|
3
|
+
} from "./chunk-EGGE52UU.js";
|
|
4
|
+
import {
|
|
5
|
+
OFFLINE_SYNC_MAX_MTIME_MS
|
|
6
|
+
} from "./chunk-7XC2HX75.js";
|
|
7
|
+
import {
|
|
8
|
+
validateArchiveRelativePath
|
|
9
|
+
} from "./chunk-GCGJW34D.js";
|
|
10
|
+
|
|
11
|
+
// src/reconcile/plan.ts
|
|
12
|
+
var ReconcilePlanInputError = class extends Error {
|
|
13
|
+
constructor(message) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = "ReconcilePlanInputError";
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
var SHA256_PATTERN = /^[a-f0-9]{64}$/i;
|
|
19
|
+
function assertCensusRecord(file, side, namespace) {
|
|
20
|
+
const path = file?.path;
|
|
21
|
+
if (typeof path !== "string" || path.length === 0) {
|
|
22
|
+
throw new ReconcilePlanInputError(
|
|
23
|
+
`reconcile: ${side} census for namespace ${namespace} contains a record with no path`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
validateArchiveRelativePath(path, `reconcile: ${side} census for namespace ${namespace}`);
|
|
28
|
+
} catch (err) {
|
|
29
|
+
throw new ReconcilePlanInputError(err instanceof Error ? err.message : String(err));
|
|
30
|
+
}
|
|
31
|
+
assertPortablePathSegments(path, side, namespace);
|
|
32
|
+
return {
|
|
33
|
+
...file,
|
|
34
|
+
path,
|
|
35
|
+
sha256: assertDigest(file?.sha256, `${side} census for namespace ${namespace} entry ${path}`),
|
|
36
|
+
...file?.mtimeMs === void 0 ? {} : { mtimeMs: assertMtimeMs(file.mtimeMs, `${side} census for namespace ${namespace} entry ${path}`) }
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function assertMtimeMs(value, context) {
|
|
40
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < 0 || value > OFFLINE_SYNC_MAX_MTIME_MS) {
|
|
41
|
+
throw new ReconcilePlanInputError(
|
|
42
|
+
`reconcile: ${context} has an out-of-range mtimeMs; expected a finite value between 0 and ${OFFLINE_SYNC_MAX_MTIME_MS}`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
function assertDigest(value, context) {
|
|
48
|
+
if (typeof value !== "string" || !SHA256_PATTERN.test(value)) {
|
|
49
|
+
throw new ReconcilePlanInputError(
|
|
50
|
+
`reconcile: ${context} must carry a 64-character sha256 hex digest`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
return value.toLowerCase();
|
|
54
|
+
}
|
|
55
|
+
function isPlainObject(value) {
|
|
56
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
|
|
57
|
+
const proto = Object.getPrototypeOf(value);
|
|
58
|
+
return proto === Object.prototype || proto === null;
|
|
59
|
+
}
|
|
60
|
+
function assertNamespace(namespace) {
|
|
61
|
+
if (typeof namespace !== "string" || namespace.length === 0) {
|
|
62
|
+
throw new ReconcilePlanInputError("reconcile: every namespace input needs a non-empty namespace");
|
|
63
|
+
}
|
|
64
|
+
if (LONE_SURROGATE.test(namespace)) {
|
|
65
|
+
throw new ReconcilePlanInputError(
|
|
66
|
+
"reconcile: namespace contains an unpaired surrogate; it would collide with another namespace on disk"
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
if (normalizeNamespaceIdentity(namespace) !== namespace) {
|
|
70
|
+
throw new ReconcilePlanInputError(
|
|
71
|
+
`reconcile: namespace ${JSON.stringify(namespace)} is not canonical; pass ${JSON.stringify(normalizeNamespaceIdentity(namespace))}`
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
return namespace;
|
|
75
|
+
}
|
|
76
|
+
function assertIterable(value, side, namespace) {
|
|
77
|
+
if (value === null || typeof value !== "object" || typeof value[Symbol.iterator] !== "function") {
|
|
78
|
+
throw new ReconcilePlanInputError(`reconcile: ${side} census for namespace ${namespace} must be iterable`);
|
|
79
|
+
}
|
|
80
|
+
return value;
|
|
81
|
+
}
|
|
82
|
+
var WIN32_INVALID_CHARS = /[<>:"|?*\u0000-\u001f]/;
|
|
83
|
+
var LONE_SURROGATE = /[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/;
|
|
84
|
+
var WIN32_RESERVED_NAMES = /^(con|prn|aux|nul|(com|lpt)[1-9\u00b9\u00b2\u00b3])$/i;
|
|
85
|
+
function assertPortablePathSegments(path, side, namespace) {
|
|
86
|
+
for (const segment of path.split("/")) {
|
|
87
|
+
if (segment.length === 0) continue;
|
|
88
|
+
if (segment.endsWith(".") || segment.endsWith(" ")) {
|
|
89
|
+
throw new ReconcilePlanInputError(
|
|
90
|
+
`reconcile: ${side} census for namespace ${namespace} path ${path} has a segment ending in a dot or space; Windows strips those and would alias it onto another file`
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
if (LONE_SURROGATE.test(segment)) {
|
|
94
|
+
throw new ReconcilePlanInputError(
|
|
95
|
+
`reconcile: ${side} census for namespace ${namespace} path ${path} contains an unpaired surrogate`
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
if (WIN32_INVALID_CHARS.test(segment)) {
|
|
99
|
+
throw new ReconcilePlanInputError(
|
|
100
|
+
`reconcile: ${side} census for namespace ${namespace} path ${path} contains a character Windows cannot store`
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
if (WIN32_RESERVED_NAMES.test(segment.split(".")[0] ?? "")) {
|
|
104
|
+
throw new ReconcilePlanInputError(
|
|
105
|
+
`reconcile: ${side} census for namespace ${namespace} path ${path} uses a reserved Windows device name`
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function assertNoPathAlias(seen, path, namespace) {
|
|
111
|
+
const folded = path.normalize("NFC").toUpperCase().toLowerCase().replace(/\u00df/g, "ss");
|
|
112
|
+
const existing = seen.get(folded);
|
|
113
|
+
if (existing !== void 0 && existing !== path) {
|
|
114
|
+
throw new ReconcilePlanInputError(
|
|
115
|
+
`reconcile: namespace ${namespace} has aliasing paths (${existing}, ${path}); they resolve to one file on a case-insensitive or Unicode-normalizing peer`
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
seen.set(folded, path);
|
|
119
|
+
}
|
|
120
|
+
function rejectConflictingDuplicate(existing, incoming, path, side, namespace) {
|
|
121
|
+
if (!existing) return false;
|
|
122
|
+
if (existing.sha256 !== incoming.sha256) {
|
|
123
|
+
throw new ReconcilePlanInputError(
|
|
124
|
+
`reconcile: ${side} census for namespace ${namespace} lists ${path} twice with different digests`
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
if (existing.mtimeMs !== incoming.mtimeMs) {
|
|
128
|
+
throw new ReconcilePlanInputError(
|
|
129
|
+
`reconcile: ${side} census for namespace ${namespace} lists ${path} twice with different mtimeMs`
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
function indexByPath(files, side, namespace) {
|
|
135
|
+
const index = /* @__PURE__ */ new Map();
|
|
136
|
+
for (const raw of files) {
|
|
137
|
+
const file = assertCensusRecord(raw, side, namespace);
|
|
138
|
+
if (rejectConflictingDuplicate(index.get(file.path), file, file.path, side, namespace)) continue;
|
|
139
|
+
index.set(file.path, file);
|
|
140
|
+
}
|
|
141
|
+
return index;
|
|
142
|
+
}
|
|
143
|
+
function parseTombstonedDigests(value, namespace, field = "tombstonedFileSha256") {
|
|
144
|
+
if (value === void 0) return /* @__PURE__ */ new Set();
|
|
145
|
+
if (typeof value === "string") {
|
|
146
|
+
throw new ReconcilePlanInputError(
|
|
147
|
+
`reconcile: ${field} for namespace ${namespace} must be a collection of digests, not a single string`
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
if (value === null || typeof value !== "object" || typeof value[Symbol.iterator] !== "function") {
|
|
151
|
+
throw new ReconcilePlanInputError(
|
|
152
|
+
`reconcile: ${field} for namespace ${namespace} must be an iterable collection of digests`
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
const digests = /* @__PURE__ */ new Set();
|
|
156
|
+
for (const entry of value) {
|
|
157
|
+
digests.add(assertDigest(entry, `${field} for namespace ${namespace}`));
|
|
158
|
+
}
|
|
159
|
+
return digests;
|
|
160
|
+
}
|
|
161
|
+
function indexDigestsByPath(files, side, namespace) {
|
|
162
|
+
const index = /* @__PURE__ */ new Map();
|
|
163
|
+
for (const raw of files) {
|
|
164
|
+
const file = assertCensusRecord(raw, side, namespace);
|
|
165
|
+
const existing = index.get(file.path);
|
|
166
|
+
if (existing !== void 0) {
|
|
167
|
+
if (existing !== file.sha256) {
|
|
168
|
+
throw new ReconcilePlanInputError(
|
|
169
|
+
`reconcile: ${side} census for namespace ${namespace} lists ${file.path} twice with different digests`
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
index.set(file.path, file.sha256);
|
|
175
|
+
}
|
|
176
|
+
return index;
|
|
177
|
+
}
|
|
178
|
+
var RECONCILE_CONFLICT_POLICIES = ["manual", "newest-wins", "keep-both"];
|
|
179
|
+
function assertConflictPolicy(value) {
|
|
180
|
+
if (value === void 0) return "manual";
|
|
181
|
+
if (!RECONCILE_CONFLICT_POLICIES.includes(value)) {
|
|
182
|
+
throw new ReconcilePlanInputError(
|
|
183
|
+
`reconcile: unknown conflictPolicy ${JSON.stringify(value)}; expected one of ${RECONCILE_CONFLICT_POLICIES.join(", ")}`
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
return value;
|
|
187
|
+
}
|
|
188
|
+
function compareEntries(a, b) {
|
|
189
|
+
if (a.namespace !== b.namespace) return a.namespace < b.namespace ? -1 : 1;
|
|
190
|
+
if (a.path !== b.path) return a.path < b.path ? -1 : 1;
|
|
191
|
+
return 0;
|
|
192
|
+
}
|
|
193
|
+
function newerSideOf(local, peer) {
|
|
194
|
+
const localMs = local.mtimeMs;
|
|
195
|
+
const peerMs = peer.mtimeMs;
|
|
196
|
+
if (typeof localMs !== "number" || typeof peerMs !== "number" || localMs === peerMs) return {};
|
|
197
|
+
return { newerSide: localMs > peerMs ? "local" : "peer" };
|
|
198
|
+
}
|
|
199
|
+
function resolveConflict(policy, local, peer) {
|
|
200
|
+
if (policy === "keep-both") return "supersede-link";
|
|
201
|
+
if (policy !== "newest-wins") return "unresolved";
|
|
202
|
+
const localMs = typeof local.mtimeMs === "number" && Number.isFinite(local.mtimeMs) ? local.mtimeMs : null;
|
|
203
|
+
const peerMs = typeof peer.mtimeMs === "number" && Number.isFinite(peer.mtimeMs) ? peer.mtimeMs : null;
|
|
204
|
+
if (localMs === null || peerMs === null) return "supersede-link";
|
|
205
|
+
if (localMs === peerMs) return "supersede-link";
|
|
206
|
+
return localMs > peerMs ? "local-wins" : "peer-wins";
|
|
207
|
+
}
|
|
208
|
+
function planNamespaceReconciliation(input, options = {}) {
|
|
209
|
+
if (!isPlainObject(input)) {
|
|
210
|
+
throw new ReconcilePlanInputError("reconcile: namespace input must be a plain object");
|
|
211
|
+
}
|
|
212
|
+
if (!isPlainObject(options)) {
|
|
213
|
+
throw new ReconcilePlanInputError("reconcile: options must be a plain object");
|
|
214
|
+
}
|
|
215
|
+
const namespace = assertNamespace(input.namespace);
|
|
216
|
+
const policy = assertConflictPolicy(options.conflictPolicy);
|
|
217
|
+
const localCensus = assertIterable(input.local, "local", namespace);
|
|
218
|
+
const caseFold = /* @__PURE__ */ new Map();
|
|
219
|
+
const peer = indexByPath(assertIterable(input.peer, "peer", namespace), "peer", namespace);
|
|
220
|
+
const base = input.base === void 0 ? null : indexDigestsByPath(assertIterable(input.base, "base", namespace), "base", namespace);
|
|
221
|
+
const tombstoned = parseTombstonedDigests(input.tombstonedFileSha256, namespace);
|
|
222
|
+
const peerTombstoned = parseTombstonedDigests(
|
|
223
|
+
input.peerTombstonedFileSha256,
|
|
224
|
+
namespace,
|
|
225
|
+
"peerTombstonedFileSha256"
|
|
226
|
+
);
|
|
227
|
+
const entries = [];
|
|
228
|
+
if (base) for (const basePath of base.keys()) assertNoPathAlias(caseFold, basePath, namespace);
|
|
229
|
+
const seenLocal = /* @__PURE__ */ new Map();
|
|
230
|
+
for (const rawLocal of localCensus) {
|
|
231
|
+
const localFile = assertCensusRecord(rawLocal, "local", namespace);
|
|
232
|
+
const path = localFile.path;
|
|
233
|
+
assertNoPathAlias(caseFold, path, namespace);
|
|
234
|
+
const seen = seenLocal.get(path);
|
|
235
|
+
if (seen !== void 0) {
|
|
236
|
+
if (rejectConflictingDuplicate(seen, localFile, path, "local", namespace)) continue;
|
|
237
|
+
}
|
|
238
|
+
seenLocal.set(path, { sha256: localFile.sha256, mtimeMs: localFile.mtimeMs });
|
|
239
|
+
const peerFile = peer.get(path);
|
|
240
|
+
peer.delete(path);
|
|
241
|
+
const baseSha256 = base?.get(path);
|
|
242
|
+
const localRetracted = tombstoned.has(localFile.sha256) || peerTombstoned.has(localFile.sha256);
|
|
243
|
+
const peerRetracted = peerFile !== void 0 && (tombstoned.has(peerFile.sha256) || peerTombstoned.has(peerFile.sha256));
|
|
244
|
+
if (localRetracted || peerRetracted) {
|
|
245
|
+
entries.push({
|
|
246
|
+
path,
|
|
247
|
+
namespace,
|
|
248
|
+
action: "suppress",
|
|
249
|
+
reason: "tombstoned",
|
|
250
|
+
localSha256: localFile.sha256,
|
|
251
|
+
...peerFile ? { peerSha256: peerFile.sha256 } : {},
|
|
252
|
+
...baseSha256 === void 0 ? {} : { baseSha256 },
|
|
253
|
+
suppressSide: localRetracted && peerRetracted ? "both" : localRetracted ? "local" : "peer"
|
|
254
|
+
});
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
if (!peerFile) {
|
|
258
|
+
if (baseSha256 !== void 0) {
|
|
259
|
+
entries.push({
|
|
260
|
+
path,
|
|
261
|
+
namespace,
|
|
262
|
+
action: "conflict",
|
|
263
|
+
reason: baseSha256 === localFile.sha256 ? "peer_deleted" : "local_modified_peer_deleted",
|
|
264
|
+
localSha256: localFile.sha256,
|
|
265
|
+
baseSha256,
|
|
266
|
+
resolution: "unresolved"
|
|
267
|
+
});
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
entries.push({
|
|
271
|
+
path,
|
|
272
|
+
namespace,
|
|
273
|
+
action: "push",
|
|
274
|
+
reason: "local_only",
|
|
275
|
+
localSha256: localFile.sha256
|
|
276
|
+
});
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
if (peerFile.sha256 === localFile.sha256) {
|
|
280
|
+
entries.push({
|
|
281
|
+
path,
|
|
282
|
+
namespace,
|
|
283
|
+
action: "identical",
|
|
284
|
+
reason: "same_content",
|
|
285
|
+
localSha256: localFile.sha256,
|
|
286
|
+
peerSha256: peerFile.sha256,
|
|
287
|
+
...baseSha256 === void 0 ? {} : { baseSha256 }
|
|
288
|
+
});
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
if (baseSha256 !== void 0 && baseSha256 === localFile.sha256) {
|
|
292
|
+
entries.push({
|
|
293
|
+
path,
|
|
294
|
+
namespace,
|
|
295
|
+
action: "pull",
|
|
296
|
+
reason: "peer_changed",
|
|
297
|
+
localSha256: localFile.sha256,
|
|
298
|
+
peerSha256: peerFile.sha256,
|
|
299
|
+
baseSha256
|
|
300
|
+
});
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
if (baseSha256 !== void 0 && baseSha256 === peerFile.sha256) {
|
|
304
|
+
entries.push({
|
|
305
|
+
path,
|
|
306
|
+
namespace,
|
|
307
|
+
action: "push",
|
|
308
|
+
reason: "local_changed",
|
|
309
|
+
localSha256: localFile.sha256,
|
|
310
|
+
peerSha256: peerFile.sha256,
|
|
311
|
+
baseSha256
|
|
312
|
+
});
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
const resolution = resolveConflict(policy, localFile, peerFile);
|
|
316
|
+
entries.push({
|
|
317
|
+
path,
|
|
318
|
+
namespace,
|
|
319
|
+
action: "conflict",
|
|
320
|
+
reason: "both_modified",
|
|
321
|
+
localSha256: localFile.sha256,
|
|
322
|
+
peerSha256: peerFile.sha256,
|
|
323
|
+
...baseSha256 === void 0 ? {} : { baseSha256 },
|
|
324
|
+
resolution,
|
|
325
|
+
...resolution === "supersede-link" ? newerSideOf(localFile, peerFile) : {}
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
for (const [path, peerFile] of peer) {
|
|
329
|
+
assertNoPathAlias(caseFold, path, namespace);
|
|
330
|
+
const baseSha256 = base?.get(path);
|
|
331
|
+
if (tombstoned.has(peerFile.sha256) || peerTombstoned.has(peerFile.sha256)) {
|
|
332
|
+
entries.push({
|
|
333
|
+
path,
|
|
334
|
+
namespace,
|
|
335
|
+
action: "suppress",
|
|
336
|
+
reason: "tombstoned",
|
|
337
|
+
peerSha256: peerFile.sha256,
|
|
338
|
+
...baseSha256 === void 0 ? {} : { baseSha256 },
|
|
339
|
+
suppressSide: "peer"
|
|
340
|
+
});
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
if (baseSha256 !== void 0) {
|
|
344
|
+
entries.push({
|
|
345
|
+
path,
|
|
346
|
+
namespace,
|
|
347
|
+
action: "conflict",
|
|
348
|
+
reason: baseSha256 === peerFile.sha256 ? "local_deleted" : "local_deleted_peer_modified",
|
|
349
|
+
peerSha256: peerFile.sha256,
|
|
350
|
+
baseSha256,
|
|
351
|
+
resolution: "unresolved"
|
|
352
|
+
});
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
entries.push({
|
|
356
|
+
path,
|
|
357
|
+
namespace,
|
|
358
|
+
action: "pull",
|
|
359
|
+
reason: "peer_only",
|
|
360
|
+
peerSha256: peerFile.sha256
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
return entries.sort(compareEntries);
|
|
364
|
+
}
|
|
365
|
+
function summarizeReconcilePlan(entries) {
|
|
366
|
+
const byNamespace = /* @__PURE__ */ new Map();
|
|
367
|
+
for (const entry of entries) {
|
|
368
|
+
let report = byNamespace.get(entry.namespace);
|
|
369
|
+
if (!report) {
|
|
370
|
+
report = { namespace: entry.namespace, pull: 0, push: 0, identical: 0, conflict: 0, suppress: 0, unresolved: 0 };
|
|
371
|
+
byNamespace.set(entry.namespace, report);
|
|
372
|
+
}
|
|
373
|
+
report[entry.action] += 1;
|
|
374
|
+
const needsOperator = entry.resolution === "unresolved" || entry.resolution === "supersede-link" && entry.newerSide === void 0;
|
|
375
|
+
if (entry.action === "conflict" && needsOperator) report.unresolved += 1;
|
|
376
|
+
}
|
|
377
|
+
return [...byNamespace.values()].sort((a, b) => a.namespace === b.namespace ? 0 : a.namespace < b.namespace ? -1 : 1);
|
|
378
|
+
}
|
|
379
|
+
function planReconciliation(namespaces, options = {}) {
|
|
380
|
+
if (!Array.isArray(namespaces)) {
|
|
381
|
+
throw new ReconcilePlanInputError("reconcile: planReconciliation expects an array of namespace inputs");
|
|
382
|
+
}
|
|
383
|
+
if (!isPlainObject(options)) {
|
|
384
|
+
throw new ReconcilePlanInputError("reconcile: options must be a plain object");
|
|
385
|
+
}
|
|
386
|
+
assertConflictPolicy(options.conflictPolicy);
|
|
387
|
+
const entries = [];
|
|
388
|
+
const seenNamespaces = /* @__PURE__ */ new Set();
|
|
389
|
+
for (const namespace of namespaces) {
|
|
390
|
+
const name = assertNamespace(namespace?.namespace);
|
|
391
|
+
if (seenNamespaces.has(name)) {
|
|
392
|
+
throw new ReconcilePlanInputError(
|
|
393
|
+
`reconcile: namespace ${name} appears twice; merge its censuses before planning`
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
seenNamespaces.add(name);
|
|
397
|
+
entries.push(...planNamespaceReconciliation(namespace, options));
|
|
398
|
+
}
|
|
399
|
+
entries.sort(compareEntries);
|
|
400
|
+
return {
|
|
401
|
+
entries,
|
|
402
|
+
byNamespace: summarizeReconcilePlan(entries),
|
|
403
|
+
converged: entries.every((entry) => entry.action === "identical")
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
export {
|
|
408
|
+
ReconcilePlanInputError,
|
|
409
|
+
planNamespaceReconciliation,
|
|
410
|
+
summarizeReconcilePlan,
|
|
411
|
+
planReconciliation
|
|
412
|
+
};
|
|
413
|
+
//# sourceMappingURL=chunk-6UWB5PTR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,KAAK,WAAW,GAAG;AACjD,UAAM,IAAI;AAAA,MACR,cAAc,IAAI,yBAAyB,SAAS;AAAA,IACtD;AAAA,EACF;AAIA,MAAI;AACF,gCAA4B,MAAM,cAAc,IAAI,yBAAyB,SAAS,EAAE;AAAA,EAC1F,SAAS,KAAK;AACZ,UAAM,IAAI,wBAAwB,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA,EACpF;AACA,6BAA2B,MAAM,MAAM,SAAS;AAChD,SA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