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). For a folder a container agent can write, that
runner runs git inside the agent’s container and never on the host, so a
container agent’s facts are its own git’s.
Structs§
- GitCache
- Probe results per block id, with the folder each was taken in.
- GitFacts
- What git says about one working folder.
Constants§
- REFRESH_
AFTER_ MS - An entry this old is probed again on the next tick.
Functions§
- branch_
contained_ in_ default - Whether every commit of
branchis already in the default branch ofroot(origin/HEAD,origin/main,origin/master): a merged or fast-forwarded branch. False when either can’t be found. A squash merge leaves the tip outside the default branch:landed_filessees those. - branch_
deleted_ files - The files that PR deletes (the
--diff-filter=Dpart ofbranch_files). A release PR deletes every changeset it consumes. - 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 in [PROBE_TIMEOUT]. A diff of two commits: no working-tree filter runs. - cached
- The cached facts for
blockindir(seeGitCache::get). - landed_
files - Of
files(whichtheir_branchchanges intheir_root), the ones whose content on that branch is exactly what the PR’s base has inmy_root: the change already landed there (a squash merge leaves the branch tip outside the base, but the blobs are the same), so it is no overlap. Blob ids are content hashes, comparable across clones. A file either side can’t be read is kept. - merge_
base_ setting - The branch’s
gh-merge-basesetting (gh’s base for a PR from it), if set. - 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 most [MAX_CONCURRENT_PROBES] at 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.