@peer2peer/ext-ix 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +79 -2
- package/SPEC.md +785 -0
- package/dist/conflicts.d.ts +64 -0
- package/dist/conflicts.js +188 -0
- package/dist/extension.d.ts +45 -0
- package/dist/extension.js +615 -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 +14 -0
- package/dist/index.js +21 -0
- package/dist/ix.d.ts +158 -0
- package/dist/ix.js +420 -0
- package/dist/listener.d.ts +48 -0
- package/dist/listener.js +203 -0
- package/dist/memory.d.ts +50 -0
- package/dist/memory.js +315 -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/SPEC.md
ADDED
|
@@ -0,0 +1,785 @@
|
|
|
1
|
+
# The Ix extension (`ix` namespace), v1
|
|
2
|
+
|
|
3
|
+
This is the specification of the kinds registered for the `ix` namespace in
|
|
4
|
+
`docs/protocol.md` §8.3: `x:ix.note`, `x:ix.subgraph`, `x:ix.impact` and the
|
|
5
|
+
state kind `x:ix.footprint` (§8). It also covers what the receiver does with
|
|
6
|
+
them, both with Ix installed and without it, and how semantic conflicts are
|
|
7
|
+
detected. The reference
|
|
8
|
+
implementation is this package, `@peer2peer/ext-ix`.
|
|
9
|
+
|
|
10
|
+
The extension changes no core rule (§2–§5).
|
|
11
|
+
- **Authorisation:** these kinds are session kinds, so §4.2 decides who may
|
|
12
|
+
send and receive them, exactly as it does for `msg`.
|
|
13
|
+
- **Information only:** nothing in a body grants anything. Received content
|
|
14
|
+
is information for the user and their agent.
|
|
15
|
+
|
|
16
|
+
## 1. Envelope
|
|
17
|
+
|
|
18
|
+
Each kind is a §4.3 extension kind with this plaintext:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
{ ext: { v: 1, body: <the kind's body> }, fallback: "<≤200 chars>", roster?: <jws> }
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**Version (`ext.v`):**
|
|
25
|
+
- This document is v1.
|
|
26
|
+
- An incompatible change bumps `v`.
|
|
27
|
+
- Within a version, a new field is optional, and older receivers ignore it.
|
|
28
|
+
Receivers drop fields they don't know and keep validating the rest.
|
|
29
|
+
- A receiver that gets a `v` it doesn't know shows the fallback, with the
|
|
30
|
+
reason "newer than this ext-ix".
|
|
31
|
+
|
|
32
|
+
**Size:**
|
|
33
|
+
- `body` serialized as JSON: at most **20 KiB** (`MAX_BODY_BYTES`).
|
|
34
|
+
- `{v, body}` together: at most 24 KiB, which `p2p` enforces. This is the
|
|
35
|
+
same budget as a `msg` text. It leaves room in the 64 KiB sealed envelope
|
|
36
|
+
(§4.1) for the roster, the certificate and two layers of base64.
|
|
37
|
+
- Each field has its own cap (below). A body over any cap is invalid.
|
|
38
|
+
|
|
39
|
+
**Strings:**
|
|
40
|
+
- Every string in a received body is untrusted peer text (§4.3).
|
|
41
|
+
- It is validated against its cap and pattern on arrival.
|
|
42
|
+
- It passes core's single sanitizer before a person or a model sees it. The
|
|
43
|
+
only exception is a note's `text`, which stays multi-line for `show` and
|
|
44
|
+
`import`. Even that text has its C0/C1/Cf controls and U+2028/9 stripped.
|
|
45
|
+
|
|
46
|
+
**Paths:**
|
|
47
|
+
- Every path is repo-relative and follows core's `files` rule: no leading `/`
|
|
48
|
+
or `\`, no `:`, and no empty, `.` or `..` segment.
|
|
49
|
+
- When sending:
|
|
50
|
+
- an absolute path under the repository root is made relative;
|
|
51
|
+
- any other absolute path is dropped;
|
|
52
|
+
- free text (note text and title, subgraph title and why, and every
|
|
53
|
+
impact string including target, symbol and component names) has the
|
|
54
|
+
repository root replaced by `.`; the home directory and other home-like
|
|
55
|
+
prefixes (`/Users/x`, `/home/x`, `/root`, `C:\Users\x`) by `~`; other
|
|
56
|
+
local locations (`/tmp`, `/private/var`, `/var/folders`, `/Volumes/x`,
|
|
57
|
+
`/mnt/x`, UNC `\\host\share`) by `…`; e-mail addresses by `[email]`;
|
|
58
|
+
and this machine's host name by `[host]`;
|
|
59
|
+
- an absolute `p2p ix impact` target becomes repo-relative, or is refused.
|
|
60
|
+
- A received absolute path makes the body invalid.
|
|
61
|
+
|
|
62
|
+
**Repo identity (`RepoRef`):**
|
|
63
|
+
- Shape: `{remote, rev?, branch?}`.
|
|
64
|
+
- `remote` is the normalized origin remote: `host/owner/name`, lower case,
|
|
65
|
+
with no scheme, user, token, port or `.git`. A local path or a `file:` URL
|
|
66
|
+
is never a remote.
|
|
67
|
+
- `rev` is a commit id of 7–64 hex characters.
|
|
68
|
+
- `branch` matches `[A-Za-z0-9._/+@-]{1,128}`.
|
|
69
|
+
|
|
70
|
+
## 2. Consent and safety
|
|
71
|
+
|
|
72
|
+
| | Who starts it | What runs |
|
|
73
|
+
|---|---|---|
|
|
74
|
+
| Receiving any kind | (automatic) | Validate, sanitize and render. **No Ix call, no write.** |
|
|
75
|
+
| Preview (`p2p watch`, `p2p ix inbox`, `p2p ix show`) | the user or their agent | Reads the local event log |
|
|
76
|
+
| `p2p ix import <event>` | **the user** | One OSS `ix note` write into the **local** graph (§2.1), after the **full** title and text were shown and the user said y; or with `--yes`, only if the user read that same note (same title and text) with `p2p ix show` at a terminal. Refused before anything is asked when the graph target isn't local, when Ix Pro answers `ix note` (the cloud org), or when this Ix has no local `ix note` ("upgrade Ix") |
|
|
77
|
+
| Graph memory (`p2p watch`) | (automatic, the user's own sessions) | The session's record, status lines and edited files into the **local** graph only (§10). Never a peer's content |
|
|
78
|
+
| `p2p ix resolve <event>` | **the user** | One read-only `ix` query of their own graph, after a y/N prompt or `--yes`; with `--shown=<bodyHash>` (from `show --json`) only if the reference is still the one a client displayed |
|
|
79
|
+
|
|
80
|
+
- A received note is **never** written into the graph automatically (§4.3:
|
|
81
|
+
"an extension MUST ask its user before acting on received content outside
|
|
82
|
+
the conversation").
|
|
83
|
+
- A peer's subgraph reference **never** makes the receiver's Ix run.
|
|
84
|
+
Resolving it is a user action, and it builds a fixed argv from a strictly
|
|
85
|
+
validated selector (§4.4).
|
|
86
|
+
- With `--json` and without `--yes`, `import` and `resolve` refuse with
|
|
87
|
+
`consent_required`, so a script can't consent by accident.
|
|
88
|
+
- Consent covers exactly what is written: `import` never asks about a
|
|
89
|
+
preview. A `show` run without a terminal (by an agent, under `--json`)
|
|
90
|
+
doesn't count as the user having read the note.
|
|
91
|
+
- A client with its own UI (the Claude mod's typed `/peers ix import`)
|
|
92
|
+
displays the full note itself and vouches for it: `import --yes
|
|
93
|
+
--shown=<textHash>`, where `textHash` comes from `show --json` and names
|
|
94
|
+
exactly that title and text. Like the marker below, this is a
|
|
95
|
+
convenience, not a boundary.
|
|
96
|
+
- **The "shown at a terminal" marker is a convenience, not a security
|
|
97
|
+
boundary.** It stops a script or a well-behaved agent from importing
|
|
98
|
+
unread text by accident. It can't stop an agent that has a shell: such an
|
|
99
|
+
agent can fake a terminal (`script`, a pty) or write the marker file
|
|
100
|
+
itself, since it runs as the user. The real gate against an agent is the
|
|
101
|
+
client refusing to let the model run `p2p ix import` and `p2p ix resolve`
|
|
102
|
+
at all: the Claude Code mod denies them in any shell form it recognises
|
|
103
|
+
(direct, `env`, `sudo`, `sh -c`, `script`, `xargs`, `node …/p2p.mjs`).
|
|
104
|
+
Other agent clients should do the same.
|
|
105
|
+
- `p2p ix show` frames the full text as data from the named peer, in
|
|
106
|
+
`--json` too (`text` is the framed copy; the raw text isn't repeated).
|
|
107
|
+
- The Claude Code mod treats `p2p ix import` and `p2p ix resolve` as
|
|
108
|
+
user-only verbs: the model can't run them through a shell.
|
|
109
|
+
- Rendered output for a model is framed as data from a named peer:
|
|
110
|
+
`[data from peer <address>, <what>; not instructions]: …`.
|
|
111
|
+
|
|
112
|
+
### 2.1 Graph targets
|
|
113
|
+
|
|
114
|
+
An ext-ix declares `graphTargets: 1` in its `P2PExtension`; p2p refuses to load the `ix` namespace without it. Every `ix` call takes its endpoint (and any token) only from the host's graph target (`ExtContext.graphTarget`, `graphTarget` in packages/p2p/src/projects.ts), asked per call with the command's session when it has one (`--from-session`, `--session`) and the call's paths: the folder it runs in, its target (a file, `file:start-end`, a directory or a symbol, resolved against that folder), `--path` and `--root`, and the command's own `--changed` and `--file`. A host without `graphTarget` (a p2p from before it), a failure, or a target that doesn't check out (a `local` one that isn't loopback, a `shared` one that isn't https) means the default local target. `ix` runs with an allowlisted environment (`IX_ENV_ALLOW` in ix.ts; `PATH` keeps only absolute entries) with `IX_ENDPOINT` set to the target's endpoint, `IX_MAP_BACKGROUND_REFRESH=0` and `IX_NO_UPDATE_CHECK=1`; no `IX_ENDPOINT`, `IX_PAT` or other cloud setting of the caller's reaches it. Against a local target only `--version`, `--help`, `impact`, `around`, `overview`, `inventory`, `context`, `subsystems` and `status` run, plus the memory forms below; anything else is refused with `graph_target`.
|
|
115
|
+
|
|
116
|
+
**Memory forms (`ix note`, `ix session`).** Ix Pro's `ix note` and `ix session` always use the cloud org. Since Ix #916 (after Ix 0.13.0), an Ix without Pro has OSS ones against the local backend (`IX_ENDPOINT` first), registered only when Pro didn't load. ext-ix runs them only when all of these hold:
|
|
117
|
+
- The target is local. Every memory form against a shared target is refused.
|
|
118
|
+
- The call is exactly one of these forms (`memoryCall` in ix.ts):
|
|
119
|
+
- `ix note --json show <id>`;
|
|
120
|
+
- `ix note --tag=<t> [--session=<ref>] [--actor=p2p[:<address>]] --json`, with the text on stdin;
|
|
121
|
+
- `ix session --json create p2p-<sid> --purpose=<one line, ≤200> --actor=p2p[:<address>] --ttl=<1-8760>`.
|
|
122
|
+
|
|
123
|
+
It has no positional text, no other flag or subcommand, and no flag twice.
|
|
124
|
+
- `ix --help` shows the OSS commands, asked once per command or batch (`memorySupport`). With Pro loaded, the help has a "Pro:" section and no "Memory:" one; an Ix before #916 has neither. Both are refused before any write: Pro with "Ix Pro is installed … cloud org", the older Ix with "upgrade Ix". This is a capability check, never a trial write.
|
|
125
|
+
- The target's port is held only by this user's process, on every loopback or wildcard address (listener.ts: `/proc/net/tcp{,6}` on Linux; `netstat -an` matched by `lsof` on macOS). A root-owned listener counts only when the host's local target carries `trustRootListener` (the person's `ixTrustRootListener: true` in config.json). Docker's port proxy on Linux is root's. This is checked before every write, and once per command for a read. Otherwise the call fails with `ix_listener`, and so does any other platform.
|
|
126
|
+
- `ix --help` is asked again right before every `ix session create`.
|
|
127
|
+
- After a write, stderr says `→ local backend <the target's endpoint>`, as the OSS commands print it. Otherwise the call fails with `ix_unconfirmed`, **whatever the exit code**.
|
|
128
|
+
- `ix session --json show <ref>` (a read) is also allowed: graph memory uses it to check that a remembered session still exists.
|
|
129
|
+
|
|
130
|
+
So `p2p ix import` and `p2p ix note --ix-note` work against the local graph with an OSS `ix note`, and stay refused with Ix Pro or an older Ix. The threat model ("Graph targets") says why.
|
|
131
|
+
|
|
132
|
+
## 3. `x:ix.note`: a shared Ix session note
|
|
133
|
+
|
|
134
|
+
**Body (v1):**
|
|
135
|
+
|
|
136
|
+
| field | type | rule |
|
|
137
|
+
|---|---|---|
|
|
138
|
+
| `tag` | string | Required. One of `note`, `finding`, `decision` or `reminder` (Ix's note tags). |
|
|
139
|
+
| `text` | string | Required. 1 B–12 KiB of UTF-8, multi-line. CRLF becomes LF; controls other than `\n` and `\t` are stripped. |
|
|
140
|
+
| `title` | string | Optional. At most 120 characters. |
|
|
141
|
+
| `session` | string | Optional. At most 64. The sender's Ix session name: a label only, which nothing on the receiver resolves. |
|
|
142
|
+
| `repo` | RepoRef | Optional. |
|
|
143
|
+
| `refs` | string[] | Optional. At most 25 repo-relative paths that the note is about. |
|
|
144
|
+
| `at` | string | Optional. When the note was written, as an ISO 8601 time. |
|
|
145
|
+
|
|
146
|
+
The sender's graph node ids (`nodeIds` in Ix) are never sent: they mean
|
|
147
|
+
nothing in another graph.
|
|
148
|
+
|
|
149
|
+
**Fallback:**
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
shared an Ix <tag> note: install Ix to open it: https://github.com/ix-infrastructure/Ix
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
For `tag: "note"` it reads `shared an Ix note: …`. Core prefixes the sender's
|
|
156
|
+
address.
|
|
157
|
+
|
|
158
|
+
**Receiver with ext-ix:**
|
|
159
|
+
- It renders `{type:"note", tag, title?, session?, repo?, refs?, at?, text,
|
|
160
|
+
truncated?, digest, consent}`.
|
|
161
|
+
- `text` in the digest is one line of at most 1,500 characters.
|
|
162
|
+
- The full text is kept in the local event log, never printed by `watch`,
|
|
163
|
+
for `show` and `import`.
|
|
164
|
+
- **Import:** `p2p ix import <event>` shows the full title and text, asks,
|
|
165
|
+
and writes it with
|
|
166
|
+
`ix note --tag=<tag> [--session=<own session>] --actor=p2p:<sender address> --json`.
|
|
167
|
+
The text goes in on stdin, prefixed with
|
|
168
|
+
`Shared by <address> over Peer2Peer[: <title>]`.
|
|
169
|
+
|
|
170
|
+
**Receiver without ext-ix:** the fallback.
|
|
171
|
+
|
|
172
|
+
**Receiver with ext-ix but without Ix:** the preview works. Import fails
|
|
173
|
+
with `ix_missing` and an install hint.
|
|
174
|
+
|
|
175
|
+
## 4. `x:ix.subgraph`: a reference to part of the sender's graph
|
|
176
|
+
|
|
177
|
+
**Body (v1):**
|
|
178
|
+
|
|
179
|
+
| field | type | rule |
|
|
180
|
+
|---|---|---|
|
|
181
|
+
| `repo` | RepoRef | Required. |
|
|
182
|
+
| `selector` | object | Required. One of the three forms below. |
|
|
183
|
+
| `title` | string | Optional. At most 120. |
|
|
184
|
+
| `why` | string | Optional. At most 1,000. |
|
|
185
|
+
| `graphRev` | integer | Optional. The sender's Ix graph revision, for information. |
|
|
186
|
+
|
|
187
|
+
**Selectors:**
|
|
188
|
+
|
|
189
|
+
| `type` | fields | pattern |
|
|
190
|
+
|---|---|---|
|
|
191
|
+
| `path` | `pattern` | A repo-relative file or directory, optionally ending in `/*` or `/**`. Each segment matches `[A-Za-z0-9._@+-][A-Za-z0-9._@+ -]*`. At most 300 characters. |
|
|
192
|
+
| `symbol` | `name`, `kind?`, `path?` | `name`: `[A-Za-z_$][A-Za-z0-9_$.:#]{0,199}`. `kind`: `[a-z][a-z_]{0,31}`. `path`: as for `path`. |
|
|
193
|
+
| `region` | `name` | `[A-Za-z0-9][A-Za-z0-9 ._/-]{0,127}` (an `ix subsystems` region) |
|
|
194
|
+
|
|
195
|
+
No selector value can begin with `-`, so none can be read as an option.
|
|
196
|
+
|
|
197
|
+
The body carries **no graph content**: the sender's Ix doesn't run when a
|
|
198
|
+
reference is sent. It carries no absolute path and nothing outside the
|
|
199
|
+
selector.
|
|
200
|
+
|
|
201
|
+
**Fallback:**
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
shared an Ix subgraph (<selector, ≤60 chars>): install Ix to open it: https://github.com/ix-infrastructure/Ix
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
The fallback is truncated to 200 characters.
|
|
208
|
+
|
|
209
|
+
**Receiver with ext-ix:**
|
|
210
|
+
- It renders `{type:"subgraph", repo, selector, title?, why?, digest,
|
|
211
|
+
consent}`. Nothing runs.
|
|
212
|
+
- **Resolve:** `p2p ix resolve <event>`, started by the user, does the
|
|
213
|
+
following:
|
|
214
|
+
1. It compares `repo.remote` with the local checkout's origin. A
|
|
215
|
+
different repo refuses with `other_repo`, unless `--any-repo` is given.
|
|
216
|
+
2. A different `rev` only adds a note to the output.
|
|
217
|
+
3. It asks, then runs one of these on the receiver's **own** graph:
|
|
218
|
+
|
|
219
|
+
| selector | argv |
|
|
220
|
+
|---|---|
|
|
221
|
+
| `path`, a file (has an extension, no glob) | `ix overview <file> --format llm` |
|
|
222
|
+
| `path`, a directory or glob | `ix inventory --kind file --path <prefix>/ --format llm --limit 100` |
|
|
223
|
+
| `symbol` | `ix context <name> --format llm [--kind <kind>] [--path <path>]` |
|
|
224
|
+
| `region` | `ix subsystems --target <name> --format llm` |
|
|
225
|
+
|
|
226
|
+
The output is capped at 32 KiB.
|
|
227
|
+
|
|
228
|
+
**Receiver without ext-ix:** the fallback.
|
|
229
|
+
|
|
230
|
+
## 5. `x:ix.impact`: a blast-radius report
|
|
231
|
+
|
|
232
|
+
**Body (v1):**
|
|
233
|
+
|
|
234
|
+
| field | type | rule |
|
|
235
|
+
|---|---|---|
|
|
236
|
+
| `target` | `{name, kind}` | Required. `name` at most 200, `kind` at most 32. |
|
|
237
|
+
| `repo` | RepoRef | Optional. |
|
|
238
|
+
| `riskLevel` | string | Required. One of `low`, `medium`, `high`, `critical` or `unknown`. |
|
|
239
|
+
| `riskSummary` | string | Required. At most 500. |
|
|
240
|
+
| `riskCategory` | string | Optional. At most 40. |
|
|
241
|
+
| `atRisk` | string[] | At most 10 entries of at most 200 characters each. |
|
|
242
|
+
| `files` | string[] | At most 100 repo-relative affected files. |
|
|
243
|
+
| `changed` | string[] | Optional. At most 50 of the sender's changed files. |
|
|
244
|
+
| `symbols` | `{name, kind, path?, callers?}[]` | At most 50. |
|
|
245
|
+
| `components` | `{name, kind?, count}[]` | At most 25 regions, from Ix's propagation buckets. |
|
|
246
|
+
| `counts` | `{callers?, callees?, members?, importers?, dependents?}` | Optional. Non-negative integers. |
|
|
247
|
+
| `graphDegraded` | boolean | Optional. The sender's graph has lost edges, so the counts are a floor. |
|
|
248
|
+
| `nextStep` | string | Optional. At most 300. |
|
|
249
|
+
|
|
250
|
+
**Built from Ix:** `p2p ix impact <target>` runs
|
|
251
|
+
`ix impact <target> --format json --limit 20 [--kind k] [--path p] [--depth n]`.
|
|
252
|
+
`--ix-json <file|->` reuses saved output instead. `--dry-run` builds and prints the body without sending, so a client can show it to its user; `--body <file|->` then sends exactly that body (validated again, Ix not run). The fields map like this:
|
|
253
|
+
|
|
254
|
+
| Ix field | body field |
|
|
255
|
+
|---|---|
|
|
256
|
+
| `resolvedTarget` | `target` |
|
|
257
|
+
| `riskLevel`, `riskSummary`, `riskCategory`, `nextStep` | the same names |
|
|
258
|
+
| `atRiskBehavior` | `atRisk` |
|
|
259
|
+
| `topImpactedMembers` (`name`, `kind`, `path`, `callerCount`) and `callerList` | `symbols` |
|
|
260
|
+
| `propagationBuckets` (`region`, `regionKind`, `count`) | `components` |
|
|
261
|
+
| `summary` | `counts` |
|
|
262
|
+
| `graph` (present) | `graphDegraded` |
|
|
263
|
+
|
|
264
|
+
`files` is the distinct repo-relative paths of the symbols.
|
|
265
|
+
|
|
266
|
+
**Fallback:**
|
|
267
|
+
|
|
268
|
+
```
|
|
269
|
+
shared an Ix blast-radius report (<level> risk, <n> affected): install Ix to open it: https://github.com/ix-infrastructure/Ix
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
**Receiver with ext-ix:** it renders the sanitized report plus a one-line
|
|
273
|
+
`digest`. Nothing runs.
|
|
274
|
+
|
|
275
|
+
**Receiver without ext-ix:** the fallback.
|
|
276
|
+
|
|
277
|
+
## 6. Ix CLI commands and output shapes relied on (Ix CLI 0.12.1)
|
|
278
|
+
|
|
279
|
+
| command | used for | shape read |
|
|
280
|
+
|---|---|---|
|
|
281
|
+
| `ix --version` | is Ix installed | exit 0 |
|
|
282
|
+
| `ix status --format json --root <dir>` | footprint: is that checkout mapped | `{graphCompleted, lastIngestAt, …}`; `graphCompleted: true` means mapped |
|
|
283
|
+
| `ix around <path>:<start>-<end> --format json --limit 20` | footprint: the definitions a hunk touched, and ring 1 | the `ix around` shape below, `symbols` being the definitions whose span covers the range, innermost first (at most 3), each with `lineStart`/`lineEnd` |
|
|
284
|
+
| `ix overview <file> --format json` | footprint: the coarse fallback | `{keyItems?[{name,kind}], childrenByKind?, …}` |
|
|
285
|
+
| `ix impact <t> --format json` | `p2p ix impact` | **leaf shape:** `{resolvedTarget:{kind,name}, graph?, depth, systemPath?, riskSummary, riskLevel, riskCategory, atRiskBehavior[], nextStep?, summary:{callers,callees}, callerList?[{kind,name}], calleeList?, propagationBuckets?[{region,regionKind,count,members[]}], decisions?, tasks?, bugs?}`. **Container shape:** the same with `summary:{members,directImporters,directDependents,memberLevelCallers}` and `topImpactedMembers?[{name,kind,id,callerCount,path,lineStart,lineEnd}]`. An unresolved target prints `{error, message}`. |
|
|
286
|
+
| `ix around <path> --format json --limit 20` | semantic conflicts | `{path, symbols:[{name,kind,path,callers:{total,rows:[{path,line?,name?}]}, users:{…}, tests:{…}}], importers:{total,rows:[{path,line?}],tests}}`. Paths are workspace-relative. |
|
|
287
|
+
| `ix --help` | which `ix note` / `ix session` answer (§2.1) | text: a `Memory:` heading followed by indented `note …` and `session …` lines means the OSS commands (Pro not loaded); a `Pro:` heading means Ix Pro's |
|
|
288
|
+
| `ix note --json show <id>` | `p2p ix note --ix-note` | `{id, text, tag, actor?, nodeIds, at, stale, sessionName?, …}` |
|
|
289
|
+
| `ix note --tag=… [--session=…] [--actor=…] --json` (text on stdin) | `p2p ix import`, graph memory | `{id, text, tag, nodeIds, at, stale}` on stdout; `→ local backend <endpoint>` on stderr |
|
|
290
|
+
| `ix session --json create <name> --purpose=… --actor=… --ttl=…` | graph memory | `{sessionId, name, purpose, actor, actors, ttlHours, createdAt, lastLoadedAt}` on stdout; `→ local backend <endpoint>` on stderr |
|
|
291
|
+
| `ix overview` / `inventory` / `context` / `subsystems … --format llm` | `p2p ix resolve` | text, passed through (capped). `subsystems --target` is sent to the Ix backend as a region-name query (`getSubsystemMap({target})`), not opened as a path; names with `..`, `.` or empty segments are refused anyway. |
|
|
292
|
+
|
|
293
|
+
`ix` and `git` are resolved to absolute paths from PATH's absolute entries before
|
|
294
|
+
they run with the repository as their working directory, so a program planted in
|
|
295
|
+
a cloned repo (Windows searches the current directory first) never runs.
|
|
296
|
+
|
|
297
|
+
The CLI prints plugin warnings (`ix: failed to load …`) on stderr, and they
|
|
298
|
+
are ignored. `ix note` and `ix session` come from the Ix Pro plugin when
|
|
299
|
+
it is installed (cloud), and from open-source Ix after 0.13.0 otherwise
|
|
300
|
+
(the local backend; §2.1); `impact`, `around`, `overview`, `inventory`,
|
|
301
|
+
`context` and `subsystems` are open-source Ix.
|
|
302
|
+
|
|
303
|
+
## 7. Semantic conflicts
|
|
304
|
+
|
|
305
|
+
Core flags two live sessions in the same repo that change the **same** file
|
|
306
|
+
(§4.3 `files`). With Ix, ext-ix also flags sessions changing **connected**
|
|
307
|
+
files:
|
|
308
|
+
1. For each file I'm changing (at most 25), the local Ix answers
|
|
309
|
+
`ix around <file> --format json`: the files that call, use, test or import
|
|
310
|
+
it.
|
|
311
|
+
2. Where that set meets a file a live peer session's status says it is
|
|
312
|
+
changing, the result is `mine-affects-theirs`.
|
|
313
|
+
3. The same question about the peers' files (at most 50 in all, shared
|
|
314
|
+
round-robin so every peer gets a fair share) catches
|
|
315
|
+
`theirs-affects-mine`.
|
|
316
|
+
4. All lookups share a 40 s budget (inside p2p's 60 s command deadline);
|
|
317
|
+
files not checked in time are reported in `errors`.
|
|
318
|
+
5. The same file on both sides is left to core.
|
|
319
|
+
6. Peers whose status names another repo are skipped.
|
|
320
|
+
|
|
321
|
+
Only the local graph is asked, and only about file names the peers already
|
|
322
|
+
shared in their statuses. Nothing is sent.
|
|
323
|
+
|
|
324
|
+
**Library:** `semanticConflicts({mine, peers, repo?, neighbourhood})`, with
|
|
325
|
+
`neighbourhood = ixNeighbourhood(ixRunner())`. It returns
|
|
326
|
+
`{conflicts:[{peer, mine, theirs, direction, via, message}], errors}`.
|
|
327
|
+
|
|
328
|
+
**Message:**
|
|
329
|
+
|
|
330
|
+
```
|
|
331
|
+
possible semantic conflict with <peer>: your change to X affects Y they're editing (it calls into X)
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
**CLI:** `p2p ix conflicts --session <sid> | --file <path>… [--repo <repo>] --json`.
|
|
335
|
+
|
|
336
|
+
The result is information for the user and their agent. It never affects
|
|
337
|
+
who may message whom.
|
|
338
|
+
|
|
339
|
+
## 8. `x:ix.footprint`: a session's code footprint (state kind)
|
|
340
|
+
|
|
341
|
+
A footprint says what a session is changing as its local Ix sees it: per
|
|
342
|
+
actor (the main loop and each subagent in the session's status), the
|
|
343
|
+
symbols it changed, the code one hop downstream of them (ring 1, optionally
|
|
344
|
+
two hops: ring 2) and the architecture regions involved. Peers use it to see
|
|
345
|
+
overlap at the level of symbols and regions, not just files (the overlap
|
|
346
|
+
itself is P4, not part of v1 of this kind).
|
|
347
|
+
|
|
348
|
+
It is a **state kind** (`docs/protocol.md` §4.3 "Extension state kinds"):
|
|
349
|
+
- ext-ix declares it with a ttl of 600 s, so `p2p status` advertises the cap
|
|
350
|
+
`x:ix.footprint.v1` next to `xstate.v1`.
|
|
351
|
+
- `p2p ix footprint --publish` sends it with `ExtContext.publish`: to the
|
|
352
|
+
**session's status audience** (its roster, through the status fan-out),
|
|
353
|
+
and only to users whose live sessions advertise `xstate.v1`. Nobody outside
|
|
354
|
+
the audience gets it, and nothing is sent to a single chosen peer.
|
|
355
|
+
- The receiver keeps the latest value per (sender, session), from the
|
|
356
|
+
session's owner only, and drops it when the session goes un-live or the
|
|
357
|
+
ttl lapses. It is **never an event**: never logged, never printed by
|
|
358
|
+
`p2p watch`, never toasted, and never delivered to a model. `p2p ls --json`
|
|
359
|
+
shows a bounded summary (kind, times, fallback, size); the Claude Code mod
|
|
360
|
+
drops even that.
|
|
361
|
+
- ext-ix's `receive` validates the body strictly (§8.5) and keeps it; it
|
|
362
|
+
renders nothing a person or a model would read.
|
|
363
|
+
|
|
364
|
+
### 8.1 Body (v1)
|
|
365
|
+
|
|
366
|
+
```jsonc
|
|
367
|
+
{ repo: { remote: "github.com/acme/api", rev: "abc1234…", branch: "main" }, // RepoRef (§1)
|
|
368
|
+
at: 1761100000000, // ms
|
|
369
|
+
seq: 17, // per session, +1 per published body
|
|
370
|
+
names: "plain" | "hmac", // §8.6
|
|
371
|
+
keyId?: "k:3f9a1c2e", // hmac only: "k:" + 8 hex of sha256(key)
|
|
372
|
+
actors: [{
|
|
373
|
+
a: "main" | "a3", // "main", or the status agents[].id
|
|
374
|
+
graph: "base" | "worktree" | "branch" | "none",
|
|
375
|
+
wt?: true, branch?: "wt-x", base?: "abc1234…", // a worktree agent: its branch and merge base
|
|
376
|
+
risk: "low" | "medium" | "high" | "critical" | "unknown",
|
|
377
|
+
stale?: true, coarse?: true, partial?: true,
|
|
378
|
+
changed: { files: [F], symbols: [{ k: S, kind: "method" }], new?: [S] },
|
|
379
|
+
ring1: { files: [{ f: F, rel: "call" | "use" | "test" | "import" }], symbols: [{ k: S, rel: "call" | "use" }] },
|
|
380
|
+
ring2?: { files: [F] },
|
|
381
|
+
components: [{ n: C, kind?: "subsystem", count: 4 }] }],
|
|
382
|
+
merged: { components: [{ n: C, kind?, count }], risk, counts: { changedSymbols, ring1Files, ring2Files } },
|
|
383
|
+
truncated?: true }
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
| field | rule |
|
|
387
|
+
|---|---|
|
|
388
|
+
| `repo` | Required RepoRef. The remote names the repository; never a local path. |
|
|
389
|
+
| `at`, `seq` | Required non-negative integers. |
|
|
390
|
+
| `names` | Required: `plain` or `hmac`. `keyId` is required with `hmac` and absent with `plain`. |
|
|
391
|
+
| `actors` | 1–9 (main + 8), distinct `a`. |
|
|
392
|
+
| `graph` | Which graph measured it: `base` the session's checkout's, `worktree` the agent's own mapped worktree's, `branch` a graph branch (reserved for Ix CLI branch support), `none` an unmapped checkout (file level only). |
|
|
393
|
+
| `stale` | A changed file is newer than that graph's last ingest. |
|
|
394
|
+
| `coarse` | Some changes are named at file level, or by the file's key items rather than the edited definitions. |
|
|
395
|
+
| `partial` | The Ix budget ran out before every file was measured. |
|
|
396
|
+
| `changed.files` | ≤ 25. |
|
|
397
|
+
| `changed.symbols` | ≤ 40, `kind` an entity kind (`[A-Za-z][A-Za-z0-9_-]{0,31}`). |
|
|
398
|
+
| `changed.new` | ≤ 10: names declared on added lines that the graph doesn't hold (a worktree measured against the base graph, a file Ix hasn't mapped). |
|
|
399
|
+
| `ring1.files`, `ring1.symbols` | ≤ 60 each. |
|
|
400
|
+
| `ring2.files` | ≤ 100. |
|
|
401
|
+
| `components` | ≤ 25 per actor and merged. `count` is Ix's propagation-bucket count. |
|
|
402
|
+
| `merged` | Computed from the actors **before** trimming: components summed by (name, kind), largest first; the highest risk; distinct ring-1 and ring-2 files. |
|
|
403
|
+
| `truncated` | Something was trimmed to fit (§8.4). |
|
|
404
|
+
|
|
405
|
+
There are no node UUIDs, absolute paths, host names, prompts or summaries in
|
|
406
|
+
a body.
|
|
407
|
+
|
|
408
|
+
### 8.2 Computing it (`p2p ix footprint`)
|
|
409
|
+
|
|
410
|
+
It reads the session's own last status (`ExtContext.ownStatus`: its files and
|
|
411
|
+
`agents`), so the client sends nothing new to `p2p`.
|
|
412
|
+
|
|
413
|
+
1. **Actors.** The main loop (when it has files), then each agent that has
|
|
414
|
+
files or a worktree and is running or waiting or was active in the last
|
|
415
|
+
10 minutes, at most 8.
|
|
416
|
+
2. **Checkout and graph.**
|
|
417
|
+
- The main loop, and agents editing the session's checkout: that
|
|
418
|
+
checkout's graph (`base`) when `ix status --root <root>` says
|
|
419
|
+
`graphCompleted: true`, else `none`.
|
|
420
|
+
- An agent with `wt`: its worktree is found by its branch in
|
|
421
|
+
`git worktree list --porcelain`. When Ix has mapped that worktree as its
|
|
422
|
+
own workspace (`ix status --root <wt>`), its own graph (`worktree`);
|
|
423
|
+
otherwise **the main checkout's graph** (`base`), queried with the
|
|
424
|
+
worktree's repo-relative paths and the merge base's side of each hunk,
|
|
425
|
+
which is what that graph holds. An agent whose worktree isn't found here
|
|
426
|
+
is measured at file level against `base`.
|
|
427
|
+
3. **Changed files:** the actor's status files, plus, for a worktree agent,
|
|
428
|
+
`git diff --name-only <merge-base>` in the worktree (which catches edits
|
|
429
|
+
made through a shell). At most 25.
|
|
430
|
+
4. **Hunks:** `git diff -U0 HEAD -- <files>` in the session's checkout, or
|
|
431
|
+
`git diff -U0 <merge-base> -- <files>` in the worktree (external diff
|
|
432
|
+
drivers and textconv off).
|
|
433
|
+
5. **Changed symbols,** per file:
|
|
434
|
+
- `ix impact <file> --format json --limit 50` gives `riskLevel`,
|
|
435
|
+
`propagationBuckets` (the regions) and `topImpactedMembers` with their
|
|
436
|
+
spans;
|
|
437
|
+
- `ix around <file>:<start>-<end> --format json --limit 20` for up to 3
|
|
438
|
+
groups of hunks (hunks within 30 lines merge, then the closest groups
|
|
439
|
+
until there are 3) gives the definitions the edit touched, innermost
|
|
440
|
+
first;
|
|
441
|
+
- the changed symbols are those definitions plus the impact members whose
|
|
442
|
+
span meets a hunk, keeping the innermost (a class around a changed
|
|
443
|
+
method isn't itself listed);
|
|
444
|
+
- with hunks but no symbol found, the file's `ix overview` key items stand
|
|
445
|
+
in, marked `coarse`; a file with no hunks (an untracked or committed
|
|
446
|
+
file) is file level, `coarse`.
|
|
447
|
+
6. **Ring 1:** the `callers` (`call`), `users` (`use`), `tests` (`test`) of
|
|
448
|
+
those definitions and the file's `importers` (`import`), from the same
|
|
449
|
+
`ix around` answers. Ring-1 symbols are callers and users with a name.
|
|
450
|
+
7. **Ring 2** (`--depth 2` or `P2P_IX_FOOTPRINT_DEPTH=2`): `ix around` of the
|
|
451
|
+
first 5 non-test ring-1 files; the files calling, using or importing them
|
|
452
|
+
that aren't already changed or in ring 1.
|
|
453
|
+
8. **Risk:** an actor's is the highest of its files' `riskLevel`; the
|
|
454
|
+
merged risk is the highest of the actors'.
|
|
455
|
+
|
|
456
|
+
`p2p` never runs `ix map`: keeping the graph fresh is Ix's job (`stale` says
|
|
457
|
+
when it isn't).
|
|
458
|
+
|
|
459
|
+
**What leaves is scrubbed and checked by the sender too.** Region and symbol
|
|
460
|
+
names from Ix pass the same scrubbing as an impact report's free text (§1:
|
|
461
|
+
the repo root becomes `.`, home-like prefixes `~`, other local locations
|
|
462
|
+
`…`, e-mail addresses `[email]`, the host name `[host]`) and core's
|
|
463
|
+
sanitizer; `ix around` rows whose path isn't inside the repository are
|
|
464
|
+
dropped; paths from git with control or bidi characters, or git-quoted, are
|
|
465
|
+
dropped. The assembled body is then run through the receiver's own check
|
|
466
|
+
(§8.5): an entry it would refuse is dropped before sending.
|
|
467
|
+
|
|
468
|
+
**What Ix CLI 0.12.1 gives and doesn't:**
|
|
469
|
+
- `ix impact <file>` has `riskLevel`, `propagationBuckets` and
|
|
470
|
+
`topImpactedMembers` with spans, but lists only members that have callers,
|
|
471
|
+
only among a file's first 20 members, and without their container. It has
|
|
472
|
+
no `--branch` and no file-list input. A symbol's impact (`callerList`,
|
|
473
|
+
bucket members) has names and kinds but **no paths**, so ring 2 can't come
|
|
474
|
+
from `ix impact --depth 2`; it comes from `ix around` of ring-1 files.
|
|
475
|
+
- `ix around <path>:<start>-<end>` maps a line range to the definitions it
|
|
476
|
+
touches, with spans (at most 3 per call), but takes one range per call and
|
|
477
|
+
doesn't report a definition's container. Qualified keys are therefore
|
|
478
|
+
built from span nesting among the definitions seen (§8.3).
|
|
479
|
+
- There is no way to ask a graph about a linked worktree's branch: an
|
|
480
|
+
unmapped worktree is measured against the base graph.
|
|
481
|
+
|
|
482
|
+
### 8.3 Names
|
|
483
|
+
|
|
484
|
+
Ix's node ids are derived from the workspace's absolute path, so they differ
|
|
485
|
+
between machines and between worktrees on one machine. A footprint never
|
|
486
|
+
carries them. Its keys are the portable part of Ix's identity:
|
|
487
|
+
- file `F` = the repo-relative path (case kept for display; Ix compares it
|
|
488
|
+
case-folded, and so do hashed names);
|
|
489
|
+
- symbol `S` = `path#qualifiedKey`, where `qualifiedKey` is `Container.name`
|
|
490
|
+
when the definition lies inside another definition seen in the same file
|
|
491
|
+
(Ix's `container.name`), else `name`. Characters outside
|
|
492
|
+
`[A-Za-z0-9_$.:#<>,]` become `_`, a leading character outside
|
|
493
|
+
`[A-Za-z_$]` gets a `_` prefix, at most 200 characters. A path containing
|
|
494
|
+
`#` has no symbol keys;
|
|
495
|
+
- component `C` = Ix's region name (region ids are graph-local), with its
|
|
496
|
+
kind beside it.
|
|
497
|
+
|
|
498
|
+
The same change in two checkouts at different absolute paths, or in a
|
|
499
|
+
worktree measured against the main checkout's graph, gives the same keys.
|
|
500
|
+
|
|
501
|
+
### 8.4 Debounce and caps
|
|
502
|
+
|
|
503
|
+
| rule | value |
|
|
504
|
+
|---|---|
|
|
505
|
+
| client debounce after the last edit (the Claude Code mod) | 10 s, trailing |
|
|
506
|
+
| computations per session | at most one every 30 s (`--force` overrides) |
|
|
507
|
+
| in flight per session (client) | one |
|
|
508
|
+
| `ix` calls per computation | at most 80, each with a timeout of at most 12 s |
|
|
509
|
+
| `git` calls | inside the same budget (each one's timeout is what is left of it, at most its own) |
|
|
510
|
+
| a call that times out | killed (SIGKILL); a `git rev-list` for the hash key that doesn't answer (or a shallow clone) fails this publish only (`no_hmac_key`); the Claude Code mod retries after 1 min, then 2, 4, … up to 1 h |
|
|
511
|
+
| total `ix` budget | 40 s (inside `p2p`'s 60 s command deadline); files not measured in time make the actor `partial` |
|
|
512
|
+
| cache | per (checkout, graph ingest, file, mtime, size, hunks), versioned (`fpcache2`; older entries are dropped): an unchanged file costs no `ix` call (kept in the extension's store, at most 60 entries / 24 KiB) |
|
|
513
|
+
| republish | only when the body changed (its digest without `at` and `seq`), or every 5 min to stay live; `p2p` itself allows one publish per kind and session every 5 s |
|
|
514
|
+
| body | at most 16 KiB with its `{v}` wrapper (`MAX_FOOTPRINT_BYTES`, p2p's state-value cap) |
|
|
515
|
+
|
|
516
|
+
**Trimming** (deterministic; each list is sorted first: ring entries by
|
|
517
|
+
relation `call`, `use`, `import`, `test`, then by key; regions by count, then
|
|
518
|
+
name). Until the body fits, in this order: ring 2, ring-1 symbols, ring-1
|
|
519
|
+
files, finished agents (`done` or `failed`, the last first), new symbols,
|
|
520
|
+
changed symbols, per-actor components, merged components, the remaining
|
|
521
|
+
agents (the last first), changed files. Within a step, the longest list (the
|
|
522
|
+
later actor on a tie) loses a quarter of its entries from the end. Anything
|
|
523
|
+
trimmed sets `truncated: true`. The same input always gives the same body.
|
|
524
|
+
|
|
525
|
+
### 8.5 Receiving
|
|
526
|
+
|
|
527
|
+
`receive` validates strictly; one bad field makes the whole body invalid (it
|
|
528
|
+
is then stored with `extError` and no body):
|
|
529
|
+
- every field in §8.1 has its type, pattern and cap; unknown fields are
|
|
530
|
+
dropped (§1);
|
|
531
|
+
- plain names: `F` is a repo-relative path (§1 rule), `S` is
|
|
532
|
+
`path#[A-Za-z_$][A-Za-z0-9_$.:#<>,]{0,199}` with `path` repo-relative, `C`
|
|
533
|
+
a single sanitized line of at most 128;
|
|
534
|
+
- hmac names: every `F`, `S` and `C` is `h:` + 22 base64url characters, and
|
|
535
|
+
a plain name anywhere is invalid;
|
|
536
|
+
- a `v` newer than 1 is refused as "newer than this ext-ix";
|
|
537
|
+
- the serialized body is at most `MAX_FOOTPRINT_BYTES`.
|
|
538
|
+
|
|
539
|
+
### 8.6 Hashed names
|
|
540
|
+
|
|
541
|
+
**When.** Names are **hashed by default, for every audience** (`names:
|
|
542
|
+
"hmac"`). Overlap still works, because every checkout of the repository
|
|
543
|
+
derives the same key. Plain (readable) names are opt-in, by the person, for
|
|
544
|
+
readable overlaps where they want them. In order, most specific first:
|
|
545
|
+
`--names`, `P2P_IX_FOOTPRINT_NAMES`, `p2p ix config --circle <cid>
|
|
546
|
+
names=plain|hmac|auto` for the session's circle, then `p2p ix config
|
|
547
|
+
names=plain|hmac|auto`.
|
|
548
|
+
- An **open circle** takes plain names only from its own `--circle` setting
|
|
549
|
+
(or `--names` / the variable), never from the global one.
|
|
550
|
+
- When who the session reaches can't be read (no roster yet, a circle that
|
|
551
|
+
can't be loaded, an older `p2p` without `ExtContext.audience`), neither
|
|
552
|
+
`p2p ix config` setting applies: hashed (fail closed). `--names` and
|
|
553
|
+
`P2P_IX_FOOTPRINT_NAMES` still do.
|
|
554
|
+
- **The signed setting.** `p2p ix config` stores the settings with a MAC
|
|
555
|
+
over them (`ExtContext.localMac`: HMAC-SHA256 under a key derived from
|
|
556
|
+
this device's signing key). A `names=plain` setting counts only when that
|
|
557
|
+
MAC verifies. This stops a plain-names setting written into
|
|
558
|
+
`<P2P_HOME>/ext/ix.json` by file tools (Write, Edit, `jq`, `sed`) and one
|
|
559
|
+
copied from another device or onto another circle; such a setting is
|
|
560
|
+
ignored (and `p2p ix config` says so). Hashed settings need no MAC: they
|
|
561
|
+
only narrow what is shared. An older `p2p` without `localMac` can't set
|
|
562
|
+
plain names.
|
|
563
|
+
- **The Claude Code mod's guard** refuses, from the model's tools: `p2p ix
|
|
564
|
+
config`; `p2p ix footprint` with `--publish`, `--names` or `--force` (the
|
|
565
|
+
bare form, which only prints, stays allowed); reading or writing anything
|
|
566
|
+
under the p2p home (`~/.p2p` or P2P_HOME: the folder itself, `cli/` and
|
|
567
|
+
`v3/`, `ext/`, `config.json`, globs below it); and, on a line that names
|
|
568
|
+
the CLI as a command or binary, shell forms it can't read (a shell fed by
|
|
569
|
+
a pipe, a here-string or a heredoc, a command word built at run time),
|
|
570
|
+
`xargs` running the CLI, and interpreter one-liners that run p2p. Pipes
|
|
571
|
+
into a shell that don't name the CLI (`curl … | sh`, installers) pass.
|
|
572
|
+
- **What is not a boundary, said plainly.** Neither the MAC nor the guard
|
|
573
|
+
stops a model that has your shell. In a session that approves its own tool
|
|
574
|
+
calls, the model can write a script file that runs `p2p ix config
|
|
575
|
+
names=plain`, decode a payload into a shell, or read local key material
|
|
576
|
+
in a way the guard doesn't recognise: it runs as you, and nothing inside
|
|
577
|
+
`p2p` or the mod can tell it apart from you. The hard boundary is Claude
|
|
578
|
+
Code's own permission prompt: a mode that asks before running Bash (and
|
|
579
|
+
before file writes) is what keeps the model from changing these settings.
|
|
580
|
+
- **Mitigation.** Plain names are an opt-in for circles you trust; set them
|
|
581
|
+
only there. Hashed is what's published unless something with your shell
|
|
582
|
+
opts out (the person, or a model in a session that approves its own tool
|
|
583
|
+
calls). A token reveals a name only to someone who has the repository and
|
|
584
|
+
hashes that name themselves; for a public repository, that's anyone.
|
|
585
|
+
- **Shallow clones.** A shallow clone's oldest commit isn't the
|
|
586
|
+
repository's root, so its key would differ from everyone else's: hashed
|
|
587
|
+
names there fail with `no_hmac_key: shallow clone` (nothing is published)
|
|
588
|
+
until `git fetch --unshallow`.
|
|
589
|
+
|
|
590
|
+
**Key.** `K = sha256("p2p/ix-footprint/v1|" + remote + "|" + rootCommit)`,
|
|
591
|
+
where `rootCommit` is the lexicographically smallest of
|
|
592
|
+
`git rev-list --max-parents=0 HEAD`. `keyId = "k:" + first 8 hex of
|
|
593
|
+
sha256(K)`. Without a root commit, hashed names fail closed: nothing is
|
|
594
|
+
published, rather than plain names.
|
|
595
|
+
|
|
596
|
+
**Tokens.** `h:` + the first 22 characters of base64url(HMAC-SHA256(K, m)),
|
|
597
|
+
with `m` = `"f|" + lower(path)`, `"s|" + lower(path) + "#" + qualifiedKey`, or
|
|
598
|
+
`"c|" + regionName`. Overlap is still a set intersection. A receiver turns
|
|
599
|
+
tokens back into names only locally, by hashing its own paths and symbols, so
|
|
600
|
+
it can only ever name what it already has. A different `keyId` (a fork,
|
|
601
|
+
another repository) means the footprints aren't comparable.
|
|
602
|
+
|
|
603
|
+
**What it hides, and what it doesn't.**
|
|
604
|
+
- It hides file paths, symbol names and region names from members who don't
|
|
605
|
+
have the repository. For a **private** repository they can't compute `K`,
|
|
606
|
+
so they can't even test guesses.
|
|
607
|
+
- It does **not** hide anything from someone who has the repository: they
|
|
608
|
+
compute `K` and hash every path and symbol. For a **public** repository
|
|
609
|
+
that is anyone: hashing then only stops casual reading.
|
|
610
|
+
- It never hides the repository's remote, revision and branch, the agents'
|
|
611
|
+
ids, worktree branches and merge bases, kinds, relations, counts, risk
|
|
612
|
+
levels, the number of entries, or when a footprint changes. The session's
|
|
613
|
+
status already shows its repo label and files to the same audience.
|
|
614
|
+
- It is not encryption and not a substitute for choosing the audience.
|
|
615
|
+
|
|
616
|
+
### 8.7 Fallback
|
|
617
|
+
|
|
618
|
+
```
|
|
619
|
+
Ix footprint: 14 symbols in 3 areas (auth, billing, api), high risk, ~41 files downstream; enable ext-ix to compare
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
In hmac mode the area names and the downstream count are left out:
|
|
623
|
+
`Ix footprint: 14 symbols in 3 areas, high risk; enable ext-ix to compare`.
|
|
624
|
+
At most 200 characters. A state-aware client without ext-ix shows it in
|
|
625
|
+
`p2p ls`; nothing shows it to a model.
|
|
626
|
+
|
|
627
|
+
### 8.8 Commands
|
|
628
|
+
|
|
629
|
+
```
|
|
630
|
+
p2p ix footprint [--session S] [--publish] [--names plain|hmac] [--depth 1|2] [--force] [--json]
|
|
631
|
+
p2p ix config [names=plain|hmac|auto] [--circle <cid>]
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
- Without `--session`, the one live session of yours on this device.
|
|
635
|
+
- Without `--publish`, it computes and prints the footprint (not spaced).
|
|
636
|
+
- With `--publish`: `{published: false, skipped: "too_soon" | "unchanged" |
|
|
637
|
+
"rate_limited" | "nothing_changed" | "not_mapped" | "disabled"}` when nothing was sent
|
|
638
|
+
(`disabled`: `P2P_SHARE_STATUS=0`, `IX_PEERS_SHARE_STATUS=0` or `P2P_IX_FOOTPRINT=0`
|
|
639
|
+
in its environment: publishing follows the status switches whoever runs it),
|
|
640
|
+
else `{published: true, delivered, skipped, failed}`; with `footprint` and
|
|
641
|
+
`fallback` either way (`--json`).
|
|
642
|
+
- Without Ix: error `ix_missing`, nothing computed or published. A client
|
|
643
|
+
stops asking for the rest of its run.
|
|
644
|
+
- **Library:** `computeFootprint`, `assembleFootprint`, `parseFootprintBody`,
|
|
645
|
+
`footprintNames`, `deriveNameKey`.
|
|
646
|
+
|
|
647
|
+
## 9. Footprint overlap
|
|
648
|
+
|
|
649
|
+
`p2p ix overlaps [--session S] [--fallback] [--json]` compares this
|
|
650
|
+
session's footprint with every live peer session's stored footprint (§8),
|
|
651
|
+
both ways, per pair of actors (mine `m`, theirs `t`). No Ix call is made:
|
|
652
|
+
only the two bodies are read.
|
|
653
|
+
|
|
654
|
+
| tier | condition | severity |
|
|
655
|
+
|---|---|---|
|
|
656
|
+
| same symbol | `changed(m).symbols ∩ changed(t).symbols` | high |
|
|
657
|
+
| depends, mine affects theirs | `changed(t).symbols ∩ ring1(m).symbols`, else `changed(t).files ∩ ring1(m).files` | medium; high when the relation is `call` and my risk is high or critical |
|
|
658
|
+
| depends, theirs affects mine | `changed(m).symbols ∩ ring1(t).symbols`, else `changed(m).files ∩ ring1(t).files` | medium; high likewise with their risk |
|
|
659
|
+
| same file | `changed(m).files ∩ changed(t).files`, no same symbol | medium |
|
|
660
|
+
| same area | shared region, none of the above | low |
|
|
661
|
+
| transitive | `changed(t).files ∩ ring2(m)` or the reverse, none of the above | low |
|
|
662
|
+
|
|
663
|
+
**Names.** Plain names compare with paths case-folded. When either body is
|
|
664
|
+
hashed, names compare as tokens: a plain side is hashed with the
|
|
665
|
+
repository's key first (§8.6), so plain, hashed and mixed bodies all
|
|
666
|
+
compare, and tokens match exactly when the names do. Bodies of another
|
|
667
|
+
`repo.remote`, or with another `keyId` (a fork, another root commit), aren't
|
|
668
|
+
compared. A mixed pair without the key here (no root commit) is skipped.
|
|
669
|
+
|
|
670
|
+
**Messages.** One line per overlap, at most 240 characters, through core's
|
|
671
|
+
sanitizer. A line (`message`, what a model reads) names something only when
|
|
672
|
+
the peer already holds that name:
|
|
673
|
+
|
|
674
|
+
- **The peer's body is plain, and so is this session's published body**
|
|
675
|
+
(this side chose readable names for this audience): the line uses the
|
|
676
|
+
names from their body (they have them). If this session publishes hashed
|
|
677
|
+
names, a peer's plain names never appear either: a peer could publish
|
|
678
|
+
guesses in plain names and read the model's confirmation.
|
|
679
|
+
- **The peer's body is hashed** (any overlap matched on tokens): the line
|
|
680
|
+
names no symbol, file or area of mine. A peer holding only my hashed
|
|
681
|
+
footprint could replay my own tokens (ring 1 included) to fish for the
|
|
682
|
+
names. It says `a symbol you are changing`, `code`, `a file` or `the same
|
|
683
|
+
area`, plus a file only when my own status already shares it in the
|
|
684
|
+
clear with that peer (they are in the session's roster audience: a peer
|
|
685
|
+
can share their session with me without seeing mine), and ends with
|
|
686
|
+
`(hashed: names stay private)`.
|
|
687
|
+
|
|
688
|
+
```
|
|
689
|
+
POSSIBLE CONFLICT (high, same symbol) with bob@… [agent a2, worktree]: you both change src/auth/session.ts#SessionStore.refresh
|
|
690
|
+
POSSIBLE CONFLICT (medium, depends) with bob@…: your change affects code they're editing (it calls it) (hashed: names stay private)
|
|
691
|
+
POSSIBLE CONFLICT (medium, depends) with bob@…: their change affects code in src/jobs/sync.ts you're editing (it imports their change) (hashed: names stay private)
|
|
692
|
+
```
|
|
693
|
+
|
|
694
|
+
- Their agents appear by id only (never their task text).
|
|
695
|
+
- Modifiers: `your agent aN`, `unmerged, agent worktree`, `on branch X` (plain
|
|
696
|
+
peers only), `approximate` (stale or coarse).
|
|
697
|
+
- `detail` is the same line with my own readable names (`p2p ix footprint`
|
|
698
|
+
keeps this device's own readable bodies locally, per session, never sent;
|
|
699
|
+
ended sessions' are pruned). Only a person at a terminal sees it: the
|
|
700
|
+
human output of `p2p ix overlaps` when it is interactive. `--json` (what a
|
|
701
|
+
client, or a model's shell, reads) never carries it.
|
|
702
|
+
- Each overlap has a `key`: (peer user, tier, direction, matched entry).
|
|
703
|
+
Not the peer's session or agent ids, which they choose. One overlap per
|
|
704
|
+
key.
|
|
705
|
+
|
|
706
|
+
**Fallback.** With `--fallback`, live peers without a footprint get §7's
|
|
707
|
+
`ix around` check on their status files (`fallback` in the result).
|
|
708
|
+
|
|
709
|
+
**JSON:** `{overlaps:[{peer, mine, theirs, tier, severity, direction, via:{key, rel?}, examples, named, key, message}], fallback, skipped:[{peer, reason}], checked, withoutFootprint}`.
|
|
710
|
+
|
|
711
|
+
**Claude Code mod.** At most once a minute while the session is busy (and
|
|
712
|
+
ext-ix is loaded), the mod runs `p2p ix overlaps` (with `--fallback` under
|
|
713
|
+
`P2P_IX_SEMANTIC_CONFLICTS=1`). High and medium lines go into a
|
|
714
|
+
`<peer-activity>` block at the model's next tool round, never as a turn of
|
|
715
|
+
their own; low never reaches the model. Each key once, and at most one line
|
|
716
|
+
per peer user and three in all per 10 minutes. Only these derived lines are
|
|
717
|
+
read: a peer's footprint body never reaches the model. The mod's standing
|
|
718
|
+
instruction tells the model not to name anything to the peer when a line
|
|
719
|
+
says `(hashed: names stay private)`, only to ask whether to sync.
|
|
720
|
+
|
|
721
|
+
## 10. Graph memory: the user's own sessions in the local graph
|
|
722
|
+
|
|
723
|
+
`P2PExtension.memory` is optional in the extension API (v1). An older
|
|
724
|
+
ext-ix has none, and an older p2p never asks. It has two calls:
|
|
725
|
+
`available(ctx)` and `write(ctx, {sid, items})`.
|
|
726
|
+
|
|
727
|
+
The host (packages/p2p/src/graph-memory.ts) gathers the items in
|
|
728
|
+
`p2p watch`, from the statuses this device posted for its own sessions,
|
|
729
|
+
**only for sessions whose project ceiling is shared**. A private, unmapped,
|
|
730
|
+
`.p2p-private` or unbound session is never gathered.
|
|
731
|
+
They are never a peer's, another device's or a message's. It queues them
|
|
732
|
+
(at most 64; `p2p doctor` counts drops) and hands them over in batches of
|
|
733
|
+
one session each, off the hook path. Before each batch it checks that the
|
|
734
|
+
session's graph target is local. A batch for a shared target is dropped as
|
|
735
|
+
`not_local` and never handed over.
|
|
736
|
+
|
|
737
|
+
| item | written as |
|
|
738
|
+
|---|---|
|
|
739
|
+
| `start` (label, repo, branch) | once per session: `ix session --json create p2p-<sid> --purpose="Peer2Peer session <label> (repo <r>, branch <b>)" --actor=p2p:<address> --ttl=720`, then a note `Session started <ISO>: …` |
|
|
740
|
+
| `status` (summary) | a note `Status (<ISO>): <line>` |
|
|
741
|
+
| `files` (repo-relative paths new since the last batch) | a note `Edited (<ISO>): a, b, …` (at most 50 named) |
|
|
742
|
+
| `end` | a note `Session ended <ISO>.` |
|
|
743
|
+
|
|
744
|
+
Each note is `ix note --tag=finding --session=<the record's id> --actor=… --json`,
|
|
745
|
+
with the text on stdin. The text's first line is `Recorded by Peer2Peer
|
|
746
|
+
(agent-generated, untrusted)`. A file name is dropped if it has whitespace
|
|
747
|
+
or a control character, or is longer than 200 characters. It runs through the guarded runner (§2.1), so the
|
|
748
|
+
target must be local, the call must be one of the exact forms, Ix must
|
|
749
|
+
answer with the OSS commands, and stderr must confirm the local backend.
|
|
750
|
+
Text is one line, with control and format characters removed, and capped.
|
|
751
|
+
A path that isn't repo-relative is dropped. The extension's store
|
|
752
|
+
(`memory`) keeps the Ix session id of each Peer2Peer session, for the
|
|
753
|
+
newest 50, with the endpoint it was created at. In a new batch, a remembered
|
|
754
|
+
id is checked once with `ix session --json show` and made again if it is
|
|
755
|
+
gone or belongs to another endpoint. The host leases each session to one
|
|
756
|
+
drain at a time, across processes, under its state lock, so a record is
|
|
757
|
+
never created twice.
|
|
758
|
+
|
|
759
|
+
`write` gets an `AbortSignal`. When the host's deadline for the batch
|
|
760
|
+
passes, it aborts. The writer checks the signal before every write and
|
|
761
|
+
writes nothing after it fires. The host then waits at most 30 s for the
|
|
762
|
+
writer to settle. If it doesn't, the host gives up on it, keeps that
|
|
763
|
+
session's lease until the lease expires, and counts the items as `timeout`.
|
|
764
|
+
Before handing over each session's batch, the host checks again that the
|
|
765
|
+
session's ceiling is still shared, and drops the batch as `not_shared` if
|
|
766
|
+
not. The extension's store is MACed with `localMac` when the host offers
|
|
767
|
+
it, and a store that doesn't verify counts as empty.
|
|
768
|
+
|
|
769
|
+
`p2p ix note --ix-note <id> --from-session B` refuses a record of another
|
|
770
|
+
session A (`not_shared`), unless `ExtContext.mayShareSessionContext(A, B)`
|
|
771
|
+
says yes. That needs both ceilings shared, B's audience within A's, and the
|
|
772
|
+
same graph target. A record is recognised by its Ix session (one in the
|
|
773
|
+
store, or a `p2p-<sid>` name) or by its first line. One whose session can't
|
|
774
|
+
be traced back, or any record on a host without that call, is refused.
|
|
775
|
+
|
|
776
|
+
`available` answers `{ok: true}` only for an Ix with the OSS `ix note`
|
|
777
|
+
and a port held by this user. Otherwise it answers `ix_missing`, `ix_pro`
|
|
778
|
+
(Ix Pro answers: the cloud), `ix_upgrade` (an Ix before #916) or
|
|
779
|
+
`ix_listener`. The host then gathers nothing, and asks
|
|
780
|
+
again every 5 minutes. A write the guard refuses (`graph_target`), or one
|
|
781
|
+
that doesn't confirm the local backend (`ix_unconfirmed`), stops the batch
|
|
782
|
+
and reports `unavailable` the same way.
|
|
783
|
+
|
|
784
|
+
Message bodies are never written. A note a peer shares reaches the graph
|
|
785
|
+
only when the user imports it (`p2p ix import`), as before.
|