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 first and make the smallest implementation change. I’ll also run formatting and the relevant/full validation commands available locally.
- Assistant
rgisn’t installed in this checkout, so I’m switching tofind/grep. I’m also checking the current branch and worktree before touching files so unrelated user changes remain intact. - Assistant
The common pattern confirms backups must cover every file each adapter actually overwrites, including MCP/config files, while preserving an existing first backup. I’m adding filesystem-level tests for both adapters, with default-enabled, explicitly-disabled, and nested project-relative custom paths.
- Assistant
The new tests fail on the intended gaps: neither adapter creates backups, and Crush treats relative custom paths as process-relative and fails on missing parents. I’m now wiring both through the shared backup/directory helpers, immediately before each actual write.
- Assistant
The focused suite now passes (31 tests). Before full validation, I’m formatting only the touched files and reviewing the diff for accidental changes; then I’ll run lint, the full test suite, and build.
- Assistant
Formatting and diff checks are clean. The full lint/build/test validation is running now; no issues have surfaced from the focused regression coverage.
- Assistant
Lint and build pass. The full suite ran 1,040 tests: the new coverage and 1,038 others pass; two pre-existing environment-sensitive tests fail (global config expects
/rootwhile this runner sets/workspace, and a permission-error test runs as root). I’m rerunning those failures individually to confirm they are unrelated, then I’ll do the final worktree check.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.