Skip to content

feat(tools): git tool — status/diff/add/commit (A2) - #41

Merged
ajianaz merged 2 commits into
developfrom
feat/a2-git-tool
Aug 27, 2026
Merged

ajianaz merged 2 commits into
developfrom
feat/a2-git-tool

Conversation

@ajianaz

@ajianaz ajianaz commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

What

Adds a git builtin tool with four whitelisted ops — status (--short --branch), diff (optional --staged), add (validated path array, -- separator, ['.'] sanctioned catch-all), commit (-m, message ≤500 chars). push and every network/history-mutating command are intentionally absent — push stays a human action. Same argv-whitelist discipline as gh.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

  • 7 new unit tests: risk classification, exact argv per op (status/diff±staged/add±catch-all/commit), injection rejection (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).
  • 121/121 tests pass, clippy clean.
  • Live validation (sandbox repo, real provider, sessions dir outside the repo): agent ran status → read_file (hash quoted) → hash-anchored edit_file → git add . → git commit (cora pre-commit hook ran and passed) → status verify. Commit 3b23e28 landed on master.

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,
}
@github-actions

github-actions Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

🔍 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.
@ajianaz
ajianaz merged commit f9583be into develop Aug 27, 2026
11 checks passed
@ajianaz
ajianaz deleted the feat/a2-git-tool branch August 27, 2026 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants