@dreamforgestudiollc/emet 0.3.1 → 0.3.3
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/CHANGELOG.md +40 -0
- package/README.md +29 -6
- package/docs/BOOTSTRAP.md +2 -0
- package/docs/BOTS.md +8 -7
- package/docs/DEPLOY.md +6 -0
- package/docs/ERROR-CODES-SPEC.md +2 -2
- package/docs/ERROR-CODES.md +29 -0
- package/docs/GUIDED-SETUP.md +1 -1
- package/docs/PERMISSIONS.md +5 -5
- package/docs/SETUP.md +10 -4
- package/docs/SUBKEYS.md +4 -4
- package/package.json +2 -2
- package/server.json +8 -4
- package/src/aleph.js +34 -13
- package/src/annotations.js +6 -2
- package/src/approve-throttle.js +3 -0
- package/src/atlas-role.js +1 -1
- package/src/attribution.js +76 -28
- package/src/bound-door.js +170 -0
- package/src/break-glass.js +531 -0
- package/src/carry-forward-close.js +386 -0
- package/src/checkpoint.js +241 -0
- package/src/chooser.js +543 -0
- package/src/claimed-tag.js +140 -0
- package/src/conformance.js +269 -5
- package/src/deep-links.js +267 -0
- package/src/dispatch.js +112 -18
- package/src/error-codes.js +29 -0
- package/src/error-log.js +138 -26
- package/src/error-report.js +17 -5
- package/src/gaps.js +1 -1
- package/src/grants.js +230 -0
- package/src/http-remote.js +80 -26
- package/src/index.js +18 -2
- package/src/invites.js +47 -1
- package/src/layers.js +1 -1
- package/src/lessons-to-checks.js +1 -1
- package/src/logger.js +3 -1
- package/src/oauth-provider.js +89 -5
- package/src/owl.js +232 -0
- package/src/owner-approvals.js +24 -267
- package/src/owner-session.js +235 -0
- package/src/pages.js +1 -1
- package/src/persons.js +39 -6
- package/src/proof-run.js +70 -0
- package/src/redact.js +4 -0
- package/src/request-log.js +2 -2
- package/src/rotate.js +554 -0
- package/src/rune-dispatch.js +1 -1
- package/src/session-graph.js +44 -25
- package/src/session.js +52 -9
- package/src/setup.js +21 -12
- package/src/staged-write.js +522 -0
- package/src/startup-pages.js +2 -2
- package/src/startup-payload.js +3 -3
- package/src/subkeys.js +61 -0
- package/src/tools.js +290 -79
- package/src/transcript-session.js +23 -4
- package/src/validation.js +1 -1
- package/src/version.js +1 -1
- package/src/writer-approval.js +394 -0
- package/templates/AREA.md +1 -1
- package/templates/BOTHANDOFF.md +2 -2
- package/templates/GRANT.md +48 -0
- package/templates/INDEX.md +9 -7
- package/templates/PROCEDURE.md +1 -1
- package/templates/ROSTER.md +2 -2
- package/templates/SEED.md +2 -2
- package/templates/SESSIONDISPOSITION.md +59 -0
- package/templates/STAGING.md +1 -1
- package/templates/STANDARD.md +1 -1
- package/templates/THREAD.md +1 -1
|
@@ -5,7 +5,7 @@ import { setting } from './env.js';
|
|
|
5
5
|
export const EXCHANGES_PER_PART = 8;
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* The zone a session id is dated in (2026-10-01,
|
|
8
|
+
* The zone a session id is dated in (2026-10-01, Alex's approval; dev team plan
|
|
9
9
|
* Part B, fix 1). Ids were dated from UTC, so an evening session in New York
|
|
10
10
|
* carried the next day's date (episodic ref 600: `2026-10-01_grok-init` minted on
|
|
11
11
|
* the night of 9/30). The day is now the user's local day: EMET_TIMEZONE, an
|
|
@@ -37,10 +37,29 @@ export function localDate(date = new Date(), timeZone = DEFAULT_TIME_ZONE) {
|
|
|
37
37
|
return `${get('year')}-${get('month')}-${get('day')}`;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Mint grammar for a leading session date: YYYY-MM-DD_ with month 01-12 and
|
|
42
|
+
* day 01-31. This is the same shape the error log accepts. It is not a
|
|
43
|
+
* calendar check: 2026-02-31 matches, 2026-13-01 and 2026-10-32 do not, and a
|
|
44
|
+
* hyphen after the day (2026-10-27-foo) is not a prefix.
|
|
45
|
+
*
|
|
46
|
+
* board 125(d): a caller slug that already begins with this prefix is the base.
|
|
47
|
+
* The server does not prepend the local day, and it does not replace or
|
|
48
|
+
* refuse a well-formed prefix that is not today's date. The text after the
|
|
49
|
+
* prefix is still cleaned. -N reopen and _verbatim_partN are applied later.
|
|
50
|
+
*/
|
|
51
|
+
const DATED_SLUG_PREFIX = /^([0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01]))_([\s\S]*)$/;
|
|
52
|
+
|
|
53
|
+
function cleanSlugBody(raw) {
|
|
54
|
+
return String(raw || 'session').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 40) || 'session';
|
|
55
|
+
}
|
|
56
|
+
|
|
40
57
|
export function sessionBaseId(date = new Date(), slug = 'session', timeZone = sessionTimeZone().zone) {
|
|
41
58
|
const day = localDate(date, timeZone);
|
|
42
|
-
const
|
|
43
|
-
|
|
59
|
+
const raw = typeof slug === 'string' ? slug.trim() : '';
|
|
60
|
+
const dated = raw ? DATED_SLUG_PREFIX.exec(raw) : null;
|
|
61
|
+
if (dated) return `${dated[1]}_${cleanSlugBody(dated[2])}`;
|
|
62
|
+
return `${day}_${cleanSlugBody(slug)}`;
|
|
44
63
|
}
|
|
45
64
|
|
|
46
65
|
export function partId(base, n) {
|
|
@@ -67,7 +86,7 @@ export function shouldStartNewPart(exchangeCount) {
|
|
|
67
86
|
}
|
|
68
87
|
|
|
69
88
|
/**
|
|
70
|
-
* A closed session is never reopened (2026-10-01,
|
|
89
|
+
* A closed session is never reopened (2026-10-01, Alex's approval; episodic
|
|
71
90
|
* 598: a session_open returned the previous night's CLOSED id and the next
|
|
72
91
|
* append landed in it as exchange 9). Returns the first of base, base-2,
|
|
73
92
|
* base-3, ... that is free, and the ids it passed over with the reason.
|
package/src/validation.js
CHANGED
|
@@ -153,7 +153,7 @@ export class ValidationError extends Error {
|
|
|
153
153
|
constructor(field, message, value = undefined) {
|
|
154
154
|
// A trailing { code: 'EMET-...' } is the stable code. It is not a field value
|
|
155
155
|
// and it is not part of the message. One-argument calls pass the whole message
|
|
156
|
-
// as `field` (
|
|
156
|
+
// as `field` (Tester's fix (b), 2026-10-02): that used to render
|
|
157
157
|
// "Validation failed for '<message>': undefined".
|
|
158
158
|
let emetCode;
|
|
159
159
|
const fourth = arguments.length > 3 ? arguments[3] : undefined;
|
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.3';
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writer approval (R6a).
|
|
3
|
+
*
|
|
4
|
+
* Master Hub prepares a request: client, claimed tag, door, reason,
|
|
5
|
+
* correlation_id. The server validates that draft. Validation is a check.
|
|
6
|
+
* It does not approve. the owner decides on /owner/chooser with the owner
|
|
7
|
+
* passphrase session. No AI grants a writer, including Master Hub and
|
|
8
|
+
* the retired owl account.
|
|
9
|
+
*
|
|
10
|
+
* The validator that runs is the server. the owner can later name another
|
|
11
|
+
* existing reviewer credential. The owl account is not that credential.
|
|
12
|
+
* Every step records grant_id, correlation_id, preparer, validator, and
|
|
13
|
+
* decider. Rows are retained. Nothing here deletes a request.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import crypto from 'node:crypto';
|
|
17
|
+
import { COLLECTION_PREFIX } from './database.js';
|
|
18
|
+
import { logClientId, logGrantId } from './grants.js';
|
|
19
|
+
import { isOwlIdentity } from './owl.js';
|
|
20
|
+
|
|
21
|
+
export const MB_TAG = 'hub-bot';
|
|
22
|
+
export const SERVER_VALIDATOR = 'server';
|
|
23
|
+
const COLLECTION = 'writer_approvals';
|
|
24
|
+
const REASON_MAX = 500;
|
|
25
|
+
const TAG_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,79}$/;
|
|
26
|
+
const CORR_RE = /^[0-9a-f]{16}$/;
|
|
27
|
+
|
|
28
|
+
const memory = new Map();
|
|
29
|
+
const steps = [];
|
|
30
|
+
|
|
31
|
+
function refusal(msg) {
|
|
32
|
+
const error = new Error(msg);
|
|
33
|
+
error.attributionRefusal = true;
|
|
34
|
+
return error;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function safeLabel(value, fallback) {
|
|
38
|
+
const text = typeof value === 'string' ? value.trim() : '';
|
|
39
|
+
if (!text || /[\r\n\s]/.test(text) || text.length > 80) return fallback;
|
|
40
|
+
return text;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function _resetWriterApprovalsForTests() {
|
|
44
|
+
memory.clear();
|
|
45
|
+
steps.length = 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function writerApprovalLog() {
|
|
49
|
+
return steps.map((row) => ({ ...row }));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function writerApprovalMetric() {
|
|
53
|
+
const rows = [...memory.values()];
|
|
54
|
+
const count = (status) => rows.filter((row) => row && row.status === status).length;
|
|
55
|
+
return {
|
|
56
|
+
rung: 'R6a',
|
|
57
|
+
preparer: MB_TAG,
|
|
58
|
+
validator: SERVER_VALIDATOR,
|
|
59
|
+
decider: 'owner-session',
|
|
60
|
+
decision_path: '/owner/chooser',
|
|
61
|
+
ai_may_approve: false,
|
|
62
|
+
prepared: rows.length,
|
|
63
|
+
validated: count('validated'),
|
|
64
|
+
invalid: count('invalid'),
|
|
65
|
+
approved: count('approved'),
|
|
66
|
+
denied: count('denied'),
|
|
67
|
+
since_process_start: true
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Login or sub-key for Master Hub. A declared tag is a claim, not this credential. */
|
|
72
|
+
export function mbCredential(actor) {
|
|
73
|
+
if (!actor || actor.transport !== 'http' || actor.authenticated !== true) return false;
|
|
74
|
+
if (isOwlIdentity(actor)) return false;
|
|
75
|
+
if (actor.ownerSession === true) return false;
|
|
76
|
+
const basis = actor.sourceBasis || null;
|
|
77
|
+
if (basis !== 'login' && basis !== 'subkey') return false;
|
|
78
|
+
if (actor.declaredTag) return false;
|
|
79
|
+
const tag = basis === 'subkey' ? (actor.effectiveTag || actor.sourceTag) : actor.sourceTag;
|
|
80
|
+
return typeof tag === 'string' && tag.trim() === MB_TAG;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Master Hub, including a declared copy. Used to refuse approval, not to authorize preparation. */
|
|
84
|
+
export function isMasterBlasterActor(actor) {
|
|
85
|
+
if (!actor || typeof actor !== 'object') return false;
|
|
86
|
+
return [actor.effectiveTag, actor.sourceTag, actor.declaredTag].some((tag) => typeof tag === 'string' && tag.trim() === MB_TAG);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function collection(db, prefix) {
|
|
90
|
+
if (!db || typeof db.collection !== 'function') return null;
|
|
91
|
+
return db.collection(`${prefix}${COLLECTION}`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function persist(db, prefix, row) {
|
|
95
|
+
memory.set(row.request_id, row);
|
|
96
|
+
const col = collection(db, prefix);
|
|
97
|
+
if (!col) return;
|
|
98
|
+
const existing = await col.findOne({ _id: row.request_id });
|
|
99
|
+
const stored = { ...row, _id: row.request_id, deleted: false, retained: true };
|
|
100
|
+
if (!existing) await col.insertOne(stored);
|
|
101
|
+
else await col.updateOne({ _id: row.request_id }, { $set: stored });
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export async function hydrateWriterApprovals(db, prefix = COLLECTION_PREFIX) {
|
|
105
|
+
const col = collection(db, prefix);
|
|
106
|
+
if (!col) return;
|
|
107
|
+
const cursor = col.find({});
|
|
108
|
+
if (!cursor || typeof cursor.toArray !== 'function') return;
|
|
109
|
+
const rows = await cursor.toArray();
|
|
110
|
+
for (const row of rows) {
|
|
111
|
+
if (row && row.request_id && !memory.has(row.request_id)) memory.set(row.request_id, row);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function logStep(entry) {
|
|
116
|
+
const row = {
|
|
117
|
+
step: entry.step,
|
|
118
|
+
grant_id: logGrantId(entry.grant_id),
|
|
119
|
+
correlation_id: CORR_RE.test(entry.correlation_id) ? entry.correlation_id : 'none',
|
|
120
|
+
preparer: safeLabel(entry.preparer, 'none'),
|
|
121
|
+
validator: entry.validator === SERVER_VALIDATOR ? SERVER_VALIDATOR : 'none',
|
|
122
|
+
decider: safeLabel(entry.decider, 'none'),
|
|
123
|
+
at: entry.at
|
|
124
|
+
};
|
|
125
|
+
steps.push(row);
|
|
126
|
+
if (steps.length > 500) steps.shift();
|
|
127
|
+
console.error(`[emet] writer-approval step=${row.step} grant_id=${row.grant_id} correlation_id=${row.correlation_id} preparer=${row.preparer} validator=${row.validator} decider=${row.decider}`);
|
|
128
|
+
return row;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Server-side check of a prepared draft. A passing check still is not
|
|
133
|
+
* approval. A failing check is retained as invalid.
|
|
134
|
+
*/
|
|
135
|
+
export function validateWriterDraft(fields, actor) {
|
|
136
|
+
const failures = [];
|
|
137
|
+
const client = typeof fields.client === 'string' ? fields.client.trim() : '';
|
|
138
|
+
if (!client || logClientId(client) === 'unknown' || client === 'stdio' || isOwlIdentity(client)) failures.push('client');
|
|
139
|
+
const tag = typeof fields.claimed_tag === 'string' ? fields.claimed_tag.trim() : '';
|
|
140
|
+
if (!TAG_RE.test(tag) || isOwlIdentity(tag)) failures.push('claimed_tag');
|
|
141
|
+
const door = fields.door === 'member' || fields.door === 'guest' ? fields.door : null;
|
|
142
|
+
if (!door) failures.push('door');
|
|
143
|
+
const reason = typeof fields.reason === 'string' ? fields.reason.trim() : '';
|
|
144
|
+
if (!reason || reason.length > REASON_MAX || /[\r\n]/.test(reason)) failures.push('reason');
|
|
145
|
+
const correlation = typeof fields.correlation_id === 'string' ? fields.correlation_id.trim() : '';
|
|
146
|
+
if (!CORR_RE.test(correlation)) failures.push('correlation_id');
|
|
147
|
+
const grant = logGrantId(actor && actor.grantId);
|
|
148
|
+
if (grant === 'none') failures.push('grant_id');
|
|
149
|
+
if (!mbCredential(actor)) failures.push('preparer');
|
|
150
|
+
return {
|
|
151
|
+
ok: failures.length === 0,
|
|
152
|
+
failures,
|
|
153
|
+
client: client || null,
|
|
154
|
+
claimed_tag: tag || null,
|
|
155
|
+
door,
|
|
156
|
+
reason: reason || null,
|
|
157
|
+
correlation_id: CORR_RE.test(correlation) ? correlation : 'none',
|
|
158
|
+
grant_id: grant
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export async function prepareWriterRequest(db, prefix = COLLECTION_PREFIX, actor, fields = {}, now = new Date()) {
|
|
163
|
+
if (isOwlIdentity(actor)) {
|
|
164
|
+
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
|
+
}
|
|
166
|
+
if (!mbCredential(actor)) {
|
|
167
|
+
throw refusal('emet_client_approve: only Master Hub, on its own login or sub-key, prepares a writer request. A declared tag does not. Nothing was changed.');
|
|
168
|
+
}
|
|
169
|
+
if (fields.decision && fields.decision !== 'prepare') {
|
|
170
|
+
throw refusal('emet_client_approve: Master Hub prepares a writer request and cannot approve it. the owner decides it on /owner/chooser. Nothing was changed.');
|
|
171
|
+
}
|
|
172
|
+
await hydrateWriterApprovals(db, prefix);
|
|
173
|
+
const at = now instanceof Date ? now.toISOString() : new Date(now).toISOString();
|
|
174
|
+
const checked = validateWriterDraft(fields, actor);
|
|
175
|
+
const prior = [...memory.values()].find((row) => row && row.correlation_id === checked.correlation_id && checked.correlation_id !== 'none');
|
|
176
|
+
if (prior) {
|
|
177
|
+
logStep({
|
|
178
|
+
step: 'prepare',
|
|
179
|
+
grant_id: prior.grant_id,
|
|
180
|
+
correlation_id: prior.correlation_id,
|
|
181
|
+
preparer: prior.preparer,
|
|
182
|
+
validator: prior.validator || 'none',
|
|
183
|
+
decider: prior.decider || 'none',
|
|
184
|
+
at
|
|
185
|
+
});
|
|
186
|
+
return { ...prior, unchanged: true };
|
|
187
|
+
}
|
|
188
|
+
const request_id = `wr-${crypto.randomBytes(8).toString('hex')}`;
|
|
189
|
+
const base = {
|
|
190
|
+
request_id,
|
|
191
|
+
client_id: checked.client,
|
|
192
|
+
claimed_tag: checked.claimed_tag,
|
|
193
|
+
door: checked.door,
|
|
194
|
+
reason: checked.reason,
|
|
195
|
+
correlation_id: checked.correlation_id,
|
|
196
|
+
grant_id: checked.grant_id,
|
|
197
|
+
preparer: MB_TAG,
|
|
198
|
+
validator: 'none',
|
|
199
|
+
decider: 'none',
|
|
200
|
+
status: 'prepared',
|
|
201
|
+
writer: checked.door === 'member',
|
|
202
|
+
issued: false,
|
|
203
|
+
deleted: false,
|
|
204
|
+
retained: true,
|
|
205
|
+
history: [],
|
|
206
|
+
at
|
|
207
|
+
};
|
|
208
|
+
logStep({ step: 'prepare', ...base, at });
|
|
209
|
+
base.history.push({ step: 'prepare', grant_id: base.grant_id, correlation_id: base.correlation_id, preparer: MB_TAG, validator: 'none', decider: 'none', at });
|
|
210
|
+
const validated = {
|
|
211
|
+
...base,
|
|
212
|
+
status: checked.ok ? 'validated' : 'invalid',
|
|
213
|
+
validator: SERVER_VALIDATOR,
|
|
214
|
+
failures: checked.failures,
|
|
215
|
+
validated_at: at
|
|
216
|
+
};
|
|
217
|
+
logStep({
|
|
218
|
+
step: 'validate',
|
|
219
|
+
grant_id: validated.grant_id,
|
|
220
|
+
correlation_id: validated.correlation_id,
|
|
221
|
+
preparer: MB_TAG,
|
|
222
|
+
validator: SERVER_VALIDATOR,
|
|
223
|
+
decider: 'none',
|
|
224
|
+
at
|
|
225
|
+
});
|
|
226
|
+
validated.history.push({
|
|
227
|
+
step: 'validate',
|
|
228
|
+
grant_id: validated.grant_id,
|
|
229
|
+
correlation_id: validated.correlation_id,
|
|
230
|
+
preparer: MB_TAG,
|
|
231
|
+
validator: SERVER_VALIDATOR,
|
|
232
|
+
decider: 'none',
|
|
233
|
+
ok: checked.ok,
|
|
234
|
+
at
|
|
235
|
+
});
|
|
236
|
+
await persist(db, prefix, validated);
|
|
237
|
+
return { ...validated };
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export async function listWriterRequests(db, prefix = COLLECTION_PREFIX) {
|
|
241
|
+
await hydrateWriterApprovals(db, prefix);
|
|
242
|
+
return [...memory.values()].sort((a, b) => String(a.at || '').localeCompare(String(b.at || '')) || String(a.request_id).localeCompare(String(b.request_id)));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export function getWriterRequest(requestId) {
|
|
246
|
+
return memory.get(requestId) || null;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function decidedAt(now) {
|
|
250
|
+
return now instanceof Date ? now.toISOString() : new Date(now).toISOString();
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function decideHistory(row, who, decision, at) {
|
|
254
|
+
return [...(row.history || []), {
|
|
255
|
+
step: 'decide',
|
|
256
|
+
grant_id: row.grant_id,
|
|
257
|
+
correlation_id: row.correlation_id,
|
|
258
|
+
preparer: row.preparer,
|
|
259
|
+
validator: row.validator || SERVER_VALIDATOR,
|
|
260
|
+
decider: who,
|
|
261
|
+
decision,
|
|
262
|
+
at
|
|
263
|
+
}];
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Claim the decision before any door is minted. The status must still be
|
|
268
|
+
* `validated`. The memory update is synchronous, then the database
|
|
269
|
+
* compare-and-set (`status: 'validated'`) is the cross-process lock.
|
|
270
|
+
* Approve becomes `approving`. Deny becomes `denied`. This does not mint.
|
|
271
|
+
*/
|
|
272
|
+
export async function claimWriterDecision(db, prefix = COLLECTION_PREFIX, { requestId, decision, decider, ownerSession } = {}, now = new Date()) {
|
|
273
|
+
if (ownerSession !== true) {
|
|
274
|
+
throw refusal('A new writer is decided only by the owner on /owner/chooser with an owner session. Nothing was changed.');
|
|
275
|
+
}
|
|
276
|
+
if (decision !== 'approve' && decision !== 'deny') {
|
|
277
|
+
throw refusal('Decision must be approve or deny. Nothing was changed.');
|
|
278
|
+
}
|
|
279
|
+
await hydrateWriterApprovals(db, prefix);
|
|
280
|
+
const row = memory.get(requestId);
|
|
281
|
+
if (!row) throw refusal('That writer request is not on file. Nothing was changed.');
|
|
282
|
+
if (row.status !== 'validated') throw refusal('That writer request is not awaiting a decision. Nothing was changed.');
|
|
283
|
+
const at = decidedAt(now);
|
|
284
|
+
const who = safeLabel(decider, 'owner');
|
|
285
|
+
const next = {
|
|
286
|
+
...row,
|
|
287
|
+
status: decision === 'approve' ? 'approving' : 'denied',
|
|
288
|
+
decider: who,
|
|
289
|
+
decision,
|
|
290
|
+
decided_at: at,
|
|
291
|
+
issued: false,
|
|
292
|
+
deleted: false,
|
|
293
|
+
retained: true,
|
|
294
|
+
history: decideHistory(row, who, decision, at)
|
|
295
|
+
};
|
|
296
|
+
// No await between the status read above and this set. A second caller
|
|
297
|
+
// in this process sees approving or denied and does not mint.
|
|
298
|
+
memory.set(requestId, next);
|
|
299
|
+
const col = collection(db, prefix);
|
|
300
|
+
if (col) {
|
|
301
|
+
const won = await col.findOneAndUpdate(
|
|
302
|
+
{ _id: requestId, status: 'validated' },
|
|
303
|
+
{ $set: { ...next, _id: requestId } }
|
|
304
|
+
);
|
|
305
|
+
if (!won) {
|
|
306
|
+
const current = await col.findOne({ _id: requestId });
|
|
307
|
+
memory.set(requestId, current || row);
|
|
308
|
+
throw refusal('That writer request is not awaiting a decision. Nothing was changed.');
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
logStep({
|
|
312
|
+
step: 'decide',
|
|
313
|
+
grant_id: next.grant_id,
|
|
314
|
+
correlation_id: next.correlation_id,
|
|
315
|
+
preparer: next.preparer,
|
|
316
|
+
validator: next.validator,
|
|
317
|
+
decider: who,
|
|
318
|
+
at
|
|
319
|
+
});
|
|
320
|
+
return { ...next };
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/** After the door minted. Only an `approving` row becomes `approved`. */
|
|
324
|
+
export async function stampWriterIssued(db, prefix = COLLECTION_PREFIX, { requestId } = {}) {
|
|
325
|
+
const row = memory.get(requestId);
|
|
326
|
+
if (!row || row.status !== 'approving') {
|
|
327
|
+
throw refusal('That writer request is not awaiting a door. Nothing was changed.');
|
|
328
|
+
}
|
|
329
|
+
const next = { ...row, status: 'approved', issued: true, deleted: false, retained: true };
|
|
330
|
+
memory.set(requestId, next);
|
|
331
|
+
const col = collection(db, prefix);
|
|
332
|
+
if (col) {
|
|
333
|
+
const won = await col.findOneAndUpdate(
|
|
334
|
+
{ _id: requestId, status: 'approving' },
|
|
335
|
+
{ $set: { ...next, _id: requestId } }
|
|
336
|
+
);
|
|
337
|
+
if (!won) {
|
|
338
|
+
const current = await col.findOne({ _id: requestId });
|
|
339
|
+
memory.set(requestId, current || row);
|
|
340
|
+
throw refusal('That writer request is not awaiting a door. Nothing was changed.');
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return { ...next };
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* The claim won and the door did not mint. Put the row back to `validated`
|
|
348
|
+
* so the owner can retry. Nothing is deleted.
|
|
349
|
+
*/
|
|
350
|
+
export async function releaseWriterClaim(db, prefix = COLLECTION_PREFIX, { requestId } = {}, now = new Date()) {
|
|
351
|
+
const row = memory.get(requestId);
|
|
352
|
+
if (!row || row.status !== 'approving') return row ? { ...row } : null;
|
|
353
|
+
const at = decidedAt(now);
|
|
354
|
+
const next = {
|
|
355
|
+
...row,
|
|
356
|
+
status: 'validated',
|
|
357
|
+
issued: false,
|
|
358
|
+
decider: 'none',
|
|
359
|
+
decision: null,
|
|
360
|
+
deleted: false,
|
|
361
|
+
retained: true,
|
|
362
|
+
history: [...(row.history || []), {
|
|
363
|
+
step: 'release',
|
|
364
|
+
grant_id: row.grant_id,
|
|
365
|
+
correlation_id: row.correlation_id,
|
|
366
|
+
preparer: row.preparer,
|
|
367
|
+
validator: row.validator || SERVER_VALIDATOR,
|
|
368
|
+
decider: 'none',
|
|
369
|
+
at
|
|
370
|
+
}]
|
|
371
|
+
};
|
|
372
|
+
logStep({
|
|
373
|
+
step: 'release',
|
|
374
|
+
grant_id: next.grant_id,
|
|
375
|
+
correlation_id: next.correlation_id,
|
|
376
|
+
preparer: next.preparer,
|
|
377
|
+
validator: next.validator,
|
|
378
|
+
decider: 'none',
|
|
379
|
+
at
|
|
380
|
+
});
|
|
381
|
+
await persist(db, prefix, next);
|
|
382
|
+
return { ...next };
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Claim, then stamp only when the caller already minted (`issued === true`).
|
|
387
|
+
* The chooser does not use this for a new door: it claims, then issues,
|
|
388
|
+
* then stamps. An AI caller does not get ownerSession.
|
|
389
|
+
*/
|
|
390
|
+
export async function recordWriterDecision(db, prefix = COLLECTION_PREFIX, { requestId, decision, decider, ownerSession, issued } = {}, now = new Date()) {
|
|
391
|
+
const claimed = await claimWriterDecision(db, prefix, { requestId, decision, decider, ownerSession }, now);
|
|
392
|
+
if (decision === 'approve' && issued === true) return stampWriterIssued(db, prefix, { requestId });
|
|
393
|
+
return claimed;
|
|
394
|
+
}
|
package/templates/AREA.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**Template control:** id `templates/AREA.md` · revision: the store's version governs · status: IN FORCE · approved: user · 2026-10-20 · owner: EMET (base) · built to `templates/STANDARD.md` · supersedes: none
|
|
4
4
|
**Fills:** `areas/<slug>.md` — the selector for one compiled topic page.
|
|
5
|
-
**Failure it prevents:** a topic page stored as a record, so a view computed from the memory database became a second source of truth (
|
|
5
|
+
**Failure it prevents:** a topic page stored as a record, so a view computed from the memory database became a second source of truth (the owner, 2026-10-20). The page body is never written here.
|
|
6
6
|
**Completion rules:** `templates/STANDARD.md` §5, unmodified.
|
|
7
7
|
|
|
8
8
|
---
|
package/templates/BOTHANDOFF.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# TEMPLATE — BOT HANDOFF
|
|
2
2
|
|
|
3
|
-
**Template control:** id `templates/BOTHANDOFF.md` · revision: the store's version governs · status: DRAFT, not in force · approved: pending — the user asked for it 2026-10-01
|
|
3
|
+
**Template control:** id `templates/BOTHANDOFF.md` · revision: the store's version governs · status: DRAFT, not in force · approved: pending — the user asked for it 2026-10-01 4:17; IN FORCE only once the user approves this text and the decision record is filed · owner: EMET (base) · built to `templates/STANDARD.md` · supersedes: none
|
|
4
4
|
**Fills:** `bots/<source tag>/HANDOFF.md` — one bot's own session narrative, written last at each of that bot's closes. Listed in `EMET_RECORD_DOCS`, so it is a record: revision 1 is written plain, every later revision is written whole with `supersedes` set to the revision in force. The hub's `HANDOFF.md` is never filled from this template, and a bot never writes `HANDOFF.md` or `STATE.md` (the server refuses it, `docs/BOTS.md` §5).
|
|
5
|
-
**Failure it prevents:** a bot that can reach a complete close only by writing a new revision of the user's own `HANDOFF.md` and revising the user's board, so the user's next session opens on the bot's narrative (C1 review note §1a, 2026-10-01); scheduled bot runs citing sessions that were never opened, leaving permanent holes in the record (`emet_gaps` pointer disagreements, episodic ref 558 and ref 592); and a bot handoff checked against the hub's template, which demands a board the bot does not keep, so every bot close would add a nonconformance marker to the backlog (the review
|
|
5
|
+
**Failure it prevents:** a bot that can reach a complete close only by writing a new revision of the user's own `HANDOFF.md` and revising the user's board, so the user's next session opens on the bot's narrative (C1 review note §1a, 2026-10-01); scheduled bot runs citing sessions that were never opened, leaving permanent holes in the record (`emet_gaps` pointer disagreements, episodic ref 558 and ref 592); and a bot handoff checked against the hub's template, which demands a board the bot does not keep, so every bot close would add a nonconformance marker to the backlog (the review gate's second read of the C1 live check, 2026-10-01).
|
|
6
6
|
**Completion rules:** `templates/STANDARD.md` §5, unmodified.
|
|
7
7
|
|
|
8
8
|
---
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# TEMPLATE — GRANT
|
|
2
|
+
|
|
3
|
+
**Template control:** id `templates/GRANT.md` · revision: the store's version governs · status: DRAFT, not in force · approved: pending — R2 design 2026-10-26; IN FORCE only once the user approves this text and the decision record is filed · owner: EMET (base) · built to `templates/STANDARD.md` · supersedes: none
|
|
4
|
+
**Fills:** a grant record. Unmapped while DRAFT. The live credential is the OAuth token family (`src/grants.js`, `src/oauth-provider.js`). A filled `grants/<grant id>.md` is a later, owner-written record of that credential. It is not a second secret and it does not authorize anything by itself.
|
|
5
|
+
**Failure it prevents:** a write stamped with another connection's name because the credential that made the write was not on the row. The shared case is one OAuth client, one consent, and a caller-declared tag (recorded 2026-10-11 and 2026-10-15). The credential was the token family. The row did not carry it.
|
|
6
|
+
**Completion rules:** `templates/STANDARD.md` §5, unmodified.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## HOW TO FILL — rules specific to this template
|
|
11
|
+
|
|
12
|
+
1. **One record per grant.** The grant id is the token family. Do not invent a second id. Do not copy the access token, the refresh token, or the passphrase into this record.
|
|
13
|
+
2. **The door is owner, member, or guest.** Guest is the invite door. A missing door on an old token is recorded as unknown, not guessed as owner.
|
|
14
|
+
3. **The tag is bound to this grant.** A declared tag is a claim. It does not outrank the tag this grant was given. Two agents that share one bearer still share one grant; say so in §3.
|
|
15
|
+
4. **End a grant by supersede, revoke, or retain.** Revoke stops new use. The record stays. Nothing in this template is a delete.
|
|
16
|
+
5. **Do not fill a grace window.** A household rotation is revoke-all and fresh invites. Blank means there is none. Do not write a number.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## §0 RECORD CONTROL
|
|
21
|
+
- Template: `templates/GRANT.md` rev __ · Grant revision: the store's version governs
|
|
22
|
+
- Grant id: __
|
|
23
|
+
- Door: __ (owner · member · guest · unknown)
|
|
24
|
+
- Written (local): __ · Session id: __ · Source tag: __
|
|
25
|
+
|
|
26
|
+
## §1 CREDENTIAL
|
|
27
|
+
- **Client id:** __ (registration id or metadata URL; not a secret)
|
|
28
|
+
- **Person id:** __
|
|
29
|
+
- **Bound tag:** __
|
|
30
|
+
- **Created:** __ · **Created via:** __ (consent · invite · migration)
|
|
31
|
+
- **Status:** __ (live · revoked · superseded)
|
|
32
|
+
|
|
33
|
+
## §2 WHAT THIS DOOR MAY DO
|
|
34
|
+
- **Scopes:** __
|
|
35
|
+
- **May approve new writers:** __ (owner only, until a later decision says otherwise)
|
|
36
|
+
- **Write versus read:** __ · If Claude or ChatGPT: `NOT DECIDED`
|
|
37
|
+
|
|
38
|
+
## §3 SHARED BEARER
|
|
39
|
+
Who else can present this same grant, or *"None — this grant is one consent and one holder."*
|
|
40
|
+
|
|
41
|
+
## §4 END
|
|
42
|
+
- **Action:** __ (revoke · supersede · retain) · **Grace window:** none
|
|
43
|
+
- **Replaced by grant id:** __ or *"None."*
|
|
44
|
+
- **Reason:** __
|
|
45
|
+
- **Rows already written:** retained. A correction is a later record, not an edit of the old row.
|
|
46
|
+
|
|
47
|
+
## §5 NOT THIS RECORD
|
|
48
|
+
Chooser page, deep link, and break-glass: later. Household rotate-all: later, and it has no grace window. A second login kept only to obtain another client id: later, revoked, not erased.
|
package/templates/INDEX.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# EMET CONTROLLED DOCUMENT LIBRARY — REGISTER
|
|
2
2
|
|
|
3
|
-
**Status:** **ADOPTED by the user 2026-09-11** (*"Yes I do"*; procedural ref 311). **IN FORCE with the repository commit** (board
|
|
3
|
+
**Status:** **ADOPTED by the user 2026-09-11** (*"Yes I do"*; procedural ref 311). **IN FORCE with the repository commit** (board 014), because the shipped copy governs (`templates/STANDARD.md` §9a L1; `CHARTER.md` §9). Revision: the store's version governs. Decision records: procedural ref 300 → ref 301 (scope), ref 302 (latitude), ref 303 → ref 304 (validation not optional; mark for audit and review); review of 2026-09-11: ref 306 (validation v1, shipping), ref 307 (locks), ref 308 (close order), ref 309 (charter lock), ref 310 (seed statuses and triggers).
|
|
4
4
|
**Written:** 2026-09-10. **Brought current** 2026-09-11, session `2026-09-11_morning-mobile-init`, source `mobile`, after the user's full review of the set. **This revision also removes install-specific names** — the reference install's orchestrator, private documents, named employers, machine paths and seed names — under the scope rule that shipped forms are generic (ref 301). The reference install's own records keep them.
|
|
5
5
|
|
|
6
6
|
---
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
| **1 — Charter** | What EMET is, what it is for, how it is structured, how information flows, how documents are controlled | `CHARTER.md` — DRAFT; locked like the base templates: ships with the release, a store copy is not authoritative, and it is present before any first-run interview |
|
|
23
23
|
| **2 — Procedures** | How a session runs, start to close | The floor, layer charter, startup instructions and close protocol — in server code, pointed to. The close order is stated once, in `CHARTER.md` §6. An install may add its own orchestrator; it points here and restates nothing |
|
|
24
24
|
| **3 — Work instructions and reference** | How to do a specific thing | `procedures/*` (PROCEDURE template) · an install's own reference and debug documents |
|
|
25
|
-
| **4 — Forms and records** | Templates (forms) and the documents filled from them (records) | `templates/*` → `HANDOFF.md`, `STATE.md`, `threads/*`, `seeds/*`, `staging/*`, `procedures/*`, `areas/*` · layer entries and transcripts (structure enforced by code) |
|
|
25
|
+
| **4 — Forms and records** | Templates (forms) and the documents filled from them (records) | `templates/*` → `HANDOFF.md`, `STATE.md`, `threads/*`, `seeds/*`, `staging/*`, `procedures/*`, `areas/*`, `records/*` · layer entries and transcripts (structure enforced by code) |
|
|
26
26
|
|
|
27
27
|
---
|
|
28
28
|
|
|
@@ -45,7 +45,9 @@ Every document listed under **Fills** is validated against its template by its i
|
|
|
45
45
|
| `templates/INSTALL.md` | `bootstrap/INSTALL.md` | A paste-block start that cannot check a machine or tag a write | IN FORCE 2026-09-26 · procedural ref 361 |
|
|
46
46
|
| `templates/BOTHANDOFF.md` | `bots/<tag>/HANDOFF.md` (unmapped while DRAFT) | A bot that could close only by writing the user's own handoff and board; scheduled bot runs citing sessions never opened (episodic ref 558, ref 592); bot handoffs marked nonconforming against a template that demands a board | DRAFT — requested by the user 2026-10-01; approval and decision record pending. Supersede-only after revision 1 (`EMET_RECORD_DOCS`) |
|
|
47
47
|
| `templates/ROSTER.md` | `bots/ROSTER.md` (unmapped while DRAFT) | A bot tag the server did not treat as a bot because its handoff id was never listed (a live check of per-bot close records, 2026-10-01); the hub's tag at risk of being listed with the bots | DRAFT — requested by the user 2026-10-01; approval and decision record pending. The hub is listed apart and never in `EMET_RECORD_DOCS` |
|
|
48
|
-
| `templates/AREA.md` | `areas/<slug>.md` | A topic page stored as a record, so a view computed from the memory database became a second source of truth (
|
|
48
|
+
| `templates/AREA.md` | `areas/<slug>.md` | A topic page stored as a record, so a view computed from the memory database became a second source of truth (the owner, 2026-10-20). The area document holds the selector only | IN FORCE 2026-10-20 · user. Only the owner creates or edits an area. The page is computed on each read and is never written back |
|
|
49
|
+
| `templates/SESSIONDISPOSITION.md` | `records/*` | A close days later blocked because receipts are compared with the store that day, and a duplicate save_transcript left unmarked (inserted_id 6ae1df09c4da08b2cadc1fb4, 2026-10-28). The disposition notes the session or the transcript. It does not write a receipt and it does not delete the transcript | IN FORCE 2026-10-28 · user, session-disposition brief. A session-level row covers checkpoint overdue. An inserted_id row does not close the session |
|
|
50
|
+
| `templates/GRANT.md` | unmapped while DRAFT. Later, an owner-written `grants/<grant id>.md` that records one OAuth token family. The live credential stays the family itself | A write stamped with another connection's name because the credential that made it was not on the row (shared OAuth client, declared tag, 2026-10-11 and 2026-10-15) | DRAFT — R2 design 2026-10-26. Approval and decision record pending. Not a second secret |
|
|
49
51
|
|
|
50
52
|
**Deliberately NOT templated:** an install's own orchestrator (a single document, not a type) · layer entries and transcripts (structure already enforced by the write-path door) · an install's private reference documents that have their own convention and no recorded failure.
|
|
51
53
|
|
|
@@ -57,13 +59,13 @@ Every document listed under **Fills** is validated against its template by its i
|
|
|
57
59
|
|
|
58
60
|
0. ~~STANDARD~~ — written 2026-09-10.
|
|
59
61
|
1. ~~HANDOFF + BOARD~~ — written 2026-09-10; in trial use.
|
|
60
|
-
2. ~~CHARTER~~ — written 2026-09-10; §1 intended use awaits the user's words (board
|
|
62
|
+
2. ~~CHARTER~~ — written 2026-09-10; §1 intended use awaits the user's words (board 010).
|
|
61
63
|
3. ~~SEED + THREAD~~ — written 2026-09-10 evening.
|
|
62
64
|
4. ~~STAGING + PROCEDURE~~ — written 2026-09-10 evening.
|
|
63
65
|
5. ~~Migrate the position document into the BOARD form~~ — done 2026-09-10.
|
|
64
66
|
6. ~~Review of the full set with the user~~ — done 2026-09-11.
|
|
65
67
|
7. **Validation v1** — DECIDED 2026-09-11 (ref 306, ref 307): the priced scope plus locks L1–L6. Not built — bridged session.
|
|
66
|
-
8. **Repository commit** (board
|
|
68
|
+
8. **Repository commit** (board 014) — the charter and templates ship in the release; the set becomes IN FORCE with it.
|
|
67
69
|
|
|
68
70
|
## LATITUDE — DECIDED (user, 2026-09-10; procedural ref 302)
|
|
69
71
|
*"They must be followed but can be expanded and there can be a generic template standard guidlines for anything added above and beyond will be created within those guidelines."* Base templates: required sections fixed; installs may expand, never loosen. Anything beyond the base is built to `templates/STANDARD.md`.
|
|
@@ -79,5 +81,5 @@ Every document listed under **Fills** is validated against its template by its i
|
|
|
79
81
|
## OPEN — the user's
|
|
80
82
|
- **Adoption — DECIDED 2026-09-11** (procedural ref 311). IN FORCE with the repository commit.
|
|
81
83
|
- **Where local templates live** in an install's store.
|
|
82
|
-
- **Intended-use statement** for the charter (board
|
|
83
|
-
- **The disclosure line** (board
|
|
84
|
+
- **Intended-use statement** for the charter (board 010).
|
|
85
|
+
- **The disclosure line** (board 016) — before the repository goes public.
|
package/templates/PROCEDURE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# TEMPLATE — PROCEDURE
|
|
2
2
|
|
|
3
|
-
**Template control:** id `templates/PROCEDURE.md` · revision: the store's version governs · status: IN FORCE · approved: user · 2026-09-11 · procedural ref 311 (board
|
|
3
|
+
**Template control:** id `templates/PROCEDURE.md` · revision: the store's version governs · status: IN FORCE · approved: user · 2026-09-11 · procedural ref 311 (board 011) · owner: EMET (base) · built to `templates/STANDARD.md` · supersedes: none
|
|
4
4
|
**Fills:** `procedures/<name>.md` — reference procedures and work instructions: how to do one specific thing on one specific system (Tier 3). **Every `procedures/*` document is validated against this template by its id** (`templates/STANDARD.md` §9 map); leaving out the control block does not exempt it (§9a L4). Work instructions that exist outside the store come in when they are next rewritten, not before.
|
|
5
5
|
**Failure it prevents:** recorded paths and commands that went stale unverified and failed silently when followed — an interpreter path that no longer existed carried in two bootstrap documents for months; a deploy command naming the project instead of the service (reference install, August–September 2026).
|
|
6
6
|
**Completion rules:** `templates/STANDARD.md` §5, unmodified.
|
package/templates/ROSTER.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# TEMPLATE — BOT ROSTER
|
|
2
2
|
|
|
3
|
-
**Template control:** id `templates/ROSTER.md` · revision: the store's version governs · status: DRAFT, not in force · approved: pending — the user asked for it 2026-10-01
|
|
3
|
+
**Template control:** id `templates/ROSTER.md` · revision: the store's version governs · status: DRAFT, not in force · approved: pending — the user asked for it 2026-10-01 4:18; IN FORCE only once the user approves this text and the decision record is filed · owner: EMET (base) · built to `templates/STANDARD.md` · supersedes: none
|
|
4
4
|
**Fills:** `bots/ROSTER.md` — the one list of the bots that write to this install: each bot's source tag, name, role, host, machine, record, tool profile and owner, and the hub that is not a bot. It is a controlled document, revised under control (each revision archived), and kept by the hub. It is the user's register; the server's switch is `EMET_RECORD_DOCS`, and §3 records that the two agree.
|
|
5
|
-
**Failure it prevents:** a bot tag the server did not treat as a bot because its handoff id was never listed in `EMET_RECORD_DOCS`, found only when a live check's refusal came from the wrong rule (a live check of per-bot close records, 2026-10-01: a bot's test write refused by the records rule, not the bot rule); and the hub's own tag at risk of being listed with the bots, which would make the server refuse the hub's writes to the user's handoff and board (the review
|
|
5
|
+
**Failure it prevents:** a bot tag the server did not treat as a bot because its handoff id was never listed in `EMET_RECORD_DOCS`, found only when a live check's refusal came from the wrong rule (a live check of per-bot close records, 2026-10-01: a bot's test write refused by the records rule, not the bot rule); and the hub's own tag at risk of being listed with the bots, which would make the server refuse the hub's writes to the user's handoff and board (the review gate's second read of that check, 2026-10-01; `docs/DEPLOY.md`). Until this list existed, which tags were bots lived only in a deploy variable nobody could read back from inside a session.
|
|
6
6
|
**Completion rules:** `templates/STANDARD.md` §5, unmodified.
|
|
7
7
|
|
|
8
8
|
---
|
package/templates/SEED.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# TEMPLATE — SEED
|
|
2
2
|
|
|
3
|
-
**Template control:** id `templates/SEED.md` · revision: the store's version governs · status: IN FORCE · approved: user · 2026-09-13 (record control stated once, as front matter — the user's instruction; prior approval 2026-09-11 · procedural ref 311 (board
|
|
3
|
+
**Template control:** id `templates/SEED.md` · revision: the store's version governs · status: IN FORCE · approved: user · 2026-09-13 (record control stated once, as front matter — the user's instruction; prior approval 2026-09-11 · procedural ref 311 (board 011)) · owner: EMET (base) · built to `templates/STANDARD.md` · supersedes: none
|
|
4
4
|
**Fills:** `seeds/<name>.md` — an idea that is valid but wrongly timed, parked with the condition that brings it back.
|
|
5
5
|
**Failure it prevents:** a met trigger that sat unsurfaced for weeks because nothing at startup could tell it had fired (reference install, 2026-09-10); triggers that name an event nobody scheduled, so they could never fire (three seeds waiting on a "post-certification review" that was never put on a calendar, same date); a seed that had already been executed still sitting as a seed, read at every startup as live (reference install, supersession work, August 2026).
|
|
6
6
|
**Completion rules:** `templates/STANDARD.md` §5, unmodified.
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
1. **Every trigger is testable without asking the user.** It is one of four kinds, and nothing else:
|
|
15
15
|
- `DATE` — a calendar date. Fires on or after it.
|
|
16
|
-
- `ROW` — a board row id and the change that fires it (`board
|
|
16
|
+
- `ROW` — a board row id and the change that fires it (`board 018 opens`, `board 011 closes`). The board row must exist when the seed is planted; if it does not, open one.
|
|
17
17
|
- `SIGNAL` — something a startup can observe by name: a named document reaching a named state, a named external item closing. **Name where it is checked.**
|
|
18
18
|
- `TOPIC` — the user raises a named subject. **Checked during the session, not at startup:** list the subject words in the trigger so any session that has scanned the seed recognises them when they come up. *Prevents:* outlawing a trigger that works — the reference install's first-run-experience seed fired correctly this way on 2026-09-11.
|
|
19
19
|
A trigger that names an event with no date and no board row ("after the review", "when there is time") is a nonconformance: plant it as `ROW` against a row that schedules the event, or as `DATE`.
|