Skip to content

fix(build): speed up declaration input discovery - #164374

Merged
steipete merged 1 commit into
mainfrom
codex/testperf-declaration-syntax
Oct 3, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/testperf-declaration-syntax

Conversation

@steipete

@steipete steipete commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Declaration input discovery creates a native compiler project for every source file when it only needs import syntax.

User Impact

Less compiler work during repository build validation. The measured full 11-case declaration command used 6.6% less wall time and 4.7% less CPU, with no intended declaration output or production-runtime change.

Why This Change Was Made

Use the pinned TypeScript API's createSourceFile for syntax extraction. A local disposable holder keeps API construction lazy, after graph setup and the source read. The existing outer graph still owns configuration and module resolution; dynamic-edge ownership, traversal and failure ordering stay unchanged. Cleanup retains its existing scope and exception behavior.

Evidence

Merged as b80b4d0b579568457b582f44e061b9b923649bc9 through the native maintainer workflow. Current-input correctness, exact-head hosted CI, and post-merge consumer proof passed.

On source 9a190f34b9c3198e40b43bdbd0f802088ea631d5, the complete CI=1 corepack pnpm test test/scripts/write-unified-entry-dts.test.ts command ran A–B–B–A on one native Testbox. All four arms passed the same 11 cases, including dynamic/unresolved-edge rejection, declaration cache invalidation, and failed publication preserving the previous generation. Tests, fixtures, concurrency, caches and deadlines were unchanged; B1 and B2 used continuously identical candidate bytes.

Arm Variant Whole-command wall User + system CPU GNU peak RSS, KiB
A1 Baseline 23.28 s 50.95 s 753908
B1 Candidate 21.04 s 47.67 s 573664
B2 Candidate 21.09 s 47.17 s 581356
A2 Baseline 21.84 s 48.56 s 588680

Mean wall time fell 22.56 → 21.065 s (6.63%); mean CPU fell 49.755 → 47.42 s (4.69%). Both candidate runs beat both baselines. RSS is GNU's process maximum, not aggregate concurrent memory. These measurements apply to this frozen 11-case workload, not the whole suite or production.

Focused formatting, script lint and script typechecking passed. Fresh independent review found no actionable findings through P2. Source, installed compiler inputs and native binaries were verified across the comparison, every managed process group joined, and baseline source was restored. Native Testbox run, Node 24.19.0, Linux x64, four available CPUs; its holder was canonically stopped after all proof and subsequent diagnostics settled.

Current-main applicability was inspected separately. The ACP/acpx dependency update is outside the selected fixture's executed package graph, but an imported worker-metadata module gained a test-worker entry. A separate full 11-case correctness run on main a163d9b3db61f02143edef8a1f655c8a8448ee66 with the exact reviewed candidate passed in 22.38 seconds, with matching case identities, source/dependency checks, joined processes and restored baseline. Current-input Testbox run; its holder was canonically stopped after the evidence was retained. This was a correctness check; the timing comparison remains attributed to the frozen source above.

Exact-head hosted CI passed for e7a547ca9466a4df11955b1b610726d0b9bd10cd. Its changed-test job covered other selected files, so the full current-input declaration proof comes from the separate run above. The full declaration consumer then passed all 11 cases on 9f6cbe9c443769ac9c13b0b239b2c8f450230b77, a verified descendant of this merge. Source comparison established unchanged generator, parser, fixture, and dependency inputs; two unrelated test-routing lists changed. The AWS Crabbox command completed in 33.79 seconds on Node 24.19.0/Linux x64 with 32 available CPUs. All process groups joined and source/dependency bytes remained intact. This is descendant correctness evidence, not another performance comparison.

Use the native syntax API without creating a project for each visited file.
Keep acquisition lazy after source reads and retain the outer graph's
module-resolution, ownership, failure-order, and cleanup contracts.

The full 11-case declaration command used 6.63% less wall time and 4.69%
less CPU in the source-pinned A-B-B-A comparison. Tests and runtime policy
are unchanged.
@clawsweeper

clawsweeper Bot commented Oct 3, 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.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: XS labels Oct 3, 2026
@steipete
steipete marked this pull request as ready for review October 3, 2026 15:28
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 Oct 3, 2026
@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 11:51 AM ET / 15:51 UTC (Revision 2).

ClawSweeper review

What this changes

The declaration build helper parses import syntax directly instead of creating a compiler project for each visited source file.

Merge readiness

✅ Ready for maintainer review

The optimization remains useful and has no actionable review findings. The updated evidence resolves the previous current-input validation blocker.

Priority: P3
Reviewed head: e7a547ca9466a4df11955b1b610726d0b9bd10cd

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused optimization with controlled native measurements, current-input correctness evidence, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The recorded native comparison exercises declaration discovery through the real writer and compiler toolchain, with all 11 cases passing and lower measured wall and CPU time. The subsequent current-input run resolves the prior coverage request. No stored-data format changes are introduced.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The recorded native comparison exercises declaration discovery through the real writer and compiler toolchain, with all 11 cases passing and lower measured wall and CPU time. The subsequent current-input run resolves the prior coverage request. No stored-data format changes are introduced.
Evidence reviewed 8 items Introduced change and lifecycle: The pinned introduction delta replaces the project-backed syntax parser with lazy API construction and createSourceFile. Source reads still precede acquisition; the outer graph retains resolution responsibility, and disposal remains scoped around traversal.
Verified merge composition: The raw test-merge record has the pinned base followed by the exact PR head as parents. Its comparison against that base contains only the declaration discovery optimization; endpoint drift is not attributed to this PR.
Pinned compiler contract: The directly imported dependency is TypeScript 7.1.0-dev.20260920.1. npm metadata identifies microsoft/TypeScript and gitHead f29aeb9f825d96feea27841f3f7342dbf0df68a8, independently verified through GitHub. Its synchronous API accepts filename and source text, returns a source tree without creating a snapshot, and closes the underlying client in finally.
Findings None None.
Security None None.

How this fits together

Declaration input discovery identifies source and toolchain files that affect generated TypeScript declarations and build-cache freshness. It extracts imports, resolves their targets, and supplies the declaration writer with a complete input inventory.

flowchart TD
  A[Declaration writer] --> B[Source and configuration files]
  B --> C[Direct syntax parsing]
  C --> D[Import resolution and ownership checks]
  D --> E[Complete input inventory]
  E --> F[Declaration generation and cache validation]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Other +4. Total +4 across 1 file.

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

Review metrics

Metric Value Why it matters
Declaration command efficiency Wall time −6.63%; CPU time −4.69% The source-pinned four-arm comparison supports the optimization for the unchanged 11-case workload without claiming whole-suite gains.

Technical review

Best possible solution:

Use direct syntax parsing while retaining the existing graph's resolution, input ownership, and cleanup contracts.

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

Not applicable as a functional bug report; the recorded native comparison provides a concrete way to measure the existing declaration discovery overhead.

Is this the best way to solve the issue?

Yes. The pinned compiler supports direct syntax extraction, and the patch preserves the existing owner for module resolution rather than introducing another graph.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 384d14f609e8.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P3: This is a bounded build-tooling performance improvement with no intended product behavior change.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The recorded native comparison exercises declaration discovery through the real writer and compiler toolchain, with all 11 cases passing and lower measured wall and CPU time. The subsequent current-input run resolves the prior coverage request. No stored-data format changes are introduced.
  • proof: sufficient: Contributor real behavior proof is sufficient. The recorded native comparison exercises declaration discovery through the real writer and compiler toolchain, with all 11 cases passing and lower measured wall and CPU time. The subsequent current-input run resolves the prior coverage request. No stored-data format changes are introduced.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-03T15:34:14.524Z sha e7a547c :: needs changes before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Oct 3, 2026
@steipete
steipete merged commit b80b4d0 into main Oct 3, 2026
181 checks passed
@steipete
steipete deleted the codex/testperf-declaration-syntax branch October 3, 2026 15:52
@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
Use the native syntax API without creating a project for each visited file.
Keep acquisition lazy after source reads and retain the outer graph's
module-resolution, ownership, failure-order, and cleanup contracts.

The full 11-case declaration command used 6.63% less wall time and 4.69%
less CPU in the source-pinned A-B-B-A comparison. Tests and runtime policy
are unchanged.

Co-authored-by: Peter Steinberger <[email protected]>
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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. scripts Repository scripts size: XS 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