Respect backups for OpenCode and Crush generated files Review run finding. OpenCode and…
- User
Respect backups for OpenCode and Crush generated files Review run finding.
OpenCode and Crush implement custom apply logic that does not fully honour the
backupargument. Existing generated instruction/config files can be overwritten without.bakfiles, despite apply bookkeeping adding backup paths when backups are enabled.Impact: user-owned
AGENTS.md,CRUSH.md, or.crush.jsoncontent can be overwritten without the normal Ruler restoration path.Evidence:
src/agents/OpenCodeAgent.tsomits the backup parameter for instructions writes.src/agents/CrushAgent.tswritesCRUSH.mdand.crush.jsondirectly.
Expected fix:
- Accept
backup = truein these agent implementations. - Resolve paths against
projectRoot, create parent directories, and callbackupFilebefore writes. - Add tests for backup enabled/disabled behaviour.
Interface
No new interfaces are introduced.
- Assistant
I’ll trace the agent implementations and existing backup test patterns, then add failing coverage before making the smallest implementation change. I’ll also run formatting and the relevant test/lint/build checks available locally.
- Assistant
rgisn’t installed in this workspace, so I’m usingfind/grepas the local fallback. The checkout is detached; after confirming the worktree is clean, I’ll create the required feature branch before editing. - Assistant
The engine already forwards the backup flag; the defect is isolated to these adapters. I’m adding direct adapter tests that exercise both instruction and config outputs, including relative custom paths, so the tests also pin path resolution and parent-directory creation.
- Assistant
The new tests fail on the expected gaps: neither adapter creates backups, and Crush also treats relative custom paths as process-relative and doesn’t create directories. I’m now applying the minimal symmetric write sequence: resolve → mkdir → optional backup → write.
- Assistant
The focused unit and integration suites now pass, and formatting is clean. I’m moving through the repository’s required CI sequence (
npm ci, lint, full tests, build); if any unrelated baseline issue appears, I’ll separate it from this change. - Assistant
Dependency installation and lint pass. The full Jest suite is still running; I’m waiting on its coverage run, then I’ll do the final build and inspect the worktree.
- Assistant
The full suite completed with 1,038/1,040 tests passing. The two failures are unrelated environment-sensitive baselines: a permission-error test runs as root and therefore doesn’t reject, and a global-init test expects
/rootwhile the test environment supplies/workspaceas the config home. All changed-agent suites pass. I’ll still run the explicit build/format checks and verify no generated artifacts entered the diff.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.