[Bugfix #1113] Anchor consult --type integration diff on an integration-branch base#1114
Merged
Conversation
…gration-branch base consult --type integration always diffed via gh pr diff (the PR's host-recorded base), so in repos with a long-lived integration branch (e.g. ci) ahead of main the diff swallowed the whole ci-over-main delta and overflowed the reviewer. Add a base override for the integration path, mirroring the hardened --type impl machinery: - --base <ref> flag + consult.integrationBranch config (.codev/config.json). - computeLocalPRDiff(): fetch both refs, verify both origin/<ref> resolve (fail loudly with a git fetch hint, no silent fallback to the checked-out tree), then git diff origin/<base>...origin/<head> (three-dot, merge-base anchored). - buildPRQuery() takes an optional local-diff override; PR info/comments still fetched normally; on-disk diff-file handoff preserved. - Wired both integration cases (builder head = current branch; architect head = pr.headRefName). No override -> gh pr diff, unchanged. - Fail-fast: --base is rejected outside --type integration.
…base - computeLocalPRDiff three-dot against the integration branch yields ONLY the PR change (excludes the ci-over-main delta that overflows the reviewer). - bug demo: anchoring on main sweeps in the whole integration delta. - fail-loud on unresolvable base/head refs (no silent local-tree fallback). - resolveIntegrationBase precedence: flag > config > undefined (default unchanged). - --base rejected outside --type integration.
…ionBase (CMAP) CMAP (codex) REQUEST_CHANGES: the blanket try/catch swallowed loadConfig errors (malformed .codev/config.json, legacy af-config.json, invalid harness config) and silently reverted to gh pr diff — the exact overflow this fix prevents, with no signal why. Remove the catch so those errors propagate like every other loadConfig caller. The explicit --base flag still short-circuits before the read, so it works even with a broken config. Add regression tests: malformed config throws (not silent undefined); --base works despite a broken config.
…leton (CMAP) CMAP (codex) REQUEST_CHANGES round 2: the consult.md doc update was applied to codev/resources/commands/ but not mirrored to the shipped codev-skeleton/ template, breaking the two-tree framework-doc mirroring rule and leaving adopters with stale CLI docs. Mirror the identical --base / consult.integrationBranch section into codev-skeleton/resources/commands/consult.md. (packages/codev/skeleton/ is a gitignored build artifact regenerated by copy-skeleton — not committed.)
Contributor
Author
CMAP review (Gemini · Codex · Claude)
Codex initially returned
After both fixes, Codex re-reviewed → APPROVE (HIGH), no issues. Verification: full unit suite green (0 failures), |
…ack) Architect noted the suite proved the diff helpers in isolation but never drove the actual --type integration command path. Add a dispatch wiring test that exercises resolveArchitectQuery -> resolveIntegrationBase -> computeLocalPRDiff -> buildPRQuery with --base ci (forge pr-view/pr-diff/comments stubbed; git runs for real), and asserts the query consumed the local three-dot diff (changed-file set = feature.txt; temp diff file holds the real change, not the stubbed gh pr diff) rather than the host-base diff. Export resolveArchitectQuery for the test.
…st + proven-vs-deferred)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
consult --type integration pr <N>could produce a 10k+ line diff that overflows a reviewer model, in repos with a long-lived integration branch ahead of the default branch (e.g. acibranch well ahead ofmain). The integration review had no way to anchor the diff on the integration branch — it always inherited the PR's host-recorded base.This adds a base override for the integration path, reusing the verified machinery the
--type implpath already has (#777/#784), so aci-ahead-of-mainrepo can point integration reviews atciand get a small, correct diff. Everyone else is unaffected.Root Cause
--type integration(both builder and architect context) →buildPRQuery(prId)→fetchPRDiff→ thepr-diffforge concept →gh pr diff <N>.gh pr diffis anchored on the PR's base branch as recorded on the host (merge-base of base↔head). When a PR's base is the trunk (main) while the head was branched from an integration branch (ci) well ahead of trunk, "changes vs main" legitimately swallow the entireci-over-maindelta. Theimplpath was already hardened for exactly this diff-base class; theintegrationpath never received that treatment.Fix
Give the integration path a diff-base override, mirroring the hardened
implpath:--base <ref>flag +consult.integrationBranchconfig (.codev/config.json). Precedence: flag → config → unset.computeLocalPRDiff()— when a base override is present, fetch both refs, verify bothorigin/<ref>resolve, then compute the diff locally asgit diff origin/<base>...origin/<head>(three-dot, merge-base anchored). Refs are passed as single argv elements (execFileSync) so branch names with shell metacharacters can't break out.git fetchhint if either ref is unresolvable — it never silently degrades to reviewing the checked-out tree (the cmap-3 degradation guarded against in the impl path).buildPRQuery(prId, localDiff?)takes an optional local-diff override; PR info/comments are still fetched normally, and the on-disk diff-file handoff is preserved (no inlining).gh pr diff(the PR's host base).--baseis rejected outside--type integration. Config-load errors propagate (no silent revert togh pr diff).The local-diff path computes the diff with plain
git(provider-agnostic), so it works for GitHub and GitLab alike without touching thepr-diffconcept.Out of scope (follow-ups, per the issue)
Auto-detecting the integration branch without configuration; changing the default base; deeper GitLab-specific work.
Test Plan
Regression suites
bugfix-1113-integration-base.test.ts(helpers) andbugfix-1113-integration-dispatch.test.ts(wiring):main→ci(well ahead) →feature(offci);computeLocalPRDiff(ci, feature)three-dot yields onlyfeature.txt, excluding theci-over-maindelta.mainsweeps in the wholecidelta (ci-big.txt) — the overflow source.--type integrationdispatch (resolveArchitectQuery→resolveIntegrationBase→computeLocalPRDiff→buildPRQuery) with--base ci(forgepr-view/pr-diff/comments stubbed); asserts the query consumed the local three-dot diff (changed-file set =feature.txtonly; the temp diff file contains the real change, not the stubbedgh pr diffoutput).git fetchhint (no silent local-tree fallback).resolveIntegrationBaseprecedence: flag > config > undefined (no override → defaultgh pr diff, unchanged); malformed config propagates the error;--baseworks even with a broken config.--baserejected outside--type integration.Proven locally vs. deferred⚠️
--type integration --base <ref>computes and consumes the local three-dot diff rather thangh pr diff), the fail-loud ref checks, precedence/guard, and config error propagation. Full unit suite green (0 failures);pnpm buildgreen.--base ci. codev itself has noci-ahead-of-maintopology, so this requires an adopter repo with the real topology. Recommend closing this against the real repro PR after merge.Fixes #1113