Repository navigation
fix(logging): identify sampled work beneath stall callers - #188474
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. |
Codex Review SummaryThis 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 adds bounded sampled-leaf and stack-tail attribution to stall reports and skips handle inventories before any restricted schema admission. Example: A 1.2-second PBKDF2 block appears beneath more than eight shared callers.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it adds useful diagnostic attribution absent from current main, has maintainer-approved direction, and introduces no definite correctness or security defect found in this review. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Gateway event-loop monitor passes a captured stall interval to the native CPU-profile recorder, which selects matching samples, sanitizes frames, and returns a warning payload; the shared-state schema owner separately controls restricted-handle admission. flowchart TD
A[Gateway event-loop monitor] --> B[Captured stall interval]
B --> C[Native profile recorder]
C --> D[Shared frame sanitizer]
D --> E[Bounded attribution report]
E --> F[Gateway warning log]
Technical reviewBest possible solution: Keep attribution in the existing bounded recorder and retain the schema owner's permanent post-admission checks. Do we have a high-confidence way to reproduce the issue? Current-main source caps inclusive output at eight entries, so shared ancestors can hide sampled leaves; the added fixture directly constructs this case, and the body reports it failing on the base. Is this the best way to solve the issue? The change reuses the recorder, sanitizer, interval selection, and schema-admission owner; bounded leaf aggregation addresses the diagnostic gap without weakening the remaining synchronous authority checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1d6f75fd7450. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +87, Tests +75, Docs +16, Other +36. Total +214 across 6 files. Added test files: 0. View PR surface stats
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 Reviewed October 30, 2026, 11:51 AM ET / 15:51 UTC. |
…88474) Report sampled leaf time, nearest OpenClaw callers, and hot stack tails within a hard 2 KiB stall-profile payload cap. Preserve sanitization and distinguish report-budget truncation from native sampling truncation. Skip schema-handle inventory scans before the first restricted admission while preserving expired-scope rejection and all subsequent restricted-handle checks. Proof: red/green attribution and work-count regressions, 80 focused tests passed, real Node 26 native attribution proof, and exact-head PR CI. The broader synchronous source/effect-boundary migration remains separate; this does not claim to identify or eliminate the original long stall.
What Problem This Solves
Main-thread stall profiles can stop at eight shared inclusive callers, hiding the sampled work beneath them and making a multi-second stall impossible to attribute.
User Impact
Operators can see sampled leaf work, its nearest OpenClaw caller, and hot stack tails in one bounded stall report. No configuration or schema changes are required. This does not claim to have identified or removed the cause of the previously observed long stall.
Why This Change Was Made
The recorder now reports up to ten self-time entries and three deepest stack tails, preserving sanitized locations and complete JSON within a hard 2 KiB payload cap. Native sampling truncation and report-budget truncation remain separate. It aggregates samples by leaf before walking ancestry, avoiding repeated traversal of identical stacks.
The source audit also found an unnecessary schema-handle inventory scan in the lifecycle deletion guard. The schema owner now records whether any restricted handle has ever been admitted: before that point there is nothing to scan. Expired scopes still reject first; after any restricted admission the existing checks remain permanently enabled, including alias and failed-cleanup handling.
Evidence
node --import ./scripts/tsx.mjs scripts/perf/main-thread-stall-measure.mjs flight. A 1.2-second crypto block produced a 984-byte report with 42 samples, identifying the native leaf,pbkdf2Sync, and its OpenClaw caller. Later unrelatedscryptSyncwork was excluded. This runs the real native profiler independently of the skipped Vitest case.Source coverage and remaining synchronous work
#188386 moved existing-state worker-read source probes to asynchronous preparation. It covers the initial deletion-journal read used during handoff preparation; it does not remove every synchronous callback in repeated
assertOwnerCurrent/assertEffectCurrentchecks.The lifecycle deletion guard consumes prepared committed journal facts (or transaction-local facts). The composed run assertion itself only invokes its source and operator owners. Those owners can still reach synchronous database-identity probes in
session-delivery-generation.tsand prepared session-entry sources, revision-triggered reads of native transaction-local session generations, and opaque SDK callbacks. Configured-agent/source/policy collections are also traversed. An opaque callback can perform arbitrary synchronous SQLite or filesystem work, so the old inclusive chain cannot identify which of these caused the stall.These remaining checks have not been weakened or represented as off-thread. Moving them safely requires changing the owning effect boundary: the filesystem dependency currently requires synchronous final-mutation callbacks, and raw native transaction checks must observe uncommitted state. Earlier asynchronous preparation alone would leave a replacement/revocation gap. Leaf attribution is the missing evidence for selecting the next concrete owner change.
Owner measurement
Used the existing committed
state-db-cache-admission-measure.tson a synthetic 10,000-row fixture (8 KiB payload per row), with five serial counterbalanced base/candidate launches, 5,000 retained lease resolutions per arm, and separate untraced timing and sampled-allocation passes. Startup and fixture writes were excluded. One-minute host load ranged from 26.81 to 30.46.CPU pairs had mixed signs (base range 1,076.69–1,335.81 ms; candidate 830.41–1,554.17 ms), so timing is inconclusive context, not a claimed speedup. This is a small allocation/work-count improvement, not a measurement of the original stall. Command per arm:
node --expose-gc --import ./scripts/tsx.mjs scripts/perf/state-db-cache-admission-measure.ts --state-dir <owned-synthetic-fixture> --payload-kib 8 --iterations 5000 --rounds 1.Runtime production delta is +87 lines: +81 for the explicitly requested bounded attribution capability and +6 for the owner-held admission fact. Existing benchmark script +36, tests +75, docs +16. No new modules, exports, budget increases, or competing source-authority owner.