Skip to content

fix(hooks): avoid blocking CLI during relay lookup - #148102

Merged
steipete merged 3 commits into
mainfrom
codex/native-hook-locator-worker
Sep 14, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/native-hook-locator-worker

Conversation

@steipete

@steipete steipete commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes blocking SQLite reads on the native-hook CLI thread when locating a registered relay, even though the lookup already returns a Promise.

User Impact

Cold CLI locator reads execute on a worker while preserving command output, loopback authentication, schema admission, retries, and deadlines. No configuration or data migration is required.

Why This Change Was Made

The cold CLI uses the existing worker transport for its read-only lookup and joins the worker before consuming its result. The worker shares the query and row decoder with the existing relay store and stays outside shared-state writer startup. Native error serialization is extracted from its existing owner, with canonical schema-error hydration retained at the caller. Standalone runtime entries are bundled independently.

Data-model compatibility: the read-only worker retains the schema-version guard, uses the same locator SELECT, and consumes the unchanged row decoder. No table, column, stored row, or schema version changes. The extracted error schema describes an existing in-memory response shape, not stored data. The source links establish that no migration is introduced; the existing runtime review also resolved this compatibility concern without patch or security findings. Maintainer disposition of Revision 5: its data-model checkbox is inapplicable because the tagged caller and worker preserve the stored format and all admission/decoding contracts, as that review itself confirms. No migration or schema change is required.

Evidence

  • The original real CLI control completed the expected authenticated loopback request but detected host SQLite calls: prepare 5, exec 1, get 4, iterate 1. The corrected flow passes with all six counters zero, including all and run.
  • All five locator/CLI/import-boundary cases pass on the current composition. The 25 unchanged build-configuration cases also passed with the qualified worker/dependency inputs; they verify schema-inlining ownership and independent standalone reader output.
  • The generated dedicated CLI completed the same synthetic loopback flow with exact output and zero host SQLite calls. This is local boundary proof, not a live provider run.
  • The full production build, complete changed-file gate, and generated CLI proof passed after the shared worker-loader and fs-safe 0.11 update. That evidence is retained: all 17 reviewed PR files are unchanged, and the latest main intersection only adds an unused named filesystem-helper re-export. The five current cases verify module evaluation and the actual compiled-worker flow. Independent P2 review remains clean.
  • The additional probe-test follow-up passes both approved injected-fetch classification cases, its scoped changed gate, and fresh P2 review. It uses the existing preload boundary to provide a native HTTP-500 Response while retaining the actual probe subprocess/parser/status logic, all three assertions, and the 300 ms/default/outer deadlines. No original timeout cause or deterministic-red claim is made.
  • The branch includes the shared fixture and routing fixes from fix(ci): restore the ClawHub plugin sweep check #148129, fix(workboard): lifecycle timer test races with database reads #148221, test(discord): await the mark after clearing playback #148268, test(wizard): run inference recovery with shared-state broker #148353, and test: route provider integration and wizard recovery tests correctly #148504. The actual composed catalog contains the wizard recovery fixture exactly once among 72 unique entries, included by infra/forks and excluded by Wizard. Earlier checkout failures and duplicate-route preflight failures remain separate outcomes; required current-head CI still gates merging.

Focused command: node scripts/run-vitest.mjs src/cli/native-hook-relay-cli.locator-worker.test.ts src/cli/native-hook-relay-cli.import-boundary.test.ts test/scripts/tsdown-runtime-config.test.ts.

Gateway-side relay persistence remains with its existing owners and is outside this cold locator read change.

@clawsweeper

clawsweeper Bot commented Sep 14, 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 docs Improvements or additions to documentation cli CLI command changes scripts Repository scripts agents Agent runtime and tooling extensions: codex size: M labels Sep 14, 2026
@steipete
steipete marked this pull request as ready for review September 14, 2026 08:44
@openclaw-barnacle openclaw-barnacle Bot added the maintainer Maintainer-authored PR label Sep 14, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 14, 2026, 5:36 PM ET / 21:36 UTC (Revision 7).

ClawSweeper review

What this changes

Moves native-hook CLI database lookups into a dedicated worker, shares existing query and error handling, and updates worker packaging and regression coverage.

Merge readiness

⛔ Blocked before merge - 1 item remains

The fix remains necessary on current main, and no actionable patch defect was found. The previous migration blocker is inapplicable: the patch preserves the stored format, schema admission, and decoding semantics.

Priority: P2
Reviewed head: 6b256304e5a2f9b6c7d42df697fa88b0fe948bdf

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with relevant runtime observations, regression coverage, and no actionable correctness findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied before/after CLI observations and generated-CLI run exercise the changed locator owner through real SQLite, worker execution, and authenticated loopback HTTP, preserving exact output while reducing host SQLite calls to zero; this proves the local boundary without claiming a live Codex run.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied before/after CLI observations and generated-CLI run exercise the changed locator owner through real SQLite, worker execution, and authenticated loopback HTTP, preserving exact output while reducing host SQLite calls to zero; this proves the local boundary without claiming a live Codex run.
Evidence reviewed 9 items Current main still performs synchronous SQLite work: The fetched main implementation opens, queries, and closes SQLite directly inside an async function; returning a Promise does not move those operations off the caller thread.
Latest release also uses a caller-thread lookup: The v2026.9.4 source uses a synchronous locator function with the same SQLite operations, so the latest supplied release does not contain this worker repair.
Worker lifecycle and preserved storage contract: The worker retains readOnly opening, busy timeout, schema admission, and the existing row decoder, then closes its database before replying. The caller awaits pool.close() before returning. The shared SELECT is unchanged in meaning; the extracted error schema represents an in-memory response, not durable data.
Findings None None.
Security None None.

How this fits together

The native-hook CLI receives hook arguments and input, reads a stored locator, and sends an authenticated request to the local relay. This change moves the database read off the CLI thread while preserving the existing response and fallback paths.

flowchart TD
 A[Hook arguments and input] --> B[Native-hook CLI]
 B --> C[Read-only locator worker]
 C --> D[State database]
 D --> E[Schema check and row decoding]
 E --> F[Close database and join worker]
 F --> G[Authenticated local relay]
 G --> H[CLI output]
 B --> H
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +89, Tests +127, Docs +5, Other +5. Total +226 across 17 files.

View PR surface stats
Area Files Added Removed Net
Source 8 150 61 +89
Tests 4 206 79 +127
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 4 23 18 +5
Total 17 384 158 +226

Review metrics

Metric Value Why it matters
Production versus test growth Production/tooling net +94 lines; tests net +127 lines The production growth has a concrete purpose: isolated worker execution, shared error/query handling, and independently packaged reader entrypoints.

Stored data model

Persistent data-model change detected: database schema: src/agents/harness/native-hook-relay-client-store.ts, database schema: src/agents/harness/native-hook-relay-client.worker.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep one shared locator query and decoder, execute the cold read off-thread, and preserve existing admission, cleanup, deadlines, and fallback behavior.

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

Yes, from source: current main executes synchronous SQLite operations on the CLI thread, and the supplied before/after CLI evidence measures those calls. This read-only review did not rerun the scenario.

Is this the best way to solve the issue?

Yes. Reusing the worker transport and existing query/decoder removes caller-thread SQLite work without introducing a competing storage owner or changing persistent contracts.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded CLI responsiveness fix for native-hook locator reads.
  • 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 (live_output): The supplied before/after CLI observations and generated-CLI run exercise the changed locator owner through real SQLite, worker execution, and authenticated loopback HTTP, preserving exact output while reducing host SQLite calls to zero; this proves the local boundary without claiming a live Codex run.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied before/after CLI observations and generated-CLI run exercise the changed locator owner through real SQLite, worker execution, and authenticated loopback HTTP, preserving exact output while reducing host SQLite calls to zero; this proves the local boundary without claiming a live Codex run.

Evidence

What I checked:

  • Current main still performs synchronous SQLite work: The fetched main implementation opens, queries, and closes SQLite directly inside an async function; returning a Promise does not move those operations off the caller thread. (src/agents/harness/native-hook-relay-client-store.ts:20, eb38ff8353dd)
  • Latest release also uses a caller-thread lookup: The v2026.9.4 source uses a synchronous locator function with the same SQLite operations, so the latest supplied release does not contain this worker repair. (src/agents/harness/native-hook-relay-client-store.ts:20, 3a9d69db306c)
  • Worker lifecycle and preserved storage contract: The worker retains readOnly opening, busy timeout, schema admission, and the existing row decoder, then closes its database before replying. The caller awaits pool.close() before returning. The shared SELECT is unchanged in meaning; the extracted error schema represents an in-memory response, not durable data. (src/agents/harness/native-hook-relay-client.worker.ts:23, 6b256304e5a2)
  • Previous migration concern resolved: The storage review checkpoint expressly excludes read-only queries that preserve existing semantics. Source inspection supports the PR body's disposition of the earlier migration checkbox; no migration, schema change, or additional product decision is necessary. Public docs: docs/reference/database-schemas/storage-changes.md. (docs/reference/database-schemas/storage-changes.md:412, 6b256304e5a2)
  • Behavior proof matches the changed boundary: The supplied PR body reports a real CLI control with host SQLite counts prepare=5, exec=1, get=4, iterate=1, followed by zero calls across all six counters after the fix. It also records generated-CLI execution with exact output and authenticated synthetic loopback delivery. The inspected regression exercises the CLI entrypoint, real database, worker, and HTTP client. This supports the local lookup claim without claiming live-provider coverage; no target code was executed during this review. (src/cli/native-hook-relay-cli.locator-worker.test.ts:15, 6b256304e5a2)
  • Packaging and error-classification coverage: Production and test builds emit each standalone reader independently, preserving schema inlining and existing dependency ownership. The probe follow-up retains the real subprocess/parser, HTTP-500 assertion, absence-of-output assertion, and existing deadlines while using the established injected-fetch boundary. (test/scripts/tsdown-runtime-config.test.ts:185, 6b256304e5a2)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • jalehman: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: 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 2026-09-14T09:10:31.032Z sha 2834fc7 :: blocked before merge. :: none
  • reviewed 2026-09-14T11:36:39.324Z sha 6b099d0 :: blocked before merge. :: none
  • reviewed 2026-09-14T12:25:35.121Z sha d5088db :: needs maintainer review before merge. :: none
  • reviewed 2026-09-14T17:55:24.447Z sha c3caa9d :: needs maintainer review before merge. :: none
  • reviewed 2026-09-14T21:14:30.962Z sha 6b25630 :: blocked before merge. :: none
  • reviewed 2026-09-14T21:26:22.148Z sha 6b25630 :: blocked before merge. :: none

@steipete
steipete force-pushed the codex/native-hook-locator-worker branch from 2834fc7 to 6b099d0 Compare September 14, 2026 11:17
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Please refresh the review for 6b099d084b1ce256c3ec209390e4afa43a584fb1. The build-configuration test correction is included, and the branch includes the shared Docker fixture repair. The PR body now links the unchanged locator query, row decoder, and retained read-only schema admission to clarify that no stored data model or migration changes are introduced.

@clawsweeper

clawsweeper Bot commented Sep 14, 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 exact_review_queue).
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 the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 14, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Please refresh for d5088db4436d8e9508a5cdc17f8317511afd1f77. The only follow-up since the reviewed head is one probe test using its existing injected-fetch/native Response boundary. It retains the actual probe subprocess/parser/status logic, the strict HTTP-500 diagnostic and other assertions, and all existing deadlines. Both injected classification cases, scoped checks, and independent review pass. All 16 previously reviewed files are byte-identical; the stored-data compatibility disposition remains unchanged. No original timeout cause is claimed.

@clawsweeper

clawsweeper Bot commented Sep 14, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The branch now includes the merged fixture prerequisites from main. The current PR body records the preserved locator behavior and deadlines, 30 focused tests, the full build and changed gate, generated CLI proof with zero host SQLite calls, and fresh independent review.

@clawsweeper

clawsweeper Bot commented Sep 14, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete
steipete force-pushed the codex/native-hook-locator-worker branch from c3caa9d to 6b25630 Compare September 14, 2026 21:07
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The branch now includes the verified main routing repair. The current body records exactly one canonical wizard recovery route, five fresh locator/import cases, preserved deadlines, and the retained build/static/generated-CLI proof for unchanged locator inputs. All 17 reviewed PR files are unchanged.

@clawsweeper

clawsweeper Bot commented Sep 14, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit b51a3ad into main Sep 14, 2026
197 of 198 checks passed
@steipete
steipete deleted the codex/native-hook-locator-worker branch September 14, 2026 21:53
@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 15, 2026
* fix(hooks): avoid blocking CLI during relay lookup

* test(hooks): cover standalone locator build graph

* test(e2e): isolate server-error probe classification
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes docs Improvements or additions to documentation extensions: codex maintainer Maintainer-authored PR 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. scripts Repository scripts size: L 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