Skip to content

refactor(repair): consolidate duplicated helpers - #1114

Merged
steipete merged 8 commits into
mainfrom
steipete/repair-duplication-merges
Aug 11, 2026
Merged

steipete merged 8 commits into
mainfrom
steipete/repair-duplication-merges

Conversation

@steipete

@steipete steipete commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Four repair-side behaviors had drift-prone duplicate implementations: merge notifications bypassed the shared OpenClaw hook client, two Gitcrawl importers independently resolved the same store paths, two publication paths independently hashed the same error detail, and three command-ack paths independently parsed and ranked the same markers.

Why This Change Was Made

This makes each behavior have one owner while retaining the caller-specific wire contracts and limits.

  1. notify-merge now uses the shared OpenClaw hook client already used by the three sibling notifiers. This intentionally changes transient-failure behavior from one-shot delivery to the shared retry policy. Every retry uses the same existing merge idempotency key.
  2. Both repair Gitcrawl importers now use gitcrawl-store.ts; their intentionally different sqliteJson buffer limits remain local and unchanged.
  3. Both error-fingerprint formats share one SHA-256 digest primitive while preserving the bare-hex batch contract and sha256:-prefixed event contract byte-for-byte.
  4. Command-ack marker parsing, status scoring, ordering, and tie-breaking now live in command-ack-convergence.ts, consumed by all three prior owners with byte-identical behavior.

No compatibility shim or old duplicate path remains. CHANGELOG.md and dashboard/ are untouched.

User Impact

There is no user-visible behavior change except that the standalone merge notifier now retries transient OpenClaw hook failures using the same idempotency key, matching the existing sibling notifier behavior.

Real Behavior Proof

Claim: each consolidation preserves its prior observable result, except for the explicitly intended merge-notifier retry adoption.

Exercised surface: the old built merge-notifier CLI and current production notifier function over native loopback HTTP, both built Gitcrawl importer CLIs over real on-disk SQLite stores, error-fingerprint wire formatting, and command-ack convergence.

Scenario and observable result:

  • Merge notifier old control: the complete origin/main tree is built and its production dist/repair/notify-merge.js runs with normal hook environment configuration. A real server bound to 127.0.0.1:<ephemeral> receives one POST at 2026-08-11T01:08:59.863Z, returns HTTP 503, and the old process records one failed delivery and exits 1 under --strict.
  • Merge notifier current path: the built runMergeNotifier function invoked by the CLI runs with the same arguments and normal hook environment configuration. The same real listener receives POST attempt 1 at 2026-08-11T01:08:59.881Z and returns 503, then receives attempt 2 at 2026-08-11T01:09:00.887Z and returns 200. Both socket requests carry merge:openclaw/openclaw#123:merge_canonical:abc123 in the idempotency-key header and JSON body. The notifier report records one sent delivery and the process exits 0.
  • Gitcrawl portable store: both old resolver copies, the shared resolver, and both built importer CLIs select $FIXTURE_ROOT/gitcrawl-store/data/openclaw__openclaw.sync.db; both importers exit 0 and read the portable-store marker from that real SQLite file.
  • Gitcrawl legacy fallback: with the portable store absent, all resolvers and both importer CLIs select $FIXTURE_ROOT/home/.config/gitcrawl/gitcrawl.db; both importers exit 0 and read the legacy-fallback marker.
  • Gitcrawl environment override: with competing portable and legacy files present, all resolvers and both importer CLIs select $FIXTURE_ROOT/override/configured.db; both importers exit 0 and read the env-override marker.
  • Error fingerprints and command acknowledgements: the existing extracted-old-versus-shared-helper harnesses remain byte-identical across their committed cases.

Commands:

pnpm run build:all
node docs/proof/repair-duplication-merges/merge-1/run-proof.mjs
node docs/proof/repair-duplication-merges/merge-2/run-proof.mjs
node docs/proof/repair-duplication-merges/merge-3/run-proof.mjs
node docs/proof/repair-duplication-merges/merge-4/run-proof.mjs
pnpm run format:check
pnpm run test:no-build

Local proof on Node 24.19.0 exited PROOF_RC=0. The full no-build suite reported 3,307 tests: 3,298 passed, 9 skipped, 0 failed. format:check passed.

Docker-backed proof used Crabbox 0.41.1, provider=local-container, lease cbx_5b0de8cbba98 (silver-barnacle-695f), image node:24-bookworm, Docker 29.4.0, and a clean --fresh-pr openclaw/clawsweeper#1114 --no-hydrate checkout at e94c0fbfe043545bebae5c3bf11fb961ef98a72a. Corepack installed pinned pnpm 11.10.0. jq 1.8.1 was checksum-verified before use. All four proof scripts exited PROOF_RC=0; build:all and format:check passed. The lease stopped automatically. Final head 48009d55171e6ebee4c3212a9f55bc1db55189dc adds only the committed README and machine-readable container provenance for that run.

Artifacts, source-extraction hashes, real socket timestamps/statuses, normalized resolved paths, real SQLite hashes, importer path traces, and machine-readable Crabbox provenance are committed under docs/proof/repair-duplication-merges/.

Limits: the proof is deterministic and credential-free. The HTTP endpoint is a loopback-only listener with a disposable token. SQLite fixtures are disposable local files queried by the real importer entry points through a node:sqlite-backed CLI adapter. No live OpenClaw, Discord, GitHub mutation, workflow, queue, or production service is exercised. The current container run did not repeat the full suite because that gate passed locally with zero failures; therefore the three previously known container blob-hydration failures did not need a new baseline run.

Validation

  • build:all: passed locally and in Docker-backed Crabbox
  • all four committed proof scripts: PROOF_RC=0 locally and in Docker-backed Crabbox
  • test:no-build: passed locally — 3,307 tests, 3,298 passed, 9 skipped, 0 failed
  • format:check: passed locally and in Docker-backed Crabbox
  • pre-commit structured review: clean, no accepted/actionable findings
  • provenance-only follow-up review: clean, no accepted/actionable findings

OpenClaw Bay

No impact. These changes do not alter lifecycle/review publication, queue/workflow ownership, status/telemetry contracts, or dashboard data. Bay remains observer-only and requires no update.

@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 11, 2026
@clawsweeper

clawsweeper Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 10, 2026, 9:22 PM ET / August 11, 2026, 01:22 UTC.

ClawSweeper review

What this changes

This PR centralizes duplicated repair-side hook posting, Gitcrawl store resolution, error fingerprinting, and command-acknowledgement selection while retaining their caller-specific formats and limits.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open: current main still has the duplicated repair paths, while this PR consolidates them with a verified shared-hook retry adoption and sufficient real-boundary proof. No actionable patch defect was found.

Priority: P3
Reviewed head: 48009d55171e6ebee4c3212a9f55bc1db55189dc

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong real-boundary proof supports a focused, behavior-preserving internal refactor with no actionable review finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): Committed Docker-backed Crabbox provenance and real loopback HTTP/SQLite traces show after-fix recovery and equivalent importer results; the final commit did not alter production or test code.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): Committed Docker-backed Crabbox provenance and real loopback HTTP/SQLite traces show after-fix recovery and equivalent importer results; the final commit did not alter production or test code.
Evidence reviewed 5 items Current main still needs the work: The affected repair paths are unchanged between the PR base and current main; main still calls its standalone merge-hook sender and retains the duplicated importer and command-ack helpers.
Shared hook contract: The PR routes merge notifications through the existing shared hook client, whose retry loop preserves the supplied idempotency key across attempts.
Real behavior proof: The committed trace records the old notifier failing once on a real loopback HTTP 503 and the new path succeeding after a 503 then 200, with the same header and body idempotency key on both attempts.
Findings None None.
Security None None.

How this fits together

Repair automation imports Gitcrawl context, processes command acknowledgements, and sends merge notifications through an OpenClaw hook before recording results. The shared helpers here sit beneath those command and notification entry points and determine their delivery, storage-selection, and duplicate-comment behavior.

flowchart LR
  A[GitHub and Gitcrawl inputs] --> B[Repair commands]
  B --> C[Shared repair helpers]
  C --> D[Hook notifications]
  C --> E[Gitcrawl imports]
  C --> F[Command acknowledgements]
  D --> G[Repair records]
  E --> G
  F --> G
Loading

Before merge

  • Resolve merge risk (P1) - Merging intentionally changes transient hook failures from one attempt to up to three attempts; downstream handling continues to rely on the existing stable idempotency key to avoid duplicate delivery.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production versus test delta production +172/-302, tests +125/-14 The repair implementation becomes smaller while focused coverage is added for the extracted helper contracts.
Proof material 14 proof files added; 29 files affected Most of the change is reproducible real-boundary evidence rather than production expansion.

Merge-risk options

Maintainer options:

  1. Retain the shared retry contract (recommended)
    Accept the bounded retry behavior because the same idempotency key is retained and the real loopback trace shows recovery after a transient failure.

Technical review

Best possible solution:

Land the consolidation with the shared hook retry contract, preserving the stable idempotency key and the existing caller-specific fingerprint and importer contracts.

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

Not applicable as a bug report; the PR supplies a high-confidence after-fix real-boundary scenario for the intentional notifier retry behavior and real SQLite importer paths.

Is this the best way to solve the issue?

Yes. Reusing the already-established hook client and extracting byte-preserving helper contracts is the narrowest maintainable way to remove the identified repair-side duplication.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. Committed Docker-backed Crabbox provenance and real loopback HTTP/SQLite traces show after-fix recovery and equivalent importer results; the final commit did not alter production or test code.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): Committed Docker-backed Crabbox provenance and real loopback HTTP/SQLite traces show after-fix recovery and equivalent importer results; the final commit did not alter production or test code.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P3: This is a bounded internal repair refactor with no reported end-user regression.
  • merge-risk: 🚨 automation: The merge notifier intentionally adopts retry behavior for transient hook failures, changing repair automation delivery timing and attempt count.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): Committed Docker-backed Crabbox provenance and real loopback HTTP/SQLite traces show after-fix recovery and equivalent importer results; the final commit did not alter production or test code.
  • proof: sufficient: Contributor real behavior proof is sufficient. Committed Docker-backed Crabbox provenance and real loopback HTTP/SQLite traces show after-fix recovery and equivalent importer results; the final commit did not alter production or test code.

Evidence

What I checked:

Likely related people:

  • Dwin Gharibi: Current-main blame attributes the shared hook retry loop and adjacent command-status behavior to this repair-area commit. (role: recent repair-area contributor; confidence: high; commits: 9725dabfeba0; files: src/repair/openclaw-hook.ts, src/repair/comment-router-core.ts)
  • steipete: History identifies prior OpenClaw hook-intake work by Peter Steinberger, and the current PR extends that existing shared-hook contract. (role: historical hook-notification contributor; confidence: medium; commits: 180cabab8bef; files: src/repair/notify-merge.ts, src/repair/openclaw-hook.ts)
  • Vincent Koc: History identifies the portable Gitcrawl-cluster support change that established the importer path-resolution area consolidated here. (role: Gitcrawl importer contributor; confidence: medium; commits: 6a0a32c8754d; files: src/repair/import-gitcrawl-clusters.ts, src/repair/import-gitcrawl-low-signal-prs.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 (2 earlier review cycles)
  • reviewed 2026-08-11T00:27:09.609Z sha 1b53811 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-11T00:36:20.475Z sha 05365b7 :: needs real behavior proof before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Current head and PR body now contain the requested real-boundary proof: native loopback HTTP 503→200 retry evidence with stable idempotency identity, old one-shot contrast, real SQLite store fixtures through both importer CLIs, and Docker-backed Crabbox provenance.

@clawsweeper

clawsweeper Bot commented Aug 11, 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 status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 11, 2026
@steipete
steipete merged commit 1ee5843 into main Aug 11, 2026
21 checks passed
@steipete
steipete deleted the steipete/repair-duplication-merges branch August 11, 2026 01:26
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. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. 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