@peer2peer/ext-ix 0.0.0-stage → 0.1.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/LICENSE +201 -0
- package/README.md +75 -2
- package/SPEC.md +695 -0
- package/dist/conflicts.d.ts +64 -0
- package/dist/conflicts.js +188 -0
- package/dist/extension.d.ts +31 -0
- package/dist/extension.js +552 -0
- package/dist/footprint-command.d.ts +57 -0
- package/dist/footprint-command.js +398 -0
- package/dist/footprint-compute.d.ts +106 -0
- package/dist/footprint-compute.js +559 -0
- package/dist/footprint.d.ts +162 -0
- package/dist/footprint.js +451 -0
- package/dist/hmac.d.ts +18 -0
- package/dist/hmac.js +42 -0
- package/dist/impact.d.ts +66 -0
- package/dist/impact.js +208 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +20 -0
- package/dist/ix.d.ts +20 -0
- package/dist/ix.js +76 -0
- package/dist/note.d.ts +40 -0
- package/dist/note.js +82 -0
- package/dist/overlap-command.d.ts +37 -0
- package/dist/overlap-command.js +81 -0
- package/dist/overlap.d.ts +83 -0
- package/dist/overlap.js +227 -0
- package/dist/repo.d.ts +36 -0
- package/dist/repo.js +116 -0
- package/dist/subgraph.d.ts +59 -0
- package/dist/subgraph.js +140 -0
- package/dist/text.d.ts +83 -0
- package/dist/text.js +187 -0
- package/dist/which.d.ts +1 -0
- package/dist/which.js +45 -0
- package/package.json +61 -4
package/dist/impact.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type RepoRef } from "./repo.js";
|
|
2
|
+
import { type Roots, type RiskLevel } from "./text.js";
|
|
3
|
+
export declare const IMPACT_KIND: "x:ix.impact";
|
|
4
|
+
export interface ImpactSymbol {
|
|
5
|
+
name: string;
|
|
6
|
+
kind: string;
|
|
7
|
+
path?: string;
|
|
8
|
+
/** Callers Ix counted for it. */
|
|
9
|
+
callers?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface ImpactComponent {
|
|
12
|
+
name: string;
|
|
13
|
+
kind?: string;
|
|
14
|
+
/** Dependents in it. */
|
|
15
|
+
count: number;
|
|
16
|
+
}
|
|
17
|
+
export interface ImpactBody {
|
|
18
|
+
target: {
|
|
19
|
+
name: string;
|
|
20
|
+
kind: string;
|
|
21
|
+
};
|
|
22
|
+
repo?: RepoRef;
|
|
23
|
+
riskLevel: RiskLevel;
|
|
24
|
+
riskSummary: string;
|
|
25
|
+
riskCategory?: string;
|
|
26
|
+
atRisk: string[];
|
|
27
|
+
/** Affected files (repo-relative). */
|
|
28
|
+
files: string[];
|
|
29
|
+
/** The sender's changed files (repo-relative), when they said. */
|
|
30
|
+
changed?: string[];
|
|
31
|
+
symbols: ImpactSymbol[];
|
|
32
|
+
components: ImpactComponent[];
|
|
33
|
+
counts?: {
|
|
34
|
+
callers?: number;
|
|
35
|
+
callees?: number;
|
|
36
|
+
members?: number;
|
|
37
|
+
importers?: number;
|
|
38
|
+
dependents?: number;
|
|
39
|
+
};
|
|
40
|
+
/** The sender's graph had lost edges: the counts are a floor. */
|
|
41
|
+
graphDegraded?: boolean;
|
|
42
|
+
nextStep?: string;
|
|
43
|
+
}
|
|
44
|
+
export declare function parseImpactBody(v: unknown): ImpactBody;
|
|
45
|
+
export declare function impactFallback(b: Pick<ImpactBody, "riskLevel" | "files" | "symbols">): string;
|
|
46
|
+
export interface ImpactInput {
|
|
47
|
+
/** `ix impact <target> --format json` output. */
|
|
48
|
+
ix: unknown;
|
|
49
|
+
repo?: RepoRef;
|
|
50
|
+
changed?: string[];
|
|
51
|
+
root?: Roots;
|
|
52
|
+
home?: string;
|
|
53
|
+
hostname?: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Sending: maps Ix's impact JSON (container or leaf shape) to a body. Paths
|
|
57
|
+
* are made repo-relative (others dropped), free text scrubbed of local
|
|
58
|
+
* paths, every list capped.
|
|
59
|
+
*/
|
|
60
|
+
export declare function buildImpact(i: ImpactInput): {
|
|
61
|
+
body: ImpactBody;
|
|
62
|
+
fallback: string;
|
|
63
|
+
};
|
|
64
|
+
export declare function renderImpact(b: ImpactBody, from: {
|
|
65
|
+
address: string;
|
|
66
|
+
}): Record<string, unknown>;
|
package/dist/impact.js
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
// Copyright 2026 Ix Infrastructure Inc.
|
|
2
|
+
//
|
|
3
|
+
// x:ix.impact: a blast-radius report for a change, made by the sender's Ix
|
|
4
|
+
// (`ix impact <target> --format json`, SPEC.md §5). The receiver only reads
|
|
5
|
+
// it: it lists files, symbols and components, and a risk summary.
|
|
6
|
+
import { parseRepo } from "./repo.js";
|
|
7
|
+
import { fail, frame, isObj, jsonBytes, LIMITS, line, list, MAX_BODY_BYTES, oneOf, optInt, optStr, relPath, RISK_LEVELS, scrubPaths, str, toRepoRelative, } from "./text.js";
|
|
8
|
+
export const IMPACT_KIND = "x:ix.impact";
|
|
9
|
+
const NAME_MAX = LIMITS.symbol;
|
|
10
|
+
function parseSymbol(x, i) {
|
|
11
|
+
if (!isObj(x))
|
|
12
|
+
return fail(`impact.symbols[${i}] must be an object`);
|
|
13
|
+
const name = str(x, "name", NAME_MAX, `impact.symbols[${i}]`);
|
|
14
|
+
const kind = str(x, "kind", LIMITS.kind, `impact.symbols[${i}]`);
|
|
15
|
+
const path = x.path === undefined ? undefined : relPath(x.path, `impact.symbols[${i}].path`);
|
|
16
|
+
const callers = optInt(x, "callers", `impact.symbols[${i}]`);
|
|
17
|
+
return { name, kind, ...(path ? { path } : {}), ...(callers !== undefined ? { callers } : {}) };
|
|
18
|
+
}
|
|
19
|
+
function parseComponent(x, i) {
|
|
20
|
+
if (!isObj(x))
|
|
21
|
+
return fail(`impact.components[${i}] must be an object`);
|
|
22
|
+
const name = str(x, "name", LIMITS.region, `impact.components[${i}]`);
|
|
23
|
+
const kind = optStr(x, "kind", LIMITS.kind, `impact.components[${i}]`);
|
|
24
|
+
const count = optInt(x, "count", `impact.components[${i}]`) ?? 0;
|
|
25
|
+
return { name, ...(kind ? { kind } : {}), count };
|
|
26
|
+
}
|
|
27
|
+
export function parseImpactBody(v) {
|
|
28
|
+
if (!isObj(v))
|
|
29
|
+
return fail("impact body must be an object");
|
|
30
|
+
const o = v;
|
|
31
|
+
if (jsonBytes(o) > MAX_BODY_BYTES)
|
|
32
|
+
fail(`impact body is larger than ${MAX_BODY_BYTES} bytes`);
|
|
33
|
+
if (!isObj(o.target))
|
|
34
|
+
fail("impact.target must be {name, kind}");
|
|
35
|
+
const t = o.target;
|
|
36
|
+
const target = { name: str(t, "name", NAME_MAX, "impact.target"), kind: str(t, "kind", LIMITS.kind, "impact.target") };
|
|
37
|
+
const repo = o.repo === undefined ? undefined : parseRepo(o.repo, "impact.repo");
|
|
38
|
+
const riskLevel = oneOf(o, "riskLevel", RISK_LEVELS, "impact");
|
|
39
|
+
const riskSummary = str(o, "riskSummary", LIMITS.riskSummary, "impact");
|
|
40
|
+
const riskCategory = optStr(o, "riskCategory", 40, "impact");
|
|
41
|
+
const atRisk = list(o, "atRisk", LIMITS.atRisk, "impact", (x, i) => {
|
|
42
|
+
if (typeof x !== "string" || x.trim() === "" || [...x].length > LIMITS.atRiskItem)
|
|
43
|
+
return fail(`impact.atRisk[${i}] must be a string of 1-${LIMITS.atRiskItem}`);
|
|
44
|
+
return x.trim();
|
|
45
|
+
});
|
|
46
|
+
const files = list(o, "files", LIMITS.files, "impact", (x, i) => relPath(x, `impact.files[${i}]`));
|
|
47
|
+
const changed = list(o, "changed", LIMITS.changed, "impact", (x, i) => relPath(x, `impact.changed[${i}]`));
|
|
48
|
+
const symbols = list(o, "symbols", LIMITS.symbols, "impact", parseSymbol);
|
|
49
|
+
const components = list(o, "components", LIMITS.components, "impact", parseComponent);
|
|
50
|
+
let counts;
|
|
51
|
+
if (o.counts !== undefined) {
|
|
52
|
+
if (!isObj(o.counts))
|
|
53
|
+
fail("impact.counts must be an object");
|
|
54
|
+
const c = o.counts;
|
|
55
|
+
counts = {};
|
|
56
|
+
for (const k of ["callers", "callees", "members", "importers", "dependents"]) {
|
|
57
|
+
const n = optInt(c, k, "impact.counts");
|
|
58
|
+
if (n !== undefined)
|
|
59
|
+
counts[k] = n;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (o.graphDegraded !== undefined && typeof o.graphDegraded !== "boolean")
|
|
63
|
+
fail("impact.graphDegraded must be a boolean");
|
|
64
|
+
const nextStep = optStr(o, "nextStep", LIMITS.nextStep, "impact");
|
|
65
|
+
return {
|
|
66
|
+
target,
|
|
67
|
+
...(repo ? { repo } : {}),
|
|
68
|
+
riskLevel,
|
|
69
|
+
riskSummary,
|
|
70
|
+
...(riskCategory ? { riskCategory } : {}),
|
|
71
|
+
atRisk,
|
|
72
|
+
files,
|
|
73
|
+
...(changed.length ? { changed } : {}),
|
|
74
|
+
symbols,
|
|
75
|
+
components,
|
|
76
|
+
...(counts && Object.keys(counts).length ? { counts } : {}),
|
|
77
|
+
...(o.graphDegraded === true ? { graphDegraded: true } : {}),
|
|
78
|
+
...(nextStep ? { nextStep } : {}),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
export function impactFallback(b) {
|
|
82
|
+
const n = b.files.length || b.symbols.length;
|
|
83
|
+
const what = b.riskLevel === "unknown" ? "" : `${b.riskLevel} risk, `;
|
|
84
|
+
return `shared an Ix blast-radius report (${what}${n} affected): install Ix to open it: https://github.com/ix-infrastructure/Ix`;
|
|
85
|
+
}
|
|
86
|
+
const num = (v) => (typeof v === "number" && Number.isSafeInteger(v) && v >= 0 ? v : undefined);
|
|
87
|
+
const s = (v, max) => (typeof v === "string" && v.trim() !== "" ? v.trim().slice(0, max) : undefined);
|
|
88
|
+
/**
|
|
89
|
+
* Sending: maps Ix's impact JSON (container or leaf shape) to a body. Paths
|
|
90
|
+
* are made repo-relative (others dropped), free text scrubbed of local
|
|
91
|
+
* paths, every list capped.
|
|
92
|
+
*/
|
|
93
|
+
export function buildImpact(i) {
|
|
94
|
+
if (!isObj(i.ix))
|
|
95
|
+
return fail("ix impact output must be a JSON object");
|
|
96
|
+
const x = i.ix;
|
|
97
|
+
if (typeof x.error === "string")
|
|
98
|
+
fail(`ix impact: ${String(x.message ?? x.error).slice(0, 200)}`);
|
|
99
|
+
// L3: every free-text field, names included (a target or symbol can be a path).
|
|
100
|
+
const scrub = (t) => scrubPaths(t, { root: i.root, home: i.home, hostname: i.hostname });
|
|
101
|
+
const rt = isObj(x.resolvedTarget) ? x.resolvedTarget : {};
|
|
102
|
+
const target = { name: scrub(s(rt.name, NAME_MAX) ?? "(unknown)"), kind: s(rt.kind, LIMITS.kind) ?? "unknown" };
|
|
103
|
+
const riskLevel = RISK_LEVELS.includes(String(x.riskLevel)) ? x.riskLevel : "unknown";
|
|
104
|
+
const rel = (p) => (typeof p === "string" ? toRepoRelative(p, i.root) : undefined);
|
|
105
|
+
const symbols = [];
|
|
106
|
+
const seen = new Set();
|
|
107
|
+
const addSym = (m) => {
|
|
108
|
+
if (!isObj(m) || symbols.length >= LIMITS.symbols)
|
|
109
|
+
return;
|
|
110
|
+
const raw = s(m.name, NAME_MAX);
|
|
111
|
+
if (!raw || raw === "(unnamed)")
|
|
112
|
+
return;
|
|
113
|
+
const name = scrub(raw);
|
|
114
|
+
const kind = s(m.kind, LIMITS.kind) ?? "unknown";
|
|
115
|
+
const path = rel(m.path);
|
|
116
|
+
const key = `${kind}|${name}|${path ?? ""}`;
|
|
117
|
+
if (seen.has(key))
|
|
118
|
+
return;
|
|
119
|
+
seen.add(key);
|
|
120
|
+
const callers = num(m.callerCount);
|
|
121
|
+
symbols.push({ name, kind, ...(path ? { path } : {}), ...(callers !== undefined ? { callers } : {}) });
|
|
122
|
+
};
|
|
123
|
+
for (const m of Array.isArray(x.topImpactedMembers) ? x.topImpactedMembers : [])
|
|
124
|
+
addSym(m);
|
|
125
|
+
for (const m of Array.isArray(x.callerList) ? x.callerList : [])
|
|
126
|
+
addSym(m);
|
|
127
|
+
const components = [];
|
|
128
|
+
for (const b of Array.isArray(x.propagationBuckets) ? x.propagationBuckets : []) {
|
|
129
|
+
if (!isObj(b) || components.length >= LIMITS.components)
|
|
130
|
+
continue;
|
|
131
|
+
const region = s(b.region, LIMITS.region);
|
|
132
|
+
if (!region)
|
|
133
|
+
continue;
|
|
134
|
+
const name = scrub(region);
|
|
135
|
+
const kind = s(b.regionKind, LIMITS.kind);
|
|
136
|
+
components.push({ name, ...(kind ? { kind } : {}), count: num(b.count) ?? 0 });
|
|
137
|
+
}
|
|
138
|
+
const files = [...new Set(symbols.map((m) => m.path).filter((p) => !!p))].slice(0, LIMITS.files);
|
|
139
|
+
const sum = isObj(x.summary) ? x.summary : {};
|
|
140
|
+
const counts = {};
|
|
141
|
+
const map = [
|
|
142
|
+
["callers", "callers"],
|
|
143
|
+
["callees", "callees"],
|
|
144
|
+
["members", "members"],
|
|
145
|
+
["importers", "directImporters"],
|
|
146
|
+
["dependents", "directDependents"],
|
|
147
|
+
];
|
|
148
|
+
for (const [k, from] of map) {
|
|
149
|
+
const n = num(sum[from]);
|
|
150
|
+
if (n !== undefined)
|
|
151
|
+
counts[k] = n;
|
|
152
|
+
}
|
|
153
|
+
const atRisk = (Array.isArray(x.atRiskBehavior) ? x.atRiskBehavior : [])
|
|
154
|
+
.map((b) => s(b, LIMITS.atRiskItem))
|
|
155
|
+
.filter((b) => !!b)
|
|
156
|
+
.map(scrub)
|
|
157
|
+
.slice(0, LIMITS.atRisk);
|
|
158
|
+
const changed = [...new Set((i.changed ?? []).map((p) => toRepoRelative(p, i.root)).filter((p) => !!p))].slice(0, LIMITS.changed);
|
|
159
|
+
const nextStep = s(x.nextStep, LIMITS.nextStep);
|
|
160
|
+
const rc = s(x.riskCategory, 40);
|
|
161
|
+
const riskCategory = rc ? scrub(rc) : undefined;
|
|
162
|
+
const raw = {
|
|
163
|
+
target,
|
|
164
|
+
...(i.repo ? { repo: i.repo } : {}),
|
|
165
|
+
riskLevel,
|
|
166
|
+
riskSummary: scrub(s(x.riskSummary, LIMITS.riskSummary) ?? "No risk summary."),
|
|
167
|
+
...(riskCategory ? { riskCategory } : {}),
|
|
168
|
+
atRisk,
|
|
169
|
+
files,
|
|
170
|
+
...(changed.length ? { changed } : {}),
|
|
171
|
+
symbols,
|
|
172
|
+
components,
|
|
173
|
+
...(Object.keys(counts).length ? { counts } : {}),
|
|
174
|
+
...(x.graph !== undefined ? { graphDegraded: true } : {}),
|
|
175
|
+
...(nextStep ? { nextStep: scrub(nextStep) } : {}),
|
|
176
|
+
};
|
|
177
|
+
const body = parseImpactBody(raw);
|
|
178
|
+
return { body, fallback: impactFallback(body) };
|
|
179
|
+
}
|
|
180
|
+
export function renderImpact(b, from) {
|
|
181
|
+
const files = b.files.slice(0, 15);
|
|
182
|
+
const comps = b.components.slice(0, 8).map((c) => `${line(c.name, LIMITS.region)} (${c.count})`);
|
|
183
|
+
const parts = [
|
|
184
|
+
`change to ${line(b.target.kind, LIMITS.kind)} ${line(b.target.name, NAME_MAX)}${b.repo ? ` in ${line(b.repo.remote, LIMITS.remote)}` : ""}`,
|
|
185
|
+
`risk ${b.riskLevel}: ${line(b.riskSummary, LIMITS.riskSummary)}`,
|
|
186
|
+
b.atRisk.length ? `at risk: ${b.atRisk.slice(0, 5).map((a) => line(a, LIMITS.atRiskItem)).join("; ")}` : undefined,
|
|
187
|
+
comps.length ? `components: ${comps.join(", ")}` : undefined,
|
|
188
|
+
files.length ? `files: ${files.join(", ")}${b.files.length > files.length ? `, +${b.files.length - files.length} more` : ""}` : undefined,
|
|
189
|
+
b.graphDegraded ? "the sender's graph is degraded, so counts are a floor" : undefined,
|
|
190
|
+
].filter(Boolean);
|
|
191
|
+
return {
|
|
192
|
+
type: "impact",
|
|
193
|
+
target: { name: line(b.target.name, NAME_MAX), kind: line(b.target.kind, LIMITS.kind) },
|
|
194
|
+
...(b.repo ? { repo: b.repo } : {}),
|
|
195
|
+
riskLevel: b.riskLevel,
|
|
196
|
+
riskSummary: line(b.riskSummary, LIMITS.riskSummary),
|
|
197
|
+
...(b.riskCategory ? { riskCategory: line(b.riskCategory, 40) } : {}),
|
|
198
|
+
atRisk: b.atRisk.map((a) => line(a, LIMITS.atRiskItem)),
|
|
199
|
+
files: b.files,
|
|
200
|
+
...(b.changed ? { changed: b.changed } : {}),
|
|
201
|
+
symbols: b.symbols.map((m) => ({ name: line(m.name, NAME_MAX), kind: line(m.kind, LIMITS.kind), ...(m.path ? { path: m.path } : {}), ...(m.callers !== undefined ? { callers: m.callers } : {}) })),
|
|
202
|
+
components: b.components.map((c) => ({ name: line(c.name, LIMITS.region), ...(c.kind ? { kind: line(c.kind, LIMITS.kind) } : {}), count: c.count })),
|
|
203
|
+
...(b.counts ? { counts: b.counts } : {}),
|
|
204
|
+
...(b.graphDegraded ? { graphDegraded: true } : {}),
|
|
205
|
+
...(b.nextStep ? { nextStep: line(b.nextStep, LIMITS.nextStep) } : {}),
|
|
206
|
+
digest: frame(from.address, "Ix blast-radius report", parts.join("; ")),
|
|
207
|
+
};
|
|
208
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { extension, createIxExtension, receiveIx, ixCommands, KINDS, VERSION, type Deps } from "./extension.js";
|
|
2
|
+
export { NOTE_KIND, parseNoteBody, buildNote, renderNote, noteFallback, type NoteBody, type NoteInput } from "./note.js";
|
|
3
|
+
export { SUBGRAPH_KIND, parseSubgraphBody, parseSelector, buildSubgraph, renderSubgraph, subgraphFallback, resolveArgv, describeSelector, splitPattern, type SubgraphBody, type Selector, type SubgraphInput, } from "./subgraph.js";
|
|
4
|
+
export { IMPACT_KIND, parseImpactBody, buildImpact, renderImpact, impactFallback, type ImpactBody, type ImpactInput, type ImpactSymbol, type ImpactComponent } from "./impact.js";
|
|
5
|
+
export { semanticConflicts, ixNeighbourhood, parseAround, type SemanticConflict, type PeerChanges, type Neighbourhood, type NeighbourhoodFn, type Relation, type ConflictOptions } from "./conflicts.js";
|
|
6
|
+
export { ixRunner, ixAvailable, ixJson, type IxRunner, type IxResult } from "./ix.js";
|
|
7
|
+
export { normalizeRemote, parseRepo, localRepo, compareRepo, type RepoRef, type LocalRepo } from "./repo.js";
|
|
8
|
+
export { SPEC_VERSION, MAX_BODY_BYTES, LIMITS, NOTE_TAGS, RISK_LEVELS, InvalidBody, IxExtError, toRepoRelative, scrubPaths, type NoteTag, type RiskLevel } from "./text.js";
|
|
9
|
+
export { FOOTPRINT_KIND, FOOTPRINT_TTL, MAX_FOOTPRINT_BYTES, FP_LIMITS, parseFootprintBody, assembleFootprint, footprintFallback, footprintDigest, symbolKey, wireQualifiedKey, type FootprintBody, type FpActor, type FpComponent, type RawActor, } from "./footprint.js";
|
|
10
|
+
export { computeFootprint, parseUnifiedDiff, groupRanges, parseWorktrees, declaredNames, type ComputeInput, type ComputeDeps, type ComputeResult } from "./footprint-compute.js";
|
|
11
|
+
export { footprintNames, FOOTPRINT_MIN_INTERVAL_MS, FOOTPRINT_KEEPALIVE_MS, type FootprintConfig } from "./footprint-command.js";
|
|
12
|
+
export { deriveNameKey, pickRootCommit, hashFile, hashSymbol, hashRegion, type NameKey } from "./hmac.js";
|
|
13
|
+
export { computeOverlaps, OVERLAP_TIERS, type Overlap, type OverlapPeer, type OverlapTier, type OverlapSeverity, type OverlapDirection } from "./overlap.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Copyright 2026 Ix Infrastructure Inc.
|
|
2
|
+
//
|
|
3
|
+
// @peer2peer/ext-ix: the Ix extension for Peer2Peer v3 (SPEC.md). `p2p`
|
|
4
|
+
// loads `extension` when this package is installed; the rest is the library
|
|
5
|
+
// (send helpers that build bodies from Ix output, receive helpers that
|
|
6
|
+
// validate, sanitize and render, and semantic-conflict detection) for other
|
|
7
|
+
// clients such as the Claude Code mod.
|
|
8
|
+
export { extension, createIxExtension, receiveIx, ixCommands, KINDS, VERSION } from "./extension.js";
|
|
9
|
+
export { NOTE_KIND, parseNoteBody, buildNote, renderNote, noteFallback } from "./note.js";
|
|
10
|
+
export { SUBGRAPH_KIND, parseSubgraphBody, parseSelector, buildSubgraph, renderSubgraph, subgraphFallback, resolveArgv, describeSelector, splitPattern, } from "./subgraph.js";
|
|
11
|
+
export { IMPACT_KIND, parseImpactBody, buildImpact, renderImpact, impactFallback } from "./impact.js";
|
|
12
|
+
export { semanticConflicts, ixNeighbourhood, parseAround } from "./conflicts.js";
|
|
13
|
+
export { ixRunner, ixAvailable, ixJson } from "./ix.js";
|
|
14
|
+
export { normalizeRemote, parseRepo, localRepo, compareRepo } from "./repo.js";
|
|
15
|
+
export { SPEC_VERSION, MAX_BODY_BYTES, LIMITS, NOTE_TAGS, RISK_LEVELS, InvalidBody, IxExtError, toRepoRelative, scrubPaths } from "./text.js";
|
|
16
|
+
export { FOOTPRINT_KIND, FOOTPRINT_TTL, MAX_FOOTPRINT_BYTES, FP_LIMITS, parseFootprintBody, assembleFootprint, footprintFallback, footprintDigest, symbolKey, wireQualifiedKey, } from "./footprint.js";
|
|
17
|
+
export { computeFootprint, parseUnifiedDiff, groupRanges, parseWorktrees, declaredNames } from "./footprint-compute.js";
|
|
18
|
+
export { footprintNames, FOOTPRINT_MIN_INTERVAL_MS, FOOTPRINT_KEEPALIVE_MS } from "./footprint-command.js";
|
|
19
|
+
export { deriveNameKey, pickRootCommit, hashFile, hashSymbol, hashRegion } from "./hmac.js";
|
|
20
|
+
export { computeOverlaps, OVERLAP_TIERS } from "./overlap.js";
|
package/dist/ix.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface IxResult {
|
|
2
|
+
code: number;
|
|
3
|
+
stdout: string;
|
|
4
|
+
stderr: string;
|
|
5
|
+
}
|
|
6
|
+
export interface IxRunner {
|
|
7
|
+
run(argv: readonly string[], opts?: {
|
|
8
|
+
stdin?: string;
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
cwd?: string;
|
|
11
|
+
}): Promise<IxResult>;
|
|
12
|
+
}
|
|
13
|
+
export declare const IX_TIMEOUT_MS = 30000;
|
|
14
|
+
export declare function ixRunner(opts?: {
|
|
15
|
+
env?: Record<string, string | undefined>;
|
|
16
|
+
cwd?: string;
|
|
17
|
+
}): IxRunner;
|
|
18
|
+
export declare function ixAvailable(ix: IxRunner): Promise<boolean>;
|
|
19
|
+
/** Runs and parses JSON output; a failure is an IxExtError naming the command. */
|
|
20
|
+
export declare function ixJson(ix: IxRunner, argv: readonly string[]): Promise<unknown>;
|
package/dist/ix.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Copyright 2026 Ix Infrastructure Inc.
|
|
2
|
+
//
|
|
3
|
+
// Running the local Ix CLI (`ix`, or IX_BIN). Always by argv with no shell,
|
|
4
|
+
// with a timeout and an output cap; every argument that came from a peer has
|
|
5
|
+
// been validated against a strict pattern first (subgraph.ts), and never
|
|
6
|
+
// starts with "-", so it can't be read as an option.
|
|
7
|
+
//
|
|
8
|
+
// Commands this extension uses (Ix CLI 0.12; output shapes in SPEC.md §6):
|
|
9
|
+
// ix --version is Ix installed
|
|
10
|
+
// ix impact <target> --format json [--kind k] [--path p] [--depth n] [--limit n]
|
|
11
|
+
// ix around <path> --format json [--limit n] callers / users / tests / importers of a file
|
|
12
|
+
// ix note show <id> --json read a note (Ix Pro memory layer)
|
|
13
|
+
// ix note [--tag t] [--session s] [--actor a] --json < text write a note (user-consented import only)
|
|
14
|
+
// ix overview <file> --format llm resolve a subgraph: one file
|
|
15
|
+
// ix inventory --kind file --path <prefix> --format llm --limit n a directory
|
|
16
|
+
// ix context <symbol> --format llm [--kind k] [--path p] a symbol
|
|
17
|
+
// ix subsystems --target <region> --format llm an architecture region
|
|
18
|
+
// ix status --format json [--root <dir>] is a checkout mapped (footprint)
|
|
19
|
+
// ix around <path>:<start>-<end> --format json the definitions an edit touched, and their dependents (footprint)
|
|
20
|
+
// ix overview <file> --format json a file's key items (footprint, coarse fallback)
|
|
21
|
+
import { execFile } from "node:child_process";
|
|
22
|
+
import { IxExtError } from "./text.js";
|
|
23
|
+
import { whichAbsolute } from "./which.js";
|
|
24
|
+
export const IX_TIMEOUT_MS = 30_000;
|
|
25
|
+
const MAX_OUTPUT = 8 * 1024 * 1024;
|
|
26
|
+
/** Lines the CLI prints about its own plugins, not about the request. */
|
|
27
|
+
const NOISE = /^ix: failed to load [^\n]*$/gm;
|
|
28
|
+
export function ixRunner(opts = {}) {
|
|
29
|
+
const env = { ...process.env, ...opts.env };
|
|
30
|
+
// Never a secret of p2p's (packages/p2p/src/projects.ts: the person token), whatever the caller passed.
|
|
31
|
+
delete env.P2P_PERSON_TOKEN;
|
|
32
|
+
const name = env.IX_BIN?.trim() || "ix";
|
|
33
|
+
// Absolute, from PATH's absolute entries: never a program planted in the repo (cwd).
|
|
34
|
+
const bin = whichAbsolute(name, env);
|
|
35
|
+
return {
|
|
36
|
+
run: (argv, o = {}) => new Promise((resolve, reject) => {
|
|
37
|
+
if (!bin)
|
|
38
|
+
return reject(new IxExtError("ix_missing", `Ix isn't installed (no \`${name}\` on PATH): https://github.com/ix-infrastructure/Ix`));
|
|
39
|
+
const child = execFile(bin, [...argv], { cwd: o.cwd ?? opts.cwd, env, timeout: o.timeoutMs ?? IX_TIMEOUT_MS, killSignal: "SIGKILL", maxBuffer: MAX_OUTPUT, windowsHide: true }, (err, stdout, stderr) => {
|
|
40
|
+
const e = err;
|
|
41
|
+
if (e && e.code === "ENOENT")
|
|
42
|
+
return reject(new IxExtError("ix_missing", `Ix isn't installed (no \`${bin}\` on PATH): https://github.com/ix-infrastructure/Ix`));
|
|
43
|
+
if (e && e.killed)
|
|
44
|
+
return reject(new IxExtError("ix_timeout", `ix ${argv[0] ?? ""} took longer than ${Math.round((o.timeoutMs ?? IX_TIMEOUT_MS) / 1000)} s`));
|
|
45
|
+
const code = e ? (typeof e.code === "number" ? e.code : 1) : 0;
|
|
46
|
+
resolve({ code, stdout: String(stdout), stderr: String(stderr).replace(NOISE, "").trim() });
|
|
47
|
+
});
|
|
48
|
+
if (o.stdin !== undefined)
|
|
49
|
+
child.stdin?.end(o.stdin);
|
|
50
|
+
else
|
|
51
|
+
child.stdin?.end();
|
|
52
|
+
}),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** Whether `ix` runs at all (cached per runner). */
|
|
56
|
+
const availability = new WeakMap();
|
|
57
|
+
export function ixAvailable(ix) {
|
|
58
|
+
let p = availability.get(ix);
|
|
59
|
+
if (!p) {
|
|
60
|
+
p = ix.run(["--version"], { timeoutMs: 10_000 }).then((r) => r.code === 0, () => false);
|
|
61
|
+
availability.set(ix, p);
|
|
62
|
+
}
|
|
63
|
+
return p;
|
|
64
|
+
}
|
|
65
|
+
/** Runs and parses JSON output; a failure is an IxExtError naming the command. */
|
|
66
|
+
export async function ixJson(ix, argv) {
|
|
67
|
+
const r = await ix.run(argv);
|
|
68
|
+
if (r.code !== 0)
|
|
69
|
+
throw new IxExtError("ix_failed", `ix ${argv[0]} failed (exit ${r.code})${r.stderr ? `: ${r.stderr.slice(0, 300)}` : ""}`);
|
|
70
|
+
try {
|
|
71
|
+
return JSON.parse(r.stdout);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
throw new IxExtError("ix_failed", `ix ${argv[0]} didn't print JSON`);
|
|
75
|
+
}
|
|
76
|
+
}
|
package/dist/note.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type RepoRef } from "./repo.js";
|
|
2
|
+
import { type NoteTag, type Roots } from "./text.js";
|
|
3
|
+
export declare const NOTE_KIND: "x:ix.note";
|
|
4
|
+
export interface NoteBody {
|
|
5
|
+
tag: NoteTag;
|
|
6
|
+
text: string;
|
|
7
|
+
title?: string;
|
|
8
|
+
/** The sender's Ix session name (a label; nothing on the receiver resolves it). */
|
|
9
|
+
session?: string;
|
|
10
|
+
repo?: RepoRef;
|
|
11
|
+
/** Repo-relative paths the note is about. */
|
|
12
|
+
refs?: string[];
|
|
13
|
+
/** When the note was written (ISO 8601). */
|
|
14
|
+
at?: string;
|
|
15
|
+
}
|
|
16
|
+
/** Validates a received (or about-to-be-sent) note body. Unknown fields are dropped. */
|
|
17
|
+
export declare function parseNoteBody(v: unknown): NoteBody;
|
|
18
|
+
export declare function noteFallback(b: Pick<NoteBody, "tag">): string;
|
|
19
|
+
export interface NoteInput {
|
|
20
|
+
text: string;
|
|
21
|
+
tag?: string;
|
|
22
|
+
title?: string;
|
|
23
|
+
session?: string;
|
|
24
|
+
refs?: string[];
|
|
25
|
+
repo?: RepoRef;
|
|
26
|
+
at?: string;
|
|
27
|
+
/** For scrubbing: the repo root and home directory (never sent). */
|
|
28
|
+
root?: Roots;
|
|
29
|
+
home?: string;
|
|
30
|
+
hostname?: string;
|
|
31
|
+
}
|
|
32
|
+
/** Sending: a validated body and its fallback, with local paths scrubbed and refs made repo-relative. */
|
|
33
|
+
export declare function buildNote(i: NoteInput): {
|
|
34
|
+
body: NoteBody;
|
|
35
|
+
fallback: string;
|
|
36
|
+
};
|
|
37
|
+
/** Receiving: the model-safe digest, framed as data from the named peer. */
|
|
38
|
+
export declare function renderNote(b: NoteBody, from: {
|
|
39
|
+
address: string;
|
|
40
|
+
}): Record<string, unknown>;
|
package/dist/note.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Copyright 2026 Ix Infrastructure Inc.
|
|
2
|
+
//
|
|
3
|
+
// x:ix.note: an Ix session note shared with a peer session (SPEC.md §3).
|
|
4
|
+
// The receiver's agent may preview it; writing it into the receiver's graph
|
|
5
|
+
// is a separate action only the user can take (`p2p ix import`), after
|
|
6
|
+
// seeing it.
|
|
7
|
+
import { parseRepo } from "./repo.js";
|
|
8
|
+
import { cleanMultiline, cps, fail, frame, isObj, jsonBytes, LIMITS, line, list, MAX_BODY_BYTES, NOTE_TAGS, oneOf, optStr, relPath, scrubPaths, toRepoRelative, } from "./text.js";
|
|
9
|
+
export const NOTE_KIND = "x:ix.note";
|
|
10
|
+
const ISO_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?(?:Z|[+-]\d{2}:\d{2})$/;
|
|
11
|
+
/** Validates a received (or about-to-be-sent) note body. Unknown fields are dropped. */
|
|
12
|
+
export function parseNoteBody(v) {
|
|
13
|
+
if (!isObj(v))
|
|
14
|
+
return fail("note body must be an object");
|
|
15
|
+
const o = v;
|
|
16
|
+
if (jsonBytes(o) > MAX_BODY_BYTES)
|
|
17
|
+
fail(`note body is larger than ${MAX_BODY_BYTES} bytes`);
|
|
18
|
+
const tag = oneOf(o, "tag", NOTE_TAGS, "note");
|
|
19
|
+
if (typeof o.text !== "string")
|
|
20
|
+
fail("note.text must be a string");
|
|
21
|
+
const text = cleanMultiline(o.text);
|
|
22
|
+
if (text === "")
|
|
23
|
+
fail("note.text is empty");
|
|
24
|
+
if (Buffer.byteLength(text, "utf8") > LIMITS.noteText)
|
|
25
|
+
fail(`note.text is larger than ${LIMITS.noteText} bytes`);
|
|
26
|
+
const title = optStr(o, "title", LIMITS.title, "note");
|
|
27
|
+
const session = optStr(o, "session", LIMITS.session, "note");
|
|
28
|
+
const repo = o.repo === undefined ? undefined : parseRepo(o.repo, "note.repo");
|
|
29
|
+
const refs = list(o, "refs", LIMITS.refs, "note", (x, i) => relPath(x, `note.refs[${i}]`));
|
|
30
|
+
const at = optStr(o, "at", 40, "note");
|
|
31
|
+
if (at !== undefined && !ISO_RE.test(at))
|
|
32
|
+
fail("note.at must be an ISO 8601 time");
|
|
33
|
+
return {
|
|
34
|
+
tag,
|
|
35
|
+
text,
|
|
36
|
+
...(title ? { title } : {}),
|
|
37
|
+
...(session ? { session } : {}),
|
|
38
|
+
...(repo ? { repo } : {}),
|
|
39
|
+
...(refs.length ? { refs } : {}),
|
|
40
|
+
...(at ? { at } : {}),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export function noteFallback(b) {
|
|
44
|
+
const what = b.tag === "note" ? "an Ix note" : `an Ix ${b.tag} note`;
|
|
45
|
+
return `shared ${what}: install Ix to open it: https://github.com/ix-infrastructure/Ix`;
|
|
46
|
+
}
|
|
47
|
+
/** Sending: a validated body and its fallback, with local paths scrubbed and refs made repo-relative. */
|
|
48
|
+
export function buildNote(i) {
|
|
49
|
+
const tag = NOTE_TAGS.includes(i.tag ?? "note") ? (i.tag ?? "note") : fail(`--tag must be one of ${NOTE_TAGS.join(", ")}`);
|
|
50
|
+
const scrub = (s) => scrubPaths(s, { root: i.root, home: i.home, hostname: i.hostname });
|
|
51
|
+
const refs = (i.refs ?? []).map((r) => toRepoRelative(r, i.root)).filter((r) => r !== undefined);
|
|
52
|
+
const raw = {
|
|
53
|
+
tag,
|
|
54
|
+
text: scrub(i.text),
|
|
55
|
+
...(i.title ? { title: scrub(i.title).trim().slice(0, LIMITS.title) } : {}),
|
|
56
|
+
...(i.session ? { session: scrub(i.session).trim().slice(0, LIMITS.session) } : {}),
|
|
57
|
+
...(i.repo ? { repo: i.repo } : {}),
|
|
58
|
+
...(refs.length ? { refs: [...new Set(refs)].slice(0, LIMITS.refs) } : {}),
|
|
59
|
+
...(i.at ? { at: i.at } : {}),
|
|
60
|
+
};
|
|
61
|
+
const body = parseNoteBody(raw);
|
|
62
|
+
return { body, fallback: noteFallback(body) };
|
|
63
|
+
}
|
|
64
|
+
/** Receiving: the model-safe digest, framed as data from the named peer. */
|
|
65
|
+
export function renderNote(b, from) {
|
|
66
|
+
const text = line(b.text, LIMITS.digestText);
|
|
67
|
+
const truncated = cps(line(b.text, LIMITS.noteText)) > cps(text);
|
|
68
|
+
const head = [b.title ? `"${line(b.title, LIMITS.title)}"` : undefined, b.session ? `from Ix session ${line(b.session, LIMITS.session)}` : undefined].filter(Boolean).join(" ");
|
|
69
|
+
return {
|
|
70
|
+
type: "note",
|
|
71
|
+
tag: b.tag,
|
|
72
|
+
...(b.title ? { title: line(b.title, LIMITS.title) } : {}),
|
|
73
|
+
...(b.session ? { session: line(b.session, LIMITS.session) } : {}),
|
|
74
|
+
...(b.repo ? { repo: b.repo } : {}),
|
|
75
|
+
...(b.refs ? { refs: b.refs } : {}),
|
|
76
|
+
...(b.at ? { at: b.at } : {}),
|
|
77
|
+
text,
|
|
78
|
+
...(truncated ? { truncated: true } : {}),
|
|
79
|
+
digest: frame(from.address, `Ix ${b.tag} note`, `${head ? `${head}: ` : ""}${text}${truncated ? " …" : ""}`),
|
|
80
|
+
consent: "Preview only. It is written into the local Ix graph only if the user runs `p2p ix import <event id>` themselves.",
|
|
81
|
+
};
|
|
82
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ExtContext, ExtPeer } from "@peer2peer/cli";
|
|
2
|
+
import { type SemanticConflict } from "./conflicts.js";
|
|
3
|
+
import type { Here } from "./extension.js";
|
|
4
|
+
import { type FootprintBody } from "./footprint.js";
|
|
5
|
+
import type { NameKey } from "./hmac.js";
|
|
6
|
+
import { type IxRunner } from "./ix.js";
|
|
7
|
+
import { type Overlap } from "./overlap.js";
|
|
8
|
+
import type { RepoRef } from "./repo.js";
|
|
9
|
+
export interface OverlapsResult {
|
|
10
|
+
overlaps: Overlap[];
|
|
11
|
+
skipped: {
|
|
12
|
+
peer: {
|
|
13
|
+
own: string;
|
|
14
|
+
sid: string;
|
|
15
|
+
address: string;
|
|
16
|
+
};
|
|
17
|
+
reason: string;
|
|
18
|
+
}[];
|
|
19
|
+
/** Live peer sessions with a footprint compared. */
|
|
20
|
+
checked: number;
|
|
21
|
+
/** Live peer sessions without one (for the `ix around` fallback). */
|
|
22
|
+
withoutFootprint: ExtPeer[];
|
|
23
|
+
note?: string;
|
|
24
|
+
}
|
|
25
|
+
/** The users a session's status reaches, and this user: whose sessions it may be compared with. */
|
|
26
|
+
export declare function audienceOf(ctx: ExtContext, sid: string, self: string): Promise<Set<string>>;
|
|
27
|
+
export declare function overlapsFor(ctx: ExtContext, sid: string, h: {
|
|
28
|
+
readMine(live: readonly string[]): Promise<FootprintBody | undefined>;
|
|
29
|
+
repo(): Promise<Here>;
|
|
30
|
+
nameKey(root: string, ref: RepoRef, env: NodeJS.ProcessEnv): Promise<{
|
|
31
|
+
key: NameKey;
|
|
32
|
+
} | {
|
|
33
|
+
why: string;
|
|
34
|
+
}>;
|
|
35
|
+
}): Promise<OverlapsResult>;
|
|
36
|
+
/** Peers without a footprint: today's semantic-conflict check (`ix around`) on their status files. */
|
|
37
|
+
export declare function conflictPeersWithoutFootprint(ctx: ExtContext, sid: string, peers: ExtPeer[], ix: IxRunner): Promise<SemanticConflict[]>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Copyright 2026 Ix Infrastructure Inc.
|
|
2
|
+
//
|
|
3
|
+
// `p2p ix overlaps` (SPEC.md §9): this session's footprint against the live
|
|
4
|
+
// peer sessions' stored footprints, and, for peers without one, today's
|
|
5
|
+
// `ix around` check on their status files.
|
|
6
|
+
import { ixNeighbourhood, semanticConflicts } from "./conflicts.js";
|
|
7
|
+
import { FOOTPRINT_KIND, parseFootprintBody } from "./footprint.js";
|
|
8
|
+
import { ixAvailable } from "./ix.js";
|
|
9
|
+
import { computeOverlaps } from "./overlap.js";
|
|
10
|
+
import { InvalidBody } from "./text.js";
|
|
11
|
+
function parsed(v) {
|
|
12
|
+
if (v === undefined)
|
|
13
|
+
return undefined;
|
|
14
|
+
try {
|
|
15
|
+
return parseFootprintBody(v);
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
if (e instanceof InvalidBody)
|
|
19
|
+
return undefined;
|
|
20
|
+
throw e;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** The users a session's status reaches, and this user: whose sessions it may be compared with. */
|
|
24
|
+
export async function audienceOf(ctx, sid, self) {
|
|
25
|
+
const aud = ctx.audience ? await ctx.audience(sid).catch(() => undefined) : undefined;
|
|
26
|
+
return new Set([self, ...(aud?.members ?? [])]);
|
|
27
|
+
}
|
|
28
|
+
export async function overlapsFor(ctx, sid, h) {
|
|
29
|
+
const rows = await ctx.peers();
|
|
30
|
+
const self = await ctx.self();
|
|
31
|
+
const isThis = (r) => r.own === self.userId && r.sid === sid;
|
|
32
|
+
const me = rows.find(isThis);
|
|
33
|
+
// My own names when this device computed them; else what this session published.
|
|
34
|
+
// (Own sessions still live on this device: the readable bodies of ended ones are pruned.)
|
|
35
|
+
const live = rows.filter((r) => r.own === self.userId && r.thisDevice && r.live).map((r) => r.sid);
|
|
36
|
+
const mine = parsed(await h.readMine(live.includes(sid) ? live : [...live, sid])) ?? parsed(me?.xstate?.[FOOTPRINT_KIND]?.body);
|
|
37
|
+
// Project boundaries (the CLI's projects.ts): only sessions this one's status reaches, and this
|
|
38
|
+
// user's own. A session in a private project compares with nobody else's; one in a shared project
|
|
39
|
+
// only with those its project shares (who see this session too). An audience that can't be read
|
|
40
|
+
// fails closed: own sessions only.
|
|
41
|
+
const reach = await audienceOf(ctx, sid, self.userId);
|
|
42
|
+
const others = rows.filter((r) => r.live && !isThis(r) && reach.has(r.own));
|
|
43
|
+
const withFp = [];
|
|
44
|
+
const withoutFootprint = [];
|
|
45
|
+
for (const r of others) {
|
|
46
|
+
const body = parsed(r.xstate?.[FOOTPRINT_KIND]?.body);
|
|
47
|
+
if (!body) {
|
|
48
|
+
withoutFootprint.push(r);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
withFp.push({ own: r.own, sid: r.sid, ref: r.ref, address: r.address, body });
|
|
52
|
+
}
|
|
53
|
+
if (!mine)
|
|
54
|
+
return { overlaps: [], skipped: [], checked: withFp.length, withoutFootprint, note: "This session has no footprint yet (`p2p ix footprint`)." };
|
|
55
|
+
let key;
|
|
56
|
+
if (mine.names === "hmac" || withFp.some((p) => p.body.names === "hmac")) {
|
|
57
|
+
const here = await h.repo();
|
|
58
|
+
if (here.root && here.ref && here.ref.remote === mine.repo.remote) {
|
|
59
|
+
const k = await h.nameKey(here.root, here.ref, { ...process.env, ...ctx.env });
|
|
60
|
+
if ("key" in k)
|
|
61
|
+
key = k.key;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// What my status already shares in the clear (a hashed overlap's line may name only these files).
|
|
65
|
+
const own = await ctx.ownStatus(sid);
|
|
66
|
+
const statusFiles = [...(own?.files ?? []), ...(own?.agents ?? []).flatMap((a) => (a.wt ? [] : (a.files ?? [])))];
|
|
67
|
+
// Who my status reaches (a peer outside it may still share theirs with me, and so be in peers()).
|
|
68
|
+
const aud = ctx.audience ? await ctx.audience(sid).catch(() => undefined) : undefined;
|
|
69
|
+
const statusAudience = [self.userId, ...(aud?.members ?? [])];
|
|
70
|
+
const publishedNames = parsed(me?.xstate?.[FOOTPRINT_KIND]?.body)?.names ?? "hmac";
|
|
71
|
+
const r = computeOverlaps({ mine, peers: withFp, statusFiles, statusAudience, publishedNames, ...(key ? { key } : {}) });
|
|
72
|
+
return { ...r, checked: withFp.length, withoutFootprint };
|
|
73
|
+
}
|
|
74
|
+
/** Peers without a footprint: today's semantic-conflict check (`ix around`) on their status files. */
|
|
75
|
+
export async function conflictPeersWithoutFootprint(ctx, sid, peers, ix) {
|
|
76
|
+
const own = await ctx.ownStatus(sid);
|
|
77
|
+
if (!own || own.files.length === 0 || !(await ixAvailable(ix)))
|
|
78
|
+
return [];
|
|
79
|
+
const r = await semanticConflicts({ mine: own.files, peers, ...(own.repo ? { repo: own.repo } : {}), neighbourhood: ixNeighbourhood(ix) });
|
|
80
|
+
return r.conflicts;
|
|
81
|
+
}
|