Skip to content

fix: source-host inspection exhausts the heap - #130

Merged
vincentkoc merged 1 commit into
mainfrom
fix/sdk-type-info-memory
Nov 4, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/sdk-type-info-memory

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes heap exhaustion during SDK usage analysis of large plugins against an OpenClaw source checkout.

User Impact

Source-host inspection completes the reproduced 59-fixture host corpus and the affected cold-process profile within the existing 2 GiB heap limit. Full report equivalence passed. JavaScript JSDoc typing and SDK findings remain intact.

Why This Change Was Made

The SDK type-program owner retained TypeScript documentation trees that inventory analysis does not consume. Use TypeScript's ParseForTypeInfo consistently across root, host, declaration, and cached source parsing. This preserves JavaScript JSDoc types and incoming compiler options without changing input coverage, module resolution, findings, timeouts, or heap limits.

Production delta: +15/-8 (net +7), implementing one parser contract across the existing paths. Tests: +79 lines. No dependency, package-version, release, or workflow changes.

Related: openclaw/crabpot#705

Evidence

  • Signed candidate 198c6d588ba427e58cfacbc50c19960c6cb05688, based on 89a3fedad864844a276ae52b4011b9c65d47fe12.
  • 25 focused tests passed on Node 24.22.1 with --max-old-space-size=2048: new JavaScript JSDoc inference and TypeScript/declaration inventory parity tests, plus existing host, cache-retention, and call-flow tests.
  • The original 59-fixture host corpus passed all six tests in 267.904 seconds, within its unchanged 600-second deadline. The preceding source revision exhausted the heap on the same prepared inputs. OpenClaw is frozen at de7e9c3e88cde66d5a68de8bdfc76707f13ba3b8.
  • Input provenance: reconstructed original ordered fixture/package identities from the original canary artifact and pinned Git inputs. The historical artifact did not retain tarball/content hashes, so this is not a claim of byte-identical historical package payloads.
  • Independent source/contract review and one fresh P0–P3 review passed. git diff --check passed.
  • The ordinary seven-producer report run passed in 266.107 seconds. All 59 ordered package identities and 2,372 source paths match the original completed report. Independent full-report comparison found exact equality after mapping nine verified target-checkout location fields; no finding, count, evidence, or ordering was excluded.
  • All hosted checks passed at the same candidate, including Node 22, Windows SDK entrypoints, CodeQL, Socket, and the publish-memory benchmark.
  • Fresh-process targeted API proof passed through the unchanged runtime-profile preparation and existing platform-probes descriptor: three real cold samples completed in 264.234, 271.374, and 270.988 seconds, each with exit 0, no signal, no timeout/cancellation, and the unchanged 600-second sample limit. Node 24.22.1 and the 2 GiB heap limit were preserved. The owner completed in 1,251.557 seconds; its group and all three sample groups were verified gone. This is targeted API proof, not the full CLI matrix; ordinary downstream CI remains separate.
  • Negative control: with only program.js restored to base 89a3feda, the new JavaScript JSDoc test failed its expected typed-documentation assertion; the other new test passed. The exact candidate source was restored and verified clean before smoke tests. Both new tests pass at the candidate as part of the 25-test run.
  • Crabpot source follow-through: the local four-file change for fix: source canaries exhaust the inspection heap crabpot#705 pins this exact candidate, updates the pin test and source identity documentation, and preserves the published package pin. The follow-through checker passed with --expected-ref 198c6d588ba427e58cfacbc50c19960c6cb05688; the two source-pin/default-smoke tests passed.
  • Crabpot source CLI smoke passed all 59 fixtures with zero breakages against this candidate. The separate published-package smoke also passed 59 fixtures with zero breakages. Registry identity was verified as @openclaw/plugin-inspector@0.4.5, Git head 8ec7d359fd78c96e723ce77eb5cffb3fec6703ee; this PR does not claim that the source fix is published.

Review Follow-through

The latest ClawSweeper review's before-merge source-pin/smoke item and cold-proof rank-up move are addressed by the completed evidence above. The dependent Crabpot pin was qualified locally before this source PR lands; after squash, PR705 will replace the candidate SHA with the actual merged Inspector SHA, verify identical source trees, and run its required native CI before landing. No npm version, tag, or publication is part of this change.

One earlier combined validation driver exhausted its 2 GiB heap after 152.95 seconds without a completed sample artifact. That driver retained full oracle reports; its exact internal failure stage and causal attribution were not established. The completed fresh-process proof matches the production process boundary, keeps oracle data outside the profile owner, and makes no source or limit changes. It supersedes the missing proof, without attributing that earlier failure to the harness.

@clawsweeper

clawsweeper Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

🦞👀
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-repro Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 4, 2026
@clawsweeper

clawsweeper Bot commented Nov 4, 2026

Copy link
Copy Markdown

Codex review: needs changes before merge.

What this changes

Use TypeScript’s type-information parsing mode throughout SDK analysis to discard TypeScript documentation trees while preserving JavaScript JSDoc types.

Example: Inspect the 59-fixture corpus against OpenClaw source with a 2 GiB Node heap.

  • Before: The preceding source revision reportedly exhausts the heap.
  • After: The candidate reportedly completes the corpus and produces equivalent reports; cold profiling remains unqualified.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and consistent with the compiler contract, but complete recovery of the affected profiling workflow remains unconfirmed.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is outside the ordinary contributor proof gate; its body reports corpus and report-equivalence success, but no completed cold-profile receipt is supplied and attribution of the profile-driver heap failure remains unresolved.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Large source-host inspections abort from heap exhaustion before producing complete compatibility results.
Reason: The maintainer-authored direction addresses a reproduced consumer failure with a small internal optimization and preserves the existing public behavior.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep open: this maintainer-authored PR addresses a concrete memory problem with a focused change absent from main; no introduced correctness defect was found.

Priority: P2
Reviewed head: 198c6d588ba427e58cfacbc50c19960c6cb05688

Before merge

  • Complete next step - The PR owner should advance the Crabpot source integration to the qualified candidate, update expectations as needed, and complete the plugin-inspector smoke required by AGENTS.md.

Findings

None.

Tests

  • Missing end-to-end proof: Completed cold profile samples through the production process boundary are still pending, and the new tests’ base-fail/head-pass result is not explicitly supplied.
Agent review details

How this fits together

Plugin Inspector builds a bounded TypeScript program from plugin files and explicit host declarations, then extracts SDK identities, classifications, evidence, and coverage for compatibility reports.

flowchart TD
A[Plugin files] --> C[SDK type program]
B[Explicit OpenClaw host] --> C
D[Reusable host inputs] --> C
C --> E[SDK provenance analysis]
E --> F[Inventory and compatibility reports]
Loading

Technical review

Best possible solution:

Keep the parser change in the existing program owner and qualify its consumer integration without raising heap limits or weakening inventory equivalence.

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

The report identifies the host revision, 59-fixture population, Node version, heap ceiling, and preceding failure, but this read-only review did not independently reproduce heap exhaustion.

Is this the best way to solve the issue?

The change targets unnecessary AST retention through TypeScript’s documented parser mode and preserves JavaScript type information, existing ownership boundaries, and report contracts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 89a3fedad864.

Provenance checked

  • SDK program parsing and host-cache reuse keeps the original intent (6df1dce: Reuse immutable host inputs and weak syntax references without retaining completed plugin programs, while preserving inventory evidence and host declarations.)
  • Typed host-body pruning and declaration effects keeps the original intent (fc33afc: Prevent implementation-only imports from inflating host graphs while retaining inferred exports, augmentations, references, JavaScript modules, and UMD exports.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned change and current-main behavior: The introduced diff consistently changes root, host, declaration, fallback, and cached parsing inside the existing program owner. Main retains the previous parsing mode; module-resolution boundaries, report fields, dependencies, and resource limits are unchanged. (src/sdk-usage/program.js:6, 198c6d588ba4)
  • Authoritative parser contract: TypeScript 6.0.3 documents ParseForTypeInfo as preserving JSDoc parsing in non-TypeScript files and omitting it in TypeScript files; scanner implementation matches that contract. Plugin Inspector directly imports TypeScript and relies on this behavior. (src/compiler/types.ts:10302, 050880ce59e3)
  • Meaningful regression coverage: Added tests verify JavaScript-only SDK parameter typing, inventory extraction, cached-tree reconstruction, omission of typed documentation, and complete TypeScript/declaration inventory parity including evidence positions. Existing host tests cover inferred facades, augmentations, references, and cache isolation. (test/sdk-usage-jsdoc.test.js:10, 198c6d588ba4)
  • Validation and draft state: The complete PR body reports corpus completion and exact report equivalence after nine verified location mappings, but explicitly records an unresolved profile-driver heap failure and pending fresh-process validation. Historical package payload hashes were unavailable, so byte-identical historical inputs are not claimed. Discussion contains only bot status comments; the reviewed head remains draft and mergeable. (198c6d588ba4)
  • Repository policy applied: Read the complete root AGENTS.md; no nested policy, maintainer-note entries, or pr-simplify skill were present. Policy requires Crabpot follow-through and smoke for behavior changes; the existing follow-through script identifies source-ref adoption and source/package smoke paths. (AGENTS.md:12, 198c6d588ba4)
  • Consumer integration remains open: fix: source canaries exhaust the inspection heap crabpot#705 exercises Inspector as its source-host implementation and supplies the reproduced workload, establishing the relevant consumer contract. Its candidate still pins Inspector main rather than this PR and records that the earlier source-pin change alone did not repair the failure. Crabpot’s complete root policy requires source-ref and expectation updates when Inspector behavior changes. (AGENTS.md:13, 15de6424b547)

Likely related people:

  • Patrick Erichsen: Raw commit d40bf71 adds src/sdk-usage/program.js:30 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d40bf710a427; files: src/sdk-usage/program.js)
  • Peter Steinberger: Raw commit fc33afc adds src/sdk-usage/program.js:31 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: fc33afcf319b; files: src/sdk-usage/program.js)

Review metrics

Metric Value Why it matters
Change size Production +15/-8; tests +79; changelog +2 Small production growth applies one parser contract across existing paths; tests cover distinct typing, cache, and report-preservation failures.

Labels

Label changes:

  • add P2: Heap exhaustion disrupts an advanced source-inspection workload, without evidence of an urgent end-user runtime regression.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: Heap exhaustion disrupts an advanced source-inspection workload, without evidence of an urgent end-user runtime regression.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rank-up moves

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

  • Assess the completed fresh-process cold-profile results at the unchanged heap and sample limits.

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 4, 2026, 2:57 AM ET / 07:57 UTC.

@vincentkoc
vincentkoc marked this pull request as ready for review November 4, 2026 08:22
@vincentkoc
vincentkoc requested a review from a team as a code owner November 4, 2026 08:22
@vincentkoc
vincentkoc merged commit 8ebe4f8 into main Nov 4, 2026
21 checks passed
@vincentkoc
vincentkoc deleted the fix/sdk-type-info-memory branch November 4, 2026 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant