Skip to content

Commit 01833e8

Browse files
committed
fix: close unclosed marker in db.ts + update reviewer pin tests to the #978 ask design
CI (TypeScript job) failures: - `cli/cmd/db.ts` read-only guard (c87d59d) opened an `altimate_change start` block but never closed it — four marker integrity/discipline suites failed. Add the missing `end`. - v0.8.0 adversarial + carry-forward pin tests asserted the reviewer's old `bash: deny`. #978 relaxed bash to `ask`; update the pins to the real invariant: NO bash command ever evaluates to "allow" (redirect writes, credential reads, plain git all ask), destructive DDL stays hard-denied, edit/write stay denied.
1 parent acb7a59 commit 01833e8

3 files changed

Lines changed: 37 additions & 21 deletions

File tree

‎packages/opencode/src/cli/cmd/db.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const QueryCommand = effectCmd({
4444
db.close()
4545
}
4646
return
47+
// altimate_change end
4748
}
4849
const child = spawn("sqlite3", [Database.path()], {
4950
stdio: "inherit",

‎packages/opencode/test/altimate/carry-forward/agent-safety.test.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
* - destructive DDL is DENIED and cannot be overridden by a user wildcard
1010
* allow (the non-overridable safetyDenials merged last, last-match-wins);
1111
* - destructive shell ops default to "ask";
12-
* - the reviewer agent denies bash/edit/write but allows dbt_pr_review.
12+
* - the reviewer agent never mutates (edit/write denied, bash asks — #978
13+
* relaxed bash from deny to ask so `gh pr view` works with user approval)
14+
* but allows dbt_pr_review.
1315
*/
1416
import { afterEach, expect } from "bun:test"
1517
import { Cause, Effect, Exit, Layer } from "effect"
@@ -124,12 +126,14 @@ it.instance("sql_execute_write DDL is denied (write safety)", () =>
124126
}),
125127
)
126128

127-
it.instance("reviewer agent denies bash/edit/write but allows the verdict engine", () =>
129+
it.instance("reviewer agent never mutates (edit/write deny, bash asks) but allows the verdict engine", () =>
128130
Effect.gen(function* () {
129131
const reviewer = yield* load((svc) => svc.get("reviewer"))
130132
expect(reviewer).toBeDefined()
131133
expect(reviewer?.mode).toBe("primary")
132-
expect(evalPerm(reviewer, "bash")).toBe("deny")
134+
// #978: bash asks (user approves each command, e.g. `gh pr view`) — never runs silently
135+
expect(evalPerm(reviewer, "bash")).toBe("ask")
136+
expect(Permission.evaluate("bash", "DROP DATABASE prod", reviewer!.permission).action).toBe("deny")
133137
expect(evalPerm(reviewer, "edit")).toBe("deny")
134138
expect(evalPerm(reviewer, "write")).toBe("deny")
135139
// The dbt PR review verdict engine + read-only analysis tools are allowed

‎packages/opencode/test/skill/release-v0.8.0-adversarial.test.ts‎

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
// found a P0 — the agent advertised "read-only / cannot modify files" but its
55
// bash allowlist (`git log *`, `cat *`, `ls *`) was bypassable to arbitrary
66
// file READ (exfil) and WRITE (shell redirects ride inside the matched
7-
// command). The fix denies bash entirely for the reviewer; these tests pin that
8-
// it stays denied and that the read-only intent holds.
7+
// command). The v0.8.0 fix denied bash entirely; #978 relaxed that to "ask"
8+
// (every command requires explicit user approval — nothing auto-runs) so the
9+
// reviewer can `gh pr view` a PR URL. These tests pin the security intent:
10+
// NO bash pattern auto-runs (nothing evaluates to "allow"), and destructive
11+
// DDL stays hard-denied.
912
import { test, expect } from "bun:test"
1013
import { tmpdir } from "../fixture/fixture"
1114
import { Instance } from "../../src/project/instance"
@@ -16,38 +19,46 @@ function bashAction(agent: Agent.Info, command: string) {
1619
return PermissionNext.evaluate("bash", command, agent.permission).action
1720
}
1821

19-
// The reviewer agent advertises read-only; these pin that bash stays denied and
20-
// arbitrary read/write is refused. (Previously test.todo'd for a dual-DB migration
21-
// race in Instance.provide — legacy src/storage/db.ts vs core Effect-SQL migration
22-
// both creating `project` — now resolved by the fresh-install core-schema adoption
23-
// fix in src/storage/db.ts; re-enabled and passing.)
24-
test("reviewer agent: bash is denied (base)", async () => {
22+
// The reviewer agent advertises read-only; these pin that NO bash command is
23+
// auto-approved and arbitrary read/write cannot run silently. (Previously
24+
// test.todo'd for a dual-DB migration race in Instance.provide — legacy
25+
// src/storage/db.ts vs core Effect-SQL migration both creating `project` —
26+
// now resolved by the fresh-install core-schema adoption fix in
27+
// src/storage/db.ts; re-enabled and passing.)
28+
test("reviewer agent: bash requires approval (base) — never auto-allowed", async () => {
2529
await using tmp = await tmpdir()
2630
await Instance.provide({
2731
directory: tmp.path,
2832
fn: async () => {
2933
const reviewer = await Agent.get("reviewer")
3034
expect(reviewer).toBeDefined()
31-
expect(PermissionNext.evaluate("bash", "*", reviewer!.permission).action).toBe("deny")
35+
// #978: "ask" instead of "deny" so `gh pr view <url>` is possible with
36+
// explicit user approval. The P0 was auto-run via a bypassable allowlist;
37+
// "ask" never auto-runs.
38+
expect(PermissionNext.evaluate("bash", "*", reviewer!.permission).action).toBe("ask")
3239
},
3340
})
3441
})
3542

36-
test("reviewer agent: redirect-write and arbitrary-read bash commands are denied", async () => {
43+
test("reviewer agent: redirect-write and arbitrary-read bash commands never auto-run", async () => {
3744
await using tmp = await tmpdir()
3845
await Instance.provide({
3946
directory: tmp.path,
4047
fn: async () => {
4148
const reviewer = (await Agent.get("reviewer"))!
4249
// Write via redirect riding inside a once-allowed `git log *` pattern.
43-
expect(bashAction(reviewer, "git log -p HEAD > ~/.ssh/authorized_keys")).toBe("deny")
44-
expect(bashAction(reviewer, "git diff HEAD >> ~/.bashrc")).toBe("deny")
45-
expect(bashAction(reviewer, "ls > /etc/cron.d/pwn")).toBe("deny")
46-
// Arbitrary file read (credential exfil) that `cat *` used to allow.
47-
expect(bashAction(reviewer, "cat ~/.altimate/altimate.json")).toBe("deny")
48-
expect(bashAction(reviewer, "cat .env")).toBe("deny")
49-
// Even the previously-allowed read-only git inspection is now denied.
50-
expect(bashAction(reviewer, "git log --oneline")).toBe("deny")
50+
// These surfaced the v0.8.0 P0 as silent auto-runs; they must never be "allow".
51+
expect(bashAction(reviewer, "git log -p HEAD > ~/.ssh/authorized_keys")).toBe("ask")
52+
expect(bashAction(reviewer, "git diff HEAD >> ~/.bashrc")).toBe("ask")
53+
expect(bashAction(reviewer, "ls > /etc/cron.d/pwn")).toBe("ask")
54+
// Arbitrary file read (credential exfil) that `cat *` used to auto-allow.
55+
expect(bashAction(reviewer, "cat ~/.altimate/altimate.json")).toBe("ask")
56+
expect(bashAction(reviewer, "cat .env")).toBe("ask")
57+
// Read-only git inspection also prompts (no allowlist at all).
58+
expect(bashAction(reviewer, "git log --oneline")).toBe("ask")
59+
// Destructive DDL stays hard-denied regardless of the ask default.
60+
expect(bashAction(reviewer, "DROP DATABASE prod")).toBe("deny")
61+
expect(bashAction(reviewer, "truncate users")).toBe("deny")
5162
},
5263
})
5364
})

0 commit comments

Comments
 (0)