@joe-broadhead/opencode-mem 0.12.4 → 0.12.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/README.md +1 -0
  3. package/package.json +147 -2
  4. package/src/actions.js +36 -1
  5. package/src/collector.js +176 -12
  6. package/src/plugins/source-contract/index.js +2 -2
  7. package/src/plugins/source-contract/vendor/PROVENANCE.json +9 -9
  8. package/src/plugins/source-contract/vendor/RELEASE-SHA256SUMS +3 -3
  9. package/src/plugins/source-contract/vendor/RELEASE.json +9 -9
  10. package/src/plugins/source-contract/vendor/SHA256SUMS +36 -29
  11. package/src/plugins/source-contract/vendor/broker-client.js +14 -14
  12. package/src/plugins/source-contract/vendor/chunks/{chunk-JUWIMDGF.js → chunk-6ZSJSJMV.js} +2 -2
  13. package/src/plugins/source-contract/vendor/chunks/{chunk-77MJETEE.js → chunk-A2KM6BYK.js} +13 -13
  14. package/src/plugins/source-contract/vendor/chunks/{chunk-HVBOAYBO.js → chunk-BEU3WWNO.js} +59 -6
  15. package/src/plugins/source-contract/vendor/chunks/{chunk-T4QM7B3S.js → chunk-CUITXC5J.js} +1 -1
  16. package/src/{vendor/source-contract/chunks/chunk-OZMX7VR7.js → plugins/source-contract/vendor/chunks/chunk-EOS4LD6F.js} +1 -1
  17. package/src/plugins/source-contract/vendor/chunks/{chunk-F4K2Y64D.js → chunk-EUDLXWG4.js} +1 -1
  18. package/src/plugins/source-contract/vendor/chunks/{chunk-BOUWB5UP.js → chunk-GDBKZBG7.js} +2 -2
  19. package/src/plugins/source-contract/vendor/chunks/{chunk-EHIOPXPL.js → chunk-HR22TL23.js} +14 -14
  20. package/src/plugins/source-contract/vendor/chunks/{chunk-X6XP7YK2.js → chunk-IGPRJ63D.js} +2 -2
  21. package/src/plugins/source-contract/vendor/chunks/{chunk-XVA6H6OO.js → chunk-IIUWLSGP.js} +2 -2
  22. package/src/plugins/source-contract/vendor/chunks/chunk-ITQZIF2U.js +191 -0
  23. package/src/plugins/source-contract/vendor/chunks/{chunk-IL565TRX.js → chunk-KXQYSM2Z.js} +1 -1
  24. package/src/plugins/source-contract/vendor/chunks/{chunk-YH323FAZ.js → chunk-LJL3EALP.js} +238 -12
  25. package/src/plugins/source-contract/vendor/chunks/{chunk-NUEROZNU.js → chunk-NUBUQFLH.js} +1 -1
  26. package/src/plugins/source-contract/vendor/cursor.js +3 -3
  27. package/src/plugins/source-contract/vendor/descriptor.js +11 -11
  28. package/src/plugins/source-contract/vendor/events.js +22 -4
  29. package/src/plugins/source-contract/vendor/hints.js +33 -0
  30. package/src/plugins/source-contract/vendor/index.js +3 -3
  31. package/src/plugins/source-contract/vendor/params.js +3 -3
  32. package/src/plugins/source-contract/vendor/permission.js +3 -3
  33. package/src/plugins/source-contract/vendor/pick.js +5 -5
  34. package/src/plugins/source-contract/vendor/read.js +14 -14
  35. package/src/plugins/source-contract/vendor/registry.js +4 -4
  36. package/src/plugins/source-contract/vendor/schema.js +14 -10
  37. package/src/plugins/source-contract/vendor/schemas/fact.commitment.json +57 -0
  38. package/src/plugins/source-contract/vendor/schemas/fact.meeting.attended.json +35 -0
  39. package/src/plugins/source-contract/vendor/schemas/fact.person.attribute.json +37 -0
  40. package/src/plugins/source-contract/vendor/schemas/hint.json +41 -0
  41. package/src/plugins/source-contract/vendor/schemas/routine.json +67 -0
  42. package/src/plugins/source-contract/vendor/schemas/sources.json +56 -0
  43. package/src/plugins/source-contract/vendor/schemas.js +16 -11
  44. package/src/plugins/source-contract/vendor/tools-rpc.js +4 -4
  45. package/src/records.js +5 -0
  46. package/src/vendor/source-contract/README.md +10 -8
  47. package/src/vendor/source-contract/VENDOR.json +48 -39
  48. package/src/vendor/source-contract/chunks/{chunk-JUWIMDGF.js → chunk-6ZSJSJMV.js} +2 -2
  49. package/src/vendor/source-contract/chunks/{chunk-T4QM7B3S.js → chunk-CUITXC5J.js} +1 -1
  50. package/src/{plugins/source-contract/vendor/chunks/chunk-OZMX7VR7.js → vendor/source-contract/chunks/chunk-EOS4LD6F.js} +1 -1
  51. package/src/vendor/source-contract/chunks/{chunk-BOUWB5UP.js → chunk-GDBKZBG7.js} +2 -2
  52. package/src/vendor/source-contract/chunks/{chunk-X6XP7YK2.js → chunk-IGPRJ63D.js} +2 -2
  53. package/src/vendor/source-contract/chunks/{chunk-YH323FAZ.js → chunk-LJL3EALP.js} +238 -12
  54. package/src/vendor/source-contract/chunks/{chunk-NUEROZNU.js → chunk-NUBUQFLH.js} +1 -1
  55. package/src/vendor/source-contract/cursor.js +3 -3
  56. package/src/vendor/source-contract/events.js +22 -4
  57. package/src/vendor/source-contract/registry.js +4 -4
  58. package/src/vendor/source-contract/tools-rpc.js +4 -4
  59. package/src/views/contracts.js +5 -1
  60. package/src/views/rpc.js +11 -0
  61. package/src/views/shape.js +11 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,87 @@
3
3
  The format follows Keep a Changelog 1.1.0: one `## [x.y.z] - date` section per
4
4
  release.
5
5
 
6
+ ## [0.12.6] - 2026-11-18
7
+
8
+ ### Fixed
9
+
10
+ - The daily routine loses no collected item:
11
+ - A unit is marked read only after its items and the journal are saved; a failed write leaves it unread.
12
+ - A day is due when items arrive for it, by ingest time, so a late arrival, a backfill or a closed laptop is caught
13
+ up. The watermark is taken before the read, so an item ingested during a run is read by the next one.
14
+ - Past days with unread units are caught up oldest first, within half of each day's budget, so today is never
15
+ starved.
16
+ - A re-run reads only new or changed units, and merges the earlier journal, keeping its highlights and dropping a
17
+ line whose cited source was forgotten or removed. Cited records are read fifty at a time.
18
+ - The person's own and addressed threads are read first; coding sessions take at most 40% of a run, yet every run
19
+ reads at least one unit, and a day that cannot progress is reported, not left to block the others.
20
+ - A model call is charged only the tokens the provider billed. A 429 is honoured with its `Retry-After` and ends the
21
+ run's remaining batches; a provider or network outage trips one breaker for the whole service, not every space's.
22
+ - A read mark goes with the events it is about. A forget, an erasure, a source's removal and retention delete the
23
+ marks of the units their events were in, so the same ids collected again are read, not skipped as already read.
24
+ - A bind request that names an account probes that account; only a request for `default` adopts the signed-in one.
25
+ - A commitment control needs its `revision` again, and a stale one is refused, naming the current one.
26
+
27
+ ### Added
28
+
29
+ - Memory accepts pages written to the source contract v0.3.0: actor `kind`, `identities` and `self`, `reply_to`,
30
+ `audience`, `domains`, `sections`, `parts` and `facts`, and a descriptor's `facts`, `hints` and `routines`. Only an
31
+ actor's declared `kind` is read now: a `kind` of `agent`, `bot`, `service`, `tool` or `system` keeps that actor off
32
+ person pages. The other fields are kept as they are for a later release. A removal, a forget and an erasure clear
33
+ them. `self` is stored, never trusted: Memory alone decides who the person is. The author is the first `from`, or
34
+ else the first `author`.
35
+ - Jelly's settings show the `actions` switch, **Let buttons change my memory**, so a person can see it and turn it off.
36
+ It is off by default, as before: a button on Memory's pages changes nothing until a host or the person turns it on.
37
+
38
+ ### Deploy
39
+
40
+ The records service needs a deploy, **before** the plugin and before any source plugin writes a v0.3 field: an older
41
+ records build refuses an event that carries one, and the collector's cursor moves past it, so the event is lost without
42
+ an error. Additive: a `unit_reads` table and an `events.meta` column, with no schema version change, so an older
43
+ service opens the file unchanged. After a rollback, `events.meta` stays in place (see
44
+ [Upgrade to 0.12.6](docs/deployment.md#upgrade-to-0126-the-source-contracts-v03-fields)).
45
+
46
+ ## [0.12.5] - 2026-11-18
47
+
48
+ ### Fixed
49
+
50
+ - A host-bound source (`history`) is collected on its own machine again. 0.12.4 compared the binding's account with
51
+ the raw host name, so a machine whose name differed from the account only by case or a `.local` suffix left its own
52
+ history alone. The plugin's own probe, run on this machine, now decides; without an answer, the account and the host
53
+ name are compared the way the plugin writes them (lowercase, no `.local`, punctuation as `-`).
54
+ - A bind request learns its account from the plugin. The probe is called without naming an account, so a plugin
55
+ signed in under a real account name, such as a code host's login or a tracker's workspace user, reports it instead of
56
+ refusing `default` with `ACCOUNT_MISMATCH`. A structured "read as" answer is adopted; a real `default` stays `default`.
57
+ - The daily routine sends each model call only the context linked to its units: the people and projects among the
58
+ units' actors or named in their text, and at most 10 current memories and the open commitments linked to them. At a
59
+ large space's sizes, a call's fixed part falls from about 11,000 to about 700 tokens, so a day fits its budget.
60
+ Memories are ranked: those linked to the batch's entities first, then by the distinctive terms they share with the
61
+ batch's text, then by recency. Validation still refuses an id the model invents.
62
+ - Greetings and acknowledgements are noise. An event is noise only when its author is a bot, a service or an
63
+ automation: a bot elsewhere on an event, such as a meeting's notetaker or a notifications address in Cc, is ignored,
64
+ and the event's items are kept.
65
+ - An agent, bot or service actor never becomes a person page: by the role `agent`, by an `opencode-agent:` id, by a
66
+ declared kind, or by an OpenCode agent's name.
67
+ - A model answer cut off at the output cap keeps its complete items, instead of failing the whole batch.
68
+ - Lint skips an item a person forgot, and counts it, instead of failing the run.
69
+ - `RECORDS_ACTIONS_ENABLED` accepts any act the build registers, three-part names such as `space.joinRequest.decide`
70
+ included. An unknown name still fails startup.
71
+
72
+ ### Added
73
+
74
+ - The journal's summary says how many items the run dropped, already knew, rejected and found truncated, and how many
75
+ wait for review.
76
+ - `RECORDS_ROUTINE_BATCH_CHARS` and `RECORDS_ROUTINE_MAX_OUTPUT_TOKENS` set a call's data size and output cap. The
77
+ defaults are unchanged.
78
+ - `commitments.list` items carry `space` and `revision`, so a host can act on a listed commitment without reading it
79
+ again. An item stored without a version carries no `revision`, and the act reads the record's own.
80
+ - `memory.saveLine` saves a line from a conversation as a cited fact. It is the person's statement only when the
81
+ line's author is the person. The line and its citation are both checked for secrets and emails.
82
+
83
+ ### Deploy
84
+
85
+ The records service needs a deploy for the routine, act and list changes. No schema change and no migration.
86
+
6
87
  ## [0.12.4] - 2026-11-18
7
88
 
8
89
  ### Fixed
package/README.md CHANGED
@@ -326,6 +326,7 @@ not clean, without an error, and draws a monogram instead, so
326
326
  | `ownService` | boolean | **Use my own Memory service.** Off by default: the service the Jelly account offers, and nothing of your own is read (no address, no key). On: the address and key below; on with no address loads and says which field to fill |
327
327
  | `controlURL` | string | Memory address, shown and read only with `ownService` on. Empty otherwise: the Jelly account's memory origin |
328
328
  | `capture` | boolean | On by default. Off: the tools still work and nothing is captured, the compaction checkpoint included |
329
+ | `actions` | boolean | **Let buttons change my memory.** Off by default: a button on Memory's pages, such as Mark done, changes nothing and says that actions are off. On: a press changes your memory, as you, under a grant your Jelly host signs |
329
330
  | `skipAsks` | string | **Run without asking.** Empty by default. Default asks to turn off, comma-separated (see [docs/permissions.md](docs/permissions.md)); a held team write still waits in the Inbox |
330
331
  | `token` | secret | Memory key, shown with `ownService` on (display only: a saved key is read either way). For a host without a Jelly sign-in that offers memory, and the fallback when Jelly refuses a token (not after `access_denied`). A saved key reaches the plugin at the engine's next start, and it presets Memory's `account` sign-in (`jelly.signIns`) |
331
332
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joe-broadhead/opencode-mem",
3
- "version": "0.12.4",
3
+ "version": "0.12.6",
4
4
  "type": "module",
5
5
  "description": "Durable private and shared-space memory for OpenCode agents",
6
6
  "license": "MIT",
@@ -1174,7 +1174,9 @@
1174
1174
  "state",
1175
1175
  "when",
1176
1176
  "overdue",
1177
- "dueToday"
1177
+ "dueToday",
1178
+ "space",
1179
+ "revision"
1178
1180
  ],
1179
1181
  "properties": {
1180
1182
  "id": {
@@ -1219,6 +1221,14 @@
1219
1221
  "type": "string",
1220
1222
  "maxLength": 80
1221
1223
  },
1224
+ "space": {
1225
+ "type": "string",
1226
+ "maxLength": 128
1227
+ },
1228
+ "revision": {
1229
+ "type": "integer",
1230
+ "minimum": 1
1231
+ },
1222
1232
  "closed": {
1223
1233
  "type": "string",
1224
1234
  "maxLength": 40
@@ -6097,6 +6107,13 @@
6097
6107
  "default": true,
6098
6108
  "description": "On by default: finished turns are saved to your private memory. Off: the memory tools still work, and nothing is saved unless the agent is asked to remember it."
6099
6109
  },
6110
+ {
6111
+ "key": "actions",
6112
+ "label": "Let buttons change my memory",
6113
+ "type": "boolean",
6114
+ "default": false,
6115
+ "description": "Off by default: a button on Memory's pages in Jelly, such as Mark done, changes nothing and says that actions are off. On: a press changes your memory, as you, under a grant your Jelly host signs."
6116
+ },
6100
6117
  {
6101
6118
  "key": "skipAsks",
6102
6119
  "label": "Run without asking",
@@ -7534,6 +7551,134 @@
7534
7551
  },
7535
7552
  "tool": "mem.revise"
7536
7553
  },
7554
+ {
7555
+ "name": "memory.saveLine",
7556
+ "label": "save a line to Memory",
7557
+ "target": "engine",
7558
+ "class": "chat",
7559
+ "confirm": "never",
7560
+ "views": [
7561
+ "memory"
7562
+ ],
7563
+ "done": "Saved.",
7564
+ "input": {
7565
+ "type": "object",
7566
+ "additionalProperties": false,
7567
+ "required": [
7568
+ "text",
7569
+ "from"
7570
+ ],
7571
+ "properties": {
7572
+ "text": {
7573
+ "type": "string",
7574
+ "maxLength": 4000
7575
+ },
7576
+ "from": {
7577
+ "type": "object",
7578
+ "additionalProperties": false,
7579
+ "required": [
7580
+ "conversation",
7581
+ "line"
7582
+ ],
7583
+ "properties": {
7584
+ "conversation": {
7585
+ "type": "string",
7586
+ "maxLength": 200
7587
+ },
7588
+ "line": {
7589
+ "type": "string",
7590
+ "maxLength": 200
7591
+ },
7592
+ "author": {
7593
+ "type": "string",
7594
+ "maxLength": 200
7595
+ },
7596
+ "at": {
7597
+ "type": "string",
7598
+ "maxLength": 40
7599
+ }
7600
+ }
7601
+ },
7602
+ "space": {
7603
+ "type": "string",
7604
+ "maxLength": 128
7605
+ },
7606
+ "jellySpeaker": {
7607
+ "type": "string"
7608
+ }
7609
+ }
7610
+ },
7611
+ "output": {
7612
+ "type": "object",
7613
+ "required": [
7614
+ "ok"
7615
+ ],
7616
+ "properties": {
7617
+ "ok": {
7618
+ "type": "boolean"
7619
+ },
7620
+ "id": {
7621
+ "type": "string",
7622
+ "maxLength": 200
7623
+ },
7624
+ "version": {
7625
+ "type": "integer",
7626
+ "minimum": 0
7627
+ },
7628
+ "state": {
7629
+ "type": "string",
7630
+ "maxLength": 40
7631
+ },
7632
+ "applied": {
7633
+ "type": "string",
7634
+ "maxLength": 200
7635
+ },
7636
+ "space": {
7637
+ "anyOf": [
7638
+ {
7639
+ "type": "string",
7640
+ "maxLength": 200
7641
+ },
7642
+ {
7643
+ "type": "object",
7644
+ "properties": {
7645
+ "id": {
7646
+ "type": "string",
7647
+ "maxLength": 200
7648
+ },
7649
+ "name": {
7650
+ "type": "string",
7651
+ "maxLength": 200
7652
+ }
7653
+ },
7654
+ "additionalProperties": false
7655
+ }
7656
+ ]
7657
+ },
7658
+ "count": {
7659
+ "type": "integer",
7660
+ "minimum": 0
7661
+ },
7662
+ "snapshot": {
7663
+ "type": "string",
7664
+ "maxLength": 64
7665
+ },
7666
+ "erased": {
7667
+ "type": "integer",
7668
+ "minimum": 0
7669
+ },
7670
+ "code": {
7671
+ "type": "string",
7672
+ "maxLength": 40
7673
+ },
7674
+ "message": {
7675
+ "type": "string",
7676
+ "maxLength": 600
7677
+ }
7678
+ }
7679
+ },
7680
+ "tool": "mem.remember"
7681
+ },
7537
7682
  {
7538
7683
  "name": "inbox.decide",
7539
7684
  "label": "decide what waits in your Inbox",
package/src/actions.js CHANGED
@@ -107,7 +107,8 @@ export const HELD_FOR_CONTROL_P2 = Object.freeze(["share.transfer", "share.decid
107
107
  * The two acts built for Jelly's #77 and #78, now declared: Jelly 0.4.0-beta.20
108
108
  * carries protocol major 7 and caps a declaration at 48 actions, so 28 declared
109
109
  * plus the four for control's P2 plus these two are 34. Nothing was merged or
110
- * trimmed to make room. `memory.saveLine` is not built and is not declared here.
110
+ * trimmed to make room. `memory.saveLine` (#58 A14) is the thirty-fifth, built
111
+ * and declared here.
111
112
  */
112
113
  export const ACTIONS_NEED_ROOM = true
113
114
 
@@ -353,6 +354,36 @@ export const ACTIONS = Object.freeze([
353
354
  output: actionOutput,
354
355
  tool: "mem.revise",
355
356
  },
357
+ // A14: "Save to Memory" on one line of a Messages conversation. The click on
358
+ // the line is the whole confirmation (it adds to memory and removes nothing),
359
+ // so `chat` and `never`; the line's citation is required, because a memory
360
+ // the person cannot trace back is one they cannot check. It writes a `fact`
361
+ // and never a preference or a procedure: an instruction-shaped line must not
362
+ // come back as a rule.
363
+ {
364
+ name: "memory.saveLine",
365
+ label: "save a line to Memory",
366
+ target: "engine",
367
+ class: "chat",
368
+ confirm: "never",
369
+ views: ["memory"],
370
+ done: "Saved.",
371
+ input: actionInput(
372
+ {
373
+ text: text(4000),
374
+ from: {
375
+ type: "object",
376
+ additionalProperties: false,
377
+ required: ["conversation", "line"],
378
+ properties: { conversation: text(200), line: text(200), author: text(200), at: text(40) },
379
+ },
380
+ space: text(128),
381
+ },
382
+ ["text", "from"],
383
+ ),
384
+ output: actionOutput,
385
+ tool: "mem.remember",
386
+ },
356
387
  // The Inbox's own decision (Jelly's answers 2 and 6): Memory's key for the
357
388
  // item, the decisions the Inbox offers, and the version it showed. It routes
358
389
  // to the same review and held-write decisions a review makes.
@@ -852,6 +883,10 @@ const CODES = Object.freeze({
852
883
  invalid_id: "NOT_FOUND",
853
884
  team_delete_console_only: "NEEDS_APPROVAL",
854
885
  page_lines_kept: "NEEDS_APPROVAL",
886
+ // What may not be stored (#58 A14, and any act whose words records refuses):
887
+ // a secret, a person's email address, a home path; and text a person forgot.
888
+ refused: "NOT_STORED",
889
+ forgotten: "FORGOTTEN",
855
890
  })
856
891
 
857
892
  /** What this module refuses in its own words, and the code the page shows. */
package/src/collector.js CHANGED
@@ -4,7 +4,7 @@ import { isSourceName } from "./source-ids.js"
4
4
  import { ACCOUNT_NAME, DEFAULT_EVERY_MINUTES, contractRefusal, hostBoundSource, resolveDeclaredSource, rpcDefinition, sourceAllowRules, sourceEntry } from "./sources.js"
5
5
  import { acceptAnswer, probe, read } from "./plugins/source-contract/vendor/read.js"
6
6
  import { isBrokerAnswer, sourceReader } from "./plugins/source-contract/vendor/broker-client.js"
7
- import { probeResultProblems } from "./plugins/source-contract/vendor/events.js"
7
+ import { canonicalCode, parseSourceError, probeResultProblems } from "./plugins/source-contract/vendor/events.js"
8
8
  import { cursorAdvance, failureAction, failureFromError } from "./plugins/source-contract/policy.js"
9
9
  import { memoryResourceAvailable } from "./credentials.js"
10
10
 
@@ -134,6 +134,25 @@ export function isAccountName(value) {
134
134
  return typeof value === "string" && ACCOUNT_NAME.test(value)
135
135
  }
136
136
 
137
+ /**
138
+ * The account a plugin's own structured refusal says to read as, or null. Only
139
+ * an `ACCOUNT_MISMATCH` source error whose own `next` (or `what`) says
140
+ * `read as "<account>"` names one: never free text that does not parse, and
141
+ * never another code (0.12.5).
142
+ *
143
+ * @param {unknown} error
144
+ * @returns {string | null}
145
+ */
146
+ export function suggestedAccount(error) {
147
+ const read = parseSourceError(error)
148
+ if (!read || (canonicalCode(read.code) ?? read.code) !== "ACCOUNT_MISMATCH") return null
149
+ for (const text of [read.next, read.what]) {
150
+ const match = /read as "([^"]{1,128})"/i.exec(String(text ?? ""))
151
+ if (match && isAccountName(match[1])) return match[1]
152
+ }
153
+ return null
154
+ }
155
+
137
156
  function bindingKey(binding) {
138
157
  return `${binding.source}\u0000${binding.account || DEFAULT_ACCOUNT}`
139
158
  }
@@ -165,12 +184,36 @@ export function collectableSources(sources, { only } = {}) {
165
184
  return [...seen.values()].sort((a, b) => bindingKey(a).localeCompare(bindingKey(b)))
166
185
  }
167
186
 
187
+ /**
188
+ * The name a plugin gives a machine: lowercase, without a trailing `.local`, and
189
+ * slugged — the history plugin's `identityOf` does
190
+ * `slug(host.replace(/\.local\.?$/i, ""), 63)`, so `Joes-MacBook-Air.local`
191
+ * names the account `joes-macbook-air` (0.12.4).
192
+ *
193
+ * @param {string | null | undefined} name
194
+ * @returns {string}
195
+ */
196
+ export function machineSlug(name) {
197
+ return String(name ?? "")
198
+ .trim()
199
+ .toLowerCase()
200
+ .replace(/\.local\.?$/, "")
201
+ .replace(/[^a-z0-9]+/g, "-")
202
+ .replace(/^-+|-+$/g, "")
203
+ .slice(0, 63)
204
+ }
205
+
168
206
  /**
169
207
  * The machine a host-bound binding belongs to, when it is not this one, or
170
208
  * null. A host-bound source's account names the machine whose own files it
171
209
  * reads (src/sources.js `hostBoundSource`): another machine's collector never
172
210
  * reads it, and never reports on it, so it cannot turn the binding failing
173
- * (0.12.3). Hostnames are case-insensitive.
211
+ * (0.12.3).
212
+ *
213
+ * **Names are compared the way the plugin names them** (0.12.4): a case or
214
+ * `.local` difference is never another machine. Live at 00:14Z on 2026-11-18,
215
+ * the owner's own `history:joes-macbook-air` was left alone on
216
+ * `Joes-MacBook-Air.local`, so it was never collected.
174
217
  *
175
218
  * @param {{ source?: string, account?: string }} binding
176
219
  * @param {string | null | undefined} host this collector's machine
@@ -180,8 +223,8 @@ export function foreignHostSource(binding, host) {
180
223
  if (!hostBoundSource(binding?.source)) return null
181
224
  const named = String(binding?.account ?? "").trim()
182
225
  const here = String(host ?? "").trim()
183
- if (!named || !here || named.toLowerCase() === here.toLowerCase()) return null
184
- return named
226
+ if (!named || !here) return null
227
+ return machineSlug(named) === machineSlug(here) ? null : named
185
228
  }
186
229
 
187
230
  /** The host's tools RPC has no plugin registered under that id right now: the plugin is starting, reloading or unloaded. */
@@ -189,6 +232,56 @@ function rpcUnavailable(error) {
189
232
  return error?.type === "rpc.unavailable" || /^RPC is unavailable\b/.test(String(error?.message ?? ""))
190
233
  }
191
234
 
235
+ /**
236
+ * The account the source's own probe names on this machine, or null when it
237
+ * answers nothing (its RPC is not registered, or the read failed). A probe is a
238
+ * read of the source, so a failure here is not the binding's failure and is not
239
+ * reported as one (0.12.4).
240
+ *
241
+ * @param {{ source: string, account?: string }} binding
242
+ * @param {{ lister: any, prober: any, sessionID?: string | ((binding: object) => Promise<string>), log?: any }} where
243
+ * @returns {Promise<string | null>}
244
+ */
245
+ async function probedMachineAccount(binding, { lister, prober, sessionID, log }) {
246
+ try {
247
+ const entry = resolveDeclaredSource(binding.source).entry ?? sourceEntry(binding.source)
248
+ if (!entry) return null
249
+ const session = typeof sessionID === "function" ? await sessionID(binding) : sessionID
250
+ const answer = entry.contract === "sources"
251
+ ? prober
252
+ ? await prober(entry.source, { account: binding.account }, session)
253
+ : null
254
+ : lister
255
+ ? await lister(binding.source, probeInput(entry, binding.account), session, null)
256
+ : null
257
+ const named = answer?.account ?? answer?.owner?.account
258
+ return typeof named === "string" && named.trim() ? named.trim() : null
259
+ } catch (error) {
260
+ log?.debug?.("a host-bound binding's probe answered nothing", { source: binding?.source, error: errorMessage(error) })
261
+ return null
262
+ }
263
+ }
264
+
265
+ /**
266
+ * Is a host-bound binding another machine's? **The plugin's own probe, run on
267
+ * this machine, wins over the host name** (0.12.4): it names the account this
268
+ * machine's plugin reads, so a binding of that account is this machine's
269
+ * whatever the host is called, and a probe naming another account leaves the
270
+ * binding alone even when the name matches. With no probe answer, the name is
271
+ * compared the way the plugin writes it (`machineSlug`), so a case or `.local`
272
+ * difference is never another machine.
273
+ *
274
+ * @returns {Promise<string | null>} the machine the binding names, when it is not this one
275
+ */
276
+ async function foreignHostBinding(binding, host, { lister, prober, sessionID, log }) {
277
+ if (!hostBoundSource(binding?.source)) return null
278
+ const named = String(binding?.account ?? "").trim()
279
+ if (!named) return null
280
+ const probed = await probedMachineAccount(binding, { lister, prober, sessionID, log })
281
+ if (probed) return machineSlug(probed) === machineSlug(named) ? null : named
282
+ return foreignHostSource(binding, host)
283
+ }
284
+
192
285
  /**
193
286
  * Mark a result whose failure is the host's RPC, not the binding's: it keeps
194
287
  * its last good state in the store (nothing is reported for it), and the run
@@ -800,7 +893,38 @@ export async function probeSource({ entry, ctx, sessionID, account, timeoutMs =
800
893
  },
801
894
  }
802
895
  const installed = { package: entry.package, version: entry.version ?? "0.0.0", directory: "", sources: entry.descriptor, hash: entry.descriptorHash }
803
- const outcome = await probe(host, { installed, source: entry.source, account: account ?? DEFAULT_ACCOUNT, identityOperations: ["probe"] })
896
+ // **No account named: the probe learns it** (0.12.5). The contract's own
897
+ // `probe` always names the account it expects and refuses an answer for
898
+ // another, which is exactly what a bind request does not yet know: live at
899
+ // 00:43Z on 2026-11-18, Memory named `default` and github, granola and linear
900
+ // each answered ACCOUNT_MISMATCH. So the method is called with the source's
901
+ // declared input alone, and its answer is checked by the contract's own
902
+ // `probeResultProblems`, which needs no expected account.
903
+ if (account === undefined || account === null) {
904
+ const client = ctx.rpc({ id: entry.rpc, events: {}, methods })
905
+ if (typeof client?.probe !== "function") throw missingMethod("probe")
906
+ const name = typeof entry.item.input?.source === "string" ? { source: entry.item.input.source } : {}
907
+ let answer
908
+ try {
909
+ answer = await boundedSourceCall(client, "probe", name, sessionID, timeoutMs)
910
+ } catch (error) {
911
+ if (error?.type === "rpc.method_not_found") throw missingMethod("probe")
912
+ throw error
913
+ }
914
+ if (answer?.owner === undefined || answer?.owner === null) {
915
+ const error = new Error(`NEEDS_SIGN_IN: ${oneLine(String(entry.source), 40)} is not signed in. Next step: sign the plugin in to the account you mean.`)
916
+ error.code = "NEEDS_SIGN_IN"
917
+ throw error
918
+ }
919
+ const problems = probeResultProblems(answer, name)
920
+ if (problems.length > 0) {
921
+ const error = new Error(`SCHEMA_VIOLATION: ${entry.source}'s probe answer is not the contract's: ${problems[0]} Next step: report it to the plugin's maintainers.`)
922
+ error.code = "SCHEMA_VIOLATION"
923
+ throw error
924
+ }
925
+ return answer
926
+ }
927
+ const outcome = await probe(host, { installed, source: entry.source, account, identityOperations: ["probe"] })
804
928
  if (!outcome.ok) {
805
929
  const error = new Error(outcome.failure.message)
806
930
  error.code = outcome.failure.code
@@ -809,7 +933,7 @@ export async function probeSource({ entry, ctx, sessionID, account, timeoutMs =
809
933
  }
810
934
  // The contract's one probe check, called by the consumer too: the answer names the source and the account,
811
935
  // carries owner { id, label } (never null) and trust: "untrusted", and reads no content (D8, D230).
812
- const problems = probeResultProblems(outcome.answer, { ...(entry.pageSource ? { source: entry.pageSource } : {}), account: account ?? DEFAULT_ACCOUNT })
936
+ const problems = probeResultProblems(outcome.answer, { ...(entry.pageSource ? { source: entry.pageSource } : {}), account })
813
937
  if (problems.length > 0) {
814
938
  const error = new Error(`SCHEMA_VIOLATION: ${entry.source}'s probe answer is not the contract's: ${problems[0]} Next step: report it to the plugin's maintainers.`)
815
939
  error.code = "SCHEMA_VIOLATION"
@@ -825,7 +949,9 @@ export function hostSourceProber(ctx) {
825
949
  const entry = sourceEntry(source)
826
950
  if (!entry) throw new Error(`${oneLine(source, 40)} is not a source Memory knows`)
827
951
  if (entry.contract !== "sources") throw new Error(`${oneLine(source, 40)} is read through its events_list, not probed`)
828
- return probeSource({ entry, ctx, sessionID, account: input?.account ?? DEFAULT_ACCOUNT })
952
+ // An account is named only when the caller names one: a bind request asks the
953
+ // plugin which account it is signed in to (0.12.5).
954
+ return probeSource({ entry, ctx, sessionID, ...(input?.account ? { account: input.account } : {}) })
829
955
  }
830
956
  }
831
957
 
@@ -921,8 +1047,9 @@ export function createCollector({ scheduler = null, lister = null, prober = null
921
1047
  lister?.resetBrokerTick?.()
922
1048
  for (const binding of collectableSources(sources, { only })) {
923
1049
  // Another machine's host-bound binding: not read, not reported, and so
924
- // never turned failing here (0.12.3). The row says whose it is.
925
- const elsewhere = foreignHostSource(binding, host)
1050
+ // never turned failing here (0.12.3). The row says whose it is. The
1051
+ // plugin's probe on this machine decides first (0.12.4).
1052
+ const elsewhere = await foreignHostBinding(binding, host, { lister, prober, sessionID, log })
926
1053
  if (elsewhere) {
927
1054
  results.push({ ...binding, pages: 0, accepted: 0, duplicates: 0, refused: 0, more: false, otherHost: elsewhere, done: true })
928
1055
  continue
@@ -1168,8 +1295,40 @@ export function createCollector({ scheduler = null, lister = null, prober = null
1168
1295
  // A declared source has the contract's `probe` (D11); the owner-only
1169
1296
  // `events_list({ limit: 0 })` page is the previous contract's, and only
1170
1297
  // for a plugin that declares no source.
1298
+ // **A declared source's probe is not told an account** (0.12.5): the
1299
+ // plugin answers the account it is signed in to. Live at 00:43Z on
1300
+ // 2026-11-18, Memory named `default`, and github, granola and linear
1301
+ // each answered ACCOUNT_MISMATCH, so none of the three could bind. **A
1302
+ // request that names an account is that account** (0.12.6): a
1303
+ // multi-account plugin is probed as `work` when the person asked for
1304
+ // `work`, and its refusal is the answer, never a quiet rebind. A
1305
+ // plugin that still refuses a default request is asked once with the
1306
+ // account its own structured answer names, and nothing is adopted from
1307
+ // unparsed text.
1308
+ const ask = (input) => (prober ? prober(reading.source, input, session) : Promise.reject(new Error("this host gives plugins no tools RPC, so a source cannot be probed")))
1309
+ const declaredAnswer = async () => {
1310
+ const named = asked.account && asked.account !== DEFAULT_ACCOUNT ? asked.account : null
1311
+ if (named) return ask({ account: named })
1312
+ try {
1313
+ return await ask({})
1314
+ } catch (error) {
1315
+ const suggested = suggestedAccount(error)
1316
+ if (!suggested) throw error
1317
+ try {
1318
+ return await ask({ account: suggested })
1319
+ } catch (retry) {
1320
+ // A retry that fails keeps the first refusal's reason too: the two
1321
+ // say different things (the account, then why it still failed) and
1322
+ // the person needs both (0.12.6, the re-review's L).
1323
+ const both = new Error(`${oneLine(errorMessage(retry), 300)} (the first attempt said: ${oneLine(errorMessage(error), 300)})`)
1324
+ both.code = retry?.code ?? error?.code
1325
+ both.next = retry?.next ?? error?.next
1326
+ throw both
1327
+ }
1328
+ }
1329
+ }
1171
1330
  const answer = reading.contract === "sources"
1172
- ? await (prober ? prober(reading.source, { account: asked.account }, session) : Promise.reject(new Error("this host gives plugins no tools RPC, so a source cannot be probed")))
1331
+ ? await declaredAnswer()
1173
1332
  : await (lister ? lister(asked.source, probeInput(reading, asked.account), session) : Promise.reject(new Error("this host gives plugins no way to call another plugin's events_list")))
1174
1333
  // A name the declaration has replaced says which source binds instead:
1175
1334
  // the store refuses a retired name, so the person needs the one to use.
@@ -1181,7 +1340,10 @@ export function createCollector({ scheduler = null, lister = null, prober = null
1181
1340
  source: asked.source,
1182
1341
  account: asked.account,
1183
1342
  owner,
1184
- reported_account: answer.account,
1343
+ // The account the probe names is the binding's account: the store
1344
+ // confirms it, and a page of a declared source always names it
1345
+ // (0.12.3). A name Memory cannot hold is not reported.
1346
+ ...(isAccountName(answer.account) ? { reported_account: answer.account } : {}),
1185
1347
  // The installed declaration's digest, read from disk: a re-consent records the digest the installed
1186
1348
  // package has now, so jelly never refuses a read made under the old one. Only for the declared id
1187
1349
  // itself: a consent recorded under a retired name never reads that declaration.
@@ -1196,7 +1358,9 @@ export function createCollector({ scheduler = null, lister = null, prober = null
1196
1358
  body = { source: asked.source, account: asked.account, note: oneLine(errorMessage(answer?.setup || `${reading.package}'s ${reading.contract === "sources" ? "probe" : "events_list"} named no signed-in account; sign in to it in its own plugin.`), 400) }
1197
1359
  }
1198
1360
  } catch (error) {
1199
- body = { source: asked.source, account: asked.account, note: oneLine(errorMessage(error), 400) }
1361
+ // A refusal keeps its own words, and a failed retry keeps both reasons:
1362
+ // the store holds a note of 500 (0.12.6).
1363
+ body = { source: asked.source, account: asked.account, note: oneLine(errorMessage(error), 500) }
1200
1364
  }
1201
1365
  probe.note = body.note ?? null
1202
1366
  try {
@@ -4,8 +4,8 @@
4
4
  * DESIGN-MEMORY-JOBS §8.3).
5
5
  *
6
6
  * The contract's package is `we-the-rebel-alliance/source-contract`. **It is
7
- * vendored, not depended on** (`vendor/`, the locked v0.2.0 release at
8
- * `88bdc1e3`, with `PROVENANCE.json` and `SHA256SUMS`), so an install of Memory
7
+ * vendored, not depended on** (`vendor/`, the locked v0.3.0 release at
8
+ * `2fd55cdc`, with `PROVENANCE.json` and `SHA256SUMS`), so an install of Memory
9
9
  * runs no build and there is no runtime dependency. Everything the contract
10
10
  * defines comes from it:
11
11
  *
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "package": "@we-the-rebel-alliance/source-contract",
3
3
  "repo": "https://github.com/we-the-rebel-alliance/source-contract",
4
- "version": "0.2.0",
5
- "commit": "88bdc1e32af83098e06e6fb234ae267d91a4320e",
6
- "tag": "v0.2.0",
7
- "tagObject": "6c2eaac8d3cc83886b4916e96f79fe1fd7d6199a",
8
- "release": "https://github.com/we-the-rebel-alliance/source-contract/releases/tag/v0.2.0",
9
- "commitNote": "The release's tag: annotated tag v0.2.0 (6c2eaac8) on 88bdc1e, which is v0.1.0 (8ace21db) plus #29-#41. Copied from the release tarball's dist/ after verifying the tarball, the conformance kit and the schemas against the release's SHA256SUMS.",
4
+ "version": "0.3.0",
5
+ "commit": "2fd55cdc0c6c1067927fefc403a88bfd18c9a971",
6
+ "tag": "v0.3.0",
7
+ "tagObject": "6e5136e274b7071d326d09d4ae5812b135228afb",
8
+ "release": "https://github.com/we-the-rebel-alliance/source-contract/releases/tag/v0.3.0",
9
+ "commitNote": "The release's tag: annotated tag v0.3.0 (6e5136e2) on 2fd55cdc, which is v0.2.0 (88bdc1e3) plus the v0.3 additions (#46): an actor's kind, identities and self, an event's reply_to, audience, domains, sections, parts and facts, and the descriptor's facts, hints and routines. Copied from the release tarball's dist/ after verifying the tarball, the conformance kit and the schemas against the release's SHA256SUMS.",
10
10
  "path": "dist/",
11
- "files": 41,
11
+ "files": 48,
12
12
  "sha256sums": "SHA256SUMS",
13
13
  "releaseSha256sums": "RELEASE-SHA256SUMS",
14
- "manifestSha256": "bad4db73bc6452eb8a50e0d47c3c5d1be4e67099535837cd814cc73d8402219e",
15
- "vendored": "2026-11-17",
14
+ "manifestSha256": "fe12db607fb1493a90f94f128b1617993cd4e5286a20e064bbc63967d3b2dfc5",
15
+ "vendored": "2026-11-18",
16
16
  "note": "Memory bundles it, so an install runs no build and there is no runtime dependency. dist/*.d.ts are not vendored: Memory reads JavaScript. test/source-contract.test.js checks every file against SHA256SUMS and this manifest hash; test/contract-release.test.js checks them against the release tarball pinned in test/fixtures/contract/."
17
17
  }
@@ -1,3 +1,3 @@
1
- d4ca51d3fe8faf1cfa1c105bb31794207b15f0323acb58f6beafdeea52abdbe8 source-contract-0.2.0.tgz
2
- 2a47f3cfdf49ce648d5af59ba8ef572885897112c8fa2bc586aff4caedc0360f source-contract-conformance-0.2.0.mjs
3
- 8be41f62e41b0d25a40f558bf275867f45eb1c5d5ed8cc2a6b949b75f7b062bd source-contract-schemas-0.2.0.json
1
+ 120cc9452302571d9674ecf108113a60390b96add0be7953bb5a1040c0a25a73 source-contract-0.3.0.tgz
2
+ 721279b2d6a1706a992b532285647db67e72f02cc4e9dde1dadf691e3d1b2863 source-contract-conformance-0.3.0.mjs
3
+ fee84bb0cd88037272c2342cbcaf7b2d8b9052ba006592c1d3051408ec4fb172 source-contract-schemas-0.3.0.json