Skip to content

perf(logging): reuse prepared diagnostic facts - #133659

Merged
steipete merged 1 commit into
mainfrom
codex/perf-diagnostic-preparation
Aug 31, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/perf-diagnostic-preparation

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Diagnostic bookkeeping repeated work even when its owner already had the needed facts: an exact session key/id match still scanned all states, bounded labels formatted strings that were discarded, and model/run handlers copied every owner registration before looking for a match.

This keeps preparation at the existing owners. Exact canonical identity hits reuse the direct lookup; changed-id and alias paths retain the existing merge flow. Label construction moves behind the five-label cap, while every activity lookup still runs in the original order because it reconciles aliases. Owner checks iterate the authoritative Map directly, and run completion still requires the exact run id as well as activity identity. There is no new cache, index, configuration, public API, protocol, storage, or authorization policy. The old formatting helper and temporary owner arrays are removed.

These are three measured mechanisms. Production is +33/−32 lines (net +1); tests are unchanged. The final production ASTs match the measured proposals after formatting. The one-line increase retains an explicit canonical-identity invariant and ordinary loops compatible with the repository's TypeScript target.

All 130 existing diagnostic, activity, core model-request, loop-admission, and command-poll tests passed on baseline and candidate. Full pnpm check:changed passed, including production/test typechecks, lint, Knip, database guards and zero runtime import cycles. Independent source review and managed review found no actionable defects. The first baseline invocation named a nonexistent test path; that failed invocation is retained separately from the corrected successful run.

The saved complete-owner differential corpus passed 1,208 scenarios and 4,832 comparisons, plus 180,000 producer-invariant checks. A reviewer-requested supplement adds 24 shared-owner/alias scenarios and 96 comparisons, covering different run ids sharing one activity, exact-owner closure and later completion. Existing shared-activity completion behavior is preserved; this does not claim to repair broader completion cleanup.

Ten fresh forward/reverse timing processes cover 73 fixed workloads, 6,570 raw samples and 730 independently recomputed medians. At 64/512 states, a last exact identity lookup drops from roughly 0.34/2.67 µs to 0.015 µs by avoiding the scan. ID-only lookup retains its existing scan. Larger bounded-label snapshots take roughly 9–17% less elapsed time; owner event processing improves at 64/512 registrations. All empty, small, ID-only and completion-miss costs remain in the evidence rather than being omitted.

Measurements cover the complete local state, snapshot and event owners with declared unrelated configuration/logger/runtime boundaries, not whole-Gateway, live-provider, heartbeat, recovery or memory performance. Current-main source checks find the same relevant owners and dependencies; the only broad manifest drift is the already-reviewed fast-uri lockfile update, which is outside this compiled graph. Existing documentation and operator-visible behavior remain unchanged.

@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Aug 31, 2026
@steipete
steipete marked this pull request as ready for review August 31, 2026 00:22
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 8:27 PM ET / August 31, 2026, 00:27 UTC.

ClawSweeper review

What this changes

The PR removes avoidable diagnostic bookkeeping by reusing direct session matches, delaying bounded-label formatting, and iterating registered owners without temporary arrays.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open. The three introduced optimizations preserve the diagnostic alias, owner-identity, and exact-run checks; no blocking correctness or security defect was found. This fresh maintainer-owned PR still contributes behavior-neutral performance work not present on current main.

Priority: P3
Reviewed head: de77a68d7e00aa41c28ad500af19def3052e87dd

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A small, focused implementation whose source-level invariants match the existing diagnostic lifecycle coverage.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-owned PR changes internal diagnostic bookkeeping and has no user-visible chat or UI behavior requiring the external-contributor proof gate.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-owned PR changes internal diagnostic bookkeeping and has no user-visible chat or UI behavior requiring the external-contributor proof gate.
Evidence reviewed 7 items Introduced owner-loop change: The introduced helper iterates the authoritative owner map and preserves object-identity matching before model lifecycle handling.
Alias invariant retained: A direct entry bypasses the ID scan only when it already has the same session ID; differing or absent IDs still follow the existing alias merge path.
Bounded-label ordering retained: Activity lookup still occurs before the five-label cap, so its alias reconciliation side effect remains in the original loop order while discarded string formatting is avoided.
Findings None None.
Security None None.

How this fits together

Diagnostic logging receives session and run lifecycle events and maintains process-local activity state for liveness warnings and stuck-session recovery. The changed code turns that state into bounded operator-facing work labels while retaining owner and alias reconciliation.

flowchart LR
  A[Session and run events] --> B[Diagnostic activity owner]
  A --> C[Session state registry]
  B --> D[Activity snapshot]
  C --> E[Diagnostic snapshot builder]
  D --> E
  E --> F[Bounded labels and counts]
  F --> G[Liveness and recovery diagnostics]
Loading

Before merge

  • Complete next step (P2) - No discrete repair is needed; this fresh maintainer-owned PR should proceed through ordinary exact-head review and merge gates.
Agent review details

Security

None.

PR surface

Source +1. Total +1 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 3 33 32 +1
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 33 32 +1

Review metrics

Metric Value Why it matters
Production versus test delta production +33/−32 (net +1); tests unchanged The small production increase is the local identity/ordering documentation while the patch removes temporary arrays and discarded formatting.

Technical review

Best possible solution:

Retain the direct-owner and bounded-formatting optimizations, with the existing alias and shared-owner lifecycle coverage guarding semantic equivalence.

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

Not applicable: this PR optimizes internal diagnostic bookkeeping rather than reporting a user-facing failure; source and existing tests expose the relevant state transitions.

Is this the best way to solve the issue?

Yes. The patch removes repeated temporary work at the owning diagnostic paths while preserving the existing alias reconciliation and exact-owner/run predicates.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a bounded internal diagnostic-performance optimization with no changed public configuration or user-visible workflow.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-owned PR changes internal diagnostic bookkeeping and has no user-visible chat or UI behavior requiring the external-contributor proof gate.

Label justifications:

  • P3: This is a bounded internal diagnostic-performance optimization with no changed public configuration or user-visible workflow.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-owned PR changes internal diagnostic bookkeeping and has no user-visible chat or UI behavior requiring the external-contributor proof gate.

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)

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.

@steipete
steipete merged commit 4b50773 into main Aug 31, 2026
309 checks passed
@steipete
steipete deleted the codex/perf-diagnostic-preparation branch August 31, 2026 00:44
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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