Skip to content

fix(code-review): resolve PR base host-agnostically (GitHub Enterprise fork fix)#818

Open
davidalee wants to merge 2 commits into
EveryInc:mainfrom
davidalee:fix/ce-code-review-resolve-base-host-agnostic
Open

fix(code-review): resolve PR base host-agnostically (GitHub Enterprise fork fix)#818
davidalee wants to merge 2 commits into
EveryInc:mainfrom
davidalee:fix/ce-code-review-resolve-base-host-agnostic

Conversation

@davidalee
Copy link
Copy Markdown
Contributor

Summary

The stable ce-code-review skill silently picks the wrong merge base — or no base at all — on GitHub Enterprise or any non-github.com host when the reviewer is working from a fork. The base-resolution awk block in SKILL.md matches remotes by literal github.com: / github.com/ substring, and the HTTPS fallback URL is hard-coded to https://github.com/.... On GHE, PR_BASE_REMOTE ends up empty, the script falls through to origin, and in fork workflows origin is the user's fork — so the resulting diff is either empty, incorrect, or relative to the wrong base.

This PR makes base resolution host-agnostic: the agent derives both <base-host> and <base-repo> from the same PR URL it already parses, and the awk block extracts (host, owner/repo) from each remote URL generically. No behavior change for github.com users.

How this was uncovered

While building ce-code-review-beta in #784 (Codex CLI delegation), the Codex code-review bot flagged the identical hard-coding pattern in the beta variant's resolve-base.sh:

The PR-base detection is hard-coded to https://github.com/... and later remote matching is hard-coded to github.com: / github.com/, so reviews on GitHub Enterprise (or any non-github.com host) will fail to identify the true base remote. In fork setups this can silently fall back to origin, producing the wrong merge base (or no base) even when the correct upstream remote exists.

That feedback was resolved in #784. Auditing the stable skill on main confirmed the same root cause — now living inline in SKILL.md after #815 replaced the standalone script with prose-driven base detection. This PR ports the fix.

What changed

plugins/compound-engineering/skills/ce-code-review/SKILL.md — base-resolution prose and awk:

  • Prose: instructs the agent to derive both <base-host> and <base-repo> from the PR URL (previously only the repo portion). Calls out case-insensitivity and shows a GHE example alongside the existing github.com example.
  • awk: replaces the two index($2, "github.com:<base-repo>") || index($2, "github.com/<base-repo>") substring checks with a per-remote parser that handles:
    • https://[user@]host[:port]/owner/repo[.git]
    • ssh://[user@]host[:port]/owner/repo[.git]
    • scp-form user@host:owner/repo[.git]
    • Strips userinfo, port, and trailing .git; lowercases host and owner/repo before exact-equality comparison.
  • HTTPS fallback URL: https://github.com/<base-repo>.githttps://<base-host>/<base-repo>.git.

Why this is safe to merge

  • No new dependencies, no new scripts: the change stays inline per fix(ce-code-review): replace resolve-base.sh with prose-driven base detection #815's design intent (prose-driven base detection).
  • No behavior change on github.com: the new awk produces the same remote pick for canonical github.com URLs, verified across HTTPS, scp-form, mixed-case, userinfo, port, and .git/no-.git variants.
  • Boundary case preserved: org/repo PR does not spuriously match a remote at org/repo-extra (exact equality, not substring).
  • No test regressions: full bun test suite passes (1340/1340); bun run release:validate clean.
  • Diff is small: 1 file, +15/-4 lines.

Test plan

  • bun test — all 1340 tests pass on this branch
  • bun run release:validate — metadata in sync
  • Awk smoke test with realistic remote URL forms:
    • git@ghe.acme.com:EveryInc/compound-engineering-plugin.git matches (ghe.acme.com, everyinc/compound-engineering-plugin)
    • https://x-token@ghe.acme.com/Org/Repo.git matches (ghe.acme.com, org/repo)
    • git@github.com:org/repo-extra.git does not match (github.com, org/repo)
    • git@github.com:org/repo.git still matches (github.com, org/repo) ✓ (regression guard)

Related

Replace hard-coded `github.com:` / `github.com/` substring matching and
`https://github.com/...` fallback URL with host+repo matching driven by
values derived from the PR URL. On GitHub Enterprise (or any non-
github.com host), the previous awk silently failed to identify the
upstream remote in fork workflows and fell through to `origin` — which
in fork setups points at the user's fork — producing the wrong merge
base or no base.

The agent now derives `<base-host>` and `<base-repo>` from the same PR
URL it already parses, lowercases both for case-insensitive comparison,
and the awk block extracts (host, owner/repo) from each remote URL
generically — handling `https://[user@]host[:port]/owner/repo[.git]`,
`ssh://[user@]host[:port]/owner/repo[.git]`, and scp-form
`user@host:owner/repo[.git]`. Strips userinfo, port, and trailing `.git`
before comparison. The HTTPS fallback URL also uses `<base-host>`
instead of a hard-coded `github.com`.

No behavior change for `github.com` users; enterprise hosts now resolve
correctly in fork workflows.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3a32c49243

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread plugins/compound-engineering/skills/ce-code-review/SKILL.md Outdated
- keep URL-form remote host ports when resolving the PR base remote

- allow scp-form SSH remotes to match a ported PR host without the web UI port

- add executable regression coverage for HTTPS, ssh URL, and scp-form GHE remotes

Note: pre-existing failure in bun test: tests/skills/ce-release-notes-helper.test.ts cannot start Bun.serve on port 0 (EADDRINUSE).
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