@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.
- package/.env.example +18 -1
- package/CHANGELOG.md +30 -3
- package/CHARTER.md +2 -2
- package/README.md +24 -16
- package/docs/BOOTSTRAP.md +33 -36
- package/docs/DEPLOY.md +61 -14
- package/docs/ERROR-CODES-SPEC.md +1 -1
- package/docs/ERROR-CODES.md +1 -0
- package/docs/GUARDRAILS-AND-MONORAILS.md +2 -0
- package/docs/GUIDED-SETUP.md +4 -8
- package/docs/ROADMAP.md +7 -6
- package/docs/SECURITY-AT-SCALE.md +71 -0
- package/docs/SETUP.md +43 -14
- package/package.json +2 -2
- package/server.json +2 -2
- package/src/attribution.js +8 -8
- package/src/bound-door.js +75 -42
- package/src/break-glass.js +7 -1
- package/src/chooser.js +15 -8
- package/src/claimed-tag.js +1 -1
- package/src/dispatch.js +2 -2
- package/src/error-codes.js +1 -0
- package/src/error-report.js +1 -1
- package/src/grants.js +1 -1
- package/src/http-remote.js +16 -7
- package/src/lessons-to-checks.js +29 -6
- package/src/owl.js +6 -7
- package/src/owner-approvals.js +1 -1
- package/src/proof-run.js +2 -2
- package/src/rotate.js +1 -1
- package/src/setup.js +4 -0
- package/src/subkeys.js +4 -1
- package/src/tools.js +74 -25
- package/src/version.js +1 -1
- package/src/writer-approval.js +11 -6
package/src/grants.js
CHANGED
|
@@ -146,7 +146,7 @@ export const OWL_ACCOUNT = 'user-EMET--owl';
|
|
|
146
146
|
/**
|
|
147
147
|
* R6. The owl MCP clone account was a second OAuth client used only to get a
|
|
148
148
|
* different client_id. R6 retires it. the owner decides a new writer on the
|
|
149
|
-
* chooser.
|
|
149
|
+
* chooser. The hub login prepares. The server validates. Rows stay.
|
|
150
150
|
* delete_wiring stays false: the name and the historical grants are retained.
|
|
151
151
|
*/
|
|
152
152
|
export const OWL_KILL = Object.freeze({
|
package/src/http-remote.js
CHANGED
|
@@ -254,6 +254,11 @@ app.post('/oauth/approve', express.urlencoded({ extended: false }), async (req,
|
|
|
254
254
|
res.locals.reason = 'bad_source';
|
|
255
255
|
return res.status(400).end('source tag is not registered');
|
|
256
256
|
}
|
|
257
|
+
const { isLegacyBoundHostSpelling } = await import('./bound-door.js');
|
|
258
|
+
if (isLegacyBoundHostSpelling(requested)) {
|
|
259
|
+
res.locals.reason = 'legacy_bound_tag';
|
|
260
|
+
return res.status(400).end('use bound-host (EMET-AUTH-045)');
|
|
261
|
+
}
|
|
257
262
|
sourceTag = requested || null;
|
|
258
263
|
}
|
|
259
264
|
const { isOwlIdentity } = await import('./owl.js');
|
|
@@ -291,13 +296,17 @@ app.post('/oauth/approve', express.urlencoded({ extended: false }), async (req,
|
|
|
291
296
|
issued_via: inviteSubject ? (inviteDoor === 'member' ? 'member' : 'invite') : 'owner',
|
|
292
297
|
source_tag: sourceTag,
|
|
293
298
|
});
|
|
294
|
-
if (sourceTag
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
299
|
+
if (sourceTag) {
|
|
300
|
+
const { recordBoundHostCredential, CLAIM_TAG } = await import('./bound-door.js');
|
|
301
|
+
// A new consent lists the door only for the current tag. The previous
|
|
302
|
+
// spelling is refused above, before a token is issued.
|
|
303
|
+
if (sourceTag === CLAIM_TAG) {
|
|
304
|
+
try {
|
|
305
|
+
const door = inviteSubject ? (inviteDoor === 'member' ? 'member' : 'guest') : 'owner';
|
|
306
|
+
await recordBoundHostCredential(t.approvalsDeps, { client_id, door, grant_id: null, by: 'consent' });
|
|
307
|
+
} catch {
|
|
308
|
+
console.error('[emet] bound door listing was not written');
|
|
309
|
+
}
|
|
301
310
|
}
|
|
302
311
|
}
|
|
303
312
|
const u = new URL(redirect_uri);
|
package/src/lessons-to-checks.js
CHANGED
|
@@ -12,11 +12,16 @@
|
|
|
12
12
|
* without a database. The wiring lives in tools.js (transcript append),
|
|
13
13
|
* session.js (close) and setup.js (initialize).
|
|
14
14
|
*
|
|
15
|
-
* 1. machineLineCheck - the first transcript append of a session
|
|
16
|
-
* a measured machine name and a clock
|
|
17
|
-
* words `no local shell MCP`.
|
|
18
|
-
*
|
|
19
|
-
*
|
|
15
|
+
* 1. machineLineCheck - the first successful transcript append of a session
|
|
16
|
+
* must carry a measured machine name and a clock
|
|
17
|
+
* reading, or the words `no local shell MCP`. The
|
|
18
|
+
* check is on the append that opens the transcript,
|
|
19
|
+
* or that becomes the lowest stored index, whatever
|
|
20
|
+
* exchange_index that is. Two sessions on 2026-09-26
|
|
21
|
+
* skipped the machine check and still got a transcript
|
|
22
|
+
* started. On 2026-11-03 a refused exchange 1 was
|
|
23
|
+
* followed by an accepted exchange 2, because the
|
|
24
|
+
* door only ran when the index was 1.
|
|
20
25
|
* 2. applyCloseCap - three blocked closes on one session escalate to the
|
|
21
26
|
* user instead of retrying. A host looping on close
|
|
22
27
|
* burns attempts; after three, the wrap plan is wrong
|
|
@@ -41,6 +46,24 @@
|
|
|
41
46
|
|
|
42
47
|
export const NO_SHELL_PHRASE = 'no local shell MCP';
|
|
43
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Whether this append is the one the machine line must ride on.
|
|
51
|
+
* `storedIndexes` are the exchange indexes already stored for the session.
|
|
52
|
+
* True when nothing is stored yet, so any index would open the transcript.
|
|
53
|
+
* True when `incoming` is lower than every stored index, so it becomes the
|
|
54
|
+
* lowest. A refused exchange 1 leaves the store empty, and a later index
|
|
55
|
+
* still has to pass.
|
|
56
|
+
*/
|
|
57
|
+
export function machineLineRequired(storedIndexes, incoming) {
|
|
58
|
+
const stored = (Array.isArray(storedIndexes) ? storedIndexes : [])
|
|
59
|
+
.map((n) => Number(n))
|
|
60
|
+
.filter((n) => Number.isInteger(n) && n >= 1);
|
|
61
|
+
if (stored.length === 0) return true;
|
|
62
|
+
const n = Number(incoming);
|
|
63
|
+
if (!Number.isInteger(n) || n < 1) return false;
|
|
64
|
+
return n < Math.min(...stored);
|
|
65
|
+
}
|
|
66
|
+
|
|
44
67
|
/**
|
|
45
68
|
* Reads the known machine names out of the user's install notes. The notes are
|
|
46
69
|
* a markdown document; the machines are the first column of any table whose
|
|
@@ -359,7 +382,7 @@ export function checkLessonFields(layer, metadata) {
|
|
|
359
382
|
}
|
|
360
383
|
|
|
361
384
|
export default {
|
|
362
|
-
NO_SHELL_PHRASE, knownMachinesFromInstallNotes, machineLineCheck,
|
|
385
|
+
NO_SHELL_PHRASE, machineLineRequired, knownMachinesFromInstallNotes, machineLineCheck,
|
|
363
386
|
CLOSE_CAP, applyCloseCap, scopeFor, escalateSpeak,
|
|
364
387
|
LESSON_REPEAT_THRESHOLD, DISPOSITION_KINDS, pendingLessons,
|
|
365
388
|
LESSON_KEY_PATTERN, suggestLessonKey, checkLessonFields
|
package/src/owl.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Owl MCP clone account (R6).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* approve.
|
|
4
|
+
* A second OAuth client account (the owl clone) let an approval queued by
|
|
5
|
+
* one grant be decided by another client_id. R6 retires that role. The
|
|
6
|
+
* owner decides a new writer on /owner/chooser. The request is prepared.
|
|
7
|
+
* The server validates it. This account does not approve.
|
|
9
8
|
*
|
|
10
9
|
* ISO 9001 7.5.3 / ISO 13485 4.2.5: supersede, retire, retain. Rows are
|
|
11
10
|
* not deleted. A startup check fails loudly (stderr and the owl
|
|
12
11
|
* retirement metric; the process does not exit) when an owl grant is
|
|
13
12
|
* active again. Rotate-all (R5) already revokes every grant; the invite step
|
|
14
13
|
* skips this account so a rotation does not hand it a fresh code. This
|
|
15
|
-
* module does not call
|
|
14
|
+
* module does not call a hosted deployment and does not run a rotation.
|
|
16
15
|
*/
|
|
17
16
|
|
|
18
17
|
import { COLLECTION_PREFIX } from './database.js';
|
|
@@ -20,7 +19,7 @@ import { assignCode, newCorrelationId } from './error-codes.js';
|
|
|
20
19
|
import { OWL_ACCOUNT, doorFromIssuedVia, grantIdFromFamily, logClientId, logDoor, logGrantId } from './grants.js';
|
|
21
20
|
import { InvalidGrantError, InvalidTokenError } from '@modelcontextprotocol/sdk/server/auth/errors.js';
|
|
22
21
|
|
|
23
|
-
const POINTER = 'this owl MCP clone account was retired by R6. A new writer is prepared by
|
|
22
|
+
const POINTER = 'this owl MCP clone account was retired by R6. A new writer is prepared by the hub login, validated on the server, and decided by the owner at /owner/chooser. This account cannot approve. Records are retained.';
|
|
24
23
|
const MARKER_ID = 'owl-mcp-clone';
|
|
25
24
|
|
|
26
25
|
const metric = {
|
package/src/owner-approvals.js
CHANGED
|
@@ -29,7 +29,7 @@ function retired(req, res) {
|
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* @param {import('express').Express} app
|
|
32
|
-
* @param {object} [_options] kept so
|
|
32
|
+
* @param {object} [_options] kept so a hosted deployment mount stays the same call.
|
|
33
33
|
*/
|
|
34
34
|
export function mountOwnerApprovals(app, _options = {}) {
|
|
35
35
|
app.get('/owner/approvals', retired);
|
package/src/proof-run.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Operational metric for this process, in the same family as the owl
|
|
5
5
|
* retirement and rotate-all lines. The controlled record is the proof pack
|
|
6
|
-
* under docs/proof/R7/ in the
|
|
6
|
+
* under docs/proof/R7/ in the private operator repository. This module does not write
|
|
7
7
|
* the memory store, does not mint a grant, and does not rotate credentials.
|
|
8
|
-
* A fresh process reports not_run.
|
|
8
|
+
* A fresh process reports not_run. A hosted deployment therefore reports not_run
|
|
9
9
|
* until a harness run is recorded in that process.
|
|
10
10
|
*
|
|
11
11
|
* ISO 9001 7.5.3 / ISO 13485 4.2.5: a later run does not delete an earlier
|
package/src/rotate.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* inside this generation or marked superseded. Fresh invites are new rows.
|
|
10
10
|
* An old grant is never made live again.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* A hosted deployment checks the generation on the next token request. This module
|
|
13
13
|
* does not call a deploy target.
|
|
14
14
|
*/
|
|
15
15
|
|
package/src/setup.js
CHANGED
|
@@ -1365,6 +1365,7 @@ export async function setupComplete(answers = {}, logger = null, options = {}) {
|
|
|
1365
1365
|
// write the identity documents as the bot. The tag that would be written
|
|
1366
1366
|
// (with its service-wide fallback) is checked too.
|
|
1367
1367
|
const { isBotTag } = await import('./session-graph.js');
|
|
1368
|
+
const { isLegacyBoundHostSpelling } = await import('./bound-door.js');
|
|
1368
1369
|
// ONE tag, used for this check and for every write below (setup's own
|
|
1369
1370
|
// records name it), so the checked tag and the written tag cannot differ.
|
|
1370
1371
|
const tag = String(answers.source_tag || options.source || setting('SOURCE_TAG') || 'setup').trim();
|
|
@@ -1376,6 +1377,9 @@ export async function setupComplete(answers = {}, logger = null, options = {}) {
|
|
|
1376
1377
|
`First-time setup is the owner's: ${declared} is a bot tag. Stop and tell the user. Nothing was written.`
|
|
1377
1378
|
, { code: 'EMET-CFG-009' });
|
|
1378
1379
|
}
|
|
1380
|
+
if (declared && isLegacyBoundHostSpelling(declared)) {
|
|
1381
|
+
throw new ValidationError(field, 'use bound-host. Nothing was written.', { code: 'EMET-AUTH-045' });
|
|
1382
|
+
}
|
|
1379
1383
|
}
|
|
1380
1384
|
const missing = SETUP_INTERVIEW.filter(q => q.required && !String(answers[q.key] || '').trim())
|
|
1381
1385
|
.map(q => q.key);
|
package/src/subkeys.js
CHANGED
|
@@ -21,6 +21,8 @@ import {
|
|
|
21
21
|
} from './attribution.js';
|
|
22
22
|
import { isOwlIdentity } from './owl.js';
|
|
23
23
|
import { isMasterBlasterActor } from './writer-approval.js';
|
|
24
|
+
import { isLegacyBoundHostSpelling } from './bound-door.js';
|
|
25
|
+
import { assignCode } from './error-codes.js';
|
|
24
26
|
import { parseReceipts } from './session.js';
|
|
25
27
|
import { storeFor, sweepFlagOffLiveSessions } from './subkey-store.js';
|
|
26
28
|
|
|
@@ -384,6 +386,7 @@ export async function requestSubkey(deps, actor, { tag } = {}, registry = [], no
|
|
|
384
386
|
const list = registryOf(registry);
|
|
385
387
|
const t = tagAllowed(tag, list);
|
|
386
388
|
if (!t) throw refusal('emet_subkey_request: "tag" must be an exact member of EMET_SOURCE_TAGS. Nothing was changed.');
|
|
389
|
+
if (isLegacyBoundHostSpelling(t)) throw assignCode(refusal('emet_subkey_request: use bound-host. Nothing was changed.'), 'EMET-AUTH-045');
|
|
387
390
|
const nonce = `${NONCE_PREFIX}${b64(32)}`;
|
|
388
391
|
const key_id = hexId();
|
|
389
392
|
let created = null;
|
|
@@ -432,7 +435,7 @@ export async function decideSubkeyIfPending(deps, actor, ownerId, { tag, decisio
|
|
|
432
435
|
if (!(ownerOk || cosOk)) throw refusal(`emet_client_approve: only the owner${cosTag() ? ` or the chief of staff (${cosTag()})` : ''} may decide a sub-key. Nothing was changed.`);
|
|
433
436
|
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.');
|
|
434
437
|
if (decision === 'approve' && (cosOk || isMasterBlasterActor(actor)) && actor.sourceTag !== 'owner') {
|
|
435
|
-
throw refusal('emet_client_approve: an AI cannot grant a writer.
|
|
438
|
+
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.');
|
|
436
439
|
}
|
|
437
440
|
const why = typeof reason === 'string' ? reason.trim() : '';
|
|
438
441
|
const channel = typeof via === 'string' ? via.trim() : '';
|
package/src/tools.js
CHANGED
|
@@ -20,7 +20,7 @@ import { replacedByOf } from './setup.js';
|
|
|
20
20
|
import { currentActor, rawActor, writerStamp, boundSourceTag, declaredAttribution, LOCAL_SUBJECT } from './persons.js';
|
|
21
21
|
import { guardClaimedTag } from './claimed-tag.js';
|
|
22
22
|
import { approvedTags, APPROVALS_DOC } from './attribution.js';
|
|
23
|
-
import {
|
|
23
|
+
import { refuseBoundHostDoor, boundHostActor, boundHostCredentialOverrides, boundHostClaimOnSharedLogin, isBoundHostTag, isLegacyBoundHostSpelling, CLAIM_TAG } from './bound-door.js';
|
|
24
24
|
import { sealAttestation, frozenAttestation } from './rune-dispatch.js';
|
|
25
25
|
|
|
26
26
|
/** Approvals record io for attribution.js (server-kept doc, written as emet-server). */
|
|
@@ -558,7 +558,7 @@ export async function saveMemory(dbManager, content, layer = null, metadata = {}
|
|
|
558
558
|
// stored (no bound tag) may use the caller's tag only when that tag is an
|
|
559
559
|
// exact member of EMET_SOURCE_TAGS. The shared default is not applied there.
|
|
560
560
|
const sourceDecision = resolvedSourceTag(validatedMetadata.source);
|
|
561
|
-
if (sourceDecision.from === 'bound-door')
|
|
561
|
+
if (sourceDecision.from === 'bound-door') refuseBoundHostDoor(boundHostActor());
|
|
562
562
|
if (sourceDecision.from === 'caller') {
|
|
563
563
|
const defaultTag = setting('SOURCE_TAG');
|
|
564
564
|
if (sourceDecision.tag) {
|
|
@@ -2243,6 +2243,36 @@ async function subkeyHandleForOpen(actor, base, now) {
|
|
|
2243
2243
|
}
|
|
2244
2244
|
}
|
|
2245
2245
|
|
|
2246
|
+
function exchangeIndexes(exchanges) {
|
|
2247
|
+
if (!Array.isArray(exchanges)) return [];
|
|
2248
|
+
const out = [];
|
|
2249
|
+
for (const row of exchanges) {
|
|
2250
|
+
const n = Number(row && row.exchange_index);
|
|
2251
|
+
if (Number.isInteger(n) && n >= 1) out.push(n);
|
|
2252
|
+
}
|
|
2253
|
+
return out;
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2256
|
+
/** Indexes already stored under other ids of this session. The current part is not included. */
|
|
2257
|
+
async function exchangeIndexesOnOtherParts(col, sessionId) {
|
|
2258
|
+
const { partId, partNumber, baseFromPart } = await import('./transcript-session.js');
|
|
2259
|
+
const base = baseFromPart(sessionId);
|
|
2260
|
+
const ids = [];
|
|
2261
|
+
if (sessionId !== base) ids.push(base);
|
|
2262
|
+
const n = partNumber(sessionId);
|
|
2263
|
+
for (let i = 1; i < n; i++) {
|
|
2264
|
+
const id = partId(base, i);
|
|
2265
|
+
if (id !== sessionId) ids.push(id);
|
|
2266
|
+
}
|
|
2267
|
+
const found = [];
|
|
2268
|
+
for (const id of ids) {
|
|
2269
|
+
const doc = await col.findOne({ session_id: id, superseded_by: { $in: [null, undefined] } })
|
|
2270
|
+
|| await col.findOne({ session_id: id });
|
|
2271
|
+
found.push(...exchangeIndexes(doc && doc.exchanges));
|
|
2272
|
+
}
|
|
2273
|
+
return found;
|
|
2274
|
+
}
|
|
2275
|
+
|
|
2246
2276
|
export async function transcriptAppend(args = {}, logger = null) {
|
|
2247
2277
|
const session_id = args.session_id;
|
|
2248
2278
|
const user_message = args.user_message;
|
|
@@ -2304,20 +2334,32 @@ export async function transcriptAppend(args = {}, logger = null) {
|
|
|
2304
2334
|
row.source_basis = 'subkey';
|
|
2305
2335
|
}
|
|
2306
2336
|
|
|
2307
|
-
// Build 1 (2026-09-27): the first append of a session must carry
|
|
2308
|
-
// measured machine line, or say there is no local shell. The rule lived
|
|
2309
|
-
// host instructions and was skipped twice on 2026-09-26
|
|
2310
|
-
//
|
|
2311
|
-
//
|
|
2337
|
+
// Build 1 (2026-09-27): the first successful append of a session must carry
|
|
2338
|
+
// the measured machine line, or say there is no local shell. The rule lived
|
|
2339
|
+
// in host instructions and was skipped twice on 2026-09-26. On 2026-11-03
|
|
2340
|
+
// the door ran only when the index was 1, so a refused exchange 1 was
|
|
2341
|
+
// followed by an accepted exchange 2 and the transcript opened without the
|
|
2342
|
+
// line. The check now runs on any append that opens the transcript, and on
|
|
2343
|
+
// any append that would become the lowest stored index. Known names come
|
|
2344
|
+
// from the user's install notes; with none, the check is reported as not
|
|
2345
|
+
// enforced.
|
|
2312
2346
|
let machineCheck = null;
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
const
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2347
|
+
const here = exchangeIndexes(exchanges);
|
|
2348
|
+
const mightOpen = here.length === 0 || idx < Math.min(...here);
|
|
2349
|
+
if (mightOpen) {
|
|
2350
|
+
const { machineLineRequired, knownMachinesFromInstallNotes, machineLineCheck } = await import('./lessons-to-checks.js');
|
|
2351
|
+
const stored = here.concat(await exchangeIndexesOnOtherParts(col, part));
|
|
2352
|
+
if (machineLineRequired(stored, idx)) {
|
|
2353
|
+
const { installDoc } = await import('./setup.js');
|
|
2354
|
+
const notes = await client.db(MONGODB_DB).collection('documents')
|
|
2355
|
+
.findOne({ doc_id: installDoc(), retired: { $ne: true } }, { projection: { content: 1 } });
|
|
2356
|
+
machineCheck = machineLineCheck(assistant_message, knownMachinesFromInstallNotes(notes && notes.content));
|
|
2357
|
+
if (!machineCheck.ok) throw new ValidationError(machineCheck.reason, { code: 'EMET-MEM-018' });
|
|
2358
|
+
}
|
|
2320
2359
|
}
|
|
2360
|
+
const machineLineField = () => (machineCheck
|
|
2361
|
+
? { machine_line: machineCheck.enforced ? `checked: ${machineCheck.matched}` : machineCheck.reason }
|
|
2362
|
+
: {});
|
|
2321
2363
|
|
|
2322
2364
|
if (!live) {
|
|
2323
2365
|
const start = typeof session_start === 'number' ? session_start : Date.now() / 1000;
|
|
@@ -2334,7 +2376,7 @@ export async function transcriptAppend(args = {}, logger = null) {
|
|
|
2334
2376
|
session_id: part, exchange_index: idx, exchange_count: 1, rolled: part !== session_id,
|
|
2335
2377
|
grant_id: appendStamp.grant_id,
|
|
2336
2378
|
...(appendClaim.warning ? { claimed_tag_warning: appendClaim.warning } : {}),
|
|
2337
|
-
...(
|
|
2379
|
+
...machineLineField()
|
|
2338
2380
|
};
|
|
2339
2381
|
}
|
|
2340
2382
|
|
|
@@ -2350,7 +2392,8 @@ export async function transcriptAppend(args = {}, logger = null) {
|
|
|
2350
2392
|
rolled: part !== session_id,
|
|
2351
2393
|
next_part_after: EXCHANGES_PER_PART,
|
|
2352
2394
|
grant_id: appendStamp.grant_id,
|
|
2353
|
-
...(appendClaim.warning ? { claimed_tag_warning: appendClaim.warning } : {})
|
|
2395
|
+
...(appendClaim.warning ? { claimed_tag_warning: appendClaim.warning } : {}),
|
|
2396
|
+
...machineLineField()
|
|
2354
2397
|
};
|
|
2355
2398
|
} finally {
|
|
2356
2399
|
await client.close();
|
|
@@ -2807,9 +2850,9 @@ export function resolvedSourceTag(caller) {
|
|
|
2807
2850
|
const bound = boundSourceTag();
|
|
2808
2851
|
const tag = typeof caller === 'string' ? caller.trim() : '';
|
|
2809
2852
|
if (bound === undefined) return { tag: tag || null, from: 'caller' };
|
|
2810
|
-
const actor =
|
|
2811
|
-
if (
|
|
2812
|
-
const sub = actor.subkeySession === true && actor.subkeyTag
|
|
2853
|
+
const actor = boundHostActor();
|
|
2854
|
+
if (boundHostCredentialOverrides(actor, tag)) {
|
|
2855
|
+
const sub = actor.subkeySession === true && isBoundHostTag(actor.subkeyTag);
|
|
2813
2856
|
return {
|
|
2814
2857
|
tag: CLAIM_TAG,
|
|
2815
2858
|
from: sub ? 'subkey' : 'credential',
|
|
@@ -2817,7 +2860,7 @@ export function resolvedSourceTag(caller) {
|
|
|
2817
2860
|
...(sub && actor.subkeyId ? { key_id: actor.subkeyId } : {})
|
|
2818
2861
|
};
|
|
2819
2862
|
}
|
|
2820
|
-
if (
|
|
2863
|
+
if (boundHostClaimOnSharedLogin(actor, tag)) return { tag: null, from: 'bound-door', login: bound || null };
|
|
2821
2864
|
// Attribution v2: the per-request tag decided by attribution.preflight is the
|
|
2822
2865
|
// stamp (declared, or generated for a login with none). Rights stay the
|
|
2823
2866
|
// login's: see rightsTags().
|
|
@@ -2830,10 +2873,10 @@ export function resolvedSourceTag(caller) {
|
|
|
2830
2873
|
return { tag: null, from: 'legacy' };
|
|
2831
2874
|
}
|
|
2832
2875
|
|
|
2833
|
-
/** A BOUND credential stamp replaces a forged
|
|
2876
|
+
/** A BOUND credential stamp replaces a forged hub-login string. A door claim throws. */
|
|
2834
2877
|
function stampedSource(decision, fallback) {
|
|
2835
|
-
if (decision && decision.from === 'bound-door')
|
|
2836
|
-
if (decision && (decision.from === 'credential' || (decision.from === 'subkey' && decision.tag
|
|
2878
|
+
if (decision && decision.from === 'bound-door') refuseBoundHostDoor(boundHostActor());
|
|
2879
|
+
if (decision && (decision.from === 'credential' || (decision.from === 'subkey' && isBoundHostTag(decision.tag)))) return decision.tag;
|
|
2837
2880
|
return fallback;
|
|
2838
2881
|
}
|
|
2839
2882
|
|
|
@@ -3940,6 +3983,9 @@ export async function inviteCreate(dbManager, { display_name, scopes, days, sour
|
|
|
3940
3983
|
if (registry.length && tag && !registry.includes(tag)) {
|
|
3941
3984
|
throw new ValidationError('source', 'A guest invite source must be a registered tag. Nothing was created.', { code: 'EMET-AUTH-032' });
|
|
3942
3985
|
}
|
|
3986
|
+
if (isLegacyBoundHostSpelling(tag)) {
|
|
3987
|
+
throw new ValidationError('source', 'use bound-host. Nothing was created.', { code: 'EMET-AUTH-045' });
|
|
3988
|
+
}
|
|
3943
3989
|
const out = await createInvite(dbManager.db, {
|
|
3944
3990
|
created_by: actor,
|
|
3945
3991
|
display_name,
|
|
@@ -3978,6 +4024,9 @@ export async function memberAccessCreate(dbManager, { display_name, days, source
|
|
|
3978
4024
|
if (registry.length && tag && !registry.includes(tag)) {
|
|
3979
4025
|
throw new ValidationError('source', 'A member code source must be a registered tag. Nothing was created.', { code: 'EMET-AUTH-035' });
|
|
3980
4026
|
}
|
|
4027
|
+
if (isLegacyBoundHostSpelling(tag)) {
|
|
4028
|
+
throw new ValidationError('source', 'use bound-host. Nothing was created.', { code: 'EMET-AUTH-045' });
|
|
4029
|
+
}
|
|
3981
4030
|
const out = await createMemberAccess(dbManager.db, { created_by: actor, display_name, days: days || 14, source_tag: tag || null });
|
|
3982
4031
|
logger?.info?.('EMET Member Access created', { display_name: out.display_name });
|
|
3983
4032
|
return {
|
|
@@ -4317,7 +4366,7 @@ const TOOL_DEFINITIONS = [
|
|
|
4317
4366
|
},
|
|
4318
4367
|
{
|
|
4319
4368
|
name: "emet_transcript_append",
|
|
4320
|
-
description: "Append ONE exchange to the session transcript. Call after every reply. Idempotent on exchange_index. Rolls to a new part after 8 exchanges. After a complete close the session takes exactly ONE more append - its closing exchange, numbered next, within EMET_CLOSE_GRACE_MINUTES (default 5) of the close; it is written into the session's last part whatever session_id it names, and the result's `closing_exchange` says it was accepted and that the session is now locked. A retry of that exchange number is answered as already saved and writes nothing. exchange_index, when given, must be a whole number of 1 or more (a number or its text). Any other append to a closed session is refused and nothing is written; that exchange belongs in the next session you open the usual way. THE FIRST APPEND OF A SESSION IS CHECKED
|
|
4369
|
+
description: "Append ONE exchange to the session transcript. Call after every reply. Idempotent on exchange_index. Rolls to a new part after 8 exchanges. After a complete close the session takes exactly ONE more append - its closing exchange, numbered next, within EMET_CLOSE_GRACE_MINUTES (default 5) of the close; it is written into the session's last part whatever session_id it names, and the result's `closing_exchange` says it was accepted and that the session is now locked. A retry of that exchange number is answered as already saved and writes nothing. exchange_index, when given, must be a whole number of 1 or more (a number or its text). Any other append to a closed session is refused and nothing is written; that exchange belongs in the next session you open the usual way. THE FIRST SUCCESSFUL APPEND OF A SESSION IS CHECKED, at whatever exchange_index opens the transcript or becomes the lowest stored index. A refused exchange 1 does not let a higher index start the transcript. Its assistant_message must carry the measured machine line - a machine name from the install notes plus the clock reading, as the shell returned them - or the words `no local shell MCP`. Without one of those the append is refused and nothing is written.",
|
|
4321
4370
|
inputSchema: {
|
|
4322
4371
|
type: "object",
|
|
4323
4372
|
properties: {
|
|
@@ -4554,7 +4603,7 @@ const TOOL_DEFINITIONS = [
|
|
|
4554
4603
|
},
|
|
4555
4604
|
{
|
|
4556
4605
|
name: "emet_client_approve",
|
|
4557
|
-
description: "Approve or deny a pending client tag, or prepare a new writer. decision prepare drafts a writer request: client, claimed tag, door (member or guest), reason, and correlation_id.
|
|
4606
|
+
description: "Approve or deny a pending client tag, or prepare a new writer. decision prepare drafts a writer request: client, claimed tag, door (member or guest), reason, and correlation_id. The hub login prepares that draft. The server validates it. Validation is a check and is not approval. Alex decides a new writer on /owner/chooser with the owner session. No AI grants a writer, including the hub login and the retired owl account. The owner login may still approve or deny a pending client tag. Pending client tags are listed in emet_initialize and emet_status as client_approvals.",
|
|
4558
4607
|
inputSchema: {
|
|
4559
4608
|
type: "object",
|
|
4560
4609
|
properties: {
|
package/src/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** The server's version, in one place. tests/version.test.js keeps it equal to package.json. */
|
|
2
|
-
export const EMET_VERSION = '0.3.
|
|
2
|
+
export const EMET_VERSION = '0.3.5';
|
package/src/writer-approval.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Writer approval (R6a).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* The hub login prepares a request: client, claimed tag, door, reason,
|
|
5
5
|
* correlation_id. The server validates that draft. Validation is a check.
|
|
6
6
|
* It does not approve. the owner decides on /owner/chooser with the owner
|
|
7
|
-
* passphrase session. No AI grants a writer, including
|
|
7
|
+
* passphrase session. No AI grants a writer, including the hub login and
|
|
8
8
|
* the retired owl account.
|
|
9
9
|
*
|
|
10
10
|
* The validator that runs is the server. the owner can later name another
|
|
@@ -17,6 +17,8 @@ import crypto from 'node:crypto';
|
|
|
17
17
|
import { COLLECTION_PREFIX } from './database.js';
|
|
18
18
|
import { logClientId, logGrantId } from './grants.js';
|
|
19
19
|
import { isOwlIdentity } from './owl.js';
|
|
20
|
+
import { isLegacyBoundHostSpelling } from './bound-door.js';
|
|
21
|
+
import { assignCode } from './error-codes.js';
|
|
20
22
|
|
|
21
23
|
export const MB_TAG = 'hub-bot';
|
|
22
24
|
export const SERVER_VALIDATOR = 'server';
|
|
@@ -68,7 +70,7 @@ export function writerApprovalMetric() {
|
|
|
68
70
|
};
|
|
69
71
|
}
|
|
70
72
|
|
|
71
|
-
/** Login or sub-key for
|
|
73
|
+
/** Login or sub-key for the hub login. A declared tag is a claim, not this credential. */
|
|
72
74
|
export function mbCredential(actor) {
|
|
73
75
|
if (!actor || actor.transport !== 'http' || actor.authenticated !== true) return false;
|
|
74
76
|
if (isOwlIdentity(actor)) return false;
|
|
@@ -80,7 +82,7 @@ export function mbCredential(actor) {
|
|
|
80
82
|
return typeof tag === 'string' && tag.trim() === MB_TAG;
|
|
81
83
|
}
|
|
82
84
|
|
|
83
|
-
/**
|
|
85
|
+
/** The hub login, including a declared copy. Used to refuse approval, not to authorize preparation. */
|
|
84
86
|
export function isMasterBlasterActor(actor) {
|
|
85
87
|
if (!actor || typeof actor !== 'object') return false;
|
|
86
88
|
return [actor.effectiveTag, actor.sourceTag, actor.declaredTag].some((tag) => typeof tag === 'string' && tag.trim() === MB_TAG);
|
|
@@ -164,14 +166,17 @@ export async function prepareWriterRequest(db, prefix = COLLECTION_PREFIX, actor
|
|
|
164
166
|
throw refusal('emet_client_approve: the owl MCP clone account was retired by R6 and cannot prepare or approve. the owner decides a new writer on /owner/chooser. Nothing was changed.');
|
|
165
167
|
}
|
|
166
168
|
if (!mbCredential(actor)) {
|
|
167
|
-
throw refusal('emet_client_approve: only
|
|
169
|
+
throw refusal('emet_client_approve: only the hub login, on its own login or sub-key, prepares a writer request. A declared tag does not. Nothing was changed.');
|
|
168
170
|
}
|
|
169
171
|
if (fields.decision && fields.decision !== 'prepare') {
|
|
170
|
-
throw refusal('emet_client_approve:
|
|
172
|
+
throw refusal('emet_client_approve: The hub login prepares a writer request and cannot approve it. the owner decides it on /owner/chooser. Nothing was changed.');
|
|
171
173
|
}
|
|
172
174
|
await hydrateWriterApprovals(db, prefix);
|
|
173
175
|
const at = now instanceof Date ? now.toISOString() : new Date(now).toISOString();
|
|
174
176
|
const checked = validateWriterDraft(fields, actor);
|
|
177
|
+
if (isLegacyBoundHostSpelling(checked.claimed_tag)) {
|
|
178
|
+
throw assignCode(refusal('emet_client_approve: use bound-host. Nothing was changed.'), 'EMET-AUTH-045');
|
|
179
|
+
}
|
|
175
180
|
const prior = [...memory.values()].find((row) => row && row.correlation_id === checked.correlation_id && checked.correlation_id !== 'none');
|
|
176
181
|
if (prior) {
|
|
177
182
|
logStep({
|