Skip to content

fix(openclaw-id): publish membership changes that arrive while a publication finishes - #195261

Merged
jalehman merged 2 commits into
mainfrom
openclaw/ocid-publication-rerun
Nov 8, 2026
Merged

jalehman merged 2 commits into
mainfrom
openclaw/ocid-publication-rerun

Conversation

@jalehman

@jalehman jalehman commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Discovery publication can stop one membership change behind. If a change arrives while the previous successful publication is finishing, the newer snapshot is never published, and the Gateway can record that nothing is pending. Nothing retries it until the next periodic re-sign or a restart.

This unblocks #193980. In a real Gateway run for that PR, authority seq 5 committed, but the published snapshot was still at seq 4 with publish_pending: false after 90 seconds.

User Impact

An approved device or node can be missing from Discovery until a later refresh. A stale mirror blocks kit enrollment, because a new device signs at the mirror's seq + 1, and it also blocks relay admission. After this change, a change that arrives while a publication is finishing is published by the same loop.

Why This Change Was Made

After a successful publish, attemptOnce checked rerun and then awaited setPending(false). A request() arriving during that await records pending and joins the running loop by setting rerun. The check had already run, so the loop exited without publishing the newer state. The clear could also land after the new request's pending write, which left the durable flag false.

  • publication-retry.ts: after clearing pending, check rerun again. If a request arrived, mark pending again durably, so a crash cannot lose it, and run another attempt for the latest state. This is 5 lines, with no new retries, delays or state.
  • No other path needs the change. adopt and publishDirect never clear pending. start and resume go through the fixed loop. The retryable-failure path keeps pending and schedules a retry of the latest state.
  • Accepted edge case: a crash between the clear and the re-mark leaves publish_pending false for that short window. The published seq still lags the authority, so publicationPending still reports it and start republishes on boot.
  • Adds one regression test, synchronized with explicit promises (no sleeps or timers), plus a test-line allocation record for its 45 lines.

Evidence

Red/green for the new regression, republishes a request that arrives while a successful attempt clears pending:

main: FAIL  AssertionError: expected [ 1 ] to deeply equal [ 1, 2 ]
fix:  ✓ (11ms)

The test also asserts the order of durable pending writes: the stale clear [false, seq 1] is followed by a re-mark [true, seq 1], and pending ends [false, seq 2] only after the latest state is published.

The deterministic reproduction from the #193980 proof run, against the production createPublicationRetry:

main: {"currentSeq":2,"publishedSeqs":[1],"publishPending":false}
fix:  {"currentSeq":2,"publishedSeqs":[1,2],"publishPending":false}
  • node scripts/run-vitest.mjs run on the publication-retry, publisher and all service.* tests in src/gateway/openclaw-id/: 11 files, 79 tests passed.
  • pnpm tsgo:core and the gateway-other core test typecheck shard pass.
  • oxlint (core config) and the format check on the changed files pass, as do git diff --check and check-test-lines-ratchet --base origin/main.
  • Test cost: the regression takes 11 ms. publication-retry.test.ts with --maxWorkers=1 took 66 s wall time, 98% of it cold transform.
  • An independent review of the full diff found no runtime issues. Its one finding, a missing test-line allocation, is fixed here.
  • Gap: the original startup/mailbox overlap has not been replayed end to end in a real Gateway. That run did not record the exact live interleaving, so the evidence is the owner-level reproduction above.

@clawsweeper

clawsweeper Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Nov 8, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 8, 2026
@clawsweeper

clawsweeper Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR republishes membership changes requested while a successful Discovery publication clears its pending flag.

Example: Membership advances from seq 1 to seq 2 while publication of seq 1 clears pending.

  • Before: Discovery stays at seq 1 and publish_pending can become false.
  • After: The retry owner restores pending, publishes seq 2, then clears pending.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused patch appears correct, but supplied after-fix evidence stops at stubbed owner callbacks rather than the required Gateway behavior.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An accepted membership change can remain absent from Discovery, blocking subsequent enrollment and relay admission until refresh or recovery.
Reason: The maintainer-authored direction addresses a recorded failure with a narrow change to the existing publication owner and no new public contract.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR makes a focused repair to a publication failure still present on main; no introduced code defect was found.

Priority: P2
Reviewed head: e67015b42e90f84c2b09269a4a0eb0d35aeb1a8d

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The reported red/green regression does not show a real Gateway startup/mailbox overlap automatically publishing the newest membership through the production Discovery client.
Agent review details

How this fits together

The Gateway publication retry owner receives membership-change requests, invokes the existing signed Discovery publisher, and records publication progress through the durable membership authority.

flowchart LR
Membership[Membership changes] --> Authority[Gateway authority]
Authority --> Retry[Publication retry owner]
Retry --> Publisher[Signed snapshot publisher]
Publisher --> Discovery[Discovery mirror]
Retry --> Store[Durable pending flag]
Discovery --> Enrollment[Enrollment clients]
Loading

Technical review

Best possible solution:

Keep the repair in the existing publication retry owner, restoring pending before publishing the latest authority after an overlapping request.

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

The source exposes the missed-await window, and the body reports a red/green owner-level reproduction; the exact interleaving behind the original Gateway incident remains unrecorded, and this review executed no target code.

Is this the best way to solve the issue?

This is the smallest complete repair for the demonstrated window: reuse rerun and setPending in the existing owner, with one regression covering the previously missed settlement overlap.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 61093f1d32cb.

Provenance checked

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

Likely related people:

  • Josh Lehman: Raw commit 428ca7d adds src/gateway/openclaw-id/publication-retry.ts:168 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 428ca7daffc9; files: src/gateway/openclaw-id/publication-retry.ts)
  • Josh Avant: Raw commit 80795a8 adds src/gateway/openclaw-id/publication-retry.ts:147 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 80795a82a614; files: src/gateway/openclaw-id/publication-retry.ts)

PR surface

Source +5, Tests +45, Other +2. Total +52 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 5 0 +5
Tests 1 45 0 +45
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 3 52 0 +52

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus regression growth Production +5/-0 lines; tests +45/-0 lines The growth is justified by one deterministic overlap regression and a repair using existing state and persistence operations.

Root-cause cluster

Relationship: canonical
Canonical: #195261
Summary: This PR owns the narrow publication lost-request repair disclosed during accountless enrollment work.

Members:

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

Labels

Label changes:

  • add P2: Stale Discovery membership blocks enrollment and relay admission on the experimental OpenClaw ID surface, with limited current exposure.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Stale Discovery membership blocks enrollment and relay admission on the experimental OpenClaw ID surface, with limited current exposure.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 8, 2026, 10:04 AM ET / 15:04 UTC.

@jalehman
jalehman marked this pull request as ready for review November 8, 2026 15:38
@jalehman
jalehman merged commit dec19a6 into main Nov 8, 2026
210 of 212 checks passed
@jalehman
jalehman deleted the openclaw/ocid-publication-rerun branch November 8, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S 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