Repository navigation
fix(gateway): avoid filesystem stalls during catalog refresh - #200136
Conversation
Delete redundant catalog sidecar locking and order credential candidate reads through canonical writer admission. Move audited config, identity, installer, skill and session metadata operations to asynchronous filesystem APIs while preserving their ownership and settlement rules. Extend the existing main-thread filesystem guards and add a production-shaped synthetic catalog benchmark with native lock-create fault injection. Preserve disclosed spill paths during prompt projection without probing temporary files.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
|
Codex review: needs maintainer review before merge. What this changesThis PR removes catalog sidecar locking and converts audited runtime filesystem operations to asynchronous APIs. Example: Catalog publication encounters an injected 2,000 ms native lock-create delay.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Both earlier findings are resolved, and no new actionable code or security defect was found. This maintainer-authored PR remains useful; exact-head CI is still pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway catalog refresh publishes provider models through the agent database worker; credential cleanup joins the same writer queues before inspecting persisted catalogs. flowchart TD
A[Catalog refresh] --> B[Agent writer admission]
C[Credential removal] --> D[Ordered candidate inspection]
D --> B
B --> E[Catalog worker transaction]
E --> F[Persisted model catalogs]
F --> G[Model registry readers]
Technical reviewBest possible solution: Use the existing database writer admission for catalog ordering and asynchronous filesystem APIs for the audited metadata operations. Do we have a high-confidence way to reproduce the issue? Current-main source retains the implicated lock path, and the supplied native fault-injection results reproduce its event-loop stall; no target code was executed during this review. Is this the best way to solve the issue? Removing redundant locking at the existing writer owner addresses the cause while preserving credential cleanup ordering, and the accompanying asynchronous conversions retain their existing owners and contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b9d11df14f80. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -9, Tests +170, Docs +10, Other +314. Total +485 across 59 files. Added test files: 0. View PR surface stats
Preflight sourceSource 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
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 16, 2026, 10:15 AM ET / 15:15 UTC (Revision 2). |
Migrate peer-link revocation and effect-admission fixtures to fs.promises while preserving authority assertions. Intercept the native addon selected by fs-safe in the catalog benchmark instead of the global module loader.
|
Addressed both open items at
A fresh scoped Codex autoreview is clean through P2. The changed-file check passes its applicable gates except the two previously documented exact-parent dead exports introduced by #200056. New-head CI remains required. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash auto-merge.
|
…tgres-compaction-watched-prompt-20261116 * commit '9e810f7101557b006d5ff223d955f14dc43329f0': (23 commits) chore(ui): refresh control ui locales (#200164) fix(update): stop reporting unset git config keys as failing checks (#200153) test: consolidate redundant coverage (198793, part 2) (#198936) revert: skills-used full-transcript scan on every chat history page (#200159) refactor(sessions): follow the chat by key for stored delivery references (#200099) fix(update): bridge 2026.11.5-beta.4 updaters (#200152) fix(gateway): avoid filesystem stalls during catalog refresh (#200136) fix(ci): match update refusal probe to selected candidate (#200043) fix(agents): keep read-only steering carriers when publishing suppressed user envelopes (#200156) test: consolidate suites while retaining recovery owners (#198933) test: consolidate redundant coverage (198789, part 2) (#198932) refactor(cli): consolidate camera command tests (#200144) fix(cli): avoid initializing provider runtime during cleanup (#200139) fix(ui): show mobile destinations without the drawer exit delay (#198879) chore(ui): refresh control ui locales (#200146) fix(knowledge): keep historical claims distinct and reject changed retries (#200140) fix(ui): align dropdown arrows on mobile New Session improve(sessions): archive inactive transcripts by default (#199899) refactor(agents): own background commands and yield waits by the chat (#200097) fix(models): guessed non-chat models leave the default picker instead of being refused (#200102) ...
…w#200136) * fix(gateway): avoid filesystem stalls during catalog refresh Delete redundant catalog sidecar locking and order credential candidate reads through canonical writer admission. Move audited config, identity, installer, skill and session metadata operations to asynchronous filesystem APIs while preserving their ownership and settlement rules. Extend the existing main-thread filesystem guards and add a production-shaped synthetic catalog benchmark with native lock-create fault injection. Preserve disclosed spill paths during prompt projection without probing temporary files. * test(gateway): observe asynchronous metadata effects Migrate peer-link revocation and effect-admission fixtures to fs.promises while preserving authority assertions. Intercept the native addon selected by fs-safe in the catalog benchmark instead of the global module loader.
Partial adaptation of 59d9759 (#200136). Move applicable catalog and filesystem preparation into existing owners, retaining current authority checks and immutable update inspection. INCOMPLETE: catalog zero-synchronous-I/O proof still fails at existing native execution/admission descriptor checks. Session path containment also retains synchronous predecessor owner operations. Do not treat this local draft as a completed release pick or publish it without resolving the recorded gaps in remaining-pass-results.json. Co-authored-by: RomneyDa <[email protected]>
Continue #200136 on the release base with bounded async filesystem preparation and the existing containment policy. Preserve candidate ordering, cross-root fallback, and symlink revalidation. The existing zero-synchronous-I/O usage regression is now green; catalog admission remains incomplete. Co-authored-by: RomneyDa <[email protected]>
… reads Adapt #200136 through existing execution, writer, descriptor and clean-close seal owners. Preserve native identity fencing, live creation authority and synchronous service settlement. Co-authored-by: RomneyDa <[email protected]>
Follow up the release adaptations of #200136 (59d9759), #200192 (9323fb9), and #200222 (3f33eb9). Preserve validated worker fields across asynchronous admission; restore required imports, await diagnostics, and normalize the nullable path adapter. Parent review complete. Doctor regression failed before the repair; 17 parent tests across Doctor and attachment boundaries pass afterward. Seven-file scoped typed lint, format and whitespace checks pass. Worker session-path suite: 9 passed. Full release qualification remains pending. Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Fixes Gateway event-loop stalls when a filesystem transaction delays the catalog refresh sidecar lock or audited runtime metadata operations.
Production evidence: Team
25c97908, 2026-11-16 05:02 PST, showed the Gateway main thread in D-state for 1.97 seconds insideopenat2(O_CREAT)foropenclaw-agent.sqlite.plugin-model-catalog.lock. The kernel stack wasbtrfs_create → start_transaction → wait_current_trans;scheduler:update.remote-model-catalogrecorded a 2,002 ms event-loop stall while worktree removals drove a btrfs commit.User Impact
Catalog publication no longer creates that sidecar lock on the Gateway thread. Audited config, OpenClaw ID, installer, skill, cron and session-artifact paths use async filesystem operations or consume existing owner facts. Prompt reduction preserves disclosed output paths without probing temporary files; a later read reports an expired artifact.
This is a bounded repair stage, not a claim that every Gateway path is sync-free. General fs-safe locks, source-capture custody, timeline durability and managed update handoff require separate owner work. No schema, configuration or dependency change is included.
Why This Change Was Made
The catalog's async file-lock wrapper reached synchronous native filesystem operations. Its sidecar duplicated canonical database writer custody. Publications now use that existing writer; credential cleanup queues its candidate read behind earlier publications, then releases the read barrier before entering individual writers. Later publications retain transactional auth revalidation. Outside writers require exclusive offline custody.
The accompanying audit converts direct runtime metadata calls, preserves async key creation and launch/stop ordering, deletes redundant existence probes, and reuses async catalog identity and inspection-budget readers. Config startup also reuses its existing fingerprint instead of computing it again. Production delta: −9 lines; guards and reproducible proof tooling are separate.
Evidence
The synthetic fixture contains a 35.06 GiB agent database, 5,000 sessions and 62,000 workspace files totaling 1.10 GB. No production data was copied. Five interleaved baseline/candidate pairs and A/A controls used Node 26.12.1 on APFS. The fault targets the actual native catalog
openBeneath(O_CREAT)call; this is fault-injection evidence, not a btrfs kernel reproduction.Every process verified committed catalogs through a fresh reader. Allocation medians were 4.31 MB → 3.44 MB, but A/A variation was too large to claim a precise gain. An initial +0.37 ms undelayed heartbeat difference did not reproduce in a bounded 20-sample-per-arm followup; both series and CPU profiles are retained. Reproducer:
scripts/perf/catalog-publication-measure.mjs.Focused proof passed: 39 catalog tests, 47 model/prompt-prefix tests, 84 session/spill tests, 32 skill-install tests, 62 OpenClaw ID tests, and the audit batches of 58, 96 and 349 tests. The final reloader simplification passed all 146 reloader tests. Twenty existing native-iroh tests were skipped because that addon is unavailable locally. Regression guards fail on the exact parent for catalog publication, spill probes and the other reproduced mutation paths.
Codex local autoreview is scoped-clean through P2 for the main change against parent
6670297776a00and the subsequent four-file CI repair at225aaebe7329c.pnpm check:changedand the scoped repair rerun pass the applicable type, lint, format and boundary checks except two proven parent dead-export failures:ProjectedContinuationSourceandpartContinuation. A clean exact-parent run reproduces both; their exports were introduced by24385a20428a3/ #200056. These are recorded main regressions, not ignored noise. No guard baseline was changed.Initial CI at
dc75193ca69fdfound stale synchronous fault hooks in three peer-link consumer suites and unregistered benchmark lint suppressions. The repair preserves all authority assertions, passes all seven affected cases under pinned Bun and all 14 suppression-guard tests, and replaces global module-loader interception with the native addon selected by fs-safe. A repeated native smoke still observes one delayed baseline create versus zero candidate creates.pnpm check:changed --base dc75193ca69fdpasses its applicable gates except the same two attributed parent dead exports.Exact-head CI and hosted ClawSweeper review are required before landing. No open ClawSweeper checklist item will be bypassed.