Repository navigation
feat(tools): git tool — status/diff/add/commit (A2) - #41
Merged
Merged
Conversation
Light git for the coding-lite loop; closes the last manual-intervention gap short of push (push stays human by design). Same argv-whitelist discipline as gh.rs: op enum (status|diff|add|commit), validated fields (paths no leading dash + -- separator, message <=500 chars, no free-form flags), refusal before spawn. git add ['.'] is the sanctioned catch-all. Git subprocesses get their own 120s budget (vs 30s generic): hosts commonly install pre-commit hooks (this host's global template runs cora review, an LLM call) — the generic ceiling killed legitimate commits in live validation. Live validation (sandbox repo, real provider): agent ran status -> read_file (hash quoted) -> hash-anchored edit_file -> git add . -> git commit (hook passed) -> status verify; commit 3b23e28 landed. 121/121 tests (+7 git), clippy clean.
| Self { | ||
| bin: PathBuf::from("git"), | ||
| workdir: None, | ||
| } |
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
CodeCora caught a real gap on PR #41: the comment claimed jail-side validation that didn't exist. A path like ../other/file (or an absolute path) would be staged by git when the repo root sits above the workdir (monorepo subdirectory case). Lexical rejection before spawn: no leading / or \, no '..' path component anywhere. 5 new injection tests. 122/122 tests.
This was referenced Oct 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a
gitbuiltin tool with four whitelisted ops —status(--short --branch),diff(optional--staged),add(validated path array,--separator,['.']sanctioned catch-all),commit(-m, message ≤500 chars).pushand every network/history-mutating command are intentionally absent — push stays a human action. Same argv-whitelist discipline asgh.rs: unknown ops, leading-dash paths/messages, empty arrays — all refused before spawn.Git subprocesses use a dedicated 120s timeout (vs the 30s generic ceiling): pre-commit hooks are common (this host's global git template runs
cora review— an LLM call), and the generic ceiling killed legitimate commits during live validation.Why
A2 in the v1.1 roadmap (docs/epics.md): closes the last maintainer intervention in the coding-lite loop — the agent can now read → edit → stage → commit end-to-end. Also the natural companion for the markdown → uteke-document workflow (write_file → git commit → uteke_document).
Testing
op:push,op:remote, path--exec=/bin/sh, message--amend, missing/empty fields, 501-char message), and a fake-git e2e proving the spawned argv (same pattern as fake-gh).status→read_file(hash quoted) → hash-anchorededit_file→git add .→git commit(cora pre-commit hook ran and passed) →statusverify. Commit3b23e28landed onmaster.