Skip to content

Commit f8a64b1

Browse files
authored
fix(lfg): finish cleanly when the repo has no git remote (#1006)
1 parent 7c13588 commit f8a64b1

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

skills/lfg/SKILL.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ When invoking any skill referenced below, resolve its name against the available
2929

3030
`mode:agent` is report-only **by design** — it surfaces findings but never edits the tree; LFG applies the eligible ones in step 5. When narrating progress to the user, frame this as "review found X → applied X in step 5," not as "code review did not auto-fix." A report-only review followed by an LFG-applied fix is the intended contract, not a gap.
3131

32+
**Shipping precondition (steps 5–9).** Run `git remote` once before the shipping steps. If it lists **no remote** (e.g. a sandbox/throwaway checkout that has `git init` but no `origin`), shipping is **local-only**: make every commit the steps below call for, but **skip every push, PR create/edit, and CI-watch action** — the pushes in steps 5 and 6, the push and PR creation in step 8, and step 9 in full. A missing remote is a terminal local-only state, not an error: never retry a push or hunt for a remote — make the local commits and proceed to step 10. Run steps 5–9 normally when a remote exists.
33+
3234
5. **Apply and persist review fixes** (REQUIRED after step 4, before residual handoff)
3335

3436
Load `references/review-followup.md` and execute its apply step (mechanical apply + commit/push when changes exist). Do not proceed to the residual handoff, run browser tests, or output DONE while eligible review fixes remain only in the working tree uncommitted.
@@ -55,15 +57,15 @@ When invoking any skill referenced below, resolve its name against the available
5557
gh pr edit PR_NUMBER --body-file BODY_FILE
5658
```
5759

58-
6. If no open PR exists, create a tracked fallback file at `docs/residual-review-findings/<branch-or-head-sha>.md` containing the composed section and the source PR-review run context. Stage only that file, commit it with `docs(review): record residual review findings`, and push the current branch. If an upstream exists, run `git push`. If no upstream exists, resolve a writable remote dynamically: prefer `origin` when present, otherwise use `git remote` and choose the first configured remote. Then run `git push --set-upstream <remote> HEAD`. This is the durable no-PR sink. Do not output DONE until either the existing PR body has been updated or this fallback file commit has been pushed. If both paths fail, stop and report the failed commands; do not silently proceed.
60+
6. If no open PR exists, create a tracked fallback file at `docs/residual-review-findings/<branch-or-head-sha>.md` containing the composed section and the source PR-review run context. Stage only that file, commit it with `docs(review): record residual review findings`, and push the current branch **when a remote is configured** (per the shipping precondition). If an upstream exists, run `git push`. If no upstream exists but a remote is configured, resolve a writable remote dynamically: prefer `origin` when present, otherwise use `git remote` and choose the first configured remote. Then run `git push --set-upstream <remote> HEAD`. If there is no remote at all, do not push — the committed fallback file is the durable sink. This is the durable no-PR sink. Do not output DONE until the residual findings are durable: either the existing PR body has been updated, or this fallback file commit has been made (pushed when a remote exists, committed locally when none). A push that fails when a remote exists is a stop-and-report; never retry a push, or block DONE, when no remote exists.
5961

6062
Never block DONE on tracker filing failures once residuals have been durably recorded. A `no_sink` outcome is success only when the findings are present in the PR body or in the pushed fallback file.
6163

6264
7. Invoke the `ce-test-browser` skill with `mode:pipeline`.
6365

6466
8. Invoke the `ce-commit-push-pr` skill.
6567

66-
This commits any remaining changes, pushes the branch, and opens a pull request. If step 6 already opened a PR (check with `gh pr view --json number,url,state 2>/dev/null`), skip PR creation but still commit and push any uncommitted changes.
68+
This commits any remaining changes, pushes the branch, and opens a pull request. If step 6 already opened a PR (check with `gh pr view --json number,url,state 2>/dev/null`), skip PR creation but still commit and push any uncommitted changes. **Per the shipping precondition, when no remote is configured, do NOT invoke `ce-commit-push-pr` — its commit step pushes unconditionally (`git push -u origin HEAD`), so a literal invocation would still hit the impossible push. Instead commit any remaining changes locally yourself (`git add -A && git commit`) and skip the push and PR creation entirely.**
6769

6870
9. **CI watch and autofix loop** (only when an open PR exists for the current branch)
6971

skills/lfg/references/review-followup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Do not treat `autofix_class` as permission to auto-apply.
3737
1. Filter `actionable_findings` (or markdown Actionable Findings) with the bar above.
3838
2. Apply eligible fixes in the working tree in severity order (`#` stable from the review).
3939
3. Run targeted tests when `requires_verification: true` on any applied finding.
40-
4. If `git status --short` shows changes, stage only review-driven files, commit `fix(review): apply review findings`, and push before step 6. To push: if an upstream exists, run `git push`. If no upstream exists (common on a fresh feature branch, since step 8's `ce-commit-push-pr` has not run yet), resolve a writable remote dynamically: prefer `origin` when present, otherwise use `git remote` and choose the first configured remote. Then run `git push --set-upstream <remote> HEAD`. If no eligible fixes were applied, note explicitly and skip commit.
40+
4. If `git status --short` shows changes, stage only review-driven files, commit `fix(review): apply review findings`, and push before step 6 **when a remote is configured** (per LFG's shipping precondition). To push: if an upstream exists, run `git push`. If no upstream exists but a remote is configured (common on a fresh feature branch), resolve a writable remote dynamically: prefer `origin` when present, otherwise use `git remote` and choose the first configured remote. Then run `git push --set-upstream <remote> HEAD`. If there is no remote at all, do not push — the local commit suffices. If no eligible fixes were applied, note explicitly and skip commit.
4141

4242
## Step 6 — residual handoff
4343

tests/review-skill-contract.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,12 @@ describe("ce-code-review contract", () => {
680680
expect(lfg).toContain("choose the first configured remote")
681681
expect(lfg).toContain("git push --set-upstream <remote> HEAD")
682682
expect(lfg).not.toContain("git push --set-upstream origin HEAD")
683-
expect(lfg).toContain("Do not output DONE until either the existing PR body has been updated or this fallback file commit has been pushed.")
683+
expect(lfg).toContain("Do not output DONE until the residual findings are durable")
684+
685+
// Shipping precondition: a remote-less repo (e.g. a sandbox/throwaway checkout)
686+
// finishes locally instead of deadlocking on an impossible push.
687+
expect(lfg).toContain("Shipping precondition")
688+
expect(lfg).toContain("skip every push, PR create/edit, and CI-watch action")
684689

685690
// Autopilot contract: never prompt, but require a durable sink before DONE.
686691
expect(lfg).toContain("Do not prompt the user")

0 commit comments

Comments
 (0)