Skip to content

perf(tooling): stream native declaration outputs - #160207

Closed
vincentkoc wants to merge 1 commit into
fix/semantic-sdk-preparationfrom
perf/native-declaration-streaming
Closed

vincentkoc wants to merge 1 commit into
fix/semantic-sdk-preparationfrom
perf/native-declaration-streaming

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Outcome

Closed without landing: the full SDK comparison did not justify this optimization.

Matched ABBA runs on one Linux worker, identical pinned install and 7 GiB kernel scopes: baseline 90.849/101.085 seconds and 6,894,493,696/6,752,440,320 peak bytes; callback emission 107.297/100.952 seconds and 6,784,827,392/6,727,839,744 peak bytes. Average peak fell about 1%; average runtime rose about 8.5%. Every run completed with zero kernel OOM events and 11,165 declaration files.

Byte hashes differed. The reverse pair localized 23 differing files; inspected samples include declarations of the modified tooling itself and property-order changes in inferred types. Full byte parity is not established, so this is not an accepted output-equivalence result. Focused native fixtures passed, but the measured full-workload benefit is too small to justify the extra staging path.

Proposed change (not landed)

Emit native declarations through the compiler's filesystem callback into the existing private staging directory. Previously emitToString retained every output string in Go and returned the whole collection while the semantic program was still alive.

The same Program, diagnostic queries, roots and compiler options remain. Output paths are admitted before staging; callback write failures are latched until RPC completion. The native compiler exits and the existing input seal succeeds before Node materializes the returned text map. Callers retain ownership of final publication.

Pinned TypeScript supports host callback emission; emitToString collects all output.

Dependency

Stacked on #160152. Land that prerequisite and retarget to main before merging.

Validation

Candidate: a155b907e0205936412b278caa6b760ca040f309.

Exact-head remote native proof passed: 27 tests across declaration-boundary and package-preparation suites (35.32 seconds; six existing conditional cases skipped), plus the cold sibling-output ownership case (2.59 seconds). Scripts typecheck, production typed lint, formatting and whitespace passed. Independent P0–P2 review found no actionable defects.

A separate full SDK preparation attempt exited 137 with a 3.5 GiB semantic limit. This patch does not solve that workload sizing issue.

Tests compare real callback and in-memory emission bytes, including BOM and maps; verify staged reads occur after native exit; inject a write failure and check cleanup/preservation; retain the existing config and sibling-output mutation hooks.

Production +49/-26 lines; tests +119/-14 lines. The added writer boundary removes whole-output retention during the compiler lifetime without publishing partial outputs.

@vincentkoc vincentkoc self-assigned this Sep 28, 2026
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: M labels Sep 28, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. 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, 2:50 AM ET / 06:50 UTC (Revision 2).

ClawSweeper review

What this changes

The branch stages native TypeScript declaration output through a filesystem callback, then loads the sealed text for SDK preparation and package builds.

Merge readiness

⛔ Blocked before merge - 6 items remain

Keep this targeted optimization open. Current main still collects native declaration output in memory, and the branch offers a distinct staged-output path.

Priority: P2
Reviewed head: a155b907e0205936412b278caa6b760ca040f309

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and reports real compiler checks, while its documentation and measured memory outcome remain unfinished.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: The member-authored PR is exempt from the external-contributor proof gate. Its body reports exact-head real native-compiler parity, write-failure, and consumer tests for the changed staging path, but no matched cold SDK memory result; this review did not execute code. The staging files are temporary artifacts, so no stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The member-authored PR is exempt from the external-contributor proof gate. Its body reports exact-head real native-compiler parity, write-failure, and consumer tests for the changed staging path, but no matched cold SDK memory result; this review did not execute code. The staging files are temporary artifacts, so no stored-data contract changes.
Evidence reviewed 9 items Current main still uses in-memory emission: The fetched main revision calls emitToString, so the central staging change is not already implemented there.
Introduced output boundary: The pinned PR head calls native emit, writes admitted outputs into private staging, closes the compiler, seals inputs, and only then reads declaration text.
Pinned compiler contract: The PR explicitly relies on this TypeScript implementation: native emit can call the host filesystem writer, while emitToString collects output text. The dependency is identified by the PR's pinned source link, not by a sibling checkout.
Findings 1 actionable finding [P3] Update the declaration guide for staged output
Security None None.

How this fits together

OpenClaw tooling compiles TypeScript declarations from project files and compiler settings. SDK preparation and package builds consume the resulting declarations and own final artifact publication.

flowchart LR
  A[Project files and settings] --> B[Native compiler]
  B --> C[Output path check]
  C --> D[Private staging]
  D --> E[Compiler exit and input seal]
  E --> F[Declaration text map]
  F --> G[SDK and package builds]
Loading

Before merge

  • Update the declaration guide for staged output (P3) - The switch to callback emission makes the guide's statements at docs/reference/test/runner-internals.md:67 and :73 inaccurate: declarations are staged and read after native exit, rather than returned in memory by the compiler. Update those two statements before merge. This was also raised in the prior review of the same head.
  • Resolve merge risk (P1) - The intended workload-level memory benefit remains unmeasured: the reported full SDK preparation attempt still exited 137 under a 3.5 GiB limit, so focused parity tests do not establish that this workload completes or uses less peak memory.
  • Resolve merge risk (P1) - This PR still targets an open stacked prerequisite. Its final main-branch composition needs review after that prerequisite lands and the PR is retargeted.
  • Resolve merge risk (P1) - The PR reports aggregate suite time but not the changed test file's one-worker wall time required to assess the repository's per-file test budget.
  • Complete next step (P2) - Correct the declaration guide, record the changed test file's one-worker wall time and a matched cold SDK memory result, then land the prerequisite and retarget this PR before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.

Findings

  • [P3] Update the declaration guide for staged output — scripts/lib/native-declaration-emitter.mts:189-192
Agent review details

Security

None.

PR surface

Tests +105, Other +23. Total +128 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 119 14 +105
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 49 26 +23
Total 4 168 40 +128

Review metrics

Metric Value Why it matters
Production versus test growth production net +23 lines; tests net +105 lines The new staging boundary explains the production growth, while the larger test delta covers output parity and failure cleanup.

Stored data model

Persistent data-model change detected: serialized state: scripts/lib/native-declaration-emitter.mts, serialized state: scripts/lib/native-declaration-filesystem.mts, unknown-data-model-change: scripts/lib/native-declaration-emitter.mts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Qualify the staged compiler path (recommended)
    Land the prerequisite, retarget this branch, and record matched cold SDK peak memory and the changed test file's one-worker wall time before merge.
  2. Pause if the workload remains unbounded
    Keep the PR open for a narrower optimization if staging does not improve the constrained SDK workload enough to justify its added I/O.

Technical review

Best possible solution:

Keep the single compiler and private staging boundary, correct the tooling guide, qualify a matched cold SDK workload and test-file cost, then review the retargeted branch after its prerequisite lands.

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

No high-confidence reproduction of the host-memory failure and recovery is available here. Source confirms current main's whole-output collection, while the reported constrained full SDK run still exits 137.

Is this the best way to solve the issue?

Yes for the identified retention path: callback staging is a focused change that preserves the compiler and final publication owner. Its effect on the constrained SDK workload still needs measurement.

Full review comments:

  • [P3] Update the declaration guide for staged output — scripts/lib/native-declaration-emitter.mts:189-192
    The switch to callback emission makes the guide's statements at docs/reference/test/runner-internals.md:67 and :73 inaccurate: declarations are staged and read after native exit, rather than returned in memory by the compiler. Update those two statements before merge. This was also raised in the prior review of the same head.
    Confidence: 0.96

Overall correctness: patch is correct
Overall confidence: 0.85

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded tooling memory improvement with useful native-compiler coverage, but its workload-level benefit remains unmeasured.
  • merge-risk: 🚨 automation: The PR changes declaration emission used by SDK preparation and package builds, where a failure could interrupt build or lint automation.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The member-authored PR is exempt from the external-contributor proof gate. Its body reports exact-head real native-compiler parity, write-failure, and consumer tests for the changed staging path, but no matched cold SDK memory result; this review did not execute code. The staging files are temporary artifacts, so no stored-data contract changes.

Evidence

Acceptance criteria:

  • [P1] pnpm docs:check-mdx.
  • [P1] pnpm format:docs:check.
  • [P1] git diff --check.

What I checked:

Likely related people:

  • 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.

  • Correct the two stale declaration-guide statements.
  • Record matched cold SDK peak memory and the changed test file's one-worker wall time.
  • Retarget to main after the stacked prerequisite lands and review the resulting composition.

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 (1 earlier review cycle)
  • reviewed 2026-09-28T06:38:21.213Z sha a155b90 :: blocked before merge. :: [P3] Update the declaration ownership guide for staged output

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

Labels

merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: M 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