Skip to content

feat(merge): quest merge runs the landing check itself - #675

Merged
kixelated merged 5 commits into
mainfrom
quest/m0/token-waste/merge-check
Nov 13, 2026
Merged

kixelated merged 5 commits into
mainfrom
quest/m0/token-waste/merge-check

Conversation

@kixelated

@kixelated kixelated commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest/m0/token-waste/merge-check.md.

Summary

quest merge --land now runs what quest check --no-stubs --base <base> --branch <head branch> checks, on the exact head it is about to queue, and refuses a head with findings (naming each, "fix the PR, then land it again"), before any GitHub write and before a queue build is spent.

  • landingCheck (src/cli/landed.ts): fetches the base's current SHA (baseRefOid) and the exact head SHA from the base repository (which serves fork heads too) into the repository of the checkout quest merge runs in. It fetches them as objects only and writes no ref, so Git sends only what is missing and an interrupted run leaves nothing behind. It then reads both trees from git objects. Nothing from the head is checked out or run. With no checkout, a shallow one, or one it cannot write, it uses a scratch bare repository instead and removes it afterward. The fetch uses the user's Git environment (proxies, insteadOf), with the token appended as a GIT_CONFIG_* header in the environment rather than in arguments.
  • It reports the head's structural findings beyond those the base already has (counted as a multiset), plus the landed finding (the quest branch neither deletes nor edits its quest since origin/<base>). It skips only when neither base nor head has quest/. Refusals name origin/<base> and the head, never the scratch path.
  • land() now takes a LandRequest { sha, method?, direct?, check } struct instead of five positional arguments; quest land bump passes a no-op check, since its PR is the daemon's own version-file commit.
  • landed() takes { branch?, head? } so it can diff two commits in a bare repository.
  • assets/skills/merge.md drops the hand-check paragraph and keeps one line: run quest merge with a quest the PR cannot modify.
  • README and quest merge --help describe the check.

Choices made without asking

  • Base findings are filtered, as the land daemon's screener does. Otherwise an installed quest older than the tree's format refuses every PR. (The dev shell's pin does this today: it flags ## Scheduled in quest/m0/mistake-audit.md on every head.)
  • Fetch objects by SHA into the user's checkout, writing no refs. Review round 1 showed that a scratch repository with alternates cannot negotiate and re-downloads the base's full history on every land. A full fetch now happens only with no usable checkout.
  • No self-refusal when run from the head's checkout. The quest asked me to weigh this. A check that lives in the untrusted code cannot establish trust, because a PR that wants to skip the check can delete it too. It would only catch honest accidents, and the skill line already covers those. Easy to add if wanted.
  • The check runs on every base, including ones whose gate checks again (queue-build.yml), as the quest's plan says.

Public API

CLI: quest merge --land gains a refusal (new behavior, no flag changes) and now needs network access to fetch git objects from github.com. No wire impact. Internal land()/landed() signatures changed.

Validation

  • just check and just test pass (1274 tests).
  • New tests in test/landed.test.ts run the real fetch path against local repositories: an untouched quest is found; an edit passes; only the committed head counts; a structural finding is reported; a base's own finding is skipped but one more copy of it is not; a head adopting quests is checked; a head with no quests is a finding; a base without quests is skipped; a checkout gets the objects but no refs; shallow and read-only checkouts are left untouched; an unknown head fails loudly and leaves no scratch directory.
  • Real surface: ran landingCheck against GitHub for open PRs. On #675's claim-only head, it reported the untouched-quest finding; its current head, which deletes the quest, is clean (136 ms). #673, a claim with no files yet, reported the finding (112 ms). #652 came back clean: 120 ms from this checkout, and 770 ms with no checkout (full fetch). git for-each-ref was unchanged afterward.
  • Differential: the old hand procedure (detached worktree + quest --root <head> check --no-stubs --base origin/main --branch <branch> from this checkout) agrees on both feat(gate): admit work through mbx's pool when mbx is installed #673 (finding) and feat(merge): hold a head an unanswered finding or newer maintainer decision signals #652 (24 documents ok).
  • quest merge 675 --land <sha> on the real CLI refused at the earlier draft-ownership check, as before; nothing was queued.

Review

Rewritten by quest review after each round.

  • Head: b6aeb10, named in full once no reviewer reports a finding

  • Base: origin/main at 696fdf8

  • Reviewer: Codex, gpt-6.1-sol, high effort

  • Session: 01a1d25a-56a7-7472-b476-d8c3e8d065a3, round 2

  • Score: 10/10, The shallow-checkout failure is fixed, and static review of the changes since the prior head found no new landing blockers; builds and tests were not run as instructed.

  • Rounds: 2; findings 1 (medium 1): fixed 1, refuted 0, open 0

  • Findings: none

  • The last round's findings, at 89c9b90:

    • Fixed: medium, src/cli/landed.ts:87: Skip shallow checkouts when configuring object alternates; src/cli/landed.ts now checks --is-shallow-repository and fetches independently into a scratch bare repository when the checkout is shallow.
  • Reviewer: opencode, opencode-go/deepseek-v4.1-flash, high effort

  • Session: ses_e2da5a2faffeEz2JXpfFPXX64C, round 2

  • Score: 9/10, All five earlier findings are fixed with code and tests I verified; only two narrow new edges remain, a read-only checkout no longer falling back and refs left behind by an interrupted run, neither of which blocks normal landings.

  • Rounds: 2; findings 7 (medium 1, low 6): fixed 5, refuted 0, open 2

  • Findings, open until the next round settles them:

    • Low, src/cli/landed.ts:81: A read-only checkout now fails the landing check instead of falling back
    • Low, src/cli/landed.ts:147: An interrupted run leaves quest-merge refs in the user's repository
  • The last round's findings, at 89c9b90:

    • Fixed: medium, src/cli/landed.ts:92: Every quest merge --land re-downloads the base branch's full history; `landingCheck` now fetches into the checkout's own repository under `refs/quest-merge/<uuid>/{base,head}` (src/cli/landed.ts:80-81,108-123) so Git advertises the checkout's refs and transfers only missing objects, with the scratch repository reserved for no checkout or a shallow one; the test "fetches into a checkout's repository, leaving none of its refs behind" covers the normal path.
    • Fixed: low, src/cli/landed.ts:110: Base-finding filter can hide a newly introduced identical finding; The base findings are now consumed one-for-one with `known.splice` (src/cli/landed.ts:130-135), so a head with one more copy of a base finding than the base reports it, covered by the test "reports one more of a finding the base already has".
    • Fixed: low, src/cli/landed.ts:107: A base without quest/ skips the head's structural check too; The early return is now `if (!based && !quests(tip)) return []` and `known` is empty when the base lacks quests (src/cli/landed.ts:124-129), so a head that introduces the quest tree is checked, covered by the test "a head that adopts quests is checked".
    • Fixed: low, src/cli/landed.ts:129: Refusals leak the scratch directory and misname the checked ref; `tidy` rewrites the scratch directory, base ref, and head ref in returned findings and in `landed` errors (src/cli/landed.ts:96-102,139-144), and `landed` now names the head ref it was given in its no-merge-base error (src/cli/landed.ts:27-31).
    • Fixed: low, src/cli/landed.ts:79: The check's fetch ignores the user's Git network configuration; The fetch now uses `discoveryEnv()` for the user's Git configuration and proxies, appending the token at `GIT_CONFIG_KEY_${count}` after any existing `GIT_CONFIG_COUNT` entries (src/cli/landed.ts:88,106-122).

Head 57a5098 fixes both open low findings, so no further round runs: (1) read-only checkout, fixed: whether the checkout's objects directory is writable is decided before fetching (accessSync), and otherwise a scratch repository is used (test "does not write to a checkout it cannot write"); (2) refs left by an interrupted run, fixed: the check now fetches the base and head SHAs (baseRefOid from GitHub) as objects only, writing no ref at all (test "fetches into a checkout's repository, writing none of its refs").

Models

Size: M
Implementer: Claude Code, claude-opus-5-5, unknown effort

🤖 Generated with Claude Code

kixelated and others added 2 commits November 12, 2026 16:32
quest merge --land fetches the base and the exact head into a temporary
bare repository that borrows the local checkout's objects, and refuses a
head on which quest check --no-stubs --base --branch finds anything the
base lacks, reading git objects so nothing from the head runs.
/quest-merge drops its hand check and keeps only: run a quest the PR
cannot modify.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title quest merge runs the landing check itself feat(merge): quest merge runs the landing check itself Nov 13, 2026
kixelated and others added 2 commits November 12, 2026 17:13
Fetch under unique refs it then deletes, so Git negotiates and sends only
what the checkout lacks; a shallow or absent checkout uses a scratch bare
repository. Count base findings as a multiset, check a head that adopts
quests, honor the user's Git network configuration, and keep scratch
paths and refs out of refusals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fetch the base and head SHAs as objects alone, so an interrupted run
leaves nothing in the checkout's repository, and use a scratch
repository for a checkout this process cannot write.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 13, 2026 01:25
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 48 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: db09fdd1-f12f-43ed-9573-380f118498b4
Commits

Reviewing files that changed from the base of the PR and between 6c97e48 and 4b7afac.

Files selected for processing: 11

  • README.md
  • assets/skills/merge.md
  • quest/m0/token-waste/merge-check.md
  • src/cli/hold.ts
  • src/cli/land-bump.ts
  • src/cli/landed.ts
  • src/cli/main.ts
  • test/hold.test.ts
  • test/land-bump.test.ts
  • test/landed.test.ts
  • test/status.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Important

The landing check's fetch breaks in any checkout that already carries a GitHub extraheader, such as one made by actions/checkout with its default persist-credentials: true. Every quest merge --land there fails with git fetch failed. One inline fix.

Reviewed changes

I reviewed the whole PR at 57a5098: the new landing check, the land() signature change, and the docs that go with them.

  • landingCheck: fetches baseRefOid and the head SHA as objects only. It fetches into the checkout's common git dir, or into a scratch bare repo when the checkout is shallow, read-only, or missing. It then runs check() on both trees, filters out findings the base already has (as a multiset), and adds the landed() finding.
  • land(pr, LandRequest, deps): the check runs after passing() and before any write. quest land bump passes a no-op check.
  • landed() options: takes { branch?, head? } so it can diff two commits in a bare or common git dir.
  • Docs: README, quest merge --help, and assets/skills/merge.md describe the built-in check in place of the hand procedure. The finished quest file is deleted.

I ran test/landed.test.ts, test/hold.test.ts, and test/land-bump.test.ts locally, and all 119 tests pass.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using claude-opus-5-5 | 𝕏

Comment thread src/cli/landed.ts Resolved
…oken

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

I reviewed the one commit added since the prior Pullfrog review at 57a5098.

  • Extraheader reset in the borrowed fetch: landingCheck now passes an empty-valued http.https://github.com/.extraheader entry before the token entry, so a checkout that already sends an Authorization header (for example actions/checkout with persist-credentials: true) no longer produces a duplicate-header 400 from GitHub. GIT_CONFIG_COUNT becomes count + 2 and the key and value indexes line up. This resolves the one open thread.

Pullfrog  | View workflow run | Using claude-sonnet-5-5 | 𝕏

@kixelated
kixelated added this pull request to the merge queue Nov 13, 2026
Merged via the queue into main with commit 47a5b56 Nov 13, 2026
16 checks passed
@kixelated
kixelated deleted the quest/m0/token-waste/merge-check branch November 13, 2026 01:41
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