Skip to content

fix(tooling): bound compiler profiling memory and lifetime - #160096

Open
vincentkoc wants to merge 3 commits into
mainfrom
fix/semantic-profiler-memory
Open

vincentkoc wants to merge 3 commits into
mainfrom
fix/semantic-profiler-memory

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Related: #160010
Depends on: #160094

What Problem This Solves

Compiler profiling retained large output buffers while launching another unbounded compiler process.

User Impact

Every compiler phase uses shared host admission and kernel process-tree containment. File inventories and explanations stream to disk with the previous 256 MiB per-stream allowance and only a 64 KiB diagnostic tail in memory. Ordinary diagnostics have a 16 MiB combined capture limit. Reports publish only after all selected phases and cleanup succeed.

Platform decision pending: this implementation requires verified Linux kernel containment and refuses native macOS/Windows execution before launching a compiler. A complete bounded remote/VM profiler workflow, including retrieval of generated artifacts, still needs qualification from those hosts and explicit acceptance of the compatibility change. General lint/compiler activation remains in subsequent slices; this PR is held until that decision and proof are resolved.

Why This Change Was Made

The profiler owns phase execution and capture. It now reuses canonical admission, managed-process, and artifact owners, keeps cancellation active through cleanup, completes short file writes, attempts both descriptor closes, and preserves uncertain child ownership through cleanup errors. Synchronous compiler launches and retained raw phase-result objects are removed.

Evidence

Current head: c7768510d67b0b1f2f128efa41fefe1937721069, patch-identically rebased onto 40019980f2687648942b0788fb8523fef58ff7ff after #160187 landed. All three commits compare identically with their reviewed versions. Prior focused process/static proof is retained. Exact-head hosted CI is green, including the aggregate gate. Exact-head ClawSweeper review found no source defect and blocks merge on the non-Linux compatibility decision and qualified alternative described above.

Exact source 83a06a8968cdab79ca09a218026fe02df71a6595 on Blacksmith Testbox, verified 3,681-input SHA256 manifest ba472d34aec5176db3ca1ce64aa6ec90ddc89e1f9f09f31acf740650c157540b:

  • All nine real-process cases passed with one worker: forced termination, supervisor death/retained admission, success, child failure, diagnostic overflow, 256 MiB artifact overflow, million-row inventory, partial file writes, and combined unjoined-child/close failures. File test time 4.247s; Vitest wall 4.72s; complete command 5.45 CI wall seconds excluding shared setup.
  • Script typecheck, targeted typed lint for implementation and tests, formatting, and whitespace passed in a separate 1m57.825s command. A prior lint rule caught a throw inside finally; errors now propagate after cleanup instead.
  • The first static command encountered an artifact lock left by a different capped proof in this task. Its exact kernel scope had been OOM-killed and removed; owner and recorded child were absent and the task compiler census was empty before releasing that lock. No profiler test was retried for that infrastructure cleanup.
  • Independent P0–P2 review is clean. Earlier baseline proof is also linked; the current source and command results above supersede it.

Production/tooling +228/-90, tests +420/-0, docs +36/-0. Growth owns asynchronous bounded capture, streaming artifacts, and cleanup; no dependency changes. No matched runtime speedup is claimed by this entrypoint repair.

@vincentkoc vincentkoc self-assigned this Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 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.

@vincentkoc
vincentkoc marked this pull request as ready for review September 28, 2026 04:14
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: L labels Sep 28, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 28, 2026, 7:23 AM ET / 11:23 UTC (Revision 7).

ClawSweeper review

What this changes

The branch runs TypeScript compiler profiling through shared memory admission, streams large file inventories and explanations to artifacts, adds process tests, and documents the bounded workflow.

Merge readiness

⛔ Blocked before merge - 5 items remain

Keep this PR open. The bounded Linux profiler addresses a real source-level problem, but the branch disables an existing macOS and Windows workflow without a qualified way to retrieve remote reports or explicit acceptance of that compatibility change. The prior request to expose helper status 75 does not match the profiler CLI's existing exit-status behavior.

Priority: P2
Reviewed head: c7768510d67b0b1f2f128efa41fefe1937721069
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused process evidence supports the Linux repair, while the unresolved platform break and incomplete remote instructions limit merge readiness.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The member-authored PR is exempt from contributor setup proof. Its body reports Linux Testbox cases through the production profiler entrypoint with real compiler processes and observed containment and cleanup, but no qualified macOS or Windows remote run returning artifacts. No stored-data contract changes.
Patch quality 🦐 gold shrimp (3/6) 2 actionable review findings remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The member-authored PR is exempt from contributor setup proof. Its body reports Linux Testbox cases through the production profiler entrypoint with real compiler processes and observed containment and cleanup, but no qualified macOS or Windows remote run returning artifacts. No stored-data contract changes.
Evidence reviewed 10 items Current main still uses the earlier profiler: Current main launches tsgo synchronously, retains stdout and stderr, and has no profiler-level process-tree memory admission; this PR's central repair is not on main.
Introduced containment path: Every compiler phase now calls the shared admission owner, whose non-Linux branch refuses launch.
Admission refusal contract: The shared helper returns 75 on unsupported platforms, while the profiler turns nonzero phase results into errors and its outer trailer exits 1. Current main's profiler also exits 1 on an error, so the earlier status-75 finding is not supported as a public CLI contract.
Findings 2 actionable findings [P1] Preserve a usable non-Linux profiling route
[P2] Include report retrieval in the remote profiling instructions
Security None None.

How this fits together

The compiler profiler is a developer CLI that launches TypeScript compiler phases for selected project graphs. It collects diagnostics and file lists, then writes local reports and optional trace artifacts.

flowchart LR
 A[Profiler command] --> B[Selected graphs]
 B --> C[Host admission]
 C --> D[Contained compiler phases]
 D --> E[Streamed artifacts]
 E --> F[Summary reports]
Loading

Decision needed

Question Recommendation
Should the profiler refuse native macOS and Windows execution before a bounded remote or VM workflow can return its generated artifacts? Qualify the replacement first: Keep the PR open until macOS and Windows runs prove bounded execution and artifact retrieval, then decide whether native refusal is acceptable.

Why: The PR intentionally changes an existing developer workflow, and source review cannot authorize that platform tradeoff.

Before merge

  • Preserve a usable non-Linux profiling route (P1) - Every compiler phase now passes through Linux-only admission, so the existing macOS and Windows profiler commands fail before starting tsgo. The suggested remote replacement has not been qualified with artifact retrieval. Preserve a working route or obtain explicit maintainer acceptance of the compatibility break before merge.
  • Include report retrieval in the remote profiling instructions (P2) - The new command runs in a remote workspace, but the generated inventory, explanation, and report files remain there. Add the actual retrieval step and verify the returned files; printing a summary is insufficient for a profiling workflow that produces artifacts.
  • Resolve merge risk (P1) - Existing macOS and Windows users will now get a profiler failure before any compiler starts. The proposed remote or VM replacement has not been qualified end to end with report retrieval, and no maintainer has accepted that compatibility change.
  • Complete next step (P2) - Qualify macOS and Windows remote or VM profiling with artifact retrieval, correct the documented workflow, and obtain explicit maintainer acceptance of any native refusal.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

  • [P1] Preserve a usable non-Linux profiling route — scripts/profile-tsgo.mts:183-189
  • [P2] Include report retrieval in the remote profiling instructions — docs/reference/test/local.md:338-340
Agent review details

Security

None.

PR surface

Tests +456, Other +138. Total +594 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 456 0 +456
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 228 90 +138
Total 3 684 90 +594

Review metrics

Metric Value Why it matters
Native platform behavior 2 existing native routes now refused macOS and Windows compatibility needs an explicit decision and a usable replacement.
Code and test growth production net +138 lines; tests +420 lines The production growth supports bounded capture and lifecycle cleanup; the PR reports a 5.45-second focused test command.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #160010
Summary: This PR is one profiler-specific candidate slice of the open compiler-memory issue; merged admission work supplies a prerequisite, while the CI repair is adjacent.

Members:

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

Merge-risk options

Maintainer options:

  1. Complete the cross-platform route (recommended)
    Add and demonstrate report retrieval from bounded Linux execution for macOS and Windows callers before merging the native refusal.
  2. Accept the platform break
    A responsible maintainer can explicitly accept Linux-only native profiling and the remaining operator impact.

Technical review

Best possible solution:

Keep the bounded Linux execution and provide a verified macOS and Windows remote or VM route that returns reports and optional artifacts before retiring native profiling.

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

Yes for the source-level mechanism: current main launches compiler phases synchronously and retains their output without process-tree memory admission. This read-only review did not run a memory-exhaustion workload.

Is this the best way to solve the issue?

Not yet. The Linux containment path is focused, but a qualified way to use and retrieve profiling artifacts from macOS and Windows is needed before replacing those native workflows.

Full review comments:

  • [P1] Preserve a usable non-Linux profiling route — scripts/profile-tsgo.mts:183-189
    Every compiler phase now passes through Linux-only admission, so the existing macOS and Windows profiler commands fail before starting tsgo. The suggested remote replacement has not been qualified with artifact retrieval. Preserve a working route or obtain explicit maintainer acceptance of the compatibility break before merge.
    Confidence: 0.94
  • [P2] Include report retrieval in the remote profiling instructions — docs/reference/test/local.md:338-340
    The new command runs in a remote workspace, but the generated inventory, explanation, and report files remain there. Add the actual retrieval step and verify the returned files; printing a summary is insufficient for a profiling workflow that produces artifacts.
    Confidence: 0.92

Overall correctness: patch is incorrect
Overall confidence: 0.89

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded developer-tooling repair with a concrete compatibility blocker, rather than an urgent user runtime outage.
  • merge-risk: 🚨 compatibility: The introduced Linux-only admission makes previously usable native macOS and Windows profiler commands fail.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The member-authored PR is exempt from contributor setup proof. Its body reports Linux Testbox cases through the production profiler entrypoint with real compiler processes and observed containment and cleanup, but no qualified macOS or Windows remote run returning artifacts. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit e07ec8c adds scripts/lib/semantic-check-admission.mts:16 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e07ec8c700d5; files: scripts/lib/semantic-check-admission.mts)
  • Jesse Merhi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Demonstrate a bounded profiler run from macOS and Windows that returns the report and requested artifacts.
  • Record the explicit platform decision and update the documented command to match the qualified workflow.

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.

History

Review history (6 earlier review cycles)
  • reviewed 2026-09-28T04:23:53.560Z sha 715700fda05ee92f6abcec287a3c1b3949cee917 :: blocked before merge. :: [P1] Preserve profiling on supported non-Linux hosts | [P1] Stream large file and explanation output to artifacts | [P3] Record the new process suite's measured cost
  • reviewed 2026-09-28T04:48:21.415Z sha 83a06a8968cdab79ca09a218026fe02df71a6595 :: blocked before merge. :: [P1] Preserve profiling on supported non-Linux hosts | [P3] Record the new process suite's measured cost
  • reviewed 2026-09-28T04:57:11.721Z sha 83a06a8968cdab79ca09a218026fe02df71a6595 :: needs changes before merge. :: none
  • reviewed 2026-09-28T05:43:06.090Z sha 0dc704c :: needs maintainer review before merge. :: none
  • reviewed 2026-09-28T08:39:51.553Z sha c776851 :: blocked before merge. :: none
  • reviewed 2026-09-28T10:39:44.640Z sha c776851 :: blocked before merge. :: [P2] Preserve the admission refusal exit status | [P2] Retrieve artifacts in the documented remote profiling flow

@vincentkoc
vincentkoc force-pushed the fix/semantic-profiler-memory branch from a739453 to 529c7e3 Compare September 28, 2026 04:39
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head 83a06a8968cdab79ca09a218026fe02df71a6595. Artifact phases preserve the previous 256 MiB per-stream allowance while streaming to disk. The body records the intentional kernel-containment policy and measured one-worker test cost, addressing the prior findings and Rank-up moves. All nine cases, script types, targeted typed lint, formatting, and whitespace pass on the linked Testbox. This PR will retarget main after its admission parent lands.

@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 28, 2026
Base automatically changed from fix/semantic-host-admission to main September 28, 2026 05:34
@vincentkoc
vincentkoc force-pushed the fix/semantic-profiler-memory branch from 83a06a8 to 0dc704c Compare September 28, 2026 05:35
@vincentkoc
vincentkoc force-pushed the fix/semantic-profiler-memory branch from 0dc704c to c776851 Compare September 28, 2026 08:32
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review current head c7768510d67b0b1f2f128efa41fefe1937721069. The CI qualification unblock #160187 is now merged; this branch was rebased onto that main revision with every patch unchanged (verified by range-diff). Prior focused proof and independent review remain applicable to the unchanged patch. Current-head hosted CI is running; the PR body distinguishes fresh and reused evidence.

@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 28, 2026
@clawsweeper clawsweeper Bot removed 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 Sep 28, 2026

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

docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant