Skip to content

fix(workers): keep idle GC diagnostics within the worker import budget - #198894

Open
RomneyDa wants to merge 1 commit into
mainfrom
fix/worker-idle-gc-lazy-logging
Open

RomneyDa wants to merge 1 commit into
mainfrom
fix/worker-idle-gc-lazy-logging

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Related: #197510

Status — November 14, 2026

Superseded by the equivalent canonical repair #198895, merged at d43de8d733674c942c8eb7bfb7333a30de4f910f on November 14 at 14:10 UTC. Source inspection confirms the same dedicated lazy-logging boundary and preserved warning fields; its reported fresh-build census is 203/220. This parallel PR should not be merged or rebased merely to duplicate that fix. It remains open pending maintainer disposition; no closure or merge is performed here.

Hosted review found no actionable code defects. The hosted check-test-types failure is in unchanged scripts/perf/state-read-worker-bench.ts:373: TS18048, optional tasksCompleted; it is separate from this three-file patch. The branch is now conflicted with the canonical repair.

What Problem This Solves

Fixes: small-worker CI exceeds its module budget when idle garbage collection eagerly loads the full logging subsystem. This inherited failure blocks validation of #197510 and other PR merge trees.

User Impact

No intended user-visible change. Slow worker GC still emits the existing console/file warning with the same threshold, subsystem, and diagnostic fields; logging loads only when a slow collection needs it. No configuration or migration is required.

Why This Change Was Made

Move the warning into a dedicated lazy module, preserving the current error handling. The regression mock retains real exports and waits for the asynchronous warning. Neither the import budget nor the mock baseline is raised. This repair is kept separate from #197510’s writer-reentrancy fix because the regression was inherited from main (#198857), not introduced by that PR.

Evidence

  • Exact failing base c787d0fac8265bfb54f9d1dd05a3eb55298c487b: 240 evaluated modules versus the 220 budget; repaired tree: 203. The hosted merge reported 245; these are separately pinned measurements.
  • Native build (declarations disabled) passed; focused typecheck and typed lint, including declaration preparation, passed.
  • Worker GC and worker-task-server suites: 11 tests passed. Mock-export ratchet and formatting passed.
  • Local autoreview (OpenClaw engine, openai/gpt-6.1-sol, P0–P2) found no actionable issues in the complete three-file candidate.
  • Integrated onto pinned main 9161e20e2c4c085ee4fd60bb8243b9c14bb7d38b to resolve a conflict with an added mock-exemption comment. All three repaired files are byte-identical to the reviewed candidate; the obsolete exemption is removed. Integrated native build passed (declarations disabled), and the worker census remains 203 ≤ 220.
  • This does not establish fix: reduce Gateway stalls under filesystem pressure #197510’s integrated Linux/btrfs, Doctor/upgrade, or performance qualification. No merge or backport requested.

Keep the slow-GC warning behind a dedicated lazy module so small workers stay within the import budget. Preserve real logging exports in the regression mock and await the asynchronous warning.

Co-authored-by: RomneyDa <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 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.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 14, 2026
@clawsweeper

clawsweeper Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR defers slow worker garbage-collection logging imports to preserve the existing worker module budget.

Example: The built identity-file worker starts without performing a slow collection.

  • Before: The reported module census is 240, exceeding the budget of 220.
  • After: The reported census is 203, with logging loaded only for collections lasting at least 1,000 ms.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused, coherent repair with reported production-worker measurements, but superseded on main and currently conflicted; failed typecheck attribution remains unavailable.
Proof confidence 🦐 gold shrimp (3/6) This internal import-boundary repair has no intended user-visible behavior change; its body reports built-worker census and focused regression results.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: No · Fix scope: Complete
User problem: Worker import-budget failures block build validation.
Reason: The repair was useful, but merging a second implementation now offers no distinct demonstrated benefit.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR addresses a real regression already repaired on main by #198895; maintainer authorship requires explicit maintainer judgment before closure.

Priority: P3
Reviewed head: bf423677342c2af918d47fdf7dc3488f048781ff
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should this maintainer-authored PR be closed as superseded by fix(workers): load idle GC diagnostics lazily #198895?
  • Recommendation: Close as superseded: Keep the merged main implementation, credit this parallel repair, and avoid resolving a redundant branch.
  • Why: The central repair is merged, but the maintainer-authorship guard prevents automatic closure.

Before merge

  • Product: not worth merging - The repair was useful, but merging a second implementation now offers no distinct demonstrated benefit.

Findings

None.

Agent review details

How this fits together

Worker task and SQLite owners schedule idle garbage collection; the shared collector samples memory and sends slow-collection diagnostics to subsystem logging.

flowchart TD
  A[Worker task owners] --> B[Idle GC scheduler]
  B --> C[Worker garbage collection]
  C --> D[Slow collection threshold]
  D --> E[Lazy logging module]
  E --> F[Console and file diagnostics]
Loading

Technical review

Best possible solution:

Retain the merged lazy-report implementation on main and obtain maintainer agreement to retire this superseded PR.

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

The original source eagerly imports subsystem logging into shared worker startup, and both repair discussions report 240 modules against the 220 budget; no target code was executed during this review.

Is this the best way to solve the issue?

A dedicated lazy module is justified by the bundler boundary and preserves the diagnostic contract, but main already contains that solution.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against d43de8d73367; fix evidence: commit d43de8d73367, main fix timestamp 2026-11-14T14:10:50Z.

Provenance checked

  • Slow idle-GC logging keeps the original intent (1b3e37b: Identify long worker pauses using timing, thread identity, and before/after memory diagnostics.)
  • Logging mock export preservation changes intended behavior with a stated reason (9161e20: The base retained an annotated isolation mock; this PR preserves real exports while continuing to intercept warnings.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Dallin Romney: Raw commit 35d2e97 adds src/infra/worker-idle-gc.ts:15 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 35d2e97a4af7; files: src/infra/worker-idle-gc.ts)

PR surface

Source +12, Tests +4. Total +16 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 23 11 +12
Tests 1 14 10 +4
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 37 21 +16

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Root-cause cluster

Relationship: superseded
Canonical: #198895
Summary: Both repairs remove the logging graph eagerly introduced into shared worker startup.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: The import-budget regression is repaired on main; the remaining action is maintainer cleanup of a parallel PR.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 14, 2026, 9:18 AM ET / 14:18 UTC.

This branch has not been deployed

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

Labels

P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant