Skip to content

fix(channels): revalidate lane policy before claiming ingress - #159197

Merged
steipete merged 3 commits into
mainfrom
codex/ingress-live-lane-policy-20260926
Sep 27, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/ingress-live-lane-policy-20260926

Conversation

@steipete

@steipete steipete commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes queued messages being claimed under stale channel lane policy when that policy changes while a claim waits for its SQLite transaction or commit.

User Impact

Queued messages respect current lane eligibility before becoming durable claims. Existing installations need no schema migration, configuration change, or operator action; retention and SDK contracts stay unchanged.

Why This Change Was Made

The existing native admission owner rechecks the selector's ordered lane observations at transaction and commit. Native row fingerprinting still protects FIFO and database freshness, and callbacks receive freshly decoded inputs. Only a policy refusal with confirmed native rollback may prepare another claim; callback failures, retired authority, and uncertain native outcomes remain terminal.

Evidence

  • Negative controls on 19c6ef8d9e02 claimed the stale first row after policy changes at both native admission stages. Callback failure and owner-retirement controls also incorrectly committed. The candidate passes all 80 distinct tests across the claim, queue/FIFO, drain-lane, admission-receipt, and cleanup owners.
  • pnpm test src/channels/message/ingress-queue.claim-ownership.test.ts --maxWorkers=1: 12 passed, 36.912 s wall, including 18.664 s worker preparation; Vitest 13.43 s. The five new cases cost 792 ms (transaction), 622 ms (commit), 631 ms (callback failure), 638 ms (owner retirement), and 1,238 ms (lost native rollback reply), 3.921 s combined. The lost-reply case intercepts the actual private lifecycle reply, joins the executing worker, and verifies no claim replay.
  • Four sibling files: 68 passed, 37.148 s wall. Fresh isolated P0–P2 review is clean; formatting and diff checks pass. Initial CI found a test-only receiver alias lint violation; the replacement captures the same worker in a termination closure. The affected lost-reply case passes again (1.102 s case, 11.778 s wrapper), and both changed TypeScript files pass lint (21.423 s). The full changed-file gate passed in 1,455.765 s, including production typechecking, all 25 test typecheck groups, export scans, lint, formatting, and repository guards. The published review of the prior ingress head is clean; the later fixture repair received a fresh independent review. All 12 cases also passed in their completed hosted Node 24.19.0 shard. The five new cases took 400/390/399/396/752 ms (2.337 s combined); all 12 totaled 5.076 s of reported case time. Standalone file wall time is not exposed.

A synthetic 100-row queue with 56-KiB payloads measured 10.170 ms median main-thread CPU using process.threadCpuUsage over five claims after warmup. Retaining ordered observations avoided the 18.570 ms median of the initial full-rescan implementation while preserving both live policy checks. These were separate runs on a shared host; they do not establish a production latency gain. The temporary benchmark is outside the committed tests.

The prior hosted run failed in the existing server.private-completion.test.ts provider-failure case: a 120-second test timeout followed by 180-second cleanup timeouts. An unchanged replay of its Gateway group passed, but restoring the preceding packed groups reproduced the hang on Node 24.19.0; all 228 infra and 214 cron tests passed before the provider-failure case timed out at 300.336 s. The bounded run joined every owned descendant.

The shared Gateway fixture reseeding helper also cleared writer queues while accepted writes were still running. This change removes those two live clears and extends the existing connected-Gateway table with a reseed case. Its negative control rejects the second accepted write with SQLite session store queue cleared for test; the repaired 14-case suite passes (60.218 s wrapper, new case 1.000 s). Quiescent startup and teardown clears remain.

With the exact fixture repair and no phase instrumentation, the original three-group sequence now passes 50 files / 534 tests in 239.185 s, including the provider-failure case in 1.175 s. Source and dependency identities stayed fixed and all descendants joined. This strengthens the evidence but does not by itself establish the intermittent timeout's exact cause. Fresh P0–P2 repair review is clean; the owning Gateway type graph, exact-file lint, formatting, and diff checks pass on this combined candidate. Current-head hosted CI passed (131 successful / 20 skipped, no failed jobs). All 21 private-completion cases passed; the previously timing-out provider-failure case took 674 ms. The new reseed case's separate hosted timing was not available from the retained job output.

Full-file fixture wall comparison on Node 24.19.0, using the supported node scripts/run-vitest.mjs src/gateway/test-helpers.server-rpc.test.ts --maxWorkers=1 entry point: the original 13-case file passed in 113.096 s supervised wall (104.35 s Vitest); the repaired 14-case file passed in 60.218 s supervised wall (56.55 s Vitest), including the new 1.000 s case. Each used isolated compiler caches. These single-run timings document test cost, not a performance percentage; source restoration, dependency identity, and all descendant joins were verified.

@clawsweeper

clawsweeper Bot commented Sep 26, 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.

@steipete
steipete marked this pull request as ready for review September 26, 2026 21:44
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M labels Sep 26, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. labels Sep 26, 2026
@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 26, 2026, 10:15 PM ET / September 27, 2026, 02:15 UTC (Revision 7).

ClawSweeper review

What this changes

The branch rechecks channel lane policy before queued messages become durable SQLite claims, adds worker-backed regressions, and prevents Gateway fixture reseeding from clearing active session write queues.

Merge readiness

✅ Ready for maintainer review

Current main still has the reported stale-policy claim window. The branch has credible worker-backed proof, current-head CI passed, and this review found no actionable patch defect.

Priority: P2
Reviewed head: c37b693939381c76beeb10f6425e8bea762965e9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Worker-backed fault evidence and current-head CI support a focused repair with no established blocking defect.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The production ingress queue and real SQLite worker were exercised with policy changes injected at transaction and commit admission: the stale row remained pending and the eligible row was claimed; a lost-reply case observed no replay. A connected-Gateway fixture case observed queued session writes surviving reseed. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The production ingress queue and real SQLite worker were exercised with policy changes injected at transaction and commit admission: the stale row remained pending and the eligible row was claimed; a lost-reply case observed no replay. A connected-Gateway fixture case observed queued session writes surviving reseed. No stored-data contract changes.
Evidence reviewed 8 items Current-main behavior: Current main selects a lane before awaiting the claim worker and has no lane-policy recheck at transaction or commit admission.
Pinned introduced change: The introduced hunk checks live lane observations at both native admission stages and retries a policy refusal only when native settlement reports completion.
Worker commit boundary: The production worker requests transaction and commit grants inside its synchronous write transaction, allowing the host policy check to refuse before commit.
Findings None None.
Security None None.

How this fits together

Channel plugins put inbound events in a durable queue. The Gateway selects a lane, asks a SQLite worker to claim an event, then dispatches the claim; a separate Gateway test fixture seeds session rows through their writer queue.

flowchart LR
  A[Inbound channel event] --> B[Durable queue]
  B --> C[Lane selection]
  C --> D[Worker admission]
  D --> E[Live policy check]
  E --> F[Durable claim]
  F --> G[Channel dispatch]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +38, Tests +225, Docs +2. Total +265 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 79 41 +38
Tests 2 228 3 +225
Docs 1 4 2 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 311 46 +265

Review metrics

Metric Value Why it matters
Net code growth production +40 lines; tests +225 lines; fixture −2 lines Production growth is scoped to admission and settlement checks, while the test growth exercises native worker fault cases.
New claim-case time 5 cases: 3.921 s local, 2.337 s hosted The PR reports the added cases' cost because these tests run in recurring CI.

Technical review

Best possible solution:

Preserve live lane-policy checks within the existing worker admission path, with FIFO and uncertain-write custody intact, and keep fixture queue clearing confined to quiescent setup and teardown.

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

Yes. The current-main source retains the preclaim policy gap, and the PR reports failing native-stage controls on that baseline; this read-only review did not execute them.

Is this the best way to solve the issue?

Yes. Rechecking the channel-owned lane decision at the existing worker admission boundary is a narrow repair that leaves row freshness and claim settlement with their current owners.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded reliability repair for queued channel messages, with no demonstrated fleet-wide outage or emergency impact.
  • 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 (terminal): The production ingress queue and real SQLite worker were exercised with policy changes injected at transaction and commit admission: the stale row remained pending and the eligible row was claimed; a lost-reply case observed no replay. A connected-Gateway fixture case observed queued session writes surviving reseed. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The production ingress queue and real SQLite worker were exercised with policy changes injected at transaction and commit admission: the stale row remained pending and the eligible row was claimed; a lost-reply case observed no replay. A connected-Gateway fixture case observed queued session writes surviving reseed. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • jb510: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (6 earlier review cycles)
  • reviewed September 26, 2026, 5:58 PM ET / 21:58 UTC sha unknown :: needs maintainer review before merge. :: none
  • reviewed 2026-09-26T22:14:57.611Z sha 08172af :: needs maintainer review before merge. :: none
  • reviewed 2026-09-26T22:56:54.959Z sha 08172af :: needs maintainer review before merge. :: none
  • reviewed 2026-09-26T23:19:07.167Z sha 08172af :: needs maintainer review before merge. :: none
  • reviewed 2026-09-26T23:47:32.121Z sha 08172af :: needs maintainer review before merge. :: none
  • reviewed 2026-09-27T01:40:03.119Z sha c37b693 :: needs maintainer review before merge. :: none

@steipete
steipete enabled auto-merge (squash) September 26, 2026 22:27
@steipete
steipete disabled auto-merge September 27, 2026 01:02
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Sep 27, 2026
@steipete
steipete merged commit 271d915 into main Sep 27, 2026
217 checks passed
@steipete
steipete deleted the codex/ingress-live-lane-policy-20260926 branch September 27, 2026 02:16
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 27, 2026
…aw#159197)

* fix(channels): revalidate lane policy before claiming ingress

* test(channels): retain claim worker termination directly

* test(gateway): preserve queued writes while reseeding fixtures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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