@dreamforgestudiollc/emet 0.3.1 → 0.3.2

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 (71) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +29 -6
  3. package/docs/BOOTSTRAP.md +2 -0
  4. package/docs/BOTS.md +8 -7
  5. package/docs/DEPLOY.md +6 -0
  6. package/docs/ERROR-CODES-SPEC.md +2 -2
  7. package/docs/ERROR-CODES.md +29 -0
  8. package/docs/GUIDED-SETUP.md +1 -1
  9. package/docs/PERMISSIONS.md +5 -5
  10. package/docs/SETUP.md +10 -4
  11. package/docs/SUBKEYS.md +4 -4
  12. package/package.json +2 -2
  13. package/server.json +8 -4
  14. package/src/aleph.js +34 -13
  15. package/src/annotations.js +6 -2
  16. package/src/approve-throttle.js +3 -0
  17. package/src/atlas-role.js +1 -1
  18. package/src/attribution.js +76 -28
  19. package/src/bound-door.js +170 -0
  20. package/src/break-glass.js +531 -0
  21. package/src/checkpoint.js +241 -0
  22. package/src/chooser.js +543 -0
  23. package/src/claimed-tag.js +140 -0
  24. package/src/conformance.js +269 -5
  25. package/src/deep-links.js +267 -0
  26. package/src/dispatch.js +112 -18
  27. package/src/error-codes.js +29 -0
  28. package/src/error-log.js +138 -26
  29. package/src/error-report.js +17 -5
  30. package/src/gaps.js +1 -1
  31. package/src/grants.js +230 -0
  32. package/src/http-remote.js +80 -26
  33. package/src/index.js +18 -2
  34. package/src/invites.js +47 -1
  35. package/src/layers.js +1 -1
  36. package/src/lessons-to-checks.js +1 -1
  37. package/src/logger.js +3 -1
  38. package/src/oauth-provider.js +89 -5
  39. package/src/owl.js +232 -0
  40. package/src/owner-approvals.js +24 -267
  41. package/src/owner-session.js +174 -0
  42. package/src/pages.js +1 -1
  43. package/src/persons.js +39 -6
  44. package/src/proof-run.js +70 -0
  45. package/src/redact.js +4 -0
  46. package/src/request-log.js +2 -2
  47. package/src/rotate.js +554 -0
  48. package/src/rune-dispatch.js +1 -1
  49. package/src/session-graph.js +44 -25
  50. package/src/session.js +3 -3
  51. package/src/setup.js +21 -12
  52. package/src/staged-write.js +522 -0
  53. package/src/startup-pages.js +2 -2
  54. package/src/startup-payload.js +3 -3
  55. package/src/subkeys.js +61 -0
  56. package/src/tools.js +270 -78
  57. package/src/transcript-session.js +23 -4
  58. package/src/validation.js +1 -1
  59. package/src/version.js +1 -1
  60. package/src/writer-approval.js +394 -0
  61. package/templates/AREA.md +1 -1
  62. package/templates/BOTHANDOFF.md +2 -2
  63. package/templates/GRANT.md +48 -0
  64. package/templates/INDEX.md +9 -7
  65. package/templates/PROCEDURE.md +1 -1
  66. package/templates/ROSTER.md +2 -2
  67. package/templates/SEED.md +2 -2
  68. package/templates/SESSIONDISPOSITION.md +59 -0
  69. package/templates/STAGING.md +1 -1
  70. package/templates/STANDARD.md +1 -1
  71. package/templates/THREAD.md +1 -1
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * EMET - the session graph: the monorail under the guardrails (2026-09-29,
3
- * board board 120, design staging/emet-session-graph.md; the practice is
3
+ * board board 120, design the staging note; the practice is
4
4
  * docs/GUARDRAILS-AND-MONORAILS.md).
5
5
  *
6
6
  * Alex: "guardrails give a field of movement and execution to allow an AI to do
@@ -61,7 +61,8 @@ export function graphMode() {
61
61
 
62
62
  /** Tools the graph governs: every tool that writes. Reads are never gated. */
63
63
  export const GRAPH_WRITE_TOOLS = Object.freeze(new Set([
64
- 'save_to_layer', 'revise_memory', 'write_doc', 'patch_doc', 'retire_doc', 'rename_doc', 'restore_doc',
64
+ 'save_to_layer', 'revise_memory', 'write_doc', 'write_doc_begin', 'write_doc_append', 'write_doc_commit', 'write_doc_abort',
65
+ 'patch_doc', 'retire_doc', 'rename_doc', 'restore_doc',
65
66
  'accept_nonconformance', 'emet_transcript_append', 'save_transcript', 'revise_transcript',
66
67
  'emet_session_close'
67
68
  ]));
@@ -71,7 +72,7 @@ export const BOARD_DOC = 'STATE.md';
71
72
 
72
73
  /**
73
74
  * Per-bot close records (C1, 2026-10-01; review note "C1: per-bot close
74
- * records", the owner's decisions 1-7). The rule, stated once: a session written
75
+ * records", Alex's decisions 1-7). The rule, stated once: a session written
75
76
  * under a bot's source tag closes against that bot's own records
76
77
  * (bots/<tag>/HANDOFF.md); only that tag's own revisions in the session window
77
78
  * count; a bot tag never writes or cites the main HANDOFF.md or STATE.md.
@@ -111,13 +112,20 @@ export function writeSourceOf(args = {}) {
111
112
  return typeof v === 'string' && v.trim() ? v.trim() : null;
112
113
  }
113
114
 
114
- /** Whether this call writes a bot's own handoff under that bot's tag: write_doc of bots/<source>/HANDOFF.md by a bot tag. */
115
+ /** write_doc, and the staged begin/commit that land a handoff through that door. Append and abort do not. */
116
+ const HANDOFF_STAGE_TOOLS = new Set(['write_doc', 'write_doc_begin', 'write_doc_commit']);
117
+
118
+ /** Whether this call writes a bot's own handoff under that bot's tag: write_doc (or staged begin/commit) of bots/<source>/HANDOFF.md by a bot tag. */
115
119
  export function isBotHandoffWrite(tool, args = {}) {
116
- if (tool !== 'write_doc') return false;
120
+ if (!HANDOFF_STAGE_TOOLS.has(tool)) return false;
117
121
  const tag = writeSourceOf(args);
118
122
  return !!tag && isBotTag(tag) && args.doc_id === botHandoffDoc(tag);
119
123
  }
120
124
 
125
+ function handoffRecordWrite(tool, args = {}) {
126
+ return HANDOFF_STAGE_TOOLS.has(tool) && (args.doc_id === HANDOFF_DOC || isBotHandoffWrite(tool, args));
127
+ }
128
+
121
129
  /** The base session id of a part id (2026-09-30_x_verbatim_part2 -> 2026-09-30_x). */
122
130
  export function baseOf(sessionId) {
123
131
  return String(sessionId || '').replace(/_verbatim_part\d+$/, '') || null;
@@ -139,7 +147,7 @@ export function echoId(id) {
139
147
  * Every session base an id could belong to, the way the close check groups a
140
148
  * session's documents (session.js inspectSession: ^base(_.*)?$). An id like
141
149
  * `<base>_extra` is counted by the close as part of `<base>`, so the closed-
142
- * session guard must treat it as `<base>` too (2026-10-01, the reviewer's gate
150
+ * session guard must treat it as `<base>` too (2026-10-01, Reviewer's gate
143
151
  * (a)). Longest first: the id itself, then each prefix ending before a `_`.
144
152
  */
145
153
  export function candidateBases(sessionId) {
@@ -172,7 +180,7 @@ export function groupedUnder(sessionId, base) {
172
180
  * that shape ("receipts.transcript_session_id is used when this is omitted")
173
181
  * and sessionClose checks that session; until 2026-10-01 the graph read only
174
182
  * `session_id`, so a close naming its session only in the receipts was never
175
- * recorded and the session stayed open (the second reader's nit 3 on an earlier draft, the reviewer's
183
+ * recorded and the session stayed open (Tester's nit 3 on thatcommit, Reviewer's
176
184
  * condition 1). Receipts sent as JSON text are read as sessionClose reads
177
185
  * them (session.js parseReceipts).
178
186
  */
@@ -196,8 +204,8 @@ function receiptsOf(value) {
196
204
  }
197
205
 
198
206
  /**
199
- * An exchange number as sent, normalized ONCE (2026-10-01, the second reader's re-check of
200
- * an earlier draft). Hosts send numbers as numbers or as text ("4"). The guard read "4"
207
+ * An exchange number as sent, normalized ONCE (2026-10-01, Tester's re-check of
208
+ * thatcommit). Hosts send numbers as numbers or as text ("4"). The guard read "4"
201
209
  * as 4 while emet_transcript_append only took real numbers, so a text "4" was a
202
210
  * "retry" to the guard and "the next exchange" to the tool. dispatch now runs
203
211
  * every exchange_index through this before the graph, the guard and the tool,
@@ -273,8 +281,10 @@ export function evaluate(tool, args = {}, state = {}, highest = 0, now = new Dat
273
281
  }
274
282
  // A bot's own handoff takes the same gate, without the board: a bot session
275
283
  // has no board unless it keeps one as a working document (C1, decision 5).
284
+ // Begin and commit of a handoff take the gate. Append and abort do not, and
285
+ // begin does not count as the handoff being written.
276
286
  const botHandoff = isBotHandoffWrite(tool, args);
277
- if (tool === 'write_doc' && (args.doc_id === HANDOFF_DOC || botHandoff)) {
287
+ if (handoffRecordWrite(tool, args)) {
278
288
  const missing = [];
279
289
  if (!botHandoff && !state.board) missing.push(`the board (${BOARD_DOC}) with patch_doc`);
280
290
  if (!state.episodic) missing.push('the episodic session record with save_to_layer (layer "episodic")');
@@ -290,7 +300,13 @@ export function evaluate(tool, args = {}, state = {}, highest = 0, now = new Dat
290
300
  // pre-call step, because that step is still the one owed.
291
301
  let after = { state, highest };
292
302
  if (tool === 'emet_transcript_append' && n !== null && n === highest + 1) after = { state: { ...state, opened: true }, highest: n };
293
- if (tool === 'write_doc' && (args.doc_id === HANDOFF_DOC || botHandoff)) after = { state: { ...state, handoff: true }, highest };
303
+ if ((tool === 'write_doc' || tool === 'write_doc_commit') && (args.doc_id === HANDOFF_DOC || botHandoff)) after = { state: { ...state, handoff: true }, highest };
304
+ if (tool === 'write_doc_begin' && (args.doc_id === HANDOFF_DOC || botHandoff)) {
305
+ return {
306
+ verdict: 'ok', gate: null, reason: null,
307
+ next: 'write_doc_append each part in order, then write_doc_commit with the sha256 of the whole document'
308
+ };
309
+ }
294
310
  return { verdict: 'ok', gate: null, reason: null, next: nextStep(after.state, after.highest) };
295
311
  }
296
312
 
@@ -311,7 +327,7 @@ export function recordStep(tool, args = {}, data = {}, now = new Date()) {
311
327
  if (tool === 'emet_transcript_append' || tool === 'save_transcript') return null;
312
328
  if (tool === 'save_to_layer' && args.layer === 'episodic') return { episodic: true, episodic_id: data && data.id };
313
329
  if ((tool === 'write_doc' || tool === 'patch_doc' || tool === 'restore_doc') && args.doc_id === BOARD_DOC) return { board: true, board_version: data && data.version };
314
- if (tool === 'write_doc' && (args.doc_id === HANDOFF_DOC || isBotHandoffWrite(tool, args))) return { handoff: true, handoff_version: data && data.version };
330
+ if ((tool === 'write_doc' || tool === 'write_doc_commit') && (args.doc_id === HANDOFF_DOC || isBotHandoffWrite(tool, args))) return { handoff: true, handoff_version: data && data.version };
315
331
  if (tool === 'emet_session_close' && data && data.state === 'complete') return { closed: true, closed_at: now };
316
332
  return null;
317
333
  }
@@ -345,7 +361,7 @@ export async function isSessionClosed(base, dbManager) {
345
361
  }
346
362
 
347
363
  /**
348
- * The closing exchange (2026-10-01, the owner's decision). In the closing turn the
364
+ * The closing exchange (2026-10-01, Alex's decision). In the closing turn the
349
365
  * assistant writes the handoff, gets `complete` from emet_session_close, and
350
366
  * only then replies - so the append of that last exchange always arrives
351
367
  * after the close. A closed session therefore takes exactly ONE more append:
@@ -354,8 +370,8 @@ export async function isSessionClosed(base, dbManager) {
354
370
  * once the window passes, the session is locked. A retry of that same
355
371
  * exchange number is answered as already saved, never as a second write:
356
372
  * the guard answers it itself and the tool is not called, at any time after
357
- * the close, so a retry can write nothing anywhere (2026-10-01, the second reader's blocker
358
- * and the reviewer's gate on an earlier draft). The closing exchange itself is written
373
+ * the close, so a retry can write nothing anywhere (2026-10-01, Tester's blocker
374
+ * and Reviewer's gate on thatcommit). The closing exchange itself is written
359
375
  * into the session's last live part, whatever part or base id the caller sent.
360
376
  *
361
377
  * graceDecision is pure: state is the session row, declared the exchange the
@@ -371,7 +387,7 @@ export const DEFAULT_CLOSE_GRACE_MINUTES = 5;
371
387
  export const MAX_CLOSE_GRACE_MINUTES = 60;
372
388
 
373
389
  /**
374
- * The window setting, checked (2026-10-01, the second reader's nit 4). Unset or blank: the
390
+ * The window setting, checked (2026-10-01, Tester's nit 4). Unset or blank: the
375
391
  * default, 5. A number from 0 to 60: that many minutes (0 turns the window
376
392
  * off). Anything else is NOT silently accepted: a negative or non-numeric value
377
393
  * falls back to the default 5, and a value over 60 is capped at 60; both come
@@ -393,7 +409,7 @@ function closeGraceName() {
393
409
  export function closeGraceSetting(raw = setting('CLOSE_GRACE_MINUTES'), name = closeGraceName()) {
394
410
  if (raw === undefined || raw === null || String(raw).trim() === '') return { minutes: DEFAULT_CLOSE_GRACE_MINUTES, note: null };
395
411
  // Decimal only: Number() also reads hex, octal and binary ("0x10" is 16),
396
- // which no one means for minutes (the second reader's nit 5 on an earlier draft).
412
+ // which no one means for minutes (Tester's nit 5 on thatcommit).
397
413
  const text = String(raw).trim();
398
414
  const n = /^[+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i.test(text) ? Number(text) : NaN;
399
415
  if (!Number.isFinite(n) || n < 0) {
@@ -520,7 +536,7 @@ export async function closedSessionGuard(tool, args = {}, dbManager, now = new D
520
536
  } catch (e) { throw await unreadable(tool, base, 'the transcript part to be revised', e); }
521
537
  if (!part) return null; // the tool itself refuses a revision of a part that does not exist
522
538
  // A correction of a closed session keeps EXACTLY the exchange numbers the
523
- // part holds (2026-10-01, the second reader's nit 2): none added, none dropped, none
539
+ // part holds (2026-10-01, Tester's nit 2): none added, none dropped, none
524
540
  // duplicated. Numbers sent as text are stored as numbers; the corrected
525
541
  // part is stored in exchange order.
526
542
  const held = [...new Set((part.exchanges || []).map((e) => Number(e && e.exchange_index)))].sort((a, b) => a - b);
@@ -566,8 +582,8 @@ export async function closedSessionGuard(tool, args = {}, dbManager, now = new D
566
582
  const d = graceDecision(row, declared, highest, now, minutes);
567
583
 
568
584
  if (d === 'retry') {
569
- // Answered HERE, and the tool is never called (2026-10-01, the second reader's blocker on
570
- // an earlier draft): a retry handed to the tool with the caller's arguments could
585
+ // Answered HERE, and the tool is never called (2026-10-01, Tester's blocker on
586
+ // thatcommit): a retry handed to the tool with the caller's arguments could
571
587
  // land in another part id, the base id, or - with the number sent as text -
572
588
  // as a new exchange, while the reply said nothing was written.
573
589
  return { retry: true, base, index: row.grace_index,
@@ -575,7 +591,7 @@ export async function closedSessionGuard(tool, args = {}, dbManager, now = new D
575
591
  }
576
592
  if (d === 'grace') {
577
593
  const index = highest + 1;
578
- // Pinned to the session's last live part (2026-10-01, the second reader's nit 3), never
594
+ // Pinned to the session's last live part (2026-10-01, Tester's nit 3), never
579
595
  // the part or base id the caller named. If that part is full, the append
580
596
  // rolls to the next part number exactly as a live append does.
581
597
  let part = typeof pos.last_part === 'string' && pos.last_part ? pos.last_part : null;
@@ -793,13 +809,15 @@ export function labRow(tool, args = {}, graph = null, now = new Date(), actor =
793
809
  source: writeSourceOf(args) ?? (args.metadata && typeof args.metadata.source === 'string' && args.metadata.source.trim() ? args.metadata.source.trim() : null),
794
810
  person_id: actor.personId || null,
795
811
  client_id: actor.clientId || 'stdio',
812
+ grant_id: actor.grantId || null,
813
+ door: actor.door || (actor.transport === 'http' ? null : 'stdio'),
796
814
  exchange_declared: declaredExchange(tool, args),
797
815
  highest_appended: Number.isInteger(graph.highest) ? graph.highest : null,
798
816
  mode: block.mode,
799
817
  verdict: block.verdict,
800
818
  gate: d.gate || null,
801
819
  reason: d.reason || null,
802
- ...(tool === 'write_doc' || tool === 'patch_doc' ? { doc_id: args.doc_id || null } : {}),
820
+ ...(tool === 'write_doc' || tool === 'patch_doc' || tool === 'write_doc_begin' || tool === 'write_doc_append' || tool === 'write_doc_commit' || tool === 'write_doc_abort' ? { doc_id: args.doc_id || null } : {}),
803
821
  ...(graph.startup_pages ? { startup_pages: graph.startup_pages } : {})
804
822
  };
805
823
  }
@@ -904,7 +922,7 @@ export function graphBlock(g) {
904
922
  /**
905
923
  * After a successful call: record the step. Never throws - a failed record is
906
924
  * logged, not fatal. Returns what happened, so the close can say so
907
- * (2026-10-01, the second reader's nit 2 on an earlier draft, the reviewer's condition 2):
925
+ * (2026-10-01, Tester's nit 2 on thatcommit, Reviewer's condition 2):
908
926
  * null nothing to record (no session, or no step)
909
927
  * {recorded: true, base} the step was written
910
928
  * {recorded: false, base, error} the write failed (logged as a warning)
@@ -918,10 +936,11 @@ export async function graphAfter(tool, args, data, dbManager, logger = null, now
918
936
  const set = recordStep(tool, args, data, now);
919
937
  if (!set) return null;
920
938
  const col = await sessionsCollection(dbManager);
921
- const { currentPersonId, currentClientId } = await import('./persons.js');
939
+ const { writerStamp } = await import('./persons.js');
940
+ const stamp = writerStamp();
922
941
  const listed = tool === 'emet_session_open' && data && Array.isArray(data.drops_seen) ? data.drops_seen.filter((id) => typeof id === 'string') : [];
923
942
  const opened = tool === 'emet_session_open'
924
- ? { opened_by: { person_id: currentPersonId() || null, client_id: currentClientId() || 'stdio' } }
943
+ ? { opened_by: { person_id: stamp.person_id, client_id: stamp.client_id || 'stdio', grant_id: stamp.grant_id, door: stamp.door } }
925
944
  : {};
926
945
  // Merge, never overwrite: a reopen keeps drops already stamped.
927
946
  // An unverified boot is stored as a flag, never as an empty seen-list.
package/src/session.js CHANGED
@@ -86,9 +86,9 @@ export const CLOSE_PROTOCOL = Object.freeze([
86
86
  {
87
87
  step: 5,
88
88
  artifact: 'handoff - written LAST, in one write',
89
- what: 'A new revision of the handoff record, written whole with write_doc and `supersedes` set to the version in force - a record is superseded, never patched or appended. What was in progress, why it stopped, the exact next steps, and the state a successor needs - documents touched, decisions made, anything half-finished - plus a close verification naming the artifacts above and the evidence each returned.',
89
+ what: 'A new revision of the handoff record, written whole with write_doc — or, when one call cannot carry it, write_doc_begin, write_doc_append, and write_doc_commit, which still land as one write_doc revision — and `supersedes` set to the version in force - a record is superseded, never patched or appended. What was in progress, why it stopped, the exact next steps, and the state a successor needs - documents touched, decisions made, anything half-finished - plus a close verification naming the artifacts above and the evidence each returned.',
90
90
  why: 'The next session begins with no context at all; this document is the only thing that crosses the gap. It is written last because its close verification attests to the other artifacts. Written earlier it attests to things that do not yet exist, and needs a patch afterwards - which is how one reference install ended up with a handoff whose section 6 cited saves made after it was written. If a session ends mid-close the prior handoff stands, and the position marker and session record already carry the session.',
91
- tools: ['write_doc']
91
+ tools: ['write_doc', 'write_doc_begin', 'write_doc_append', 'write_doc_commit']
92
92
  }
93
93
  ]);
94
94
 
@@ -354,7 +354,7 @@ export async function corroborateCoverage(db, baseId) {
354
354
  * The store check above answers "do the artifacts exist". It could not answer
355
355
  * "did the host actually do each step", and a host that skipped a step, or
356
356
  * never read the transcript back, could still walk away with `complete`
357
- * because the store happened to look fine. the owner's requirement (procedural ref 388,
357
+ * because the store happened to look fine. Alex's requirement (procedural ref 388,
358
358
  * 389, 391): the wrap steps HAVE TO BE FOLLOWED, whichever model is hosting,
359
359
  * and a skipped step blocks the close the same way a skipped opening is caught
360
360
  * at initialize.
package/src/setup.js CHANGED
@@ -250,12 +250,21 @@ export function registeredSourceTags() {
250
250
  return env.length ? [...new Set([...env, ...approvedTags()])] : env;
251
251
  }
252
252
 
253
- /** Attribution v2: the caller's real tag, not the server-wide default (Alex 2026-10-12 (c)). */
253
+ /** Attribution v2: the caller's real tag, not the server-wide default (Alex 2026-10-12 (c)).
254
+ * R2 adds the credential: grant_id (the token family) and door. Stdio has no grant. */
254
255
  export function callerAttribution() {
255
256
  const d = declaredAttribution();
256
- if (!d) return { source_tag: setting('SOURCE_TAG') || null };
257
+ if (!d) return { source_tag: setting('SOURCE_TAG') || null, grant_id: null, door: 'stdio' };
257
258
  const tag = d.effective || d.login || null;
258
- return { source_tag: tag, source_basis: d.basis || (tag ? 'login' : 'none'), ...(d.login && d.login !== tag ? { source_login: d.login } : {}), approval_state: d.approval || (d.basis === 'login' ? 'login' : 'unknown'), ...((() => { const v = rememberedView({ rememberedTags: d.rememberedTags, declaredTag: d.declared || d.effective }); return v ? { source_remembered: v } : {}; })()) };
259
+ return {
260
+ source_tag: tag,
261
+ grant_id: d.grantId || null,
262
+ door: d.door || null,
263
+ source_basis: d.basis || (tag ? 'login' : 'none'),
264
+ ...(d.login && d.login !== tag ? { source_login: d.login } : {}),
265
+ approval_state: d.approval || (d.basis === 'login' ? 'login' : 'unknown'),
266
+ ...((() => { const v = rememberedView({ rememberedTags: d.rememberedTags, declaredTag: d.declared || d.effective }); return v ? { source_remembered: v } : {}; })())
267
+ };
259
268
  }
260
269
 
261
270
  export function hostSetupInstructions() {
@@ -618,7 +627,7 @@ export function upsertEnvAssignments(text, assignments) {
618
627
  * owner page and the store already ship. This only writes EMET_SUBKEYS=1, a
619
628
  * pepper, and EMET_SUBKEY_PEPPER_VERSION=1. The pepper is not returned. An
620
629
  * existing strong pepper is kept, not rotated. This does not set process.env:
621
- * the flag takes effect on restart, with the tools and /owner/approvals together.
630
+ * the flag takes effect on restart, with the tools and /owner/chooser together.
622
631
  * A hosted process, where real env vars are the config source, is refused
623
632
  * instead of writing a pepper into the container.
624
633
  */
@@ -653,7 +662,7 @@ export function enableSubkeysAtFirstUse({ envFile = ENV_FILE, env = process.env,
653
662
  try { fs.unlinkSync(tmp); } catch { /* the temp file may not exist */ }
654
663
  throw new ValidationError('more_than_one_bot', 'Could not write .env. Sub-keys were not turned on.', { code: 'EMET-CFG-006' });
655
664
  }
656
- // The flag stays off in this process. Tools and /owner/approvals appear together on restart.
665
+ // The flag stays off in this process. Tools and /owner/chooser appear together on restart.
657
666
  // Register the pepper so a later write that contains it is masked.
658
667
  registerSecretsFromEnv({ EMET_SUBKEY_PEPPER: pepper });
659
668
  return {
@@ -672,7 +681,7 @@ export function subkeySetupNote(multi, subkeys) {
672
681
  return 'The store is set up. Sub-keys were not turned on because .env could not be written. See docs/SUBKEYS.md.';
673
682
  }
674
683
  if (multi && subkeys && subkeys.enabled) {
675
- return 'Sub-keys were written to .env. The pepper is not in this result. Restart (or redeploy) the server once so the tools and /owner/approvals appear together. Each bot\'s tag must be listed in EMET_SOURCE_TAGS. See docs/SUBKEYS.md.';
684
+ return 'Sub-keys were written to .env. The pepper is not in this result. Restart (or redeploy) the server once so the tools and /owner/chooser appear together. Each bot\'s tag must be listed in EMET_SOURCE_TAGS. See docs/SUBKEYS.md.';
676
685
  }
677
686
  if (setting('SUBKEYS') === '1') return 'Sub-keys were already on. This answer does not turn them off.';
678
687
  return 'Sub-keys stay off. See docs/SUBKEYS.md.';
@@ -1121,9 +1130,9 @@ async function buildStartup(options = {}) {
1121
1130
  lessonsPending = { assessed: false, error: e && e.message ? e.message : String(e), pending: [] };
1122
1131
  }
1123
1132
 
1124
- // Stage 1 of the ref 358 startup amendment (2026-10-02; the owner's decision 2,
1133
+ // Stage 1 of the ref 358 startup amendment (2026-10-02; Alex's decision 2,
1125
1134
  // procedural ref 407: "emet_initialize is the startup doorway every bot
1126
- // calls; only first-time setup stays the owner's"). Initialize no longer creates
1135
+ // calls; only first-time setup stays Alex's"). Initialize no longer creates
1127
1136
  // the owner person: that write moved to setupComplete, the owner's
1128
1137
  // first-time setup, so initialize is read-only in every branch and matches
1129
1138
  // its annotation (annotations.js, READ) for every caller. A store with no
@@ -1342,15 +1351,15 @@ function renderUserDoc(a) {
1342
1351
 
1343
1352
  export async function setupComplete(answers = {}, logger = null, options = {}) {
1344
1353
  // First-time setup is the owner's (decision 2, procedural ref 407). Stage 1
1345
- // guards (2026-10-02, the reviewer's stage 1 admission, conditions S1-S2):
1354
+ // guards (2026-10-02, Reviewer's stage 1 admission, conditions S1-S2):
1346
1355
  // - refused under a configured bot tag. The tag is self-declared and
1347
1356
  // emet_initialize takes no source until stage 2, so this is inert until a
1348
1357
  // caller declares a bot tag that Alex has configured (stage 3);
1349
- // - refused on a store that is already set up unless `reissue: true` (the owner's
1358
+ // - refused on a store that is already set up unless `reissue: true` (Alex's
1350
1359
  // answer 5): a re-run replaces the user's identity documents with new
1351
1360
  // versions, so it needs the owner's explicit word. Nothing is written
1352
1361
  // when either refusal fires.
1353
- // S1-1 (the reviewer's re-check of commit-1a215d7): EACH declared value is checked, not
1362
+ // S1-1 (Reviewer's re-check of thatcommit): EACH declared value is checked, not
1354
1363
  // the first non-empty one. The write below takes answers.source_tag first, so
1355
1364
  // checking only `source` let `source: <host>` + `answers.source_tag: <bot>`
1356
1365
  // write the identity documents as the bot. The tag that would be written
@@ -1417,7 +1426,7 @@ export async function setupComplete(answers = {}, logger = null, options = {}) {
1417
1426
  const [hasIdentity, hasUser] = await Promise.all([
1418
1427
  docsCol.findOne({ doc_id: IDENTITY_DOC }), docsCol.findOne({ doc_id: USER_DOC })
1419
1428
  ]);
1420
- // Set up = BOTH identity documents exist (the second reader's S-c; the reviewer: test it,
1429
+ // Set up = BOTH identity documents exist (Tester's S-c; Reviewer: test it,
1421
1430
  // don't loosen it). A half-set-up store (one of the two) is an interrupted
1422
1431
  // first setup, and completing it needs no reissue.
1423
1432
  if (hasIdentity && hasUser && options.reissue !== true) {