@ericrisco/rsc 4.1.4 → 4.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/manifest.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.1.4",
2
+ "version": "4.1.6",
3
3
  "counts": {
4
4
  "skills": 273,
5
5
  "agents": 34,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ericrisco/rsc",
3
- "version": "4.1.4",
3
+ "version": "4.1.6",
4
4
  "description": "A guided harness builder that turns your goal into a minimal, verified AI-agent setup using strict best practices.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { claudeBootstrapPath } from '../targets/claude-lifecycle.js';
2
3
  import { rmSync, rmdirSync, existsSync, cpSync, lstatSync, mkdirSync, readFileSync, realpathSync, writeFileSync, appendFileSync, readdirSync, renameSync } from 'node:fs';
3
4
  import { join, dirname, relative, resolve, sep } from 'node:path';
4
5
  import { fileURLToPath } from 'node:url';
@@ -115,6 +116,8 @@ export function managedPathsForInstall({ skillIds, agentIds = [], target, home,
115
116
  const paths = targetPaths(target, home, cwd);
116
117
  const plan = planInstall({ skillIds, target, home, cwd, hooks: policy?.alwaysOn !== false });
117
118
  const out = [paths.stateFile, versionFile(cwd), baseVersionsFile(cwd)];
119
+ // Knowledge/memory wiring also needs this shared dependency without suggest.
120
+ if (target === 'claude') out.push(claudeBootstrapPath(cwd));
118
121
  // Pi can move its managed block when the native context-file precedence changes.
119
122
  if (target === 'pi') out.push(...paths.contextFiles);
120
123
  if (policy?.context7 === false) out.push(join(cwd, '.rsc', '.no-context7'));
@@ -29,6 +29,20 @@ const text = (v) => (typeof v === 'string' ? v.trim() : '');
29
29
  const normFile = (f) => text(f).replace(/\\/g, '/').replace(/^\.\//, '');
30
30
  const normEvidence = (e) => text(e).replace(/\s+/g, ' ').toLowerCase();
31
31
 
32
+ // Explicit pairs survive consolidation without attributing every criterion to every lens.
33
+ // A report filename is not a lens, and prose is not an acceptance-criterion identifier.
34
+ export function criterionRefs(f) {
35
+ const refs = Array.isArray(f.criterion_refs) ? f.criterion_refs : [{ criterion: f.criterion, lens: f.lens }];
36
+ const unique = new Map();
37
+ for (const ref of refs) {
38
+ if (!ref || typeof ref !== 'object') continue;
39
+ const criterion = text(ref.criterion);
40
+ const lens = text(ref.lens).toLowerCase();
41
+ if (criterion && lens) unique.set(JSON.stringify([criterion, lens]), { criterion, lens });
42
+ }
43
+ return [...unique.values()];
44
+ }
45
+
32
46
  // Pull every finding out of one source. A source is a lens report (markdown with fenced blocks) or a
33
47
  // JSON file. Anything unparseable is reported, never silently dropped: a lost finding is the one
34
48
  // failure a consolidation step must not add.
@@ -69,6 +83,7 @@ export function normalizeFinding(f) {
69
83
  failure_scenario: text(f.failure_scenario) || text(f.repro),
70
84
  evidence: text(f.evidence),
71
85
  class: text(f.class) || text(f.bug_class) || text(f.defect_class),
86
+ criterion_refs: criterionRefs(f),
72
87
  notes: [],
73
88
  };
74
89
  if (!out.severity) {
@@ -143,6 +158,7 @@ export function consolidate(rawFindings, { window = DEFAULT_WINDOW } = {}) {
143
158
  evidence: uniq(members.map((m) => m.evidence)),
144
159
  // Carried through so `review ledger record` can fingerprint by bug class.
145
160
  class: uniq(members.map((m) => m.class))[0] || '',
161
+ criterion_refs: criterionRefs({ criterion_refs: members.flatMap((m) => m.criterion_refs) }),
146
162
  notes: uniq(members.flatMap((m) => m.notes)),
147
163
  reported: members.length,
148
164
  verify: rank(severity) <= rank('should-fix'),
@@ -12,6 +12,7 @@
12
12
  import { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync } from 'node:fs';
13
13
  import { join } from 'node:path';
14
14
  import { spawnSync } from 'node:child_process';
15
+ import { criterionRefs } from './review-findings.js';
15
16
 
16
17
  export const LEDGER_PATH = '.rsc/review-ledger.jsonl';
17
18
  // `parked`: the finding's task went to the decision queue; neither fixed nor dismissed, a human decides.
@@ -46,6 +47,7 @@ export function normalize(f) {
46
47
  class: text(f.class) || text(f.bug_class) || text(f.defect_class),
47
48
  claim: text(f.claim) || (Array.isArray(f.claims) ? text(f.claims[0]) : '') || text(f.title) || text(f.summary),
48
49
  severity: text(f.severity) || 'question',
50
+ criterion_refs: criterionRefs(f),
49
51
  };
50
52
  }
51
53
 
@@ -69,10 +71,71 @@ function append(root, entries) {
69
71
  appendFileSync(join(root, LEDGER_PATH), entries.map((e) => `${JSON.stringify(e)}\n`).join(''));
70
72
  }
71
73
 
74
+ // A panel completes an explicit round, or starts one when an older caller omitted `round`.
75
+ // Replay legacy records in order rather than trusting their old, independent round counters.
76
+ function reviewBudget(ledger, task) {
77
+ let count = 0;
78
+ let panelled = false;
79
+ let explicit = false;
80
+ for (const e of ledger) {
81
+ if (e.task !== task) continue;
82
+ if (e.type === 'round') { count += 1; panelled = false; explicit = true; }
83
+ if (e.type === 'panel') {
84
+ if (!count || panelled) { count += 1; explicit = false; }
85
+ panelled = true;
86
+ }
87
+ }
88
+ return { count, panelled, explicit };
89
+ }
90
+
91
+ function panelAssignments(ledger) {
92
+ const assigned = new Map();
93
+ for (const e of ledger) {
94
+ if (e.type !== 'panel' || !Number.isInteger(e.round) || e.round < 1 || !Array.isArray(e.finding_ids)) continue;
95
+ for (const id of e.finding_ids) assigned.set(JSON.stringify([e.task, id]), e.round);
96
+ }
97
+ return assigned;
98
+ }
99
+
100
+ export function criterionSignals(ledger) {
101
+ const groups = new Map();
102
+ const assigned = panelAssignments(ledger);
103
+ for (const entry of ledger) {
104
+ if (entry.type !== 'finding' || entry.repeatOf || !QUALIFIED_TASK.test(entry.task)) continue;
105
+ const round = entry.round ?? (entry.round_pending ? assigned.get(JSON.stringify([entry.task, entry.id])) : undefined);
106
+ if (!Number.isInteger(round) || round < 1) continue;
107
+ const f = { ...entry, round };
108
+ for (const ref of criterionRefs(f)) {
109
+ const key = JSON.stringify([f.task, ref.criterion, ref.lens]);
110
+ if (!groups.has(key)) groups.set(key, { task: f.task, ...ref, findings: [] });
111
+ groups.get(key).findings.push(f);
112
+ }
113
+ }
114
+ const signals = [];
115
+ for (const group of groups.values()) {
116
+ const distinct = [];
117
+ for (const f of group.findings) if (!distinct.some((s) => sameClaim(s, f))) distinct.push(f);
118
+ const rounds = [...new Set(distinct.map((f) => f.round))].sort((a, b) => a - b);
119
+ if (rounds.length < 2) continue;
120
+ const { task, criterion, lens } = group;
121
+ signals.push({ task, criterion, lens, rounds, findings: distinct.map((f) => f.id),
122
+ message: `Possible criterion evidence gap: ${task}, ${criterion}, ${lens} has distinct objections across rounds ${rounds.join(', ')}. This does not prove the criterion is impossible. Revisit the spec and its demonstration method with clarify, or park the task in the decision queue; do not weaken the criterion or dismiss findings automatically.` });
123
+ }
124
+ return signals;
125
+ }
126
+
127
+ function convergenceMessage(task) {
128
+ return `rsc: task "${task}" has had ${MAX_ROUNDS} review rounds and has not converged. Stop fixing line by line: rethink the approach, review the spec criterion and its demonstration method, or park the task in the decision queue (02-DOCS/wiki/sdd/progress/<slug>.md, "## Decision queue") and continue with independent tasks.`;
129
+ }
130
+
72
131
  // → [{id, status: 'new'|'repeat', repeatOf?, ...finding}]. A repeat is recorded too (it is the noise
73
132
  // being measured) but points at the original, and the caller must not raise it again.
74
133
  export function record(root, rawFindings, { task = '', now = new Date().toISOString() } = {}) {
75
134
  const ledger = readLedger(root);
135
+ const budget = reviewBudget(ledger, task);
136
+ // An explicit round is the context for the entire review, before AND after its panel. The
137
+ // implement protocol records the panel first, while other callers consolidate findings first.
138
+ const reviewRound = budget.explicit ? budget.count : 0;
76
139
  // A finding closed as fixed that shows up again is a regression, not noise: it is raised anew.
77
140
  const fixed = new Set(ledger.filter((e) => e.type === 'outcome' && e.outcome === 'fixed').map((e) => e.id));
78
141
  const seen = ledger.filter((e) => e.type === 'finding' && !e.repeatOf && !fixed.has(e.id));
@@ -83,12 +146,17 @@ export function record(root, rawFindings, { task = '', now = new Date().toISOStr
83
146
  const f = normalize(raw);
84
147
  n += 1;
85
148
  const original = seen.find((s) => sameClaim(s, f));
86
- const entry = { type: 'finding', id: `L${n}`, task, at: now, ...f, ...(original ? { repeatOf: original.id } : {}) };
149
+ // Without an explicit active round, these new findings belong to the next panel. Bind them
150
+ // only when that panel succeeds; old findings without this marker remain ambiguous.
151
+ const roundRef = reviewRound ? { round: reviewRound } : (QUALIFIED_TASK.test(task) ? { round_pending: true } : {});
152
+ const entry = { type: 'finding', id: `L${n}`, task, at: now, ...f, ...roundRef, ...(original ? { repeatOf: original.id } : {}) };
87
153
  if (!original) seen.push(entry);
88
154
  out.push(entry);
89
155
  }
90
156
  append(root, out);
91
- return out.map((e) => ({ ...e, status: e.repeatOf ? 'repeat' : 'new' }));
157
+ const signals = criterionSignals([...ledger, ...out]);
158
+ return out.map((e) => ({ ...e, status: e.repeatOf ? 'repeat' : 'new',
159
+ advisories: signals.filter((s) => s.findings.includes(e.id)) }));
92
160
  }
93
161
 
94
162
  export function outcome(root, id, value, { now = new Date().toISOString() } = {}) {
@@ -111,15 +179,16 @@ export function round(root, task, { now = new Date().toISOString() } = {}) {
111
179
  if (!QUALIFIED_TASK.test(task)) {
112
180
  return { ok: false, round: 0, message: `rsc: qualify the task with its spec slug, e.g. \`review ledger round <slug>/${task || 'T001'}\` — task ids repeat across plans.` };
113
181
  }
114
- const n = readLedger(root).filter((e) => e.type === 'round' && e.task === task).length + 1;
182
+ const ledger = readLedger(root);
183
+ const n = reviewBudget(ledger, task).count + 1;
115
184
  if (n > MAX_ROUNDS) {
116
185
  return {
117
186
  ok: false, round: n,
118
- message: `rsc: task "${task}" has had ${MAX_ROUNDS} review rounds and has not converged. Stop fixing line by line: rethink the approach, or park the task in the decision queue (02-DOCS/wiki/sdd/progress/<slug>.md, "## Decision queue") and continue with independent tasks.`,
187
+ message: convergenceMessage(task),
119
188
  };
120
189
  }
121
190
  append(root, [{ type: 'round', task, n, at: now }]);
122
- return { ok: true, round: n, message: `task "${task}": review round ${n} of ${MAX_ROUNDS}` };
191
+ return { ok: true, round: n, message: [`task "${task}": review round ${n} of ${MAX_ROUNDS}`, ...criterionSignals(ledger).filter((s) => s.task === task).map((s) => s.message)].join('\n') };
123
192
  }
124
193
 
125
194
  // Records that a review panel ran on a task: which lenses, distinct. Self-attested, like the sello's
@@ -131,11 +200,19 @@ export function panel(root, task, lenses, { now = new Date().toISOString() } = {
131
200
  }
132
201
  const list = [...new Set(String(lenses || '').split(',').map((l) => l.trim().toLowerCase()).filter(Boolean))];
133
202
  if (!list.length) return { ok: false, message: 'rsc: name the lenses that ran: --lenses correctness,security,tests' };
203
+ const ledger = readLedger(root);
204
+ const budget = reviewBudget(ledger, task);
205
+ const n = budget.count + (!budget.count || budget.panelled ? 1 : 0);
206
+ if (n > MAX_ROUNDS) return { ok: false, message: convergenceMessage(task) };
134
207
  // Bound to the commit reviewed: code committed after it is code no panel has seen.
135
208
  const r = spawnSync('git', ['-C', root, 'rev-parse', 'HEAD'], { encoding: 'utf8', windowsHide: true });
136
209
  const sha = r.status === 0 ? r.stdout.trim() : null;
137
- append(root, [{ type: 'panel', task, lenses: list, sha, at: now }]);
138
- return { ok: true, message: `task "${task}": panel of ${list.length} recorded (${list.join(', ')})${sha ? ` on ${sha.slice(0, 7)}` : ''}` };
210
+ const assigned = panelAssignments(ledger);
211
+ const finding_ids = ledger.filter((e) => e.type === 'finding' && e.task === task && e.round_pending
212
+ && !assigned.has(JSON.stringify([task, e.id]))).map((e) => e.id);
213
+ const entry = { type: 'panel', task, round: n, finding_ids, lenses: list, sha, at: now };
214
+ append(root, [entry]);
215
+ return { ok: true, message: [`task "${task}": panel of ${list.length} recorded (${list.join(', ')})${sha ? ` on ${sha.slice(0, 7)}` : ''}; review round ${n} of ${MAX_ROUNDS}`, ...criterionSignals([...ledger, entry]).filter((s) => s.task === task).map((s) => s.message)].join('\n') };
139
216
  }
140
217
 
141
218
  export function stats(root) {
@@ -149,7 +226,7 @@ export function stats(root) {
149
226
  // Parked is undecided: a human holds it. Counting it as closed would understate the false rate.
150
227
  const closed = originals.length - outcomes.open - outcomes.parked;
151
228
  const rounds = new Map();
152
- for (const e of ledger) if (e.type === 'round') rounds.set(e.task, Math.max(rounds.get(e.task) || 0, e.n));
229
+ for (const e of ledger) if (e.type === 'round' || e.type === 'panel') rounds.set(e.task, reviewBudget(ledger, e.task).count);
153
230
  const totalRounds = [...rounds.values()].reduce((a, b) => a + b, 0);
154
231
  return {
155
232
  findings: originals.length,
@@ -159,6 +236,7 @@ export function stats(root) {
159
236
  tasks: rounds.size,
160
237
  meanRounds: rounds.size ? totalRounds / rounds.size : null,
161
238
  open: originals.filter((f) => !last.has(f.id)).map((f) => f.id),
239
+ criterionSignals: criterionSignals(ledger),
162
240
  };
163
241
  }
164
242
 
@@ -170,6 +248,7 @@ export function renderStats(s) {
170
248
  `false rate: ${pct(s.falseRate)} of closed findings`,
171
249
  `rounds: ${s.tasks} task(s), mean ${s.meanRounds === null ? 'n/a' : s.meanRounds.toFixed(2)} round(s) per task`,
172
250
  ...(s.open.length ? [`still open: ${s.open.join(', ')} — close each with \`review ledger outcome <id> <${OUTCOMES.join('|')}>\``] : []),
251
+ ...(s.criterionSignals || []).map((signal) => signal.message),
173
252
  ].join('\n');
174
253
  }
175
254
 
package/scripts/rsc.js CHANGED
@@ -1319,6 +1319,7 @@ async function main() {
1319
1319
  'Use: npx @ericrisco/rsc review consolidate [report.md|findings.json ...] [--json] [--window <lines>]',
1320
1320
  ' Without files it reads stdin. Each lens report carries its findings in ```json findings blocks.',
1321
1321
  ' npx @ericrisco/rsc review ledger record <findings.json> [--task <id>] | outcome <id> <fixed|false|intentional|irrelevant|parked> | round <slug>/<task> | panel <slug>/<task> --lenses a,b,c | stats [--json]',
1322
+ ' Findings may include criterion and lens; with a qualified --task, recurring criterion objections are reported without dismissing them. round and panel share a three-round budget.',
1322
1323
  ' npx @ericrisco/rsc review escapes [--since <ref>] [--json]',
1323
1324
  ].join('\n');
1324
1325
  if (argv[1] === 'ledger' || argv[1] === 'escapes') {
@@ -1350,7 +1351,7 @@ async function main() {
1350
1351
  catch { const p = R.parseFindings(raw, file || 'stdin'); if (p.errors.length) return fail(p.errors.join('\n')); list = p.findings; }
1351
1352
  const out = L.record(root, list, { task: str('task') || '' });
1352
1353
  if (json) say(JSON.stringify(out, null, 2));
1353
- else say(out.map((f) => `${f.id} ${f.status === 'repeat' ? `repeat of ${f.repeatOf} — do not raise it again` : 'new'} ${f.file || '(no file)'} ${f.claim}`).join('\n') || 'nothing to record');
1354
+ else say(out.map((f) => [`${f.id} ${f.status === 'repeat' ? `repeat of ${f.repeatOf} — do not raise it again` : 'new'} ${f.file || '(no file)'} ${f.claim}`, ...f.advisories.map((s) => s.message)].join('\n')).join('\n') || 'nothing to record');
1354
1355
  return;
1355
1356
  }
1356
1357
  if (sub === 'outcome') {
@@ -129,7 +129,7 @@ finding.
129
129
  Exactly as `../review/SKILL.md` → *Consolidate, then verify*: `npx @ericrisco/rsc review consolidate
130
130
  <reports…>` (tier 1 too: it applies the downgrade), then `finding-verifier` on every finding it
131
131
  marks `verify` — every blocker and should-fix. Findings use the JSON shape in
132
- `references/per-task-review.md`. Then `npx @ericrisco/rsc review ledger record <findings.json>`. A
132
+ `references/per-task-review.md`. Then `npx @ericrisco/rsc review ledger record <findings.json> --task <slug>/<task>`. A
133
133
  finding the ledger already holds comes back `repeat`: **never raise it again**. When a finding
134
134
  closes, record its outcome: `review ledger outcome <id> fixed|false|intentional|irrelevant|parked`
135
135
  (`parked` = its task went to the decision queue). The ledger is local (`.rsc/`, not committed);
@@ -153,6 +153,7 @@ A control that did not run is reported as **not run**, never as passed — and t
153
153
  Each re-review opens with another `review ledger round <slug>/<task>` (step c). It exits non-zero
154
154
  on the 4th round with the action to take; obey it (step g).
155
155
 
156
+ Follow [criterion evidence and rounds](references/per-task-review.md#criterion-evidence-and-rounds) for panel accounting, criterion/lens metadata and advisory handling.
156
157
  - **From round 2, re-review only the new diff** (BASE = the previous round's head).
157
158
  - **Fix the bug class, not the line**: name the class and fix every instance in the task's scope.
158
159
  - **Never repeat a finding** — the ledger marks repeats; drop them.
@@ -29,9 +29,13 @@ report ends with a ` ```json findings ` block — the input to `review consolida
29
29
  `review ledger record` — holding an array of objects in exactly this shape:
30
30
 
31
31
  ```json
32
- {"severity":"blocker|should-fix|nit|question","file":"path","line":N,"claim":"…","failure_scenario":"concrete input → wrong result","evidence":"quoted code","class":"bug class"}
32
+ {"severity":"blocker|should-fix|nit|question","file":"path","line":N,"claim":"…","failure_scenario":"concrete input → wrong result","evidence":"quoted code","class":"bug class","lens":"actual review lens","criterion":"stable acceptance-criterion id, when applicable"}
33
33
  ```
34
34
 
35
+ Keep the same lens label and the spec's actual criterion identifier across rounds; omit
36
+ `criterion` when it does not apply. Record with `--task <slug>/<task>` and preserve consolidation's
37
+ `criterion_refs` so the ledger can identify recurring criterion objections without dismissing them.
38
+
35
39
  A `blocker` or `should-fix` without `file`+`line` or without `failure_scenario` is downgraded to
36
40
  `question` by `review consolidate`; then every remaining blocker and should-fix goes to
37
41
  `finding-verifier`. Close the report with one line: `VERDICT: pass` or
@@ -46,3 +50,16 @@ do not invent findings to look thorough (an empty array is fine).
46
50
  - A stated reason never downgrades a finding's severity. Rate the defect, not the excuse.
47
51
  - You are reviewing **one task's** commits, not the whole branch — stay scoped; the whole-branch pass
48
52
  runs once at closing (ASDD stage 5).
53
+
54
+ ## Criterion evidence and rounds
55
+
56
+ `panel` consumes that same round, or starts one when `round` was omitted; repeated panels do not
57
+ reset the budget. An explicit round remains the findings' context whether the panel is recorded
58
+ before or after consolidation. Without an explicit round, record findings before the panel so
59
+ it can bind them to its round. Pass each reviewer the stable acceptance-criterion IDs and require explicit
60
+ `criterion` and `lens` metadata when a finding concerns one. Preserve the resulting
61
+ `criterion_refs` from consolidation. If the ledger signals a **possible criterion evidence gap**
62
+ (different objections from the same lens about one criterion across rounds), revisit the spec's
63
+ demonstration method through `clarify` or park it with evidence. This is an advisory, not proof
64
+ that a requirement is impossible. Do not remove a criterion, dismiss its findings or loosen a
65
+ security requirement automatically; a spec change still requires the human's decision.
@@ -179,9 +179,14 @@ steps, in this order:
179
179
  array of objects in exactly this shape (give it to every reviewer verbatim):
180
180
 
181
181
  ```json
182
- {"severity":"blocker|should-fix|nit|question","file":"path","line":N,"claim":"…","failure_scenario":"concrete input → wrong result","evidence":"quoted code","class":"bug class"}
182
+ {"severity":"blocker|should-fix|nit|question","file":"path","line":N,"claim":"…","failure_scenario":"concrete input → wrong result","evidence":"quoted code","class":"bug class","lens":"correctness|security|tests","criterion":"stable acceptance-criterion id, when applicable"}
183
183
  ```
184
184
 
185
+ Use the spec's actual criterion identifier (for example `AC4`), consistently across rounds;
186
+ omit `criterion` when no criterion is involved. Name the actual lens, never infer one from the
187
+ report filename. Consolidation preserves these associations as `criterion_refs` pairs so a
188
+ criterion raised by one lens is not attributed to another lens that reported the same defect.
189
+
185
190
  Save the reports and run `npx @ericrisco/rsc review consolidate <reports…>`. It merges findings
186
191
  on the same place that say the same thing, or that quote the same evidence; keeps the highest
187
192
  severity and every lens that saw it; and **downgrades a blocker or should-fix with no
@@ -217,21 +222,37 @@ fix-and-re-review is one round of the loop below.
217
222
  ### Convergence — the fix loop ends
218
223
 
219
224
  A review loop that never converges is worse than none: Anthropic saw a single PR take 50 rounds.
220
- Four rules, enforced by `npx @ericrisco/rsc review ledger` (`.rsc/review-ledger.jsonl`) rather
225
+ Five rules, enforced by `npx @ericrisco/rsc review ledger` (`.rsc/review-ledger.jsonl`) rather
221
226
  than by memory:
222
227
 
223
228
  1. **Max 3 rounds per task.** Call `review ledger round <slug>/<task>` before **every** review of
224
229
  the task, the first included: round 1 is the task's first review, not its first fix. It exits
225
230
  non-zero on the 4th. That is not "try harder": rethink the approach, or park the task in the
226
231
  decision queue (a `blocking` entry) and continue with independent work.
232
+ `panel` shares this budget: it completes the pending round, or counts a round itself when an
233
+ older caller omitted `round`. Repeated panels cannot bypass the limit. After an explicit
234
+ `round`, either `record → panel` or `panel → record` counts once and attributes findings to
235
+ that round. Invalid panel arguments consume no round.
236
+ If `round` was omitted, record the findings **before** `panel`: the successful panel binds
237
+ those pending findings to its round and can report the criterion advisory immediately.
238
+ Old findings without recorded round information are not retroactively assigned a round.
227
239
  2. **From round 2, re-review only the new diff** — what changed since the last round, not the task
228
240
  again from scratch.
229
241
  3. **Flag the bug class, not the line.** "Every handler in this file trusts `req.params.id`" — so
230
242
  one fix covers every instance and round 3 does not find the sibling.
231
243
  4. **Never repeat a finding.** Record each round's findings with `review ledger record
232
- <findings.json>` (the consolidate output works). A finding already seen — same file, class and
244
+ <findings.json> --task <slug>/<task>` (the consolidate output works). A finding already seen — same file, class and
233
245
  normalized title — comes back marked `repeat`; it is never re-raised as new. A repeat means the
234
246
  last fix missed the class, so say that instead.
247
+ 5. **Revisit recurring criterion objections.** Distinct findings linked to the same criterion and
248
+ lens in two or more rounds of one task produce a **possible criterion evidence gap** advisory in
249
+ `record`, `stats`, and subsequent `round`/`panel` output. Several findings in one round, or
250
+ findings without explicit metadata, are not evidence of this pattern. The signal does **not**
251
+ prove a requirement impossible and does not resolve findings, change severity, or approve work.
252
+ Route to `clarify`: check whether the required property and the agreed demonstration method
253
+ match, or park the task with its evidence. For example, source inspection alone is not a claim
254
+ that all runtime timing is constant. Keep the security requirement intact until the human
255
+ approves any change to the spec; never make the loop pass by silently deleting its criterion.
235
256
 
236
257
  **Every finding closes with an outcome**: `review ledger outcome <id> fixed|false|intentional|irrelevant|parked`
237
258
  — `parked` when the finding's task went to the decision queue (neither fixed nor dismissed; a human
@@ -0,0 +1,34 @@
1
+ // Local lifecycle settings can be inherited by a worktree whose ignored runtime is
2
+ // absent. Use the same portable bootstrap as Claude's committed hook settings.
3
+ import { copyFileSync, mkdirSync, existsSync, readFileSync, rmSync } from 'node:fs';
4
+ import { dirname, join } from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+
7
+ const HERE = dirname(fileURLToPath(import.meta.url));
8
+ export const claudeBootstrapPath = (cwd) => join(cwd, '.claude', 'rsc-bootstrap.mjs');
9
+
10
+ export function ensureClaudeBootstrap(cwd) {
11
+ const dest = claudeBootstrapPath(cwd);
12
+ mkdirSync(dirname(dest), { recursive: true });
13
+ copyFileSync(join(HERE, 'clone-bootstrap.mjs'), dest);
14
+ }
15
+
16
+ // script and args are internal lifecycle identifiers, never caller-provided shell text.
17
+ export function claudeLifecycleCommand(script, ...args) {
18
+ return `node "\${CLAUDE_PROJECT_DIR}/.claude/rsc-bootstrap.mjs" "quiet" "\${CLAUDE_PROJECT_DIR}" "\${CLAUDE_PROJECT_DIR}/.rsc/${script}" ${args.join(' ')}`;
19
+ }
20
+
21
+ // The committed hooks and the local lifecycle hooks share this file. Retire it
22
+ // only after both settings surfaces stop referencing it; unreadable settings retain it.
23
+ export function pruneClaudeBootstrap(cwd) {
24
+ for (const name of ['settings.json', 'settings.local.json']) {
25
+ const file = join(cwd, '.claude', name);
26
+ if (!existsSync(file)) continue;
27
+ try {
28
+ const config = JSON.parse(readFileSync(file, 'utf8'));
29
+ if (!config || typeof config !== 'object' || Array.isArray(config)) return;
30
+ if (JSON.stringify(config.hooks || {}).replace(/\\\\/g, '/').includes('.claude/rsc-bootstrap.mjs')) return;
31
+ } catch { return; }
32
+ }
33
+ try { rmSync(claudeBootstrapPath(cwd), { force: true }); } catch { /* cleanup must not break uninstall */ }
34
+ }
package/targets/claude.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { pruneClaudeBootstrap } from './claude-lifecycle.js';
1
2
  import { readFileSync, writeFileSync, existsSync, mkdirSync, copyFileSync, rmSync } from 'node:fs';
2
3
  import { dirname, join, relative, sep } from 'node:path';
3
4
  import { fileURLToPath } from 'node:url';
@@ -48,12 +49,7 @@ export function hookWiringOf(entry) {
48
49
  const ATTRIBUTION_MARKER = '.rsc/attribution-default';
49
50
 
50
51
  export function unwireHook(paths) {
51
- // The bootstrap lives in the COMMITTED tree, so leaving it behind does not just orphan a file the
52
- // way a stray `.rsc/` entry would — it leaves an executable in something the user pushes. Nothing
53
- // else removes it: uninstall and purge only ever knew about `.rsc/`.
54
- try {
55
- rmSync(join(paths.projectRoot, '.claude', 'rsc-bootstrap.mjs'), { force: true });
56
- } catch { /* never let cleanup be the thing that fails */ }
52
+ const finish = (removed) => { pruneClaudeBootstrap(paths.projectRoot); return removed; };
57
53
 
58
54
  // The shadow CLAUDE.md exists only to keep the hook from being doubled by a natively-read
59
55
  // AGENTS.md. Unwiring the hook removes the reason for it. Only ever takes back an untouched one.
@@ -61,9 +57,9 @@ export function unwireHook(paths) {
61
57
  const removed = shadow ? [shadow] : [];
62
58
 
63
59
  const file = paths.hookTarget;
64
- if (!existsSync(file)) return removed;
60
+ if (!existsSync(file)) return finish(removed);
65
61
  let settings;
66
- try { settings = JSON.parse(readFileSync(file, 'utf8')); } catch { return removed; }
62
+ try { settings = JSON.parse(readFileSync(file, 'utf8')); } catch { return finish(removed); }
67
63
  // wireHook's attribution default goes back out with it — only when wireHook wrote it (the marker)
68
64
  // and it is still untouched. The same value set by the person before rsc stays theirs.
69
65
  const marker = join(paths.projectRoot, ATTRIBUTION_MARKER);
@@ -72,9 +68,9 @@ export function unwireHook(paths) {
72
68
  if (ours) delete settings.attribution;
73
69
  try { rmSync(marker, { force: true }); } catch { /* cleanup never fails the uninstall */ }
74
70
  if (!settings.hooks) {
75
- if (!ours) return removed;
71
+ if (!ours) return finish(removed);
76
72
  writeFileSync(file, JSON.stringify(settings, null, 2) + '\n');
77
- return [...removed, file];
73
+ return finish([...removed, file]);
78
74
  }
79
75
  for (const event of Object.keys(settings.hooks)) {
80
76
  settings.hooks[event] = (settings.hooks[event] || []).filter((e) => {
@@ -85,7 +81,7 @@ export function unwireHook(paths) {
85
81
  }
86
82
  if (Object.keys(settings.hooks).length === 0) delete settings.hooks;
87
83
  writeFileSync(file, JSON.stringify(settings, null, 2) + '\n');
88
- return [...removed, file];
84
+ return finish([...removed, file]);
89
85
  }
90
86
 
91
87
  // SessionStart runs a project-local session-start.mjs via `node`: it prints
@@ -1,3 +1,4 @@
1
+ import { ensureClaudeBootstrap, claudeLifecycleCommand, pruneClaudeBootstrap } from './claude-lifecycle.js';
1
2
  // Wiring for knowledge sync (`knowledge-sync.mjs`): two lifecycle events per assistant — the person
2
3
  // sends a message, the agent finishes — in the same project-local config files the session memory
3
4
  // uses, under a needle of its own so either can be wired or removed without touching the other.
@@ -66,6 +67,7 @@ function handler(target, event) {
66
67
  ? '"$(git rev-parse --show-toplevel)/.rsc/knowledge-sync.mjs"'
67
68
  : '".rsc/knowledge-sync.mjs"';
68
69
  const value = { type: 'command', command: `node ${script} hook ${target} ${event}`, timeout: target === 'gemini' ? 10000 : 10 };
70
+ if (target === 'claude') value.command = claudeLifecycleCommand('knowledge-sync.mjs', 'hook', target, event);
69
71
  if (target === 'codex') value.commandWindows = `node "$((git rev-parse --show-toplevel).Trim())/.rsc/knowledge-sync.mjs" hook ${target} ${event}`;
70
72
  if (target === 'gemini') value.name = `rsc-knowledge-${event}`;
71
73
  return value;
@@ -145,6 +147,8 @@ export function wireKnowledge(target, cwd = process.cwd()) {
145
147
  const config = target === 'opencode' ? null : readConfig(configPath);
146
148
  if (target !== 'opencode' && !validHookConfig(config)) return { mode: 'degraded', reason: 'config-invalid', paths: [] };
147
149
 
150
+ if (target === 'claude') ensureClaudeBootstrap(cwd);
151
+
148
152
  const script = join(cwd, '.rsc', 'knowledge-sync.mjs');
149
153
  mkdirSync(dirname(script), { recursive: true });
150
154
  copyFileSync(join(HERE, 'knowledge-sync.mjs'), script);
@@ -183,6 +187,7 @@ export function unwireKnowledge(target, cwd = process.cwd()) {
183
187
  const config = readConfig(path);
184
188
  if (config) { strip(config); writeFileSync(path, `${JSON.stringify(config, null, 2)}\n`); touched.push(path); }
185
189
  }
190
+ if (target === 'claude') pruneClaudeBootstrap(cwd);
186
191
  return touched;
187
192
  }
188
193
 
package/targets/memory.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { ensureClaudeBootstrap, claudeLifecycleCommand, pruneClaudeBootstrap } from './claude-lifecycle.js';
1
2
  import {
2
3
  appendFileSync, copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync,
3
4
  } from 'node:fs';
@@ -83,6 +84,7 @@ function handler(target, event) {
83
84
  command: `node ${unixScript} ${target} ${event}`,
84
85
  timeout: target === 'gemini' ? 5000 : event === 'end' && target === 'codex' ? 3 : 5,
85
86
  };
87
+ if (target === 'claude') value.command = claudeLifecycleCommand('session-memory-adapter.mjs', target, event);
86
88
  if (target === 'codex') {
87
89
  value.commandWindows = `node \"$((git rev-parse --show-toplevel).Trim())/.rsc/session-memory-adapter.mjs\" ${target} ${event}`;
88
90
  value.additionalContextLimit = 1400;
@@ -184,6 +186,8 @@ export function wireMemory(target, cwd = process.cwd()) {
184
186
  return { mode: 'degraded', reason: 'rule-collision', paths: [] };
185
187
  }
186
188
 
189
+ if (target === 'claude') ensureClaudeBootstrap(cwd);
190
+
187
191
  const [core, adapter, cli] = commonPaths(cwd);
188
192
  mkdirSync(dirname(core), { recursive: true });
189
193
  copyFileSync(join(HERE, 'session-memory-core.mjs'), core);
@@ -264,6 +268,7 @@ export function unwireMemory(target, cwd = process.cwd()) {
264
268
  const rule = join(cwd, '.cursor', 'rules', 'rsc-memory.mdc');
265
269
  if (existsSync(rule) && readFileSync(rule, 'utf8').includes('rsc-memory:managed')) { rmSync(rule, { force: true }); touched.push(rule); }
266
270
  }
271
+ if (target === 'claude') pruneClaudeBootstrap(cwd);
267
272
  return touched;
268
273
  }
269
274
 
@@ -11,7 +11,8 @@
11
11
  // rsc's own knowledge commits (📥/📝 docs(auto)) are not the person's unpushed work. If the current feature branch has uncommitted changes or commits
12
12
  // that were never pushed, the guard DENIES the command and tells the agent to run
13
13
  // `ship` (commit → push → PR). Opening the PR itself is `ship`'s job and the skill's
14
- // hard rule; this hook guarantees you cannot quietly abandon unsaved/unpushed work.
14
+ // hard rule. An explicitly open main also permits parking a clean local-only experiment,
15
+ // with a reminder; publishing and merging still run their separate gates.
15
16
  //
16
17
  // Design: precise (only fires on a trunk switch/merge), local-only (no network, no gh),
17
18
  // and FAIL-OPEN — any ambiguity (detached HEAD, no repo, git error) allows the command.
@@ -22,7 +23,10 @@ import { spawnSync } from 'node:child_process';
22
23
 
23
24
  const root = process.argv[2] || process.cwd();
24
25
 
25
- function allow() { process.exit(0); }
26
+ function allow(message) {
27
+ if (message) process.stdout.write(JSON.stringify({ systemMessage: message }));
28
+ process.exit(0);
29
+ }
26
30
  function deny(reason) {
27
31
  process.stdout.write(JSON.stringify({
28
32
  hookSpecificOutput: {
@@ -86,6 +90,33 @@ const MERGE = new RegExp(String.raw`\bgit\s+${GOPTS}merge\b`);
86
90
  const SH = await import(new URL('./shell-unwrap.mjs', import.meta.url)).catch(() => null);
87
91
  const judged = SH ? SH.expand(command).map((s) => s.replace(/"(?:[^"\\]|\\.)*"|'[^']*'/g, '""')) : [command];
88
92
 
93
+ // A parking exception is deliberately narrower than the legacy landing detector: one
94
+ // non-destructive switch, no chained delivery, and the checkout the command really addresses.
95
+ function parkingSwitch(text, cwd, depth = 0) {
96
+ if (!SH || depth > 6 || /[$`<>]/.test(text)) return null;
97
+ const parts = SH.segments(text);
98
+ if (parts.length !== 1) return null;
99
+ const args = SH.words(parts[0]).map(w => w.text);
100
+ // Unlike generic command detection, granting an exception cannot discard environment
101
+ // assignments or wrapper options: env -C and GIT_DIR can select another checkout.
102
+ if (['bash', 'sh', 'zsh', 'dash', 'ksh'].includes(args[0]) && args[1] === '-c' && args.length === 3) {
103
+ return parkingSwitch(args[2], cwd, depth + 1);
104
+ }
105
+ if (args.shift() !== 'git') return null;
106
+ let dir = cwd;
107
+ while (args[0] === '-C') {
108
+ args.shift(); const path = args.shift();
109
+ if (path === undefined) return null;
110
+ dir = resolve(dir, path);
111
+ }
112
+ if (!['switch', 'checkout'].includes(args.shift())) return null;
113
+ const names = args.filter(arg => !['-q', '--quiet'].includes(arg));
114
+ if (names.length !== 1 || !['main', 'master'].includes(names[0])) return null;
115
+ return { dir };
116
+ }
117
+ const parking = parkingSwitch(command, input.cwd || root);
118
+
119
+
89
120
  const gitIn = (dir, ...args) => {
90
121
  const r = spawnSync('git', ['-C', dir, ...args], { windowsHide: true, encoding: 'utf8' });
91
122
  return r.status === 0 ? (r.stdout || '').trim() : null;
@@ -103,7 +134,7 @@ function mergesIntoTrunk(segment) {
103
134
  const b = gitIn(dir, 'rev-parse', '--abbrev-ref', 'HEAD');
104
135
  return b === 'main' || b === 'master';
105
136
  }
106
- if (!judged.some((s) => TRUNK.test(s) || mergesIntoTrunk(s))) allow();
137
+ if (!parking && !judged.some((s) => TRUNK.test(s) || mergesIntoTrunk(s))) allow();
107
138
 
108
139
  // Commits in a range that are the person's: rsc's own knowledge commits are left out.
109
140
  const RSC_OWN = /^(?:📥|📝) docs\(auto\)/u;
@@ -120,8 +151,11 @@ if (!branch || branch === 'HEAD' || branch === 'main' || branch === 'master') al
120
151
  const tail = '\n(If this is intentional and you accept the risk, create .rsc/.no-ship-guard to disable this guard.)';
121
152
 
122
153
  // 1) Uncommitted work would be carried off the feature branch.
123
- const dirty = git('status', '--porcelain');
124
- if (dirty && dirty.length > 0) {
154
+ // NUL records preserve unusual filenames and distinguish tracked changes from untracked
155
+ // editor metadata. Git's own ignore rules still apply; source files are never excluded here.
156
+ const dirty = git('status', '--porcelain=v1', '-z', '--untracked-files=all');
157
+ const pending = dirty?.split('\0').filter(Boolean).filter(record => !record.startsWith('?? .vscode/'));
158
+ if (pending?.length) {
125
159
  deny(`You're leaving feature branch "${branch}" with uncommitted changes. Commit them first — run the \`ship\` skill (commit → push → PR), don't abandon the diff.${tail}`);
126
160
  }
127
161
 
@@ -136,6 +170,17 @@ if (upstream) {
136
170
  // No upstream at all: if the branch carries commits beyond the trunk, it was never pushed.
137
171
  const aheadOfTrunk = ownCommits('main..HEAD') ?? ownCommits('master..HEAD');
138
172
  if (aheadOfTrunk && Number(aheadOfTrunk) > 0) {
173
+ // workflow=main is the person's explicit choice. Parking keeps the local branch;
174
+ // it neither delivers the experiment nor opts out of any push/spec/seal gate.
175
+ const sameCheckout = parking && gitIn(parking.dir, 'rev-parse', '--absolute-git-dir') === git('rev-parse', '--absolute-git-dir');
176
+ const remoteBranches = git('for-each-ref', '--format=%(refname:strip=3)', 'refs/remotes');
177
+ const knownPublished = remoteBranches === null || remoteBranches.split('\n').includes(branch);
178
+ if (sameCheckout && !knownPublished && existsSync(join(root, '.rsc', '.no-trunk-guard'))) {
179
+ allow(`rsc: leaving "${branch}" parked locally with ${aheadOfTrunk} unpublished commit(s). The branch is preserved; return to it to resume. This does not publish or approve the work.`);
180
+ }
181
+ if (knownPublished) {
182
+ deny(`Feature branch "${branch}" has a remote-tracking reference but no upstream configured. Recover: set its upstream with \`git branch --set-upstream-to=<remote>/<branch>\`, review any pending commits, and run the \`ship\` skill before returning to the trunk.${tail}`);
183
+ }
139
184
  deny(`Feature branch "${branch}" was never pushed (no upstream, ${aheadOfTrunk} commit(s) ahead of the trunk). Push it and open a PR — run the \`ship\` skill — before leaving it.${tail}`);
140
185
  }
141
186
  }