Skip to content

test: git-remote coverage (4/4) — OPF pre-push, degraded remotes, shallow/partial clones, e2e#1639

Open
Soph wants to merge 7 commits into
soph/git-remote-tests-3-divergencefrom
soph/git-remote-test-coverage
Open

test: git-remote coverage (4/4) — OPF pre-push, degraded remotes, shallow/partial clones, e2e#1639
Soph wants to merge 7 commits into
soph/git-remote-tests-3-divergencefrom
soph/git-remote-test-coverage

Conversation

@Soph

@Soph Soph commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

https://entire.io/gh/entireio/cli/trails/760

Part 4 (final) of the stack on #1638. First integration-level coverage for the OPF pre-push rewrite, degraded-remote/protocol edges, shallow and partial user clones, and the two remaining e2e scenarios.

Tests

  • E-group (OPF over a real remote, git-branch): happy path via real hook — remote v1 tip carries Entire-OPF-Applied: true with the OPF binary invocation proven via a fake opf script seam (the in-process runtime seam can't cross the hook process boundary; content-level redaction stays unit-covered); diverged v1 → V1DivergedError aborts the user push; CAS V1RefMovedError + successful re-run (strategy layer — the timing seam isn't deterministically reachable from a spawned hook); bootstrap cap aborts before OPF runs; non-TTY push completes without /dev/tty (regression 626a034).
  • F-group: GH013-style protected v1 branch → loud banner, no retry loop, user push unaffected (F1); shared checkpoint push budget bounds wall-clock against a stalling remote (F2, strategy layer — checkpointPushBudget has no env seam); blocked checkpoint policy under git-refs skips the ref push, keeps refs queued, doesn't abort the user push (F4); detached-HEAD session + HEAD:branch push + read-from-clone all work — no bug found (F5). F6 (entire:// provider routing) deferred: needs an injectable provider host table.
  • C5/C6 (both backends): --depth=1 clone — full session/commit/push/read without self-inflicted shallow grafts (regressions git_operations: stop shallow-fetching the metadata tip (root-cause fix for shallow-metadata false-disconnect) #1443/Prevent pack file race condition during checkpoint sync #1276); --filter=blob:none clone — lazy blob fetch on read with no promisor config stamped onto [remote "origin"] (regression Fetch checkpoint refs by URL to avoid polluting origin config #934).
  • G2/G3 (e2e): agent session in a linked worktree → plain push from the worktree → clone → resume; doctor against an unreachable origin completes without hanging.

Also marks the test plan's implementation status in docs/testing/git-remote-test-plan.md. Remaining open items: B-group (blocked on #1634), F6, and the pinned decisions (#1635, the unmerged >1000-commit replay cap fix).

Verification

  • mise run fmt && mise run lint clean per commit
  • mise run test:integration green (457 tests at tip, 0 skips)
  • go test ./cmd/entire/cli/strategy/ green
  • mise run test:e2e:canary green under both E2E_CHECKPOINT_STORE values (61 vogon + 4 external-agent)

🤖 Generated with Claude Code

https://claude.ai/code/session_012yi3hHGAGepwfrfjPETjGq


Note

Low Risk
Test-only changes and documentation; no modifications to production push, OPF, or remote logic.

Overview
Adds the final slice of the git-remote test plan: integration and e2e tests only (no production behavior changes), plus doc status updates.

OPF pre-push (git-branch, real hook): New opf_prepush_test.go drives OpenAI Privacy Filter through committed settings and a fake opf script in the spawned hook subprocess—happy path (Entire-OPF-Applied on remote v1), diverged v1 aborting the user push, bootstrap cap before OPF runs, and non-TTY completion. E3 (V1RefMovedError + retry) lives in manual_commit_opf_rewrite_test.go via fakeOPFMovesRefOnce because the race isn’t deterministic across a hook subprocess.

Degraded remotes (F-group): degraded_remotes_test.go covers GH013-style protected v1 (banner, no retry, user push OK), git-refs blocked checkpoint policy (skip ref push, keep queue), and detached-HEAD checkpoint push/read from clone.

Shallow/partial clones (both backends): shallow_partial_clone_test.go plus TestEnv.cloneFromWithArgs for --depth=1 and --filter=blob:none flows—checkpoint sync without worsening shallow state; lazy blob fetch without extra promisor config on origin.

Strategy: F2 shared push budget for pushCheckpointRefWithRecovery (git-refs analogue of the v1 budget test).

E2E: Worktree session → plain push → clone → resume (G2); DoctorCtx + unreachable origin without hang (G3).

docs/testing/git-remote-test-plan.md is marked implemented with remaining open items (B-group, F6, pinned decisions).

Reviewed by Cursor Bugbot for commit 2f04953. Configure here.

Soph and others added 5 commits July 4, 2026 22:37
Cover the OPF (OpenAI Privacy Filter) pre-push rewrite at the integration
and strategy layers, exercising what the existing in-process unit tests
structurally cannot: OPF enabled via committed settings, resolved and
executed inside a spawned pre-push hook, redacting real committed
checkpoints and pushing the Entire-OPF-Applied trailer to a real bare
remote.

- E1: happy path via the real git-invoked hook — remote v1 tip carries
  the trailer, the fake opf binary is invoked, checkpoint + branch land.
- E2: diverged v1 -> V1DivergedError aborts the user push (non-zero exit,
  actionable message); the branch tip on the remote does not advance.
- E4: bootstrap cap exceeded -> typed abort before OPF runs; nothing
  pushed and the opf binary is never executed.
- E5: non-TTY push (execx.NonInteractive, no controlling terminal)
  completes without hanging and still ships the trailer (regression
  626a034).
- E3: the CAS V1RefMovedError path is deterministically impossible to hit
  from a spawned hook, so it lands at the strategy layer via a fake OPF
  runtime that advances the local v1 ref mid-rewrite; a re-run succeeds.

Integration tests point the OPF `command` at a fake opf script on disk
(the in-process runtime seam is unavailable across the process boundary).
OPF is git-branch only, so all E-group tests stay on the default backend.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012yi3hHGAGepwfrfjPETjGq
Entire-Checkpoint: 950ada63c568
- F1 (git-branch): a bare-remote pre-receive hook rejecting the checkpoint
  v1 branch with a GH013-style message drives the protected-ref path: the
  hook prints its loud one-shot banner and returns, the user's own push
  still lands, and a repeat push does not retry-loop the rejected branch
  onto the remote (regression #1033).
- F2 (git-refs slice): pushCheckpointRefWithRecovery wraps its push,
  fetch+replay, and retry in the same shared checkpointPushBudget as the
  v1 path, so a stuck transport bounds total wall clock to ~one budget
  rather than stacking a full budget per attempt. Mirrors the existing
  git-branch TestDoPushRef_SharedBudget_BoundsTotalWallClock (regressions
  #1282, 2e2c1b7).
- F4 (git-refs): the git-refs pre-push path honors the checkpoint policy —
  a local policy this CLI cannot satisfy skips the per-checkpoint ref push
  (leaving refs queued) but does NOT abort the user push (regression
  7bbdad0 follow-up).
- F5 (git-branch): a session that checkpoints while HEAD is detached,
  pushed via `git push origin HEAD:<branch>` through the real hook, syncs
  and is readable from a fresh clone. Pins current (working) behavior.

F6 (entire:// provider-host routing) is deferred: it needs an injectable
provider host table / fake provider mapping that does not yet exist.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012yi3hHGAGepwfrfjPETjGq
Entire-Checkpoint: ca5c18be1b8a
Cover the two clone shapes a user can arrive with, across both checkpoint
backends:

- C5: a `git clone --depth=1` user clone runs the full session -> commit
  -> real-hook push -> read flow, and the checkpoint machinery never makes
  the repo shallower than git left it (no self-inflicted .git/shallow;
  regressions #1443/#1276). Reading the checkpoint tolerates the shallow
  boundary instead of corrupting it.
- C6: a `git clone --filter=blob:none` user clone reading a remote-only
  checkpoint lazily fetches the omitted metadata blobs, and the CLI stamps
  no new promisor/partialclonefilter config onto [remote "origin"]
  (regression #934). The .git/config guard enforces this at cleanup; an
  inline snapshot gives a clearer failure.

Refactors CloneFrom into cloneFromWithArgs so shallow/partial clone helpers
can pass --depth/--filter over the smart file:// transport (required for
those flags to be honored from a local bare).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012yi3hHGAGepwfrfjPETjGq
Entire-Checkpoint: 4da47566b4a2
- G2: an agent session runs inside a linked `git worktree`, the user
  commits and pushes the worktree's branch with a plain `git push` (the
  real pre-push hook syncs checkpoints — no explicit PushCheckpointRefs),
  and a fresh clone `entire resume`s the session. Exercises the worktree
  shadow-branch namespace and the shared common-dir push queue end to end.
- G3: `entire doctor` on a repo whose origin points at an unreachable
  (hermetic, missing local path) target completes without hanging or
  crashing and still reports its local session-health scan — pinning the
  degrade-to-local behavior.

Both are vogon-only (deterministic, free, part of the CI canary matrix).
G2 reuses the resume-from-clone prompt phrasing verbatim so vogon's
regex prompt parser needs no changes. Adds entire.DoctorCtx, a
context-bounded doctor runner that returns output+error instead of
failing the test, so G3 can surface a hang as a deadline.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012yi3hHGAGepwfrfjPETjGq
Entire-Checkpoint: 8f2fa44f0ab7
Groups A/C/D/E/F(1,2,4,5)/G delivered on this branch; B-group blocked on
decision D-1, F6 deferred, two pinned behaviors await product decisions.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012yi3hHGAGepwfrfjPETjGq
Entire-Checkpoint: 4f990d0112c0
Copilot AI review requested due to automatic review settings July 4, 2026 21:27
@Soph Soph requested a review from a team as a code owner July 4, 2026 21:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR completes the git-remote test-plan coverage by adding integration and E2E tests around OPF pre-push rewriting, degraded remote behaviors, and shallow/partial clone scenarios, plus a small E2E helper and a doc status update.

Changes:

  • Add integration tests for OPF pre-push rewrite (real hook + fake OPF binary seam), degraded remote cases, and shallow/partial user clones.
  • Add E2E scenarios for worktree-originated sessions resuming from a fresh clone, and entire doctor behavior with an unreachable remote.
  • Extend integration test harness cloning to support shallow/partial clones; add a git-refs push-budget regression test and document test-plan status.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
e2e/tests/worktree_remote_test.go Adds E2E coverage for worktree session → push → clone → resume, and doctor against an unreachable origin.
e2e/entire/entire.go Adds DoctorCtx helper to run doctor under a caller-supplied context timeout.
docs/testing/git-remote-test-plan.md Marks the plan as implemented on this branch and records remaining open items/pins.
cmd/entire/cli/strategy/push_common_budget_unix_test.go Adds shared-budget wall-clock bound test for git-refs checkpoint push recovery path.
cmd/entire/cli/strategy/manual_commit_opf_rewrite_test.go Adds deterministic ref-move seam to cover V1RefMovedError + successful retry.
cmd/entire/cli/integration_test/testenv.go Extends clone helper to accept extra clone args (used for shallow/partial clone test setup).
cmd/entire/cli/integration_test/shallow_partial_clone_test.go Adds C5/C6 integration coverage for --depth=1 and --filter=blob:none clones (both backends).
cmd/entire/cli/integration_test/opf_prepush_test.go Adds E-group integration tests validating OPF pre-push rewrite via real hook subprocess.
cmd/entire/cli/integration_test/degraded_remotes_test.go Adds F-group integration tests for protected v1 branch, blocked policy behavior, and detached-HEAD push/resume.

Comment on lines 1880 to 1884
cloneArgs := []string{"clone"}
cloneArgs = append(cloneArgs, extraArgs...)
if currentBranch != "" {
cloneArgs = append(cloneArgs, "--branch", currentBranch)
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2182fe0-c key=val pairs are hoisted before the clone subcommand. Note git clone -c is actually valid here (--config applies before the remote history is fetched, which is why these tests passed), but the hoist is still the right call: it avoids persisting the setting into the clone's .git/config and matches the git -c ... fetch pattern used elsewhere in the suite.

Soph and others added 2 commits July 5, 2026 10:14
Global -c applies to the transport for the invocation only; `git clone -c`
would also persist the setting into the clone's .git/config. Matches the
`git -c protocol.file.allow=always fetch` pattern used elsewhere.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012yi3hHGAGepwfrfjPETjGq
Entire-Checkpoint: 9d3594469d76
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants