instar 1.2.43 → 1.2.44

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.
@@ -174,6 +174,74 @@ export class SafeFsExecutor {
174
174
  throw err;
175
175
  }
176
176
  }
177
+ // ── Atomic write ────────────────────────────────────────────────────
178
+ //
179
+ // Crash-safe file writes for file-backed state. The failure these prevent:
180
+ // a direct `fs.writeFileSync` truncates the target THEN writes; if the
181
+ // process crashes (or the disk fills) mid-write, the file is left
182
+ // truncated or partially written — and for append-only event logs / JSON
183
+ // state, that means silent data loss when the next reader hits a parse
184
+ // error and falls back to an empty skeleton.
185
+ //
186
+ // The pattern: write to a sibling temp file in the SAME directory (so the
187
+ // rename stays on one filesystem and is therefore atomic per POSIX),
188
+ // fsync the data to durable storage, then rename over the target. A crash
189
+ // at any point leaves EITHER the old file intact OR the fully-written new
190
+ // file — never a half-written one.
191
+ //
192
+ // Cherry-picked into Instar 2026-05-23 from the GSD-Instar integration
193
+ // spike (gsd-executor Rule 2 finding: file-backed state lacked atomic
194
+ // writes). Not a destructive op, so it does not go through the
195
+ // source-tree guard — but it lives here as the natural home for safe-fs
196
+ // primitives and shares the audit trail.
197
+ /**
198
+ * Atomically write a string to `target`. Writes to a temp sibling, fsyncs,
199
+ * then renames over the target. Creates parent directories if missing.
200
+ */
201
+ static atomicWriteFileSync(target, data, opts) {
202
+ const operation = opts?.operation ?? 'atomicWriteFileSync';
203
+ const resolved = path.resolve(target);
204
+ const dir = path.dirname(resolved);
205
+ // Ensure parent dir exists (matches the convenience of writeFileSync callers
206
+ // who often forget mkdir).
207
+ fs.mkdirSync(dir, { recursive: true });
208
+ // Temp file in the SAME directory so rename is atomic (same filesystem).
209
+ const tmp = path.join(dir, `.${path.basename(resolved)}.${process.pid}.${Date.now()}.tmp`);
210
+ let fd;
211
+ try {
212
+ fd = fs.openSync(tmp, 'w', opts?.mode ?? 0o644);
213
+ fs.writeSync(fd, data);
214
+ fs.fsyncSync(fd); // flush data to durable storage before rename
215
+ fs.closeSync(fd);
216
+ fd = undefined;
217
+ fs.renameSync(tmp, resolved); // atomic replace
218
+ audit('atomicWriteFileSync', operation, resolved, 'allowed');
219
+ }
220
+ catch (err) {
221
+ // Best-effort cleanup of the temp file; never mask the original error.
222
+ try {
223
+ if (fd !== undefined)
224
+ fs.closeSync(fd);
225
+ }
226
+ catch { /* ignore */ }
227
+ try {
228
+ if (fs.existsSync(tmp))
229
+ fs.unlinkSync(tmp);
230
+ }
231
+ catch { /* ignore */ }
232
+ audit('atomicWriteFileSync', operation, resolved, 'denied', `write-error: ${err.message}`);
233
+ throw err;
234
+ }
235
+ }
236
+ /**
237
+ * Atomically write `value` as pretty-printed JSON to `target`.
238
+ * Convenience wrapper around atomicWriteFileSync — the common case for
239
+ * Instar's `.instar/state/*.json` files.
240
+ */
241
+ static atomicWriteJsonSync(target, value, opts) {
242
+ const json = JSON.stringify(value, null, opts?.indent ?? 2);
243
+ this.atomicWriteFileSync(target, json, { operation: opts?.operation ?? 'atomicWriteJsonSync', mode: opts?.mode });
244
+ }
177
245
  }
178
246
  // Re-export the guard error so call-site catch blocks don't have to import
179
247
  // from two modules.
@@ -1 +1 @@
1
- {"version":3,"file":"SafeFsExecutor.js","sourceRoot":"","sources":["../../src/core/SafeFsExecutor.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,QAAQ,IAAI,GAAG,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAUxD,SAAS,kBAAkB;IACzB,MAAM,CAAC,GAAG,IAAI,KAAK,EAAE,CAAC;IACtB,MAAM,KAAK,GAAG,CAAC,CAAC,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44",
4
4
  "description": "Persistent autonomy infrastructure for AI agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "$schema": "./builtin-manifest.schema.json",
3
3
  "schemaVersion": 1,
4
- "generatedAt": "2026-05-23T03:49:24.867Z",
5
- "instarVersion": "1.2.43",
4
+ "generatedAt": "2026-05-23T03:52:30.990Z",
5
+ "instarVersion": "1.2.44",
6
6
  "entryCount": 191,
7
7
  "entries": {
8
8
  "hook:session-start": {
@@ -11,7 +11,7 @@
11
11
  "domain": "identity",
12
12
  "sourcePath": "src/core/PostUpdateMigrator.ts",
13
13
  "installedPath": ".instar/hooks/instar/session-start.sh",
14
- "contentHash": "66f1de9704cc6bebfa8e551f195202455902abfbe309fe53faa9fe10b5138f9f",
14
+ "contentHash": "2a4639dfdecd37347736d04e008f4a201cd17e9660fa1584df2a43dae2d7e4be",
15
15
  "since": "2025-01-01"
16
16
  },
17
17
  "hook:dangerous-command-guard": {
@@ -20,7 +20,7 @@
20
20
  "domain": "safety",
21
21
  "sourcePath": "src/core/PostUpdateMigrator.ts",
22
22
  "installedPath": ".instar/hooks/instar/dangerous-command-guard.sh",
23
- "contentHash": "66f1de9704cc6bebfa8e551f195202455902abfbe309fe53faa9fe10b5138f9f",
23
+ "contentHash": "2a4639dfdecd37347736d04e008f4a201cd17e9660fa1584df2a43dae2d7e4be",
24
24
  "since": "2025-01-01"
25
25
  },
26
26
  "hook:grounding-before-messaging": {
@@ -29,7 +29,7 @@
29
29
  "domain": "safety",
30
30
  "sourcePath": "src/core/PostUpdateMigrator.ts",
31
31
  "installedPath": ".instar/hooks/instar/grounding-before-messaging.sh",
32
- "contentHash": "66f1de9704cc6bebfa8e551f195202455902abfbe309fe53faa9fe10b5138f9f",
32
+ "contentHash": "2a4639dfdecd37347736d04e008f4a201cd17e9660fa1584df2a43dae2d7e4be",
33
33
  "since": "2025-01-01"
34
34
  },
35
35
  "hook:compaction-recovery": {
@@ -38,7 +38,7 @@
38
38
  "domain": "identity",
39
39
  "sourcePath": "src/core/PostUpdateMigrator.ts",
40
40
  "installedPath": ".instar/hooks/instar/compaction-recovery.sh",
41
- "contentHash": "66f1de9704cc6bebfa8e551f195202455902abfbe309fe53faa9fe10b5138f9f",
41
+ "contentHash": "2a4639dfdecd37347736d04e008f4a201cd17e9660fa1584df2a43dae2d7e4be",
42
42
  "since": "2025-01-01"
43
43
  },
44
44
  "hook:external-operation-gate": {
@@ -47,7 +47,7 @@
47
47
  "domain": "safety",
48
48
  "sourcePath": "src/core/PostUpdateMigrator.ts",
49
49
  "installedPath": ".instar/hooks/instar/external-operation-gate.js",
50
- "contentHash": "66f1de9704cc6bebfa8e551f195202455902abfbe309fe53faa9fe10b5138f9f",
50
+ "contentHash": "2a4639dfdecd37347736d04e008f4a201cd17e9660fa1584df2a43dae2d7e4be",
51
51
  "since": "2025-01-01"
52
52
  },
53
53
  "hook:deferral-detector": {
@@ -56,7 +56,7 @@
56
56
  "domain": "safety",
57
57
  "sourcePath": "src/core/PostUpdateMigrator.ts",
58
58
  "installedPath": ".instar/hooks/instar/deferral-detector.js",
59
- "contentHash": "66f1de9704cc6bebfa8e551f195202455902abfbe309fe53faa9fe10b5138f9f",
59
+ "contentHash": "2a4639dfdecd37347736d04e008f4a201cd17e9660fa1584df2a43dae2d7e4be",
60
60
  "since": "2025-01-01"
61
61
  },
62
62
  "hook:post-action-reflection": {
@@ -65,7 +65,7 @@
65
65
  "domain": "evolution",
66
66
  "sourcePath": "src/core/PostUpdateMigrator.ts",
67
67
  "installedPath": ".instar/hooks/instar/post-action-reflection.js",
68
- "contentHash": "66f1de9704cc6bebfa8e551f195202455902abfbe309fe53faa9fe10b5138f9f",
68
+ "contentHash": "2a4639dfdecd37347736d04e008f4a201cd17e9660fa1584df2a43dae2d7e4be",
69
69
  "since": "2025-01-01"
70
70
  },
71
71
  "hook:external-communication-guard": {
@@ -74,7 +74,7 @@
74
74
  "domain": "safety",
75
75
  "sourcePath": "src/core/PostUpdateMigrator.ts",
76
76
  "installedPath": ".instar/hooks/instar/external-communication-guard.js",
77
- "contentHash": "66f1de9704cc6bebfa8e551f195202455902abfbe309fe53faa9fe10b5138f9f",
77
+ "contentHash": "2a4639dfdecd37347736d04e008f4a201cd17e9660fa1584df2a43dae2d7e4be",
78
78
  "since": "2025-01-01"
79
79
  },
80
80
  "hook:scope-coherence-collector": {
@@ -83,7 +83,7 @@
83
83
  "domain": "coherence",
84
84
  "sourcePath": "src/core/PostUpdateMigrator.ts",
85
85
  "installedPath": ".instar/hooks/instar/scope-coherence-collector.js",
86
- "contentHash": "66f1de9704cc6bebfa8e551f195202455902abfbe309fe53faa9fe10b5138f9f",
86
+ "contentHash": "2a4639dfdecd37347736d04e008f4a201cd17e9660fa1584df2a43dae2d7e4be",
87
87
  "since": "2025-01-01"
88
88
  },
89
89
  "hook:scope-coherence-checkpoint": {
@@ -92,7 +92,7 @@
92
92
  "domain": "coherence",
93
93
  "sourcePath": "src/core/PostUpdateMigrator.ts",
94
94
  "installedPath": ".instar/hooks/instar/scope-coherence-checkpoint.js",
95
- "contentHash": "66f1de9704cc6bebfa8e551f195202455902abfbe309fe53faa9fe10b5138f9f",
95
+ "contentHash": "2a4639dfdecd37347736d04e008f4a201cd17e9660fa1584df2a43dae2d7e4be",
96
96
  "since": "2025-01-01"
97
97
  },
98
98
  "hook:free-text-guard": {
@@ -101,7 +101,7 @@
101
101
  "domain": "safety",
102
102
  "sourcePath": "src/core/PostUpdateMigrator.ts",
103
103
  "installedPath": ".instar/hooks/instar/free-text-guard.sh",
104
- "contentHash": "66f1de9704cc6bebfa8e551f195202455902abfbe309fe53faa9fe10b5138f9f",
104
+ "contentHash": "2a4639dfdecd37347736d04e008f4a201cd17e9660fa1584df2a43dae2d7e4be",
105
105
  "since": "2025-01-01"
106
106
  },
107
107
  "hook:claim-intercept": {
@@ -110,7 +110,7 @@
110
110
  "domain": "coherence",
111
111
  "sourcePath": "src/core/PostUpdateMigrator.ts",
112
112
  "installedPath": ".instar/hooks/instar/claim-intercept.js",
113
- "contentHash": "66f1de9704cc6bebfa8e551f195202455902abfbe309fe53faa9fe10b5138f9f",
113
+ "contentHash": "2a4639dfdecd37347736d04e008f4a201cd17e9660fa1584df2a43dae2d7e4be",
114
114
  "since": "2025-01-01"
115
115
  },
116
116
  "hook:claim-intercept-response": {
@@ -119,7 +119,7 @@
119
119
  "domain": "coherence",
120
120
  "sourcePath": "src/core/PostUpdateMigrator.ts",
121
121
  "installedPath": ".instar/hooks/instar/claim-intercept-response.js",
122
- "contentHash": "66f1de9704cc6bebfa8e551f195202455902abfbe309fe53faa9fe10b5138f9f",
122
+ "contentHash": "2a4639dfdecd37347736d04e008f4a201cd17e9660fa1584df2a43dae2d7e4be",
123
123
  "since": "2025-01-01"
124
124
  },
125
125
  "hook:auto-approve-permissions": {
@@ -128,7 +128,7 @@
128
128
  "domain": "safety",
129
129
  "sourcePath": "src/core/PostUpdateMigrator.ts",
130
130
  "installedPath": ".instar/hooks/instar/auto-approve-permissions.js",
131
- "contentHash": "66f1de9704cc6bebfa8e551f195202455902abfbe309fe53faa9fe10b5138f9f",
131
+ "contentHash": "2a4639dfdecd37347736d04e008f4a201cd17e9660fa1584df2a43dae2d7e4be",
132
132
  "since": "2025-01-01"
133
133
  },
134
134
  "job:health-check": {
@@ -360,7 +360,7 @@
360
360
  "type": "skill",
361
361
  "domain": "skills",
362
362
  "sourcePath": ".claude/skills/build/SKILL.md",
363
- "contentHash": "5b3557fa3662cf0c7b7bab85a252cc2e567b3fc64a04a92d430374ef1f264ca6",
363
+ "contentHash": "bdd16b784c3482372d442ff5986b271213f3d2a705784c7dbbd4345f217be2b2",
364
364
  "since": "2025-01-01"
365
365
  },
366
366
  "skill:instar-project": {
@@ -1040,7 +1040,7 @@
1040
1040
  "type": "template",
1041
1041
  "domain": "safety",
1042
1042
  "sourcePath": "src/templates/hooks/settings-template.json",
1043
- "contentHash": "557133aed5a8c543affac6df7a959bfb573df9b1e8197b0d29809e1de9d00aec",
1043
+ "contentHash": "2cc950f0635f9c3412b768610f690288b466e7ace280285aee2481fbe514f230",
1044
1044
  "since": "2025-01-01"
1045
1045
  },
1046
1046
  "template:skill-usage-telemetry.sh": {
@@ -1472,7 +1472,7 @@
1472
1472
  "type": "subsystem",
1473
1473
  "domain": "updates",
1474
1474
  "sourcePath": "src/core/PostUpdateMigrator.ts",
1475
- "contentHash": "66f1de9704cc6bebfa8e551f195202455902abfbe309fe53faa9fe10b5138f9f",
1475
+ "contentHash": "2a4639dfdecd37347736d04e008f4a201cd17e9660fa1584df2a43dae2d7e4be",
1476
1476
  "since": "2025-01-01"
1477
1477
  },
1478
1478
  "subsystem:scheduler": {
@@ -31,6 +31,11 @@
31
31
  "command": "node .instar/hooks/instar/deferral-detector.js",
32
32
  "timeout": 5000
33
33
  },
34
+ {
35
+ "type": "command",
36
+ "command": "node .instar/hooks/instar/slopcheck-guard.js",
37
+ "timeout": 5000
38
+ },
34
39
  {
35
40
  "type": "command",
36
41
  "command": "node .instar/hooks/instar/external-communication-guard.js",
@@ -0,0 +1,32 @@
1
+ # Upgrade Guide — vNEXT
2
+
3
+ <!-- bump: minor -->
4
+
5
+ ## What Changed
6
+
7
+ **feat(build): /build methodology bundle — four GSD cherry-picks + defense-in-depth doc.**
8
+
9
+ Four enhancements to the /build skill, all from the GSD-Instar spike, bundled in one PR because they all touch the /build SKILL.md:
10
+
11
+ - **Phase 0.5: MUST-HAVES (goal-backward)** — before planning HOW, state WHAT must be observably true: truths (consumer-perspective), artifacts (exist + substantive + wired), and key_links (grep patterns proving real wiring). Each truth becomes a Phase 3 verification gate. Prevents shipping a component that compiles + passes unit tests but is never instantiated.
12
+ - **STRIDE threat pass** (LARGE builds only) — a small threat register where each mitigation binds to a specific test. Skipped for SMALL builds.
13
+ - **Atomic-commit discipline** in Phase 2 EXECUTE — one commit per plan step, stage specific files by name (never `git add -A`), `{type}({scope}): {summary}` format, verify no accidental deletions. Replaces the old single-mega-commit guidance (which was unreviewable).
14
+ - **SUMMARY.md deviation-tracking** in Phase 5 COMPLETE — enumerate deviations from plan, categorized by the executor Rule 1/2/3/4, plus the must-haves verification result and any infrastructure-backed deferrals.
15
+
16
+ Also adds `docs/patterns/defense-in-depth-insert-and-projection.md` — the insert-time + projection-time pattern the spike surfaced (with the Topic Intent Layer affirmation cap as the worked example).
17
+
18
+ ## Evidence
19
+
20
+ 4 unit tests for the migration (migrateBuildSkillMethodology): stock skill updated, idempotent, customized skill untouched, no-throw on missing. TypeScript clean.
21
+
22
+ Migration parity: installBuildSkill is install-if-missing, so existing agents get the methodology via a content-sniffed idempotent migration (only updates a stock /build skill lacking the "Phase 0.5: MUST-HAVES" marker; leaves customized skills alone).
23
+
24
+ Side-effects review: `upgrades/side-effects/build-methodology-bundle.md`.
25
+
26
+ ## What to Tell Your User
27
+
28
+ Your /build skill got sharper. It now asks "what must be true when this is done?" before planning, commits work in reviewable per-task chunks instead of one giant commit, and writes a short deviation log at the end so you can see exactly what changed from the original plan. On big builds it also does a quick threat pass. Nothing you have to do differently — /build just does more of the right thing automatically.
29
+
30
+ ## Summary of New Capabilities
31
+
32
+ Four /build methodology sections + one pattern doc + one content-update migration + 4 migration tests. Framework-agnostic (prompt-skill content + a migration). The methodology is the GSD planner/executor discipline imported as Instar's own.
@@ -0,0 +1,30 @@
1
+ # Side-Effects Review — Atomic-Write Helper
2
+
3
+ **Source:** Cherry-pick from GSD-Instar spike (gsd-executor Rule 2 finding)
4
+ **Author:** Echo · autonomous run · 2026-05-23
5
+
6
+ ## 1. Over-block
7
+ N/A — additive library function, blocks nothing.
8
+
9
+ ## 2. Under-block
10
+ N/A — not a gate.
11
+
12
+ ## 3. Level-of-abstraction fit
13
+ Lives in SafeFsExecutor alongside the other safe-fs primitives. Natural home. Static methods matching the existing `safeRmSync` etc. style.
14
+
15
+ ## 4. Signal-vs-authority compliance
16
+ N/A — not a gate/filter. Pure fs primitive.
17
+
18
+ ## 5. Cross-feature interactions
19
+ - Additive — no existing callsite changes. Existing `fs.writeFileSync` callers are untouched; they can migrate to the atomic helper incrementally.
20
+ - Shares the destructive-ops audit trail (appendAuditEntry) — adds `atomicWriteFileSync` / `atomicWriteJsonSync` verbs to the JSONL. No schema change, just new verb values.
21
+ - Temp file naming uses pid + timestamp in the same directory; concurrent writes to the same target from different processes each use a distinct temp, then race on rename (last-rename-wins, which is the correct atomic semantics — no corruption, just last-writer-wins).
22
+
23
+ ## 6. Rollback cost
24
+ Trivial. Two new static methods + one test file. Revert the commit; any caller that adopted it would need reverting too, but at ship time there are zero adopters (the helper is introduced here; migration of existing callsites is a separate follow-up).
25
+
26
+ ## 7. Migration parity
27
+ N/A — `SafeFsExecutor` is a compiled-in library module, not an agent-installed file (`.claude/settings.json` hook, config default, CLAUDE.md section, hook script, or skill). Ships with the package on `npm i instar@next`. No PostUpdateMigrator entry needed.
28
+
29
+ ## Conclusion
30
+ Ship. Purely additive crash-safety primitive. Zero blast radius at introduction. Adopting it across existing `.instar/state/*.json` writers (TopicIntent store, etc.) is a separate follow-up that each gets its own review.
@@ -0,0 +1,34 @@
1
+ # Side-Effects Review — /build Methodology Bundle
2
+
3
+ **Source:** Cherry-picks from GSD-Instar spike (gsd-planner + gsd-executor methodology)
4
+ **Author:** Echo · autonomous run · 2026-05-23
5
+
6
+ ## 1. Over-block
7
+ None — these are prompt-skill methodology sections, not gates. They add steps the agent runs, not blocks. The Phase 0.5 "quality gate" (must-haves.md exists before Phase 1) is a soft self-check inside the skill, not an external block.
8
+
9
+ ## 2. Under-block
10
+ The methodology is advisory within /build. An agent could skip Phase 0.5. Enforcement of the spirit lives elsewhere (e2e-pairing pre-commit gate, /verify-claim, response-review). This bundle imports the DISCIPLINE; the structural gates are separate cherry-picks.
11
+
12
+ ## 3. Level-of-abstraction fit
13
+ All four changes are content edits to the /build SKILL.md — the natural home for build methodology. The defense-in-depth doc lives in docs/patterns/ alongside other pattern docs. The migration follows the existing migrateSkillPortHardcoding content-sniff pattern.
14
+
15
+ ## 4. Signal-vs-authority compliance
16
+ Compatible. Phase 0.5 must-haves PRODUCE the verification signals that Phase 3 (authority: the agent + reviewers) acts on. STRIDE mitigations bind to tests (the authority). The defense-in-depth doc explicitly reconciles itself with signal-vs-authority. No brittle filter is given blocking authority.
17
+
18
+ ## 5. Cross-feature interactions
19
+ - Phase 0.5 key_links + /verify-claim (separate PR) compose: must-haves define the wiring; /verify-claim checks it.
20
+ - Atomic-commit discipline aligns with the e2e-pairing pre-commit gate (per-task commits make the gate's per-commit check meaningful).
21
+ - SUMMARY deviation-tracking references the executor Rule 1/2/3/4 vocabulary (consistent with the deferral-detector + the GSD methodology framing).
22
+ - The old Phase 5 `git add -A` guidance is REPLACED (it contradicted the new atomic-commit discipline) — a deliberate fix, not just an addition.
23
+ - Migration only touches a stock /build skill; customized skills are fingerprint-guarded.
24
+
25
+ ## 6. Rollback cost
26
+ Moderate-low. Revert the SKILL.md edits + the migration method + the doc + the migration test. Existing agents that already ran the migration would keep the updated SKILL.md (harmless — the new sections are additive guidance). The migration is idempotent and conservative, so a revert-then-re-apply is safe.
27
+
28
+ ## 7. Migration parity
29
+ - New agents: bundled SKILL.md (copied by installBuildSkill on fresh init) carries the sections.
30
+ - Existing agents: migrateBuildSkillMethodology() content-sniffs for the Phase 0.5 marker and re-copies the bundled SKILL.md if absent AND the file matches the stock fingerprint. Wired into the migration sequence after migrateSkillPortHardcoding. Idempotent + fingerprint-guarded (verified by 4 tests).
31
+ - The defense-in-depth doc is a repo doc, not an agent-installed file — ships with the package, no migration needed.
32
+
33
+ ## Conclusion
34
+ Ship. Bundling the four /build-touching items into one PR is correct (separate PRs would self-conflict on SKILL.md). The methodology is the spike's planner+executor discipline imported as Instar's own. Migration parity covered with a conservative content-sniff migration + 4 tests. Seven-dimension review clean.
@@ -0,0 +1,36 @@
1
+ # Side-Effects Review — Slopcheck Guard Hook
2
+
3
+ **Source:** Cherry-pick from GSD-Instar spike (gsd-executor Rule 3 exclusion)
4
+ **Author:** Echo · autonomous run · 2026-05-23
5
+
6
+ ## 1. Over-block
7
+ Could over-fire on legitimate installs of new-but-real packages. Mitigation: NEVER blocks — signal-only nudge. Worst case is one extra checklist the agent reads and proceeds past. Familiar packages (in any manifest/lockfile) are silently skipped.
8
+
9
+ ## 2. Under-block
10
+ Could miss a slopsquat if it happens to share a token with something in a lockfile. Mitigation: the lockfile presence check is deliberately loose (favors NOT nagging on known-safe). The nudge is a backstop, not the only defense — the agent still reasons about each install. Acceptable: under-block here means "no extra nudge", not "install proceeds unchecked" (the agent always sees the command).
11
+
12
+ ## 3. Level-of-abstraction fit
13
+ PreToolUse Bash hook alongside dangerous-command-guard, deferral-detector, grounding-before-messaging. Same layer, same idiom, same generator pattern (PostUpdateMigrator getter).
14
+
15
+ ## 4. Signal-vs-authority compliance
16
+ Compliant. Pure pattern-match + lockfile lookup = low-context filter emitting a signal (additionalContext). The agent (full-context authority) decides whether to install. Never blocks.
17
+
18
+ ## 5. Cross-feature interactions
19
+ - dangerous-command-guard (PreToolUse Bash, blocking) runs first and independently — no overlap (it blocks destructive commands; slopcheck nudges on installs).
20
+ - deferral-detector (PreToolUse Bash) matches communication commands — no overlap with install commands.
21
+ - The hook reads project manifests read-only; no mutation, no shared state.
22
+ - Edge: `echo npm install foo` would trigger the nudge (regex matches anywhere). Harmless — signal-only, rare, and erring toward caution on anything that looks like an install is the safe direction.
23
+
24
+ ## 6. Rollback cost
25
+ Trivial. One generator method, one settings-template entry, one migrateSettings ensure-block, one manifest entry, one known-list entry, one test file. Revert the commit; the hook stops generating and existing copies become inert.
26
+
27
+ ## 7. Migration parity
28
+ Full coverage:
29
+ - New agents: settings-template.json PreToolUse Bash entry.
30
+ - Existing agents: explicit ensure-block in migrateSettings() adds the slopcheck entry to the Bash matcher if absent (idempotent — checks `hasSlopcheck` first).
31
+ - Hook script: always-overwritten by migrateHooks() (built-in hook).
32
+ - builtin-manifest.json: registered.
33
+ - known-builtin-hooks list: registered (orphan-cleanup safe).
34
+
35
+ ## Conclusion
36
+ Ship. Real supply-chain defense Instar lacked. Signal-only, trivial rollback, full migration parity. Seven-dimension review clean.
@@ -0,0 +1,33 @@
1
+ # Side-Effects Review — /verify-claim Skill
2
+
3
+ **Source:** Cherry-pick from GSD-Instar spike (gsd-verifier 4-level protocol)
4
+ **Author:** Echo · autonomous run · 2026-05-23
5
+
6
+ ## 1. Over-block
7
+ N/A — a prompt skill, blocks nothing. Worst case: the agent runs a few extra grep/test commands before claiming done. That's the intended cost.
8
+
9
+ ## 2. Under-block
10
+ The skill is advisory — an agent could skip invoking it. Mitigation: it's wired into the recommended /build Phase 3 flow and the "before claiming shipped" trigger. Not a hard gate (that would be the e2e-pairing pre-commit hook + response-review). This is the verification METHODOLOGY made callable; enforcement lives elsewhere.
11
+
12
+ ## 3. Level-of-abstraction fit
13
+ A user-invocable skill alongside the other built-in skills in installBuiltinSkills(). Same inline-content pattern, same install mechanism, same idempotency guarantee.
14
+
15
+ ## 4. Signal-vs-authority compliance
16
+ N/A in the gate sense — it's a methodology the agent runs. It PRODUCES signals (the per-level status), and the agent (authority) acts on them. Aligned with the spike's whole verdict: import the methodology, let the agent wield it.
17
+
18
+ ## 5. Cross-feature interactions
19
+ - Complements the e2e-pairing pre-commit gate (that enforces an e2e test FILE exists; this verifies a claim is actually wired). Different layers, no overlap.
20
+ - Complements response-review (Stop hook). /verify-claim is invoked DURING work; response-review checks the outbound message.
21
+ - Referenced from /build Phase 3 VERIFY as the per-must-have check.
22
+ - Pure additive skill — no existing skill changes.
23
+
24
+ ## 6. Rollback cost
25
+ Trivial. One entry in the installBuiltinSkills record + one test file. Revert the commit; the skill stops being installed for new agents. Existing agents that already have the SKILL.md keep an inert copy (harmless).
26
+
27
+ ## 7. Migration parity
28
+ Adding a NEW skill needs no migration per the Migration Parity Standard: installBuiltinSkills() is called from refreshHooksAndSettings() on every update and is non-destructive (only writes missing SKILL.md files). Existing agents get verify-claim on their next update. Idempotency verified in the test (does not overwrite a customized copy).
29
+
30
+ Note: a follow-up should add /verify-claim to the CLAUDE.md template's capability list (Agent Awareness Standard) so agents surface it conversationally — tracked, not blocking this PR.
31
+
32
+ ## Conclusion
33
+ Ship. The spike's #1 cherry-pick by leverage. Pure additive prompt skill, trivial rollback, no migration needed. Seven-dimension review clean.
@@ -1,31 +0,0 @@
1
- # Upgrade Guide — vNEXT
2
-
3
- <!-- bump: patch -->
4
-
5
- ## What Changed
6
-
7
- **feat(dev): e2e-pairing pre-commit gate — GSD cherry-pick.**
8
-
9
- New pre-commit gate (`scripts/check-e2e-pairing.cjs`, wired into `.husky/pre-commit`) that blocks any commit changing a non-test `src/server/*.ts` file unless it also stages at least one `tests/e2e/*.test.ts`. Structurally enforces the Tier-3 "feature is alive" discipline that CLAUDE.md calls the single most important test for any feature with API routes.
10
-
11
- From the GSD-Instar spike, where the gsd-planner methodology surfaced that the Topic Intent Layer's Tier-3 lifecycle test would have been forgotten under ad-hoc planning. This gate makes "ship a route without an e2e test" structurally hard rather than discipline-dependent.
12
-
13
- Two escape hatches keep it from being tyrannical: env bypass (`INSTAR_SKIP_E2E_PAIRING=1`) and an `E2E-PAIRING: EXEMPT — <reason>` marker in a staged server file (for genuine refactors / type-only / comment changes).
14
-
15
- This governs instar's OWN development commits (it's in instar's `.husky/`), not agent-installed files — so no migration parity needed.
16
-
17
- ## Evidence
18
-
19
- 8 unit tests, all green (tmp-git-repo harness): passes with no server files, blocks server-without-e2e, passes server-with-e2e, ignores server test files + .d.ts, respects env bypass + EXEMPT marker, blocks when only an unrelated unit test is staged. TypeScript clean.
20
-
21
- Verified the gate does not block this very PR (this PR changes scripts/ + .husky/ + tests/, not src/server/).
22
-
23
- Side-effects review: `upgrades/side-effects/e2e-pairing-gate.md`.
24
-
25
- ## What to Tell Your User
26
-
27
- Nothing user-visible. Internal dev-discipline gate for instar contributors.
28
-
29
- ## Summary of New Capabilities
30
-
31
- One new pre-commit gate script + one line in .husky/pre-commit. Signal-with-commit-authority (blocks), with two escape hatches. Errs toward false positives because a route shipped without an e2e test is the corruption-class failure being defended against.