instar 1.3.195 → 1.3.197
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/commands/server.d.ts.map +1 -1
- package/dist/commands/server.js +12 -1
- package/dist/commands/server.js.map +1 -1
- package/dist/core/AgentRegistry.d.ts +15 -0
- package/dist/core/AgentRegistry.d.ts.map +1 -1
- package/dist/core/AgentRegistry.js +26 -2
- package/dist/core/AgentRegistry.js.map +1 -1
- package/dist/core/MultiMachineCoordinator.d.ts.map +1 -1
- package/dist/core/MultiMachineCoordinator.js +16 -2
- package/dist/core/MultiMachineCoordinator.js.map +1 -1
- package/dist/core/uncaughtExceptionPolicy.d.ts.map +1 -1
- package/dist/core/uncaughtExceptionPolicy.js +11 -0
- package/dist/core/uncaughtExceptionPolicy.js.map +1 -1
- package/package.json +1 -1
- package/scripts/check-spec-review-link.mjs +63 -0
- package/scripts/validate-retro-harvest.mjs +272 -0
- package/src/data/builtin-manifest.json +4 -4
- package/src/templates/scripts/convergence-check.sh +20 -0
- package/upgrades/1.3.196.md +27 -0
- package/upgrades/1.3.197.md +24 -0
- package/upgrades/side-effects/APPRENTICESHIP-STEP0-RETRO-HARVEST-SPEC.md +78 -0
- package/upgrades/side-effects/fix-activepull-solo-demotion.md +75 -0
- package/upgrades/side-effects/fix-fetch-blocked-ports.md +74 -0
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* validate-retro-harvest.mjs — the schema validator for Apprenticeship Step 0
|
|
4
|
+
* retro-harvest artifacts (`apprenticeship-retro-harvest/v1`).
|
|
5
|
+
*
|
|
6
|
+
* Per APPRENTICESHIP-STEP0-RETRO-HARVEST-SPEC.md §9, this is the structural
|
|
7
|
+
* SIGNAL — not the authority. It checks the artifact's SHAPE deterministically;
|
|
8
|
+
* the LLM fidelity review (recorded in frontmatter) is the AUTHORITY for whether
|
|
9
|
+
* the harvest is faithful. (Signal vs Authority / The Body and the Mind.)
|
|
10
|
+
*
|
|
11
|
+
* Two layers:
|
|
12
|
+
* - validateRetroHarvest(text, opts) — PURE, offline, unit-tested. Structure,
|
|
13
|
+
* reconciliation, redaction backstop, path safety, completeness, scope rules.
|
|
14
|
+
* - checkLiveLedger(frontmatter, fetchImpl) — OPTIONAL live cross-check that
|
|
15
|
+
* seeded ids resolve in the running ledger. Network; run by the integration
|
|
16
|
+
* test / `--check-live`, never by the pure unit path.
|
|
17
|
+
*
|
|
18
|
+
* CLI: node scripts/validate-retro-harvest.mjs <artifact.md> [--prior] [--check-live]
|
|
19
|
+
* exit 0 = valid, exit 1 = invalid (errors to stderr).
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { readFileSync } from 'node:fs';
|
|
23
|
+
import { fileURLToPath } from 'node:url';
|
|
24
|
+
import path from 'node:path';
|
|
25
|
+
import yaml from 'js-yaml';
|
|
26
|
+
|
|
27
|
+
export const SCHEMA_ID = 'apprenticeship-retro-harvest/v1';
|
|
28
|
+
export const INSTANCE_TYPES = ['mentorship', 'apprenticeship'];
|
|
29
|
+
export const SCOPE_MODES = ['full', 'incremental'];
|
|
30
|
+
export const COMPLETENESS = ['complete', 'partial-accepted'];
|
|
31
|
+
export const FIDELITY_VERDICTS = ['faithful', 'partial', 'rejected'];
|
|
32
|
+
export const HARVEST_DIR = 'docs/apprenticeship/retro-harvests';
|
|
33
|
+
|
|
34
|
+
/** Scrubbers Step 0 trusts. A missing/unknown/failed scrub refuses the artifact (§7). */
|
|
35
|
+
export const APPROVED_SCRUBBERS = ['correction-scrub', 'instar-pii-scrub'];
|
|
36
|
+
|
|
37
|
+
/** Evidence-pointer URI schemes (§6). */
|
|
38
|
+
export const POINTER_PATTERNS = {
|
|
39
|
+
ledger: /^ledger:[0-9a-f-]{6,}$/i, // validator-resolvable
|
|
40
|
+
pr: /^pr:\d+$/, // validator-resolvable
|
|
41
|
+
thread: /^thread:\d+#[\w.-]+$/, // immutable msg locator; fidelity-review-only
|
|
42
|
+
memory: /^memory:[a-z0-9_-]+@[0-9a-f]{6,}#[\w.-]+$/i, // slug@hash#anchor; fidelity-review-only
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/** Secret-shaped strings the backstop rejects (§7). A LIMITED backstop, not a scrub. */
|
|
46
|
+
const SECRET_PATTERNS = [
|
|
47
|
+
{ name: 'bearer-token', re: /\bBearer\s+[A-Za-z0-9._-]{8,}/ },
|
|
48
|
+
{ name: 'tunnel-sig', re: /[?&]sig=[0-9a-f]{16,}/i },
|
|
49
|
+
{ name: 'long-hex-blob', re: /\b[0-9a-f]{40,}\b/i },
|
|
50
|
+
{ name: 'long-base64-blob', re: /\b[A-Za-z0-9+/]{50,}={0,2}\b/ },
|
|
51
|
+
{ name: 'email', re: /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/ },
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Split a markdown doc into { frontmatter (parsed), body (string) }.
|
|
56
|
+
* Throws if there is no `---`-delimited YAML frontmatter.
|
|
57
|
+
*/
|
|
58
|
+
export function parseArtifact(text) {
|
|
59
|
+
const m = /^---\n([\s\S]*?)\n---\n?([\s\S]*)$/.exec(text);
|
|
60
|
+
if (!m) throw new Error('no YAML frontmatter (--- … ---) found');
|
|
61
|
+
const frontmatter = yaml.load(m[1]) || {};
|
|
62
|
+
return { frontmatter, body: m[2] || '' };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Count top-level `- ` bullet items directly under a `## <heading>` section. */
|
|
66
|
+
export function countSectionItems(body, heading) {
|
|
67
|
+
const lines = body.split('\n');
|
|
68
|
+
let inSection = false;
|
|
69
|
+
let count = 0;
|
|
70
|
+
const headingRe = new RegExp('^##\\s+' + heading.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'i');
|
|
71
|
+
for (const line of lines) {
|
|
72
|
+
if (/^##\s+/.test(line)) inSection = headingRe.test(line);
|
|
73
|
+
else if (inSection && /^-\s+\S/.test(line)) count++;
|
|
74
|
+
}
|
|
75
|
+
return count;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** True when the body contains a secret-shaped string (returns the matched pattern name or null). */
|
|
79
|
+
export function findSecret(body) {
|
|
80
|
+
for (const { name, re } of SECRET_PATTERNS) {
|
|
81
|
+
if (re.test(body)) return name;
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Resolve + confine an artifact path to HARVEST_DIR. Returns the safe relative
|
|
88
|
+
* path or throws on traversal / bad component (§6 security).
|
|
89
|
+
*/
|
|
90
|
+
export function safeArtifactPath(from, to, instanceType) {
|
|
91
|
+
for (const [k, v] of Object.entries({ from, to, instanceType })) {
|
|
92
|
+
if (typeof v !== 'string' || !/^[a-z0-9-]+$/.test(v)) {
|
|
93
|
+
throw new Error(`unsafe path component ${k}="${v}" (must match ^[a-z0-9-]+$)`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const rel = `${HARVEST_DIR}/${from}-to-${to}-${instanceType}.md`;
|
|
97
|
+
const resolved = path.normalize(rel);
|
|
98
|
+
if (resolved.includes('..') || !resolved.startsWith(HARVEST_DIR + path.sep) && !resolved.startsWith(HARVEST_DIR + '/')) {
|
|
99
|
+
throw new Error(`path escapes ${HARVEST_DIR}: ${resolved}`);
|
|
100
|
+
}
|
|
101
|
+
return rel;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* PURE structural validation of a retro-harvest artifact.
|
|
106
|
+
* @param {string} text - full artifact markdown
|
|
107
|
+
* @param {{ priorHarvestExists?: boolean }} [opts]
|
|
108
|
+
* @returns {{ valid: boolean, errors: string[] }}
|
|
109
|
+
*/
|
|
110
|
+
export function validateRetroHarvest(text, opts = {}) {
|
|
111
|
+
const errors = [];
|
|
112
|
+
const priorHarvestExists = !!opts.priorHarvestExists;
|
|
113
|
+
|
|
114
|
+
let parsed;
|
|
115
|
+
try {
|
|
116
|
+
parsed = parseArtifact(text);
|
|
117
|
+
} catch (e) {
|
|
118
|
+
return { valid: false, errors: [`parse: ${e.message}`] };
|
|
119
|
+
}
|
|
120
|
+
const { frontmatter: fm, body } = parsed;
|
|
121
|
+
|
|
122
|
+
// --- schema id
|
|
123
|
+
if (fm.schema !== SCHEMA_ID) errors.push(`schema must be "${SCHEMA_ID}" (got "${fm.schema}")`);
|
|
124
|
+
|
|
125
|
+
// --- required scalar fields
|
|
126
|
+
for (const f of ['instanceType', 'from', 'to', 'framework', 'harvestedAt', 'scopeMode', 'completeness']) {
|
|
127
|
+
if (fm[f] == null || fm[f] === '') errors.push(`missing required field: ${f}`);
|
|
128
|
+
}
|
|
129
|
+
if (fm.instanceType && !INSTANCE_TYPES.includes(fm.instanceType))
|
|
130
|
+
errors.push(`instanceType must be one of ${INSTANCE_TYPES.join('|')}`);
|
|
131
|
+
if (fm.scopeMode && !SCOPE_MODES.includes(fm.scopeMode))
|
|
132
|
+
errors.push(`scopeMode must be one of ${SCOPE_MODES.join('|')}`);
|
|
133
|
+
if (fm.completeness && !COMPLETENESS.includes(fm.completeness))
|
|
134
|
+
errors.push(`completeness must be one of ${COMPLETENESS.join('|')}`);
|
|
135
|
+
|
|
136
|
+
// --- path safety on the identity components
|
|
137
|
+
if (fm.from && fm.to && fm.instanceType) {
|
|
138
|
+
try { safeArtifactPath(fm.from, fm.to, fm.instanceType); }
|
|
139
|
+
catch (e) { errors.push(`path: ${e.message}`); }
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// --- scope rule: first harvest (no prior baseline) MUST be full (§8)
|
|
143
|
+
if (fm.scopeMode === 'incremental' && !priorHarvestExists)
|
|
144
|
+
errors.push('scopeMode "incremental" requires a prior harvest baseline; the first harvest must be "full"');
|
|
145
|
+
|
|
146
|
+
// --- sourcesCovered: coverage EXTENT, not bare booleans (§8)
|
|
147
|
+
const sc = fm.sourcesCovered;
|
|
148
|
+
if (!sc || typeof sc !== 'object') {
|
|
149
|
+
errors.push('missing sourcesCovered');
|
|
150
|
+
} else {
|
|
151
|
+
if (!sc.ledger || typeof sc.ledger.issueCount !== 'number')
|
|
152
|
+
errors.push('sourcesCovered.ledger must carry { read, issueCount }');
|
|
153
|
+
if (!sc.playbook || typeof sc.playbook.entryCount !== 'number')
|
|
154
|
+
errors.push('sourcesCovered.playbook must carry { read, entryCount }');
|
|
155
|
+
if (!Array.isArray(sc.threads))
|
|
156
|
+
errors.push('sourcesCovered.threads must be an array of { id, messagesRead, truncated }');
|
|
157
|
+
else for (const t of sc.threads) {
|
|
158
|
+
if (typeof t.messagesRead !== 'number' || typeof t.truncated !== 'boolean')
|
|
159
|
+
errors.push(`sourcesCovered.threads[${t && t.id}] needs numeric messagesRead + boolean truncated (coverage extent, not presence)`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// --- completeness vs truncation (§8): complete ⇒ nothing truncated
|
|
164
|
+
if (fm.completeness === 'complete' && sc && Array.isArray(sc.threads)) {
|
|
165
|
+
if (sc.threads.some((t) => t.truncated === true))
|
|
166
|
+
errors.push('completeness "complete" is invalid when a source is truncated; use "partial-accepted" with named gaps');
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// --- counts reconcile with body (§9)
|
|
170
|
+
const counts = fm.counts || {};
|
|
171
|
+
const bodyLessons = countSectionItems(body, 'Lessons');
|
|
172
|
+
const bodyMeta = countSectionItems(body, 'Meta-lessons');
|
|
173
|
+
const bodyProc = countSectionItems(body, 'Process-insights');
|
|
174
|
+
const bodyNeeds = countSectionItems(body, 'What the program needs');
|
|
175
|
+
if (counts.lessons !== bodyLessons)
|
|
176
|
+
errors.push(`counts.lessons=${counts.lessons} but body has ${bodyLessons} "## Lessons" items`);
|
|
177
|
+
if (counts.metaLessons !== bodyMeta)
|
|
178
|
+
errors.push(`counts.metaLessons=${counts.metaLessons} but body has ${bodyMeta} "## Meta-lessons" items`);
|
|
179
|
+
if (counts.processInsights !== bodyProc)
|
|
180
|
+
errors.push(`counts.processInsights=${counts.processInsights} but body has ${bodyProc} "## Process-insights" items`);
|
|
181
|
+
if (fm.programNeeds !== bodyNeeds)
|
|
182
|
+
errors.push(`programNeeds=${fm.programNeeds} but body has ${bodyNeeds} "## What the program needs" items`);
|
|
183
|
+
|
|
184
|
+
// --- redaction: approved scrubber, not failed (§7)
|
|
185
|
+
const r = fm.redaction;
|
|
186
|
+
if (!r || typeof r !== 'object') {
|
|
187
|
+
errors.push('missing redaction { scrubber, findingsRemoved, scrubbedAt }');
|
|
188
|
+
} else {
|
|
189
|
+
const scrubberName = String(r.scrubber || '').split('@')[0];
|
|
190
|
+
if (!APPROVED_SCRUBBERS.includes(scrubberName))
|
|
191
|
+
errors.push(`redaction.scrubber "${r.scrubber}" not in approved list (${APPROVED_SCRUBBERS.join(', ')})`);
|
|
192
|
+
if (r.status === 'failed') errors.push('redaction.status is "failed" — scrub must succeed before write');
|
|
193
|
+
if (typeof r.findingsRemoved !== 'number') errors.push('redaction.findingsRemoved must be a number');
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// --- fidelity review: the authority's stamp (§9)
|
|
197
|
+
const fr = fm.fidelityReview;
|
|
198
|
+
if (!fr || typeof fr !== 'object') {
|
|
199
|
+
errors.push('missing fidelityReview { reviewer, verdict, at }');
|
|
200
|
+
} else {
|
|
201
|
+
if (!FIDELITY_VERDICTS.includes(fr.verdict))
|
|
202
|
+
errors.push(`fidelityReview.verdict must be one of ${FIDELITY_VERDICTS.join('|')}`);
|
|
203
|
+
if (fr.verdict === 'rejected') errors.push('fidelityReview.verdict is "rejected" — harvest is not faithful');
|
|
204
|
+
if (fr.verdict === 'partial' && !fr.gaps && !(fr.audit && fr.audit.gaps))
|
|
205
|
+
errors.push('fidelityReview "partial" must name the gaps (fidelityReview.gaps)');
|
|
206
|
+
if (!fr.reviewer) errors.push('fidelityReview.reviewer required (must be independent of the harvesting pass)');
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// --- evidence pointers well-formed (§6). Strip trailing sentence punctuation
|
|
210
|
+
// so a pointer at a clause boundary ("ledger:abc123, priority…") still validates.
|
|
211
|
+
const pointerTokens = (body.match(/\b(?:ledger|pr|thread|memory):[^\s)\]]+/g) || [])
|
|
212
|
+
.map((t) => t.replace(/[.,;:]+$/, ''));
|
|
213
|
+
for (const tok of pointerTokens) {
|
|
214
|
+
const scheme = tok.split(':')[0];
|
|
215
|
+
const re = POINTER_PATTERNS[scheme];
|
|
216
|
+
if (re && !re.test(tok)) errors.push(`malformed evidence pointer: ${tok}`);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// --- secret backstop (§7)
|
|
220
|
+
const secret = findSecret(body);
|
|
221
|
+
if (secret) errors.push(`secret-shaped string in body (${secret}) — pointers-not-payloads (§7)`);
|
|
222
|
+
|
|
223
|
+
return { valid: errors.length === 0, errors };
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* OPTIONAL live cross-check: every seededToPlaybook id resolves at candidate+ in
|
|
228
|
+
* the running ledger. Network — never part of the pure unit path. Inject fetch.
|
|
229
|
+
* @returns {Promise<{ ok: boolean, errors: string[] }>}
|
|
230
|
+
*/
|
|
231
|
+
export async function checkLiveLedger(frontmatter, fetchImpl) {
|
|
232
|
+
const errors = [];
|
|
233
|
+
const seeded = Array.isArray(frontmatter.seededToPlaybook) ? frontmatter.seededToPlaybook : [];
|
|
234
|
+
for (const s of seeded) {
|
|
235
|
+
const id = s && s.id;
|
|
236
|
+
if (!id) { errors.push('seededToPlaybook entry without id'); continue; }
|
|
237
|
+
try {
|
|
238
|
+
const res = await fetchImpl(id);
|
|
239
|
+
if (!res || !res.found) errors.push(`seeded id ${id} not found in live ledger`);
|
|
240
|
+
else if (!['candidate', 'extracted'].includes(res.playbookStatus))
|
|
241
|
+
errors.push(`seeded id ${id} is "${res.playbookStatus}", expected candidate+`);
|
|
242
|
+
} catch (e) {
|
|
243
|
+
errors.push(`live check for ${id} failed: ${e.message}`);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return { ok: errors.length === 0, errors };
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// --- CLI entry (guarded so importing for tests is side-effect-free)
|
|
250
|
+
const isMain = (() => {
|
|
251
|
+
try { return process.argv[1] && fileURLToPath(import.meta.url) === path.resolve(process.argv[1]); }
|
|
252
|
+
catch { return false; }
|
|
253
|
+
})();
|
|
254
|
+
|
|
255
|
+
if (isMain) {
|
|
256
|
+
const args = process.argv.slice(2);
|
|
257
|
+
const file = args.find((a) => !a.startsWith('--'));
|
|
258
|
+
const priorHarvestExists = args.includes('--prior');
|
|
259
|
+
if (!file) {
|
|
260
|
+
console.error('usage: validate-retro-harvest.mjs <artifact.md> [--prior] [--check-live]');
|
|
261
|
+
process.exit(1);
|
|
262
|
+
}
|
|
263
|
+
const text = readFileSync(file, 'utf8');
|
|
264
|
+
const { valid, errors } = validateRetroHarvest(text, { priorHarvestExists });
|
|
265
|
+
if (!valid) {
|
|
266
|
+
console.error(`INVALID: ${file}`);
|
|
267
|
+
for (const e of errors) console.error(' - ' + e);
|
|
268
|
+
process.exit(1);
|
|
269
|
+
}
|
|
270
|
+
console.log(`valid: ${file}`);
|
|
271
|
+
process.exit(0);
|
|
272
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "./builtin-manifest.schema.json",
|
|
3
3
|
"schemaVersion": 1,
|
|
4
|
-
"generatedAt": "2026-06-
|
|
5
|
-
"instarVersion": "1.3.
|
|
4
|
+
"generatedAt": "2026-06-02T04:46:08.483Z",
|
|
5
|
+
"instarVersion": "1.3.197",
|
|
6
6
|
"entryCount": 193,
|
|
7
7
|
"entries": {
|
|
8
8
|
"hook:session-start": {
|
|
@@ -1089,7 +1089,7 @@
|
|
|
1089
1089
|
"type": "template",
|
|
1090
1090
|
"domain": "operations",
|
|
1091
1091
|
"sourcePath": "src/templates/scripts/convergence-check.sh",
|
|
1092
|
-
"contentHash": "
|
|
1092
|
+
"contentHash": "b0475554bde6729d2d9a1f8005dcada6a8e4c767203d8293c09a212f9bf0a196",
|
|
1093
1093
|
"since": "2025-01-01"
|
|
1094
1094
|
},
|
|
1095
1095
|
"template:git-sync-gate.sh": {
|
|
@@ -1545,7 +1545,7 @@
|
|
|
1545
1545
|
"type": "subsystem",
|
|
1546
1546
|
"domain": "coordination",
|
|
1547
1547
|
"sourcePath": "src/core/MultiMachineCoordinator.ts",
|
|
1548
|
-
"contentHash": "
|
|
1548
|
+
"contentHash": "63ce6fcd9564b1e547e2b0ad6153e43293566dac6a6db6f17ffb8cbf28b28894",
|
|
1549
1549
|
"since": "2025-01-01"
|
|
1550
1550
|
},
|
|
1551
1551
|
"subsystem:backup-manager": {
|
|
@@ -149,6 +149,26 @@ if echo "$CONTENT" | grep -qiE "(i used to (think|believe|feel|assume)|back when
|
|
|
149
149
|
ISSUE_COUNT=$((ISSUE_COUNT + 1))
|
|
150
150
|
fi
|
|
151
151
|
|
|
152
|
+
# 8. SPEC-REVIEW LINK — a spec handed over for review must carry a rendered
|
|
153
|
+
# ELI16 tunnel link the operator can open. Structure > Willpower: the link is
|
|
154
|
+
# guaranteed by skills/spec-converge/scripts/publish-spec-review.mjs. Narrow by
|
|
155
|
+
# design (this blocks the send): fires only on an unambiguous spec handoff —
|
|
156
|
+
# a docs/specs/*.md reference, OR a GitHub PR mentioned with the word "spec" —
|
|
157
|
+
# in an explicit review/approval handoff, with no /view/ link present. An
|
|
158
|
+
# ordinary code-PR mention does not fire.
|
|
159
|
+
SPEC_HANDOFF=""
|
|
160
|
+
if echo "$CONTENT" | grep -qiE "docs/specs/[^ )]+\.md"; then
|
|
161
|
+
SPEC_HANDOFF="yes"
|
|
162
|
+
elif echo "$CONTENT" | grep -qiE "github\.com/[^ )]+/pull/[0-9]+" && echo "$CONTENT" | grep -qiE "\bspec(s|ification)?\b"; then
|
|
163
|
+
SPEC_HANDOFF="yes"
|
|
164
|
+
fi
|
|
165
|
+
if [ -n "$SPEC_HANDOFF" ] \
|
|
166
|
+
&& echo "$CONTENT" | grep -qiE "\b(review|approv|sign[- ]?off|take a look|for your|ready for)\b" \
|
|
167
|
+
&& ! echo "$CONTENT" | grep -qiE "/view/[0-9a-f-]{8,}"; then
|
|
168
|
+
ISSUES+=("SPEC_REVIEW_LINK: You're handing a spec over for review with no rendered ELI16 tunnel link the operator can open. Deliver spec reviews via skills/spec-converge/scripts/publish-spec-review.mjs — it renders the ELI16, verifies the link (HTTP 200), and includes it. Don't send a spec for review without the rendered link.")
|
|
169
|
+
ISSUE_COUNT=$((ISSUE_COUNT + 1))
|
|
170
|
+
fi
|
|
171
|
+
|
|
152
172
|
# Output results
|
|
153
173
|
if [ "$ISSUE_COUNT" -gt "0" ]; then
|
|
154
174
|
echo "=== CONVERGENCE CHECK: ${ISSUE_COUNT} ISSUE(S) FOUND ==="
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Upgrade Guide — vNEXT
|
|
2
|
+
|
|
3
|
+
<!-- assembled-by: assemble-next-md -->
|
|
4
|
+
<!-- bump: patch -->
|
|
5
|
+
|
|
6
|
+
## What Changed
|
|
7
|
+
|
|
8
|
+
Fixes a crash-loop regression introduced with the multi-machine active-pull feature.
|
|
9
|
+
|
|
10
|
+
On a machine running by itself (no other live machine in its mesh), the active-pull loop was re-checking the "who's awake" role every few seconds and, whenever the short-lived internal lease briefly lapsed between renewals, wrongly flipped the machine to a standby (read-only) state. A follow-up write then crashed the server, and it restarted into the same loop. Because the server is also the messaging relay, the operator saw silence during the loop.
|
|
11
|
+
|
|
12
|
+
The fix: the active-pull loop now only re-evaluates the awake/standby role when it has actually heard a lease from a peer. A machine on its own is never demoted by the pull loop on a transient lease lapse — its normal heartbeat keeps renewing the lease as before. The genuine multi-machine behavior (a backup that pulls a newer lease from a live peer still steps down) is unchanged.
|
|
13
|
+
|
|
14
|
+
This pairs with the earlier hardening that made a read-only/standby write non-fatal, so both the wrong state and the crash it could cause are now closed.
|
|
15
|
+
|
|
16
|
+
## What to Tell Your User
|
|
17
|
+
|
|
18
|
+
Nothing to do. If you run an agent on a single machine, this removes a rare crash-restart loop that could make it go quiet for a while; multi-machine setups behave the same as before, just without the spurious solo demotion.
|
|
19
|
+
|
|
20
|
+
## Summary of New Capabilities
|
|
21
|
+
|
|
22
|
+
- The active lease-pull loop only reconciles the awake/standby role when a peer lease was actually observed, so a solo machine is never demoted (and never driven read-only) by the pull loop on a transient self-lease lapse. Regression test added; the real peer-driven demotion path is retained and tested.
|
|
23
|
+
|
|
24
|
+
## Evidence
|
|
25
|
+
|
|
26
|
+
- `tsc --noEmit` clean; 45 multi-machine unit tests green, including a new regression (a solo holder whose self-lease lapses with no peer observed stays awake and never goes read-only) and the retained same-epoch contested-split-brain test (feature intact).
|
|
27
|
+
- Root cause of the 2026-06-02 echo crash-loop incident. Spec: docs/specs/MULTI-MACHINE-ROBUST-LEASE-PROPAGATION-SPEC.md (approved). Side-effects review: upgrades/side-effects/fix-activepull-solo-demotion.md.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Upgrade Guide — vNEXT
|
|
2
|
+
|
|
3
|
+
<!-- assembled-by: assemble-next-md -->
|
|
4
|
+
<!-- bump: patch -->
|
|
5
|
+
|
|
6
|
+
## What Changed
|
|
7
|
+
|
|
8
|
+
Agents are no longer assigned a network port that the multi-machine mesh secretly can't reach.
|
|
9
|
+
|
|
10
|
+
The mesh talks between machines using Node's built-in web-request function, which refuses a short standard list of "bad ports" (for example 4045, the old file-lock service port). That list includes a port inside the default range agents were picked from — so an agent could be handed a port on which it would silently fail to pair or fail over, with no error in normal tools. The port picker now skips those bad ports, and any agent already running on one prints a clear startup warning telling you to change its port.
|
|
11
|
+
|
|
12
|
+
## What to Tell Your User
|
|
13
|
+
|
|
14
|
+
Nothing to do for new agents — they'll automatically avoid the handful of reserved ports that break multi-machine networking. If you run multiple machines and one happens to be on a bad port, the agent now warns you at startup with the exact fix (change its port and restart). This removes a silent, very-hard-to-spot failure where an agent looked healthy but could never join the mesh.
|
|
15
|
+
|
|
16
|
+
## Summary of New Capabilities
|
|
17
|
+
|
|
18
|
+
- The agent port allocator skips WHATWG fetch "bad ports" (4045, 6000, 6566, 6697, …), so a new agent never lands on a port the mesh's node-fetch comms can't reach.
|
|
19
|
+
- A new exported helper, isFetchBlockedPort, plus an unconditional server-startup warning when an existing agent's configured port is on that list (the migration path for already-running agents).
|
|
20
|
+
|
|
21
|
+
## Evidence
|
|
22
|
+
|
|
23
|
+
- Root cause of a real 2026-06-02 failure: a paired test agent on port 4045 could never be joined ("fetch failed: bad port") even though curl reached its pairing endpoint; moving it off 4045 fixed the join immediately.
|
|
24
|
+
- `tsc --noEmit` clean; 34 agent-registry unit tests green, including 3 new ones covering the blocklist helper (both sides of the boundary) and the allocator skipping a blocked port. Side-effects review: upgrades/side-effects/fix-fetch-blocked-ports.md.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Side-Effects Review — Apprenticeship Step 0: Retro-Harvest
|
|
2
|
+
|
|
3
|
+
**Version / slug:** `APPRENTICESHIP-STEP0-RETRO-HARVEST-SPEC`
|
|
4
|
+
**Date:** `2026-06-01`
|
|
5
|
+
**Author:** `echo`
|
|
6
|
+
**Second-pass reviewer:** `not required` (converged via /spec-converge: 5 internal reviewers + codex gpt-5.5, 3 rounds)
|
|
7
|
+
|
|
8
|
+
## Summary of the change
|
|
9
|
+
|
|
10
|
+
Builds Step 0 of the Apprenticeship Program (Tier-3 umbrella #675). Ships:
|
|
11
|
+
- `scripts/validate-retro-harvest.mjs` — the pure, offline schema validator (the structural
|
|
12
|
+
SIGNAL) for `apprenticeship-retro-harvest/v1` artifacts, plus an optional injected-fetch
|
|
13
|
+
live-ledger cross-check.
|
|
14
|
+
- `tests/unit/validate-retro-harvest.test.ts` (34 cases, both sides of every boundary) +
|
|
15
|
+
`tests/integration/retro-harvest-artifact.test.ts` (the real artifact as a fixture-of-record).
|
|
16
|
+
- `docs/apprenticeship/RETRO-HARVEST-PROCEDURE.md` — the repeatable how-to.
|
|
17
|
+
- `docs/apprenticeship/retro-harvests/echo-to-codey-mentorship.md` — the first real harvest,
|
|
18
|
+
grounded in the live ledger (28 issues), reviewed by an independent fidelity reviewer.
|
|
19
|
+
- `docs/apprenticeship/retro-harvests/INDEX.json` — the latest-harvest pointer.
|
|
20
|
+
|
|
21
|
+
No `src/` is touched. The validator is a standalone `scripts/` tool not imported by `src/`.
|
|
22
|
+
|
|
23
|
+
## Decision-point inventory
|
|
24
|
+
|
|
25
|
+
One: the validator's pass/fail boundary (`validateRetroHarvest`). It is a **signal**, not an
|
|
26
|
+
authority (spec §9) — it asserts artifact SHAPE (schema, required fields, count/programNeeds
|
|
27
|
+
reconciliation, coverage-extent, scope/completeness rules, evidence-pointer well-formedness,
|
|
28
|
+
a limited secret-pattern backstop, path confinement, an approved+succeeded scrub, and a
|
|
29
|
+
non-`rejected` fidelity verdict). It does NOT judge harvest fidelity — that is the independent
|
|
30
|
+
LLM fidelity review, recorded in the artifact frontmatter.
|
|
31
|
+
|
|
32
|
+
## 1. Over-block
|
|
33
|
+
|
|
34
|
+
**What legitimate inputs does this reject?** A structurally malformed artifact (missing fields,
|
|
35
|
+
counts that disagree with the body, an incremental first harvest, a `complete` artifact with a
|
|
36
|
+
truncated source, an unapproved/failed scrub, a `rejected` fidelity verdict, a secret-shaped
|
|
37
|
+
string, a malformed pointer). All are genuine defects the gate is meant to refuse. Trailing
|
|
38
|
+
sentence punctuation after a pointer is tolerated (stripped before validation) so a clause-
|
|
39
|
+
boundary pointer is not falsely rejected.
|
|
40
|
+
|
|
41
|
+
## 2. Under-block
|
|
42
|
+
|
|
43
|
+
**What does this still miss?** By design, the validator does NOT judge whether the harvest is
|
|
44
|
+
*truthful or complete* — a well-shaped but hollow harvest passes the validator; the LLM fidelity
|
|
45
|
+
review is the authority that catches that (Signal vs Authority). The secret-pattern scan is an
|
|
46
|
+
explicit *limited backstop*, not a scrub guarantee (it misses API keys, hostnames, sig-less
|
|
47
|
+
URLs, names, phone numbers, contextual PII); the authoritative defense is the approved scrubber.
|
|
48
|
+
Live-ledger resolution of seeded ids runs only under `--check-live` / the integration path, not
|
|
49
|
+
the pure unit path.
|
|
50
|
+
|
|
51
|
+
## 3. Level-of-abstraction fit
|
|
52
|
+
|
|
53
|
+
**Right layer?** Yes. The validator is a pure function with a thin CLI guard, in `scripts/`
|
|
54
|
+
beside the other repo-invariant validators, unit-testable with no git/fs/network mocking. The
|
|
55
|
+
harvest artifact + procedure + index are plain repo docs under `docs/apprenticeship/`. The gate
|
|
56
|
+
that will *require* a valid harvest before an instance starts is deliberately deferred to Step 1
|
|
57
|
+
(spec §12–13) — this step ships the artifact + the validator the gate will call.
|
|
58
|
+
|
|
59
|
+
## 4. Testing
|
|
60
|
+
|
|
61
|
+
- **Unit** (`tests/unit/validate-retro-harvest.test.ts`): 34 cases — valid baseline + a targeted
|
|
62
|
+
failing mutation per decision boundary + `checkLiveLedger` with an injected fetch.
|
|
63
|
+
- **Integration** (`tests/integration/retro-harvest-artifact.test.ts`): the REAL
|
|
64
|
+
`echo-to-codey-mentorship.md` validates against the REAL validator; it is a full first harvest
|
|
65
|
+
with an independent (non-Echo) fidelity reviewer; seeds nothing (#50-independent); is INDEX-
|
|
66
|
+
registered.
|
|
67
|
+
- **E2E:** genuinely n/a — pure CLI validator, no HTTP route, no DI (spec §9, §11).
|
|
68
|
+
|
|
69
|
+
## 5. Migration / rollback / Agent-Awareness
|
|
70
|
+
|
|
71
|
+
- **Migration Parity:** N/A. No agent-installed files (`.claude/`, `.instar/config.json`, hooks,
|
|
72
|
+
skills, CLAUDE.md template), no config defaults, no `src/`. Pure repo docs + one `scripts/`
|
|
73
|
+
helper + tests.
|
|
74
|
+
- **Rollback:** revert the commit; nothing is deployed to agents, no state is written.
|
|
75
|
+
- **Agent-Awareness:** explicitly deferred to Step 1 (spec §12) — the awareness surface ("a valid
|
|
76
|
+
harvest is required before an instance starts") belongs with the gate Step 1 wires, not before
|
|
77
|
+
it exists.
|
|
78
|
+
- **NEXT.md / publish:** no `src/` change → no fleet-release/publish concern.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Side-Effects Review — Fix: active-pull must not demote a solo machine on a transient lease lapse
|
|
2
|
+
|
|
3
|
+
**Version / slug:** `fix-activepull-solo-demotion`
|
|
4
|
+
**Date:** `2026-06-02`
|
|
5
|
+
**Author:** `echo`
|
|
6
|
+
**Spec:** `docs/specs/MULTI-MACHINE-ROBUST-LEASE-PROPAGATION-SPEC.md` (approved: true) — corrects a regression in the active-pull it introduced (#668).
|
|
7
|
+
**Parent principle:** `Cross-Machine Coherence — One Agent, Robust Under Degraded Conditions`
|
|
8
|
+
|
|
9
|
+
## Summary of the change
|
|
10
|
+
|
|
11
|
+
A one-condition fix to `MultiMachineCoordinator.tickLeasePull`: it now only calls
|
|
12
|
+
`reconcileRoleToLease('lease-pull')` + `surfacePullDiscoveredSplitBrain()` when a peer
|
|
13
|
+
lease was **actually observed** (`leaseCoordinator.observedPeerLease()` non-null).
|
|
14
|
+
|
|
15
|
+
### Why (live incident, 2026-06-02)
|
|
16
|
+
|
|
17
|
+
The active-pull loop (shipped in #668) reconciled the machine's lease role
|
|
18
|
+
**unconditionally** every `leasePullIntervalMs` (~5s). On a solo machine — one with no
|
|
19
|
+
reachable peers (the only registry peer was dead 3 days, no `lastKnownUrl`, so `peers()`
|
|
20
|
+
was empty) — every brief lapse of the 60s self-lease between renewals made
|
|
21
|
+
`holdsLease()` return false, so the pull loop flipped the machine to **standby** →
|
|
22
|
+
`StateManager` read-only → a standby write threw and (pre-#673) crashed the server in a
|
|
23
|
+
launchd restart loop (lease epoch climbed into the thousands). The crashing server is the
|
|
24
|
+
Telegram relay, so the operator saw silence. #673 already stopped the *crash* (read-only
|
|
25
|
+
write is now an isolated/recoverable uncaught-exception class); this PR removes the *root
|
|
26
|
+
cause* (the spurious demotion itself).
|
|
27
|
+
|
|
28
|
+
## Decision-point inventory
|
|
29
|
+
|
|
30
|
+
- `tickLeasePull` reconcile vs skip: reconcile only when `observedPeerLease()` is non-null.
|
|
31
|
+
Pull is for LEARNING from peers; with no peer signal there is nothing to reconcile.
|
|
32
|
+
Role/renewal for a solo holder stays with the heartbeat `tickLease` (which RE-ACQUIRES,
|
|
33
|
+
not merely demotes).
|
|
34
|
+
|
|
35
|
+
## 1. Over-correction risk
|
|
36
|
+
Does gating on an observed peer break the real feature (a standby pulling a higher-epoch
|
|
37
|
+
holder must still demote)? No — that path records the holder's lease via `recordObserved`,
|
|
38
|
+
so `observedPeerLease()` is non-null and the reconcile runs exactly as before. Covered by
|
|
39
|
+
the retained "same-epoch contested" test.
|
|
40
|
+
|
|
41
|
+
## 2. Under-correction risk
|
|
42
|
+
A solo holder whose lease lapses is no longer demoted by the *pull* loop, but the 2-min
|
|
43
|
+
heartbeat `tickLease` still renews/re-acquires it — so role management is preserved, just
|
|
44
|
+
moved off the aggressive 5s pull cadence that caused the DoS.
|
|
45
|
+
|
|
46
|
+
## 3. Level-of-abstraction fit
|
|
47
|
+
The fix sits in the pull tick (the loop that caused the regression), gating on the
|
|
48
|
+
coordinator's existing `observedPeerLease()` accessor — no new surface.
|
|
49
|
+
|
|
50
|
+
## 4. Signal vs Authority
|
|
51
|
+
The pull remains a SIGNAL (observe peer leases); the FencedLease epoch/validity checks
|
|
52
|
+
remain the authority for who holds. The fix stops the signal loop from ACTING (demoting)
|
|
53
|
+
in the absence of any signal.
|
|
54
|
+
|
|
55
|
+
## 5. External surfaces
|
|
56
|
+
None. No route/config/schema change. `leasePullIntervalMs` unchanged.
|
|
57
|
+
|
|
58
|
+
## 6. Interactions with existing primitives
|
|
59
|
+
Composes with #673 (read-only-write no longer fatal) as defense-in-depth: #673 prevents
|
|
60
|
+
the crash; this prevents the wrong state that led to it. The heartbeat `tickLease` and the
|
|
61
|
+
acquire path are untouched.
|
|
62
|
+
|
|
63
|
+
## 7. Rollback cost
|
|
64
|
+
Trivial + safe: a single `if (observedPeerLease())` guard. Reverting restores the prior
|
|
65
|
+
(buggy) unconditional reconcile.
|
|
66
|
+
|
|
67
|
+
## Migration parity
|
|
68
|
+
None — pure code logic change, reaches existing agents on the normal dist update.
|
|
69
|
+
|
|
70
|
+
## Tests
|
|
71
|
+
`tsc --noEmit` clean. 45 multi-machine tests green, including a NEW regression
|
|
72
|
+
(`MultiMachineCoordinator-leasePull` — a solo holder whose self-lease lapses with no peer
|
|
73
|
+
observed stays awake + never goes read-only) and the retained same-epoch-contested test
|
|
74
|
+
(feature intact). Operational note: echo was reverted to solo mode during the incident
|
|
75
|
+
(machine identity moved aside); re-pairing its mesh is a separate, operator-gated step.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Side-Effects Review — Skip WHATWG fetch-blocked ports in agent port allocation
|
|
2
|
+
|
|
3
|
+
**Version / slug:** `fix-fetch-blocked-ports`
|
|
4
|
+
**Date:** `2026-06-02`
|
|
5
|
+
**Author:** `echo`
|
|
6
|
+
**Tier:** 1 (small, low-risk; ELI16 + side-effects, no converged spec)
|
|
7
|
+
**Parent principle:** Cross-Machine Coherence — One Agent, Robust Under Degraded Conditions
|
|
8
|
+
|
|
9
|
+
## Summary of the change
|
|
10
|
+
|
|
11
|
+
Instar's multi-machine mesh does ALL cross-machine I/O over node's global `fetch`
|
|
12
|
+
(pairing `POST /api/pair`, lease broadcast/pull, heartbeat). Node's `fetch` (undici)
|
|
13
|
+
throws `TypeError: fetch failed { cause: 'bad port' }` for any URL whose port is on the
|
|
14
|
+
WHATWG Fetch spec "bad ports" list. The default agent port-allocation range (4040–4099)
|
|
15
|
+
**contains 4045** (NFS `lockd`, a blocked port), so the allocator could hand an agent a
|
|
16
|
+
port on which it can **never** be reached over the mesh — silently, because `curl`
|
|
17
|
+
ignores the blocklist so the endpoint looks healthy.
|
|
18
|
+
|
|
19
|
+
**Observed live (2026-06-02):** a freshly-paired throwaway test agent landed on 4045 and
|
|
20
|
+
could not be joined — `instar join` failed with "fetch failed" despite `curl` to the same
|
|
21
|
+
`/api/pair` returning 400. Moving it off 4045 fixed the join instantly.
|
|
22
|
+
|
|
23
|
+
### What changed
|
|
24
|
+
- `src/core/AgentRegistry.ts`: added `FETCH_BLOCKED_PORTS` (the WHATWG bad-ports set) +
|
|
25
|
+
exported `isFetchBlockedPort(port)`. Both `allocatePort` and `allocatePortByName` now
|
|
26
|
+
skip blocked ports (in addition to used + lsof-busy ones).
|
|
27
|
+
- `src/commands/server.ts`: an unconditional startup warning when `config.port` is a
|
|
28
|
+
blocked port — the migration-parity path for EXISTING agents already on one (the
|
|
29
|
+
allocator guard only protects newly-allocated agents).
|
|
30
|
+
|
|
31
|
+
## Decision-point inventory
|
|
32
|
+
- allocator: skip vs allocate a port → skip if on the blocklist (the check precedes the
|
|
33
|
+
lsof probe, so it's deterministic).
|
|
34
|
+
- startup: warn vs silent → warn (loud, non-fatal) when an existing config sits on a
|
|
35
|
+
blocked port; we do NOT auto-re-port (that would change a running agent's port — left
|
|
36
|
+
to the operator).
|
|
37
|
+
|
|
38
|
+
## 1. Over-correction risk
|
|
39
|
+
The blocklist is the fixed WHATWG set; legitimate agent ports (4040–4044, 4046–4099, etc.)
|
|
40
|
+
are unaffected. Only 4045 falls in the default range. Skipping reduces the usable range by
|
|
41
|
+
one port — negligible (60→59).
|
|
42
|
+
|
|
43
|
+
## 2. Under-correction risk
|
|
44
|
+
Existing agents already on a blocked port aren't auto-fixed (that would change their port);
|
|
45
|
+
the startup warning surfaces it so the operator re-ports. Acceptable — auto-re-porting a
|
|
46
|
+
live agent is riskier than a loud warning.
|
|
47
|
+
|
|
48
|
+
## 3. Level-of-abstraction fit
|
|
49
|
+
The skip lives in the single port allocator both callers use; the warning at the single
|
|
50
|
+
server-start path. No scattering.
|
|
51
|
+
|
|
52
|
+
## 4. Signal vs Authority
|
|
53
|
+
Pure deterministic check against a fixed spec list — no LLM, no heuristic. Appropriate.
|
|
54
|
+
|
|
55
|
+
## 5. External surfaces
|
|
56
|
+
None. No route/config-schema change. `isFetchBlockedPort` is a new pure export.
|
|
57
|
+
|
|
58
|
+
## 6. Interactions with existing primitives
|
|
59
|
+
The allocator's existing used-port + lsof checks are unchanged; the blocklist is an
|
|
60
|
+
additional AND condition. The warning composes with the existing startup logs.
|
|
61
|
+
|
|
62
|
+
## 7. Rollback cost
|
|
63
|
+
Trivial: remove the `&& !FETCH_BLOCKED_PORTS.has(port)` clauses + the warning. No state.
|
|
64
|
+
|
|
65
|
+
## Migration parity
|
|
66
|
+
- New agents: allocator skips blocked ports (no action needed).
|
|
67
|
+
- Existing agents on a blocked port: the startup warning surfaces it (operator re-ports).
|
|
68
|
+
- Pure code; reaches existing agents on the normal dist update. No config/hook migration.
|
|
69
|
+
|
|
70
|
+
## Tests
|
|
71
|
+
`tsc --noEmit` clean. 34 `agent-registry` unit tests green, including 3 new: `isFetchBlockedPort`
|
|
72
|
+
both sides of the boundary (4045/6000/6697/2049 blocked; 4040/4046/4050/4099 not),
|
|
73
|
+
`allocatePort` throws rather than return a sole blocked candidate, and `allocatePort` skips
|
|
74
|
+
a blocked port to return the next usable one.
|