Repository navigation
perf(gateway): retain agent and session boot filesystem facts - #170467
Conversation
|
🦞👀 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. |
Security-sensitive guard clearedCurrent revision: This PR no longer changes files in the maintainer security-review tier. Separate CODEOWNERS requirements still apply to security policy and enforcement files. |
|
Codex review: needs changes before merge. What this changesThis PR retains filesystem facts in Gateway owners and refreshes them through write publications and shared directory observations. Example: A dashboard client requests talk.catalog with six synthetic agents and 120 auth profiles per agent.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 3 items remain Keep this PR open: the measured performance improvement is useful, but destination migration admission and scoped teardown still have blocking defects. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherGateway boot RPCs consume agent, auth, workspace, and session facts derived from filesystem paths and SQLite owners; committed writes and directory observations update those retained facts. flowchart TD
A[Dashboard RPCs] --> B[Gateway readers]
B --> C[Retained owner facts]
C --> D[SQLite read workers]
E[Owner write publications] --> C
F[Directory observations] --> C
D --> G[RPC responses]
Technical reviewBest possible solution: Retain cached discovery while checking migration readiness at credential effects and retiring observations only for their closing owner. Do we have a high-confidence way to reproduce the issue? Both findings have concrete source paths: restore a legacy file after cached absence before a credential write, or close root B while root A retains an auth reader or session-source preparation; no target code was executed. Is this the best way to solve the issue? Caching in existing owners fits the measured problem, and persisted-source separation addresses the earlier baseline concern; effect admission and scoped cleanup must preserve their existing contracts. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f7d7425192bd. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +1235, Tests +1424, Other +2. Total +2661 across 48 files. Added test files: 6. View PR surface stats
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 (2 earlier review cycles)
Reviewed October 12, 2026, 11:52 PM ET / October 13, 2026, 03:52 UTC (Revision 3). |
956b67a to
102a035
Compare
102a035 to
1bfcd0a
Compare
1bfcd0a to
97fb85f
Compare
a095ea4 to
510ac80
Compare
510ac80 to
a7a8c72
Compare
#170467 (3ac0c05) intentionally retains agent directory observations with one coarse fallback. The utility-only browser handoff first registers that observer while fake timers are active, so runAllTimersAsync drains its recurring maintenance interval until the 10000-timer guard aborts. Fake only Date and timeout methods used by handoff polling. Keep every custodian route, bootstrap, presence, deadline, and failure assertion; production preparation, directory maintenance, and onboarding are unchanged. Proof: before 1/15 fails with the hourly timer error; after 27/27 handoff and sibling cases pass (17.75s wrapper). Commands types, targeted lint, boundary guards, formatting, and independent P2 review pass. The tsdown js-extension regression also passes on main containing 18e4969.
PR #170826 intentionally permits captured or fallback pricing to survive plugin cache retirement until the next config or restart. Assert every log record and its estimated cost on that path; retain the typed rejection when the database admission is revoked. PR #170467 introduced process-owned directory observation with a shared 30-second fallback interval. Prepare agent directory facts before the fixture installs its refresh clock. Keep every zero-timer, backoff, scope drain and cancellation assertion. Before: two failures across these files on main. After: all 14 cases pass through pnpm test with --maxWorkers=1 (29.89s wrapper, 15.74s Vitest). Targeted infra test types, typed and boundary lint, formatting, and independent review through P2 pass. Production behavior is unchanged.
…170842) Second half of the Gateway process-owned file state work (first half #170467): auth-profile file identity, persisted rows, runtime snapshots and secrets facts are held by their owners, updated write-through, and invalidated by directory observation for external writers (CLI, Doctor, manual edits). Readers capture the database file identity; assertCurrent() rejects stale authority when the observed identity changed. Per-request fs calls: talk.catalog 56/40/26 -> 4/0/0 existence/stat/realpath (with #170467). Security review: Peter (admin and SecOps) signed off 2026-10-13. Admin-merged over the inherited server.config-patch agents.create 10 s timeout, which reproduces on the exact main base under CI's two-CPU budget (main 66/67, head 67/67; evidence in the PR body).
openclaw#170467 (d2aac29) intentionally retains agent directory observations with one coarse fallback. The utility-only browser handoff first registers that observer while fake timers are active, so runAllTimersAsync drains its recurring maintenance interval until the 10000-timer guard aborts. Fake only Date and timeout methods used by handoff polling. Keep every custodian route, bootstrap, presence, deadline, and failure assertion; production preparation, directory maintenance, and onboarding are unchanged. Proof: before 1/15 fails with the hourly timer error; after 27/27 handoff and sibling cases pass (17.75s wrapper). Commands types, targeted lint, boundary guards, formatting, and independent P2 review pass. The tsdown js-extension regression also passes on main containing ab0bbfc.
PR openclaw#170826 intentionally permits captured or fallback pricing to survive plugin cache retirement until the next config or restart. Assert every log record and its estimated cost on that path; retain the typed rejection when the database admission is revoked. PR openclaw#170467 introduced process-owned directory observation with a shared 30-second fallback interval. Prepare agent directory facts before the fixture installs its refresh clock. Keep every zero-timer, backoff, scope drain and cancellation assertion. Before: two failures across these files on main. After: all 14 cases pass through pnpm test with --maxWorkers=1 (29.89s wrapper, 15.74s Vitest). Targeted infra test types, typed and boundary lint, formatting, and independent review through P2 pass. Production behavior is unchanged.
…penclaw#170842) Second half of the Gateway process-owned file state work (first half openclaw#170467): auth-profile file identity, persisted rows, runtime snapshots and secrets facts are held by their owners, updated write-through, and invalidated by directory observation for external writers (CLI, Doctor, manual edits). Readers capture the database file identity; assertCurrent() rejects stale authority when the observed identity changed. Per-request fs calls: talk.catalog 56/40/26 -> 4/0/0 existence/stat/realpath (with openclaw#170467). Security review: Peter (admin and SecOps) signed off 2026-10-13. Admin-merged over the inherited server.config-patch agents.create 10 s timeout, which reproduces on the exact main base under CI's two-CPU budget (main 66/67, head 67/67; evidence in the PR body).
What Problem This Solves
A signed-in reload of a dashboard deep link passed through 14 visible states over roughly 15 seconds in the campaign evidence. Gateway boot RPCs repeatedly prepared agent paths, workspace Git display facts, session sources, and database identity. After the Talk fix, filesystem callbacks accounted for roughly 735 inclusive samples.
Change
PR A of the split requested by the campaign lead. Retain those process-owned facts in their existing owners. Shared directory observation provides external invalidation and one coarse fallback. The generic observer has no auth-specific behavior. Auth-profile and secret changes are in stacked PR #170842; this PR has zero security-review-policy matches.
Database proof survives native-handle close. A newly admitted history lane checks physical identity before capturing its request receipt; warm lanes use retained facts. Captured receipts remain fixed through queued work. Receiver admission and privileged writes keep their current physical checks and post-await authority revalidation, rejecting swapped files even before watcher delivery.
Delete repeated request preparation and the duplicate Git discovery implementation. Simplify the registry reconciliation callback and workspace observer closure. No schema, protocol, durability, configuration-option or UI source changes.
Evidence
Candidate
a7a8c725268aafc3b8f90bb7ef5264c2d6e3e7d1, based on main27aef9ac6a0231b9fa494905a79361b30097fe67. Fresh independent review: no actionable P0–P2 findings.Focused source-mode one-file tests (
pnpm exec vitest run --config <owner> <file> --maxWorkers=1):Synthetic fixture: six agents/workspaces, 120 auth profiles per agent, 300 sessions, 240 transcript messages and one widget, with plugins disabled. Main
27aef9ac6a02and this exact candidate each completed 225 counted and 900 profiled RPCs with zero errors, using identical synthetic fixture paths.Synchronous existence / stat / native-realpath API calls per RPC:
talk.catalogchat.startupagents.listmodels.authStatus,models.listtools.catalogboard.getTalk's remaining auth filesystem calls belong to PR B. Board admission and shared Gateway lease guards remain direct. Async log-file operations inheriting RPC traces are excluded from the owned-fact claim. No private captures or real state were used; both scratch Gateways shut down cleanly.
Main-thread samples are noisy on this loaded Mac; inclusive categories overlap. Total samples 4,261 → 2,586; filesystem 1,688 → 524; agent registry 342 → 5; SQLite identity 591 → 292; session-source preparation 391 → 4. CPU across threads 4,607 → 3,527 ms and burst wall time 3,454 → 2,998 ms do not establish an end-to-end reload improvement.
Exact-head CI run 38366281729 completed green: 63 jobs passed, 25 skipped, zero failures, including the Gateway/agents checks CI selected. AWS Crabbox
cbx_045d3624cf3euploaded source but refused hydration because it could not verify the Actions workspace Git root/origin; no test payload ran. That guard was preserved. CI resolved the broad-proof uncertainty, so remote setup was stopped.Size and release context
Production delta +502 LOC: 568 additions / 66 deletions across 11 production/inventory paths, using the campaign's exclusion filter. Growth implements bounded retained projections, shared external invalidation and admission-time replacement checks. The superseded request-time paths and duplicate Git scan are removed.
Release-note context: reduce redundant Gateway filesystem work during Control UI boot without weakening database authority. No changelog edit. This PR is ready for review; the campaign lead lands it. Do not auto-merge.