@ericrisco/rsc 4.2.1 → 4.2.3

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/README.md CHANGED
@@ -310,7 +310,7 @@ commit on a closed `main` is still refused. It is saved as `gitPermissions` in `
310
310
 
311
311
  | Assistant | Where it goes |
312
312
  | --- | --- |
313
- | Claude Code | `.claude/settings.json` → `permissions.allow` (force-push under `ask`) |
313
+ | Claude Code | `.claude/settings.json` → Bash and PowerShell rules under `permissions.allow` (force-push under `ask`) |
314
314
  | Codex | `.codex/rules/rsc-git.rules` (force-push → `prompt`) |
315
315
  | Gemini | `.gemini/settings.json` → `tools.allowed` |
316
316
  | OpenCode | `opencode.json`: the `permissions` list on OpenCode 2, `permission.bash` on 1.x. An `opencode.jsonc` is never rewritten; rsc prints the rules to paste. |
@@ -319,6 +319,20 @@ commit on a closed `main` is still refused. It is saved as `gitPermissions` in `
319
319
  `rsc git-permissions status | on | off` explains, per assistant, what rsc controls and what is left
320
320
  to the assistant.
321
321
 
322
+ With the danger guard enabled for a mixed or non-technical profile, direct Git commits and pushes
323
+ through Claude's shell tools can prompt for review of credential filenames. The guard checks the
324
+ index before a commit and local outgoing history before a push. It looks for environment files,
325
+ PEM and key files, and files in a `secrets/` directory. Example environment files such as
326
+ `.env.example` are allowed. A filename check cannot identify a token inside an ordinary source file.
327
+ Keep any content-based secret scanning enabled.
328
+
329
+ The danger guard receives Bash and PowerShell tool events. Connector permissions control actions
330
+ such as sending mail through Gmail. If the shell guard itself fails internally, its existing
331
+ fail-open policy lets the assistant's ordinary permissions decide.
332
+
333
+ In Claude Code, project skills can take precedence over built-in commands such as `/init` and
334
+ `/plan`. Use `/rsc-ship` for the RSC shipping procedure when Claude provides its own `/ship`.
335
+
322
336
  ### Memory between sessions
323
337
 
324
338
  On supported local targets, rsc checkpoints observable repository state (branch, worktree, HEAD,
package/manifest.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.2.1",
2
+ "version": "4.2.3",
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.2.1",
3
+ "version": "4.2.3",
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": {
@@ -27,7 +27,7 @@ import {
27
27
  } from '../targets/memory.js';
28
28
  import { wireUpdate, unwireUpdate, updateManagedPaths, updateArtifactsPresent } from '../targets/update-wiring.js';
29
29
  import { wireKnowledge, unwireKnowledge, knowledgeManagedPaths, knowledgeArtifactsPresent } from '../targets/knowledge-wiring.js';
30
- import { wireGitPermissions, unwireGitPermissions, gitPermissionsPath } from '../targets/git-permissions.js';
30
+ import { wireGitPermissions, unwireGitPermissions, gitPermissionsPath, claudeGitOwnershipPath } from '../targets/git-permissions.js';
31
31
  import { wireDeepseekBridge } from '../targets/deepseek-bridge.js';
32
32
 
33
33
  const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');
@@ -125,6 +125,7 @@ export function managedPathsForInstall({ skillIds, agentIds = [], target, home,
125
125
  if (policy?.memory !== false) out.push(...memoryManagedPaths(target, cwd));
126
126
  out.push(...updateManagedPaths(target, cwd));
127
127
  out.push(...knowledgeManagedPaths(target, cwd));
128
+ if (target === 'claude') out.push(claudeGitOwnershipPath(cwd));
128
129
  if (gitPermissionsPath(target, cwd)) out.push(gitPermissionsPath(target, cwd)); // backed up before it is merged into
129
130
  if (targetHasAgents(target)) {
130
131
  const state = readState(paths.stateFile);
@@ -6,10 +6,10 @@
6
6
  // that only lives in a skill's prose is the decorative gate (P2), so the three live here.
7
7
  // Spec: 02-DOCS/wiki/sdd/specs/asdd-v4.md.
8
8
  //
9
- // One JSONL file, append-only: `finding`, `outcome` and `round` entries. It sits under .rsc/ and is
9
+ // One JSONL file, append-only: findings, outcomes, ordinary reviews and exceptional decisions. It sits under .rsc/ and is
10
10
  // excluded from the sello's candidate like every other journal the harness writes (targets/sello.mjs).
11
11
 
12
- import { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync } from 'node:fs';
12
+ import { appendFileSync, closeSync, existsSync, fstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, realpathSync, unlinkSync } from 'node:fs';
13
13
  import { join } from 'node:path';
14
14
  import { spawnSync } from 'node:child_process';
15
15
  import { criterionRefs } from './review-findings.js';
@@ -67,8 +67,47 @@ export function readLedger(root) {
67
67
  }
68
68
 
69
69
  function append(root, entries) {
70
- mkdirSync(join(root, '.rsc'), { recursive: true });
71
- appendFileSync(join(root, LEDGER_PATH), entries.map((e) => `${JSON.stringify(e)}\n`).join(''));
70
+ const fd = openSync(join(root, LEDGER_PATH), 'a+');
71
+ try {
72
+ // A killed writer may have left a partial final JSON line. Preserve those bytes and
73
+ // start the next event on its own line, so readLedger can still replay the next write.
74
+ const size = fstatSync(fd).size;
75
+ const last = Buffer.alloc(1);
76
+ if (size && readSync(fd, last, 0, 1, size - 1) && last[0] !== 10) appendFileSync(fd, '\n');
77
+ appendFileSync(fd, entries.map((e) => `${JSON.stringify(e)}\n`).join(''));
78
+ } finally {
79
+ closeSync(fd);
80
+ }
81
+ }
82
+
83
+ // Serialize read/check/append across CLI processes. A second writer must see the first
84
+ // writer's decision before assigning ids, spending a review or closing its blocker.
85
+ function ledgerMutation(fn) {
86
+ return (root, ...args) => {
87
+ mkdirSync(join(root, '.rsc'), { recursive: true });
88
+ const lock = join(root, '.rsc', 'review-ledger.lock');
89
+ const deadline = Date.now() + 3000;
90
+ for (;;) {
91
+ try { closeSync(openSync(lock, 'wx')); break; }
92
+ catch (err) {
93
+ if (err.code !== 'EEXIST') throw err;
94
+ if (Date.now() >= deadline) throw new Error(`Review ledger is busy. Retry when the writer finishes. If it crashed, remove its stale lock at ${lock}.`);
95
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 25);
96
+ }
97
+ }
98
+ try { return fn(root, ...args); }
99
+ finally { unlinkSync(lock); }
100
+ };
101
+ }
102
+
103
+ // A recovery verdict owns its finding's outcome in the same JSON line. A partial write
104
+ // cannot close the blocker without its evidence or spend the approval without its outcome.
105
+ function outcomeEntries(ledger) {
106
+ return ledger.flatMap(e => {
107
+ if (e.type === 'outcome') return [e];
108
+ if (e.type === 'recovery-result') return [{ id: e.finding, outcome: e.outcome }];
109
+ return [];
110
+ });
72
111
  }
73
112
 
74
113
  // A panel completes an explicit round, or starts one when an older caller omitted `round`.
@@ -125,20 +164,24 @@ export function criterionSignals(ledger) {
125
164
  }
126
165
 
127
166
  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.`;
167
+ 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. For a confirmed final-round blocker, its owner can authorize one focused validation with review ledger recover.`;
129
168
  }
130
169
 
131
170
  // → [{id, status: 'new'|'repeat', repeatOf?, ...finding}]. A repeat is recorded too (it is the noise
132
171
  // being measured) but points at the original, and the caller must not raise it again.
133
- export function record(root, rawFindings, { task = '', now = new Date().toISOString() } = {}) {
172
+ export const record = ledgerMutation(function (root, rawFindings, { task = '', now = new Date().toISOString() } = {}) {
134
173
  const ledger = readLedger(root);
135
174
  const budget = reviewBudget(ledger, task);
136
175
  // An explicit round is the context for the entire review, before AND after its panel. The
137
176
  // implement protocol records the panel first, while other callers consolidate findings first.
177
+ const inRecovery = ledger.some(e => e.type === 'recovery' && e.task === task);
138
178
  const reviewRound = budget.explicit ? budget.count : 0;
139
179
  // A finding closed as fixed that shows up again is a regression, not noise: it is raised anew.
140
- const fixed = new Set(ledger.filter((e) => e.type === 'outcome' && e.outcome === 'fixed').map((e) => e.id));
180
+ const fixed = new Set(outcomeEntries(ledger).filter((e) => e.outcome === 'fixed').map((e) => e.id));
141
181
  const seen = ledger.filter((e) => e.type === 'finding' && !e.repeatOf && !fixed.has(e.id));
182
+ let roundRef = QUALIFIED_TASK.test(task) ? { round_pending: true } : {};
183
+ if (reviewRound) roundRef = { round: reviewRound };
184
+ if (inRecovery) roundRef = { recovery: true };
142
185
  let n = ledger.filter((e) => e.type === 'finding').length;
143
186
  const out = [];
144
187
  for (const raw of rawFindings) {
@@ -146,9 +189,6 @@ export function record(root, rawFindings, { task = '', now = new Date().toISOStr
146
189
  const f = normalize(raw);
147
190
  n += 1;
148
191
  const original = seen.find((s) => sameClaim(s, f));
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
192
  const entry = { type: 'finding', id: `L${n}`, task, at: now, ...f, ...roundRef, ...(original ? { repeatOf: original.id } : {}) };
153
193
  if (!original) seen.push(entry);
154
194
  out.push(entry);
@@ -157,25 +197,29 @@ export function record(root, rawFindings, { task = '', now = new Date().toISOStr
157
197
  const signals = criterionSignals([...ledger, ...out]);
158
198
  return out.map((e) => ({ ...e, status: e.repeatOf ? 'repeat' : 'new',
159
199
  advisories: signals.filter((s) => s.findings.includes(e.id)) }));
160
- }
200
+ });
161
201
 
162
- export function outcome(root, id, value, { now = new Date().toISOString() } = {}) {
202
+ export const outcome = ledgerMutation(function (root, id, value, { now = new Date().toISOString() } = {}) {
163
203
  if (!OUTCOMES.includes(value)) {
164
204
  return { ok: false, message: `rsc: unknown outcome "${value}". Use one of: ${OUTCOMES.join(', ')}.` };
165
205
  }
166
- if (!readLedger(root).some((e) => e.type === 'finding' && e.id === id)) {
206
+ const ledger = readLedger(root);
207
+ if (ledger.some(e => e.type === 'recovery' && e.finding === id)) {
208
+ return { ok: false, message: `rsc: the independent recovery-result owns the outcome for ${id}. See its decision queue entry.` };
209
+ }
210
+ if (!ledger.some((e) => e.type === 'finding' && e.id === id)) {
167
211
  return { ok: false, message: `rsc: no finding "${id}" in ${LEDGER_PATH}. Run \`npx @ericrisco/rsc review ledger stats\` to see the recorded ids.` };
168
212
  }
169
213
  append(root, [{ type: 'outcome', id, outcome: value, at: now }]);
170
214
  return { ok: true, message: `${id}: ${value}` };
171
- }
215
+ });
172
216
 
173
217
  // Counts one more review round for a task. The fourth is refused, with the way out in the message
174
218
  // (P6): rethink the approach, or park the task in the decision queue and go on with independent work.
175
219
  // The task is qualified by its spec (`<slug>/T001`): every plan numbers its tasks from T001, and a
176
220
  // bare id would let one feature inherit another's rounds and park work never reviewed.
177
221
  export const QUALIFIED_TASK = /^[^/\s]+\/[^/\s]+$/;
178
- export function round(root, task, { now = new Date().toISOString() } = {}) {
222
+ export const round = ledgerMutation(function (root, task, { now = new Date().toISOString() } = {}) {
179
223
  if (!QUALIFIED_TASK.test(task)) {
180
224
  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.` };
181
225
  }
@@ -189,6 +233,25 @@ export function round(root, task, { now = new Date().toISOString() } = {}) {
189
233
  }
190
234
  append(root, [{ type: 'round', task, n, at: now }]);
191
235
  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') };
236
+ });
237
+
238
+ function reviewedCommit(root, repo) {
239
+ // Bound to the commit reviewed: code committed after it is code no panel has seen.
240
+ const r = spawnSync('git', ['-C', repo, 'rev-parse', 'HEAD'], { encoding: 'utf8', windowsHide: true });
241
+ const sha = r.status === 0 ? r.stdout.trim() : null;
242
+ if (repo !== root) {
243
+ // A folder inside some repo resolves HEAD by walking up; only the checkout's own top level counts.
244
+ const top = spawnSync('git', ['-C', repo, 'rev-parse', '--show-toplevel'], { encoding: 'utf8', windowsHide: true });
245
+ const real = (p) => { try { return realpathSync(p); } catch { return null; } };
246
+ if (!sha || top.status !== 0 || real(top.stdout.trim()) !== real(repo)) {
247
+ return { ok: false, message: `rsc: --repo ${repo} is not the top of a git checkout with a commit; name the repository the panel reviewed.` };
248
+ }
249
+ }
250
+ return { ok: true, sha };
251
+ }
252
+
253
+ function lensList(lenses) {
254
+ return [...new Set(String(lenses || '').split(',').map((l) => l.trim().toLowerCase()).filter(Boolean))];
192
255
  }
193
256
 
194
257
  // Records that a review panel ran on a task: which lenses, distinct. Self-attested, like the sello's
@@ -197,41 +260,114 @@ export function round(root, task, { now = new Date().toISOString() } = {}) {
197
260
  // `repo` names the reviewed checkout when it is not the ledger's own repository: a child repo or its
198
261
  // worktree supervised by a workspace keeps its evidence in the workspace, but the commit reviewed is
199
262
  // the child's, and that is the commit the push gate checks the panel against.
200
- export function panel(root, task, lenses, { now = new Date().toISOString(), repo = root } = {}) {
263
+ export const panel = ledgerMutation(function (root, task, lenses, { now = new Date().toISOString(), repo = root } = {}) {
201
264
  if (!QUALIFIED_TASK.test(task)) {
202
265
  return { ok: false, message: `rsc: qualify the task with its spec slug, e.g. \`review ledger panel <slug>/closing --lenses correctness,security,tests\`.` };
203
266
  }
204
- const list = [...new Set(String(lenses || '').split(',').map((l) => l.trim().toLowerCase()).filter(Boolean))];
267
+ const list = lensList(lenses);
205
268
  if (!list.length) return { ok: false, message: 'rsc: name the lenses that ran: --lenses correctness,security,tests' };
206
269
  const ledger = readLedger(root);
207
270
  const budget = reviewBudget(ledger, task);
208
271
  const n = budget.count + (!budget.count || budget.panelled ? 1 : 0);
209
- if (n > MAX_ROUNDS) return { ok: false, message: convergenceMessage(task) };
210
- // Bound to the commit reviewed: code committed after it is code no panel has seen.
211
- const r = spawnSync('git', ['-C', repo, 'rev-parse', 'HEAD'], { encoding: 'utf8', windowsHide: true });
212
- const sha = r.status === 0 ? r.stdout.trim() : null;
213
- if (repo !== root) {
214
- // A folder inside some repo resolves HEAD by walking up; only the checkout's own top level counts.
215
- const top = spawnSync('git', ['-C', repo, 'rev-parse', '--show-toplevel'], { encoding: 'utf8', windowsHide: true });
216
- const real = (p) => { try { return realpathSync(p); } catch { return null; } };
217
- if (!sha || top.status !== 0 || real(top.stdout.trim()) !== real(repo)) {
218
- return { ok: false, message: `rsc: --repo ${repo} is not the top of a git checkout with a commit; name the repository the panel reviewed.` };
219
- }
220
- }
272
+ if (n > MAX_ROUNDS || ledger.some(e => e.type === 'recovery' && e.task === task)) return { ok: false, message: convergenceMessage(task) };
273
+ const reviewed = reviewedCommit(root, repo);
274
+ if (!reviewed.ok) return reviewed;
275
+ const { sha } = reviewed;
221
276
  const assigned = panelAssignments(ledger);
222
277
  const finding_ids = ledger.filter((e) => e.type === 'finding' && e.task === task && e.round_pending
223
278
  && !assigned.has(JSON.stringify([task, e.id]))).map((e) => e.id);
224
279
  const entry = { type: 'panel', task, round: n, finding_ids, lenses: list, sha, at: now };
225
280
  append(root, [entry]);
226
281
  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') };
227
- }
282
+ });
283
+
284
+ // Approval and validation are separate attestations. Neither consumes an ordinary round.
285
+ // The task stays in the decision queue until the human closes it with the successful result.
286
+ export const recover = ledgerMutation(function (root, task, { finding, approvedBy, reason, scope, confirmation, repo }) {
287
+ if (!QUALIFIED_TASK.test(task) || ![finding, approvedBy, reason, scope, confirmation].every(text)) {
288
+ return { ok: false, message: 'rsc: recover needs a qualified task, --finding, --approved-by, --reason, --scope and --confirmation (the proof that confirmed the blocker).' };
289
+ }
290
+ const ledger = readLedger(root);
291
+ const history = ledger.filter(e => e.task === task);
292
+ if (history.some(e => e.type === 'recovery')) {
293
+ return { ok: false, message: `rsc: the one exceptional review for ${task} has already been authorized.` };
294
+ }
295
+ const budget = reviewBudget(history, task);
296
+ if (budget.count !== MAX_ROUNDS) return { ok: false, message: `rsc: recovery requires exactly ${MAX_ROUNDS} ordinary rounds.` };
297
+ const blocker = history.find(e => e.type === 'finding' && e.id === finding && !e.repeatOf && e.severity === 'blocker');
298
+ const last = ledger.filter(e => e.type === 'outcome' && e.id === finding).at(-1);
299
+ const assigned = panelAssignments(history);
300
+ const inFinalRound = history.some(e => e.type === 'finding' && (e.id === finding || e.repeatOf === finding)
301
+ && (e.round ?? assigned.get(JSON.stringify([task, e.id]))) === MAX_ROUNDS);
302
+ if (!blocker || !inFinalRound || last?.outcome !== 'parked') {
303
+ return { ok: false, message: `rsc: name an original, currently parked blocker of ${task} observed in its final round.` };
304
+ }
305
+ const panel = history.filter(e => e.type === 'panel').at(-1);
306
+ let base = budget.panelled ? panel?.sha : null;
307
+ if (repo || !base) {
308
+ // Tier 1 may have recorded only rounds, or a panel only in an earlier round. Capture
309
+ // its checkout before the authorized fix when the final round supplies no commit.
310
+ const checkout = repo || root;
311
+ const reviewed = reviewedCommit(root, checkout);
312
+ if (!reviewed.ok) return reviewed;
313
+ if (base && spawnSync('git', ['-C', checkout, 'merge-base', '--is-ancestor', base, reviewed.sha], { windowsHide: true }).status !== 0) {
314
+ return { ok: false, message: 'rsc: --repo must name the checkout of the original reviewed commit.' };
315
+ }
316
+ base ??= reviewed.sha;
317
+ }
318
+ if (!base) return { ok: false, message: 'rsc: recovery needs the original commit. Name its checkout with --repo.' };
319
+ append(root, [{ type: 'recovery', task, finding, base, approved_by: approvedBy, reason, scope, confirmation, at: new Date().toISOString() }]);
320
+ return { ok: true, message: `Authorized one independent validation for ${task}, finding ${finding}. Record its evidence with review ledger recovery-result.` };
321
+ });
322
+
323
+ export const recoveryResult = ledgerMutation(function (root, task, { candidate, reviewer, evidence, result, lenses, repo = root }) {
324
+ const ledger = readLedger(root);
325
+ const history = ledger.filter(e => e.task === task);
326
+ const approval = history.find(e => e.type === 'recovery');
327
+ if (!approval || history.some(e => e.type === 'recovery-result')) {
328
+ return { ok: false, message: `rsc: ${task} has no unused, owner-authorized exceptional review.` };
329
+ }
330
+ const list = lensList(lenses);
331
+ if (![candidate, reviewer, evidence].every(text) || !list.length || !['passed', 'blocked'].includes(result)) {
332
+ return { ok: false, message: 'rsc: provide --candidate <reviewed commit SHA>, --independent-reviewer, --lenses, --evidence and --result passed|blocked.' };
333
+ }
334
+ const lastPanel = history.filter(e => e.type === 'panel').at(-1);
335
+ const missing = (lastPanel?.lenses || []).filter(l => !list.includes(l));
336
+ if (missing.length) return { ok: false, message: `rsc: recovery needs the previous panel's lenses: ${missing.join(', ')}.` };
337
+ const reviewed = reviewedCommit(root, repo);
338
+ if (!reviewed.ok) return reviewed;
339
+ if (candidate !== reviewed.sha || candidate === approval.base) {
340
+ return { ok: false, message: 'rsc: --candidate must be the full reviewed HEAD of the corrected checkout. Use --repo when reviewing a child checkout.' };
341
+ }
342
+ const ancestry = spawnSync('git', ['-C', repo, 'merge-base', '--is-ancestor', approval.base, candidate], { windowsHide: true });
343
+ if (ancestry.status !== 0) {
344
+ return { ok: false, message: 'rsc: commit the correction on the original reviewed history and use --repo for its checkout.' };
345
+ }
346
+ const { finding } = approval;
347
+ const at = new Date().toISOString();
348
+ const outcome = result === 'passed' ? 'fixed' : 'parked';
349
+ const outcomes = new Map(outcomeEntries(ledger).map(e => [e.id, e.outcome]));
350
+ outcomes.set(finding, outcome);
351
+ const remaining = new Set();
352
+ for (const entry of history) {
353
+ if (entry.type !== 'finding' || entry.severity !== 'blocker') continue;
354
+ const id = entry.repeatOf || entry.id;
355
+ const latest = outcomes.get(entry.id) || outcomes.get(id);
356
+ if (!latest || latest === 'parked') remaining.add(id);
357
+ }
358
+ const state = remaining.size ? 'parked' : 'resolved';
359
+ append(root, [{ type: 'recovery-result', task, finding, result, outcome, state, remaining: [...remaining], reviewer, evidence, lenses: list, sha: candidate, at }]);
360
+ return remaining.size
361
+ ? { ok: false, message: `Independent review recorded; ${task} remains parked (${[...remaining].join(', ')}). Replan in the decision queue.` }
362
+ : { ok: true, message: `Independent review passed for ${task} on ${candidate}; the owner can close its original decision queue entry.` };
363
+ });
228
364
 
229
365
  export function stats(root) {
230
366
  const ledger = readLedger(root);
231
367
  const findings = ledger.filter((e) => e.type === 'finding');
232
368
  const originals = findings.filter((f) => !f.repeatOf);
233
369
  const last = new Map();
234
- for (const e of ledger) if (e.type === 'outcome') last.set(e.id, e.outcome);
370
+ for (const e of outcomeEntries(ledger)) last.set(e.id, e.outcome);
235
371
  const outcomes = Object.fromEntries([...OUTCOMES, 'open'].map((k) => [k, 0]));
236
372
  for (const f of originals) outcomes[last.get(f.id) || 'open'] += 1;
237
373
  // Parked is undecided: a human holds it. Counting it as closed would understate the false rate.
package/scripts/rsc.js CHANGED
@@ -5,7 +5,7 @@ import { detectRepo } from './detect-repo.js';
5
5
  import { rank } from './consult.js';
6
6
  import { expandRecommends, toOutcomes, hasOutcome } from './lib/recommend.js';
7
7
  import { applyInstall, listInstalled, listInstalledAgents, listInstalledCommands, uninstall, syncInstalled, purgeReport, collisions, ownSkillPaths, resetAgents } from './install-apply.js';
8
- import { isAbsolute, relative, sep } from 'node:path';
8
+ import { isAbsolute, relative, resolve, sep } from 'node:path';
9
9
  import {
10
10
  stackAgentNames, targetHasAgents, isValidAgentModel, agentModelSetting, targetInheritsByDefault,
11
11
  effectiveAgentModel, writeAgentsDetailed, readDeveloperTier, AGENT_MODEL_INHERIT, AGENT_TARGET_IDS,
@@ -1360,6 +1360,8 @@ async function main() {
1360
1360
  'Use: npx @ericrisco/rsc review consolidate [report.md|findings.json ...] [--json] [--window <lines>]',
1361
1361
  ' Without files it reads stdin. Each lens report carries its findings in ```json findings blocks.',
1362
1362
  ' 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 [--repo <reviewed checkout>] | stats [--json]',
1363
+ ' npx @ericrisco/rsc review ledger recover <slug>/<task> --finding <id> --approved-by <owner> --reason <why> --scope <focused correction> --confirmation <blocker proof> [--repo <reviewed checkout>]',
1364
+ ' npx @ericrisco/rsc review ledger recovery-result <slug>/<task> --candidate <full commit SHA> --independent-reviewer <reviewer(s)> --lenses a,b,c --evidence <regression proof> --result passed|blocked [--repo <reviewed checkout>]',
1363
1365
  ' 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.',
1364
1366
  ' npx @ericrisco/rsc review escapes [--since <ref>] [--json]',
1365
1367
  ].join('\n');
@@ -1418,6 +1420,23 @@ async function main() {
1418
1420
  say(r.message);
1419
1421
  return;
1420
1422
  }
1423
+ if (sub === 'recover' || sub === 'recovery-result') {
1424
+ if (!a || a.startsWith('--')) return fail(USE);
1425
+ const value = (key) => {
1426
+ const v = str(key);
1427
+ return v && !v.startsWith('--') ? v.trim() : undefined;
1428
+ };
1429
+ if (argv.includes('--repo') && !value('repo')) return fail('rsc: --repo needs the path of the reviewed checkout.');
1430
+ const repo = value('repo') ? resolve(value('repo')) : undefined;
1431
+ const r = sub === 'recover'
1432
+ ? L.recover(root, a, { finding: value('finding'), approvedBy: value('approved-by'), reason: value('reason'),
1433
+ scope: value('scope'), confirmation: value('confirmation'), repo })
1434
+ : L.recoveryResult(root, a, { candidate: value('candidate'), reviewer: value('independent-reviewer'), evidence: value('evidence'),
1435
+ result: value('result'), lenses: value('lenses'), repo });
1436
+ if (!r.ok) return fail(r.message);
1437
+ say(r.message);
1438
+ return;
1439
+ }
1421
1440
  if (sub === 'stats') {
1422
1441
  const s = L.stats(root);
1423
1442
  say(json ? JSON.stringify(s, null, 2) : L.renderStats(s));
@@ -29,13 +29,16 @@ If the video is *rendered from data/code* (charts, timelines, JSON-driven scenes
29
29
 
30
30
  ElevenLabs Python SDK. The call is `convert(text, voice_id, model_id, output_format)`; auth via `ELEVENLABS_API_KEY`.
31
31
 
32
+ Set `ELEVENLABS_VOICE_ID` to a voice in your account's My Voices. To migrate a narration that used George, add Eldrin – Crisp British Baritone from the Voice Library and use its ID, `6WwXjDDEMyNmFG95zycZ`. Preview it with your script to check the delivery. [ElevenLabs voice replacements](https://elevenlabs.io/docs/help-center/product/voices/my-voices/what-are-default-voices)
33
+
32
34
  ```python
35
+ import os
33
36
  from elevenlabs.client import ElevenLabs
34
37
 
35
38
  client = ElevenLabs() # reads ELEVENLABS_API_KEY
36
39
  audio = client.text_to_speech.convert(
37
40
  text="Your narration script here.",
38
- voice_id="JBFqnCBsd6RMkjVDRZzb",
41
+ voice_id=os.environ["ELEVENLABS_VOICE_ID"],
39
42
  model_id="eleven_multilingual_v2", # final-quality VO
40
43
  output_format="mp3_44100_128", # codec_samplerate_bitrate
41
44
  )
@@ -51,7 +51,7 @@ Every spec answers four questions, and `spec:gate` refuses one dated 2026-11-03
51
51
 
52
52
  ### The risk decides, never the agent
53
53
 
54
- `npx @ericrisco/rsc risk [--base <ref>] [paths…]` classifies a change by **what it touches and what it adds** (the sello's path table plus fixed content patterns — password hashing, session cookies, payments, schema changes, secrets — so auth code in `src/app.js` is still auth; works with the sello off): tier 0 docs/copy → no reviewer; tier 1 ordinary code → one fresh-context reviewer; tier 2 auth, billing, CI workflows, migrations, secrets, harness config → the three-refuter panel **and human approval**. An agent's approval never counts as a human's. **Enforced at push:** a tier-2 branch leaves the machine only with a spec linked to it that passes `rsc spec gate` **and** a panel recorded with `rsc review ledger panel <slug>/<task> --lenses correctness,security,tests`.
54
+ `npx @ericrisco/rsc risk [--base <ref>] [paths…]` classifies a change by **what it touches and what it adds** (the sello's path table plus fixed content patterns — password hashing, session cookies, payments, schema changes, secrets — so auth code in `src/app.js` is still auth; works with the sello off): tier 0 docs/copy → no reviewer; tier 1 ordinary code → one fresh-context reviewer; tier 2 auth, billing, CI workflows, migrations, secrets, harness config → the three-refuter panel **and human approval**. An agent's approval never counts as a human's. **Enforced at push:** a tier-2 branch leaves the machine only with a spec linked to it that passes `rsc spec gate` **and** a panel recorded with `rsc review ledger panel <slug>/<task> --lenses correctness,security,tests`. An owner-authorized [exceptional recovery](../review/SKILL.md#exceptional-recovery-on-the-original-task) can supply the independent panel on the corrected commit.
55
55
 
56
56
  ### The loop converges
57
57
 
@@ -100,7 +100,7 @@ Autopilot does not stop the run for questions — it **parks**: real ambiguity,
100
100
  - `specify` uses a checkable reference it wrote itself (expected output, sample response) → `review-after` entry.
101
101
  - `clarify` records its assumptions (`suposición tomada`) → `review-after` entries.
102
102
  - `implement` parks `blocking` items and continues with the independent tasks.
103
- - `ship` lands by the rule below.
103
+ - `ship` lands by the rule below. In Claude Code, use `/rsc-ship` to load the project's shipping procedure where Claude reserves `/ship`.
104
104
 
105
105
  **Never hand the turn back mid-run.** No "¿sigo?" / "shall I continue?": not between phases, not while reviewers run. Background reviewers are waited for (their completion notice, or run them in the foreground); ending the turn to wait ends a headless run. A later "continue" from the person resumes the run; it is **not** approval for a tier-2 merge, which needs an explicit yes to that merge.
106
106
 
@@ -141,7 +141,7 @@ To target another provider, change `models.provider` and set `models.tiers` to t
141
141
  | provider | heavy | balanced | light |
142
142
  | --- | --- | --- | --- |
143
143
  | `anthropic` | `claude-opus-5-5` | `claude-sonnet-5-5` | `claude-haiku-5-5` |
144
- | `openai` | `gpt-5.1` (or current flagship) | `gpt-5.1-mini` | `gpt-5.1-nano` |
144
+ | `openai` | `gpt-6.2-astra` | `gpt-6.2-sol` | an available lightweight model |
145
145
  | `google` | `gemini-2.5-pro` | `gemini-2.5-flash` | `gemini-2.5-flash-lite` |
146
146
  | `openrouter` | a strong model slug | a mid model slug | a cheap/free model slug |
147
147
 
@@ -155,7 +155,7 @@ rsc installs a **`developer`** subagent into every assistant that supports file-
155
155
  harness is installed. It is the concrete embodiment of "run the fan-out on a smaller model":
156
156
 
157
157
  - It is pinned to the **balanced** tier — **Sonnet** for Anthropic-backed tools, the provider's
158
- mid model elsewhere (Gemini Flash, GPT-mini). It is **never** `light`/Haiku — that tier is too
158
+ mid model elsewhere (Gemini Flash, GPT Sol). It is **never** `light`/Haiku — that tier is too
159
159
  weak to build with. The floor for implementation is balanced.
160
160
  - The tier is chosen at **onboarding** (`init`, Step 4): balanced (default) or heavy. It is stored
161
161
  in `.rsc/developer.json` and the installer writes the per-target agent file with the resolved
@@ -47,9 +47,10 @@ status: in-progress
47
47
  ## Next — the single next step, so an interruption costs nothing
48
48
  ```
49
49
 
50
- The frontmatter says whose work it is, so «¿qué ha hecho cada uno?» has an answer. You never close
51
- it by hand: when the branch lands on the default branch, rsc's post-merge hook sets `status: done`
52
- and replaces Next with where and when it merged (on a closed default branch, via `rsc/knowledge`).
50
+ On a feature branch, rsc's post-merge hook sets `status: done` when the branch lands and records
51
+ the merge under Next. When working directly on the default branch, finish the checklist and record
52
+ the observed evidence, then set `status: done` and update Next in the commit that completes the task.
53
+ Keep unfinished work in progress.
53
54
 
54
55
  No decision journal, no phase records, no approvals. If a decision was meaningful, one line of
55
56
  rationale goes next to the task it belongs to.
@@ -10,7 +10,8 @@
10
10
 
11
11
  1. `cp .env.example .env && chmod 600 .env`
12
12
  2. Fill in the real values from the provider dashboard (link in `CREDENTIALS.md`).
13
- 3. `./test_connection.sh` (or `python3 test_connection.py`) — should end with
13
+ 3. Implement a read-only provider request in the connection test and replace the placeholder failure.
14
+ 4. `./test_connection.sh` (or `python3 test_connection.py`) — should end with
14
15
  `OK — …`.
15
16
 
16
17
  ## Scripts
@@ -10,21 +10,16 @@
10
10
  # ./test_connection.sh
11
11
  set -euo pipefail
12
12
 
13
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
14
- ENV_PATH="$SCRIPT_DIR/.env"
13
+ # Replace this stub with a credential check for the selected provider.
14
+ echo 'Connection check not implemented. Add a read-only API request before reporting success.' >&2
15
+ exit 1
15
16
 
16
- [ -f "$ENV_PATH" ] || { echo "ERROR: missing $ENV_PATH" >&2; exit 1; }
17
-
18
- set -a
19
- # shellcheck disable=SC1090
20
- source "$ENV_PATH"
21
- set +a
22
-
23
- : "${<TOOL>_API_KEY:?<TOOL>_API_KEY not set in $ENV_PATH}"
24
-
25
- # TODO: replace with the real read-only call for this provider.
26
- # curl -fsS "https://api.<provider>.com/v1/me" \
27
- # -H "Authorization: Bearer ${<TOOL>_API_KEY}" \
28
- # | python3 -m json.tool
29
-
30
- echo "OK — credentials valid."
17
+ # Example implementation after replacing the stub above:
18
+ # SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
19
+ # set -a
20
+ # source "$SCRIPT_DIR/.env"
21
+ # set +a
22
+ # : "${DEMO_API_KEY:?DEMO_API_KEY is required}"
23
+ # curl -fsS --max-time 15 "https://api.<provider>.com/v1/me" \
24
+ # -H "Authorization: Bearer $DEMO_API_KEY" >/dev/null
25
+ # echo "OK — credentials valid."
@@ -911,7 +911,7 @@ providers:
911
911
  : "${MINIMAX_API_KEY:?MINIMAX_API_KEY not set}"
912
912
  case "${MINIMAX_REGION:-global}" in
913
913
  global) base_url="https://api.minimax.io/v1" ;;
914
- cn) base_url="https://api.minimax.cn/v1" ;;
914
+ cn) base_url="https://api.minimaxi.com/v1" ;;
915
915
  *) echo "MINIMAX_REGION must be global or cn" >&2; exit 1 ;;
916
916
  esac
917
917
  curl -fsS --max-time 30 "$base_url/models" -H "Authorization: Bearer $MINIMAX_API_KEY" |
@@ -108,7 +108,7 @@ task's risk forecast. **The agent never picks or argues down its own tier.**
108
108
 
109
109
  ### c) Review scaled by tier — fresh context
110
110
 
111
- Tier 1 or 2: first call `npx @ericrisco/rsc review ledger round <slug>/<task>` — before **every**
111
+ Tier 1 or 2: first call `npx @ericrisco/rsc review ledger round <slug>/<task>` — before **every ordinary**
112
112
  review of the task, this first one included. Round 1 is the task's first review, not its first fix.
113
113
 
114
114
  | Tier | Review |
@@ -148,9 +148,9 @@ These are `verify`'s per-task mode (`../verify/SKILL.md`):
148
148
 
149
149
  A control that did not run is reported as **not run**, never as passed — and the task is not done.
150
150
 
151
- ### f) Fix loop — at most 3 rounds
151
+ ### f) Fix loop — at most 3 ordinary rounds
152
152
 
153
- Each re-review opens with another `review ledger round <slug>/<task>` (step c). It exits non-zero
153
+ Each ordinary 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
156
  Follow [criterion evidence and rounds](references/per-task-review.md#criterion-evidence-and-rounds) for panel accounting, criterion/lens metadata and advisory handling.
@@ -166,13 +166,13 @@ Follow [criterion evidence and rounds](references/per-task-review.md#criterion-e
166
166
  | Trivial, or no business weight | Fix it and record it in `decisions.md` with the task id |
167
167
  | Tier 2, contradicts a decision in `decisions.md`, or no convergence in 3 rounds | Park the task in the **decision queue** (`blocking`) and continue with independent tasks |
168
168
 
169
- The **decision queue** is a `## Decision queue` section in `02-DOCS/wiki/sdd/progress/<slug>.md`, one
170
- entry per item: its kind, task id, tier, the question, the options, your recommendation, the
171
- evidence path. **Kind is `blocking` or `review-after`.** Tier 2, a contradiction with a recorded
172
- decision and no convergence are `blocking`: the task is parked, its dependents wait, and the branch
173
- cannot merge itself. An assumption you took so work could continue is `review-after`: nothing waits
174
- and it does not stop a self-merge — the human reads it afterwards. Only a human closes an entry —
175
- an agent's approval never counts as human.
169
+ Record each item under `## Decision queue` in `02-DOCS/wiki/sdd/progress/<slug>.md` with its kind,
170
+ task id, tier, question, options, recommendation and evidence path. A `blocking` item parks the task
171
+ and its dependents and prevents self-merge. Use it for tier 2, a contradiction with a recorded decision
172
+ or failure to converge. A `review-after` item records an assumption for later human review and allows
173
+ work and self-merge to continue. Only a human closes either kind of entry.
174
+
175
+ For a confirmed round-three blocker, the owner can authorize [one focused correction and independent validation](../review/references/exceptional-recovery.md). Keep the original task parked until the owner closes the blocking entry on a successful result.
176
176
 
177
177
  Then append the progress entry and show the checkpoint (below).
178
178
 
@@ -351,7 +351,7 @@ outranks the plan, and the plan outranks your in-the-moment preference.
351
351
  ```text
352
352
  - [ ] a) RED for the right reason → GREEN → REFACTOR; committed as one unit (authorship = the configured git user, no AI attribution)
353
353
  - [ ] b) `rsc risk` on the task diff; tier recorded
354
- - [ ] c) `review ledger round <slug>/<task>` before each review (≤ 3); by tier, fresh context, no pre-judging
354
+ - [ ] c) `review ledger round <slug>/<task>` before each ordinary review (≤ 3); by tier, fresh context, no pre-judging
355
355
  - [ ] d) `review consolidate` + `finding-verifier`; `review ledger record`; outcomes closed
356
356
  - [ ] e) tests, build, security, traceability — each passed or **not run**
357
357
  - [ ] f) re-review only the new diff; class fixed, no repeats
@@ -237,7 +237,7 @@ A review loop that never converges is worse than none: without a cap, fix and re
237
237
  Five rules, enforced by `npx @ericrisco/rsc review ledger` (`.rsc/review-ledger.jsonl`) rather
238
238
  than by memory:
239
239
 
240
- 1. **Max 3 rounds per task.** Call `review ledger round <slug>/<task>` before **every** review of
240
+ 1. **Max 3 ordinary rounds per task.** Call `review ledger round <slug>/<task>` before **every ordinary** review of
241
241
  the task, the first included: round 1 is the task's first review, not its first fix. It exits
242
242
  non-zero on the 4th. That is not "try harder": rethink the approach, or park the task in the
243
243
  decision queue (a `blocking` entry) and continue with independent work.
@@ -271,6 +271,12 @@ than by memory:
271
271
  decides). `review ledger stats` then shows totals per outcome, the false rate and mean rounds per
272
272
  task — the only way to tell whether a change to the reviewer made it better or worse.
273
273
 
274
+ #### Exceptional recovery on the original task
275
+
276
+ Park a confirmed round-three blocker in the decision queue. The owner may authorize one focused
277
+ correction and independent regression review on that task. Follow the [recovery procedure](references/exceptional-recovery.md)
278
+ to record the decision and verdict. A failed review or remaining blocker keeps the task parked.
279
+
274
280
  The ledger is **local**: it lives in `.rsc/` and is never committed, so it does not travel between
275
281
  machines or clones. What lasts is what you write from it — review-evals cases and rules (below).
276
282
 
@@ -0,0 +1,34 @@
1
+ # Exceptional recovery on the original task
2
+
3
+ After the third ordinary round, park the confirmed blocker with `review ledger outcome <id> parked`
4
+ and add a `blocking` entry to the decision queue. Keep the original task and finding IDs. The owner
5
+ may authorize **one** focused correction and independent validation. Record the owner's explicit
6
+ decision before the correction, including why the exception is warranted, its limits, and the
7
+ reproduction or trace that confirmed the blocker.
8
+
9
+ ```bash
10
+ rsc review ledger recover <slug>/<task> --finding <id> --approved-by "<owner>" \
11
+ --reason "<owner's rationale>" --scope "<authorized correction>" --confirmation "<blocker proof>"
12
+ ```
13
+
14
+ When the task has no panel commit, authorization captures its checkout's current HEAD. For a child
15
+ checkout, pass `--repo "<reviewed checkout>"` at authorization too. Commit the correction on top
16
+ of the reviewed history and give the required fresh-context reviewer(s) its full commit SHA,
17
+ the diff from the last review, the agreed scope and the regression case. At tier 2 run the full
18
+ panel. Each reviewer must be independent of the implementer. Record any new findings and
19
+ their verified outcomes under the same task. The panel checks the corrected behavior and possible
20
+ regressions, reporting what it ran and observed on this commit.
21
+
22
+ ```bash
23
+ rsc review ledger recovery-result <slug>/<task> --candidate <full-reviewed-commit-SHA> \
24
+ --independent-reviewer "<reviewer names>" --lenses correctness,security,tests \
25
+ --evidence "<regression check, observed result and report path>" --result passed
26
+ ```
27
+
28
+ Name the actual lenses. For a child checkout, add `--repo "<reviewed checkout>"` from the
29
+ workspace root. These commands record attestations, like ordinary panels. Preserve the owner’s
30
+ decision and reviewer reports in the progress record. A passing result fixes the selected blocker.
31
+ Once all blockers for the task are resolved, the owner can close its original queue entry and the
32
+ reviewed panel counts at ship. If the correction fails, record `--result blocked`. A failed review
33
+ or another open blocker keeps the task parked and returns a nonzero exit after recording the
34
+ verdict. Replan with the owner. Both outcomes spend the single authorization.
@@ -244,7 +244,7 @@ In the `orient` voice: the explainer, the checklist result in one line, the thre
244
244
  | "I'll add `Co-Authored-By: Claude` / a 'Generated with Claude Code' footer to be transparent" | It forges the record. The work is the responsible person's — no AI trailer, ever. Strip it. |
245
245
  | "Review didn't formally approve but it's obviously fine" | No verdict = not ready. Ship runs on APPROVE or APPROVE WITH NITS only. Route back to review. |
246
246
  | "Tier 2, but the three refuters approved — I'll self-merge" | An agent's approval never counts as a human's. Tier 2 waits for human approval. |
247
- | "Tier 2, one reviewer was enough here" | The push gate wants the panel recorded (`review ledger panel … --lenses correctness,security,tests`). Run the three, record them, then push. |
247
+ | "Tier 2, one reviewer was enough here" | The push gate wants the panel recorded (`review ledger panel … --lenses correctness,security,tests`). Run the three and record them. An owner-authorized successful `recovery-result` records the panel for the corrected commit. |
248
248
  | "The tree has a couple of stray edits, they're harmless" | A dirty tree means the merge is not the reviewed diff. Clean it or stash it first. |
249
249
  | "`main` is protected but I'll just force-merge, I'm sure" | Protected means PR. Don't bypass the gate the repo deliberately set. |
250
250
  | "No remote and the guard denies the merge — I'll merge another way" | The denial is the answer. Park the branch with the merge command for the human. |
package/targets/agents.js CHANGED
@@ -23,13 +23,14 @@ import {
23
23
  const TIER_MODEL = {
24
24
  anthropic: { balanced: 'claude-sonnet-5-5', heavy: 'claude-opus-5-5' },
25
25
  google: { balanced: 'gemini-2.5-flash', heavy: 'gemini-2.5-pro' },
26
- openai: { balanced: 'gpt-5.1-mini', heavy: 'gpt-5.1' },
26
+ openai: { balanced: 'gpt-6.2-sol', heavy: 'gpt-6.2-astra' },
27
27
  };
28
28
 
29
- // The Anthropic ids earlier releases wrote into agent files. Never rendered for a new file: they only
29
+ // The ids earlier releases wrote into agent files. Never rendered for a new file: they only
30
30
  // let `knownRenderings` recognise a file rsc wrote before the ids moved, so an upgrade replaces it
31
31
  // instead of keeping it as the user's.
32
32
  const PREVIOUS_TIER_MODEL = {
33
+ openai: { balanced: 'gpt-5.1-mini', heavy: 'gpt-5.1' },
33
34
  anthropic: { balanced: 'claude-sonnet-4-6', heavy: 'claude-opus-4-8' }, // prompt-audit: allow retired-model — recognises agent files written by earlier rsc releases
34
35
  };
35
36
 
@@ -50,7 +51,7 @@ const AGENT_TARGETS = {
50
51
  gemini: { dir: '.gemini/agents', ext: '.md', format: 'md', model: (t) => TIER_MODEL.google[t] },
51
52
  copilot: { dir: '.github/agents', ext: '.agent.md', format: 'md', model: (t) => TIER_MODEL.anthropic[t], previousModel: (t) => PREVIOUS_TIER_MODEL.anthropic[t] },
52
53
  kiro: { dir: '.kiro/agents', ext: '.json', format: 'json', model: (t) => (t === 'heavy' ? 'claude-opus-4' : 'claude-sonnet-4') }, // prompt-audit: allow retired-model — Kiro's own model names, not Anthropic API ids; change them when Kiro lists newer ones
53
- codex: { dir: '.codex/agents', ext: '.toml', format: 'toml', model: (t) => TIER_MODEL.openai[t] },
54
+ codex: { dir: '.codex/agents', ext: '.toml', format: 'toml', model: (t) => TIER_MODEL.openai[t], previousModel: (t) => PREVIOUS_TIER_MODEL.openai[t] },
54
55
  };
55
56
 
56
57
  export const AGENT_TARGET_IDS = Object.keys(AGENT_TARGETS);
@@ -320,6 +321,7 @@ function knownRenderings(target, cwd, agent) {
320
321
  if (target === 'codex' && agent.tools) {
321
322
  out.add(renderToml(resolveModel(target, cwd, tier), agent, true));
322
323
  out.add(renderToml(spec.model(tier), agent, true));
324
+ out.add(renderToml(spec.previousModel(tier), agent, true));
323
325
  }
324
326
  if (target === 'claude') {
325
327
  out.add(renderAgent(target, spec, resolveModel(target, cwd, tier), agent, 'list'));
@@ -295,7 +295,8 @@ function panelSize(root, slugs, stillValid = () => true) {
295
295
  } catch {
296
296
  return 0;
297
297
  }
298
- let best = 0;
298
+ const sizes = new Map();
299
+ const recoveries = new Map();
299
300
  for (const line of text.split('\n')) {
300
301
  let e;
301
302
  try {
@@ -303,28 +304,23 @@ function panelSize(root, slugs, stillValid = () => true) {
303
304
  } catch {
304
305
  continue;
305
306
  }
306
- if (
307
- e?.type !== 'panel' ||
308
- typeof e.task !== 'string' ||
309
- !Array.isArray(e.lenses)
310
- )
307
+ if (typeof e?.task !== 'string') continue;
308
+ if (!slugs.some(s => e.task.toLowerCase().replace(/_/g, '-').startsWith(`${s.toLowerCase().replace(/_/g, '-')}/`))) continue;
309
+ if (e.type === 'recovery') {
310
+ // The owner's escalation retires the original panel even if later commits only touch docs.
311
+ sizes.delete(e.task);
312
+ recoveries.set(e.task, e.finding);
311
313
  continue;
312
- if (
313
- !slugs.some((s) =>
314
- e.task
315
- .toLowerCase()
316
- .replace(/_/g, '-')
317
- .startsWith(`${s.toLowerCase().replace(/_/g, '-')}/`),
318
- )
319
- )
320
- continue;
321
- if (!stillValid(e.sha)) continue;
322
- best = Math.max(
323
- best,
324
- new Set(e.lenses.map((l) => String(l).toLowerCase())).size,
325
- );
314
+ }
315
+ const authorized = recoveries.has(e.task);
316
+ const accepted = authorized
317
+ ? e.type === 'recovery-result' && e.finding === recoveries.get(e.task) && e.result === 'passed' && e.state === 'resolved'
318
+ : e.type === 'panel';
319
+ if (!accepted || !Array.isArray(e.lenses) || !stillValid(e.sha)) continue;
320
+ const size = new Set(e.lenses.map(l => String(l).toLowerCase())).size;
321
+ sizes.set(e.task, Math.max(sizes.get(e.task) || 0, size));
326
322
  }
327
- return best;
323
+ return Math.max(0, ...sizes.values());
328
324
  }
329
325
 
330
326
  // A linked checkout owns its spec and ledger, just as the review CLI owns its HEAD.
@@ -463,6 +459,7 @@ export function branchCheck(
463
459
  'the commit it was recorded on: code committed after it needs the panel again (the record is self-attested, like the sello). ' +
464
460
  `Recover: run the ${required} fresh-context refuters (correctness, security, tests) on the branch, then record it — ` +
465
461
  `\`npx @ericrisco/rsc review ledger panel ${slugs[0]}/closing --lenses correctness,security,tests${repoFlag}\` (run from ${evidence === repo ? 'the repository' : 'the workspace root'}) — and push again. ` +
462
+ 'For a confirmed blocker parked after round three, the owner can authorize one review on the original task with review ledger recover and recovery-result. ' +
466
463
  'To turn this gate off for the project: create `.rsc/.no-asdd-gate`.'
467
464
  );
468
465
  }
@@ -317,7 +317,7 @@ if (isMain(import.meta.url)) {
317
317
  if (!existsSync(join(root, '.git'))) allow();
318
318
  let input = {};
319
319
  try { input = JSON.parse(readFileSync(0, 'utf8') || '{}'); } catch { allow(); }
320
- if ((input.tool_name || input.toolName) !== 'Bash') allow();
320
+ if (!['Bash', 'PowerShell'].includes(input.tool_name || input.toolName)) allow();
321
321
  const command = input.tool_input?.command || input.toolInput?.command || '';
322
322
  const reason = await evaluate({ root, command, cwd: input.cwd || root, sessionId: input.session_id });
323
323
  if (reason) deny(reason);
package/targets/claude.js CHANGED
@@ -207,7 +207,7 @@ export function wireHook(paths, sourceMd, policy = {}) {
207
207
  settings.hooks.PreToolUse = settings.hooks.PreToolUse.filter(
208
208
  (e) => !hookWiringOf(e).includes('.rsc/ship-guard.'),
209
209
  );
210
- settings.hooks.PreToolUse.push({ matcher: 'Bash', hooks: [{ type: 'command', command: sgCmd }] });
210
+ settings.hooks.PreToolUse.push({ matcher: 'Bash|PowerShell', hooks: [{ type: 'command', command: sgCmd }] });
211
211
 
212
212
  // Branch guard (team-safe-default): the default branch closed for the agent where the project shows
213
213
  // it is complex or in production, and no branch switching under another session working in the same
@@ -221,7 +221,7 @@ export function wireHook(paths, sourceMd, policy = {}) {
221
221
  settings.hooks.PreToolUse = settings.hooks.PreToolUse.filter(
222
222
  (e) => !hookWiringOf(e).includes('.rsc/branch-guard.'),
223
223
  );
224
- settings.hooks.PreToolUse.push({ matcher: 'Bash', hooks: [{ type: 'command', command: bgCmd }] });
224
+ settings.hooks.PreToolUse.push({ matcher: 'Bash|PowerShell', hooks: [{ type: 'command', command: bgCmd }] });
225
225
 
226
226
 
227
227
  // Gitmoji guard: a PreToolUse(Bash) hook that DENIES a `git commit` whose message
@@ -237,7 +237,7 @@ export function wireHook(paths, sourceMd, policy = {}) {
237
237
  settings.hooks.PreToolUse = settings.hooks.PreToolUse.filter(
238
238
  (e) => !hookWiringOf(e).includes('.rsc/gitmoji-guard.'),
239
239
  );
240
- settings.hooks.PreToolUse.push({ matcher: 'Bash', hooks: [{ type: 'command', command: gmCmd }] });
240
+ settings.hooks.PreToolUse.push({ matcher: 'Bash|PowerShell', hooks: [{ type: 'command', command: gmCmd }] });
241
241
 
242
242
  // New-feature gate: a UserPromptSubmit hook that re-injects the SDD new-feature gate as
243
243
  // the most-recent instruction on every user turn. SessionStart injects the full gate (the
@@ -81,7 +81,13 @@ function fixedFor({ target, skills, agents, memoryMode }) {
81
81
  const out = [];
82
82
  for (const command of FIXED_COMMANDS) {
83
83
  if (command.kind === 'skill') {
84
- if (!skillSet.has(command.backing) || spec.skillsAreCommands) continue;
84
+ if (!skillSet.has(command.backing)) continue;
85
+ if (spec.skillsAreCommands) {
86
+ if (target === 'claude' && command.name === 'ship') {
87
+ out.push({ ...command, name: 'rsc-ship', body: 'Read .rsc/skills/ship/SKILL.md in the project and follow its checks and landing procedure for {{ARGS}}.' });
88
+ }
89
+ continue;
90
+ }
85
91
  out.push({ ...command });
86
92
  } else if (command.kind === 'testing-skill') {
87
93
  if (!testing.length || spec.skillsAreCommands) continue;
@@ -204,7 +210,7 @@ export function reconcileCommands(target, cwd, previousNames = [], desiredComman
204
210
  }
205
211
 
206
212
  export function allPotentialCommandNames() {
207
- const names = new Set(fixedCommandNames());
213
+ const names = new Set([...fixedCommandNames(), 'rsc-ship']);
208
214
  // Every stack alias follows directly from catalog metadata; no second mapping.
209
215
  const agents = allAgentNames();
210
216
  const skills = [...new Set(agents.flatMap((id) => agentByName(id)?.skills || []))];
@@ -18,17 +18,18 @@
18
18
  // for it (the deny message says so). Fail-open on any internal error (never brick a shell).
19
19
  import { existsSync, readFileSync } from 'node:fs';
20
20
  import { homedir } from 'node:os';
21
- import { join, win32 } from 'node:path';
21
+ import { spawnSync } from 'node:child_process';
22
+ import { join, resolve, win32 } from 'node:path';
22
23
 
23
24
  const root = process.argv[2] || process.cwd();
24
25
 
25
26
  function allow() { process.exit(0); }
26
- function ask(why) {
27
+ function ask(why, guidance = 'It cannot be undone, so the person confirms it.') {
27
28
  process.stdout.write(JSON.stringify({
28
29
  hookSpecificOutput: {
29
30
  hookEventName: 'PreToolUse',
30
31
  permissionDecision: 'ask',
31
- permissionDecisionReason: `rsc: this command ${why}. It cannot be undone, so the person confirms it.`,
32
+ permissionDecisionReason: `rsc: this command ${why}. ${guidance}`,
32
33
  },
33
34
  }));
34
35
  process.exit(0);
@@ -267,4 +268,98 @@ for (const rule of RULES) {
267
268
  } catch { /* a rule erroring must never block */ }
268
269
  }
269
270
 
271
+ // Ask before an assistant publishes named credential files. Inspect Git's path index and
272
+ // commit history only. Remote-tracking refs are the local record of already-published commits.
273
+ const credentialPaths = ['**/.env', '**/.env.*', '**/*.pem', '**/*.key', '**/secrets/**']
274
+ .map(path => ':(top,glob,icase)' + path)
275
+ .concat(['example', 'sample', 'template'].map(ext => ':(top,exclude,glob,icase)**/.env.' + ext));
276
+
277
+ function inspectDeliveryPaths(argv, cwd) {
278
+ const git = args => spawnSync('git', ['-C', cwd, ...args], {
279
+ encoding: 'utf8', windowsHide: true, timeout: 4000, stdio: ['ignore', 'pipe', 'ignore'],
280
+ });
281
+ if (git(['rev-parse', '--git-dir']).status !== 0) return;
282
+ const [action, ...args] = argv;
283
+ if (action === 'commit') {
284
+ // Let Git select the actual commit paths, including --all and path-limited commits.
285
+ // Only selection flags reach the dry run. Message, editor and hook options stay out of it.
286
+ const selection = [];
287
+ const paths = [];
288
+ for (let i = 0; i < args.length; i++) {
289
+ const arg = args[i];
290
+ if (arg === '--') { paths.push(...args.slice(i + 1)); break; }
291
+ if (!arg.startsWith('-')) { paths.push(arg); continue; }
292
+ if (['--all', '--include', '--only'].includes(arg)) selection.push(arg);
293
+ if (/^-[^-]/.test(arg)) {
294
+ const flags = arg.slice(1).split(/[mFCct]/)[0];
295
+ for (const flag of ['a', 'i', 'o']) if (flags.includes(flag)) selection.push('-' + flag);
296
+ }
297
+ if (/^-[^-]*[mFCct]$/.test(arg) || ['--message', '--file', '--reuse-message', '--reedit-message',
298
+ '--template', '--author', '--date', '--fixup', '--squash', '--cleanup', '--trailer'].includes(arg)) i++;
299
+ }
300
+ const preview = git(['-c', 'status.renames=false', 'commit', '--dry-run', '--porcelain', '-z',
301
+ '--untracked-files=no', ...selection, '--', ...paths]);
302
+ if (preview.status !== 0) return;
303
+ for (const item of preview.stdout.split('\0')) {
304
+ if (!/^[AMTC]/.test(item)) continue;
305
+ const path = item.slice(3);
306
+ if (/(?:^|\/)secrets\/|\.(?:pem|key)$/i.test(path) ||
307
+ (/(?:^|\/)\.env(?:$|\.)/i.test(path) && !/\.env\.(?:example|sample|template)$/i.test(path))) {
308
+ ask('would commit a filename commonly used for credentials', 'Review the selected files before committing.');
309
+ }
310
+ }
311
+ } else if (action === 'push') {
312
+ if (args.includes('--delete') || args.includes('-d') || args.includes('--dry-run') || args.includes('-n')) return;
313
+ // Inspect named sources; for a configured/default push conservatively cover local branches
314
+ // and tags, including files that were deleted again later in the unpublished history.
315
+ const [destination, ...explicit] = args.filter(a => !a.startsWith('-'));
316
+ const branch = git(['symbolic-ref', '--quiet', '--short', 'HEAD']).stdout.trim();
317
+ const config = key => git(['config', '--get', key]).stdout.trim();
318
+ const remote = destination || config('branch.' + branch + '.pushRemote') || config('remote.pushDefault') ||
319
+ config('branch.' + branch + '.remote') || 'origin';
320
+ const configured = git(['config', '--get-all', 'remote.' + remote + '.push']).stdout.trim();
321
+ const specs = explicit.length ? explicit : configured.split('\n').filter(Boolean);
322
+ // --follow-tags adds annotated tags reachable from the selected tips; their commits are already included.
323
+ const tips = [];
324
+ if (args.some(a => ['--all', '--branches', '--mirror'].includes(a))) tips.push('--branches');
325
+ if (args.some(a => ['--tags', '--mirror'].includes(a))) tips.push('--tags');
326
+ for (const spec of specs) {
327
+ const src = spec.replace(/^\+/, '').split(':')[0];
328
+ if (!src && spec !== ':') continue;
329
+ if (spec === ':' || src.includes('*')) { tips.push('--branches'); continue; }
330
+ const oid = git(['rev-parse', '--verify', '--end-of-options', src + '^{commit}']);
331
+ if (oid.status === 0) tips.push(oid.stdout.trim());
332
+ }
333
+ if (!tips.length && !specs.length) tips.push(config('push.default') === 'matching' ? '--branches' : 'HEAD');
334
+ if (!tips.length) return;
335
+ const hit = git(['log', '-1', '--format=%H', '-m', '--full-history', '--no-renames', '--diff-filter=ACMT',
336
+ ...tips, '--not', '--remotes', '--', ...credentialPaths]);
337
+ if (hit.status === 0 && hit.stdout.trim()) ask('could publish a credential filename in local commit history', 'Review the outgoing commits before pushing.');
338
+ }
339
+ }
340
+
341
+ function reviewDeliveryPaths() {
342
+ if (technical || !/\bgit(?:\.exe)?\b/i.test(command) || !/\b(?:commit|push)\b/i.test(command)) return;
343
+ const commands = psCommands
344
+ ? psCommands.map(args => args.map(a => a.replace(/^(['"])(.*)\1$/, '$2')))
345
+ : (SH?.expand(command) || []).map(segment => SH.words(segment).map(word => word.text));
346
+ let cwd = input.cwd || root;
347
+ for (const [bin, ...args] of commands) {
348
+ if (['cd', 'set-location'].includes(bin.toLowerCase()) && args.length === 1) {
349
+ cwd = resolve(cwd, args[0]);
350
+ continue;
351
+ }
352
+ if (!/(?:^|[\\/])git(?:\.exe)?$/i.test(bin)) continue;
353
+ let at = cwd;
354
+ let i = 0;
355
+ while (args[i] === '-C' && i + 1 < args.length) {
356
+ at = resolve(at, args[i + 1]);
357
+ i += 2;
358
+ }
359
+ if (['commit', 'push'].includes(args[i])) inspectDeliveryPaths(args.slice(i), at);
360
+ }
361
+ }
362
+
363
+ reviewDeliveryPaths();
364
+
270
365
  allow();
@@ -17,9 +17,11 @@ import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
17
17
 
18
18
  export const GIT_PERMISSION_TARGETS = Object.freeze(['claude', 'codex', 'gemini', 'opencode']);
19
19
 
20
- const CLAUDE_ALLOW = ['Bash(git commit *)', 'Bash(git push *)', 'Bash(gh pr create *)'];
20
+ const claudeShellRules = commands => ['Bash', 'PowerShell'].flatMap(shell => commands.map(command => `${shell}(${command})`));
21
+ const CLAUDE_ALLOW = claudeShellRules(['git commit *', 'git push *', 'gh pr create *']);
21
22
  // `ask` beats `allow` in Claude Code, and applies to any subcommand of a chain.
22
- const CLAUDE_ASK = ['Bash(git push --force*)', 'Bash(git push -f*)', 'Bash(git push * --force*)', 'Bash(git push * -f*)'];
23
+ export const claudeGitOwnershipPath = cwd => join(cwd, '.rsc', 'claude-git-ownership.json');
24
+ const CLAUDE_ASK = claudeShellRules(['git push --force*', 'git push -f*', 'git push * --force*', 'git push * -f*']);
23
25
  const GEMINI_ALLOW = ['run_shell_command(git commit)', 'run_shell_command(git push)', 'run_shell_command(gh pr create)'];
24
26
  // OpenCode: the last matching rule wins, so the force-push asks come after the allows.
25
27
  const OPENCODE_BASH = [
@@ -230,8 +232,15 @@ export function wireGitPermissions(target, cwd = process.cwd()) {
230
232
  if (!config) return { mode: 'config-invalid', path }; // never overwrite a file we cannot read
231
233
  if (target === 'claude') {
232
234
  config.permissions ||= {};
233
- config.permissions.allow = addAll(config.permissions.allow, CLAUDE_ALLOW);
234
- config.permissions.ask = addAll(config.permissions.ask, CLAUDE_ASK);
235
+ const ownershipPath = claudeGitOwnershipPath(cwd);
236
+ const owned = readJson(ownershipPath) || {};
237
+ for (const [kind, rules] of [['allow', CLAUDE_ALLOW], ['ask', CLAUDE_ASK]]) {
238
+ const existing = config.permissions[kind] || [];
239
+ owned[kind] = rules.filter(rule => rule.startsWith('PowerShell(') &&
240
+ (!existing.includes(rule) || owned[kind]?.includes(rule)));
241
+ config.permissions[kind] = addAll(existing, rules);
242
+ }
243
+ writeJson(ownershipPath, owned);
235
244
  } else if (target === 'gemini') {
236
245
  config.tools ||= {};
237
246
  config.tools.allowed = addAll(config.tools.allowed, GEMINI_ALLOW);
@@ -259,8 +268,13 @@ export function unwireGitPermissions(target, cwd = process.cwd()) {
259
268
  const config = readJson(path);
260
269
  if (!config) return [];
261
270
  if (target === 'claude' && config.permissions) {
262
- config.permissions.allow = dropAll(config.permissions.allow, CLAUDE_ALLOW);
263
- config.permissions.ask = dropAll(config.permissions.ask, CLAUDE_ASK);
271
+ const ownershipPath = claudeGitOwnershipPath(cwd);
272
+ const owned = readJson(ownershipPath) || {};
273
+ for (const [kind, rules] of [['allow', CLAUDE_ALLOW], ['ask', CLAUDE_ASK]]) {
274
+ const managed = rules.filter(rule => rule.startsWith('Bash(') || owned[kind]?.includes(rule));
275
+ config.permissions[kind] = dropAll(config.permissions[kind], managed);
276
+ }
277
+ rmSync(ownershipPath, { force: true });
264
278
  for (const k of ['allow', 'ask']) if (Array.isArray(config.permissions[k]) && !config.permissions[k].length) delete config.permissions[k];
265
279
  if (!Object.keys(config.permissions).length) delete config.permissions;
266
280
  } else if (target === 'gemini' && config.tools) {
@@ -316,7 +316,7 @@ if (isMainModule(import.meta.url)) {
316
316
 
317
317
  let input = {};
318
318
  try { input = JSON.parse(readFileSync(0, 'utf8') || '{}'); } catch { allow(); }
319
- if ((input.tool_name || input.toolName) !== 'Bash') allow();
319
+ if (!['Bash', 'PowerShell'].includes(input.tool_name || input.toolName)) allow();
320
320
  const command = input.tool_input?.command || input.toolInput?.command || '';
321
321
  if (typeof command !== 'string' || !command) allow();
322
322
 
package/targets/memory.js CHANGED
@@ -87,7 +87,7 @@ function handler(target, event) {
87
87
  if (target === 'claude') value.command = claudeLifecycleCommand('session-memory-adapter.mjs', target, event);
88
88
  if (target === 'codex') {
89
89
  value.commandWindows = `node \"$((git rev-parse --show-toplevel).Trim())/.rsc/session-memory-adapter.mjs\" ${target} ${event}`;
90
- value.additionalContextLimit = 1400;
90
+ if (['start', 'request', 'edit', 'boundary'].includes(event)) value.additionalContextLimit = 1400;
91
91
  }
92
92
  if (target === 'gemini') value.name = `rsc-memory-${event}`;
93
93
  return value;
package/targets/sello.mjs CHANGED
@@ -44,7 +44,7 @@ export { readPolicy, mergePolicyConfig, policyRoot, changeDetails } from './risk
44
44
  // with no switch to stop it, so leaving it out made the lockout permanent.
45
45
  export const SELLO_STATE_PATHS = [
46
46
  '.rsc/sello.json', '.rsc/sello-config.json', '.rsc/sello-findings.md', '.rsc/sello-log.jsonl',
47
- '.rsc/automation-gaps.md', '.rsc/review-ledger.jsonl',
47
+ '.rsc/automation-gaps.md', '.rsc/review-ledger.jsonl', '.rsc/review-ledger.lock',
48
48
  ];
49
49
 
50
50
  // Worktrees nested inside the project (the assistant's native `.claude/worktrees/`, rsc's own
@@ -46,7 +46,7 @@ if (!existsSync(join(root, '.git'))) allow();
46
46
  // Read the tool call. Only Bash commands can move branches.
47
47
  let input = {};
48
48
  try { input = JSON.parse(readFileSync(0, 'utf8') || '{}'); } catch { allow(); }
49
- if ((input.tool_name || input.toolName) !== 'Bash') allow();
49
+ if (!['Bash', 'PowerShell'].includes(input.tool_name || input.toolName)) allow();
50
50
  const command = input.tool_input?.command || input.toolInput?.command || '';
51
51
  if (typeof command !== 'string' || !command) allow();
52
52