@sentropic/track 0.98.11-rc.9 → 0.98.11
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/dist/adopt/apply.d.ts +1 -0
- package/dist/adopt/apply.d.ts.map +1 -1
- package/dist/adopt/apply.js +5 -1
- package/dist/adopt/apply.js.map +1 -1
- package/dist/capture/cli.d.ts +5 -0
- package/dist/capture/cli.d.ts.map +1 -0
- package/dist/capture/cli.js +532 -0
- package/dist/capture/cli.js.map +1 -0
- package/dist/capture/index.d.ts +8 -0
- package/dist/capture/index.d.ts.map +1 -0
- package/dist/capture/index.js +8 -0
- package/dist/capture/index.js.map +1 -0
- package/dist/capture/inscribe.d.ts +64 -0
- package/dist/capture/inscribe.d.ts.map +1 -0
- package/dist/capture/inscribe.js +407 -0
- package/dist/capture/inscribe.js.map +1 -0
- package/dist/capture/markers.d.ts +10 -0
- package/dist/capture/markers.d.ts.map +1 -0
- package/dist/capture/markers.js +26 -0
- package/dist/capture/markers.js.map +1 -0
- package/dist/capture/queue.d.ts +131 -0
- package/dist/capture/queue.d.ts.map +1 -0
- package/dist/capture/queue.js +422 -0
- package/dist/capture/queue.js.map +1 -0
- package/dist/capture/reader.d.ts +42 -0
- package/dist/capture/reader.d.ts.map +1 -0
- package/dist/capture/reader.js +72 -0
- package/dist/capture/reader.js.map +1 -0
- package/dist/capture/registry.d.ts +42 -0
- package/dist/capture/registry.d.ts.map +1 -0
- package/dist/capture/registry.js +141 -0
- package/dist/capture/registry.js.map +1 -0
- package/dist/capture/secrets.d.ts +30 -0
- package/dist/capture/secrets.d.ts.map +1 -0
- package/dist/capture/secrets.js +145 -0
- package/dist/capture/secrets.js.map +1 -0
- package/dist/cli/adopt.d.ts +1 -1
- package/dist/cli/adopt.d.ts.map +1 -1
- package/dist/cli/adopt.js +3 -2
- package/dist/cli/adopt.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +113 -22
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/journal-reference.d.ts +2 -0
- package/dist/cli/journal-reference.d.ts.map +1 -1
- package/dist/cli/journal-reference.js +12 -0
- package/dist/cli/journal-reference.js.map +1 -1
- package/dist/cli/journal.d.ts +1 -1
- package/dist/cli/journal.d.ts.map +1 -1
- package/dist/cli/journal.js +130 -6
- package/dist/cli/journal.js.map +1 -1
- package/dist/cli/restructure-apply.d.ts +3 -0
- package/dist/cli/restructure-apply.d.ts.map +1 -1
- package/dist/cli/restructure-apply.js +5 -1
- package/dist/cli/restructure-apply.js.map +1 -1
- package/dist/events/store.d.ts +5 -1
- package/dist/events/store.d.ts.map +1 -1
- package/dist/events/store.js +8 -1
- package/dist/events/store.js.map +1 -1
- package/dist/events/types.d.ts +8 -3
- package/dist/events/types.d.ts.map +1 -1
- package/dist/events/types.js +4 -0
- package/dist/events/types.js.map +1 -1
- package/dist/focus-vendor/artifact/manifest.d.ts +1 -1
- package/dist/focus-vendor/artifact/manifest.js +4 -4
- package/dist/focus-vendor/artifact/manifest.js.map +1 -1
- package/dist/focus-vendor/cli/index.d.ts +1 -1
- package/dist/focus-vendor/cli/index.d.ts.map +1 -1
- package/dist/focus-vendor/cli/index.js +38 -3
- package/dist/focus-vendor/cli/index.js.map +1 -1
- package/dist/focus-vendor/index.d.ts +2 -1
- package/dist/focus-vendor/index.js +4 -1
- package/dist/focus-vendor/index.js.map +1 -1
- package/dist/focus-vendor/model.d.ts +13 -0
- package/dist/focus-vendor/model.d.ts.map +1 -1
- package/dist/focus-vendor/model.js +13 -0
- package/dist/focus-vendor/model.js.map +1 -1
- package/dist/focus-vendor/registry/definitions.js +7 -7
- package/dist/focus-vendor/registry/definitions.js.map +1 -1
- package/dist/focus-vendor/registry/entries.v1.json +14 -14
- package/dist/focus-vendor/render/html.d.ts +1 -1
- package/dist/focus-vendor/render/html.d.ts.map +1 -1
- package/dist/focus-vendor/render/html.js +8 -2
- package/dist/focus-vendor/render/html.js.map +1 -1
- package/dist/focus-vendor/render/theme.d.ts +17 -0
- package/dist/focus-vendor/render/theme.d.ts.map +1 -0
- package/dist/focus-vendor/render/theme.js +654 -0
- package/dist/focus-vendor/render/theme.js.map +1 -0
- package/dist/focus-vendor/validation/index.d.ts +6 -0
- package/dist/focus-vendor/validation/index.d.ts.map +1 -1
- package/dist/focus-vendor/validation/index.js +14 -1
- package/dist/focus-vendor/validation/index.js.map +1 -1
- package/dist/focus-vendor/validation/readability.d.ts.map +1 -1
- package/dist/focus-vendor/validation/readability.js +25 -25
- package/dist/focus-vendor/validation/readability.js.map +1 -1
- package/dist/fs-private.d.ts +37 -0
- package/dist/fs-private.d.ts.map +1 -0
- package/dist/fs-private.js +224 -0
- package/dist/fs-private.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/journal/index-store.d.ts.map +1 -1
- package/dist/journal/index-store.js +9 -24
- package/dist/journal/index-store.js.map +1 -1
- package/dist/model/decision.d.ts +3 -0
- package/dist/model/decision.d.ts.map +1 -1
- package/dist/model/decision.js.map +1 -1
- package/dist/model/demand.d.ts +19 -1
- package/dist/model/demand.d.ts.map +1 -1
- package/dist/model/demand.js +4 -0
- package/dist/model/demand.js.map +1 -1
- package/dist/read/commands.d.ts +2 -0
- package/dist/read/commands.d.ts.map +1 -1
- package/dist/read/commands.js +3 -1
- package/dist/read/commands.js.map +1 -1
- package/dist/report/owner-table-qualified.d.ts +28 -0
- package/dist/report/owner-table-qualified.d.ts.map +1 -1
- package/dist/report/owner-table-qualified.js +90 -8
- package/dist/report/owner-table-qualified.js.map +1 -1
- package/dist/report/owner-table-scope.d.ts +13 -1
- package/dist/report/owner-table-scope.d.ts.map +1 -1
- package/dist/report/owner-table-scope.js +35 -6
- package/dist/report/owner-table-scope.js.map +1 -1
- package/dist/report/owner-table-strings.d.ts +43 -3
- package/dist/report/owner-table-strings.d.ts.map +1 -1
- package/dist/report/owner-table-strings.js +86 -18
- package/dist/report/owner-table-strings.js.map +1 -1
- package/dist/report/owner-table.d.ts +21 -1
- package/dist/report/owner-table.d.ts.map +1 -1
- package/dist/report/owner-table.js +98 -1
- package/dist/report/owner-table.js.map +1 -1
- package/dist/state/fold.d.ts.map +1 -1
- package/dist/state/fold.js +47 -0
- package/dist/state/fold.js.map +1 -1
- package/dist/track.d.ts +26 -1
- package/dist/track.d.ts.map +1 -1
- package/dist/track.js +72 -0
- package/dist/track.js.map +1 -1
- package/dist/write-policy.d.ts +83 -0
- package/dist/write-policy.d.ts.map +1 -0
- package/dist/write-policy.js +290 -0
- package/dist/write-policy.js.map +1 -0
- package/package.json +1 -1
- package/skills/present-decision/SKILL.md +24 -25
- package/skills/present-decision/assets/dossier-template.md +2 -3
- package/skills/present-decision/assets/self-audit.md +11 -10
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { createHash, randomBytes, timingSafeEqual } from 'node:crypto';
|
|
2
|
+
import { mkdirSync } from 'node:fs';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
import { maskSecrets } from './capture/secrets.js';
|
|
5
|
+
import { withFileLock } from './events/lock.js';
|
|
6
|
+
import { ensurePrivateDirHardened, lstatNoFollow, readFileNoFollow, writeFileAtomicPrivate, } from './fs-private.js';
|
|
7
|
+
import { DomainError } from './model/item.js';
|
|
8
|
+
export const WRITE_POLICY_VERSION = 1;
|
|
9
|
+
export const WRITE_POLICY_FILENAME = 'write-policy.json';
|
|
10
|
+
const MAX_HISTORY_ENTRIES = 20;
|
|
11
|
+
const MAX_HOLDER_LENGTH = 64;
|
|
12
|
+
const FORBIDDEN_HOLDER_CHARS_RE = /[\x00-\x1f\x7f·]/u;
|
|
13
|
+
function assertValidHolder(holder, context) {
|
|
14
|
+
const trimmed = holder.trim();
|
|
15
|
+
if (trimmed.length === 0) {
|
|
16
|
+
throw new DomainError(`${context}: --holder must be non-empty`);
|
|
17
|
+
}
|
|
18
|
+
if (trimmed.length > MAX_HOLDER_LENGTH) {
|
|
19
|
+
throw new DomainError(`${context}: --holder must be at most ${MAX_HOLDER_LENGTH} characters`);
|
|
20
|
+
}
|
|
21
|
+
if (FORBIDDEN_HOLDER_CHARS_RE.test(trimmed)) {
|
|
22
|
+
throw new DomainError(`${context}: --holder must not contain control characters or '·'`);
|
|
23
|
+
}
|
|
24
|
+
return trimmed;
|
|
25
|
+
}
|
|
26
|
+
export class WritePolicyError extends DomainError {
|
|
27
|
+
holder;
|
|
28
|
+
epoch;
|
|
29
|
+
constructor(message, holder, epoch) {
|
|
30
|
+
super(message);
|
|
31
|
+
this.holder = holder;
|
|
32
|
+
this.epoch = epoch;
|
|
33
|
+
this.name = 'WritePolicyError';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function writePolicyPathFor(eventsPath) {
|
|
37
|
+
return join(dirname(eventsPath), WRITE_POLICY_FILENAME);
|
|
38
|
+
}
|
|
39
|
+
function sha256Hex(input) {
|
|
40
|
+
return createHash('sha256').update(input, 'utf8').digest('hex');
|
|
41
|
+
}
|
|
42
|
+
export function digestWriterToken(token) {
|
|
43
|
+
return `sha256:${sha256Hex(token)}`;
|
|
44
|
+
}
|
|
45
|
+
function constantTimeDigestEqual(presentedDigest, expectedDigest) {
|
|
46
|
+
const normA = presentedDigest.replace(/^sha256:/iu, '').trim().toLowerCase();
|
|
47
|
+
const normB = expectedDigest.replace(/^sha256:/iu, '').trim().toLowerCase();
|
|
48
|
+
if (normA.length === 0 || normA.length !== normB.length)
|
|
49
|
+
return false;
|
|
50
|
+
return timingSafeEqual(Buffer.from(normA, 'utf8'), Buffer.from(normB, 'utf8'));
|
|
51
|
+
}
|
|
52
|
+
function defaultOpenPolicy() {
|
|
53
|
+
return {
|
|
54
|
+
version: WRITE_POLICY_VERSION,
|
|
55
|
+
mode: 'open',
|
|
56
|
+
holder: null,
|
|
57
|
+
epoch: 0,
|
|
58
|
+
tokenDigest: null,
|
|
59
|
+
updatedAt: null,
|
|
60
|
+
history: [],
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function parseWritePolicy(raw, filePath) {
|
|
64
|
+
let parsed;
|
|
65
|
+
try {
|
|
66
|
+
parsed = JSON.parse(raw);
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
throw new WritePolicyError(`malformed write-policy.json at ${filePath}: ${err instanceof Error ? err.message : String(err)}`, null, 0);
|
|
70
|
+
}
|
|
71
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
72
|
+
throw new WritePolicyError(`malformed write-policy.json at ${filePath}: expected JSON object`, null, 0);
|
|
73
|
+
}
|
|
74
|
+
const obj = parsed;
|
|
75
|
+
const mode = obj['mode'];
|
|
76
|
+
if (mode !== 'open' && mode !== 'exclusive') {
|
|
77
|
+
throw new WritePolicyError(`invalid write-policy mode "${String(mode)}" at ${filePath}`, null, 0);
|
|
78
|
+
}
|
|
79
|
+
const holder = typeof obj['holder'] === 'string' && obj['holder'].trim() !== '' ? obj['holder'].trim() : null;
|
|
80
|
+
const epoch = typeof obj['epoch'] === 'number' && Number.isInteger(obj['epoch']) && obj['epoch'] >= 0
|
|
81
|
+
? obj['epoch']
|
|
82
|
+
: 0;
|
|
83
|
+
// Accept both `tokenDigest` (lot 3a) and `tokenHash` (lot 5a adopt fixture compatibility)
|
|
84
|
+
const rawDigest = typeof obj['tokenDigest'] === 'string' && obj['tokenDigest'].trim() !== ''
|
|
85
|
+
? obj['tokenDigest'].trim()
|
|
86
|
+
: typeof obj['tokenHash'] === 'string' && obj['tokenHash'].trim() !== ''
|
|
87
|
+
? obj['tokenHash'].trim()
|
|
88
|
+
: null;
|
|
89
|
+
const updatedAt = typeof obj['updatedAt'] === 'string' ? obj['updatedAt'] : null;
|
|
90
|
+
const history = Array.isArray(obj['history']) ? obj['history'] : [];
|
|
91
|
+
if (holder !== null && (holder.length > MAX_HOLDER_LENGTH || FORBIDDEN_HOLDER_CHARS_RE.test(holder))) {
|
|
92
|
+
throw new WritePolicyError(`malformed write-policy.json at ${filePath}: invalid holder value`, null, epoch);
|
|
93
|
+
}
|
|
94
|
+
if (mode === 'exclusive' && (holder === null || rawDigest === null)) {
|
|
95
|
+
throw new WritePolicyError(`malformed exclusive write-policy.json at ${filePath}: missing holder or token digest`, holder, epoch);
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
version: WRITE_POLICY_VERSION,
|
|
99
|
+
mode,
|
|
100
|
+
holder,
|
|
101
|
+
epoch,
|
|
102
|
+
tokenDigest: rawDigest,
|
|
103
|
+
updatedAt,
|
|
104
|
+
history,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Pure read-only view of a journal's write policy (V4: never creates or modifies files).
|
|
109
|
+
* Absent file (`ENOENT` only) means open, epoch 0 (spec §7.4). Fails closed (`WritePolicyError`)
|
|
110
|
+
* on symlinks, permission errors (`EACCES`), or any other unreadable state.
|
|
111
|
+
*/
|
|
112
|
+
export function readWritePolicy(eventsPath) {
|
|
113
|
+
const filePath = writePolicyPathFor(eventsPath);
|
|
114
|
+
const raw = readFileNoFollow(filePath, (msg) => new WritePolicyError(msg, null, 0));
|
|
115
|
+
if (raw === undefined)
|
|
116
|
+
return defaultOpenPolicy();
|
|
117
|
+
return parseWritePolicy(raw, filePath);
|
|
118
|
+
}
|
|
119
|
+
function writePolicyAtomically(filePath, policy) {
|
|
120
|
+
const parent = dirname(filePath);
|
|
121
|
+
if (lstatNoFollow(parent) === undefined) {
|
|
122
|
+
mkdirSync(parent, { recursive: true });
|
|
123
|
+
}
|
|
124
|
+
const payload = `${JSON.stringify(policy, null, 2)}\n`;
|
|
125
|
+
writeFileAtomicPrivate(filePath, payload, 0o600, (msg) => new WritePolicyError(msg, policy.holder, policy.epoch));
|
|
126
|
+
}
|
|
127
|
+
export function writeTokenFilePrivate(tokenFilePath, token) {
|
|
128
|
+
const parent = dirname(tokenFilePath);
|
|
129
|
+
const parentSt = lstatNoFollow(parent);
|
|
130
|
+
if (parentSt === undefined) {
|
|
131
|
+
ensurePrivateDirHardened(parent);
|
|
132
|
+
}
|
|
133
|
+
else if (!parentSt.isDirectory()) {
|
|
134
|
+
throw new DomainError(`token file parent is not a directory: ${parent}`);
|
|
135
|
+
}
|
|
136
|
+
writeFileAtomicPrivate(tokenFilePath, `${token}\n`, 0o600);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Resolve the presented writer token from explicit option, `--writer-token-file`, or
|
|
140
|
+
* `TRACK_WRITER_TOKEN` env var. Throws `WritePolicyError` if an explicit token file is missing,
|
|
141
|
+
* a symbolic link, or unreadable.
|
|
142
|
+
*/
|
|
143
|
+
export function resolvePresentedWriterToken(input = {}, policyForError) {
|
|
144
|
+
if (input.writerToken !== undefined) {
|
|
145
|
+
const trimmed = input.writerToken.trim();
|
|
146
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
147
|
+
}
|
|
148
|
+
if (input.writerTokenFile !== undefined) {
|
|
149
|
+
const makeErr = (msg) => new WritePolicyError(`write refused: journal is in exclusive mode (holder: ${policyForError?.holder ?? 'unknown'}, epoch: ${policyForError?.epoch ?? 0}); ${msg}`, policyForError?.holder ?? null, policyForError?.epoch ?? 0);
|
|
150
|
+
const raw = readFileNoFollow(input.writerTokenFile, makeErr);
|
|
151
|
+
if (raw === undefined) {
|
|
152
|
+
throw makeErr(`writer token file not found: ${input.writerTokenFile}`);
|
|
153
|
+
}
|
|
154
|
+
const content = raw.trim();
|
|
155
|
+
return content.length > 0 ? content : undefined;
|
|
156
|
+
}
|
|
157
|
+
const env = input.env ?? process.env;
|
|
158
|
+
const fromEnv = env['TRACK_WRITER_TOKEN']?.trim();
|
|
159
|
+
return fromEnv !== undefined && fromEnv.length > 0 ? fromEnv : undefined;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Enforce the journal's write policy. Intended to be called INSIDE `withFileLock(eventsPath, ...)`
|
|
163
|
+
* BEFORE any integrity check or mutation (plan/07 Lot 3).
|
|
164
|
+
*
|
|
165
|
+
* Refuses (throws `WritePolicyError` naming holder and epoch) whenever `mode === 'exclusive'` and
|
|
166
|
+
* the presented token does not match the recorded digest. No expiry or automatic takeover exists.
|
|
167
|
+
*/
|
|
168
|
+
export function assertWritePolicyAllows(eventsPath, input = {}) {
|
|
169
|
+
const policy = readWritePolicy(eventsPath);
|
|
170
|
+
if (policy.mode !== 'exclusive')
|
|
171
|
+
return;
|
|
172
|
+
const presented = resolvePresentedWriterToken(input, policy);
|
|
173
|
+
if (presented === undefined ||
|
|
174
|
+
policy.tokenDigest === null ||
|
|
175
|
+
!constantTimeDigestEqual(digestWriterToken(presented), policy.tokenDigest)) {
|
|
176
|
+
throw new WritePolicyError(`write refused: journal is in exclusive write mode (holder: ${policy.holder ?? 'unknown'}, epoch: ${policy.epoch}); present the current writer token via TRACK_WRITER_TOKEN or --writer-token-file`, policy.holder, policy.epoch);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function generateWriterToken() {
|
|
180
|
+
return randomBytes(32).toString('hex');
|
|
181
|
+
}
|
|
182
|
+
function appendHistory(prev, entry) {
|
|
183
|
+
const next = [...prev, entry];
|
|
184
|
+
return next.length > MAX_HISTORY_ENTRIES ? next.slice(next.length - MAX_HISTORY_ENTRIES) : next;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Declare an exclusive writer on an open journal (`track journal declare-writer`).
|
|
188
|
+
* Refuses if the journal is already exclusive (never replaces a holder without explicit takeover).
|
|
189
|
+
*/
|
|
190
|
+
export function declareExclusiveWriter(eventsPath, holder, opts = {}) {
|
|
191
|
+
const trimmedHolder = assertValidHolder(holder, 'journal declare-writer');
|
|
192
|
+
const now = opts.now ?? new Date().toISOString();
|
|
193
|
+
return withFileLock(eventsPath, () => {
|
|
194
|
+
const current = readWritePolicy(eventsPath);
|
|
195
|
+
if (current.mode === 'exclusive') {
|
|
196
|
+
throw new WritePolicyError(`journal declare-writer: journal is already in exclusive mode (holder: ${current.holder ?? 'unknown'}, epoch: ${current.epoch}); use \`track journal takeover --holder <name> --reason <text>\` to replace the holder`, current.holder, current.epoch);
|
|
197
|
+
}
|
|
198
|
+
const token = generateWriterToken();
|
|
199
|
+
const epoch = current.epoch + 1;
|
|
200
|
+
const next = {
|
|
201
|
+
version: WRITE_POLICY_VERSION,
|
|
202
|
+
mode: 'exclusive',
|
|
203
|
+
holder: trimmedHolder,
|
|
204
|
+
epoch,
|
|
205
|
+
tokenDigest: digestWriterToken(token),
|
|
206
|
+
updatedAt: now,
|
|
207
|
+
history: appendHistory(current.history, {
|
|
208
|
+
action: 'declare',
|
|
209
|
+
holder: trimmedHolder,
|
|
210
|
+
epoch,
|
|
211
|
+
at: now,
|
|
212
|
+
}),
|
|
213
|
+
};
|
|
214
|
+
writePolicyAtomically(writePolicyPathFor(eventsPath), next);
|
|
215
|
+
if (opts.tokenFile !== undefined) {
|
|
216
|
+
writeTokenFilePrivate(opts.tokenFile, token);
|
|
217
|
+
}
|
|
218
|
+
return { policy: next, token };
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Explicit takeover (`track journal takeover`): raises epoch, issues a fresh token, immediately
|
|
223
|
+
* invalidating any prior holder's token. Never automatic (spec V6, §7.4).
|
|
224
|
+
*/
|
|
225
|
+
export function takeoverExclusiveWriter(eventsPath, holder, reason, opts = {}) {
|
|
226
|
+
const trimmedHolder = assertValidHolder(holder, 'journal takeover');
|
|
227
|
+
const trimmedReason = reason.trim();
|
|
228
|
+
if (trimmedReason.length === 0) {
|
|
229
|
+
throw new DomainError('journal takeover: --reason must be non-empty');
|
|
230
|
+
}
|
|
231
|
+
const maskedReason = maskSecrets(trimmedReason).text;
|
|
232
|
+
const now = opts.now ?? new Date().toISOString();
|
|
233
|
+
return withFileLock(eventsPath, () => {
|
|
234
|
+
const current = readWritePolicy(eventsPath);
|
|
235
|
+
const token = generateWriterToken();
|
|
236
|
+
const epoch = current.epoch + 1;
|
|
237
|
+
const next = {
|
|
238
|
+
version: WRITE_POLICY_VERSION,
|
|
239
|
+
mode: 'exclusive',
|
|
240
|
+
holder: trimmedHolder,
|
|
241
|
+
epoch,
|
|
242
|
+
tokenDigest: digestWriterToken(token),
|
|
243
|
+
updatedAt: now,
|
|
244
|
+
history: appendHistory(current.history, {
|
|
245
|
+
action: 'takeover',
|
|
246
|
+
holder: trimmedHolder,
|
|
247
|
+
epoch,
|
|
248
|
+
at: now,
|
|
249
|
+
reason: maskedReason,
|
|
250
|
+
}),
|
|
251
|
+
};
|
|
252
|
+
writePolicyAtomically(writePolicyPathFor(eventsPath), next);
|
|
253
|
+
if (opts.tokenFile !== undefined) {
|
|
254
|
+
writeTokenFilePrivate(opts.tokenFile, token);
|
|
255
|
+
}
|
|
256
|
+
return { policy: next, token };
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Release exclusivity (`track journal release`): holder-only (requires current token), raises
|
|
261
|
+
* epoch and returns the journal to `open` mode.
|
|
262
|
+
*/
|
|
263
|
+
export function releaseExclusiveWriter(eventsPath, tokenInput = {}, opts = {}) {
|
|
264
|
+
const now = opts.now ?? new Date().toISOString();
|
|
265
|
+
return withFileLock(eventsPath, () => {
|
|
266
|
+
const current = readWritePolicy(eventsPath);
|
|
267
|
+
if (current.mode !== 'exclusive') {
|
|
268
|
+
throw new DomainError('journal release: journal is already in open mode');
|
|
269
|
+
}
|
|
270
|
+
assertWritePolicyAllows(eventsPath, tokenInput);
|
|
271
|
+
const epoch = current.epoch + 1;
|
|
272
|
+
const next = {
|
|
273
|
+
version: WRITE_POLICY_VERSION,
|
|
274
|
+
mode: 'open',
|
|
275
|
+
holder: null,
|
|
276
|
+
epoch,
|
|
277
|
+
tokenDigest: null,
|
|
278
|
+
updatedAt: now,
|
|
279
|
+
history: appendHistory(current.history, {
|
|
280
|
+
action: 'release',
|
|
281
|
+
holder: current.holder,
|
|
282
|
+
epoch,
|
|
283
|
+
at: now,
|
|
284
|
+
}),
|
|
285
|
+
};
|
|
286
|
+
writePolicyAtomically(writePolicyPathFor(eventsPath), next);
|
|
287
|
+
return next;
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
//# sourceMappingURL=write-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-policy.js","sourceRoot":"","sources":["../src/write-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EACL,wBAAwB,EACxB,aAAa,EACb,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAE7C,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAU,CAAA;AAC9C,MAAM,CAAC,MAAM,qBAAqB,GAAG,mBAAmB,CAAA;AACxD,MAAM,mBAAmB,GAAG,EAAE,CAAA;AAC9B,MAAM,iBAAiB,GAAG,EAAE,CAAA;AAC5B,MAAM,yBAAyB,GAAG,mBAAmB,CAAA;AAErD,SAAS,iBAAiB,CAAC,MAAc,EAAE,OAAe;IACxD,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,CAAA;IAC7B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,WAAW,CAAC,GAAG,OAAO,8BAA8B,CAAC,CAAA;IACjE,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,GAAG,iBAAiB,EAAE,CAAC;QACvC,MAAM,IAAI,WAAW,CAAC,GAAG,OAAO,8BAA8B,iBAAiB,aAAa,CAAC,CAAA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;QAC/B,MAAM,IAAI,GAAqB;YAC7B,OAAO,EAAE,oBAAoB;YAC7B,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,IAAI;YACZ,KAAK;YACL,WAAW,EAAE,IAAI;YACjB,SAAS,EAAE,GAAG;YACd,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,OAAO,EAAE;gBACtC,MAAM,EAAE,SAAS;gBACjB,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,KAAK;gBACL,EAAE,EAAE,GAAG;aACR,CAAC;SACH,CAAA;QACD,qBAAqB,CAAC,kBAAkB,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,CAAA;QAC3D,OAAO,IAAI,CAAA;IACb,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: present-decision
|
|
3
|
-
description: Present consequential human decisions with a readable dossier, or
|
|
3
|
+
description: Present consequential human decisions with a readable dossier, or decide and trace reversible choices. Covers irreversible, costly, security, contract, cross-owner and genuinely balanced choices; records the outcome in track. Agent-to-human, not h2a inter-agent negotiation.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Present Decision
|
|
@@ -14,15 +14,14 @@ Render it in small type in a thin band (at most 1.25rem), never a hero or a larg
|
|
|
14
14
|
|
|
15
15
|
## 1. Choose the right effort
|
|
16
16
|
|
|
17
|
-
Start with what changes for the owner
|
|
17
|
+
Start with what changes for the owner. Keep their intention central;
|
|
18
18
|
an agent's technical inconvenience alone does not justify a dossier.
|
|
19
19
|
|
|
20
|
-
- **Decide + trace:** local, readily reversible,
|
|
21
|
-
privacy, data-loss, frozen-contract or cross-owner impact
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
- **Dossier:** irreversible or costly rollback; public/frozen contract or data-schema change;
|
|
20
|
+
- **Decide + trace:** local, readily reversible, no hard trigger (no meaningful security,
|
|
21
|
+
privacy, data-loss, frozen-contract or cross-owner impact). When an owner preference is
|
|
22
|
+
missing, decide alone (or make the choice configurable), state the assumption within
|
|
23
|
+
existing authorization, and ask for option confirmation at the end of the task if needed.
|
|
24
|
+
- **Full dossier:** irreversible or costly rollback; public/frozen contract or data-schema change;
|
|
26
25
|
security, privacy, access control, migration or retention; cross-repo/owner/agent impact;
|
|
27
26
|
meaningful cost, schedule or scope impact; strong disagreement or balanced alternatives;
|
|
28
27
|
unknown validation criteria that could change the outcome; or explicit owner request.
|
|
@@ -40,12 +39,12 @@ Verify claims against sources. Do not edit other repos or global rules without a
|
|
|
40
39
|
Quote the **literal owner request**, with date/source. Map demands to questions, options or
|
|
41
40
|
acceptance criteria; flag departures. Use `assets/owner-criteria.template.md`.
|
|
42
41
|
|
|
43
|
-
Complex design
|
|
44
|
-
review
|
|
42
|
+
Complex design needs independent Codex + Opus reviews; surface disagreements. Without a
|
|
43
|
+
required review: **Incomplete**, reversible preparation only.
|
|
45
44
|
|
|
46
45
|
## 3. Write a short, self-contained question
|
|
47
46
|
|
|
48
|
-
Use `assets/dossier-template.md
|
|
47
|
+
Use `assets/dossier-template.md`; in plain words, include:
|
|
49
48
|
|
|
50
49
|
- the exact decision and boundary, the owner's expected benefit and risk;
|
|
51
50
|
- representative context: current behavior, a concrete problem/scenario, affected people,
|
|
@@ -56,7 +55,7 @@ Use `assets/dossier-template.md` for content. In plain words, include:
|
|
|
56
55
|
- the smallest answer needed and acceptance criteria tied to the owner's words.
|
|
57
56
|
|
|
58
57
|
Explain acronyms; replace opaque codes with meaningful names and source links. Distinguish
|
|
59
|
-
`[FACT]` (sourced) from `[JUDGMENT]`.
|
|
58
|
+
`[FACT]` (sourced) from `[JUDGMENT]`. Separate presenter convenience from
|
|
60
59
|
owner value; include a brief failure scenario, no mandatory long appendix.
|
|
61
60
|
|
|
62
61
|
## 4. Audit, present, record
|
|
@@ -64,16 +63,16 @@ owner value; include a brief failure scenario, no mandatory long appendix.
|
|
|
64
63
|
Owner gates: read `assets/owner-gates.md` first. Record their outcome only from the required session's answer.
|
|
65
64
|
|
|
66
65
|
Run `assets/self-audit.md`, fix failures and re-check before presenting.
|
|
67
|
-
If a
|
|
68
|
-
not approval
|
|
66
|
+
If a fact, criterion or review is missing, label **Incomplete** and ask for that input,
|
|
67
|
+
not approval.
|
|
69
68
|
|
|
70
|
-
**Default dossier output: portable Focus
|
|
71
|
-
|
|
69
|
+
**Default dossier output: a bound-surface Focus artifact or standalone portable Focus HTML, never a claude.ai artifact.**
|
|
70
|
+
Author the `DecisionDossierDocument` JSON (literal request, readable options, ecosystem diagram `source: "ecosystem:overview"`, `models`, `knowledge` or `interfaces`), validate it against the Focus gate, and deliver via the host's decision-dossier workflow.
|
|
72
71
|
|
|
73
|
-
Refusals block output verbatim. Deliver
|
|
74
|
-
Cards only prepare a local answer; they never record approval.
|
|
75
|
-
Before asking, read `assets/native-questions.md
|
|
76
|
-
dossier with a diagram. If unavailable, leave consequential decisions pending.
|
|
72
|
+
Refusals block output verbatim. Deliver the artifact URL or standalone HTML; check the real output at 390 and ~800 px in its shell — light/dark, cards, response line, pinch zoom, no sideways scroll. Diagrams: horizontal while readable, else column. Keep diagrams compact at natural size; split overflow instead of stretching. See `docs/focus/portable-dossiers.md`.
|
|
73
|
+
Cards and response lines only prepare a local answer; they never record approval.
|
|
74
|
+
Before asking, read `assets/native-questions.md` and use the native question tool after a decision
|
|
75
|
+
dossier with a diagram. If unavailable, leave consequential decisions pending.
|
|
77
76
|
|
|
78
77
|
Record when `.track/` exists or the owner approves tracking:
|
|
79
78
|
|
|
@@ -90,10 +89,10 @@ Record when `.track/` exists or the owner approves tracking:
|
|
|
90
89
|
negotiation evidence. Never fabricate `comprehension[]`: a chat reply is not a signed attestation.
|
|
91
90
|
Never record a bridge/relay principal as the human decider.
|
|
92
91
|
|
|
93
|
-
|
|
92
|
+
Agent-facing method; h2a negotiations remain inter-agent. Existing repo methods win.
|
|
94
93
|
## Embedded evidence (H1)
|
|
95
94
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
Use the version 2 embedded-evidence Focus schema: original bytes/digests,
|
|
96
|
+
citations, separate annexes. Keep material risks primary; disclose consultation
|
|
97
|
+
separately. Test offline search/download/back. DS in-canvas controls await
|
|
98
|
+
H2/H3. Never rewrite renderer/geometry.
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
# Decision <subject> — <decision object>
|
|
2
2
|
|
|
3
|
-
Default delivery: Focus
|
|
4
|
-
|
|
5
|
-
call MCP `h2a_focus_build` (`{ input, output }`) to produce `dossier.html`. Include a relevant ecosystem diagram
|
|
3
|
+
Default delivery: a Focus artifact on the bound surface or a standalone portable Focus HTML file, never a claude.ai artifact.
|
|
4
|
+
Author `dossier.json` from the Focus schema (v1 or v2 embedded evidence), replacing every example, validate against the Focus gate, and deliver through the host's decision-dossier workflow. Include a relevant ecosystem diagram
|
|
6
5
|
(`ecosystem:overview`, `ecosystem:models`, `ecosystem:knowledge`, `ecosystem:interfaces`).
|
|
7
6
|
Use the following as the content checklist for the document sections, not an alternative renderer.
|
|
8
7
|
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Missing evidence, criteria or review: **Incomplete**; request input, never final validation.
|
|
4
4
|
|
|
5
|
-
- [ ] **Title first:** subject and decision object in plain words;
|
|
6
|
-
one short line
|
|
5
|
+
- [ ] **Title first:** subject and decision object in plain words;
|
|
6
|
+
one short line. HTML `<title>` matches the visible title;
|
|
7
7
|
small type (≤1.25rem), thin band, no hero.
|
|
8
8
|
- [ ] **Owner interest:** owner benefit/risk and intention; no agent inconvenience or false problems.
|
|
9
9
|
- [ ] **Reading budget:** fits the stakes; question, context, 2–4 short options and
|
|
10
10
|
recommendation: 2 minutes, at most 400 words.
|
|
11
11
|
- [ ] **Self-contained:** representative scenario, current behavior, affected people and constraints
|
|
12
|
-
clear without links. Plain words; no opaque codes
|
|
12
|
+
clear without links. Plain words; no opaque codes.
|
|
13
13
|
- [ ] **No hidden decisions:** every implied choice explicit; no nested sub-options.
|
|
14
14
|
Questions stand alone; dependencies stated. Supporting evidence hides no choice or material risk.
|
|
15
15
|
- [ ] **Traceability:** dated/sourced literal owner request quoted; demands map to
|
|
@@ -17,12 +17,13 @@ Missing evidence, criteria or review: **Incomplete**; request input, never final
|
|
|
17
17
|
- [ ] **Options and recommendation:** one-line owner consequence, cost/rollback and strongest honest case per option.
|
|
18
18
|
Recommendation, strongest objection and overturning condition stated.
|
|
19
19
|
- [ ] **Evidence and bias:** decisive claims: `[FACT]` with sources or `[JUDGMENT]`;
|
|
20
|
-
assumptions/unknowns separate; failure scenario
|
|
21
|
-
- [ ] **Reviews:** independent Codex + Opus passes for complex design
|
|
22
|
-
- [ ] **Delivery/capture:**
|
|
23
|
-
ecosystem canvas, light/dark,
|
|
20
|
+
assumptions/unknowns separate; failure scenario.
|
|
21
|
+
- [ ] **Reviews:** independent Codex + Opus passes for complex design.
|
|
22
|
+
- [ ] **Delivery/capture:** Focus artifact or standalone portable Focus HTML (`dossier.json`),
|
|
23
|
+
ecosystem canvas, light/dark, response line, pinch zoom; no claude.ai artifact. Dossier with diagram before the native question tool;
|
|
24
24
|
never a bare text question. If unavailable, explain and leave the decision pending.
|
|
25
|
-
|
|
25
|
+
Open the real output at 390 and ~800 px in its shell: diagrams horizontal while readable, else column,
|
|
26
|
+
no sideways scroll, diagrams compact.
|
|
27
|
+
Local selections never record approval; no fabricated `comprehension[]` or relay as decider.
|
|
26
28
|
- [ ] **Evidence (H1):** original bytes/digests; resolved citations/backlinks; primary summaries,
|
|
27
|
-
separate annex consultation; offline search/download/back. H1 manifest only
|
|
28
|
-
DS in-canvas controls await H2/H3.
|
|
29
|
+
separate annex consultation; offline search/download/back. H1 manifest only.
|