Skip to content

fix: compare GitHub repository slugs case-insensitively - #1058

Merged
steipete merged 3 commits into
openclaw:mainfrom
dwin-gharibi:fix/automerge-repo-case-sensitivity
Aug 8, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
dwin-gharibi:fix/automerge-repo-case-sensitivity

Conversation

@dwin-gharibi

Copy link
Copy Markdown
Contributor

Closes #1057.

What Problem This Solves

Fixes an issue where a repair result naming the target repository with different
casing — https://github.com/OpenClaw/OpenClaw/pull/83707 instead of
openclaw/openclaw — failed every repository guard in the repair lane, even
though github.com serves both URLs and they address the same PR.

The clearest symptom is in automerge: the reviewed head SHA is dropped, and
automergePlanningHeadBlock then reports "automerge planning result is missing a
valid reviewed head SHA"
— a diagnostic that blames the model's output rather
than the comparison. The failure is fail-closed, so it stalls the lane rather than
merging anything wrong.

This is reachable, not theoretical. canonical_pr is model-authored:
prompts/repair/autonomous.md:93 tells Codex to emit it "with full URL when
known", and schema/repair/codex-result.schema.json:180 types it as an
unconstrained ["string", "null"] — no pattern, no normalization. A model echoing
a repository's display casing produces exactly this input.

Why This Change Was Made

parsePullRequestUrl / parseIssueOrPullRef match with the i flag and return
the slug verbatim; every consumer compared it byte-exactly. A sibling helper in
the same file already got this right — issueNumberFromRef lowercases both sides.

This adds one shared comparator, sameRepoSlug, and routes all sixteen
comparison sites through it:

module comparisons
automerge-outcome.ts 1
execute-fix-github.ts 4
execute-fix-artifact.ts 7
post-flight.ts 1
source-pr-checkout.ts 2
target-validation.ts 1

Fixing only the reported site would have left the identical defect in five other
modules, so they move together.

On the risk of touching execute-fix-artifact.ts (≈13% covered): the change is
one-directional. It can only turn a "different repository" verdict into "same
repository" when the two slugs differ solely by case; it can never make a
previously-matching slug stop matching. That bounds what a mechanical edit in a
low-coverage module can do.

sameRepoSlug also treats an empty or absent slug as no match, so the
comparator cannot degrade into "empty matches everything" — a real hazard when
swapping === for a helper.

Non-goals: no change to URL parsing, the allowed host, item-number matching, or any
other guard.

User Impact

Automerge and repair lanes resolve a canonical or source PR whose slug differs only
by case, instead of stalling with a misleading "missing reviewed head SHA". No
configuration change, no migration, no data-contract change.

OpenClaw Bay: not affected. No status, lifecycle, or telemetry shape Bay renders
changes. No Bay update or Bay proof is needed.

Release note: fix: compare GitHub repository slugs case-insensitively.
No CHANGELOG.md edit is included — happy to add one if this repo's release policy
wants it.

Evidence

Diff

 src/repair/automerge-outcome.ts       |  4 +--
 src/repair/execute-fix-artifact.ts    | 20 ++++++-------
 src/repair/execute-fix-github.ts      | 12 ++++----
 src/repair/github-ref.ts              | 17 +++++++++++
 src/repair/post-flight.ts             |  4 +--
 src/repair/source-pr-checkout.ts      |  6 ++--
 src/repair/target-validation.ts       |  6 ++--
 test/repair/automerge-outcome.test.ts | 54 +++++++++++++++++++++++++++++++++++
 8 files changed, 97 insertions(+), 26 deletions(-)

Plus a new proof package under docs/proof/automerge-repo-case-sensitivity/.

Focused tests

node --test test/repair/automerge-outcome.test.ts test/repair/execute-fix-github.test.ts test/repair/post-flight.test.ts test/repair/source-pr-checkout.test.ts → 18/18 pass.

Three new cases:

  • a canonical PR whose slug differs only by case resolves (three casings, including
    a mixed-case GitHub.com host);
  • a genuinely different repository is still rejected — a regression guard that
    passes both before and after, proving the fix did not widen into cross-repository
    head borrowing;
  • sameRepoSlug compares case-insensitively and never matches an empty/absent slug.

Red/green

Reverted only src/repair/, rebuilt, and re-ran:

build result
pre-fix 2 fail, 4 pass — the case-variant test and the comparator test
post-fix 6 pass, 0 fail

The cross-repository rejection test passes in both directions, which is the point:
it is a guard, not a symptom.

Real Behavior Proof

Claim. A parsed repository slug is matched case-insensitively, so a
case-differing canonical_pr resolves normally — while a genuinely different
repository is still rejected.

Exercised surface. automergeOutcomeReviewedShaFromResult() in
dist/repair/automerge-outcome.js (the reported site, measured before/after), plus
a scan of the built output of all six consumer modules.

Scenario / fixture. Three claims:

  1. Resolves — three casings each return the reviewed head, alongside an
    exact-case control.
  2. Bounded — three different repositories are rejected, including the near-miss
    openclaw/openclaw-state; an absent slug never satisfies a guard.
  3. Consistent — the built output of all six modules is scanned for a parsed slug
    compared with ===/!== instead of the comparator. Any match fails the proof, so
    a site added later without it is caught.

The contrast compiles the pre-fix automerge-outcome.ts + github-ref.ts from
the base commit inside the lease. If that build is unavailable the proof reports
SKIPPED and fails, rather than quietly asserting an unmeasured contrast.

Command and environment. Node 24 in a Docker-backed Crabbox local-container
lease:

crabbox run \
  --provider local-container \
  --local-container-image node:24 \
  --no-hydrate \
  --timing-json \
  --artifact-glob '.artifacts/automerge-repo-case-proof/**' \
  --script docs/proof/automerge-repo-case-sensitivity/run-proof.sh
field value
provider Crabbox local-container (Docker/OrbStack)
crabbox 0.15.0
image node:24 @ sha256:934240a162082fd8b8a2f90cd5114446443f1eba1c5378f6687167ca405e6584
container node v24.19.0 (satisfies engines.node >= 24)
lease cbx_fe1bec2bb1b0 (amber-barnacle)
run run_194358f6840f
artifact .crabbox/runs/run_194358f6840f/run_194358f6840f-artifacts.tgz
exit 0

Observed result. In-container: 17/17 proof checks PASS, focused suites
18/18, exit 0. The lease verified the comparator counts on both sides
(post-fix: 2 sameRepoSlug, pre-fix: 0) before running the claims.

https://github.com/OpenClaw/OpenClaw/pull/83707
  pre-fix : null  (reviewed SHA dropped)
  post-fix: 92dca8fde03aee8da56a84a011fa387b9c1640fe

PASS  cross-repository rejection unchanged by the fix

A gap this proof caught in itself. The first lease run failed:
post-flight.test.ts could not load, because the script ran build:repair while
test/helpers.ts imports dist/clawsweeper.js and dist/review-activity-cursor.js
from the main build. That was an environment gap in my proof script, not a code
defect — it passed on my host only because dist/ was already fully built there.
The script now runs build:node and asserts both artifacts exist. Recording it
because a proof that only works on a pre-warmed host is not a proof.

Artifact / trace. docs/proof/automerge-repo-case-sensitivity/ holds
run-proof.sh, run-proof.mjs, and the contract README. The lease artifact tarball
holds proof-output.txt, focused-tests.txt, install.log, build.log, and
prefix-build.log.

Limits. Covers the slug comparison only. Claim 3 scans built output for the
specific parsed.repo === … shape — a site comparing a parsed slug through a
differently-named local variable would not be caught by that regex; the six modules
were enumerated by hand from the parser call graph. The proof exercises no live
GitHub redirect: that github.com serves case-differing slugs is GitHub's documented
behavior, relied on here rather than demonstrated.

Repository test suite status

The proof and focused suites run on Node 24 inside the Crabbox lease recorded above
(18/18 in-container). The note below concerns only the full suite on the macOS host.

Host full suite on this branch: 22 distinct failures. Three did not appear in the
clean-tree baseline — comment webhook settles duplicate fast ack comments after dispatch, webhook signature verification uses sha256 body hmac, and exact-review queue durably coalesces concurrent unchanged pull request edits. All three are
known flakes from earlier branches in this series, and I verified rather than assumed:

  • comment-webhook.test.ts passes 25/25, three runs in a row in isolation on this
    branch;
  • a module-graph walk from dist/repair/comment-webhook.js shows none of the seven
    files this PR touches is reachable from it.

Green on this branch:

check environment result
Crabbox local-container proof Node 24 container PASS, 17/17, exit 0
focused repair suites Node 24 container 18/18
pnpm run build:all macOS host clean
pnpm run format:check macOS host clean, 636 files
pnpm run lint macOS host clean (all four projects)

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal priority bug or improvement with limited blast radius. labels Aug 7, 2026
@clawsweeper

clawsweeper Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 7, 2026, 5:06 PM ET / 21:06 UTC.

ClawSweeper review

What this changes

The PR adds a shared case-insensitive GitHub repository-slug comparator, applies it across repair and automerge guards, and adds focused tests plus a Crabbox proof package.

Merge readiness

✅ Ready for maintainer review

Keep this PR open for normal maintainer review: current main still performs byte-exact parsed-slug guards, while the PR consistently uses the non-empty case-insensitive comparator. The prior P1 does not remain on the reviewed head; the previously named source-PR and automerge-status guards now use the shared helper.

Priority: P2
Reviewed head: f81b1b01804faf8fcc041227216e7852d8bf20cc

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A narrow, consistent repair with strong controlled before/after proof and no remaining actionable patch finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body supplies a Node 24 Crabbox terminal proof with a recorded lease, pre-/post-fix built-output contrast, bounded rejection checks, and 17 passing proof checks.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body supplies a Node 24 Crabbox terminal proof with a recorded lease, pre-/post-fix built-output contrast, bounded rejection checks, and 17 passing proof checks.
Evidence reviewed 5 items Current main remains affected: Current main parses GitHub URLs case-insensitively but preserves the captured slug, while the automerge outcome guard compares it byte-exactly to the configured repository.
All relevant parsed-PR guards on the PR head use the helper: The PR head routes the source-PR checkout and the formerly flagged replacement/automerge target guards through sameRepoSlug; the previous P1 is not reproducible from this head.
Focused real-behavior proof is present: The checked-in proof exercises built repair output, measures a pre-fix null result against the post-fix reviewed SHA, preserves cross-repository rejection, and records a successful Node 24 Crabbox lease in the PR body.
Findings None None.
Security None None.

How this fits together

The repair lane receives model-authored GitHub URLs, parses their repository and PR identity, and validates that identity before repair or automerge actions proceed. These guards feed source-PR checkout, replacement handling, and automerge outcome reporting.

flowchart LR
A[Model-authored GitHub URL] --> B[GitHub URL parser]
B --> C[Repository slug comparator]
C --> D{Same target repository?}
D -->|Yes| E[Repair or automerge handling]
D -->|No| F[Fail-closed rejection]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Functional and proof scope production +43/-26, tests +54, proof docs +374 across 11 files The production change is a narrow shared-comparator rollout; the larger addition is a reproducible before/after proof contract.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #1057
Summary: This PR is the concrete candidate fix for the linked case-sensitive repository-slug bug.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Land the shared comparator with its bounded cross-repository regression guard, preserving exact repository identity apart from GitHub’s case-insensitive slug semantics.

Do we have a high-confidence way to reproduce the issue?

Yes. A case-variant model-authored canonical PR URL reaches the byte-exact current-main guard, and the checked-in pre-fix build proof records the resulting missing reviewed SHA.

Is this the best way to solve the issue?

Yes. A single non-empty case-insensitive comparator preserves the existing fail-closed boundary while matching GitHub repository-slug semantics at every parsed-PR guard.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against f6f6bfca7d65.

Labels

Label justifications:

  • P2: This fixes a bounded repair/automerge stall that fails closed rather than risking an incorrect GitHub action.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body supplies a Node 24 Crabbox terminal proof with a recorded lease, pre-/post-fix built-output contrast, bounded rejection checks, and 17 passing proof checks.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies a Node 24 Crabbox terminal proof with a recorded lease, pre-/post-fix built-output contrast, bounded rejection checks, and 17 passing proof checks.

Evidence

What I checked:

  • Current main remains affected: Current main parses GitHub URLs case-insensitively but preserves the captured slug, while the automerge outcome guard compares it byte-exactly to the configured repository. (src/repair/automerge-outcome.ts:24, f6f6bfca7d65)
  • All relevant parsed-PR guards on the PR head use the helper: The PR head routes the source-PR checkout and the formerly flagged replacement/automerge target guards through sameRepoSlug; the previous P1 is not reproducible from this head. (src/repair/execute-fix-artifact.ts:4472, f81b1b01804f)
  • Focused real-behavior proof is present: The checked-in proof exercises built repair output, measures a pre-fix null result against the post-fix reviewed SHA, preserves cross-repository rejection, and records a successful Node 24 Crabbox lease in the PR body. (docs/proof/automerge-repo-case-sensitivity/run-proof.mjs:57, f81b1b01804f)
  • Feature provenance and likely routing owner: The parser and its repair-lane structure date to the modularization commit, whose blame owns the current parser lines. (src/repair/github-ref.ts:7, 9ab7ed40220a)
  • Not already implemented or released: The PR head is not an ancestor of current main, and no tag contains it; the latest release therefore does not include this proposed fix. (src/repair/github-ref.ts:7, f81b1b01804f)

Likely related people:

  • Peter Steinberger: The parser lines and modularized repair implementation trace to the same feature-introducing commit. (role: introduced the current repair URL-parser and guard structure; confidence: high; commits: 9ab7ed40220a; files: src/repair/github-ref.ts, src/repair/automerge-outcome.ts, src/repair/source-pr-checkout.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (7 earlier review cycles)
  • reviewed 2026-08-07T09:20:55.206Z sha f81b1b0 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-07T11:23:52.643Z sha f81b1b0 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-07T13:17:12.149Z sha f81b1b0 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-07T14:21:25.509Z sha f81b1b0 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-07T16:22:30.623Z sha f81b1b0 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-07T18:17:22.093Z sha f81b1b0 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-07T19:26:21.684Z sha f81b1b0 :: needs changes before merge. :: [P1] Normalize the remaining source-PR repository guards

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 7, 2026
@steipete
steipete merged commit 7a9d33b into openclaw:main Aug 8, 2026
42 checks passed
@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Maintainer review done before merge: read the full source diff — the sameRepoSlug substitution is uniform across all six guard sites, the comparator's non-empty guard makes the both-missing edge stricter than the old ===, and the case-differing canonical_pr regression is covered in test/repair/automerge-outcome.test.ts. CI green on head. Thanks @dwin-gharibi! 🦞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Repository slugs are compared case-sensitively, so a case-differing canonical_pr drops the reviewed SHA

2 participants