mossbear 0.1.0-alpha.78 → 0.1.0-alpha.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/commands/artifacts/remote.d.ts.map +1 -1
  2. package/dist/commands/artifacts/remote.js +0 -1
  3. package/dist/commands/artifacts/remote.js.map +1 -1
  4. package/dist/commands/docs/index.d.ts +3 -2
  5. package/dist/commands/docs/index.d.ts.map +1 -1
  6. package/dist/commands/docs/index.js +4 -2
  7. package/dist/commands/docs/index.js.map +1 -1
  8. package/dist/commands/docs/rekey-preview.d.ts +15 -0
  9. package/dist/commands/docs/rekey-preview.d.ts.map +1 -0
  10. package/dist/commands/docs/rekey-preview.js +70 -0
  11. package/dist/commands/docs/rekey-preview.js.map +1 -0
  12. package/dist/commands/pull.d.ts.map +1 -1
  13. package/dist/commands/pull.js +23 -0
  14. package/dist/commands/pull.js.map +1 -1
  15. package/dist/docs/global-delivery.d.ts +1 -10
  16. package/dist/docs/global-delivery.d.ts.map +1 -1
  17. package/dist/docs/global-delivery.js +2 -13
  18. package/dist/docs/global-delivery.js.map +1 -1
  19. package/dist/docs/global-namespace.d.ts +56 -0
  20. package/dist/docs/global-namespace.d.ts.map +1 -1
  21. package/dist/docs/global-namespace.js +97 -1
  22. package/dist/docs/global-namespace.js.map +1 -1
  23. package/dist/docs/rekey-preview.d.ts +51 -0
  24. package/dist/docs/rekey-preview.d.ts.map +1 -0
  25. package/dist/docs/rekey-preview.js +203 -0
  26. package/dist/docs/rekey-preview.js.map +1 -0
  27. package/dist/docs/rekey.d.ts +169 -0
  28. package/dist/docs/rekey.d.ts.map +1 -0
  29. package/dist/docs/rekey.js +321 -0
  30. package/dist/docs/rekey.js.map +1 -0
  31. package/dist/docs/sidecar.d.ts.map +1 -1
  32. package/dist/docs/sidecar.js +13 -8
  33. package/dist/docs/sidecar.js.map +1 -1
  34. package/dist/docs/sync-docs.d.ts +20 -1
  35. package/dist/docs/sync-docs.d.ts.map +1 -1
  36. package/dist/docs/sync-docs.js +102 -0
  37. package/dist/docs/sync-docs.js.map +1 -1
  38. package/dist/lifecycle/operations.d.ts.map +1 -1
  39. package/dist/lifecycle/operations.js +10 -0
  40. package/dist/lifecycle/operations.js.map +1 -1
  41. package/dist/mcp/client.d.ts +2 -7
  42. package/dist/mcp/client.d.ts.map +1 -1
  43. package/dist/mcp/client.js +2 -2
  44. package/dist/mcp/client.js.map +1 -1
  45. package/dist/mcp/server.d.ts.map +1 -1
  46. package/dist/mcp/server.js +0 -4
  47. package/dist/mcp/server.js.map +1 -1
  48. package/package.json +4 -4
@@ -0,0 +1,169 @@
1
+ /**
2
+ * Re-keying committed placement records when a guide's id changes.
3
+ *
4
+ * A placement record names its item by id (`sidecar.ts` → `PlacementRecord`). A
5
+ * guide used to carry two ids, its own and its body file's, and the pull
6
+ * returned the first. The server is moving to one id per guide, the body file's,
7
+ * so after that change a pull returns an id no committed record names. Without
8
+ * this step every guide in every repo would read as gone (its old record
9
+ * retired) and new (materialized again), and a repo that git tracks would get a
10
+ * second copy beside the first.
11
+ *
12
+ * **No id map exists, here or on the server.** A record is matched to its guide
13
+ * by what both still agree on: the bundle and the path. A record whose id is
14
+ * absent from the pull is re-keyed when exactly one pulled guide in its bundle
15
+ * sits at the record's path, declared or alias. A record that matches none, or
16
+ * more than one, is left exactly as it is, and the sync then treats it as any
17
+ * record whose guide has left the pull: it stops tracking it (an unedited file
18
+ * in a bundle folder is pruned, any other stays where it is). The cost is a guide
19
+ * whose committed path differs from every path the server holds for it: it lands
20
+ * at its own path as a new file.
21
+ *
22
+ * **Only an item that already carries its single id is a target** (`id` equals
23
+ * `artifactId`). Before the change a guide's two ids differ, so a pull from that
24
+ * server offers no target and this step changes nothing, whatever the
25
+ * placement file holds. That is what lets this ship ahead of the server change:
26
+ * the same code is a no-op on one side of it and a re-key on the other.
27
+ *
28
+ * **A path is not proof it is the same guide.** `my-guides` returns every
29
+ * project guide the account has, so another repo's guide can sit at this
30
+ * record's path in the same bundle. The sync's own adoption rule has the same
31
+ * problem and the same answer (`findHeldGuideFile`): the guide must carry this
32
+ * repo's project id, or its bytes must be the bytes on disk. A foreign guide is
33
+ * never a candidate, and a lone candidate needs that proof.
34
+ *
35
+ * The planner decides from what it is handed; the sync applies the decisions, so
36
+ * the dry run reads the same answer.
37
+ */
38
+ import type { GuideProjectionDeps } from './guide-projection.js';
39
+ import type { DocMapping, PlacementConflict, TombstoneRecord } from './sidecar.js';
40
+ import type { ContextItem } from '@mossbear/protocol';
41
+ /** One subscribed bundle as the pull returned it. */
42
+ export type RekeyBundle = {
43
+ /** The name placement records the bundle under (`DocMapping.bundle`). */
44
+ bundle: string;
45
+ items: readonly ContextItem[];
46
+ /** False when the pull failed: there is no page to read. */
47
+ readable: boolean;
48
+ /**
49
+ * False when the pull filled its page, and there is no way to ask for the
50
+ * rest. A guide that is in the page is still there, so a record can follow
51
+ * it; what a short page cannot show is that something is absent, so it never
52
+ * settles a conflict and never says a record has no guide.
53
+ */
54
+ complete: boolean;
55
+ };
56
+ /** Why a record was not re-keyed. */
57
+ export type RekeyUnmatchedReason =
58
+ /** No pulled guide in the record's bundle sits at the record's path. */
59
+ 'no-guide-at-path'
60
+ /** The record's bundle was not pulled, or its pull was incomplete. */
61
+ | 'bundle-unavailable'
62
+ /** A suppression record exists for the path, so it is not claimed again. */
63
+ | 'tombstoned'
64
+ /** The guide that sits at the path is already tracked, at another path. */
65
+ | 'guide-tracked-elsewhere'
66
+ /** A guide sits at the path, but nothing shows it is the one this record named. */
67
+ | 'not-shown-to-be-the-same';
68
+ export type RekeyDecision = {
69
+ kind: 'rekey';
70
+ /** The id the record carries now. */
71
+ from: string;
72
+ /** The id of the one guide at its path. */
73
+ to: string;
74
+ bundle: string;
75
+ path: string;
76
+ } | {
77
+ kind: 'ambiguous';
78
+ itemId: string;
79
+ bundle: string;
80
+ path: string;
81
+ /** The ids that could claim it: several guides at the path, or several records for one guide. */
82
+ candidates: string[];
83
+ } | {
84
+ kind: 'unmatched';
85
+ itemId: string;
86
+ bundle: string;
87
+ path: string;
88
+ reason: RekeyUnmatchedReason;
89
+ } | {
90
+ /**
91
+ * Two records at one path, an old id and a current one, which is what a
92
+ * union merge of a pre-change branch into a migrated one leaves. The
93
+ * placement reader withholds both as a conflict; here one of them is
94
+ * absent from the pull and the other is the live guide, so the stale one
95
+ * is retired and the live one is tracked again.
96
+ */
97
+ kind: 'supersede';
98
+ live: string;
99
+ stale: string[];
100
+ bundle: string;
101
+ path: string;
102
+ };
103
+ export type RekeyPlan = {
104
+ decisions: RekeyDecision[];
105
+ };
106
+ /** True for a guide that carries its single id, which only a migrated server sends. */
107
+ export declare function carriesSingleId(item: ContextItem): boolean;
108
+ /**
109
+ * The repo-relative paths a pulled guide is held at: its declared path and its
110
+ * project-root alias paths. Compared lower-cased, because two spellings of one
111
+ * file are one file on macOS and Windows (the same rule `parsePlacement` applies).
112
+ */
113
+ export declare function guideProjectPaths(item: ContextItem): string[];
114
+ /**
115
+ * Read the file a record names, only if reading it is safe.
116
+ *
117
+ * A placement path arrives by git and is checked as a bare string, so it can be
118
+ * `../../…` or a link out of the repo, and the file behind it can be any size.
119
+ * The write path refuses both before it touches such a target
120
+ * (`refuseUnsafeMappedTarget`), and so does this read: a refused or oversized
121
+ * file answers null, which proves nothing and so never licenses a re-key.
122
+ */
123
+ export declare function readMappedFileForProof(input: {
124
+ root: string;
125
+ mapping: DocMapping;
126
+ read: (absolutePath: string) => Promise<string | null>;
127
+ size: (absolutePath: string) => Promise<number | null>;
128
+ projectionDeps?: GuideProjectionDeps;
129
+ }): Promise<string | null>;
130
+ /** Whether a guide is provably the one a record named. */
131
+ export type RekeyProof = (record: DocMapping, item: ContextItem) => Promise<boolean>;
132
+ /**
133
+ * The proof the sync's adoption rule asks for: the guide carries this repo's
134
+ * project id, or the file on disk holds exactly the guide's bytes.
135
+ *
136
+ * A guide that names a different project than a repo that declares one is not
137
+ * this repo's whatever the bytes say, so it fails without reading the file.
138
+ */
139
+ export declare function rekeyProof(input: {
140
+ homeProjectId: string | null;
141
+ /** The record's file as text, or null when it is missing or unreadable. */
142
+ readLocal: (record: DocMapping) => Promise<string | null>;
143
+ }): RekeyProof;
144
+ /**
145
+ * Decide, for every record the pull no longer names, whether it follows a guide.
146
+ *
147
+ * `records` and `conflicts` are the placement reader's view (`Sidecar.docs` and
148
+ * `Sidecar.placementConflicts`). A conflicted item is not a record, so it is
149
+ * never re-keyed; the one conflict this resolves is the stale-plus-current pair
150
+ * described on the `supersede` decision.
151
+ */
152
+ export declare function planRekey(input: {
153
+ records: readonly DocMapping[];
154
+ conflicts: readonly PlacementConflict[];
155
+ bundles: readonly RekeyBundle[];
156
+ tombstones: ReadonlyMap<string, TombstoneRecord>;
157
+ /** This checkout's committed `project.id`, or null when it declares none. */
158
+ homeProjectId: string | null;
159
+ isProven: RekeyProof;
160
+ /** The record's file as text, or null when it can't be read safely. */
161
+ readLocal: (record: DocMapping) => Promise<string | null>;
162
+ /**
163
+ * Where a guide with no path of its own lands in its bundle's folder, as
164
+ * repo-relative paths. Such a guide has nothing to match a record on but the
165
+ * file name the sync would give it.
166
+ */
167
+ landingPaths?: (bundle: string, item: ContextItem) => readonly string[];
168
+ }): Promise<RekeyPlan>;
169
+ //# sourceMappingURL=rekey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rekey.d.ts","sourceRoot":"","sources":["../../src/docs/rekey.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAUH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAErD,qDAAqD;AACrD,MAAM,MAAM,WAAW,GAAG;IACxB,yEAAyE;IACzE,MAAM,EAAE,M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AE,UAAU,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;IACzD;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,KAAK,SAAS,MAAM,EAAE,CAAA;CACxE,GAAG,OAAO,CAAC,SAAS,CAAC,CAwNrB"}
@@ -0,0 +1,321 @@
1
+ /**
2
+ * Re-keying committed placement records when a guide's id changes.
3
+ *
4
+ * A placement record names its item by id (`sidecar.ts` → `PlacementRecord`). A
5
+ * guide used to carry two ids, its own and its body file's, and the pull
6
+ * returned the first. The server is moving to one id per guide, the body file's,
7
+ * so after that change a pull returns an id no committed record names. Without
8
+ * this step every guide in every repo would read as gone (its old record
9
+ * retired) and new (materialized again), and a repo that git tracks would get a
10
+ * second copy beside the first.
11
+ *
12
+ * **No id map exists, here or on the server.** A record is matched to its guide
13
+ * by what both still agree on: the bundle and the path. A record whose id is
14
+ * absent from the pull is re-keyed when exactly one pulled guide in its bundle
15
+ * sits at the record's path, declared or alias. A record that matches none, or
16
+ * more than one, is left exactly as it is, and the sync then treats it as any
17
+ * record whose guide has left the pull: it stops tracking it (an unedited file
18
+ * in a bundle folder is pruned, any other stays where it is). The cost is a guide
19
+ * whose committed path differs from every path the server holds for it: it lands
20
+ * at its own path as a new file.
21
+ *
22
+ * **Only an item that already carries its single id is a target** (`id` equals
23
+ * `artifactId`). Before the change a guide's two ids differ, so a pull from that
24
+ * server offers no target and this step changes nothing, whatever the
25
+ * placement file holds. That is what lets this ship ahead of the server change:
26
+ * the same code is a no-op on one side of it and a re-key on the other.
27
+ *
28
+ * **A path is not proof it is the same guide.** `my-guides` returns every
29
+ * project guide the account has, so another repo's guide can sit at this
30
+ * record's path in the same bundle. The sync's own adoption rule has the same
31
+ * problem and the same answer (`findHeldGuideFile`): the guide must carry this
32
+ * repo's project id, or its bytes must be the bytes on disk. A foreign guide is
33
+ * never a candidate, and a lone candidate needs that proof.
34
+ *
35
+ * The planner decides from what it is handed; the sync applies the decisions, so
36
+ * the dry run reads the same answer.
37
+ */
38
+ import { MAX_RAW_GUIDE_CONTENT_BYTES } from '@mossbear/protocol';
39
+ import { materializedBody } from '../context/materialize.js';
40
+ import { isPathWithin } from '../rules/path-contains.js';
41
+ import { refuseUnsafeMappedTarget } from './guide-projection.js';
42
+ import { fromSidecarPath, hashContent } from './sidecar.js';
43
+ import { isForeignProjectItem } from './sync-plan.js';
44
+ /** True for a guide that carries its single id, which only a migrated server sends. */
45
+ export function carriesSingleId(item) {
46
+ return item.type === 'guide' && item.artifactId != null && item.artifactId === item.id;
47
+ }
48
+ /**
49
+ * The repo-relative paths a pulled guide is held at: its declared path and its
50
+ * project-root alias paths. Compared lower-cased, because two spellings of one
51
+ * file are one file on macOS and Windows (the same rule `parsePlacement` applies).
52
+ */
53
+ export function guideProjectPaths(item) {
54
+ if ((item.root ?? 'project') !== 'project')
55
+ return [];
56
+ const paths = [];
57
+ if (typeof item.path === 'string' && item.path.length > 0)
58
+ paths.push(item.path);
59
+ for (const alias of item.aliases ?? []) {
60
+ if (alias.root === 'project')
61
+ paths.push(alias.path);
62
+ }
63
+ return [...new Set(paths)];
64
+ }
65
+ /**
66
+ * Read the file a record names, only if reading it is safe.
67
+ *
68
+ * A placement path arrives by git and is checked as a bare string, so it can be
69
+ * `../../…` or a link out of the repo, and the file behind it can be any size.
70
+ * The write path refuses both before it touches such a target
71
+ * (`refuseUnsafeMappedTarget`), and so does this read: a refused or oversized
72
+ * file answers null, which proves nothing and so never licenses a re-key.
73
+ */
74
+ export async function readMappedFileForProof(input) {
75
+ const { root, mapping, read, size, projectionDeps } = input;
76
+ const absolutePath = fromSidecarPath(root, mapping.path);
77
+ if (!isPathWithin(root, absolutePath))
78
+ return null;
79
+ if ((await refuseUnsafeMappedTarget(root, absolutePath, projectionDeps)) !== null) {
80
+ return null;
81
+ }
82
+ const bytes = await size(absolutePath);
83
+ if (bytes === null || bytes > MAX_RAW_GUIDE_CONTENT_BYTES)
84
+ return null;
85
+ return read(absolutePath);
86
+ }
87
+ /**
88
+ * The proof the sync's adoption rule asks for: the guide carries this repo's
89
+ * project id, or the file on disk holds exactly the guide's bytes.
90
+ *
91
+ * A guide that names a different project than a repo that declares one is not
92
+ * this repo's whatever the bytes say, so it fails without reading the file.
93
+ */
94
+ export function rekeyProof(input) {
95
+ const { homeProjectId, readLocal } = input;
96
+ return async (record, item) => {
97
+ const itemProject = item.projectId ?? '';
98
+ if (itemProject.length > 0 && homeProjectId !== null && homeProjectId.length > 0) {
99
+ return itemProject === homeProjectId;
100
+ }
101
+ if (item.content === null)
102
+ return false;
103
+ const local = await readLocal(record);
104
+ // The comparison adoption makes (`findHeldGuideFile`): both sides as the
105
+ // sync would write them, so a missing trailing newline is not a difference.
106
+ return local !== null && materializedBody(local) === materializedBody(item.content);
107
+ };
108
+ }
109
+ /**
110
+ * Decide, for every record the pull no longer names, whether it follows a guide.
111
+ *
112
+ * `records` and `conflicts` are the placement reader's view (`Sidecar.docs` and
113
+ * `Sidecar.placementConflicts`). A conflicted item is not a record, so it is
114
+ * never re-keyed; the one conflict this resolves is the stale-plus-current pair
115
+ * described on the `supersede` decision.
116
+ */
117
+ export async function planRekey(input) {
118
+ const { records, conflicts, bundles, tombstones, homeProjectId, isProven, readLocal, landingPaths, } = input;
119
+ const pulledIds = new Set(bundles.flatMap((entry) => entry.items.map((item) => item.id)));
120
+ const singleIdIds = new Set(bundles.flatMap((entry) => entry.items.filter(carriesSingleId).map((item) => item.id)));
121
+ const trackedIds = new Set([
122
+ ...records.map((record) => record.itemId),
123
+ ...conflicts.map((conflict) => conflict.itemId),
124
+ ]);
125
+ // Lower-cased like every other path comparison here: a tombstone for
126
+ // `AGENTS.md` is a tombstone for `Agents.md` on a case-insensitive disk.
127
+ const tombstonedHashes = new Map();
128
+ for (const entry of tombstones.values()) {
129
+ if (entry.root !== 'project')
130
+ continue;
131
+ const key = entry.path.toLowerCase();
132
+ tombstonedHashes.set(key, [...(tombstonedHashes.get(key) ?? []), entry.contentHash]);
133
+ }
134
+ /**
135
+ * A tombstone suppresses the exact bytes that were deleted, so a path whose
136
+ * file now holds other bytes is a new guide and is not suppressed. Bytes that
137
+ * can't be read leave the tombstone standing: not knowing is not permission.
138
+ */
139
+ const isTombstoned = async (record) => {
140
+ const hashes = tombstonedHashes.get(record.path.toLowerCase());
141
+ if (hashes === undefined)
142
+ return false;
143
+ const local = await readLocal(record);
144
+ return local === null || hashes.includes(hashContent(local));
145
+ };
146
+ /**
147
+ * Per bundle, lower-cased path → the single-id guides held there, by id. A
148
+ * guide of another project is left out: it is not a guide this repo could hold.
149
+ */
150
+ const guidesByPath = new Map();
151
+ for (const entry of bundles) {
152
+ if (!entry.readable)
153
+ continue;
154
+ const byPath = guidesByPath.get(entry.bundle) ?? new Map();
155
+ for (const item of entry.items) {
156
+ if (!carriesSingleId(item))
157
+ continue;
158
+ if (isForeignProjectItem({ itemProjectId: item.projectId, homeProjectId }))
159
+ continue;
160
+ const held = guideProjectPaths(item).length > 0
161
+ ? guideProjectPaths(item)
162
+ : (item.root ?? 'project') === 'project'
163
+ ? [...(landingPaths?.(entry.bundle, item) ?? [])]
164
+ : [];
165
+ for (const path of held.map((raw) => raw.toLowerCase())) {
166
+ const ids = byPath.get(path) ?? new Map();
167
+ ids.set(item.id, item);
168
+ byPath.set(path, ids);
169
+ }
170
+ }
171
+ guidesByPath.set(entry.bundle, byPath);
172
+ }
173
+ const completeBundles = new Set(bundles
174
+ .filter((entry) => entry.readable && entry.complete)
175
+ .map((entry) => entry.bundle));
176
+ const readableBundles = new Set(bundles.filter((entry) => entry.readable).map((entry) => entry.bundle));
177
+ const decisions = [];
178
+ /** Target id → the records that would follow it. */
179
+ const proposals = new Map();
180
+ for (const record of records) {
181
+ if (pulledIds.has(record.itemId))
182
+ continue;
183
+ const base = { bundle: record.bundle, path: record.path };
184
+ if (await isTombstoned(record)) {
185
+ decisions.push({
186
+ kind: 'unmatched',
187
+ itemId: record.itemId,
188
+ ...base,
189
+ reason: 'tombstoned',
190
+ });
191
+ continue;
192
+ }
193
+ if (!readableBundles.has(record.bundle)) {
194
+ decisions.push({
195
+ kind: 'unmatched',
196
+ itemId: record.itemId,
197
+ ...base,
198
+ reason: 'bundle-unavailable',
199
+ });
200
+ continue;
201
+ }
202
+ const here = guidesByPath.get(record.bundle)?.get(record.path.toLowerCase());
203
+ if (here === undefined || here.size === 0) {
204
+ decisions.push({
205
+ kind: 'unmatched',
206
+ itemId: record.itemId,
207
+ ...base,
208
+ // A short page cannot say there is no guide here, only that it did not
209
+ // show one.
210
+ reason: completeBundles.has(record.bundle)
211
+ ? 'no-guide-at-path'
212
+ : 'bundle-unavailable',
213
+ });
214
+ continue;
215
+ }
216
+ // Several guides at one path (two pathless guides with the same name land on
217
+ // the same file name): only one that is provably the record's own can break
218
+ // the tie. Two that are, or none, leave it ambiguous.
219
+ let chosen = [...here.entries()];
220
+ let proven = false;
221
+ if (chosen.length > 1) {
222
+ const candidates = chosen;
223
+ chosen = [];
224
+ for (const entry of candidates) {
225
+ if (await isProven(record, entry[1]))
226
+ chosen.push(entry);
227
+ }
228
+ proven = true;
229
+ if (chosen.length !== 1) {
230
+ decisions.push({
231
+ kind: 'ambiguous',
232
+ itemId: record.itemId,
233
+ ...base,
234
+ candidates: candidates.map(([id]) => id).sort(),
235
+ });
236
+ continue;
237
+ }
238
+ }
239
+ const [[target, targetItem]] = chosen;
240
+ if (trackedIds.has(target)) {
241
+ decisions.push({
242
+ kind: 'unmatched',
243
+ itemId: record.itemId,
244
+ ...base,
245
+ reason: 'guide-tracked-elsewhere',
246
+ });
247
+ continue;
248
+ }
249
+ if (!proven && !(await isProven(record, targetItem))) {
250
+ decisions.push({
251
+ kind: 'unmatched',
252
+ itemId: record.itemId,
253
+ ...base,
254
+ reason: 'not-shown-to-be-the-same',
255
+ });
256
+ continue;
257
+ }
258
+ proposals.set(target, [...(proposals.get(target) ?? []), record]);
259
+ }
260
+ for (const [target, claimants] of proposals) {
261
+ if (claimants.length > 1) {
262
+ for (const record of claimants) {
263
+ decisions.push({
264
+ kind: 'ambiguous',
265
+ itemId: record.itemId,
266
+ bundle: record.bundle,
267
+ path: record.path,
268
+ candidates: claimants.map((claimant) => claimant.itemId).sort(),
269
+ });
270
+ }
271
+ continue;
272
+ }
273
+ const [record] = claimants;
274
+ decisions.push({
275
+ kind: 'rekey',
276
+ from: record.itemId,
277
+ to: target,
278
+ bundle: record.bundle,
279
+ path: record.path,
280
+ });
281
+ }
282
+ // Path collisions: the reader withholds every item of a pair that shares a
283
+ // path. When one of them is a live single-id guide and every other is absent
284
+ // from the pull, the others are the stale half of a merge.
285
+ const collisions = new Map();
286
+ for (const conflict of conflicts) {
287
+ const [only, ...rest] = conflict.paths;
288
+ if (only === undefined || rest.length > 0)
289
+ continue;
290
+ // Per bundle: the same path in two subscriptions is legal, and one
291
+ // bundle's pull says nothing about the other's records.
292
+ const key = `${conflict.bundle}\u0000${only.toLowerCase()}`;
293
+ collisions.set(key, [...(collisions.get(key) ?? []), conflict]);
294
+ }
295
+ for (const group of collisions.values()) {
296
+ if (group.length < 2)
297
+ continue;
298
+ const [first] = group;
299
+ const path = first.paths[0];
300
+ if (await isTombstoned({ itemId: first.itemId, bundle: first.bundle, path }))
301
+ continue;
302
+ const live = group.filter((conflict) => pulledIds.has(conflict.itemId));
303
+ const stale = group.filter((conflict) => !pulledIds.has(conflict.itemId));
304
+ const [current] = live;
305
+ if (live.length !== 1 || stale.length === 0 || current === undefined)
306
+ continue;
307
+ if (!singleIdIds.has(current.itemId))
308
+ continue;
309
+ if (!completeBundles.has(current.bundle))
310
+ continue;
311
+ decisions.push({
312
+ kind: 'supersede',
313
+ live: current.itemId,
314
+ stale: stale.map((conflict) => conflict.itemId).sort(),
315
+ bundle: current.bundle,
316
+ path,
317
+ });
318
+ }
319
+ return { decisions };
320
+ }
321
+ //# sourceMappingURL=rekey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rekey.js","sourceRoot":"","sources":["../../src/docs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;;;GAaG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,WAAgB,GACrB,OAAO,CAAC,IAAI,CAAC,CAqBf;AAwBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,WAAgB,GACrB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAmBtB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,WAAgB,GACrB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAKvC;AAED,0EAA0E;AAC1E,wBAAgB,aAAa,CAAC,OAAO,EAAE;IACrC,IAAI,EAAE,SAAS,UAAU,EAAE,CAAA;CAC5B,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAI1B"}
@@ -866,14 +866,19 @@ export async function writePlacement(root, docs, retiredItemIds, deps = {}, tomb
866
866
  const contextExists = (await readStateFile(contextPlacementPath(root), readFileFn)) !== null;
867
867
  // Its lines were read above and are re-filed below, so the file itself goes.
868
868
  const legacyExists = (await readStateFile(legacyPlacementPath(root), readFileFn)) !== null;
869
- const mappingEntries = [...docs, ...preserved].map((mapping) => ({
870
- path: mapping.path,
871
- json: JSON.stringify({
872
- itemId: mapping.itemId,
873
- bundle: mapping.bundle,
874
- path: mapping.path,
875
- }),
876
- }));
869
+ // Identical lines are one line: a record this pass claims can also be kept
870
+ // as a withheld conflict (a re-key that settles one), and the file should
871
+ // carry it once.
872
+ const mappingEntries = [
873
+ ...new Map([...docs, ...preserved].map((mapping) => {
874
+ const json = JSON.stringify({
875
+ itemId: mapping.itemId,
876
+ bundle: mapping.bundle,
877
+ path: mapping.path,
878
+ });
879
+ return [json, { path: mapping.path, json }];
880
+ })).values(),
881
+ ];
877
882
  const tombstoneEntries = [...(tombstoneChanges.add ?? []), ...preservedTombstones].map((tombstone) => ({
878
883
  path: tombstone.path,
879
884
  json: JSON.stringify({