opencode-workflow-guard 1.20.1 → 1.20.4
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 +1 -1
- package/docs/agents/ledger.md +523 -0
- package/docs/agents/lessons/20261120T134830Z-align-with-the-sibling-matcher.md +13 -0
- package/docs/agents/rsi-loop-playbook.md +77 -0
- package/docs/policies.md +11 -7
- package/docs/testing.md +2 -2
- package/docs/troubleshooting.md +2 -0
- package/package.json +5 -5
- package/src/lib/custom-tools.ts +1 -1
- package/src/lib/guard-api.ts +1 -0
- package/src/lib/guard-dispatcher.ts +38 -26
- package/src/lib/shell.ts +12 -3
- package/src/lib/state.ts +5 -2
- package/src/lib/types.ts +10 -0
- package/src/lib/v2-plugin.ts +2 -1
- package/src/lib/verify.ts +43 -5
- package/src/policies/completion.ts +7 -3
- package/src/policies/git.ts +82 -1
- package/src/policies/post-edit-validation.ts +7 -2
- package/src/policies/shell-safety.ts +50 -25
- package/src/policies/tamper.ts +96 -4
- package/src/policies/todo.ts +158 -52
- package/src/workflow-guard.ts +6 -1
- package/test/test.mts +277 -6
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ WORKFLOW_GUARD_LIVE_E2E=1 npm run test:install # Also run policy probes with Ope
|
|
|
46
46
|
The plugin enforces **28 deterministic policy rules** across four main pillars:
|
|
47
47
|
|
|
48
48
|
* **Branch & History Protection:** Enforces feature-branch workflows and blocks edits and commits on `main`/`master`. The one exception is a sync: `git merge --ff-only`, `git rebase`, and `git pull --ff-only` are allowed on a protected branch when the target is its tracked upstream or the remote default and the branch is strictly behind it, because a fast-forward adds no unreviewed commit. Direct and forced pushes to protected branches are hard-blocked. The guard checks mergeability before PR creation, requires secondary review approval bound to the reviewed worktree content, and requires a PR changelog or changeset. An opt-in dogfood gate can additionally require a recorded run of the change on real hardware before a PR opens. Verdicts follow the tree the command actually runs in: git parsing takes the shell's `workdir` as its base, an in-command `cd`/`pushd`/`popd` and a wrapper `-C`/`-D` move the tree later segments are judged in, and a nested interpreter payload is judged by its own `cd` or `cwd` option. A linked worktree of the same repository is judged rather than boundary-blocked, a PR preflight resolves `--head`/`--source-branch` to the checkout holding that branch, and the V2 permission seat defers cwd-dependent commands to `execute.before` instead of judging the session-bound checkout. A `workdir` in a different repository is not judged: mutations and git writes there are blocked, because relative targets would be validated against the wrong tree.
|
|
49
|
-
* **Task & Verification Discipline:** Gates file mutations on active `todowrite` tasks, which subagents inherit. A task can be marked completed only after its own recorded work. Review and investigation tasks use an audited `[read-only]` marker instead. The guard also blocks concurrent direct edits to the same canonical file across sessions. It requires a same-session fresh read before `edit`/`write` can replace an existing file. Silent task deletion is blocked,
|
|
49
|
+
* **Task & Verification Discipline:** Gates file mutations on active `todowrite` tasks, which subagents inherit. A task can be marked completed only after its own recorded work. Review and investigation tasks use an audited `[read-only]` marker instead. The guard also blocks concurrent direct edits to the same canonical file across sessions. It requires a same-session fresh read before `edit`/`write` can replace an existing file. Silent task deletion is blocked, while a reworded task that only adds wording is treated as the same work item and keeps its evidence window. Task completion requires fresh test verification evidence. Completion claims and sweeping repository claims are journaled against their evidence. Repeated failures force a live-documentation lookup instead of a guess from training data.
|
|
50
50
|
* **Secrets & Workspace Confinement:** Confines edit tools and recognized shell/git mutations to the workspace root, including symlink and `../` escape checks. Agent subshells have sensitive environment variables scrubbed, and `.env` reads return a safe schema mask. Arbitrary executables are not OS-sandboxed. Use containers or filesystem isolation when hard confinement is required.
|
|
51
51
|
* **Destructive CLI, Delegation & Environment Safety:** Intercepts destructive cloud, database, and infrastructure commands. Stops script laundering and interpreter evasion, blocks TTY hangs such as `vim`, `nano`, and `sudo`, and guards against dangerous package manager flags. It also refuses a shell-spawned agent CLI (`claude`, `codex`, `gemini`, `aider`, `opencode run`), because a spawned agent runs outside the guard's hooks; the host's `task` tool is the governed path to a subagent.
|
|
52
52
|
|
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
# RSI experiment ledger
|
|
2
|
+
|
|
3
|
+
Structured, create-only record of every base-loop attempt, accepted or
|
|
4
|
+
rejected. One record per iteration; append only. Never edit or delete a prior
|
|
5
|
+
record: a negative result is data, not clutter.
|
|
6
|
+
|
|
7
|
+
## Schema (one block per iteration)
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
n · date (UTC) · hypothesis (falsifiable) · trace evidence · code change ·
|
|
11
|
+
commit SHA + git tree · artifact name + checksum · exact command/config ·
|
|
12
|
+
test results · eval job path · score · gains · losses · exceptions ·
|
|
13
|
+
token/cost/duration · interpretation · keep/revert · next hypothesis
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Schema v2 adds two fields, required on every new record:
|
|
17
|
+
|
|
18
|
+
```text
|
|
19
|
+
selection score (n items) · held-out score (n items, never used for selection)
|
|
20
|
+
· prev-chain: sha256:<hex of the preceding record block>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`selection score` is the score on the items the loop selected against.
|
|
24
|
+
`held-out score` is the score on a disjoint item set never used for
|
|
25
|
+
selection. Report both (winner's curse). `prev-chain` links each record to
|
|
26
|
+
the sha256 of the prior record block so the create-only rule is
|
|
27
|
+
tamper-evident (hash-chained admission).
|
|
28
|
+
|
|
29
|
+
## Rules
|
|
30
|
+
|
|
31
|
+
- Append only. One block per iteration. No rewrites, renumbering, or deletes.
|
|
32
|
+
- Report `selection score` and `held-out score` side by side; a `keep`
|
|
33
|
+
requires a non-empty `held-out score`. Held-out items are never reused for
|
|
34
|
+
selection.
|
|
35
|
+
- `prev-chain` is the sha256 of the preceding record block.
|
|
36
|
+
- Record failures with the same care as successes; an empty failures column
|
|
37
|
+
is a smell, not a clean run.
|
|
38
|
+
- Name idiosyncratic infrastructure/verifier constraints explicitly, so a
|
|
39
|
+
later reader does not re-derive them.
|
|
40
|
+
- Every `keep` cites the eval run that justified it; every `revert` keeps the
|
|
41
|
+
failure evidence and the next hypothesis.
|
|
42
|
+
- A record is written by the base loop, not a subagent.
|
|
43
|
+
|
|
44
|
+
## Records
|
|
45
|
+
|
|
46
|
+
<!-- append blocks below this line, newest last -->
|
|
47
|
+
|
|
48
|
+
### n=1 — campaign scaffolding (docs, preregistered 2026-11-21)
|
|
49
|
+
|
|
50
|
+
- **hypothesis (falsifiable, registered before the edit):** this repository has
|
|
51
|
+
no `docs/agents/rsi-loop-playbook.md` and no `docs/agents/ledger.md`, so a
|
|
52
|
+
campaign run here has no grounding and nowhere to append. `docs/agents/lessons.md`
|
|
53
|
+
and `docs/agents/lessons/` already exist from earlier loops (LL-001 onwards),
|
|
54
|
+
so two of the three anchors are missing. Falsified if either file already
|
|
55
|
+
exists at `origin/main`.
|
|
56
|
+
|
|
57
|
+
- **prediction (expected gain):** both files created from
|
|
58
|
+
`~/.config/opencode/templates/rsi/`, with the playbook's placeholder anchors
|
|
59
|
+
replaced by this repository's real verifier (`npm run typecheck && npm test`),
|
|
60
|
+
metric (false-positive policy blocks against a frozen journal snapshot), and
|
|
61
|
+
frozen ruler (the audit journal is read-only evidence). **at-risk
|
|
62
|
+
regressions:** none; both are new and no gate reads them. **non-goals:** no
|
|
63
|
+
change to the existing lesson corpus, no new policy, no change to `src/`.
|
|
64
|
+
|
|
65
|
+
- **accept/reject rule:** accept if both files exist, the playbook names the
|
|
66
|
+
real verifier, and `git status` shows additions only.
|
|
67
|
+
|
|
68
|
+
- **selection score (2 items, deterministic):** (a) both files are absent at
|
|
69
|
+
`origin/main`, confirmed with `git ls-tree origin/main docs/agents/`; (b) the
|
|
70
|
+
template sources exist and are readable.
|
|
71
|
+
|
|
72
|
+
- **held-out score:** 2/2 passed (2 items, never used for selection): the
|
|
73
|
+
pre-existing `docs/agents/lessons.md` still parses as an index, and
|
|
74
|
+
`docs/agents/lessons/` still holds its 7 lesson files. Neither was used to
|
|
75
|
+
choose or shape the scaffold.
|
|
76
|
+
|
|
77
|
+
- **disjointness:** the held-out set is the pre-existing lesson corpus. It reads
|
|
78
|
+
neither the playbook nor the ledger, and neither was used for selection.
|
|
79
|
+
|
|
80
|
+
- **eval job path:** none. A file-existence and content check, with no
|
|
81
|
+
model-scored eval, so the matched-budget test-time-scaling control does not
|
|
82
|
+
apply (deterministic verifier, per the playbook anchors).
|
|
83
|
+
|
|
84
|
+
- **result (appended after the acceptance run):** GAIN. Both files created in
|
|
85
|
+
the campaign worktree; the playbook's anchors name `npm run typecheck && npm
|
|
86
|
+
test`, the block-count proxy, and the read-only journal. The lesson corpus is
|
|
87
|
+
untouched. **keep/revert:** keep.
|
|
88
|
+
|
|
89
|
+
- **next hypothesis:** the plugin's own telemetry has never been read as a
|
|
90
|
+
first-class input. The audit journal holds 10,395 records with 249 block
|
|
91
|
+
decisions, and the block reasons carry enough text to reconstruct the command
|
|
92
|
+
shape even though bodies are redacted. Mining it should expose false positives
|
|
93
|
+
the suite cannot, because the suite only encodes shapes someone already
|
|
94
|
+
imagined.
|
|
95
|
+
|
|
96
|
+
- prev-chain: sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
|
97
|
+
|
|
98
|
+
### n=2 — campaign candidate set and idea-level screening (instrument, preregistered 2026-11-21)
|
|
99
|
+
|
|
100
|
+
- **hypothesis (falsifiable, registered before any evaluation):** this
|
|
101
|
+
campaign's premise is that the guard's telemetry names false positives worth
|
|
102
|
+
fixing. The audit journal at
|
|
103
|
+
`~/.local/state/opencode/workflow-guard/workflow-guard.jsonl` holds 10,395
|
|
104
|
+
records: 9,978 allows, 249 blocks, 168 abstains. Command bodies are redacted
|
|
105
|
+
by design (byte count plus sha256), so the reconstructable evidence is the
|
|
106
|
+
policy code, the block-reason string, and the tool. Falsified if the reasons
|
|
107
|
+
name no legitimate command shape.
|
|
108
|
+
|
|
109
|
+
- **trace evidence (the frozen ruler for this campaign):** block counts by
|
|
110
|
+
policy code: `stale-write/stale_write` 26,
|
|
111
|
+
`shell-safety/dynamic_shell_syntax` 26, `todo/todo_lifecycle` 18,
|
|
112
|
+
`boundary/workspace_escape` 16, `git/protected_branch` 14,
|
|
113
|
+
`boundary/shell_mutation` 9, `pr-preflight/pr_preflight_failed` 8,
|
|
114
|
+
`todo/no_active_todo` 7, `todo/todo_completion_unverified` 7,
|
|
115
|
+
`destructive/live_mutation` 7, `shell-safety/interactive_tty` 5, and a long
|
|
116
|
+
tail of 1-3. 85 of the 249 are `workspace.binding` /
|
|
117
|
+
`workspace_rebind_refused` journal events, which are observations rather than
|
|
118
|
+
tool blocks. Repeated identical blocked payloads isolate the friction loops:
|
|
119
|
+
`todo_lifecycle` on `todowrite` appears 7, 7 and 6 times in single sessions.
|
|
120
|
+
The `interactive_tty` reasons include
|
|
121
|
+
`command -v unshare fakeroot sudo systemd-tmpfiles getent; id` and a
|
|
122
|
+
`git commit -m` message, both refused as "sudo with password prompt". The
|
|
123
|
+
`todo_lifecycle` reasons show text refinement read as deletion, for example
|
|
124
|
+
`'Verify the doc change and open its PR'` then
|
|
125
|
+
`'Verify the doc change, pass review, and open its PR'`. Live reproduction
|
|
126
|
+
during this campaign added a fourth class: any backtick in a shell command is
|
|
127
|
+
refused as command substitution, so a Markdown payload written through a
|
|
128
|
+
quoted heredoc cannot be written at all.
|
|
129
|
+
|
|
130
|
+
- **candidate set (built before iterating, one hypothesis each, with the
|
|
131
|
+
change-type the selection phase checks for diversity):**
|
|
132
|
+
- **C1 [gate]** `src/policies/shell-safety.ts:47-83` applies
|
|
133
|
+
`INTERACTIVE_COMMAND_PATTERNS` with `regex.test(WHOLE_COMMAND)`, so an
|
|
134
|
+
editor name, `sudo`, `npm init`, `apt` or `yum` anywhere in the text blocks
|
|
135
|
+
the call, while monitors and pagers already resolve command position
|
|
136
|
+
(`containsMonitorCommand` line 97, `containsPagerCommand` line 126).
|
|
137
|
+
- **C2 [gate]** `src/policies/todo.ts:312-372` matches task identity by exact
|
|
138
|
+
normalized text, so sharpening an in-progress task's wording reads as a
|
|
139
|
+
silent deletion and blocks the whole `todowrite`.
|
|
140
|
+
- **C3 [routing]** `src/lib/state.ts:292-330` binds a session to its creation
|
|
141
|
+
directory on the first host announcement, so the session's own first
|
|
142
|
+
tool-call context (`registerSessionWorkspaceFromToolCall`, line 211) can
|
|
143
|
+
never bind and is journaled as a refused widening.
|
|
144
|
+
- **C4 [security]** the tamper policy treats any mention of
|
|
145
|
+
`~/.config/opencode/*` in a shell command as a write, so a `cp` from
|
|
146
|
+
`~/.config/opencode/templates/rsi/` into a workspace file is refused as
|
|
147
|
+
tampering, although reading the same path is explicitly allowed and
|
|
148
|
+
Policy 6 already sanctions copying *from* a config path.
|
|
149
|
+
- **C5 [instrument]** 85 of the 249 `decision:"block"` records are
|
|
150
|
+
journal-only boundary observations, so a naive block count overstates
|
|
151
|
+
policy blocks by 34%.
|
|
152
|
+
- **C6 [gate] (considered, then deferred, not denied on merit):** a redirect
|
|
153
|
+
to `/dev/null` is boundary-refused (`curl output to '/dev/null' targets a
|
|
154
|
+
path outside the workspace`) although three code paths already treat it as
|
|
155
|
+
a sink for observation seeding (`workflow-guard.ts:574`,
|
|
156
|
+
`src/lib/v2-plugin.ts:394`, `boundary.ts:241`).
|
|
157
|
+
|
|
158
|
+
- **screening (idea level, before evaluation budget):** the `screener`
|
|
159
|
+
subagent ranked C2 > C1 > C4 and denied C3 and C5. Its C5 reason holds: an
|
|
160
|
+
audit-schema change moves the column but a naive reader still counts the same
|
|
161
|
+
rows, so it fixes no decision. Its C3 reason does not hold: it declined to
|
|
162
|
+
read `src/lib/state.ts` and denied on "unverified line numbers", while the
|
|
163
|
+
function, its binding behaviour and the 85 journaled refusals are all present
|
|
164
|
+
in the evidence above. The deny is recorded as-is rather than silently
|
|
165
|
+
reversed, and C3 is archived for a later campaign with a narrower brief.
|
|
166
|
+
|
|
167
|
+
- **appraisal against the two bounds (HSI, 2608.08466):** all retained
|
|
168
|
+
candidates have an informative signal (a named command shape or lifecycle
|
|
169
|
+
update, plus a block code) and none asks the frozen model to exceed its
|
|
170
|
+
ceiling; each is a deterministic classifier change with a regression case.
|
|
171
|
+
C2 and C1 clear both bounds. C4's feedback is thinner (one journal record,
|
|
172
|
+
one live reproduction) but its signal is exact. C6 was deferred on the RRSI
|
|
173
|
+
pruner's "too small" rule (2609.24972), not on evidence.
|
|
174
|
+
|
|
175
|
+
- **selection decision (archive, not lineage, per 2505.22954 and 2609.26457):**
|
|
176
|
+
iteration order is **C2 (gate), C4 (security), C1 (gate)**. That order obeys
|
|
177
|
+
the diversity brake (no two consecutive iterations of one change-type) while
|
|
178
|
+
spending the first iteration on the candidate with the most durable evidence
|
|
179
|
+
and the clearest spirit argument: the rule exists to stop dropped work, not
|
|
180
|
+
to forbid sharper wording. The rejected and deferred candidates stay above,
|
|
181
|
+
graded, so a later campaign can re-open one without re-deriving the evidence.
|
|
182
|
+
|
|
183
|
+
- **selection score (5 items, deterministic):** (a) C2 has 18 journal records
|
|
184
|
+
and three retry loops of 7, 7 and 6; (b) C2's fix generalizes an existing
|
|
185
|
+
carve-out at `todo.ts:326-357` rather than inventing a mechanism; (c) C1 is
|
|
186
|
+
live-reproduced twice in this campaign and reuses `unwrapShellWords`; (d) C4
|
|
187
|
+
is live-reproduced once; (e) each candidate is a single source file plus
|
|
188
|
+
tests and docs, inside the annealed edit budget.
|
|
189
|
+
|
|
190
|
+
- **held-out score:** pending, scored at each iteration's evaluation (2 items,
|
|
191
|
+
never used for selection): the repository's own suite (`npm run typecheck &&
|
|
192
|
+
npm test`) and an independent probe bank written at evaluation time.
|
|
193
|
+
|
|
194
|
+
- **disjointness:** the selection items are journal records from past sessions'
|
|
195
|
+
command shapes. The held-out items are the deterministic suite plus fresh
|
|
196
|
+
probes invented after the fix. Held-out items are never used for selection.
|
|
197
|
+
|
|
198
|
+
- **eval job path:** none. Deterministic verifier, no model in the scoring loop,
|
|
199
|
+
so the matched-budget control and the answer-rescue audit do not apply
|
|
200
|
+
(2607.12227, 2610.05533).
|
|
201
|
+
|
|
202
|
+
- **result:** the candidate set is built, screened and archived; the campaign
|
|
203
|
+
proceeds with C2.
|
|
204
|
+
|
|
205
|
+
- **next hypothesis:** if C2 lands, the same replacement-by-refinement question
|
|
206
|
+
recurs for `[read-only]` marker stripping and for duplicate-text matching,
|
|
207
|
+
the other two places task identity is normalized.
|
|
208
|
+
|
|
209
|
+
- prev-chain: sha256:c7f964d3dd285f1d02eba1ccd0ee200ec8dcca8b94d05d0b03d5f81403aad669
|
|
210
|
+
|
|
211
|
+
### n=3 — a reworded active task is a refinement, not a silent deletion (gate, preregistered 2026-11-21)
|
|
212
|
+
|
|
213
|
+
- **hypothesis (falsifiable, registered before the edit):** `validateTodoLifecycle`
|
|
214
|
+
(`src/policies/todo.ts:312-372`) decides task identity with exact normalized
|
|
215
|
+
text (`todoTaskKey`, line 117). An agent that sharpens an in-progress task's
|
|
216
|
+
wording therefore loses the old key, the function reports the old task as
|
|
217
|
+
"removed without being marked completed or cancelled", and the whole
|
|
218
|
+
`todowrite` is refused. Falsified if the journal's `todo_lifecycle` records
|
|
219
|
+
show no text refinement, or if a refinement already passes today.
|
|
220
|
+
|
|
221
|
+
- **pre-change probe (recorded before the edit):** the journal holds 18
|
|
222
|
+
`todo/todo_lifecycle` blocks. Three sessions repeat the identical payload 7,
|
|
223
|
+
7 and 6 times. The reason strings name refinement pairs, not dropped work:
|
|
224
|
+
`'Verify the doc change and open its PR'` then `'Verify the doc change, pass
|
|
225
|
+
review, and open its PR'`; `'Push the branch, open PR #245 with Fixes #245'`
|
|
226
|
+
then `'Push the branch, open PR for #245 with Fixes #245'`; `'Open PR for
|
|
227
|
+
issue #42 and clean up the branch'` then `'Re-run review, record verdict, open
|
|
228
|
+
PR for issue #42 and clean up the branch'`. In every pair the removed text's
|
|
229
|
+
tokens are a subset of the retained text's tokens. The code already accepts
|
|
230
|
+
one replacement shape for this reason: the review-obligation carve-out at
|
|
231
|
+
line 326-357, and `todoTaskKey` already strips the `[read-only]` annotation
|
|
232
|
+
because "the marker is an annotation about a task, not part of which task it
|
|
233
|
+
is" (line 108-116).
|
|
234
|
+
|
|
235
|
+
- **prediction (expected gain):** a removed active task is treated as refined,
|
|
236
|
+
not deleted, when an unclaimed active task in the new list strictly contains
|
|
237
|
+
its token set (at least two distinct tokens in the removed text, at least one
|
|
238
|
+
more in the retained text). The refinement carries the removed task's
|
|
239
|
+
mutation window, so the completion-evidence gate keeps the work it already
|
|
240
|
+
counted, and the pass is journaled as `todo_refined`. Expected effect: the
|
|
241
|
+
refinement class stops producing `todo_lifecycle` blocks, and an agent no
|
|
242
|
+
longer burns retries folding the old wording back in. **at-risk
|
|
243
|
+
regressions:** (i) a genuine work drop that happens to extend the text now
|
|
244
|
+
passes, which is accepted because the tracker is textual and the new task
|
|
245
|
+
strictly contains the old tokens; (ii) two removed tasks could both claim one
|
|
246
|
+
retained task, so the claim is count-bounded; (iii) a one-word task has too
|
|
247
|
+
little signal and must stay strict. **non-goals:** no semantic comparison, no
|
|
248
|
+
change to the completion-evidence rule, no change to the read-only marker, no
|
|
249
|
+
fuzzy edit distance.
|
|
250
|
+
|
|
251
|
+
- **accept/reject rule:** accept if (a) the three journal pairs above now pass,
|
|
252
|
+
(b) an unrelated replacement of equal-length wording still blocks, (c) a
|
|
253
|
+
removed task with no retained successor still blocks, (d) the carried window
|
|
254
|
+
lets a refined task complete on the mutation already recorded, (e) a
|
|
255
|
+
refinement with no mutation still fails completion evidence, (f) `npm run
|
|
256
|
+
typecheck` and `npm test` are green, and (g) the held-out probes do not
|
|
257
|
+
regress. Reject if any genuine removal passes, if an existing lifecycle
|
|
258
|
+
assertion is weakened, or if the held-out set regresses.
|
|
259
|
+
|
|
260
|
+
- **selection score (5 items, deterministic):** (a) 18 journal records with
|
|
261
|
+
three retry loops of 7, 7 and 6; (b) the rule generalizes an existing
|
|
262
|
+
carve-out instead of inventing a mechanism (`todo.ts:326-357`); (c)
|
|
263
|
+
`todoTaskKey` already defines identity as annotated-normalized text, so the
|
|
264
|
+
change extends the same concept; (d) the diff is one policy file plus tests
|
|
265
|
+
and docs; (e) the failure is silent from the model's side, so the block
|
|
266
|
+
message alone cannot fix it.
|
|
267
|
+
|
|
268
|
+
- **held-out score:** 5/5 passed (5 items, never used for selection): the full
|
|
269
|
+
`npm test` suite (1726 passed, 0 failed), plus four probes written after the
|
|
270
|
+
fix. Those probes are an unrelated equal-length replacement (still blocks), a
|
|
271
|
+
one-word reword (still blocks), two removed tasks competing for one successor
|
|
272
|
+
(still blocks), and mutations before the inherited window (never count).
|
|
273
|
+
|
|
274
|
+
- **disjointness:** the selection items are journal reason strings from past
|
|
275
|
+
sessions. The held-out items are the repository's deterministic suite plus
|
|
276
|
+
probes invented after the fix. Nothing in the held-out set was used to choose
|
|
277
|
+
the token rule or its thresholds.
|
|
278
|
+
|
|
279
|
+
- **eval job path:** none. Deterministic verifier, no model in the scoring loop,
|
|
280
|
+
so the matched-budget control and the answer-rescue audit do not apply
|
|
281
|
+
(2607.12227, 2610.05533).
|
|
282
|
+
|
|
283
|
+
- **result (appended after the evaluation run):** GAIN. All three journal pairs
|
|
284
|
+
pass `validateTodoLifecycle`; the dispatcher accepts the reworded list and
|
|
285
|
+
journals `todo_refined`. Restoring the `origin/main` sources makes 8 of the
|
|
286
|
+
first-pass checks fail, which is the pre-change control. The remaining new
|
|
287
|
+
checks are boundary guards and pass in both directions by design. The full
|
|
288
|
+
suite is 1731 passed, 0 failed, and `npm run typecheck` is clean. The worktree
|
|
289
|
+
is on `feature/rsi-campaign-telemetry`; commit and PR follow.
|
|
290
|
+
|
|
291
|
+
- **review round (recorded before the PR):** the secondary reviewer returned
|
|
292
|
+
REQUEST-CHANGES. Its P1 held: the window carry and the completion gate each
|
|
293
|
+
re-derived the predecessor, so one predecessor could carry its start to two
|
|
294
|
+
successors. The fix makes the lifecycle verdict the only pairing authority:
|
|
295
|
+
`inspectTodoLifecycle` returns the key-level pairs, and the dispatcher passes
|
|
296
|
+
them to both `unverifiedTodoCompletions` and `recordTodoTaskStarts`. A split
|
|
297
|
+
case (one predecessor, two successors) and a one-to-one case (two and two)
|
|
298
|
+
are now regression tests; the second successor gets a fresh window, never the
|
|
299
|
+
predecessor's. Its P2 on matcher looseness was declined: a strict token
|
|
300
|
+
superset is the preregistered hypothesis, and the near-miss drop is its named,
|
|
301
|
+
accepted at-risk regression. Tightening it (semantic distance, scope terms)
|
|
302
|
+
would change the hypothesis mid-iteration and needs its own preregistration.
|
|
303
|
+
|
|
304
|
+
- **keep/revert:** keep.
|
|
305
|
+
|
|
306
|
+
- **next hypothesis:** the same identity question recurs wherever task text is
|
|
307
|
+
normalized, and C4 (tamper source-operand classification) is the next distinct
|
|
308
|
+
change-type in the archived candidate set.
|
|
309
|
+
|
|
310
|
+
- prev-chain: sha256:856438a0ed76a918a6acb324f0130adf0a2569c248a42229613120f330d775c2
|
|
311
|
+
|
|
312
|
+
### n=4 — a copy source under a config path is not a settings mutation (security, preregistered 2026-11-21)
|
|
313
|
+
|
|
314
|
+
- **hypothesis (falsifiable, registered before the edit):** in legacy mode
|
|
315
|
+
(no `liveControlPlanePaths` declared), `isSettingsTamper`
|
|
316
|
+
(`src/policies/tamper.ts:61-78`) applies `PATH_PATTERNS` to the whole command
|
|
317
|
+
segment, so any guarded path operand after `cp`, `ln`, or `install` blocks
|
|
318
|
+
the command, including a read-only source. The live-control-plane fact mode
|
|
319
|
+
already decides by the mutation target and allows the same copy
|
|
320
|
+
(`test/test.mts:8219-8233` pins both directions). Falsified if a guarded `cp`
|
|
321
|
+
source already passes without declared roots, or if a guarded destination
|
|
322
|
+
already blocks for a reason other than this pattern.
|
|
323
|
+
|
|
324
|
+
- **pre-change probe:** `test/test.mts` names the false positive "legacy: cp
|
|
325
|
+
FROM a .config/opencode source is blocked without live roots" and calls it
|
|
326
|
+
"the F3 false positive, pinned as current behavior". A live `cp` from
|
|
327
|
+
`~/.config/opencode/templates/rsi/` into a workspace draft was refused with
|
|
328
|
+
`PROTECTED_PATH_REASON` during this campaign.
|
|
329
|
+
|
|
330
|
+
- **prediction (expected gain):** legacy mode classifies `cp`, `ln`, and
|
|
331
|
+
`install` operands by role. The destination (last operand, or the `-t` /
|
|
332
|
+
`--target-directory` value) is checked against the guarded-path patterns; a
|
|
333
|
+
guarded source alone is allowed, matching fact mode and Policy 6's read-only
|
|
334
|
+
allowance. `mv`, `rm`, `tee`, `sed -i`, `chmod`, `chown`, `truncate`, `dd`,
|
|
335
|
+
`patch`, and `perl -i` keep the broad any-operand match, because each mutates
|
|
336
|
+
every operand it names. **at-risk regressions:** (i) a destination hidden in
|
|
337
|
+
a flag value (`--suffix .config/opencode`) is treated as an operand and could
|
|
338
|
+
be skipped; it is not a write target, so the residual risk is a missed
|
|
339
|
+
non-writing mention, not a write; (ii) an unrecognized copy-like program
|
|
340
|
+
(`rsync`) is out of scope and keeps its current behaviour; (iii) `mv` must
|
|
341
|
+
stay blocked even when the guarded path is the source, because the move
|
|
342
|
+
removes it. **non-goals:** no change to fact mode, no new path pattern, no
|
|
343
|
+
change to the redirect rules, no change to `isProtectedPath`.
|
|
344
|
+
|
|
345
|
+
- **accept/reject rule:** accept if (a) the legacy copy-source probe now
|
|
346
|
+
passes, (b) a copy into a guarded path still blocks, (c) `mv` from a guarded
|
|
347
|
+
path still blocks, (d) `ln` from a guarded path is allowed and `ln` into one
|
|
348
|
+
blocks, (e) `cp -t <guarded>` and `install -d <guarded>` block, (f) the
|
|
349
|
+
facts-mode tests are unchanged and green, (g) `npm run typecheck` and
|
|
350
|
+
`npm test` are green. Reject if any guarded destination passes, if `mv`
|
|
351
|
+
loosens, or if a fact-mode assertion regresses.
|
|
352
|
+
|
|
353
|
+
- **selection score (5 items, deterministic):** (a) the false positive is
|
|
354
|
+
pinned by an existing test and named finding F3; (b) fact mode already
|
|
355
|
+
defines the intended semantics, so this aligns two modes instead of
|
|
356
|
+
inventing a rule; (c) the change is one policy file plus tests and docs;
|
|
357
|
+
(d) a live reproduction failed in this campaign; (e) the true-positive set
|
|
358
|
+
is enumerable (`mv`, redirects, destinations).
|
|
359
|
+
|
|
360
|
+
- **held-out score:** pass. The full `npm test` suite is green, and every
|
|
361
|
+
held-out probe from the bank behaves as predicted: `--target-directory=` and
|
|
362
|
+
`-t` destinations block, `install -d <guarded>` blocks while `install -d
|
|
363
|
+
./build/out` passes, a multi-source `cp` with one guarded source passes, and
|
|
364
|
+
a guarded source with a guarded destination blocks.
|
|
365
|
+
|
|
366
|
+
- **disjointness:** the selection items are the existing test and the live
|
|
367
|
+
reproduction. The held-out probes are written after the fix. Neither was
|
|
368
|
+
used to choose the operand parser.
|
|
369
|
+
|
|
370
|
+
- **eval job path:** none. Deterministic verifier, no model in the loop.
|
|
371
|
+
|
|
372
|
+
- **result (appended after the evaluation run):** GAIN. Six legacy allowance
|
|
373
|
+
probes pass: `cp FROM`, `cp FROM` with a `2>/dev/null` redirect, a
|
|
374
|
+
multi-source `cp` with one guarded source, `ln -s FROM`, `ln -sfn FROM`, and
|
|
375
|
+
`cp -s FROM`. Restoring the `origin/main` source makes eight checks fail
|
|
376
|
+
(1776 passed, 8 failed). Six are those allowance probes. The other two are
|
|
377
|
+
destination probes that expose a pre-existing hole, recorded below. Every
|
|
378
|
+
remaining blocked-direction probe is green on both trees, which is the
|
|
379
|
+
pre-change control. The full suite is 1784 passed, 0 failed, and
|
|
380
|
+
`npm run typecheck` is clean. Fact-mode assertions are unchanged. A residual,
|
|
381
|
+
fail-closed limitation is recorded: `cp -tDIR src` parses the attached short
|
|
382
|
+
value, while a copy whose destination cannot be identified (one operand)
|
|
383
|
+
keeps the broad match.
|
|
384
|
+
|
|
385
|
+
- **review-driven amendment 1 (recorded before the PR):** the registered rule
|
|
386
|
+
(d) said "`ln` from a guarded path is allowed". That was too broad. A hard
|
|
387
|
+
link is a second writable name for the guarded inode, so a later write to the
|
|
388
|
+
workspace link would mutate the guarded file, and the realpath-based
|
|
389
|
+
protected-path check cannot see it. The accepted result therefore changes the
|
|
390
|
+
registered `ln` scope from a blanket allowance to a symbolic-link-only
|
|
391
|
+
allowance: `ln -s`, `cp -s`, and `cp --symbolic-link` are reads, while `ln`
|
|
392
|
+
without `-s`, `cp -l`, and `cp --link` keep the broad any-operand match. The
|
|
393
|
+
tests cover both directions, and the docs and changeset name the carve-out.
|
|
394
|
+
|
|
395
|
+
- **review-driven amendment 2 (a pre-existing hole, not a regression):** the
|
|
396
|
+
reviewer asked for proof that a guarded destination cannot hide around an fd
|
|
397
|
+
duplication. It could. `isSettingsTamper` split on `&`, so
|
|
398
|
+
`cp src 2>&1 <guarded>` became `cp src 2>` plus `1 <guarded>`, and the second
|
|
399
|
+
fragment had no verb to match. The base tree allows that command, so the hole
|
|
400
|
+
predates this change. `isSettingsTamper` now drops `N>&M` and `N>&-` before
|
|
401
|
+
segmenting, because a descriptor duplication or close never names a write
|
|
402
|
+
target. A word after `>&` that is not a descriptor is kept, because bash reads
|
|
403
|
+
it as a file redirect. Two true-positive probes cover it, and both fail on
|
|
404
|
+
the base tree.
|
|
405
|
+
|
|
406
|
+
- **keep/revert:** keep.
|
|
407
|
+
|
|
408
|
+
- **chain repair (2026-11-21):** this record's `prev-chain` was computed while
|
|
409
|
+
n=3 was the last record. `parseRecords` extends the last record's block to
|
|
410
|
+
end of file, so appending n=4 changed n=3's parsed bytes. The value below is
|
|
411
|
+
n=3's parsed hash, which is what the parser compares against.
|
|
412
|
+
|
|
413
|
+
- prev-chain: sha256:9730e53bca265ed97b3094eddc97ff82ce5db06e32a1878fd281ab27d94a1c06
|
|
414
|
+
|
|
415
|
+
### n=5 — an interactive-tool name in argument position is not a TTY hang (gate, preregistered 2026-11-21)
|
|
416
|
+
|
|
417
|
+
- **hypothesis (falsifiable, registered before the edit):**
|
|
418
|
+
`checkInteractiveTtyCommand` (`src/policies/shell-safety.ts:143-155`) applies
|
|
419
|
+
`INTERACTIVE_COMMAND_PATTERNS` to the raw command text with
|
|
420
|
+
`regex.test(command)`, while monitors (`containsMonitorCommand:97-118`) and
|
|
421
|
+
pagers (`containsPagerCommand:126-141`) already match at command position.
|
|
422
|
+
A pattern word that is only a grep pattern, a printf string, or another
|
|
423
|
+
program's argument therefore blocks a safe command. Falsified if a
|
|
424
|
+
data-position `sudo` or `git rebase -i` already passes, or if the journal
|
|
425
|
+
records no such block.
|
|
426
|
+
|
|
427
|
+
- **pre-change probe:** the frozen journal holds two `interactive_tty` blocks,
|
|
428
|
+
both named "sudo with password prompt", in two different sessions
|
|
429
|
+
(`ses_e07461c9…` at `2026-11-20T11:38:17Z`, `ses_e06fc50b…` at
|
|
430
|
+
`2026-11-20T12:56:37Z`). The second is `cd … && grep -n "sudo…`, where the
|
|
431
|
+
matched word is a grep pattern; its resource list contains the bare token
|
|
432
|
+
`sudo`. During this iteration the same false positive blocked two live
|
|
433
|
+
commands in this session: a `grep` whose pattern listed `sudo`, and a `grep`
|
|
434
|
+
whose pattern listed `git rebase -i` (block reason "git interactive rebase").
|
|
435
|
+
No journal record shows a monitor or pager false positive, which matches the
|
|
436
|
+
command-position checks those two families already use.
|
|
437
|
+
|
|
438
|
+
- **prediction (expected gain):** every pattern in the family is judged at
|
|
439
|
+
command position, the way monitors and pagers already are. A segment's
|
|
440
|
+
command word comes from `unwrapShellWords`, so wrappers (`env`, `timeout`,
|
|
441
|
+
`command`, `exec`, `nice`, `nohup`, `stdbuf`, `time`) and leading
|
|
442
|
+
assignments never become the command. Control-flow prefixes (`do`, `then`,
|
|
443
|
+
`else`, `elif`, `while`, `for`, `!`, `time`) are skipped, so a loop or
|
|
444
|
+
conditional body is still judged. The editor names become an executable set.
|
|
445
|
+
`git rebase -i`, `git add -p`, `npm init` without `-y`, and the
|
|
446
|
+
apt/yum/dnf install forms become anchored verb patterns. `sudo` is detected
|
|
447
|
+
from the unwrapper, because unwrapping strips it: a new
|
|
448
|
+
`shellHasSudoWrapper` reports whether a `sudo` wrapper was consumed.
|
|
449
|
+
`eval` and shell `-c` payloads recurse. **at-risk regressions:** (i) a
|
|
450
|
+
command name that reaches a shell as stdin data (`echo 'vim x' | sh`) is no
|
|
451
|
+
longer matched, joining the indirection class the policy already excludes
|
|
452
|
+
(`watch`, `xargs`, `man`, `find -exec`, loop bodies); (ii) an unmodelled
|
|
453
|
+
wrapper that changes the command word is still unmodelled; (iii) a quoted
|
|
454
|
+
alias or shell function that expands to an editor is unchanged.
|
|
455
|
+
**non-goals:** no change to the monitor or pager sets, no new editor name, no
|
|
456
|
+
change to the dispatcher's policy ordering.
|
|
457
|
+
|
|
458
|
+
- **accept/reject rule:** accept if (a) a `sudo` word in a grep pattern or
|
|
459
|
+
printf string passes, (b) `journalctl … | grep -i sudo` passes, (c) a
|
|
460
|
+
`git rebase -i` word in a grep pattern passes, (d) `vim`, `nano`, `sudo
|
|
461
|
+
apt-get update`, `env A=1 sudo ls`, `timeout 5 sudo ls`, `git rebase -i`,
|
|
462
|
+
`git add -p`, `npm init`, `apt-get install curl`, and `yum install curl`
|
|
463
|
+
still block, (e) `sh -c 'vim x'` and `eval 'npm init'` still block, (f) the
|
|
464
|
+
monitor and pager assertions are unchanged and green, (g) `npm run typecheck`
|
|
465
|
+
and `npm test` are green. Reject if a command-position true positive stops
|
|
466
|
+
blocking or a monitor/pager assertion regresses.
|
|
467
|
+
|
|
468
|
+
- **selection score (5 items, deterministic):** (a) 2 journal `interactive_tty`
|
|
469
|
+
records, both the same `sudo`-as-data class, in 2 sessions; (b) 2 live
|
|
470
|
+
reproductions in this campaign session; (c) the repository already defines
|
|
471
|
+
the intended semantics for monitors and pagers, with tests pinning
|
|
472
|
+
`echo top` as allowed, so the change aligns the remaining family rather than
|
|
473
|
+
inventing a mechanism; (d) no existing test covers data position for the
|
|
474
|
+
editor, `sudo`, `git`, `npm`, or apt/yum patterns, so the gap is silent;
|
|
475
|
+
(e) the change is one policy file, one shared helper, tests, and docs.
|
|
476
|
+
|
|
477
|
+
- **held-out score:** 26/26 passed (26 items, never used for selection). The
|
|
478
|
+
seven probes the base matcher also blocks are the control: with the base
|
|
479
|
+
`shell-safety.ts` restored they fail and the suite reports 1802 passed, 7
|
|
480
|
+
failed. The allowance probes are a `sudo` grep pattern, an exact `grep -n
|
|
481
|
+
sudo file.txt`, a piped `grep -i sudo`, a `git rebase -i` grep pattern, an
|
|
482
|
+
`npm init` grep pattern, an editor name in a printf string, and a command name
|
|
483
|
+
fed to a filter. The blocked probes are a chained editor, `sh -c`, `eval`,
|
|
484
|
+
`env`-wrapped and `timeout`-wrapped `sudo`, `sudo` as a loop body, `command
|
|
485
|
+
sudo`, `sudo` before an editor, a wrapped `sudo` before an editor, `git add
|
|
486
|
+
-p`, unconfirmed `yum install` and apt install, an apt install in a `then`
|
|
487
|
+
body, a nested `bash -lc`, and `busybox vi`. Three `shellHasSudoWrapper`
|
|
488
|
+
probes bind the helper's two directions.
|
|
489
|
+
|
|
490
|
+
- **disjointness:** the selection items are the frozen journal records, the two
|
|
491
|
+
live reproductions, the existing monitor/pager implementation, and the
|
|
492
|
+
absence of a data-position test. The held-out probes were written after the
|
|
493
|
+
fix, so they were never used for selection, and they were not used to choose
|
|
494
|
+
the command-position matcher.
|
|
495
|
+
|
|
496
|
+
- **eval job path:** none. Deterministic verifier, no model in the loop.
|
|
497
|
+
|
|
498
|
+
- **result (appended after the evaluation run):** GAIN. Every allowance probe
|
|
499
|
+
passes and every blocked-direction probe still blocks. The base matcher fails
|
|
500
|
+
exactly the seven probes it is expected to fail (1802 passed, 7 failed),
|
|
501
|
+
which is the pre-change control. The full suite is 1809 passed, 0 failed, and
|
|
502
|
+
`npm run typecheck` is clean. Monitor and pager assertions are unchanged. The
|
|
503
|
+
shared helper change is additive: `unwrapShellWordsImpl` now also reports
|
|
504
|
+
whether a `sudo` wrapper was consumed, and `TRANSPARENT_PREFIX` is exported,
|
|
505
|
+
so no existing caller changes behavior. One residual, accepted regression is
|
|
506
|
+
recorded above: a command name delivered to a shell as stdin data is no
|
|
507
|
+
longer read as code, which matches the indirection class the policy already
|
|
508
|
+
excludes.
|
|
509
|
+
|
|
510
|
+
- **review round (recorded before the PR):** the secondary reviewer returned
|
|
511
|
+
APPROVE and named three P2/P3 items. The paired-check item was accepted:
|
|
512
|
+
`sudo vim notes.txt`, `env A=1 sudo vim notes.txt`, and an exact `grep -n
|
|
513
|
+
sudo file.txt` were added, which is why the held-out set is 26 rather than
|
|
514
|
+
23. The docs item was declined with evidence that the reviewer read the
|
|
515
|
+
Policy 6 text: Policy 22 (`docs/policies.md:190`) already states the
|
|
516
|
+
command-position rule, the wrapper and control-flow handling, and the
|
|
517
|
+
stdin-data limitation. The public-surface item was declined: the test suite
|
|
518
|
+
imports the public helper surface from `src/workflow-guard.ts` by repository
|
|
519
|
+
convention, and no other production caller is added.
|
|
520
|
+
|
|
521
|
+
- **keep/revert:** keep.
|
|
522
|
+
|
|
523
|
+
- prev-chain: sha256:06f156a444fbb946dc13f77d389db3091c5cadb9ad360ac77938760df1346573
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# LL-016 — A false-positive matcher is usually a matcher that disagrees with a tested sibling; align the two instead of adding a rule
|
|
2
|
+
|
|
3
|
+
- **Evidence:** `/rsi-campaign` on `opencode-workflow-guard`, 3 iterations, ledger n=3/4/5, PRs #226/#228/#229. Every accepted fix landed on a question that a sibling matcher in the same policy core already answered, and every rejected candidate would have added a rule instead. Telemetry: 45 block codes over 7458 journal records; the two `interactive_tty` blocks were both `sudo`-as-grep-pattern, and the same false positive blocked two live commands during the iteration that fixed it.
|
|
4
|
+
|
|
5
|
+
| Iteration | Broken matcher | Tested sibling that already decided it | Change |
|
|
6
|
+
| --- | --- | --- | --- |
|
|
7
|
+
| n=3 | exact-text todo identity rejected a reworded active task | the annotated-normalized lifecycle key (`src/policies/todo.ts:326-357`) | carry the task window across a token-superset refinement |
|
|
8
|
+
| n=4 | legacy tamper mode matched every operand of `cp`/`ln`/`install` | fact mode judged the mutation target (`liveControlPlanePaths`) and allowed a guarded source | judge copy-like verbs by destination; `mv` keeps the broad match |
|
|
9
|
+
| n=5 | interactive-TTY patterns matched the raw command text | monitors and pagers already matched at command position | read the command word per segment; `sudo` comes from the unwrapper |
|
|
10
|
+
|
|
11
|
+
- **Fix:** each iteration aligned the broken matcher with its sibling and shipped both directions. The control run restores the base source file alone, never the tests: n=3 makes 8 of the new checks fail against `origin/main`'s sources; n=4 makes 8 fail against `origin/main`'s `tamper.ts` (6 allowances, 2 pre-existing fd-split destinations); n=5 makes 7 fail against the base `shell-safety.ts`. Suite at each iteration tip: 1756 (#226), 1784 (#228), 1809 (#229), each with 0 failed. The two screening rejections (unverified line numbers; no decision change) were the candidates with no sibling to align with.
|
|
12
|
+
|
|
13
|
+
- **Lesson:** name the sibling before naming the fix. If the same question already has a tested answer in the policy core, the preregistration cites it, the diff inverts the pinned false positive, and the held-out set proves the opposite direction still blocks. If no sibling exists, the candidate needs a design discussion rather than an iteration. A control that restores the base source and leaves the new tests in place is what makes the gain attributable to the alignment alone.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# RSI loop playbook
|
|
2
|
+
|
|
3
|
+
The operating manual for the `/rsi-loop` and `/rsi-campaign` commands, and the
|
|
4
|
+
repo-local grounding those commands read first. The top half is the scaffold
|
|
5
|
+
template; the anchors at the bottom are this repository's own pain points,
|
|
6
|
+
verifier, and metric.
|
|
7
|
+
|
|
8
|
+
## Before the first iteration
|
|
9
|
+
|
|
10
|
+
The loop depends on three artifacts in this repo. Create any missing one from
|
|
11
|
+
`~/.config/opencode/templates/rsi/` before running an iteration:
|
|
12
|
+
|
|
13
|
+
- `docs/agents/rsi-loop-playbook.md` — this file.
|
|
14
|
+
- `docs/agents/ledger.md` — the create-only experiment ledger.
|
|
15
|
+
- `docs/agents/lessons.md` and `docs/agents/lessons/` — the lesson memory.
|
|
16
|
+
|
|
17
|
+
## The base loop
|
|
18
|
+
|
|
19
|
+
One iteration maps to one branch and one PR:
|
|
20
|
+
|
|
21
|
+
1. **PROPOSE** — pick one minimal candidate change. Read the actual code first;
|
|
22
|
+
cite the files you read in the proposal.
|
|
23
|
+
2. **PREDICT** — before editing, register a falsifiable claim: expected effect
|
|
24
|
+
on the metric, how it will be verified, and at-risk regressions.
|
|
25
|
+
3. **IMPLEMENT** — delegate mechanical work to an `executor` subagent with a
|
|
26
|
+
full spec (inputs, constraints, acceptance command). Keep the diff minimal.
|
|
27
|
+
Start on the cheap tier; escalate only on an observable trigger.
|
|
28
|
+
4. **EVALUATE** — run the external verifier only; self-review is not evidence.
|
|
29
|
+
Change one causal axis per iteration.
|
|
30
|
+
5. **SELECT** — regularize selection: anneal the edit budget, screen proposals
|
|
31
|
+
for benchmark-specific trickery, prune stale or too-small edits, and advance
|
|
32
|
+
the incumbent only on a minimum effect size. Delegate a fresh-eyes check to
|
|
33
|
+
a `reviewer` subagent. Archive rejected attempts with their failure evidence.
|
|
34
|
+
6. **REMEMBER** — write one lesson file under `docs/agents/lessons/`, and append
|
|
35
|
+
one structured record to `docs/agents/ledger.md`. Write it either way; a
|
|
36
|
+
negative result is data.
|
|
37
|
+
|
|
38
|
+
## Hard rules
|
|
39
|
+
|
|
40
|
+
- Never edit tests, the verifier, baselines, or run logs to make a change pass.
|
|
41
|
+
- Live settings changes go through a sanctioned installer, never a direct edit.
|
|
42
|
+
- A negative result is a valid result: log it and stop.
|
|
43
|
+
|
|
44
|
+
## Multi-iteration campaigns
|
|
45
|
+
|
|
46
|
+
`/rsi-loop` runs one iteration. `/rsi-campaign` runs a bounded batch (3-5
|
|
47
|
+
iterations) in one session with explicit stop brakes and subagent fan-out: it
|
|
48
|
+
builds a diversity-tagged candidate set before iterating, enforces no-gain and
|
|
49
|
+
same-type stop brakes, and isolates overlapping edits in git worktrees. Each
|
|
50
|
+
iteration still maps to one branch and one PR.
|
|
51
|
+
|
|
52
|
+
## Anchors for this repository
|
|
53
|
+
|
|
54
|
+
- **verifier** — `npm run typecheck && npm test` in the repository root. Both
|
|
55
|
+
are deterministic: strict TypeScript compilation, then the in-memory
|
|
56
|
+
adversarial harness in `test/test.mts`. `npm run test:install` is the heavier
|
|
57
|
+
package and loader check, reserved for a change that touches the entrypoint.
|
|
58
|
+
- **metric** — false-positive policy blocks. The counterfactual is a command an
|
|
59
|
+
agent legitimately issues, or a legitimate lifecycle update, that a policy
|
|
60
|
+
refuses. The observable proxy is the block count per policy code in the audit
|
|
61
|
+
journal (`~/.local/state/opencode/workflow-guard/workflow-guard.jsonl`,
|
|
62
|
+
`decision: "block"`), paired with a regression case that fails before the fix
|
|
63
|
+
and passes after it. A fix that lowers the block count while removing a real
|
|
64
|
+
detection is a loss, not a gain, so every candidate ships both directions:
|
|
65
|
+
the now-allowed false positive, and a still-blocked true positive.
|
|
66
|
+
- **noise floor** — the journal accumulates across sessions and machines, so a
|
|
67
|
+
raw count is not comparable between runs. Every iteration therefore scores
|
|
68
|
+
against a frozen snapshot of the journal and a frozen subset of commands
|
|
69
|
+
quoted in its own block-reason strings, not against a live count.
|
|
70
|
+
- **frozen ruler** — the audit journal is read-only evidence. No iteration
|
|
71
|
+
edits, truncates, or regenerates it, and no iteration edits `test/test.mts`
|
|
72
|
+
assertions to make a case pass. The ruler is the historical journal plus the
|
|
73
|
+
policy code at `origin/main`.
|
|
74
|
+
- **spirit** — this plugin is a defence-in-depth deterrent against forgetful or
|
|
75
|
+
prompt-injected agents, not a sandbox. A candidate that removes a detection
|
|
76
|
+
class instead of a false positive is rejected, even when the suite stays
|
|
77
|
+
green.
|