Skip to content

docs: make repo_status spec faithful to source check_repo#11

Merged
hartsock merged 1 commit into
mainfrom
spec/repo-status-fidelity
May 31, 2026
Merged

docs: make repo_status spec faithful to source check_repo#11
hartsock merged 1 commit into
mainfrom
spec/repo-status-fidelity

Conversation

@hartsock

Copy link
Copy Markdown
Owner

What

Docs-only correction of the repo_status specification — the next
unimplemented M1 item (src/status.rs is still todo!()). Brings the spec
into line with the authoritative source check_repo it is meant to reproduce.

No source files touched, so this does not collide with the in-flight per-method
implementation work (#3#10). No private/internal references reintroduced
(verified against the cleanup in #8).

Why

The earlier scaffold spec for repo_status had drifted from the real
check_repo logic in several ways that would have produced a subtly
non-drop-in implementation:

Spec said Source actually does
field state field sync_state
dirty as a fallback state gates on local_sha == remote_sha → up-to-date first, then ahead/behind
could return DIRTY check_repo never returns DIRTY (it's a flag; DIRTY comes from the scan path)
no-remote populates tracking no-remote leaves tracking_branch None
fetch returns bool only a fetch failuresync_state=ERROR, error="Fetch failed: {stderr}"

Changes

  • docs/API.mdRepoStatus.sync_state (not state); decision rewritten as
    the verbatim check_repo tree; field-name caveat for the implementor.
  • docs/PORTING.mdrepo_status pseudocode transcribed line-for-line from
    check_repo, including exact error strings and the _fetch -> (ok, stderr)
    note.

Implementor follow-up (flagged, not changed here)

The compiled RepoStatus #[pyclass] getter is state; the source contract
uses sync_state. When repo_status is implemented, rename the getter in
src/python.rs and the .pyi stub for a true drop-in. Left to the impl thread
to avoid racing the in-flight src/ work.

🤖 Generated with Claude Code

Corrects logic drift in the repo_status spec (the next unimplemented M1 item)
against the authoritative check_repo:
- field is sync_state, not state
- gate on local_sha == remote_sha -> up-to-date FIRST, then ahead/behind
- check_repo never returns DIRTY (flag only; DIRTY comes from the scan path)
- no-remote leaves tracking_branch unset
- fetch failure -> sync_state=ERROR, error="Fetch failed: {stderr}"
- exact error strings preserved
- flags the src/python.rs pyclass `state` -> `sync_state` rename for the
  implementor (not changed here, to avoid racing in-flight per-method work)

Docs-only; no source files touched. No private refs reintroduced.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@hartsock hartsock merged commit cdebdc6 into main May 31, 2026
1 check passed
hartsock added a commit that referenced this pull request May 31, 2026
WHAT: src/repo/fetch.rs — `fetch_result(path, remote) -> (bool, stderr)` and
`fetch(path, remote) -> bool`, a contained `git fetch` shell-out. Per PORTING.md,
gix network fetch is the least-mature path; shelling out to the user's `git`
honors their config / credentials / ssh-agent. `fetch_result` exposes stderr so
the repo_status roll-up can build "Fetch failed: {stderr}" (API.md / #11).
Registered + PyO3 wrapper. Tested vs a local bare remote (fetch advances
origin/main) and a bad-remote failure.

WHY: Last read-side primitive of M1, and the (ok, stderr) seam S1 needs.

NOTE: pilot-authored. The newt-agent worker prose-scrubbed twice here (the long
pre-written shell-out recipe pushed it past its whole-file-emit envelope — see
newt-agent docs/notes/2026-05-31-newt-coder-driving-sweet-spots.md). 12 of the 13
read methods were worker-coded; this network method is the exception.

Co-authored-by: Shawn Hartsock <hartsock@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
hartsock added a commit that referenced this pull request May 31, 2026
WHAT: src/status.rs — RepoStatusData + repo_status(path, fetch) porting
check_repo verbatim per #11: gates on SHA equality first (up-to-date), then
ahead/behind (diverged/behind/ahead); NEVER returns "dirty" (is_dirty is a flag
only); no-remote leaves tracking_branch None; a fetch failure -> sync_state
"error", error "Fetch failed: {stderr}" (via repo::fetch_result). Renamed the
RepoStatus pyclass getter state -> sync_state (python.rs + the .pyi stub) for a
true drop-in (the #11 follow-up). Wired the repo_status PyO3 wrapper.

WHY: The keystone roll-up; closes the M1 read side.

Tests: error (Directory not found / Not a git repository), no-remote, up-to-date,
ahead, behind (+ new_remote_commits), diverged — built on real fixtures with a
local bare remote.

NOTE: pilot-authored (a large multi-state file beyond the worker's whole-file
envelope; the 13 read primitives it composes were newt-agent-coded).

Co-authored-by: Shawn Hartsock <hartsock@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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