Expand description
The git half of an agent’s work facts: repository, branch and uncommitted files in its working folder.
git never runs on a request: a background loop probes each agent’s folder
and the request reads the cache. An entry is re-probed once it is
REFRESH_AFTER_MS old or the agent’s folder changed. Distinct folders
are probed concurrently (MAX_CONCURRENT_PROBES at a time) and a probe
is abandoned after PROBE_TIMEOUT, so with a handful of folders an
entry is under ~30 s old; many slow repositories can make it older, which
is why every answer carries git_checked_ms. Every git run goes through
fs_ops::git’s safe runner (the repository’s own fsmonitor and filters
are off, nothing prompts, the index isn’t written, a slow run is killed
after a few seconds).
Structs§
- Entry 🔒
- GitCache
- Probe results per block id, with the folder each was taken in.
- GitFacts
- What git says about one working folder.
Constants§
- MAX_
CONCURRENT_ 🔒PROBES - Most probes running at once: each is a few git processes.
- MAX_
DIRTY_ 🔒FILES - Most uncommitted paths kept per agent;
GitFacts::dirty_countis the real total. - PROBE_
TIMEOUT 🔒 - A probe (several git runs, each with its own 4 s limit) is abandoned after this and the folder reads as having no git facts until the next.
- REFRESH_
AFTER_ MS - An entry this old is probed again on the next tick.
- TICK 🔒
- How often the loop looks for entries to refresh.
Functions§
- branch_
files - The files a PR from
headintobasechanges inroot:git diff --name-only base...head, the base beingorigin/<base>(or a local<base>), else the default branch (origin/HEAD,origin/main,origin/master), and the head a local branch, elseorigin/<head>. Empty when either can’t be found, on the base itself, or when git can’t say inPROBE_TIMEOUT. A diff of two commits: no working-tree filter runs. - cache 🔒
- cached
- The cached facts for
blockindir(seeGitCache::get). - first_
ref 🔒 - The first of
candidatesthat names a commit inroot. - merge_
base_ setting - The branch’s
gh-merge-basesetting (gh’s base for a PR from it), if set. - plain_
branch 🔒 - A branch name taken from a command, safe to hand git: no option, range or whitespace.
- probe
- Probe
dir:Nonewhen it isn’t inside a git repository (or git is missing or too slow). - refresh_
once - One refresh pass: probe each due
(block, folder)infolders, every distinct folder once and at mostMAX_CONCURRENT_PROBESat a time, each abandoned aftertimeout, and store the results stampednow_ms. - run_
git_ refresh_ loop - Keep every registered agent’s git facts fresh. Never returns.