axstack 0.65.0 → 0.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/README.md +2 -2
  2. package/docs/host-operations.md +6 -3
  3. package/package.json +1 -1
  4. package/skills/axstack/references/automations.md +8 -5
  5. package/skills/axstack/references/candidate-publication.md +7 -12
  6. package/skills/axstack/references/fleet-verification.md +3 -3
  7. package/skills/axstack/references/lifecycle.md +1 -1
  8. package/skills/axstack/references/pr-shape.md +8 -0
  9. package/skills/axstack/references/review-manager-prompt.md +16 -0
  10. package/skills/axstack/references/schedule-policy.json +123 -0
  11. package/skills/axstack/references/t3-runtime.md +5 -5
  12. package/skills/axstack/references/workspace-hygiene.md +9 -3
  13. package/skills/axstack/scripts/check-staged-file-tokens.js +1 -0
  14. package/skills/axstack/scripts/default-policy.js +1 -0
  15. package/skills/axstack/scripts/fleet-route-cli.js +2 -2
  16. package/skills/axstack/scripts/fleet-route-plan.js +2 -1
  17. package/skills/axstack/scripts/fleet-sample-io.js +1 -0
  18. package/skills/axstack/scripts/hub-usage.js +1 -1
  19. package/skills/axstack/scripts/pr-shape.js +161 -2
  20. package/skills/axstack/scripts/readiness-run.js +2 -0
  21. package/skills/axstack/scripts/readiness.js +10 -5
  22. package/skills/axstack/scripts/resolve-models.js +3 -1
  23. package/skills/axstack/scripts/schedule-drift.js +130 -0
  24. package/skills/axstack/scripts/scratch.js +201 -0
  25. package/skills/axstack/scripts/sync-default.js +1 -0
  26. package/skills/axstack/scripts/test-repository.js +1 -0
  27. package/skills/axstack/scripts/usage-split.js +286 -0
  28. package/skills/axstack-audit/SKILL.md +2 -0
  29. package/skills/axstack-review/references/review-receipt.md +1 -1
  30. package/skills/axstack-verify/SKILL.md +8 -1
  31. package/skills/voa/references/verification.md +5 -2
@@ -0,0 +1,286 @@
1
+ #!/usr/bin/env bun
2
+ import { Database } from 'bun:sqlite';
3
+ import { existsSync, writeFileSync } from 'node:fs';
4
+
5
+ const HELP = `usage-split — offline cost baseline (R2 fact mode)
6
+ bun usage-split.js --cache FILE --rates FILE --state FILE --prs FILE --start ISO --end ISO [--billed FILE] [--out FILE]
7
+ --cache FILE Saved usage-scan-cache JSON, version 11; models/sessions/files dictionaries.
8
+ Rows: [timestampMs, modelIndex, sessionIndex, input, cacheRead, cacheWrite, output, reasoning, requestId].
9
+ Reasoning is included in output, never added again. Interval is [start,end).
10
+ --rates FILE Saved model-rates JSON: {document:{exactModelName:{input_cost_per_token,
11
+ cache_read_input_token_cost, cache_creation_input_token_cost, output_cost_per_token}}}.
12
+ --state FILE Saved standalone statev2 SQLite (no WAL), or JSON array of provider-thread rows,
13
+ or {providers:[],threads:[],runs:[]}. Provider rows: thread_id and payload_json
14
+ with nativeThreadRef.nativeId; normalized {thread,native} also accepted.
15
+ Optional thread metadata: thread_id,title,lineage,prs (URLs or {url}); runs: thread_id,turns.
16
+ SQLite reads provider_threads, optional threads, and interval-filtered aggregate runs.
17
+ Without a runs export/table, turn and usage coverage remain unknown.
18
+ JSON payload_json metadata accepted.
19
+ Export titles/lineage/PR links for full role inference. Absent metadata stays unknown.
20
+ --prs FILE JSON array of ten {url,mergedAt,mergeCommit} identities (40-char SHA).
21
+ Merge dates must lie in the interval. Supplied identities are not verified online.
22
+ --start ISO Inclusive timestamp, with timezone.
23
+ --end ISO Exclusive timestamp, with timezone.
24
+ --billed FILE Optional {usd,start,end,evidence} for this exact interval; otherwise billed cost unknown.
25
+ --out FILE Exclusively create this report; existing files are refused. Default: stdout only.
26
+ --help Show flags, formats, effects and limitations.
27
+ Side effects: none by default. --out creates only the caller-named report (also printed to stdout).
28
+ No network, dispatch, subprocess, live cache refresh, database sidecar, scheduling or persistent state.
29
+ SQLite is deserialized read-only in memory; supply a saved export, not a live database.
30
+ Role precedence follows the token-split audit: explicit roles, delegated title, coordinator titles, root driver.
31
+ PR links are thread-level associations, not request-level proof; shared work is never divided.
32
+ Proxy: exact-name base API rates only, excluding subscription/tier/priority premiums; never a bill.
33
+ Exit: 0 measured (including failed terms), 1 invalid input/error, 2 incomplete (unknown terms).
34
+ `;
35
+ const fields = ['input', 'cacheRead', 'cacheWrite', 'output'];
36
+ const rateFields = ['input_cost_per_token', 'cache_read_input_token_cost', 'cache_creation_input_token_cost', 'output_cost_per_token'];
37
+ const validNumber = (n) => typeof n === 'number' && Number.isFinite(n) && n >= 0;
38
+ const validCount = (n) => Number.isSafeInteger(n) && n >= 0;
39
+ const sha256 = (bytes) => new Bun.CryptoHasher('sha256').update(bytes).digest('hex');
40
+ const add = (a, b) => a === null || b === null ? null : a + b;
41
+ const timestamp = (s) => typeof s === 'string' && /T.*(?:Z|[+-]\d\d:\d\d)$/.test(s) ? Date.parse(s) : NaN;
42
+
43
+ function decoded(s) {
44
+ for (let n = 0; n < 3; n++) {
45
+ try { const next = decodeURIComponent(s); if (next === s) break; s = next; } catch { break; }
46
+ }
47
+ return s;
48
+ }
49
+
50
+ // Order is intentional: identical to the audited measure.ts classifier.
51
+ function classify(t) {
52
+ const title = (t.title ?? '').toLowerCase(), id = decoded(t.thread_id).toLowerCase(), text = `${title} ${id}`;
53
+ const role = text.match(/axstack-(?:author|reviewer|review|verifier|verify|diligence|readiness|advisor|adviser|escalation|auditor|owner|research|explainer|explore|scout|judge|brainstorm)[a-z0-9-]*/)?.[0] ?? null;
54
+ const delegated = t.lineage?.relationshipToParent === 'subagent' || t.thread_id.startsWith('thread:delegated-task:');
55
+ const result = (cls, type) => ({ class: cls, type, role });
56
+ if (t.unmatched) return result('other', 'Unmapped transcripts');
57
+ if (/axstack-author\b/.test(role ?? '')) return result('authoring', 'Authors');
58
+ if (/axstack-owner\b/.test(role ?? '')) return result('orchestration overhead', 'PR owners');
59
+ if (/axstack-(verifier|verify|diligence|readiness)\b/.test(role ?? '') || /axstack-reviewer[^: ]*verif/.test(role ?? '')) return result('verification', 'Verification / diligence');
60
+ if (/axstack-review(?:er)?\b/.test(role ?? '') || /axstack-explainer-review\b/.test(role ?? '')) return result('review', 'Reviewers');
61
+ if (/axstack-(advisor|adviser|escalation)\b/.test(role ?? '')) return result('orchestration overhead', 'Advisers / escalation');
62
+ if (/axstack-auditor\b/.test(role ?? '')) return result('other', 'Audits');
63
+ if (/axstack-(research|explore|scout)\b/.test(role ?? '')) return result('other', 'Research / exploration');
64
+ if (/axstack-explainer\b/.test(role ?? '')) return result('other', 'Explainers');
65
+ if (/collector/.test(title)) return result('orchestration overhead', 'Fleet collectors');
66
+ if (/axstack review manager|review manager pass/.test(title)) return result('orchestration overhead', 'Review-manager passes');
67
+ if (delegated && /review-mgr.*owner/.test(id)) return result('orchestration overhead', 'PR owners');
68
+ if ((delegated && /\b(author|implement)\b/.test(title)) || /^(worker|author):/.test(title)) return result('authoring', 'Authors');
69
+ if (delegated && /\b(verif|uiv|readiness|pentest|test[- :]|diligence)/.test(`${title} ${id.split('delegate-task:').pop()}`)) return result('verification', 'Verification / diligence');
70
+ if ((delegated && /\b(review|rev[- :])/.test(title)) || /^reviewer:/.test(title)) return result('review', 'Reviewers');
71
+ if (delegated && /\b(adviser|advisor|escalation)\b/.test(title)) return result('orchestration overhead', 'Advisers / escalation');
72
+ if (/settle|settlement|close.?out|cleanup/.test(title)) return result('orchestration overhead', 'Settlement / cleanup');
73
+ if (/watch|babysit|monitor.*pr|run[- ]wake/.test(title)) return result('orchestration overhead', 'Watches / PR monitoring');
74
+ if (/review github and linear activity|^voa$|scheduled|schedule|periodic|status sweep|automation/.test(title)) return result('orchestration overhead', 'Schedules / status sweeps');
75
+ if (!t.title && !role) return result('other', 'Unknown metadata');
76
+ if (!role && !/^(researcher|subagent):/.test(title) && !delegated) return result('orchestration overhead', 'Drivers (mixed work)');
77
+ if (delegated && /research|scout/.test(title)) return result('other', 'Research / exploration');
78
+ return result('other', 'Other role / unresolved');
79
+ }
80
+
81
+ function readState(bytes, start, end) {
82
+ if (bytes.subarray(0, 16).toString() !== 'SQLite format 3\0') {
83
+ const saved = JSON.parse(bytes.toString());
84
+ return Array.isArray(saved) ? { providers: saved, threads: saved } : saved;
85
+ }
86
+ // Deserialization cannot create journals, WAL/SHM files or mutate the saved DB.
87
+ const db = Database.deserialize(bytes, { readonly: true });
88
+ try {
89
+ const table = (name) => db.query('SELECT name FROM sqlite_master WHERE type=\'table\' AND name=?').get(name);
90
+ return {
91
+ providers: db.query('SELECT thread_id,payload_json FROM orchestration_v2_projection_provider_threads').all(),
92
+ threads: table('orchestration_v2_projection_threads')
93
+ ? db.query('SELECT thread_id,title,payload_json FROM orchestration_v2_projection_threads').all() : [],
94
+ runs: table('orchestration_v2_projection_runs')
95
+ ? db.query('SELECT thread_id,count(*) AS turns FROM orchestration_v2_projection_runs WHERE requested_at>=? AND requested_at<? GROUP BY thread_id').all(start, end) : undefined,
96
+ };
97
+ } finally { db.close(); }
98
+ }
99
+
100
+ const payload = (row) => typeof row.payload_json === 'string' ? JSON.parse(row.payload_json) : row.payload_json ?? {};
101
+ const prUrl = (p) => typeof p === 'string' ? p : p?.url;
102
+ const meter = () => ({ input: 0, cacheRead: 0, cacheWrite: 0, output: 0, tokens: 0, observedTokens: 0,
103
+ records: 0, knownRateProxyUsd: 0, unpricedTokens: 0 });
104
+ function accumulate(target, source) {
105
+ for (const key of Object.keys(meter())) target[key] = add(target[key], source[key]);
106
+ }
107
+
108
+ function measure(cache, rates, state, prs, start, end, term) {
109
+ const threads = new Map();
110
+ for (const row of state.threads ?? []) {
111
+ const p = payload(row), id = row.thread_id ?? row.thread;
112
+ if (typeof id !== 'string') continue;
113
+ const prior = threads.get(id);
114
+ threads.set(id, { ...p, ...row, thread_id: id, lineage: row.lineage ?? p.lineage,
115
+ prs: row.prs ?? [p.linkedPullRequest, p.branchPullRequest, ...p.pullRequests ?? []].filter(Boolean),
116
+ turns: prior?.turns ?? (Array.isArray(state.runs) ? 0 : null), usage: prior?.usage ?? meter() });
117
+ }
118
+ const native = new Map();
119
+ for (const row of state.providers ?? []) {
120
+ const id = row.thread_id ?? row.thread, session = row.native ?? payload(row).nativeThreadRef?.nativeId;
121
+ if (typeof id !== 'string' || typeof session !== 'string') continue;
122
+ const ids = native.get(session) ?? new Set(); ids.add(id); native.set(session, ids);
123
+ if (!threads.has(id)) threads.set(id, { thread_id: id, turns: Array.isArray(state.runs) ? 0 : null, usage: meter(), prs: [] });
124
+ }
125
+ const invalidRows = [], unknownThreads = [];
126
+ for (const [index, run] of (state.runs ?? []).entries()) {
127
+ const id = run?.thread_id;
128
+ let t = threads.get(id);
129
+ if (!t) {
130
+ unknownThreads.push({ index, threadId: id ?? null });
131
+ if (typeof id !== 'string') continue;
132
+ t = { thread_id: id, turns: null, uncertainTurns: true, usage: meter(), prs: [] };
133
+ threads.set(id, t);
134
+ }
135
+ if (!validCount(run.turns)) {
136
+ invalidRows.push({ index, threadId: id, turns: run.turns ?? null });
137
+ t.turns = null; t.uncertainTurns = true;
138
+ } else t.turns = add(t.turns, run.turns);
139
+ }
140
+ const runsSupplied = Array.isArray(state.runs);
141
+ const runDataComplete = runsSupplied && !invalidRows.length && !unknownThreads.length;
142
+ term('run-counts', runDataComplete ? 'pass' : 'unknown',
143
+ { invalidRows, unknownThreads, note: 'Absent or invalid aggregate turns and unknown-thread turns remain null.' });
144
+ const totals = meter(), seen = new Set();
145
+ let duplicatesRemoved = 0, ambiguousRecords = 0, invalidRecords = 0, missingComponents = 0, unpricedRecords = 0, maxTs = null;
146
+ for (const v of Object.values(cache.files)) {
147
+ if (!Array.isArray(v?.r)) { invalidRecords++; continue; }
148
+ for (const row of v.r) {
149
+ if (!Array.isArray(row) || !validNumber(row[0])) { invalidRecords++; continue; }
150
+ if (row[0] < start || row[0] >= end) continue;
151
+ const session = cache.sessions[row[2]], model = cache.models[row[1]];
152
+ const key = JSON.stringify([v.p, session, row[8] || row[0], row[1], ...row.slice(3, 8)]);
153
+ if (seen.has(key)) { duplicatesRemoved++; continue; }
154
+ seen.add(key); maxTs = Math.max(maxTs ?? row[0], row[0]);
155
+ const ids = typeof session === 'string' ? native.get(session) : null;
156
+ if (ids?.size > 1) {
157
+ ambiguousRecords++;
158
+ for (const candidate of ids) threads.get(candidate).uncertainUsage = true;
159
+ }
160
+ const id = ids?.size === 1 ? [...ids][0] : `UNMAPPED:${v.p}:${session ?? key}`;
161
+ if (!threads.has(id)) threads.set(id, { thread_id: id, unmatched: true, turns: null, usage: meter(), prs: [] });
162
+ const usage = meter(), parts = fields.map((_, i) => validCount(row[i + 3]) ? row[i + 3] : null);
163
+ for (let i = 0; i < fields.length; i++) usage[fields[i]] = parts[i];
164
+ usage.tokens = parts.reduce(add, 0); usage.observedTokens = parts.reduce((n, x) => n + (x ?? 0), 0); usage.records = 1;
165
+ if (usage.tokens === null) missingComponents++;
166
+ const rate = rates.document?.[model];
167
+ const priced = usage.tokens !== null && rate && validNumber(rate.input_cost_per_token) && validNumber(rate.output_cost_per_token)
168
+ && parts.every((n, i) => n === 0 || validNumber(rate[rateFields[i]]));
169
+ if (priced) usage.knownRateProxyUsd = parts.reduce((sum, n, i) => sum + n * (rate[rateFields[i]] ?? 0), 0);
170
+ else { usage.unpricedTokens = usage.tokens; unpricedRecords++; }
171
+ accumulate(totals, usage); accumulate(threads.get(id).usage, usage);
172
+ }
173
+ }
174
+ const classes = new Map(), roleMapping = [], shared = [], unattributed = [], exclusive = new Map(), perPrShared = new Map();
175
+ const attribution = { exclusiveTokens: 0, sharedTokens: 0, unattributedTokens: 0, unmatchedTokens: 0, observedUnattributedTokens: 0 };
176
+ let missingUsageThreads = 0, unknownMetadata = 0;
177
+ for (const t of threads.values()) {
178
+ if (!t.turns && !t.usage.records && !t.uncertainUsage && !t.uncertainTurns) continue;
179
+ const role = classify(t), missing = !t.usage.records;
180
+ const row = { threadId: t.thread_id, ...role, tokens: missing || t.uncertainUsage ? null : t.usage.tokens,
181
+ observedTokens: t.usage.observedTokens, turns: t.turns, records: t.usage.records };
182
+ roleMapping.push(row);
183
+ if (missing) missingUsageThreads++;
184
+ if (role.type === 'Unknown metadata') unknownMetadata++;
185
+ const cls = classes.get(role.class) ?? { class: role.class, ...meter(), threads: 0, turns: 0, unmatchedSessions: 0, missingUsageThreads: 0 };
186
+ cls.threads += t.unmatched ? 0 : 1; cls.unmatchedSessions += t.unmatched ? 1 : 0;
187
+ if (!t.unmatched) cls.turns = add(cls.turns, t.turns);
188
+ cls.missingUsageThreads += missing ? 1 : 0;
189
+ accumulate(cls, t.usage); classes.set(role.class, cls);
190
+ const links = [...new Set((t.prs ?? []).map(prUrl).filter(Boolean))];
191
+ if (t.unmatched) attribution.unmatchedTokens = add(attribution.unmatchedTokens, row.tokens);
192
+ if (links.length > 1) {
193
+ shared.push({ ...row, prs: links }); attribution.sharedTokens = add(attribution.sharedTokens, row.tokens);
194
+ for (const link of links) perPrShared.set(link, add(perPrShared.has(link) ? perPrShared.get(link) : 0, row.tokens));
195
+ } else if (links.length === 1 && prs.some((p) => p.url === links[0])) {
196
+ exclusive.set(links[0], add(exclusive.has(links[0]) ? exclusive.get(links[0]) : 0, row.tokens));
197
+ attribution.exclusiveTokens = add(attribution.exclusiveTokens, row.tokens);
198
+ } else {
199
+ unattributed.push({ ...row, prs: links }); attribution.unattributedTokens = add(attribution.unattributedTokens, row.tokens);
200
+ attribution.observedUnattributedTokens += row.observedTokens;
201
+ }
202
+ }
203
+ term('token-components', missingComponents || invalidRecords ? 'unknown' : 'pass', { missingComponents, invalidRecords, formula: fields.join(' + '), reasoningIncludedInOutput: true });
204
+ term('native-join', ambiguousRecords ? 'unknown' : 'pass', { ambiguousRecords, unmatchedTokens: attribution.unmatchedTokens });
205
+ term('usage-coverage', !runDataComplete || missingUsageThreads ? 'unknown' : 'pass', { runsSupplied, missingUsageThreads, note: 'Class tokens count observed cache records only; missing-thread tokens remain null.' });
206
+ term('role-mapping', unknownMetadata ? 'unknown' : 'pass', { unknownMetadata, method: 'audit role precedence; inferred roles; root drivers contain mixed work' });
207
+ term('rates', unpricedRecords ? 'unknown' : 'pass', { unpricedRecords, unpricedTokens: totals.unpricedTokens, method: 'exact model name, base per-token rates; premiums unknown' });
208
+ term('attribution', unattributed.length || shared.length ? 'unknown' : 'pass', { ...attribution, note: 'Thread associations only; shared work is reported without allocation.' });
209
+ const prReports = prs.map((pr, i) => {
210
+ const hasData = exclusive.has(pr.url) || perPrShared.has(pr.url), empty = runDataComplete && !totals.records && !missingUsageThreads;
211
+ const ex = hasData || empty ? exclusive.has(pr.url) ? exclusive.get(pr.url) : 0 : null;
212
+ const sh = hasData || empty ? perPrShared.has(pr.url) ? perPrShared.get(pr.url) : 0 : null;
213
+ const observed = add(ex, sh), fraction = observed ? ex / observed : null;
214
+ term(`pr:${i + 1}`, !runDataComplete ? 'unknown' : empty ? 'n/a' : !hasData || observed === null ? 'unknown' : 'pass', { url: pr.url, exclusiveTokens: ex, sharedTokens: sh, exclusiveFraction: fraction, denominator: 'only observed tokens linked to this PR; total real PR cost unknown' });
215
+ return { ...pr, exclusiveTokens: ex, sharedTokens: sh, observedTokens: observed, exclusiveFraction: fraction };
216
+ });
217
+ return { totals, classes: [...classes.values()].sort((a, b) => b.observedTokens - a.observedTokens), roleMapping,
218
+ shared, unattributed, attribution, prs: prReports, duplicatesRemoved, ambiguousRecords,
219
+ maxUsageTimestamp: maxTs === null ? null : new Date(maxTs).toISOString() };
220
+ }
221
+
222
+ async function main(argv) {
223
+ if (argv.includes('--help')) {
224
+ if (argv.length !== 1) throw Error('Use --help alone');
225
+ console.log(HELP); return 0;
226
+ }
227
+ const flags = {}, allowed = ['cache', 'rates', 'state', 'prs', 'start', 'end', 'billed', 'out'];
228
+ for (let i = 0; i < argv.length; i += 2) {
229
+ const key = argv[i].slice(2), value = argv[i + 1];
230
+ if (!argv[i].startsWith('--') || !allowed.includes(key) || !value || value.startsWith('--')) throw Error(`Invalid flag/value: ${argv[i]}`);
231
+ if (Object.hasOwn(flags, key)) throw Error(`Repeated flag: --${key}`);
232
+ flags[key] = value;
233
+ }
234
+ for (const key of allowed.slice(0, 6)) if (!flags[key]) throw Error(`Required --${key}; see --help`);
235
+ const start = timestamp(flags.start), end = timestamp(flags.end);
236
+ if (!Number.isFinite(start) || !Number.isFinite(end) || start >= end) throw Error('Require valid --start < --end with timezone');
237
+ const interval = { start: new Date(start).toISOString(), end: new Date(end).toISOString(), endExclusive: true };
238
+ const terms = [], inputs = {}, data = {};
239
+ const term = (id, status, evidence) => terms.push({ id, status, evidence: [evidence] });
240
+ for (const key of ['cache', 'rates', 'state', 'prs', 'billed']) {
241
+ if (!flags[key]) continue;
242
+ try {
243
+ if (key === 'state' && (existsSync(`${flags[key]}-wal`) || existsSync(`${flags[key]}-shm`))) {
244
+ term('input:state', 'unknown', 'Require standalone saved SQLite, without WAL/SHM sidecars'); continue;
245
+ }
246
+ const bytes = Buffer.from(await Bun.file(flags[key]).arrayBuffer());
247
+ inputs[key] = { path: flags[key], bytes: bytes.length, sha256: sha256(bytes) };
248
+ data[key] = key === 'state' ? readState(bytes, interval.start, interval.end) : JSON.parse(bytes.toString());
249
+ term(`input:${key}`, 'pass', inputs[key]);
250
+ } catch (error) {
251
+ if (['ENOENT', 'EACCES', 'EPERM', 'EBUSY'].includes(error.code)) term(`input:${key}`, 'unknown', { path: flags[key], error: error.code });
252
+ else throw error;
253
+ }
254
+ }
255
+ const snapshot = { inputs, sha256: sha256(JSON.stringify({ interval, inputs: Object.entries(inputs).map(([k, v]) => [k, v.sha256]) })) };
256
+ const report = { interval, snapshot, terms, billedCost: null };
257
+ if (['cache', 'rates', 'state', 'prs'].every((key) => Object.hasOwn(data, key))) {
258
+ if (!Array.isArray(data.prs)) throw Error('--prs must contain an array');
259
+ const identities = data.prs.every((p) => p && /^https:\/\/github\.com\/[^/]+\/[^/]+\/pull\/\d+$/.test(p.url)
260
+ && /^[a-f0-9]{40}$/i.test(p.mergeCommit) && timestamp(p.mergedAt) >= start && timestamp(p.mergedAt) < end);
261
+ term('merged-prs', data.prs.length === 10 && new Set(data.prs.map((p) => p?.url)).size === 10 && identities ? 'pass' : 'fail',
262
+ { identities: data.prs, source: 'caller-supplied merged PR snapshot; no online verification' });
263
+ const supported = data.cache?.version === 11 && Array.isArray(data.cache.models) && Array.isArray(data.cache.sessions)
264
+ && data.cache.files && typeof data.cache.files === 'object' && !Array.isArray(data.cache.files);
265
+ const stateSupported = Array.isArray(data.state?.providers) && ['threads', 'runs'].every((key) =>
266
+ data.state[key] === undefined || Array.isArray(data.state[key]));
267
+ const ratesSupported = data.rates?.document && typeof data.rates.document === 'object' && !Array.isArray(data.rates.document);
268
+ term('cache-format', supported ? 'pass' : 'unknown', { version: data.cache?.version ?? null, supportedVersions: [11] });
269
+ term('state-format', stateSupported ? 'pass' : 'unknown', 'Require exported provider rows with optional thread metadata and aggregate turns');
270
+ term('rates-format', ratesSupported ? 'pass' : 'unknown', 'Require a saved model-rates document keyed by exact model name');
271
+ if (supported && stateSupported && ratesSupported) Object.assign(report,
272
+ measure(data.cache, data.rates, data.state, data.prs.filter(Boolean), start, end, term));
273
+ }
274
+ if (data.billed && validNumber(data.billed.usd) && timestamp(data.billed.start) === start
275
+ && timestamp(data.billed.end) === end && typeof data.billed.evidence === 'string' && data.billed.evidence.trim()) {
276
+ report.billedCost = data.billed; term('billed-cost', 'pass', data.billed);
277
+ } else term('billed-cost', 'unknown', 'No matching interval statement supplied; list-price proxy is not billed spend');
278
+ report.summary = Object.fromEntries(['pass', 'fail', 'unknown', 'n/a'].map((status) => [status, terms.filter((t) => t.status === status).length]));
279
+ const output = `${JSON.stringify(report, null, 2)}\n`;
280
+ if (flags.out) writeFileSync(flags.out, output, { flag: 'wx', mode: 0o600 });
281
+ process.stdout.write(output);
282
+ return report.summary.unknown ? 2 : 0;
283
+ }
284
+
285
+ try { process.exitCode = await main(process.argv.slice(2)); }
286
+ catch (error) { console.error(`usage-split: ${error.message}`); process.exitCode = 1; }
@@ -221,6 +221,8 @@ record. Material already covered with the same scope and meaning yields an
221
221
  explicit already-covered no-op with pointers to the covering instructions when
222
222
  no recurrence is recorded.
223
223
 
224
+ For recurring mechanical classes, learning candidates propose a code, structure or check fix before an instruction change.
225
+
224
226
  If a covered rule recurs, never classify it as an already-covered no-op.
225
227
  Record that recurrence as recurred.
226
228
  Suggest `axstack-correct` for the recurrence.
@@ -3,7 +3,7 @@
3
3
  ```text
4
4
  Mode: <peer | authored>
5
5
  Reviewer: <reviewer role + provider/model/effort receipt> session <id> rev <candidate sha> base <current base>
6
- Workspace: <T3 taskId/childThreadId/runId + authored: native worktree absolute path | peer: detached checkout absolute path>
6
+ Workspace: <authored: native worktree absolute path | peer: detached checkout absolute path>
7
7
  Evidence: <run dir>/evidence/<dispatch>/ (report and probe paths)
8
8
  Verdict: <APPROVE | REQUEST_CHANGES | INCOMPLETE>
9
9
  Scope: <PASS | FINDINGS | UNKNOWN | n/a — separate diligence>
@@ -78,7 +78,14 @@ Test helper logic red/green before implementation.
78
78
 
79
79
  ### Isolate every attempt
80
80
 
81
- Launch with an owned 0700 TMPDIR outside HOME for data, home and port bookkeeping.
81
+ Use [scratch.js](../axstack/scripts/scratch.js) for command scratch; consult
82
+ `--help` and the [workspace recipe](../axstack/references/workspace-hygiene.md#safe-deletion)
83
+ for explicit repository selection and child exit checks.
84
+ Launch must allocate an owned 0700 directory outside HOME for data, home and port bookkeeping.
85
+ Keep the same directory from Launch through Doctor and Drive.
86
+ Allocate it once with `scratch.js run -- true`, save its JSON outside scratch,
87
+ and reuse the printed root for Launch state, creating the fixture home inside it.
88
+ Per-command scratch roots do not replace this persistent state root.
82
89
  Listen on loopback only.
83
90
  Never use production secrets.
84
91
  Keep evidence in the private evidence folder after cleanup.
@@ -1,8 +1,11 @@
1
1
  # Local verification and live boundary
2
2
 
3
3
  In an Axstack source checkout, use the repository `verify-axstack` Launch and
4
- Doctor with an owned 0700 TMPDIR outside HOME, an isolated fixture HOME and
5
- offline network namespace. Run these actual interfaces:
4
+ Doctor with [scratch.js](../../axstack/scripts/scratch.js) command scratch,
5
+ an isolated fixture HOME and offline network namespace. Consult the helper's
6
+ `--help` for effects and the [repository command recipe](../../axstack/references/workspace-hygiene.md#safe-deletion)
7
+ for explicit repository selection and child exit checks. Run these actual interfaces
8
+ from the source checkout (or use `bun --cwd=<repo>` when wrapping them):
6
9
 
7
10
  ```bash
8
11
  bun run test tests/workflows/voa-install.test.js \