Skip to content

fix(queue): preserve empty legacy target branches - #889

Merged
brokemac79 merged 2 commits into
mainfrom
codex/fix-issue-target-branch
Jul 27, 2026
Merged

fix(queue): preserve empty legacy target branches#889
brokemac79 merged 2 commits into
mainfrom
codex/fix-issue-target-branch

Conversation

@brokemac79

@brokemac79 brokemac79 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Preserve an omitted target-branch field on legacy issue and pull-request intake so the event resolves the target repository's default branch instead of trying to fetch branch 0.

Problem

#857 changed the legacy event parser to read three tab-separated fields with Bash read. Tabs are IFS whitespace, so Bash collapses an empty middle field. For a branchless event, the serialized values were effectively:

openclaw/openclaw    <empty>    0

That shifted 0 into target_branch, and intake failed or admitted the wrong branch before normal review generation. The shared parser affects any legacy payload that omits target_branch:

  • openclaw/openclaw issue intake: #114128 was the last successful comparable issue; #114129 was the first subsequent failure.
  • openclaw/clawhub PR intake: ClawHub #3273 dispatched a pull_request_target/opened payload without target_branch in run 30235550150, then hit the affected receiver in run 30235555535.

Implementation

  • Emit the three legacy intake values as NUL-delimited fields.
  • Read them with Bash mapfile, which preserves the empty branch slot.
  • Require exactly three parsed fields before continuing.
  • Keep the existing empty-branch fallback to gh api "repos/$target_repo" --jq .default_branch.
  • Execute the workflow's actual embedded Node serializer in regression tests for:
    • branchless issue-open;
    • the branchless ClawHub #3273 PR-open payload shape;
    • branchless edited-PR source authority;
    • explicit-main command re-review.

NUL is not legal in Git refs, so this avoids both whitespace collapsing and collisions with valid branch-name characters.

After-fix runtime proof

On current head 9caa0704d744fdb94cc1ed3d625131cac3f40e4a, Git Bash extracted and executed the workflow's embedded Node serializer, applied the NUL mapfile assignments, and ran the workflow's live public default-branch lookup with this redacted issue payload:

{"item_kind":"issue","target_repo":"openclaw/openclaw","target_branch":"","source_event":"issues","source_action":"opened"}

Captured terminal output:

proof=legacy-issue-intake-after-fix
head=9caa0704d744fdb94cc1ed3d625131cac3f40e4a
field_count=3
field[0].target_repo=openclaw/openclaw
field[1].target_branch_before_default=<empty>
field[2].use_source_authority=0
default_branch_api=main
fetch_branch=main
authority_used_as_fetch_branch=no
assertions=PASS

This demonstrates the required runtime behavior: exactly three fields survive; the target branch remains empty until GitHub resolves main; and 0 remains the authority field rather than becoming the fetch branch. No token, credential, or secret value is included.

Validation

  • node --test --test-name-pattern "legacy event field serializer preserves branchless issue and PR intake|sweep issue and PR event reviews and target fanout avoid storm amplification" test/sweep-workflow.test.ts
    • 2 passed, 0 failed.
    • The executable serializer cases produced:
      • issue-open: ["openclaw/openclaw", "", "0"]
      • ClawHub PR-open: ["openclaw/clawhub", "", "0"]
      • edited PR authority: ["openclaw/clawhub", "", "1"]
      • explicit-branch re-review: ["openclaw/clawhub", "main", "0"]
  • pnpm exec oxfmt --check .github/workflows/sweep.yml test/sweep-workflow.test.ts
  • git diff --check
  • Parsed the workflow as YAML and passed the changed run: block through Git Bash bash -n.

actionlint is not installed on this host. The changed surface is an Ubuntu-hosted Bash step; the focused workflow tests and explicit Git Bash syntax/runtime proof passed. Known native-Windows aggregate failures invoke WSL's docker-desktop environment without /bin/bash and are outside this hosted workflow surface.

Review proof

  • Initial codex review --uncommitted found that a proposed | delimiter is legal in Git branch names. That finding was accepted; the parser was changed to NUL-delimited mapfile, and focused proof was rerun.
  • After adding executable issue/PR regression coverage, codex review --uncommitted was clean: “The added regression coverage correctly executes the workflow serializer and verifies branchless issue and PR payload handling.”
  • Final codex review --base origin/main on 9caa0704d744fdb94cc1ed3d625131cac3f40e4a was clean: “The workflow now uses NUL-delimited fields, preserving an empty target branch before resolving the repository default branch. The added serializer coverage exercises branchless issue and PR payloads.”

Risks / rollout

  • This changes only shared legacy repository-dispatch field decoding. Queue, Worker, state, publication, and review logic are unchanged.
  • The workflow-file change requires GitHub workflow write scope.
  • ClawHub #3273's later maintainer re-review carried explicit target_branch: main, reached the durable control plane, and still did not publish before merge. That is not explained by this parser bug. It requires a separate trace of dispatch key router-51dc3a77137b7009 through queue parking/retry and publication state; this PR does not claim to fix it.
  • After merge, verify three independent fresh canaries: issue-open, PR-open, and maintainer @clawsweeper re-review.
  • Existing missed, corrupted, or parked items need a separately authorized replay; this PR does not replay or mutate them.

Links

@brokemac79
brokemac79 requested a review from a team as a code owner July 27, 2026 08:03
@brokemac79

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 Urgent regression or broken agent/channel workflow affecting real users now. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. labels Jul 27, 2026
@clawsweeper

clawsweeper Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 27, 2026, 4:31 AM ET / 08:31 UTC.

ClawSweeper review

What this changes

This PR replaces whitespace-delimited legacy event fields with NUL-delimited fields so an omitted target branch remains empty and falls back to the target repository’s default branch instead of becoming the authority flag value.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This PR remains necessary: it repairs a concrete regression in legacy repository-dispatch intake, is narrowly scoped, and now includes credible after-fix terminal proof plus focused regression coverage. I found no discrete correctness defect in the proposed NUL-delimited handoff, but this shared workflow path should receive the stated post-merge issue, PR, and re-review canaries.

Priority: P1
Reviewed head: 9caa0704d744fdb94cc1ed3d625131cac3f40e4a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) This is a focused workflow repair with executable regression coverage, green checks, and direct redacted terminal evidence of the intended branchless intake behavior.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR body includes redacted after-fix Git Bash output on the final head showing the empty branch survives decoding, the public default-branch lookup resolves main, and authority 0 is not used as the fetch branch.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body includes redacted after-fix Git Bash output on the final head showing the empty branch survives decoding, the public default-branch lookup resolves main, and authority 0 is not used as the fetch branch.
Evidence reviewed 4 items Workflow decoder preserves empty branch slots: The proposed workflow emits three NUL-delimited values and uses Bash mapfile -d '' -t; it checks for exactly three fields before assigning the repository, branch, and authority values. This prevents Bash IFS whitespace processing from collapsing an empty middle field.
Executable regression coverage: The added focused test extracts the actual embedded Node serializer from the workflow and verifies branchless issue intake, branchless ClawHub pull-request intake, edited-PR authority handling, and explicit-branch re-review serialization.
Prior merged ingress work establishes the affected area: The related merged pull request #857 changed legacy event parsing for queue intake; this PR addresses the empty-field behavior left by that whitespace-delimited handoff.
Findings None None.
Security None None.

How this fits together

The sweep.yml legacy intake job receives repository-dispatch payloads and derives a target repository, target branch, and source-authority flag before placing work into ClawSweeper’s durable review queue. That branch selection controls which repository revision the downstream review worker fetches and evaluates.

flowchart LR
  A[Legacy repository-dispatch event] --> B[Legacy intake workflow]
  B --> C[Decode repository branch and authority]
  C --> D{Target branch supplied?}
  D -->|No| E[Look up repository default branch]
  D -->|Yes| F[Use supplied target branch]
  E --> G[Durable review queue]
  F --> G
  G --> H[Fetch revision and generate review]
Loading

Before merge

  • Resolve merge risk (P1) - This changes shared GitHub Actions intake before durable queue admission; fresh production canaries should confirm branchless issue-open, branchless PR-open, and maintainer re-review paths after merge.
  • Complete next step (P2) - No repair lane is needed because the PR has no concrete review finding; the remaining action is normal maintainer merge review and post-merge canary verification.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Changed surface 2 files affected; 87 added, 3 removed The patch is confined to one legacy workflow intake handoff and focused executable regression coverage.
Serialized scenarios 4 payload shapes covered The new test covers branchless issue and PR payloads, edited-PR source authority, and explicit-branch re-review behavior.

Merge-risk options

Maintainer options:

  1. Merge with targeted intake canaries (recommended)
    Land the focused parser fix, then verify one fresh branchless issue event, one branchless PR event, and one maintainer re-review against the live durable intake path.

Technical review

Best possible solution:

Merge the narrow parser repair with its workflow-level regression coverage, then verify the three independent live intake canaries without replaying previously missed or parked events.

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

Yes. The branchless legacy payload has a clear source-level failure mode: tab-delimited Bash read collapses the empty middle field, while the new workflow test executes the embedded serializer and asserts the expected three-field output.

Is this the best way to solve the issue?

Yes. NUL-delimited fields with mapfile -d '' preserve an empty field without colliding with legal Git ref characters, retain the existing default-branch fallback, and add focused coverage for the affected payload shapes.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes redacted after-fix Git Bash output on the final head showing the empty branch survives decoding, the public default-branch lookup resolves main, and authority 0 is not used as the fetch branch.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes redacted after-fix Git Bash output on the final head showing the empty branch survives decoding, the public default-branch lookup resolves main, and authority 0 is not used as the fetch branch.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: A shared queue-intake parsing regression can prevent real issue and pull-request review work from entering the durable control plane.
  • merge-risk: 🚨 automation: The diff changes the GitHub Actions parser that determines repository and branch inputs before durable review dispatch.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes redacted after-fix Git Bash output on the final head showing the empty branch survives decoding, the public default-branch lookup resolves main, and authority 0 is not used as the fetch branch.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes redacted after-fix Git Bash output on the final head showing the empty branch survives decoding, the public default-branch lookup resolves main, and authority 0 is not used as the fetch branch.

Evidence

What I checked:

  • Workflow decoder preserves empty branch slots: The proposed workflow emits three NUL-delimited values and uses Bash mapfile -d '' -t; it checks for exactly three fields before assigning the repository, branch, and authority values. This prevents Bash IFS whitespace processing from collapsing an empty middle field. (.github/workflows/sweep.yml:253, 9caa0704d744)
  • Executable regression coverage: The added focused test extracts the actual embedded Node serializer from the workflow and verifies branchless issue intake, branchless ClawHub pull-request intake, edited-PR authority handling, and explicit-branch re-review serialization. (test/sweep-workflow.test.ts:2630, 9caa0704d744)
  • Prior merged ingress work establishes the affected area: The related merged pull request fix(queue): dedupe unchanged pull request edits #857 changed legacy event parsing for queue intake; this PR addresses the empty-field behavior left by that whitespace-delimited handoff. (.github/workflows/sweep.yml:253, 439f425ec76d)
  • After-fix behavior proof: The PR body provides redacted Git Bash output on the current head showing three decoded fields, an empty target branch before default-branch lookup, authority value 0 retained separately, and main used as the fetch branch. (.github/workflows/sweep.yml:253, 9caa0704d744)

Likely related people:

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • After merge, run the three stated live canaries and keep any replay of previously parked work separately authorized.

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 (2 earlier review cycles)
  • reviewed 2026-07-27T08:06:30.265Z sha cf01495 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-27T08:11:18.226Z sha cf01495 :: needs real behavior proof before merge. :: none

@brokemac79 brokemac79 changed the title fix(queue): preserve empty issue target branches fix(queue): preserve empty legacy target branches Jul 27, 2026
@brokemac79

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. 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. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 27, 2026
@clawsweeper

clawsweeper Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(queue): preserve empty legacy target branches This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@brokemac79
brokemac79 merged commit 183b44c into main Jul 27, 2026
23 checks passed
@brokemac79
brokemac79 deleted the codex/fix-issue-target-branch branch July 27, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. P1 Urgent regression or broken agent/channel workflow affecting real users now. proof: sufficient Contributor real behavior proof is sufficient. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant