@dreamforgestudiollc/emet 0.3.3 → 0.3.5

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.
@@ -0,0 +1,71 @@
1
+ # Run one EMET instance per project
2
+
3
+ One collaborative project uses one EMET instance. An instance is one MongoDB database, one running server, and one `EMET_OAUTH_PASSPHRASE`. EMET is not multi-tenant on one database.
4
+
5
+ The document store has no prefix. One database holds one identity. A second `EMET_COLLECTION_PREFIX` in the same database does not make a second memory. When the configured prefix sees no memories and the same database holds data under another prefix, `emet_initialize` returns `state: "misconfigured"` and refuses the setup interview. That refusal is what stops a second identity from being written beside the first.
6
+
7
+ Guest access and member access are doors into this one store. They stay off until you set `EMET_INVITES=1` or `EMET_MEMBER_ACCESS=1`. They are not a second project.
8
+
9
+ ISO 9001 7.5.3 / ISO 13485 4.2.5 document-control wording is unchanged. EMET holds no certification and claims no conformity. Nothing is deleted. Records are superseded, retired, and retained. The standing text is `CHARTER.md` §7 and `templates/STANDARD.md`.
10
+
11
+ Run one process per instance. The record of which startup pages a host fetched lives in that process for 60 minutes after the last page. A second replica does not have it, so `emet_session_open` refuses a `load_id` whose pages were fetched elsewhere. See [GUARDRAILS-AND-MONORAILS.md](GUARDRAILS-AND-MONORAILS.md).
12
+
13
+ EMET is still 0.x. Stored document shapes may change before 1.0. Pin a version if you depend on them.
14
+
15
+ ## Harden one project
16
+
17
+ Do this before a second host or bot writes.
18
+
19
+ 1. Set `EMET_SOURCE_TAGS` to every host tag and every bot tag this project will use. With the list unset, an unregistered tag is accepted, and the guards on the main records and on `bots/` are off.
20
+ 2. Set a unique strong `EMET_OAUTH_PASSPHRASE` for this instance. Do not reuse it on another instance. While it is unset, the HTTP server refuses every authorization.
21
+ 3. Leave guest access, member access, and sub-keys off until you need them. Leave `EMET_INVITES`, `EMET_MEMBER_ACCESS`, and `EMET_SUBKEYS` unset.
22
+ 4. Optional. Set `EMET_SIGNING_KEY` to 32 random bytes, generated on this host. Keep it only on this host. Do not commit it. Do not store it in MongoDB or in a document. Unset means rows are saved unsigned. A new instance gets its own key. A different key makes an old signature read as not matching. Leave the key stable on a live store.
23
+ 5. Set `PUBLIC_URL` to the deployed https origin, with no path. It is the OAuth issuer. It must match the live URL exactly. Redeploy after you set it.
24
+ 6. After any environment change, request `https://<host>/health`. The JSON includes `"ok":true`. Then call `emet_status` with `{"probe": true}`. A read alone does not prove the write path.
25
+
26
+ Leave `EMET_SOURCE_TAG` unset when several hosts share this server. A default tag makes every host look the same. Over HTTP, document, transcript, and memory writes use the tag bound at approval. A local stdio host still passes an exact tag from `EMET_SOURCE_TAGS` as `source`.
27
+
28
+ ## Clone a project instance
29
+
30
+ A new project is a new instance. Do not point it at the first project's database.
31
+
32
+ 1. Create a new MongoDB database. Set a new `MONGODB_DB`. Give that database the same least-privilege role as [SETUP.md](SETUP.md). Do not copy the first database into this one when you want an empty project. Copying the database copies its identity, its transcripts, and its grants.
33
+ 2. Deploy a new service. Use a new `EMET_OAUTH_PASSPHRASE`, a new `PUBLIC_URL`, and a new `EMET_SIGNING_KEY` if you sign. If you turn sub-keys on, generate a new `EMET_SUBKEY_PEPPER`. Do not copy secrets from the other instance.
34
+ 3. Set `EMET_SOURCE_TAGS` to the hosts of this project only.
35
+ 4. Request `/health`, then call `emet_status` with `probe: true`.
36
+ 5. Say initialize. The interview runs on this empty store. `emet_setup_complete` writes this store's identity. It does not read another instance.
37
+
38
+ GEMs stay on the instance that names them.
39
+
40
+ - `EMET_ACTIVE_GEMS` is the comma-separated list of GEM ids for this process. It is not shared with another instance. Set it on the new service only when this project wants those GEMs. Restart, then read `emet_status` and confirm `gems`.
41
+ - Bundled GEMs ship with `defaultOn` false. An unset `EMET_ACTIVE_GEMS` leaves them off.
42
+ - At the interview, yes is the recommended answer for bot-team backup. Yes records that choice in this store's `bootstrap/USER.md`. The assistant then follows `gems/bot-team-backup/guides/BOT_TEAM_BACKUP.md`. EMET does not copy prompts or settings. Secret values are never stored. No, or leaving the question out, leaves the practice off. The GEM id `bot-team-backup` stays out of `EMET_ACTIVE_GEMS` unless you also want its floor text seated. Seating it does not replace the interview answer.
43
+ - Neurendipity and Lean Six Sigma are opt-in. Set `EMET_ACTIVE_GEMS` to `neurendipity`, to `lean-six-sigma`, or to both separated by a comma, only on the instance that should use them.
44
+ - Fieldnote is a developer case-study. Leave it off.
45
+ - Do not weaken the floor. No GEM can remove a protected floor line. Do not edit the floor to match a project. Read a GEM's floor with `emet_floor` and `gem` set to that id. That read does not turn the GEM on.
46
+
47
+ ## Keep an inventory and offboard
48
+
49
+ Keep an inventory outside the stores. One line per instance is enough. Record the project name, the public URL, the database name, whether guest access, member access, or sub-keys are on, and which GEM ids are active.
50
+
51
+ Do not put passphrases, connection strings, peppers, or signing keys in the inventory. Do not write those values into any EMET document.
52
+
53
+ To stop new owner sign-ins that use the old passphrase, set a new `EMET_OAUTH_PASSPHRASE` and redeploy. The passphrase is checked when a device consents and on the owner pages. Tokens already issued keep working until you revoke them. Changing the variable does not, by itself, end those tokens.
54
+
55
+ To end every grant and every sub-key, open `/owner/break-glass` in your own browser. Sign in with the owner passphrase. Confirm with the exact text `rotate-all`. There is no MCP tool for this, and there is no grace window. Access tokens, refresh tokens, authorization codes, sub-keys, live session handles, and unused invites are superseded, retired, and retained. Rows are not deleted. Devices sign in again with the current passphrase.
56
+
57
+ To end one member or one bot and leave the rest working, open `/owner/break-glass/revoke-member`. Name that one tag. Confirm with the exact text `revoke-member`. This does not rotate the household.
58
+
59
+ To end one sub-key and leave the login, call `emet_subkey_revoke` from the owner login. Pass the tag or the key id, and a reason. Later writes that present that session handle are refused. Earlier writes stay as written.
60
+
61
+ To take an instance out of service, revoke as above, then stop the process. Keep the database. EMET has no tool that drops the record. Pausing the cluster is the database host's control.
62
+
63
+ ## A control plane is future work
64
+
65
+ A later operator tool could provision an isolated instance. It would create a new database, a new deploy, and a new passphrase. It would not add a tenant to an existing database. It would not share `EMET_OAUTH_PASSPHRASE`, `EMET_SIGNING_KEY`, `EMET_SUBKEY_PEPPER`, or `EMET_ACTIVE_GEMS` across projects.
66
+
67
+ That tool is not built. Charter commitment 6 says nothing is built until it names the failure it fixes, what it replaces, how we will know it worked, and what holds it once it works. Those four answers are not on record. The item stays a seed in [ROADMAP.md](ROADMAP.md).
68
+
69
+ ## Every instance uses the same session order
70
+
71
+ Connecting the server does not make a host follow the session. The server refuses a skipped step. There is no report mode and no off switch. Paste the block in [BOOTSTRAP.md](BOOTSTRAP.md). The gates are in [GUARDRAILS-AND-MONORAILS.md](GUARDRAILS-AND-MONORAILS.md).
package/docs/SETUP.md CHANGED
@@ -103,11 +103,12 @@ when you want a second device to reach the same memory.
103
103
  5. **Pick a database name** and set `MONGODB_DB`. It defaults to `emet`. Collections (`emet_episodic`, `emet_semantic`, …) are
104
104
  created on first write — there is nothing to pre-create.
105
105
 
106
- 6. **One database per EMET instance.** The document store (`documents`,
107
- `documents_history`) is deliberately *not* prefixed, so two instances pointed at the same
108
- database will share their identity and continuity documents even if their memory
109
- collections use different prefixes. If you want two separate memories, give them separate
110
- databases - not just separate prefixes.
106
+ 6. **One database per EMET instance.** These collections are not prefixed:
107
+ `documents`, `documents_history`, `transcripts`, `exchanges`, `persons`, `invites`,
108
+ `close_attempts`, `error_log`, `error_log_summary`, and `_emet_verify`. Two instances
109
+ pointed at the same database share all of them, even when their memory collections use
110
+ different prefixes. If you want two separate memories, give them separate databases -
111
+ not just separate prefixes.
111
112
 
112
113
  7. **Vector index — only if you want `semantic_recall`.** Keyword search works without it.
113
114
  For meaning-based search, create an Atlas Vector Search index named
@@ -227,8 +228,10 @@ it is.
227
228
  | `EMET_VECTOR_INDEX` | `cascade_content_auto` | the Atlas Vector Search index `semantic_recall` uses |
228
229
  | `EMET_CORPORA` | your corpus names, comma-separated | only if you use `corpus_recall`; leave unset otherwise |
229
230
 
230
- `EMET_COLLECTION_PREFIX` also governs the counters collection and the three OAuth
231
- collections, so **devices you have already authorized stay authorized** - there is no
231
+ `EMET_COLLECTION_PREFIX` also governs the counters collection, the three OAuth
232
+ collections (`oauth_clients`, `oauth_codes`, `oauth_tokens`), and `sessions`,
233
+ `subkeys`, `subkeys_history`, `rotations`, `meta`, `doc_stages`, `gem_serves`,
234
+ `writer_approvals`, `owl_retirement`, and `graph_lab`, so **devices you have already authorized stay authorized** - there is no
232
235
  re-consent step.
233
236
 
234
237
  Your old `CASCADE_SOURCE_TAG` and `CASCADE_OAUTH_PASSPHRASE` continue to work; the `EMET_`
@@ -248,6 +251,20 @@ it should come back `ready` with your existing identity, not `setup_required`. I
248
251
  `setup_required`, one of the four variables above is wrong; **do not run the setup interview,
249
252
  which would write a new identity over your existing one.**
250
253
 
254
+ ## Upgrading to 0.3.5
255
+
256
+ 0.3.5 brings the public docs current. Stored data shapes are unchanged. The bound door's tag is `bound-host`. Writes from a stored legacy token or sub-key are stamped `bound-host`. The alias covers stored data only. The previous spelling is refused for a new consent, a new sub-key request, a new writer request, a new member or guest code, a new setup source, and a chooser decision.
257
+
258
+ ISO 9001 7.5.3 / ISO 13485 4.2.5 document-control wording is unchanged.
259
+
260
+ ## Upgrading to 0.3.4
261
+
262
+ 0.3.3 and 0.3.4 leave stored data shapes as they were in 0.3.2. Deploy over 0.3.2 or 0.3.3 as is.
263
+
264
+ From 0.3.4, `EMET-MEM-018` is checked on the append that opens a transcript, and on an append that would become the lowest stored index. Send the measured machine line on that first append, or the words `no local shell MCP`. A refused exchange 1 does not let a higher index start the transcript. With no machine table in the install notes, the check stays not enforced.
265
+
266
+ ISO 9001 7.5.3 / ISO 13485 4.2.5 document-control wording is unchanged.
267
+
251
268
  ## Upgrading to 0.3.2
252
269
 
253
270
  0.3.2 adds door grants, the owner chooser, household rotation, and writer approval. An existing store keeps its records. After you deploy:
@@ -335,17 +352,29 @@ host, `emet_status` with `probe: true` still passes.
335
352
 
336
353
  ## Stage 4 — tell your assistant to use it
337
354
 
338
- Setup gives the store an identity. It does not tell your assistant to consult it. See
339
- **[BOOTSTRAP.md](BOOTSTRAP.md)** for the short instruction block to paste into your project,
340
- and for what to expect on hosts that offer no instructions field.
355
+ Setup gives the store an identity. It does not tell your assistant to consult it. Paste the block from **[BOOTSTRAP.md](BOOTSTRAP.md)** into the project instructions. On a host with no instructions field, paste that block as the first message.
356
+
357
+ The path the server enforces, on every host:
358
+
359
+ 1. Call `emet_initialize` and fetch every startup page. Keep `startup_page.load_id`.
360
+ 2. Call `emet_session_open` with that `load_id`.
361
+ 3. After every reply, call `emet_transcript_append` for that one exchange. The first successful append must carry the measured machine line, or the words `no local shell MCP`. A refused exchange 1 does not let a higher index open the transcript.
362
+ 4. At the end, follow `session_close_protocol`, then call `emet_session_close`. Tell the user the session is saved only when the state is `complete`.
363
+
364
+ The monorail is enforce only. A skipped step is refused and nothing is written. There is no off switch. The cost of each skip is in [BOOTSTRAP.md](BOOTSTRAP.md). The gates are in [GUARDRAILS-AND-MONORAILS.md](GUARDRAILS-AND-MONORAILS.md).
365
+
366
+ One project is one instance: one database, one deploy, and one passphrase. See [SECURITY-AT-SCALE.md](SECURITY-AT-SCALE.md).
341
367
 
342
368
  ## Verifying it worked
343
369
 
344
370
  ```
345
- emet_status → initialized: true (false until the setup interview is done)
346
- emet_status probe:true → every probe check passed
347
- emet_session_open → a session_id
348
- save_to_layer → with that session_id, then recall it from a different device
371
+ emet_initialize → fetch every page, keep startup_page.load_id
372
+ emet_status → initialized: true (false until the setup interview is done)
373
+ emet_status probe:true → every probe check passed
374
+ emet_session_open → pass that load_id, get a session_id
375
+ emet_transcript_append → exchange 1 carries the machine line, or the words no local shell MCP
376
+ save_to_layer → with that session_id, then recall it from a different device
377
+ emet_session_close → state "complete" only after the close steps landed
349
378
  ```
350
379
 
351
380
  Ask your assistant to remember something and it makes these calls. A `semantic` or
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dreamforgestudiollc/emet",
3
- "version": "0.3.3",
4
- "description": "ISO 9001 7.5.3 / ISO 13485 4.2.5 document-control memory for AI agents. Nothing is deleted. EMET 0.3.3 — Enduring Memory & Epistemic Tiers. An MCP memory server with persistent shared memory for AI agents, bot teams and chats: layered memory, verified writes, a verbatim transcript tier, per-client attribution and approvals, and client-side GEM execution. EMET verifies the record, not the computation. A GEM is seated only when its released flag is true. Every error carries a stable code; the owner-only emet_error_report returns a report and an email draft the user sends. npm run verify drives the registered tools from a checkout, and docs/features is the map of every feature.",
3
+ "version": "0.3.5",
4
+ "description": "ISO 9001 7.5.3 / ISO 13485 4.2.5 document-control memory for AI agents. Nothing is deleted. EMET 0.3.5 — Enduring Memory & Epistemic Tiers. An MCP memory server with persistent shared memory for AI agents, bot teams and chats: layered memory, verified writes, a verbatim transcript tier, per-client attribution and approvals, and client-side GEM execution. EMET verifies the record, not the computation. A GEM is seated only when its released flag is true. Every error carries a stable code; the owner-only emet_error_report returns a report and an email draft the user sends. npm run verify drives the registered tools from a checkout, and docs/features is the map of every feature.",
5
5
  "keywords": [
6
6
  "agent-memory",
7
7
  "ai-agents",
package/server.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "io.github.dreamforgestudiollc/emet",
4
4
  "title": "EMET",
5
5
  "description": "ISO 9001 7.5.3 / ISO 13485 4.2.5 document-control memory for AI agents. Nothing is deleted.",
6
- "version": "0.3.3",
6
+ "version": "0.3.5",
7
7
  "websiteUrl": "https://dreamforgestudiollc.github.io/EMET/",
8
8
  "repository": {
9
9
  "url": "https://github.com/dreamforgestudiollc/EMET",
@@ -22,7 +22,7 @@
22
22
  "registryType": "npm",
23
23
  "registryBaseUrl": "https://registry.npmjs.org",
24
24
  "identifier": "@dreamforgestudiollc/emet",
25
- "version": "0.3.3",
25
+ "version": "0.3.5",
26
26
  "transport": {
27
27
  "type": "stdio"
28
28
  },
@@ -9,7 +9,7 @@
9
9
  * stamped with (source_basis "declared", source_login = the login's tag),
10
10
  * but a declared tag never gains rights beyond the login's tag (A3): every
11
11
  * guard is run for BOTH tags and the write must pass both (rightsTags()).
12
- * grok-project on the token bound to hub-bot is not that
12
+ * bound-host on the token bound to hub-bot is not that
13
13
  * claim: it is refused (BOUND's own door). A credential row (basis
14
14
  * "credential") is not a remembered tag for the shared client.
15
15
  *
@@ -40,7 +40,7 @@ import { setting } from './env.js';
40
40
  import { chooserBinding } from './deep-links.js';
41
41
  import { isOwlIdentity } from './owl.js';
42
42
  import { isMasterBlasterActor } from './writer-approval.js';
43
- import { isSophiaCredential, sophiaClaimOnSharedLogin, BOUND_LOGIN_MESSAGE, CLAIM_TAG, MB_TAG } from './bound-door.js';
43
+ import { isBoundHostCredential, isBoundHostTag, boundHostClaimOnSharedLogin, BOUND_LOGIN_MESSAGE, CLAIM_TAG, MB_TAG } from './bound-door.js';
44
44
 
45
45
  export const APPROVALS_DOC = 'emet/CLIENT_APPROVALS.md';
46
46
  export const WRITE_TOOLS = new Set([
@@ -350,7 +350,7 @@ export async function preflight(ctx, actor, args, toolName) {
350
350
  if (foreign) throw refusal(`source "${actor.subkeyTag}" is bound to another person's login, so this session may not write under it. Pass your own tag. Nothing was written.`);
351
351
  }
352
352
 
353
- if (STRICT_TAG_TOOLS.has(toolName) && sophiaClaimOnSharedLogin(actor, declared)) {
353
+ if (STRICT_TAG_TOOLS.has(toolName) && boundHostClaimOnSharedLogin(actor, declared)) {
354
354
  const denied = refusal(
355
355
  BOUND_LOGIN_MESSAGE,
356
356
  chooserBinding({ kind: 'onboarding_required', grantId: actor.grantId, tag: CLAIM_TAG, door: 'member' })
@@ -413,8 +413,8 @@ export async function preflight(ctx, actor, args, toolName) {
413
413
  const keptAuto = !declared && !bound && remembered.length === 1 ? remembered[0] : null;
414
414
  let effective = declared || bound || keptAuto || (actor.clientId && actor.clientId !== 'http:visitor' ? autoTag(actor.clientId) : null);
415
415
  let basis = declared && declared !== bound ? 'declared' : (bound ? 'login' : (keptAuto ? 'remembered' : (effective ? 'auto' : null)));
416
- const sophiaDoor = isSophiaCredential(actor) && (!declared || declared === CLAIM_TAG || declared === MB_TAG);
417
- if (sophiaDoor) {
416
+ const boundHostDoor = isBoundHostCredential(actor) && (!declared || isBoundHostTag(declared) || declared === MB_TAG);
417
+ if (boundHostDoor) {
418
418
  effective = CLAIM_TAG;
419
419
  basis = 'credential';
420
420
  }
@@ -425,7 +425,7 @@ export async function preflight(ctx, actor, args, toolName) {
425
425
 
426
426
  // New-client gate (the owner 2026-10-12). Bound tags were approved at consent;
427
427
  // registered tags by the owner's env. Everything else needs the record.
428
- if (!sophiaDoor && deps && effective && basis !== 'login' && basis !== 'credential' && !registry.includes(effective)) {
428
+ if (!boundHostDoor && deps && effective && basis !== 'login' && basis !== 'credential' && !registry.includes(effective)) {
429
429
  const cur = await loadApprovals(deps);
430
430
  if (cur.broken) {
431
431
  actor.approvalState = 'unreadable';
@@ -537,10 +537,10 @@ export async function clientApprove(deps, actor, ownerId, { tag, decision, reaso
537
537
  if (!(ownerOk || cosOk)) throw refusal(`emet_client_approve: only the owner${cosTag() ? ` or the chief of staff (${cosTag()})` : ''} may decide new clients. Nothing was changed.`);
538
538
  if (isOwlIdentity(actor)) throw refusal('emet_client_approve: the owl MCP clone account was retired by R6 and cannot approve. the owner decides a new writer on /owner/chooser. Nothing was changed.');
539
539
  if (decision === 'approve' && isMasterBlasterActor(actor) && !(actor && actor.ownerSession === true)) {
540
- throw refusal('emet_client_approve: an AI cannot grant a writer. Master Hub prepares a request. the owner decides it on /owner/chooser. Nothing was changed.');
540
+ throw refusal('emet_client_approve: an AI cannot grant a writer. The hub login prepares a request. the owner decides it on /owner/chooser. Nothing was changed.');
541
541
  }
542
542
  if (decision === 'approve' && cosOk && !(actor && actor.ownerSession === true)) {
543
- throw refusal('emet_client_approve: an AI cannot grant a writer. Master Hub prepares a request. the owner decides it on /owner/chooser. Nothing was changed.');
543
+ throw refusal('emet_client_approve: an AI cannot grant a writer. The hub login prepares a request. the owner decides it on /owner/chooser. Nothing was changed.');
544
544
  }
545
545
  if (setting('SUBKEYS') === '1') {
546
546
  const { decideSubkeyIfPending } = await import('./subkeys.js');
package/src/bound-door.js CHANGED
@@ -1,29 +1,31 @@
1
1
  /**
2
2
  * BOUND's door (init audit items 3 and 5, 2026-10-27).
3
3
  *
4
- * grok-project is a host tag. It is not a declared claim on the Master
5
- * Hub token that shares OAuth client bound-login-client. That token
6
- * is bound to hub-bot. A grok-project claim on it is refused
4
+ * bound-host is a host tag. It is not a declared claim on the hub login's
5
+ * token that shares OAuth client bound-login-client. That token
6
+ * is bound to hub-bot. A bound-host claim on it is refused
7
7
  * and is not stamped hub-bot.
8
8
  *
9
- * A credential is the token's own source_tag grok-project (member, owner, or
10
- * a legacy token with no door) or a sub-key whose tag is grok-project. Guest
9
+ * A credential is the token's own source_tag bound-host (member, owner, or
10
+ * a legacy token with no door) or a sub-key whose tag is bound-host. Guest
11
11
  * is not a writer credential. One EMET server. No second instance.
12
12
  *
13
- * The approvals row lists that credential. It does not remember grok-project
13
+ * The approvals row lists that credential. It does not remember bound-host
14
14
  * onto the shared client, so the claim path stays closed. CI does not mint a
15
15
  * live key and does not approve a production client.
16
16
  */
17
17
 
18
+ import crypto from 'node:crypto';
18
19
  import { rawActor } from './persons.js';
19
20
  import { chooserBinding } from './deep-links.js';
20
21
  import { ValidationError } from './validation.js';
21
22
 
22
- export const CLAIM_TAG = 'grok-project';
23
+ export const CLAIM_TAG = 'bound-host';
24
+ /** First 16 hex of sha256(the exact 0.3.4 bound-door tag). The spelling stays out of this file. */
25
+ export const LEGACY_CLAIM_TAG_DIGEST = '43897607a89a6b2e';
23
26
  /** Same string as writer-approval.js MB_TAG. */
24
27
  export const MB_TAG = 'hub-bot';
25
28
  export const SHARED_GROK_CLIENT = 'bound-login-client';
26
- export const EPISODIC_697_ID = 697;
27
29
  export const CORRECTION_NOTE_DATE = '2026-10-27';
28
30
 
29
31
  export const BOUND_LOGIN_MESSAGE =
@@ -34,39 +36,68 @@ export const BOUND_LOGIN_MESSAGE =
34
36
  * Guest is not a writer credential. A declared tag does not remove a login
35
37
  * credential and is not itself a credential.
36
38
  */
37
- export function isSophiaCredential(actor) {
39
+ export function boundHostTagDigest(tag) {
40
+ return crypto.createHash('sha256').update(String(tag).trim()).digest('hex').slice(0, 16);
41
+ }
42
+
43
+ /** Current `bound-host`, or the exact 0.3.4 spelling still stored on a token, approval row, writer request, or sub-key. A different case is not that door. */
44
+ export function isBoundHostTag(tag) {
45
+ if (typeof tag !== 'string') return false;
46
+ const text = tag.trim();
47
+ if (!text) return false;
48
+ if (text === CLAIM_TAG) return true;
49
+ return boundHostTagDigest(text) === LEGACY_CLAIM_TAG_DIGEST;
50
+ }
51
+
52
+ /** The stored 0.3.4 spelling. A newly chosen consent, sub-key, or writer request must not use it. */
53
+ export function isLegacyBoundHostSpelling(tag) {
54
+ if (typeof tag !== 'string') return false;
55
+ const text = tag.trim();
56
+ return text !== CLAIM_TAG && isBoundHostTag(text);
57
+ }
58
+
59
+ function boundHostMapKey(map) {
60
+ if (!map || typeof map !== 'object') return null;
61
+ if (Object.prototype.hasOwnProperty.call(map, CLAIM_TAG)) return CLAIM_TAG;
62
+ for (const key of Object.keys(map)) {
63
+ if (isBoundHostTag(key)) return key;
64
+ }
65
+ return null;
66
+ }
67
+
68
+ export function isBoundHostCredential(actor) {
38
69
  if (!actor || actor.transport !== 'http' || actor.authenticated !== true) return false;
39
70
  if (actor.door === 'guest') return false;
40
- if (actor.subkeySession === true && actor.subkeyTag === CLAIM_TAG) return true;
71
+ if (actor.subkeySession === true && isBoundHostTag(actor.subkeyTag)) return true;
41
72
  const login = typeof actor.sourceTag === 'string' ? actor.sourceTag.trim() : '';
42
- if (login !== CLAIM_TAG) return false;
73
+ if (!isBoundHostTag(login)) return false;
43
74
  return actor.door === 'member' || actor.door === 'owner' || actor.door == null;
44
75
  }
45
76
 
46
77
  /**
47
- * The shared Grok client, bound to Master Hub, claiming grok-project.
78
+ * The shared Grok client, bound to the hub login, claiming bound-host.
48
79
  * A BOUND credential is not this claim. Only the caller string counts, so a
49
80
  * tag left on a reused actor object cannot refuse a later write that names
50
81
  * no source.
51
82
  */
52
- export function sophiaClaimOnSharedLogin(actor, callerTag) {
83
+ export function boundHostClaimOnSharedLogin(actor, callerTag) {
53
84
  if (!actor || actor.transport !== 'http' || actor.authenticated !== true) return false;
54
85
  if (actor.clientId !== SHARED_GROK_CLIENT) return false;
55
86
  const bound = typeof actor.sourceTag === 'string' ? actor.sourceTag.trim() : '';
56
87
  if (bound !== MB_TAG) return false;
57
- if (isSophiaCredential(actor)) return false;
88
+ if (isBoundHostCredential(actor)) return false;
58
89
  const declared = typeof callerTag === 'string' ? callerTag.trim() : '';
59
- return declared === CLAIM_TAG;
90
+ return isBoundHostTag(declared);
60
91
  }
61
92
 
62
- /** Stamp grok-project when the credential's caller is empty, itself, or Master Hub. */
63
- export function sophiaCredentialOverrides(actor, callerTag) {
64
- if (!isSophiaCredential(actor)) return false;
93
+ /** Stamp bound-host when the credential's caller is empty, itself, or the hub login. */
94
+ export function boundHostCredentialOverrides(actor, callerTag) {
95
+ if (!isBoundHostCredential(actor)) return false;
65
96
  const caller = typeof callerTag === 'string' ? callerTag.trim() : '';
66
- return caller === '' || caller === CLAIM_TAG || caller === MB_TAG;
97
+ return caller === '' || isBoundHostTag(caller) || caller === MB_TAG;
67
98
  }
68
99
 
69
- export function refuseSophiaDoor(actor) {
100
+ export function refuseBoundHostDoor(actor) {
70
101
  const grantId = actor && typeof actor.grantId === 'string' && actor.grantId.trim() ? actor.grantId.trim() : 'unknown';
71
102
  const err = new ValidationError('source', BOUND_LOGIN_MESSAGE, { code: 'EMET-AUTH-044' });
72
103
  err.chooser = chooserBinding({ kind: 'onboarding_required', grantId, tag: CLAIM_TAG, door: 'member' });
@@ -74,24 +105,23 @@ export function refuseSophiaDoor(actor) {
74
105
  }
75
106
 
76
107
  /**
77
- * Dated episodic correction for 697. The parent stays. This is not
78
- * revise_memory and it does not supersede the row. Master Hub writes it
79
- * on the live store after merge, from the Master Hub login, and does not
80
- * pass source grok-project on that login.
108
+ * Dated correction note. The parent stays. This is not
109
+ * revise_memory and it does not supersede the row. The hub login writes it
110
+ * on the live store after merge, from the hub login, and does not
111
+ * pass source bound-host on that login.
81
112
  */
82
- export function episodic697CorrectionNote() {
113
+ export function boundHostCorrectionNote() {
83
114
  return {
84
115
  layer: 'episodic',
85
116
  content: [
86
117
  `Correction note dated ${CORRECTION_NOTE_DATE}.`,
87
- `Episodic ${EPISODIC_697_ID} was written from client ${SHARED_GROK_CLIENT} and stamped ${MB_TAG}.`,
118
+ `A row written from client ${SHARED_GROK_CLIENT} and stamped ${MB_TAG}.`,
88
119
  `That stamp is a misattribution when the writer was BOUND (${CLAIM_TAG}).`,
89
120
  'The original row is retained. This note does not edit it in place and does not supersede it.',
90
121
  `A BOUND write carries ${CLAIM_TAG} from its own door.`,
91
- `Master Hub writes this note on the live store after merge, from the Master Hub login, and does not pass source ${CLAIM_TAG} on that login.`
122
+ `The hub login writes this note on the live store after merge, from the hub login, and does not pass source ${CLAIM_TAG} on that login.`
92
123
  ].join(' '),
93
124
  metadata: {
94
- corrects: EPISODIC_697_ID,
95
125
  assertion_origin: 'assistant',
96
126
  custom: {
97
127
  correction: 'misattribution',
@@ -105,10 +135,10 @@ export function episodic697CorrectionNote() {
105
135
  }
106
136
 
107
137
  /**
108
- * List grok-project as a credential door. Does not remember() it onto the
138
+ * List bound-host as a credential door. Does not remember() it onto the
109
139
  * shared client. Idempotent for the same client, door, and grant.
110
140
  */
111
- export async function recordSophiaCredential(deps, { client_id, door, grant_id, by } = {}, now = new Date()) {
141
+ export async function recordBoundHostCredential(deps, { client_id, door, grant_id, by } = {}, now = new Date()) {
112
142
  if (!deps || typeof deps.readDoc !== 'function' || typeof deps.writeDoc !== 'function') {
113
143
  return { written: false, reason: 'no-approvals-io' };
114
144
  }
@@ -120,8 +150,10 @@ export async function recordSophiaCredential(deps, { client_id, door, grant_id,
120
150
  const { mutateApprovals } = await import('./attribution.js');
121
151
  const at = (now instanceof Date ? now : new Date(now)).toISOString();
122
152
  const out = await mutateApprovals(deps, (d) => {
123
- const prev = d.approved[CLAIM_TAG];
124
- const pending = d.pending && d.pending[CLAIM_TAG];
153
+ const key = boundHostMapKey(d.approved) || CLAIM_TAG;
154
+ const prev = d.approved[key];
155
+ const pendingKey = boundHostMapKey(d.pending);
156
+ const pending = pendingKey ? d.pending[pendingKey] : undefined;
125
157
  const same = prev
126
158
  && prev.basis === 'credential'
127
159
  && prev.door === doorName
@@ -129,31 +161,32 @@ export async function recordSophiaCredential(deps, { client_id, door, grant_id,
129
161
  && (prev.grant_id || null) === grant
130
162
  && !pending;
131
163
  if (same) return false;
132
- d.approved[CLAIM_TAG] = {
164
+ d.approved[key] = {
133
165
  basis: 'credential',
134
166
  door: doorName,
135
167
  client_id: clientId,
136
168
  grant_id: grant,
137
- source_tag: CLAIM_TAG,
169
+ source_tag: key,
138
170
  separate_from_client: SHARED_GROK_CLIENT,
139
171
  separate_from_tag: MB_TAG,
140
172
  by: by || 'owner',
141
173
  at,
142
- rule: 'separate login, then assign grok-project, then initialize'
174
+ rule: `separate login, then assign ${key}, then initialize`
143
175
  };
144
- if (d.pending && d.pending[CLAIM_TAG]) delete d.pending[CLAIM_TAG];
176
+ if (pendingKey) delete d.pending[pendingKey];
145
177
  return true;
146
178
  });
147
- return { written: out.written, approved: out.data.approved[CLAIM_TAG] };
179
+ const storedKey = boundHostMapKey(out.data.approved) || CLAIM_TAG;
180
+ return { written: out.written, approved: out.data.approved[storedKey] };
148
181
  }
149
182
 
150
- /** After the owner's chooser issues a grok-project door. The preparer's grant is not stored. */
151
- export async function sophiaListingAfterWriterIssue({ recorded, issued, deps, by, now } = {}) {
152
- if (!recorded || recorded.claimed_tag !== CLAIM_TAG) return { written: false, reason: 'tag' };
183
+ /** After the owner's chooser issues a bound-host door. The preparer's grant is not stored. */
184
+ export async function boundHostListingAfterWriterIssue({ recorded, issued, deps, by, now } = {}) {
185
+ if (!recorded || !isBoundHostTag(recorded.claimed_tag)) return { written: false, reason: 'tag' };
153
186
  if (!issued || issued.issued !== true) return { written: false, reason: 'not-issued' };
154
187
  if (recorded.door === 'guest') return { written: false, reason: 'guest' };
155
188
  try {
156
- return await recordSophiaCredential(deps, {
189
+ return await recordBoundHostCredential(deps, {
157
190
  client_id: recorded.client_id,
158
191
  door: recorded.door,
159
192
  grant_id: null,
@@ -165,6 +198,6 @@ export async function sophiaListingAfterWriterIssue({ recorded, issued, deps, by
165
198
  }
166
199
 
167
200
  /** The actor in force, for stamp sites that do not take one. */
168
- export function sophiaActor() {
201
+ export function boundHostActor() {
169
202
  return rawActor();
170
203
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Break-glass recovery (R4b).
3
3
  *
4
- * One stable URL on Railway EMET: /owner/break-glass. The owner passphrase
4
+ * One stable URL on a hosted deployment: /owner/break-glass. The owner passphrase
5
5
  * session is the only credential. A member or guest grant does not open it,
6
6
  * and no AI client is required. Each authenticated use is logged and counted
7
7
  * on emet_status.break_glass.
@@ -25,6 +25,7 @@ import {
25
25
  import {
26
26
  esc, sendHtml, loginForm, mountOwnerLogin, createOwnerGate
27
27
  } from './owner-session.js';
28
+ import { isLegacyBoundHostSpelling } from './bound-door.js';
28
29
 
29
30
  export { breakGlassMetric };
30
31
 
@@ -450,6 +451,11 @@ export function mountBreakGlass(app, options = {}) {
450
451
  sendHtml(res, 400, '<p>A tag is required for member or guest. Nothing was issued.</p>', 'EMET break-glass');
451
452
  return;
452
453
  }
454
+ if (isLegacyBoundHostSpelling(tag)) {
455
+ res.locals.reason = 'legacy_bound_tag';
456
+ sendHtml(res, 400, '<p>use bound-host (EMET-AUTH-045). Nothing was issued.</p>', 'EMET break-glass');
457
+ return;
458
+ }
453
459
  let note = 'Owner door is the passphrase consent on this host. This page did not mint a token.';
454
460
  let issued = false;
455
461
  if (door !== 'owner') {
package/src/chooser.js CHANGED
@@ -9,7 +9,7 @@
9
9
  * Pending sub-keys from the retired /owner/approvals path are listed here.
10
10
  * Their records stay in the sub-key store.
11
11
  *
12
- * Prepared writer requests are listed here too. Master Hub prepares.
12
+ * Prepared writer requests are listed here too. The hub login prepares.
13
13
  * The server validates. This owner session decides. The request row stays.
14
14
  */
15
15
 
@@ -25,6 +25,7 @@ import {
25
25
  esc, sendHtml, loginForm, ownerPageActor, ownerMayGrant, mountOwnerLogin, readCookie, createOwnerGate
26
26
  } from './owner-session.js';
27
27
  import { rotationForms } from './rotate.js';
28
+ import { boundHostListingAfterWriterIssue, isBoundHostTag, isLegacyBoundHostSpelling, CLAIM_TAG } from './bound-door.js';
28
29
 
29
30
  const CHOOSER_COOKIE = 'emet_chooser';
30
31
  const REASON_MAX = 500;
@@ -83,7 +84,7 @@ function writerSection(session, writers) {
83
84
  return `<tr><td>${esc(row.claimed_tag)}</td><td>${esc(row.door)}</td><td>${esc(row.status)}</td><td>${esc(row.preparer)}</td><td>${esc(row.validator)}</td><td>${esc(row.correlation_id)}</td><td>${buttons}</td></tr>`;
84
85
  }).join('\n');
85
86
  return `<h2>Writer requests</h2>
86
- <p>Master Hub prepares. The server validates. Only this owner session decides.</p>
87
+ <p>The hub login prepares. The server validates. Only this owner session decides.</p>
87
88
  <table><thead><tr><th>Tag</th><th>Door</th><th>Status</th><th>Preparer</th><th>Validator</th><th>Correlation</th><th></th></tr></thead><tbody>${body}</tbody></table>`;
88
89
  }
89
90
 
@@ -362,6 +363,11 @@ export function mountChooser(app, options = {}) {
362
363
  sendHtml(res, 400, '<p>A tag is required for member or guest. Nothing was granted.</p>', 'EMET chooser');
363
364
  return;
364
365
  }
366
+ if (isLegacyBoundHostSpelling(tag)) {
367
+ res.locals.reason = 'legacy_bound_tag';
368
+ sendHtml(res, 400, '<p>use bound-host (EMET-AUTH-045). Nothing was granted.</p>', 'EMET chooser');
369
+ return;
370
+ }
365
371
  let db = null;
366
372
  try { db = dbOf() || null; } catch { db = null; }
367
373
  const issued = await issueDoor(db, decision, tag === 'unknown' ? 'owner' : tag, personId);
@@ -527,16 +533,17 @@ export function mountChooser(app, options = {}) {
527
533
  const bits = [`Recorded ${decision} for ${recorded.claimed_tag}.`];
528
534
  if (issued.note) bits.push(issued.note);
529
535
  if (issued.invite && issued.invite.code) bits.push(`Invite code, shown once: ${issued.invite.code}`);
530
- if (issued.issued && recorded.claimed_tag === 'grok-project') {
531
- let sophiaNote = 'The BOUND door listing was not written. The invite code above is still the door.';
536
+ // A request already stored under the previous spelling still lists the door.
537
+ // prepareWriterRequest refuses that spelling when it is newly chosen.
538
+ if (issued.issued && isBoundHostTag(recorded.claimed_tag)) {
539
+ let boundHostNote = 'The BOUND door listing was not written. The invite code above is still the door.';
532
540
  try {
533
- const { sophiaListingAfterWriterIssue } = await import('./bound-door.js');
534
- const listing = await sophiaListingAfterWriterIssue({
541
+ const listing = await boundHostListingAfterWriterIssue({
535
542
  recorded, issued, deps: depsOf(), by: personId, now: new Date(now())
536
543
  });
537
- if (listing.written) sophiaNote = 'Listed grok-project as its own door.';
544
+ if (listing.written) boundHostNote = `Listed ${CLAIM_TAG} as its own door.`;
538
545
  } catch { /* the invite still stands */ }
539
- bits.push(sophiaNote);
546
+ bits.push(boundHostNote);
540
547
  }
541
548
  await render(req, res, bits.join(' '));
542
549
  }
@@ -9,7 +9,7 @@
9
9
  * the write is kept and the receipt warns. On that day and after, the write
10
10
  * is refused. Unset uses PROPOSED_CLAIMED_TAG_KILL_DATE.
11
11
  *
12
- * The traffic counter is this process. Railway EMET is one long-lived process.
12
+ * The traffic counter is this process. A hosted deployment is one long-lived process.
13
13
  * It is not a backfill of older rows.
14
14
  */
15
15
 
package/src/dispatch.js CHANGED
@@ -33,7 +33,7 @@ import {
33
33
  resolvedSourceTag,
34
34
  TOOLS
35
35
  } from './tools.js';
36
- import { refuseSophiaDoor, sophiaActor } from './bound-door.js';
36
+ import { refuseBoundHostDoor, boundHostActor } from './bound-door.js';
37
37
  import { beginStagedDoc, appendStagedChunk, commitStagedDoc, abortStagedDoc } from './staged-write.js';
38
38
  import { reserveToolNames } from './rune-registry.js';
39
39
  import { applyCheckpoint, checkpointOnError, checkpointStatus } from './checkpoint.js';
@@ -59,7 +59,7 @@ export function sourceOf(args) {
59
59
  // Stdio still reads the argument, and requireRegisteredSource checks the registry.
60
60
  const caller = args.source ?? args.updated_by ?? args.retired_by ?? args.accepted_by ?? args.channel ?? null;
61
61
  const decision = resolvedSourceTag(caller);
62
- if (decision.from === 'bound-door') refuseSophiaDoor(sophiaActor());
62
+ if (decision.from === 'bound-door') refuseBoundHostDoor(boundHostActor());
63
63
  return decision.tag;
64
64
  }
65
65
 
@@ -79,6 +79,7 @@ export const ERROR_CODES = Object.freeze({
79
79
  'EMET-AUTH-042': Object.freeze({ area: 'AUTH', summary: "A retired owl credential was refused", status: 'active', internal: false }),
80
80
  'EMET-AUTH-043': Object.freeze({ area: 'AUTH', summary: "A writer approval step was refused", status: 'active', internal: false }),
81
81
  'EMET-AUTH-044': Object.freeze({ area: 'AUTH', summary: "A bound login cannot stamp another tag", status: 'active', internal: false }),
82
+ 'EMET-AUTH-045': Object.freeze({ area: 'AUTH', summary: "The previous bound-door spelling is refused for a new choice", status: 'active', internal: false }),
82
83
  'EMET-CFG-001': Object.freeze({ area: 'CFG', summary: "Database name must be a plain name", status: 'active', internal: true }),
83
84
  'EMET-CFG-002': Object.freeze({ area: 'CFG', summary: "Collection prefix must be a plain name", status: 'active', internal: true }),
84
85
  'EMET-CFG-004': Object.freeze({ area: 'CFG', summary: "Hosted setup cannot turn sub-keys on from here", status: 'active', internal: false }),
@@ -14,7 +14,7 @@ import { logClientId, logDoor, logGrantId } from './grants.js';
14
14
  import { queryErrorLog, logSessionId } from './error-log.js';
15
15
 
16
16
  export const SEND_INSTRUCTION = 'The calling assistant may send this report only after showing the report to its user and getting their OK.';
17
- export const DEFAULT_REPORT_EMAIL = 'dreamforgestudio@mail.hubbot.com';
17
+ export const DEFAULT_REPORT_EMAIL = 'dreamforgestudio@mail.grokbot.com';
18
18
  export const MAILTO_MAX = 1800;
19
19
 
20
20
  /**