Skip to content

Ground explicit file edits in real file contents#34

Draft
CoreyRDean wants to merge 1 commit into
mainfrom
fix/file-edit-grounding
Draft

Ground explicit file edits in real file contents#34
CoreyRDean wants to merge 1 commit into
mainfrom
fix/file-edit-grounding

Conversation

@CoreyRDean
Copy link
Copy Markdown
Owner

@CoreyRDean CoreyRDean commented May 17, 2026

Non-technical summary

This fixes a reliability gap in intent's natural-language mode for file edits. When a user names a real file and asks intent to change it, the model can no longer skip straight to an ungrounded snippet that never touches the file. intent now forces that workflow to read the target file first or fail closed.

That matters now because issue #22 is a direct break in the product promise: a request to modify a known file should yield an executable edit grounded in the file's actual contents, not pseudocode.

Technical summary

  • add an engine-side grounding check that detects explicit file-edit requests and tracks whether the model has called read_file on the named target before returning a command or script
  • if the model skips grounding, feed back a repair instruction inside the same turn so it can recover with a read_file tool call; if it still does not, return a refusal instead of surfacing the ungrounded edit
  • strengthen the system prompt in internal/model/prompt.go so explicit file edits require read_file(path) FIRST
  • add regression coverage in internal/engine/engine_test.go for both the repair path and the fail-closed path, and update docs/SPEC.md to document the contract
  • verification: PATH="/opt/homebrew/bin:$PATH" go test ./internal/engine ./internal/model ./internal/cli, PATH="/opt/homebrew/bin:$PATH" go test ./..., PATH="/opt/homebrew/bin:$PATH" go vet ./..., PATH="/opt/homebrew/bin:$PATH" make build
  • breaking changes: none intended; this tightens a buggy edge case so ungrounded file-edit proposals are repaired or rejected instead of shown to the user

Additional notes

Trade-off: the detector is intentionally narrow and keys off explicit edit verbs plus file-like targets. It improves the real bug path without trying to infer every possible mutation request shape in one increment.

Deferred: broader grounding around implicit targets, multi-file rewrite flows, or richer path resolution heuristics remains separate work.

Remaining gap: this ensures explicit file-edit requests must read the named file before proposing a mutation, but it does not redesign the wider prompt/tooling strategy for all mutation tasks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant