instar 1.3.955 → 1.3.957

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.
@@ -0,0 +1,66 @@
1
+ export declare const CAPABILITY_REGISTRY_SCHEMA_VERSION = 1;
2
+ export declare const MAX_ENTRIES_PER_MACHINE = 200;
3
+ export declare const MAX_STRING_LENGTH = 256;
4
+ export declare const MAX_SCHEMA_VERSION = 999;
5
+ export declare const MAX_MACHINE_EPOCH = 9999999999;
6
+ export declare const MAX_PROJECTION_SEQ = 9999999999;
7
+ export declare const MAX_SCAN_STAMP_SECS = 9999999999;
8
+ export declare const CAPABILITY_KINDS: readonly ["model"];
9
+ export declare const PROBE_OUTCOMES: readonly ["positive", "negative", "unknown"];
10
+ export declare const SCAN_STATES: readonly ["observed", "never-observed", "source-unavailable"];
11
+ export declare const SOURCES: readonly ["local-doorways"];
12
+ export declare const SOURCE_DETAILS: readonly ["doorway-scan", "doorway-manifest", "pool-observation"];
13
+ export declare const EVIDENCE_CLASSES: readonly ["cli-present", "probe-answered", "manifest-only"];
14
+ export type ProbeOutcome = (typeof PROBE_OUTCOMES)[number];
15
+ export type ScanState = (typeof SCAN_STATES)[number];
16
+ export type SourceDetail = (typeof SOURCE_DETAILS)[number];
17
+ export type CapabilityStatus = 'available' | 'unavailable' | 'unknown' | 'stale' | 'conflict';
18
+ export interface CapabilityEvidence {
19
+ doorwayScanAt?: string;
20
+ manifestVerifiedAt?: string;
21
+ }
22
+ export interface CapabilityEntry {
23
+ capabilityId: string;
24
+ capabilityKind: 'model';
25
+ doorwayId: string;
26
+ machineId: string;
27
+ probeOutcome: ProbeOutcome;
28
+ endpointRef: string;
29
+ observedAt: string;
30
+ receivedAt: string;
31
+ source: 'local-doorways';
32
+ sourceDetail: SourceDetail;
33
+ evidenceClass: (typeof EVIDENCE_CLASSES)[number];
34
+ evidence: CapabilityEvidence;
35
+ }
36
+ export interface CapabilityProjection {
37
+ schemaVersion: number;
38
+ machineId: string;
39
+ machineEpoch: number;
40
+ projectionSeq: number;
41
+ scanStampSecs: number;
42
+ scanState: ScanState;
43
+ truncated: boolean;
44
+ entries: CapabilityEntry[];
45
+ }
46
+ export declare function canonicalCapabilityId(doorwayId: unknown, modelId: unknown): string;
47
+ export declare function validateProjection(raw: unknown): CapabilityProjection;
48
+ export declare function canonicalDigest(projection: CapabilityProjection): string;
49
+ export declare function deriveStatus(entries: CapabilityEntry[], now?: number, opts?: {
50
+ localStaleAfterMs?: number;
51
+ remoteTtlCeilingMs?: number;
52
+ lastConfirmedAt?: number;
53
+ }): CapabilityStatus;
54
+ export declare function readDoorwaySources(projectDir: string, stateDir: string, now?: string, machineId?: string): {
55
+ entries: CapabilityEntry[];
56
+ scanState: ScanState;
57
+ scanStampSecs: number;
58
+ };
59
+ export declare class CapabilityRegistryWriter {
60
+ private readonly filePath;
61
+ private readonly machineId;
62
+ constructor(filePath: string, machineId: string);
63
+ write(input: Omit<CapabilityProjection, 'machineId'>): CapabilityProjection;
64
+ read(): CapabilityProjection | null;
65
+ }
66
+ //# sourceMappingURL=CapabilityRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CapabilityRegistry.d.ts","sourceRoot":"","sources":["../../src/core/CapabilityRegistry.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,kCAAkC,IAAI,CAAC;AACpD,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,kBAAkB,MAAM,CAAC;AACtC,eAAO,MAAM,iBAAiB,aAAgB,CAAC;AAC/C,eAAO,MAAM,kBAAkB,aAAgB,CAAC;AAChD,eAAO,MAAM,mBAAmB,aAAgB,CAAC;AAEjD,eAAO,MAAM,gBAAgB,oBAAqB,CAAC;AACnD,eAAO,MAAM,cAAc,8CAA+C,CAAC;AAC3E,eAAO,MAAM,WAAW,+DAAgE,CAAC;AACzF,eAAO,MAAM,OAAO,6BAA8B,CAAC;AACn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AAiBD,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAIlF;AAuBD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,oBAAoB,CAerE;AAID,wBAAgB,eAAe,CAAC,UAAU,EAAE,oBAAoB,GAAG,MAAM,CAOxE;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,GAAG,SAAa,EAAE,IAAI,GAAE;IAAE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,gBAAgB,CAU7L;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,SAA2B,EAAE,SAAS,SAAU,GAAG;IAAE,OAAO,EAAE,eAAe,EAAE,CAAC;IAAC,SAAS,EAAE,SAAS,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CA6BzM;AAED,qBAAa,wBAAwB;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAAU,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAA5C,QAAQ,EAAE,MAAM,EAAmB,SAAS,EAAE,MAAM;IACjF,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,oBAAoB,EAAE,WAAW,CAAC,GAAG,oBAAoB;IAqB3E,IAAI,IAAI,oBAAoB,GAAG,IAAI;CAQpC"}
@@ -0,0 +1,214 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import crypto from 'node:crypto';
4
+ import { readDoorwayRegistry, scanStatePath } from './DoorwayRegistryReader.js';
5
+ import { DegradationReporter } from '../monitoring/DegradationReporter.js';
6
+ export const CAPABILITY_REGISTRY_SCHEMA_VERSION = 1;
7
+ export const MAX_ENTRIES_PER_MACHINE = 200;
8
+ export const MAX_STRING_LENGTH = 256;
9
+ export const MAX_SCHEMA_VERSION = 999;
10
+ export const MAX_MACHINE_EPOCH = 9_999_999_999;
11
+ export const MAX_PROJECTION_SEQ = 9_999_999_999;
12
+ export const MAX_SCAN_STAMP_SECS = 9_999_999_999;
13
+ export const CAPABILITY_KINDS = ['model'];
14
+ export const PROBE_OUTCOMES = ['positive', 'negative', 'unknown'];
15
+ export const SCAN_STATES = ['observed', 'never-observed', 'source-unavailable'];
16
+ export const SOURCES = ['local-doorways'];
17
+ export const SOURCE_DETAILS = ['doorway-scan', 'doorway-manifest', 'pool-observation'];
18
+ export const EVIDENCE_CLASSES = ['cli-present', 'probe-answered', 'manifest-only'];
19
+ const int = (v, max, name) => {
20
+ if (!Number.isSafeInteger(v) || v < 0 || v > max)
21
+ throw new Error(`${name}-width`);
22
+ return v;
23
+ };
24
+ const str = (v, name) => {
25
+ if (typeof v !== 'string' || v.length === 0 || v.length > MAX_STRING_LENGTH)
26
+ throw new Error(`${name}-invalid`);
27
+ return v;
28
+ };
29
+ const iso = (v, name) => {
30
+ const s = str(v, name);
31
+ if (Number.isNaN(Date.parse(s)))
32
+ throw new Error(`${name}-timestamp`);
33
+ return s;
34
+ };
35
+ const oneOf = (v, values, name) => {
36
+ if (!values.includes(v))
37
+ throw new Error(`${name}-enum`);
38
+ return v;
39
+ };
40
+ export function canonicalCapabilityId(doorwayId, modelId) {
41
+ const d = str(doorwayId, 'doorwayId').toLowerCase();
42
+ const m = str(modelId, 'modelId').toLowerCase();
43
+ if (!/^[a-z0-9._-]+$/.test(d) || !/^[a-z0-9._-]+$/.test(m))
44
+ throw new Error('capability-id-invalid');
45
+ return `models:${d}/${m}`;
46
+ }
47
+ function validateEntry(raw, machineId) {
48
+ if (!raw || typeof raw !== 'object')
49
+ throw new Error('entry-invalid');
50
+ const r = raw;
51
+ if (r.machineId !== machineId)
52
+ throw new Error('origin-mismatch');
53
+ const capabilityId = str(r.capabilityId, 'capabilityId');
54
+ if (!/^models:[a-z0-9._-]+\/[a-z0-9._-]+$/.test(capabilityId))
55
+ throw new Error('capability-id-invalid');
56
+ const doorwayId = str(r.doorwayId, 'doorwayId').toLowerCase();
57
+ const endpointRef = str(r.endpointRef, 'endpointRef');
58
+ if (!new RegExp(`^mesh://${escapeRegExp(machineId)}/doorways$`).test(endpointRef))
59
+ throw new Error('endpoint-ref-invalid');
60
+ const evidence = r.evidence && typeof r.evidence === 'object' ? r.evidence : {};
61
+ if (Object.keys(evidence).some(k => !['doorwayScanAt', 'manifestVerifiedAt'].includes(k)))
62
+ throw new Error('evidence-keys');
63
+ return {
64
+ capabilityId, capabilityKind: oneOf(r.capabilityKind, CAPABILITY_KINDS, 'capabilityKind'), doorwayId,
65
+ machineId, probeOutcome: oneOf(r.probeOutcome, PROBE_OUTCOMES, 'probeOutcome'), endpointRef,
66
+ observedAt: iso(r.observedAt, 'observedAt'), receivedAt: iso(r.receivedAt, 'receivedAt'),
67
+ source: oneOf(r.source, SOURCES, 'source'), sourceDetail: oneOf(r.sourceDetail, SOURCE_DETAILS, 'sourceDetail'),
68
+ evidenceClass: oneOf(r.evidenceClass, EVIDENCE_CLASSES, 'evidenceClass'),
69
+ evidence: { ...(evidence.doorwayScanAt ? { doorwayScanAt: iso(evidence.doorwayScanAt, 'doorwayScanAt') } : {}), ...(evidence.manifestVerifiedAt ? { manifestVerifiedAt: iso(evidence.manifestVerifiedAt, 'manifestVerifiedAt') } : {}) },
70
+ };
71
+ }
72
+ export function validateProjection(raw) {
73
+ if (!raw || typeof raw !== 'object')
74
+ throw new Error('malformed');
75
+ const r = raw;
76
+ const machineId = str(r.machineId, 'machineId');
77
+ const schemaVersion = int(r.schemaVersion, MAX_SCHEMA_VERSION, 'schemaVersion');
78
+ if (schemaVersion > CAPABILITY_REGISTRY_SCHEMA_VERSION)
79
+ throw new Error('version-unsupported');
80
+ if (!Array.isArray(r.entries) || r.entries.length > MAX_ENTRIES_PER_MACHINE)
81
+ throw new Error('over-limit');
82
+ const p = {
83
+ schemaVersion, machineId, machineEpoch: int(r.machineEpoch, MAX_MACHINE_EPOCH, 'machineEpoch'),
84
+ projectionSeq: int(r.projectionSeq, MAX_PROJECTION_SEQ, 'projectionSeq'),
85
+ scanStampSecs: int(r.scanStampSecs, MAX_SCAN_STAMP_SECS, 'scanStampSecs'),
86
+ scanState: oneOf(r.scanState, SCAN_STATES, 'scanState'),
87
+ truncated: typeof r.truncated === 'boolean' ? r.truncated : (() => { throw new Error('truncated-invalid'); })(),
88
+ entries: r.entries.map(e => validateEntry(e, machineId)),
89
+ };
90
+ return p;
91
+ }
92
+ function escapeRegExp(s) { return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); }
93
+ function fact(e) { return { capabilityId: e.capabilityId, capabilityKind: e.capabilityKind, doorwayId: e.doorwayId, machineId: e.machineId, probeOutcome: e.probeOutcome, endpointRef: e.endpointRef, source: e.source, sourceDetail: e.sourceDetail, evidenceClass: e.evidenceClass }; }
94
+ export function canonicalDigest(projection) {
95
+ const entries = [...projection.entries].sort((a, b) => `${a.doorwayId}\0${a.capabilityId}\0${a.sourceDetail}`.localeCompare(`${b.doorwayId}\0${b.capabilityId}\0${b.sourceDetail}`));
96
+ const serialized = JSON.stringify(entries.map(fact));
97
+ const hash = crypto.createHash('sha256').update(serialized).digest('hex').slice(0, 16);
98
+ const state = SCAN_STATES.indexOf(projection.scanState);
99
+ const digest = `cap1:${projection.schemaVersion}:${projection.machineEpoch}:${projection.projectionSeq}:${projection.truncated ? 1 : 0}:${state}:${projection.scanStampSecs}:${hash}`;
100
+ if (Buffer.byteLength(digest) > 64)
101
+ throw new Error('digest-width');
102
+ return digest;
103
+ }
104
+ export function deriveStatus(entries, now = Date.now(), opts = {}) {
105
+ if (!entries.length)
106
+ return 'unknown';
107
+ const byOutcome = new Set(entries.map(e => e.probeOutcome));
108
+ if (byOutcome.size > 1)
109
+ return 'conflict';
110
+ if (entries.every(e => e.evidenceClass === 'manifest-only'))
111
+ return 'unknown';
112
+ if (entries.some(e => e.probeOutcome === 'unknown'))
113
+ return 'unknown';
114
+ const observedStale = entries.some(e => now - Date.parse(e.observedAt) > (opts.localStaleAfterMs ?? 86_400_000));
115
+ const transportStale = opts.lastConfirmedAt !== undefined && now - opts.lastConfirmedAt > (opts.remoteTtlCeilingMs ?? 600_000);
116
+ if (transportStale || observedStale)
117
+ return 'stale';
118
+ return entries[0].probeOutcome === 'positive' ? 'available' : 'unavailable';
119
+ }
120
+ export function readDoorwaySources(projectDir, stateDir, now = new Date().toISOString(), machineId = 'local') {
121
+ const scanPath = scanStatePath(stateDir);
122
+ const scanExists = fs.existsSync(scanPath);
123
+ let scanReadable = false;
124
+ if (scanExists) {
125
+ try {
126
+ JSON.parse(fs.readFileSync(scanPath, 'utf8'));
127
+ scanReadable = true;
128
+ }
129
+ catch (error) {
130
+ DegradationReporter.getInstance().report({ feature: 'CapabilityRegistry.scanState', primary: 'Readable doorway scan-state', fallback: 'Source-unavailable projection state', reason: `scan-state parse failed: ${error instanceof Error ? error.message : String(error)}`, impact: 'Local doorway freshness is unavailable until the next successful scan.' });
131
+ }
132
+ }
133
+ const result = readDoorwayRegistry({ projectDir, stateDir });
134
+ if (result.status !== 'ok')
135
+ throw new Error(`doorway-registry-${result.status}`);
136
+ const { body } = result;
137
+ const scanState = !scanReadable && scanExists ? 'source-unavailable' : body.scanState === 'scanned' ? 'observed' : 'never-observed';
138
+ const scanStampSecs = body.lastScanAt ? Math.floor(Date.parse(body.lastScanAt) / 1000) : 0;
139
+ const entries = [];
140
+ for (const door of body.doorways) {
141
+ const d = door.probeStatus === 'never-scanned' ? null : door;
142
+ for (const model of door.topModels) {
143
+ if (!model.id)
144
+ continue;
145
+ const doorwayId = door.doorId;
146
+ const scannedAt = d?.lastScannedAt ?? now;
147
+ const capabilityId = canonicalCapabilityId(doorwayId, model.id);
148
+ const common = { capabilityId, capabilityKind: 'model', doorwayId, machineId, endpointRef: `mesh://${machineId}/doorways`, receivedAt: now, source: 'local-doorways', evidence: { ...(d?.lastScannedAt ? { doorwayScanAt: d.lastScannedAt } : {}) } };
149
+ entries.push({ ...common, probeOutcome: 'positive', observedAt: model.verifiedAt ?? now, sourceDetail: 'doorway-manifest', evidenceClass: 'manifest-only' });
150
+ if (d)
151
+ entries.push({ ...common, probeOutcome: d.probeStatus === 'ok' ? 'positive' : ['not-installed', 'http-4xx'].includes(d.probeStatus) ? 'negative' : 'unknown', observedAt: scannedAt, sourceDetail: 'doorway-scan', evidenceClass: d.probeStatus === 'ok' ? 'probe-answered' : 'cli-present' });
152
+ }
153
+ }
154
+ return { entries, scanState, scanStampSecs };
155
+ }
156
+ export class CapabilityRegistryWriter {
157
+ filePath;
158
+ machineId;
159
+ constructor(filePath, machineId) {
160
+ this.filePath = filePath;
161
+ this.machineId = machineId;
162
+ }
163
+ write(input) {
164
+ const previous = this.read();
165
+ let epoch = input.machineEpoch;
166
+ let seq = input.projectionSeq;
167
+ if (previous) {
168
+ epoch = Math.max(epoch, previous.machineEpoch);
169
+ seq = previous.machineEpoch === epoch ? previous.projectionSeq + 1 : seq;
170
+ }
171
+ const scanStampSecs = input.scanStampSecs;
172
+ if (seq >= MAX_PROJECTION_SEQ) {
173
+ epoch = Math.max(Math.floor(Date.now() / 1000), epoch + 1);
174
+ seq = 0;
175
+ }
176
+ const sorted = [...input.entries].sort((a, b) => `${a.doorwayId}\0${a.capabilityId}\0${a.sourceDetail}`.localeCompare(`${b.doorwayId}\0${b.capabilityId}\0${b.sourceDetail}`));
177
+ let truncated = input.truncated;
178
+ if (sorted.length > MAX_ENTRIES_PER_MACHINE) {
179
+ const kept = [];
180
+ let i = 0;
181
+ while (i < sorted.length && kept.length < MAX_ENTRIES_PER_MACHINE) {
182
+ const id = sorted[i].capabilityId;
183
+ const group = sorted.filter(e => e.capabilityId === id);
184
+ if (kept.length + group.length > MAX_ENTRIES_PER_MACHINE)
185
+ break;
186
+ kept.push(...group);
187
+ i += group.length;
188
+ }
189
+ sorted.splice(0, sorted.length, ...kept);
190
+ truncated = true;
191
+ }
192
+ if (!previous)
193
+ epoch = Math.max(Math.floor(Date.now() / 1000), epoch);
194
+ const projection = validateProjection({ ...input, machineId: this.machineId, machineEpoch: epoch, projectionSeq: seq, scanStampSecs, truncated, entries: sorted });
195
+ const dir = path.dirname(this.filePath);
196
+ fs.mkdirSync(dir, { recursive: true });
197
+ const tmp = `${this.filePath}.tmp-${process.pid}`;
198
+ fs.writeFileSync(tmp, JSON.stringify(projection, null, 2));
199
+ fs.renameSync(tmp, this.filePath);
200
+ return projection;
201
+ }
202
+ read() {
203
+ if (!fs.existsSync(this.filePath))
204
+ return null;
205
+ try {
206
+ return validateProjection(JSON.parse(fs.readFileSync(this.filePath, 'utf8')));
207
+ }
208
+ catch (error) {
209
+ DegradationReporter.getInstance().report({ feature: 'CapabilityRegistry.projection', primary: 'Valid local capability projection', fallback: 'Fresh projection rebuild', reason: `projection read failed: ${error instanceof Error ? error.message : String(error)}`, impact: 'The registry will rebuild from current local doorway sources.' });
210
+ return null;
211
+ }
212
+ }
213
+ }
214
+ //# sourceMappingURL=CapabilityRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CapabilityRegistry.js","sourceRoot":"","sources":["../../src/core/CapabilityRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,CAAC;AACpD,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AACrC,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AACtC,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAA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1,6 @@
1
1
  {
2
2
  "name": "instar",
3
- "version": "1.3.955",
3
+ "version": "1.3.957",
4
4
  "description": "Coherence infrastructure for self-evolving AI agents — on the Claude Code or Codex subscription you already have.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -0,0 +1,136 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Generate a spec's IMPLEMENTATION CONTRACT — the normative sections only,
4
+ * with the review history stripped out.
5
+ *
6
+ * Why this exists (outbound-gate-advisory-override rounds 22/23/24): a spec that
7
+ * records its own review honestly accumulates change logs describing designs that
8
+ * were REVERSED. Both external reviewers independently named the same risk — an
9
+ * implementer cargo-culting a retired term out of a change log — and the same
10
+ * fix: publish the contract separately from the history.
11
+ *
12
+ * The rule is deliberately dumb and mechanical: everything up to the first
13
+ * history heading is the contract; everything from there on is history. A
14
+ * generator that had to understand the document would drift like the document.
15
+ *
16
+ * Usage:
17
+ * node scripts/generate-spec-contract.mjs --spec docs/specs/<slug>.md
18
+ * node scripts/generate-spec-contract.mjs --spec <path> --check # CI: fail if stale
19
+ */
20
+
21
+ import fs from 'node:fs';
22
+ import path from 'node:path';
23
+
24
+ /** A heading that begins the review-history half. Matched case-insensitively. */
25
+ const HISTORY_HEADING_RE = /^##\s+(?:\d+\.\s+)?(?:Round-\d+\b[^\n]*?(?:change log|hand-check|consistency sweep)|Appendix\b)/i;
26
+
27
+ /** Headings that are contract even though they sort after a history heading. */
28
+ const ALWAYS_CONTRACT_RE = /^##\s+(?:\d+\.\s+)?(?:Decision points touched|Open questions|Frontloaded Decisions|Dependencies|Honest limits|Multi-machine posture|What this does not do)/i;
29
+
30
+ /**
31
+ * Inline review annotations inside NORMATIVE prose — "(round-12, codex — ...)",
32
+ * "*(Round-25, codex: ...)*". They are provenance, not contract. Both external
33
+ * reviewers named them as the reason §§0-11 still read as history (rounds 24/25).
34
+ * Stripped from the generated contract; untouched in the source spec, where they
35
+ * are the record of why a decision is what it is.
36
+ *
37
+ * Deliberately conservative: only fully-delimited groups are removed, so a
38
+ * malformed annotation is left visible rather than silently eating prose.
39
+ */
40
+ const INLINE_ANNOTATION_RES = [
41
+ // *( Round-N ... )* — a complete italic aside
42
+ /\*\((?:round|rounds)[- ]\d+[^()*]*\)\*/gi,
43
+ // ( round-N, reviewer — ... ) — a complete parenthetical with no nesting
44
+ /\s*\((?:round|rounds)[- ]\d+[^()]*\)/gi,
45
+ // — round-N, codex … (an em-dash aside running to the end of a sentence)
46
+ /\s+—\s+(?:round|rounds)[- ]\d+,[^.;]*(?=[.;])/gi,
47
+ ];
48
+
49
+ export function stripInlineAnnotations(text) {
50
+ let out = text;
51
+ for (const re of INLINE_ANNOTATION_RES) out = out.replace(re, '');
52
+ // Collapse the double spaces a removal can leave mid-sentence.
53
+ return out.replace(/[ \t]{2,}/g, ' ').replace(/ +([.,;:])/g, '$1');
54
+ }
55
+
56
+ export function splitContract(markdown) {
57
+ const lines = markdown.split('\n');
58
+ const kept = [];
59
+ let inHistory = false;
60
+ let droppedSections = 0;
61
+ for (const line of lines) {
62
+ if (/^##\s/.test(line)) {
63
+ if (HISTORY_HEADING_RE.test(line) && !ALWAYS_CONTRACT_RE.test(line)) {
64
+ if (!inHistory) inHistory = true;
65
+ droppedSections++;
66
+ continue;
67
+ }
68
+ // A non-history H2 ends a history run (sections are not strictly ordered).
69
+ inHistory = false;
70
+ }
71
+ if (!inHistory) kept.push(line);
72
+ }
73
+ const body = stripInlineAnnotations(kept.join('\n')).replace(/\n{4,}/g, '\n\n\n');
74
+ return { contract: body, droppedSections };
75
+ }
76
+
77
+ /** The banner that makes the generated file unmistakable and un-editable-by-hand. */
78
+ function banner(specRel) {
79
+ return [
80
+ '<!-- GENERATED FILE — DO NOT EDIT.',
81
+ ` Source: ${specRel}`,
82
+ ' Regenerate: node scripts/generate-spec-contract.mjs --spec ' + specRel,
83
+ ' This is the IMPLEMENTATION CONTRACT: the normative design only.',
84
+ ' Review history (change logs, retired designs, reversed decisions) is',
85
+ ' deliberately absent — read the source spec for how the design got here.',
86
+ '-->',
87
+ '',
88
+ ].join('\n');
89
+ }
90
+
91
+ function main() {
92
+ const args = process.argv.slice(2);
93
+ const specIdx = args.indexOf('--spec');
94
+ if (specIdx === -1 || !args[specIdx + 1]) {
95
+ console.error('usage: generate-spec-contract.mjs --spec <path> [--check]');
96
+ process.exit(2);
97
+ }
98
+ const specPath = path.resolve(args[specIdx + 1]);
99
+ const check = args.includes('--check');
100
+ const specRel = path.relative(process.cwd(), specPath);
101
+
102
+ const markdown = fs.readFileSync(specPath, 'utf8');
103
+ const { contract, droppedSections } = splitContract(markdown);
104
+ const output = banner(specRel) + contract;
105
+
106
+ const slug = path.basename(specPath, '.md');
107
+ const outPath = path.join(path.dirname(specPath), 'generated', `${slug}.contract.md`);
108
+
109
+ if (check) {
110
+ if (!fs.existsSync(outPath)) {
111
+ console.error(`STALE: ${path.relative(process.cwd(), outPath)} does not exist. Run without --check.`);
112
+ process.exit(1);
113
+ }
114
+ const existing = fs.readFileSync(outPath, 'utf8');
115
+ if (existing !== output) {
116
+ console.error(
117
+ `STALE: ${path.relative(process.cwd(), outPath)} does not match ${specRel}.\n` +
118
+ 'The contract is generated — regenerate it rather than editing it.',
119
+ );
120
+ process.exit(1);
121
+ }
122
+ console.log(`OK: contract is current (${droppedSections} history sections excluded).`);
123
+ return;
124
+ }
125
+
126
+ fs.mkdirSync(path.dirname(outPath), { recursive: true });
127
+ fs.writeFileSync(outPath, output, 'utf8');
128
+ const pct = Math.round((1 - output.length / markdown.length) * 100);
129
+ console.log(
130
+ `wrote ${path.relative(process.cwd(), outPath)} — ${droppedSections} history sections excluded, ${pct}% smaller.`,
131
+ );
132
+ }
133
+
134
+ if (import.meta.url === `file://${process.argv[1]}` || process.argv[1]?.endsWith('generate-spec-contract.mjs')) {
135
+ main();
136
+ }
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "$schema": "./builtin-manifest.schema.json",
3
3
  "schemaVersion": 1,
4
- "generatedAt": "2026-07-25T08:30:40.747Z",
5
- "instarVersion": "1.3.955",
4
+ "generatedAt": "2026-07-25T09:37:20.372Z",
5
+ "instarVersion": "1.3.957",
6
6
  "entryCount": 202,
7
7
  "entries": {
8
8
  "hook:session-start": {
@@ -5,6 +5,10 @@
5
5
 
6
6
  ## What Changed
7
7
 
8
+ Added the dark, local-only capability-registry schema, validation funnel,
9
+ doorway/manifest and scan-state adapters, deterministic digest serializer,
10
+ status derivation, and atomic self-projection writer.
11
+
8
12
  The outbound tone gate's representation rules (B1–B14, B20–B21) now return an
9
13
  overridable **nudge** instead of a terminal block: the message comes back to the
10
14
  agent with the rule, a `decisionRef`, and both ways forward. The agent either
@@ -25,6 +29,9 @@ says so (`advisoryUnavailable`) rather than loosening for nothing.
25
29
 
26
30
  ## What to Tell Your User
27
31
 
32
+ This increment is intentionally unmounted: no route, peer traffic, mesh verb,
33
+ heartbeat emission, or routing consumer was added.
34
+
28
35
  ⚗️ **Experimental, and off unless you turn it on.** Most outbound checks become
29
36
  suggestions your agent can overrule — provided it writes down why, which is the
30
37
  whole point: those written reasons are what finally make it possible to measure
@@ -41,6 +48,10 @@ looser behaviour without the accountability that justifies it.
41
48
 
42
49
  ## Summary of New Capabilities
43
50
 
51
+ - Bounded v6 projection envelope with closed enums and width clamps.
52
+ - Real local doorway manifest and scan-state source adapters.
53
+ - Deterministic fact digest, conflict-aware status matrix, and atomic writer.
54
+
44
55
  - Representation rules resolve as overridable nudges carrying a `decisionRef`,
45
56
  with the override reason required and recorded.
46
57
  - Compliance is credited **server-side** when a revised message follows a nudge —
@@ -0,0 +1,54 @@
1
+ # Upgrade Guide — vNEXT
2
+
3
+ <!-- assembled-by: assemble-next-md -->
4
+ <!-- bump: patch -->
5
+
6
+ ## What Changed
7
+
8
+ Added `scripts/generate-spec-contract.mjs` — a build-time generator that emits
9
+ `docs/specs/generated/<slug>.contract.md` from a spec: the normative sections
10
+ only, with review-history sections and inline round-annotations stripped.
11
+
12
+ **Why.** A spec that honestly records its review accumulates change logs
13
+ describing designs that were later *reversed*. On
14
+ `outbound-gate-advisory-override` (33 review rounds), both external reviewers —
15
+ `codex-cli:gpt-5.5` and `gemini-cli:gemini-3.1-pro-preview` — independently
16
+ identified the same risk and proposed the same fix: an implementer reading the
17
+ document top-to-bottom can follow a retired design, so publish the contract
18
+ separately from the history.
19
+
20
+ `--check` fails the build when the committed contract does not match a fresh
21
+ generation, so the history cannot drift back into the contract over time.
22
+
23
+ The transform is deliberately mechanical — heading shapes mark history,
24
+ everything else is contract. A generator that had to *understand* the document
25
+ would drift out of step with it exactly as the document drifted out of step with
26
+ itself.
27
+
28
+ No runtime surface: no `src/` change, nothing installed to agent homes, no hook,
29
+ job or template references it. Nothing at runtime reads a spec.
30
+
31
+ ## What to Tell Your User
32
+
33
+ None — internal change (no user-facing surface).
34
+
35
+ ## Summary of New Capabilities
36
+
37
+ None — internal change (no user-facing surface).
38
+
39
+ ## Evidence
40
+
41
+ - Generated against the real 2,700-line spec: **36 history sections excluded,
42
+ 37% smaller output**.
43
+ - `--check` verified in both directions: exits 0 on a current contract, exits 1
44
+ with a regenerate message on a stale one.
45
+ - A regex leak was found and fixed during verification — `## 24. Round-11
46
+ external change log` was initially retained, because the heading text between
47
+ `Round-11` and `change log` was not matched. Caught by inspecting the generated
48
+ headings rather than trusting the run.
49
+ - Determinism confirmed by construction: no timestamps, no randomness, no
50
+ environment reads beyond the input path — which is what makes `--check` usable
51
+ in CI at all.
52
+ - Side-effects review: `upgrades/side-effects/spec-contract-generator.md`
53
+ (Tier 1; no decision point, no blocking authority, rollback is deleting two
54
+ files).
@@ -0,0 +1,7 @@
1
+ # Side-effects review: capability registry Increment 0
2
+
3
+ - Adds only a reusable core schema/reader/writer and unit fixtures.
4
+ - The durable file is unreferenced and local-only; no route or mesh surface is mounted.
5
+ - Remote ingest, heartbeat, freshness confirmation, and pool projection remain deferred.
6
+ - Review follow-up aligns scanStampSecs/scanState with the canonical doorway reader and keeps the writer local-only.
7
+ - Degradation reporting now makes corrupt local state explicit and recoverable.
@@ -0,0 +1,126 @@
1
+ # Side-effects review — spec contract generator
2
+
3
+ **Change:** adds `scripts/generate-spec-contract.mjs`, a build-time generator that
4
+ produces `docs/specs/generated/<slug>.contract.md` from a spec: the normative
5
+ sections only, with review history and inline round-annotations stripped.
6
+
7
+ **Tier:** 1 (declared). New standalone dev-tooling script; no runtime surface, no
8
+ `src/` change, no decision point. Signal-only in the strongest sense — it emits a
9
+ derived document and can refuse a stale check; it gates no agent behavior.
10
+
11
+ **Why it exists:** on the `outbound-gate-advisory-override` spec, both external
12
+ reviewers (codex-cli, gemini-cli) independently identified the same risk across
13
+ several rounds — a spec that honestly records 33 rounds of review accumulates
14
+ change logs describing designs that were later **reversed**, and an implementer
15
+ reading top-to-bottom can follow a retired design. Both proposed the same fix:
16
+ publish the contract separately from the history.
17
+
18
+ ---
19
+
20
+ ## 1. Over-block — what legitimate inputs does this reject that it shouldn't?
21
+
22
+ The generator's only refusal is `--check` failing when the committed contract does
23
+ not byte-match a fresh generation. That is the intended behavior (CI staleness
24
+ gate), and it is refusable-by-regeneration, not by argument.
25
+
26
+ **Real over-block risk identified:** the history-heading regex could classify a
27
+ *normative* section as history if someone titles one `## Round-trip validation` or
28
+ similar. Mitigated by requiring both a `Round-N` prefix **and** one of
29
+ `change log` / `hand-check` / `consistency sweep`, plus an `ALWAYS_CONTRACT_RE`
30
+ allowlist for the known normative section names. A false positive drops a section
31
+ from the generated contract — visible immediately as a missing section, not
32
+ silent.
33
+
34
+ ## 2. Under-block — what does it still miss?
35
+
36
+ - **Narrative history inside normative prose.** The generator strips history
37
+ *sections* and *inline annotations*; it cannot strip a paragraph of normative
38
+ prose that happens to narrate how a decision evolved. Those remain in the
39
+ contract. Partially addressed by the spec's own §0.2 "current design overview";
40
+ fully addressing it would require judgment the generator deliberately does not
41
+ have.
42
+ - **It does not verify the contract is CORRECT** — only that it is current. A
43
+ spec that is internally contradictory generates a contract that is equally
44
+ contradictory. The separate spec lint (required by the outbound spec) is what
45
+ addresses that; this is not it.
46
+
47
+ ## 3. Level-of-abstraction fit
48
+
49
+ Correct layer: it is a build-time document transform, alongside the other
50
+ `scripts/*.mjs` spec tooling (`write-convergence-tag.mjs`,
51
+ `eli16-overview-check.mjs`, `publish-spec-review.mjs`). It does not belong in
52
+ `src/` — nothing at runtime reads a spec.
53
+
54
+ **Should a higher layer own it?** `/spec-converge` could invoke it automatically
55
+ on convergence. Deliberately not wired that way in this change: the generator
56
+ should prove itself as a standalone tool first, and auto-invocation is a change to
57
+ the skill's contract, not to this script. Not deferred-and-forgotten — it is
58
+ simply not part of this change's scope, and the script is useful without it.
59
+
60
+ ## 4. Signal vs authority compliance
61
+
62
+ **Compliant, trivially.** The script holds no authority over agent behavior. Its
63
+ one enforcement surface (`--check` exiting non-zero) is a build-time staleness
64
+ assertion on a *derived artifact*, with a deterministic remedy (regenerate). It
65
+ makes no judgment, consults no model, and gates no message, session, or action.
66
+
67
+ ## 5. Interactions
68
+
69
+ - **Shadows nothing.** No existing script generates or validates a spec contract.
70
+ - **Shadowed by nothing.** It reads a spec and writes a derived file under
71
+ `docs/specs/generated/`, a path nothing else writes.
72
+ - **No double-fire, no race.** Single-shot CLI; no daemon, no watcher, no
73
+ scheduling.
74
+ - **Adjacent tooling unaffected:** `write-convergence-tag.mjs` and
75
+ `eli16-overview-check.mjs` read the *source* spec; this writes only the
76
+ generated copy. `hashSpecReviewableBody` (used for cross-model delta-gating)
77
+ also reads the source, so generated files never affect review gating.
78
+
79
+ ## 6. External surfaces
80
+
81
+ - **Other agents / users:** none. Dev tooling in the instar repo; not installed to
82
+ agent homes, not referenced by any hook, job, or template.
83
+ - **Timing / runtime conditions:** none — pure file in, file out.
84
+ - **New file paths introduced:** `docs/specs/generated/`. Additive; no existing
85
+ path changes meaning.
86
+
87
+ ## 7. Multi-machine posture (Cross-Machine Coherence)
88
+
89
+ **Machine-local BY DESIGN, and trivially so:** the script runs in a developer's
90
+ checkout and writes a file into that checkout, which is then committed and
91
+ distributed by git like any other source file. There is no runtime state, no
92
+ per-machine store, no notice, and no generated URL. Running it on two machines
93
+ against the same spec produces byte-identical output (the transform is pure and
94
+ deterministic — no timestamps, no randomness, no environment reads beyond the
95
+ input path).
96
+
97
+ That determinism is what makes the `--check` mode usable in CI at all, and it is
98
+ asserted by the mode's existence: if the transform were machine-sensitive, CI
99
+ would fail against a contract generated on a developer's machine.
100
+
101
+ ## 8. Rollback cost
102
+
103
+ **Near zero.** Delete the script and the generated directory; nothing depends on
104
+ either. No release, no migration, no agent-state repair. If the `--check` mode
105
+ turns out to be a nuisance in CI, it can be dropped independently of the
106
+ generator (the generator is useful without the check; the check is not useful
107
+ without the generator).
108
+
109
+ ---
110
+
111
+ ## Verification performed
112
+
113
+ - Generated against the real 2,700-line spec: 36 history sections excluded, 37%
114
+ smaller output.
115
+ - `--check` verified in both directions: passes on a current contract, fails with
116
+ a clear message on a stale one.
117
+ - Regex leak found and fixed during verification (`## 24. Round-11 external
118
+ change log` was initially retained because the heading text between `Round-11`
119
+ and `change log` was not matched) — caught by inspecting the generated
120
+ headings rather than trusting the run.
121
+
122
+ ## Second pass
123
+
124
+ **Not required.** The change touches no block/allow decision, no session
125
+ lifecycle, no coherence gate, and nothing named sentinel/guard/gate/watchdog. It
126
+ is a standalone document transform.