Skip to content

feat: real git introspection (changes, wip, file-diff, history ops)#2

Merged
fdatoo merged 8 commits intomainfrom
feat/git-introspection
Apr 30, 2026
Merged

feat: real git introspection (changes, wip, file-diff, history ops)#2
fdatoo merged 8 commits intomainfrom
feat/git-introspection

Conversation

@fdatoo
Copy link
Copy Markdown
Owner

@fdatoo fdatoo commented Apr 30, 2026

Summary

  • fbi/git.gleam — shell-out wrapper (git -C repo_path) with typed GitError
  • fbi/git/parse.gleam — pure text parsers: log porcelain, name-status, numstat, unified diff hunks, status porcelain v2
  • fbi/git/repo.gleam — domain ops against the bare repo: commits_on_branch, commit_files, file_diff, branch_base_ahead_behind, wip_files / wip_file_diff / wip_patch (reading refs/fbi/wip-snapshot)
  • fbi/git/mutex.gleam — per-run OTP actor serialising concurrent history ops
  • fbi/git/history_ops.gleamsquash_local, mirror_rebase, sync_in_container, merge_in_container, dispatch_polish, dispatch_merge_conflict
  • fbi/handlers/history.gleam — real POST /api/runs/:id/history dispatching all five ops
  • handlers/changes.gleam — real /changes, /commits/:sha/files, /file-diff
  • handlers/wip.gleam — real /wip, /wip/file, /wip/patch, /wip/discard (via docker exec)
  • docker.gleamexec_container (create → start → inspect exec lifecycle)
  • db/runs.gleamchildren_of, insert_polish_run, insert_merge_conflict_run, count_active_children
  • context.gleam / fbi.gleamhistory_mutex field; actor started at boot
  • priv/static/wip-snapshotter.sh — in-container daemon writing refs/fbi/wip-snapshot to safeguard every 5 s
  • supervisor.sh — starts snapshotter; handles polish / merge-conflict kinds
  • run/worker.gleam — binds snapshotter + polish-prompt into containers; exports FBI_KIND

All stub handlers replaced. 67 tests pass (2 pre-existing NIF failures unrelated to this change).

Test plan

  • gleam test — 67 passed, 2 pre-existing failures only
  • GET /api/runs/:id/changes returns branch_name, commits[], branch_base, uncommitted[], children[]
  • GET /api/runs/:id/commits/:sha/files returns real file list with status + line counts
  • GET /api/runs/:id/file-diff?path=...&ref=<sha> returns hunk list
  • GET /api/runs/:id/wip returns ok: true with files once snapshotter has fired (≥5 s after container start)
  • POST /api/runs/:id/wip/discard clears working-tree changes via docker exec
  • POST /api/runs/:id/history with {"op":"polish"} spawns a child run and returns {"kind":"agent","child_run_id":N}

🤖 Generated with Claude Code

@fdatoo fdatoo merged commit d8f277c into main Apr 30, 2026
5 checks passed
@fdatoo fdatoo deleted the feat/git-introspection branch April 30, 2026 12:57
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.

1 participant