instar 1.3.2033 → 1.3.2034

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,63 @@
1
+ export interface SecurityPreflightFlags {
2
+ enabled: boolean;
3
+ sourceRoot: string | null;
4
+ }
5
+ export declare function securityPreflightFlags(config: unknown): SecurityPreflightFlags;
6
+ export interface SecurityPreflightRun {
7
+ slug: string;
8
+ sessionId: string;
9
+ sessionName: string;
10
+ runId: string;
11
+ machineId: string;
12
+ /** The actual dispatched prompt, kept byte-for-byte; never modified by this module. */
13
+ prompt: string;
14
+ }
15
+ export interface PacketChunk {
16
+ offset: number;
17
+ bytes: number;
18
+ sha256: string;
19
+ base64: string;
20
+ }
21
+ export interface PacketSource {
22
+ name: string;
23
+ bytes: number;
24
+ sha256: string;
25
+ chunks: PacketChunk[];
26
+ }
27
+ export interface SecurityPreflightPacket {
28
+ version: 1;
29
+ evidenceOnly: true;
30
+ packetId: string;
31
+ createdAt: string;
32
+ binding: Omit<SecurityPreflightRun, 'prompt'>;
33
+ sourceRootHash: string;
34
+ coverage: 'complete-declared-inputs';
35
+ preflight: {
36
+ lastPass: number;
37
+ nextPass: number;
38
+ codeTree: 'not-captured';
39
+ modelReachability: 'not-probed';
40
+ delivery: 'not-proven';
41
+ semanticReview: 'not-proven';
42
+ };
43
+ sources: PacketSource[];
44
+ }
45
+ export type SecurityPreflightResult = {
46
+ status: 'disabled' | 'busy' | 'unavailable' | 'recorded';
47
+ reason: string;
48
+ packetId?: string;
49
+ };
50
+ export declare function packetSource(name: string, bytes: Buffer): PacketSource;
51
+ /** A strict local consumer can verify coverage without interpreting Markdown or UTF-8 chunks. */
52
+ export declare function verifyPacketSource(source: PacketSource): Buffer | null;
53
+ export declare class SecurityReviewPreflight {
54
+ private readonly options;
55
+ private busy;
56
+ constructor(options: {
57
+ stateDir: string;
58
+ flags: () => SecurityPreflightFlags;
59
+ canWrite: () => boolean;
60
+ });
61
+ capture(run: SecurityPreflightRun): Promise<SecurityPreflightResult>;
62
+ }
63
+ //# sourceMappingURL=SecurityReviewPreflight.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SecurityReviewPreflight.d.ts","sourceRoot":"","sources":["../../src/scheduler/SecurityReviewPreflight.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,sBAAsB;IAAG,OAAO,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE;AACvF,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,sBAAsB,CAK9E;AACD,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IACvF,uFAAuF;IACvF,MAAM,EAAE,MAAM,CAAC;CAChB;AACD,MAAM,WAAW,WAAW;IAAG,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AAC9F,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,WAAW,EAAE,CAAC;CACpE;AACD,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,CAAC,CAAC;IAAC,YAAY,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IACpE,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IACtE,QAAQ,EAAE,0BAA0B,CAAC;IACrC,SAAS,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,cAAc,CAAC;QACxE,iBAAiB,EAAE,YAAY,CAAC;QAAC,QAAQ,EAAE,YAAY,CAAC;QAAC,cAAc,EAAE,YAAY,CAAA;KAAE,CAAC;IAC1F,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB;AACD,MAAM,MAAM,uBAAuB,GAAG;IAAE,MAAM,EAAE,UAAU,GAAG,MAAM,GAAG,aAAa,GAAG,UAAU,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtI,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,CAOtE;AAED,iGAAiG;AACjG,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,GAAG,IAAI,CAatE;AAED,qBAAa,uBAAuB;IAEtB,OAAO,CAAC,QAAQ,CAAC,OAAO;IADpC,OAAO,CAAC,IAAI,CAAS;IACrB,YAA6B,OAAO,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,sBAAsB,CAAC;QAAC,QAAQ,EAAE,MAAM,OAAO,CAAA;KAAE,EAAI;IAEtH,OAAO,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA8FzE;CACF"}
@@ -0,0 +1,185 @@
1
+ /** Evidence only. This module has no admission, read-suppression or model authority. */
2
+ import fs from 'node:fs/promises';
3
+ import { constants } from 'node:fs';
4
+ import path from 'node:path';
5
+ import { createHash, randomUUID } from 'node:crypto';
6
+ import { SafeFsExecutor } from '../core/SafeFsExecutor.js';
7
+ const FILE_LIMIT = 4 * 1024 * 1024;
8
+ const TOTAL_LIMIT = 8 * 1024 * 1024;
9
+ const CHUNK_SIZE = 16 * 1024;
10
+ const PACKET_LIMIT = 16;
11
+ const OWNED_NAME = /^packet-[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}\.json$/;
12
+ const sha = (b) => createHash('sha256').update(b).digest('hex');
13
+ const object = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
14
+ export function securityPreflightFlags(config) {
15
+ const jobs = object(config) && object(config.jobs) ? config.jobs : {};
16
+ const flag = object(jobs.securityReviewPreflight) ? jobs.securityReviewPreflight : {};
17
+ return { enabled: flag.enabled === true, sourceRoot: typeof flag.sourceRoot === 'string'
18
+ && path.isAbsolute(flag.sourceRoot) ? path.resolve(flag.sourceRoot) : null };
19
+ }
20
+ export function packetSource(name, bytes) {
21
+ const chunks = [];
22
+ for (let offset = 0; offset < bytes.length; offset += CHUNK_SIZE) {
23
+ const chunk = bytes.subarray(offset, offset + CHUNK_SIZE);
24
+ chunks.push({ offset, bytes: chunk.length, sha256: sha(chunk), base64: chunk.toString('base64') });
25
+ }
26
+ return { name, bytes: bytes.length, sha256: sha(bytes), chunks };
27
+ }
28
+ /** A strict local consumer can verify coverage without interpreting Markdown or UTF-8 chunks. */
29
+ export function verifyPacketSource(source) {
30
+ if (!object(source) || !Number.isSafeInteger(source.bytes) || source.bytes < 0 || source.bytes > FILE_LIMIT || !Array.isArray(source.chunks) || source.chunks.length > Math.ceil(FILE_LIMIT / CHUNK_SIZE))
31
+ return null;
32
+ let offset = 0;
33
+ const buffers = [];
34
+ for (const [index, c] of source.chunks.entries()) {
35
+ if (!object(c) || typeof c.base64 !== 'string' || c.base64.length > Math.ceil(CHUNK_SIZE / 3) * 4)
36
+ return null;
37
+ const b = Buffer.from(c.base64, 'base64');
38
+ if (b.toString('base64') !== c.base64 || c.offset !== offset || c.bytes !== b.length || b.length === 0
39
+ || b.length > CHUNK_SIZE || (index < source.chunks.length - 1 && b.length !== CHUNK_SIZE) || sha(b) !== c.sha256)
40
+ return null;
41
+ buffers.push(b);
42
+ offset += b.length;
43
+ if (offset > source.bytes)
44
+ return null;
45
+ }
46
+ const b = Buffer.concat(buffers);
47
+ return offset === source.bytes && sha(b) === source.sha256 ? b : null;
48
+ }
49
+ export class SecurityReviewPreflight {
50
+ options;
51
+ busy = false;
52
+ constructor(options) {
53
+ this.options = options;
54
+ }
55
+ async capture(run) {
56
+ // Off means no filesystem access, including existence checks or mkdir.
57
+ const flags = { ...this.options.flags() };
58
+ run = { ...run };
59
+ if (!flags.enabled || run.slug !== 'security-review')
60
+ return { status: 'disabled', reason: 'off' };
61
+ if (this.busy)
62
+ return { status: 'busy', reason: 'capture-in-flight' };
63
+ if (!flags.sourceRoot)
64
+ return { status: 'unavailable', reason: 'source-root-required' };
65
+ this.busy = true;
66
+ let temporary;
67
+ try {
68
+ if (!this.options.canWrite() || [run.sessionId, run.runId, run.sessionName, run.machineId].some(v => typeof v !== 'string' || v.length === 0 || v.length > 256)
69
+ || Buffer.byteLength(run.prompt) > FILE_LIMIT)
70
+ throw new Error('unavailable');
71
+ const stateRoot = await fs.realpath(this.options.stateDir);
72
+ const sourceRoot = await fs.realpath(flags.sourceRoot);
73
+ const specs = [
74
+ { name: 'findings-ledger', file: path.join(stateRoot, 'state/security/private/findings.md') },
75
+ { name: 'threat-map', file: path.join(sourceRoot, 'docs/security/threat-map.md') },
76
+ { name: 'rotation-state', file: path.join(stateRoot, 'state/security/review-state.json') },
77
+ ];
78
+ const snapshots = [];
79
+ let total = Buffer.byteLength(run.prompt);
80
+ for (const spec of specs) {
81
+ // Never follow an installed input symlink into an unrelated file.
82
+ if (await fs.realpath(spec.file) !== spec.file)
83
+ throw new Error('unavailable');
84
+ const handle = await fs.open(spec.file, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
85
+ try {
86
+ const before = await handle.stat();
87
+ if (!before.isFile() || before.size > FILE_LIMIT)
88
+ throw new Error('unavailable');
89
+ total += before.size;
90
+ if (total > TOTAL_LIMIT)
91
+ throw new Error('unavailable');
92
+ const bytes = Buffer.alloc(before.size);
93
+ let offset = 0;
94
+ while (offset < bytes.length) {
95
+ const read = await handle.read(bytes, offset, Math.min(64 * 1024, bytes.length - offset), offset);
96
+ if (read.bytesRead === 0)
97
+ throw new Error('unavailable');
98
+ offset += read.bytesRead;
99
+ }
100
+ const fingerprint = (s) => [s.dev, s.ino, s.birthtimeMs, s.size, s.mtimeMs, s.ctimeMs].join(':');
101
+ const expected = fingerprint(before);
102
+ if (fingerprint(await handle.stat()) !== expected)
103
+ throw new Error('unavailable');
104
+ snapshots.push({ ...spec, fingerprint: expected, bytes });
105
+ }
106
+ finally {
107
+ await handle.close();
108
+ }
109
+ }
110
+ const rotation = JSON.parse(snapshots[2].bytes.toString('utf8'));
111
+ if (!object(rotation) || !Number.isInteger(rotation.lastPass) || Number(rotation.lastPass) < 0 || Number(rotation.lastPass) > 3)
112
+ throw new Error('unavailable');
113
+ const sources = snapshots.map(s => packetSource(s.name, s.bytes));
114
+ sources.push(packetSource('dispatched-prompt', Buffer.from(run.prompt)));
115
+ // Recheck every input after all reads; never claim a cross-file stable window from individual reads alone.
116
+ for (const source of snapshots) {
117
+ const stat = await fs.lstat(source.file);
118
+ if (!stat.isFile() || [stat.dev, stat.ino, stat.birthtimeMs, stat.size, stat.mtimeMs, stat.ctimeMs].join(':') !== source.fingerprint
119
+ || await fs.realpath(source.file) !== source.file)
120
+ throw new Error('unavailable');
121
+ }
122
+ const { prompt: _prompt, ...binding } = run;
123
+ const packet = { version: 1, evidenceOnly: true, packetId: randomUUID(),
124
+ createdAt: new Date().toISOString(), binding, sourceRootHash: sha(sourceRoot), coverage: 'complete-declared-inputs',
125
+ preflight: { lastPass: Number(rotation.lastPass), nextPass: Number(rotation.lastPass) % 3 + 1,
126
+ codeTree: 'not-captured', modelReachability: 'not-probed', delivery: 'not-proven', semanticReview: 'not-proven' }, sources };
127
+ const dir = path.join(stateRoot, 'state/security/private/review-packets');
128
+ // Private source content must not be persisted underneath a symlink or a permissive private parent.
129
+ const parent = path.dirname(dir);
130
+ const parentStat = await fs.lstat(parent);
131
+ if (!parentStat.isDirectory() || await fs.realpath(parent) !== parent || (parentStat.mode & 0o077) !== 0)
132
+ throw new Error('unavailable');
133
+ if (!this.options.canWrite())
134
+ throw new Error('unavailable');
135
+ await fs.mkdir(dir, { mode: 0o700, recursive: true });
136
+ if (!(await fs.lstat(dir)).isDirectory() || await fs.realpath(dir) !== dir)
137
+ throw new Error('unavailable');
138
+ await fs.chmod(dir, 0o700);
139
+ const entries = [];
140
+ const directory = await fs.opendir(dir);
141
+ for await (const entry of directory) {
142
+ entries.push(entry.name);
143
+ if (entries.length > 128)
144
+ throw new Error('unavailable');
145
+ }
146
+ const owned = [];
147
+ for (const name of entries.filter(n => OWNED_NAME.test(n))) {
148
+ const file = path.join(dir, name);
149
+ const stat = await fs.lstat(file);
150
+ if (stat.isFile())
151
+ owned.push({ file, mtime: stat.mtimeMs });
152
+ }
153
+ // Class-B derived evidence: keep16 private packets, never touch source ledger or unknown files.
154
+ owned.sort((a, b) => a.mtime - b.mtime);
155
+ while (owned.length >= PACKET_LIMIT) {
156
+ if (!this.options.canWrite())
157
+ throw new Error('unavailable');
158
+ await SafeFsExecutor.safeUnlink(owned.shift().file, { operation: 'SecurityReviewPreflight:retention' });
159
+ }
160
+ const final = path.join(dir, `packet-${packet.packetId}.json`);
161
+ temporary = path.join(dir, `packet-${packet.packetId}.tmp`);
162
+ await fs.writeFile(temporary, JSON.stringify(packet), { flag: 'wx', mode: 0o600 });
163
+ const current = this.options.flags();
164
+ if (!current.enabled || current.sourceRoot !== flags.sourceRoot || !this.options.canWrite())
165
+ throw new Error('unavailable');
166
+ await fs.rename(temporary, final);
167
+ temporary = undefined;
168
+ return { status: 'recorded', reason: 'complete-declared-inputs-evidence-only', packetId: packet.packetId };
169
+ }
170
+ catch {
171
+ // @silent-fallback-ok — diagnostic packet failure never changes normal review or exposes private content.
172
+ return { status: 'unavailable', reason: 'inputs-or-storage-unavailable' };
173
+ }
174
+ finally {
175
+ if (temporary) {
176
+ try {
177
+ await SafeFsExecutor.safeUnlink(temporary, { operation: 'SecurityReviewPreflight:failed-capture' });
178
+ }
179
+ catch { /* @silent-fallback-ok — exact owned private temp retained on cleanup failure; never read as a packet. */ }
180
+ }
181
+ this.busy = false;
182
+ }
183
+ }
184
+ }
185
+ //# sourceMappingURL=SecurityReviewPreflight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SecurityReviewPreflight.js","sourceRoot":"","sources":["../../src/scheduler/SecurityReviewPreflight.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,MAAM,UAAU,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AACnC,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AACpC,MAAM,UAAU,GAAG,EAAE,GAAG,IAAI,CAAC;AAC7B,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,UAAU,GAAG,oFAAoF,CAAC;AACxG,MAAM,GAAG,GAAG,CAAC,CAAkB,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACjF,MAAM,MAAM,GAAG,CAAC,CAAU,EAAgC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAG/G,MAAM,UAAU,sBAAsB,CAAC,MAAe;IACpD,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,M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AC5H,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;YAAC,SAAS,GAAG,SAAS,CAAC;YACzD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,wCAAwC,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC;QAC7G,CAAC;QAAC,MAAM,CAAC;YACP,0GAA0G;YAC1G,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,+BAA+B,EAAE,CAAC;QAC5E,CAAC;gBAAS,CAAC;YACT,IAAI,SAAS,EAAE,CAAC;gBACd,IAAI,CAAC;oBAAC,MAAM,cAAc,CAAC,UAAU,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,wCAAwC,EAAE,CAAC,CAAC;gBAAC,CAAC;gBAC5G,MAAM,CAAC,CAAC,yGAAyG,CAAC,CAAC;YACrH,CAAC;YACD,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;QACpB,CAAC;IACH,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instar",
3
- "version": "1.3.2033",
3
+ "version": "1.3.2034",
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,6 @@
1
+ ---
2
+ title: Security review evidence packets
3
+ ---
4
+ Security review can capture a private full-input evidence packet after a normal session starts. `jobs.securityReviewPreflight.enabled` defaults to false. An explicit absolute `sourceRoot` names the source checkout whose threat map is captured. Updates do not activate it. The original prompt, source reads, model selection and review schedule remain unchanged.
5
+
6
+ The packet includes every byte of the findings ledger, threat map, rotation state and dispatched prompt, in verifiable bounded chunks. It is local to the source machine under `.instar/state/security/private/review-packets/`. It does not prove delivery, retained context, code-tree coverage, model reachability or review quality. Missing/changing inputs or storage failure leave normal review running. Never use this evidence-only packet to suppress a source read or security review, and never post its private content publicly.
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "$schema": "./builtin-manifest.schema.json",
3
3
  "schemaVersion": 1,
4
- "generatedAt": "2026-11-25T07:12:22.252Z",
5
- "instarVersion": "1.3.2033",
4
+ "generatedAt": "2026-11-25T10:43:53.315Z",
5
+ "instarVersion": "1.3.2034",
6
6
  "entryCount": 210,
7
7
  "entries": {
8
8
  "hook:session-start": {
@@ -1636,7 +1636,7 @@
1636
1636
  "type": "subsystem",
1637
1637
  "domain": "scheduling",
1638
1638
  "sourcePath": "src/scheduler/JobScheduler.ts",
1639
- "contentHash": "79471cbacf7d5dd539838c4a20a310d945f6e47c65b05cf30457d242876f621a",
1639
+ "contentHash": "62cdff1482aa32ef310613e1d015696d5a6097ff02d620fb5382215748197862",
1640
1640
  "since": "2025-01-01"
1641
1641
  },
1642
1642
  "subsystem:project-mapper": {
@@ -2,7 +2,7 @@
2
2
  "schemaVersion": 1,
3
3
  "generatedFrom": "source-tree",
4
4
  "registrySha256": "11e2a45ab1345e2ded6499404ee9962e4e48bcfed4677a4d31dac4492565d2fa",
5
- "packageVersion": "1.3.2033",
5
+ "packageVersion": "1.3.2034",
6
6
  "guards": [
7
7
  {
8
8
  "ref": "docs/audits/phase-b/f10-triage.md",
@@ -1,5 +1,5 @@
1
1
  {
2
- "sha256": "6cdb274648a7d400e2422f0967149406f522f529d792a2827ebdb4fe5e087c67",
2
+ "sha256": "36862ac0230a268aad27beaec790a13c4622bda76704299e6935125b7a180980",
3
3
  "registrySha256": "11e2a45ab1345e2ded6499404ee9962e4e48bcfed4677a4d31dac4492565d2fa",
4
- "packageVersion": "1.3.2033"
4
+ "packageVersion": "1.3.2034"
5
5
  }
@@ -2,5 +2,5 @@
2
2
  "sha256": "11e2a45ab1345e2ded6499404ee9962e4e48bcfed4677a4d31dac4492565d2fa",
3
3
  "articleCount": 102,
4
4
  "generatedFrom": "docs/STANDARDS-REGISTRY.md",
5
- "packageVersion": "1.3.2033"
5
+ "packageVersion": "1.3.2034"
6
6
  }
@@ -4,6 +4,24 @@
4
4
  "censusDate": "2026-06-05",
5
5
  "sourceDoc": "docs/specs/STATE-COHERENCE-REGISTRY.md",
6
6
  "entries": [
7
+ {
8
+ "category": "security-review-preflight-packets",
9
+ "description": "Private, bounded, machine-local full declared-input snapshots for evidence-only security-review diagnostics. They certify neither model consumption nor semantic review; source ledger is never modified.",
10
+ "scope": "machine-local",
11
+ "freshness": "session-boundary",
12
+ "conflictShape": "single-writer",
13
+ "transport": "none",
14
+ "paths": [
15
+ "state/security/private/review-packets/"
16
+ ],
17
+ "grandfathered": false,
18
+ "retention": {
19
+ "class": "B",
20
+ "access": "bounded",
21
+ "maxEntries": 16,
22
+ "note": "Keep at most16 complete owned UUID packets (up to8MiB source bytes per packet); remove only oldest owned derived packets. Unknown/partial artifacts are never consumed; enumeration over128 entries refuses capture. These are never the sole record of a finding."
23
+ }
24
+ },
7
25
  {
8
26
  "category": "attribution-ledger",
9
27
  "description": "Append-only history of claims credited to a person: wording, verdict, source ref and lineage. Rotated into kept gzip archives, never deleted. One writer per machine; a trace merges every machine's rows on read.",
@@ -0,0 +1,20 @@
1
+ # Upgrade Guide — vNEXT
2
+
3
+ <!-- assembled-by: assemble-next-md -->
4
+ <!-- bump: patch -->
5
+
6
+ ## What Changed
7
+
8
+ Added a default-off, evidence-only security-review preflight. After a normal session starts, it can privately capture complete versioned chunks of the findings ledger, selected threat map, rotation state and dispatched prompt. Capture never changes review admission, prompt, model, required reads or completion. Missing/changing inputs and storage errors leave ordinary review intact.
9
+
10
+ ## What to Tell Your User
11
+
12
+ This update adds a disabled diagnostic for future work on repeated security-review context. It does not skip reviews, suppress reads or turn on any token-saving change.
13
+
14
+ ## Summary of New Capabilities
15
+
16
+ Optional private full-input packets for security-review, configured with `jobs.securityReviewPreflight.enabled` and an explicit absolute `sourceRoot`. Both delivery and review remain unproven by these packets.
17
+
18
+ ## Evidence
19
+
20
+ Focused unit, HTTP and production-shaped restart tests cover complete byte coverage, changed/missing inputs, privacy, bounds and normal model-session behavior. Complete verification is assigned to throughput. No live configuration change or realized savings is claimed. Design and ELI16: docs/specs/security-review-preflight.md and its .eli16.md companion.
@@ -0,0 +1,73 @@
1
+ # Side-Effects Review — Security Review Evidence Preflight
2
+
3
+ **Version / slug:** security-review-preflight
4
+ **Date:** 2026-11-23
5
+ **Author:** echo
6
+ **Second-pass reviewer:** review_connector_reads, independent read-only source review
7
+
8
+ ## Summary of the change
9
+
10
+ Tier1 reversible default-off diagnostic. Adds SecurityReviewPreflight, detached JobScheduler wiring, awareness/state declarations, tests and documentation. It writes complete private declared-input packets after the normal session/run exists; it never changes prompt, model/account routing, reads, review admission or completion. A revert restores prior behavior with inert derived files. This is a SMALL build with one independent review plus correction of an actual validator finding; normal commit gates and complete throughput verification still apply. Size is recorded in the commit trace; there is no formal spec-convergence claim or live activation.
11
+
12
+ ## Decision-point inventory
13
+
14
+ - Literal enabled flag and explicit sourceRoot — add, diagnostics only; absence/invalid config preserves normal review.
15
+ - Stable bounded input/coverage checks — add, determine whether evidence is available, never whether an agent may review or read.
16
+ - Private output permissions, role/flag narrowing and retention — add, restrict only diagnostic writes.
17
+ - Existing model spawn, original prompt, reads, security semantics and completion — pass through without a new await or session.
18
+
19
+ ## 1. Over-block
20
+
21
+ No security review, source read or agent action is blocked. Missing/changing inputs, unsupported rotation values, oversize sources, wrong permissions and unavailable storage decline a packet while the normal session proceeds. Output privacy intentionally refuses a permissive/symlink private directory. Full source text is retained, including duplicate Markdown headings, old findings and mixed statuses; there is no regex active-only summary.
22
+
23
+ ## 2. Under-block
24
+
25
+ A complete packet proves only coverage of its four declared inputs during a checked snapshot window. It does not prove actual delivery, retained context, code-tree coverage, model availability, semantic judgment, successful review or upstream completeness. All those unknowns remain explicit. Sources may change after the snapshot, and the model may update rotation during detached capture; that is not permission to skip anything. Trusted local filesystem/config access remains the trust boundary; this is not a defense against an actor able to rewrite all agent state.
26
+
27
+ ## 3. Level-of-abstraction fit
28
+
29
+ The scheduler knows the actual dispatched prompt, run and returned session. It is therefore the right producer of run-bound evidence. The private ledger remains the finding authority and the model remains the review authority. This module neither interprets statuses nor supplies read-suppression instructions. It uses existing SafeFsExecutor for exact owned derived-file retention and the existing awareness registry update path.
30
+
31
+ ## 4. Signal vs authority compliance
32
+
33
+ Required reference: docs/signal-vs-authority.md. This is a signal producer without blocking authority. It cannot skip a model session, advance a rotation/bookmark, suppress a source read, certify a finding or route a model. Its status is scalar optional telemetry; diagnostics fail independently of the launched job.
34
+
35
+ ## 5. Cascade / interaction analysis
36
+
37
+ Ordering: capture starts only after normal spawn and run binding/bookkeeping. Its Promise is detached and both rejection and telemetry errors are contained. Slow IO cannot hold ordinary trigger/completion or add a session. One capture is in flight per scheduler instance. Snapshot checks cover ordinary file identity and stability across all reads; symlink inputs/output are refused. Flags and write authority are rechecked before publication. No timer, retry, re-drive, notification or new model helper is introduced. The module snapshots caller binding/config values so outside alias mutation cannot change a capture in progress.
38
+
39
+ Source reads use bounded asynchronous file handles. Limits are4MiB per input,8MiB raw total,16KiB chunks and128 output-directory entries. Complete owned UUIDv4 packets are retained to16; unknown files and incomplete crash artifacts are never treated as evidence. Enumeration overflow makes diagnostics unavailable. The export verifier now rejects malformed/null sources/chunks, excessive chunk counts, non-final short chunks, gaps, duplicates, noncanonical base64 and hash mismatches before unbounded buffer allocation.
40
+
41
+ ## 6. External surfaces
42
+
43
+ No subprocess, external API, model call, public route or operator action is added. No live config/job/schedule is edited. Packet content is private: existing private parent must be0700, own directory0700, packet/temp0600; output is atomic and exact failed temp cleanup is attempted. Events contain only status, fixed reason, run and packet ids, never text, source paths or raw errors. Private source ledger, map and rotation are never written by this feature.
44
+
45
+ New and existing agents receive awareness through the existing awareness registry/update pipeline. The new flag is absent/off without any activating migration. No installed hook/script or default config change requires a dedicated migration.
46
+
47
+ ## 6b. Operator-surface quality
48
+
49
+ No operator-facing action or UI surface is added. There is no new approval/configuration form or read-suppression control.
50
+
51
+ ## 7. Multi-machine posture
52
+
53
+ Machine-local by design: the packet names an actual local launched run and snapshots local source inputs. It is not replicated and does not grant another machine coverage or read-suppression authority. Failover continues normal security review with the feature off unless explicitly configured locally. No one-voice outbound channel or transferable user-facing URL is introduced.
54
+
55
+ ## 8. Rollback cost
56
+
57
+ Disable the flag or revert the code. Existing derived packets are inert; no data repair, source rewrite or external rollback is necessary. Retention only removes owned Class-B diagnostic copies, never the sole findings ledger or any unknown artifact.
58
+
59
+ ## Conclusion
60
+
61
+ The approved evidence-only stage is complete behind a default-off flag. Review found a malformed-chunk validator gap, which now has structural bounds and regression tests. Two initial test-harness assumptions were corrected: macOS canonical temporary paths and waiting for normal asynchronous spawn bookkeeping. These were not presented as production defects. Focused tests and normal lint/commit gates establish the targeted behavior; complete-suite results must come from throughput. No live installation, read suppression or realized savings is claimed.
62
+
63
+ ## Second-pass review (if required)
64
+
65
+ Reviewer: review_connector_reads. Initial review found missing malformed-chunk/count checks. The reviewer re-read the corrected source, spec, ELI16 and artifact and concurred, with no remaining blocking findings. The reviewer ran no tests and inspected no live ledger.
66
+
67
+ ## Evidence pointers
68
+
69
+ New unit tests: security-review-preflight.test.ts and security-preflight-scheduler.test.ts. HTTP: security-preflight-routes.test.ts. Lifecycle: security-preflight-alive.test.ts. Worktree .instar/state/build contains unit-commit.log, integration-final.log, lifecycle-final.log and lint/commit logs. Full test:all goes through throughput.
70
+
71
+ ## Class-Closure Declaration (display-only mirror)
72
+
73
+ No agent-authored-artifact defect is being repaired. This is one diagnostic call attached to an already-authorized normal spawn, with no self-triggered loop, retry, recovery, re-drive or additional spawn. For the detector's scheduler notification/spawn vocabulary, declare defectClass unbounded-self-action, closure n/a, reason: the existing scheduler remains the only controller; the new code only captures one bounded evidence packet per normal launch and cannot trigger another action. There is no convergence claim for a nonexistent new controller.