Skip to content

refactor(scripts): separate syntax parsing from import resolution - #164243

Merged
steipete merged 1 commit into
mainfrom
codex/test-runtime-import-syntax-parser
Oct 3, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/test-runtime-import-syntax-parser

Conversation

@steipete

@steipete steipete commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The Control UI import-boundary check and build dependency discovery create a compiler project for each file even when they only need its import syntax. Parsing that syntax directly cuts the measured Control UI check's whole-command time by 52%.

User Impact

Faster repository validation and dependency discovery, with no intended product behavior change. On one Linux x64 Testbox, the existing Control UI import-boundary command averaged 9.32 seconds before and 4.47 seconds after. This is a focused test-command result, not a whole-suite or production-runtime claim.

Why This Change Was Made

Use the pinned native TypeScript API.createSourceFile for syntax extraction. The existing outer compiler project continues to own configuration and module resolution, including late roots and import/require conditions. The change removes the inner per-file project without changing assertions, fixtures, test selection, or deadlines.

Evidence

Independent review found no actionable findings. The committed candidate bytes match the verified baseline/candidate proof on source ca77256127e6ba13c00d68bca42194d1b9e2a780.

The contiguous A–B–B–A comparison ran node scripts/run-vitest.mjs test/control-ui-import-boundary.test.ts on the same native Blacksmith Testbox, using Node 24.19.0, Linux x64, four available CPUs, and 16,555,134,976 bytes of reported system memory. All four runs passed the same single test. No source rewrite or cache reset occurred between B1 and B2.

Run Variant Whole-command wall User + system CPU
A1 Baseline 9.74 s 12.48 s
B1 Candidate 4.50 s 6.98 s
B2 Candidate 4.44 s 5.57 s
A2 Baseline 8.90 s 11.43 s

Mean wall time fell 52.04% (9.32 → 4.47 seconds); mean CPU time fell 47.51% (11.955 → 6.275 seconds). Both candidate runs beat both baselines.

  • A separately accepted parser/graph probe produced identical baseline/candidate output for 16 valid/malformed syntax cases across eight extensions and two graph scenarios. The continuation verified matching source, candidate, Node/native parser binaries, and portable dependency fingerprints before reusing that proof.
  • Eager-import semantic checks passed: 6 passed, 11 intentionally filtered; declaration-generator checks: 4 passed, 7 filtered; worker-artifact check: 1 passed, 34 filtered.
  • Linux formatting, script lint, and script typechecking passed. All ten continuation phases exited zero, their process groups and resources settled, and the exact baseline was restored.
  • Native Testbox run. The full archive's 184 manifest entries were independently verified; archive SHA-256: be50da254e0ebc799c3e0c2e2b1bdfc752ba76b005f544eb7f8861ae45165476. The holder job was later cancelled by canonical lease cleanup after the benchmark and a separate discovery invocation had both settled; the benchmark command and result receipts passed independently.

Hosted CI attribution

Exact-head CI run passed the boundary, lint, production-type, and test-type checks but failed the changed-test shard's get-reply.imports.test.ts assertion: the inline-actions closure reaches skills/library/errors.ts.

The actual CI merge was 16c62eb647d63436a7d699437d2ea596f9294b1e, incorporating base a6748f0731aade9063e07e905bf88ca6721221c3. Independent source tracing found the new value edge in main commit a06f24e1edb6a4b25873ff60dd4f139b855609b9 (#164165): openclaw-state-worker-error-identity.ts imports SkillLibraryError. The preceding path to the worker-error adapter is unchanged from this PR's frozen base; the main-side import in the error-identity module is the new edge. This PR changes only scripts/lib/runtime-import-closure.mts.

The main-source origin is verified; the exact CI merge has not been rerun with the baseline parser through the Bun shard route. The red result is retained, with no assertion change, CI rerun, or push to obtain green.

Post-merge verification

Merged as e9edca4c578317b03b56b67a4b6fec44032e64d1. A fresh-descendant smoke at main 9a190f34b9c3198e40b43bdbd0f802088ea631d5 passed the full test/control-ui-import-boundary.test.ts command: one file and one case on Node 24.19.0, Linux x64, four available CPUs. The landed helper bytes matched the reviewed candidate, both the managed command and wrapper joined, and the source remained unchanged. This is post-merge correctness proof, with no new speed comparison. Post-merge Testbox run. Its holder was subsequently stopped after the smoke and a separate diagnostic had settled.

The merge-push CI run succeeded with only security-fast executed; its skipped test jobs are not counted as UI test proof.

Use the pinned native TypeScript standalone syntax API inside the runtime import graph. Keep compiler-based configuration and module resolution with the existing outer project.

Validation: independent source review and Linux parser/graph contract parity passed. Whole-command timing and consumer/static checks remain pending remote admission.
@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 10:18
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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, 8:46 AM ET / 12:46 UTC (Revision 5).

ClawSweeper review

What this changes

The PR parses import syntax directly with native TypeScript while retaining compiler-based dependency resolution, making repository validation and build-input discovery faster.

Merge readiness

✅ Ready for maintainer review

The optimization remains useful on current main, and the pinned patch has no actionable correctness findings. The recorded command benchmark supports the performance claim; the failed CI assertion concerns a main-side import edge rather than an established defect introduced here.

Priority: P3
Reviewed head: 47ba44103ca9203161440be35c8a4e663b62bd77

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused simplification with direct command-level performance evidence and no actionable introduced defect.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The changed import-graph parser is exercised by the recorded real Control UI boundary command on Linux Testbox: both candidate runs pass and outperform both baselines. Syntax/graph parity and consumer checks supplement that direct performance evidence. The holder's cleanup cancellation does not invalidate the recorded command results; no stored-data contract changes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The changed import-graph parser is exercised by the recorded real Control UI boundary command on Linux Testbox: both candidate runs pass and outperform both baselines. Syntax/graph parity and consumer checks supplement that direct performance evidence. The holder's cleanup cancellation does not invalidate the recorded command results; no stored-data contract changes.
Evidence reviewed 8 items Pinned introduction: The introduced delta replaces the inner compiler-backed parser with API.createSourceFile. Import selection, outer compiler project, resolution conditions, late-root handling, and cleanup remain intact.
Still necessary on main: Fetched main still constructs createNativeTypeScriptParser and invokes parseSourceFile for this graph. No verified merged replacement implements this optimization.
Pinned dependency contract: The direct typescript/unstable/sync import establishes the dependency signal. Read the published typescript 7.1.0-dev.20260920.1 tarball: dist/api/sync/api.js:172 implements createSourceFile(fileName, sourceText, options), sends a standalone parsing request, and returns a source tree without opening a compiler project. npm repository metadata and GitHub commit metadata verify the repository and gitHead.
Findings None None.
Security None None.

How this fits together

OpenClaw's import-graph tooling reads source files and compiler configuration to discover dependencies without executing them. Boundary checks and build tooling consume the resulting dependency graph.

flowchart TD
  A[Source files] --> B[Standalone syntax parser]
  B --> C[Selected import references]
  D[Compiler configuration] --> E[Compiler module resolution]
  C --> E
  E --> F[Dependency graph]
  F --> G[Boundary checks and build inputs]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Other -2. Total -2 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 4 6 -2
Total 1 4 6 -2

Review metrics

Metric Value Why it matters
Measured boundary-command time 9.32 → 4.47 seconds; 52.04% reduction The recorded same-host A–B–B–A comparison measures the affected repository command, rather than extrapolating to the whole suite.

Technical review

Best possible solution:

Keep syntax extraction lightweight and leave configuration, package conditions, and dependency resolution with the existing compiler owner.

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

Not applicable to a bug reproduction: this is a performance refactor, supported by recorded baseline and candidate runs of the actual affected command.

Is this the best way to solve the issue?

Yes. The standalone parser removes unnecessary compiler-project work while preserving the existing resolution owner and dependency contracts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 3bfa7cd91059.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is a bounded repository-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 (terminal): The changed import-graph parser is exercised by the recorded real Control UI boundary command on Linux Testbox: both candidate runs pass and outperform both baselines. Syntax/graph parity and consumer checks supplement that direct performance evidence. The holder's cleanup cancellation does not invalidate the recorded command results; no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed import-graph parser is exercised by the recorded real Control UI boundary command on Linux Testbox: both candidate runs pass and outperform both baselines. Syntax/graph parity and consumer checks supplement that direct performance evidence. The holder's cleanup cancellation does not invalidate the recorded command results; no stored-data contract changes.

Evidence

What I checked:

  • Pinned introduction: The introduced delta replaces the inner compiler-backed parser with API.createSourceFile. Import selection, outer compiler project, resolution conditions, late-root handling, and cleanup remain intact. (scripts/lib/runtime-import-closure.mts:169, 47ba44103ca9)
  • Still necessary on main: Fetched main still constructs createNativeTypeScriptParser and invokes parseSourceFile for this graph. No verified merged replacement implements this optimization. (scripts/lib/runtime-import-closure.mts:126, 3bfa7cd91059)
  • Pinned dependency contract: The direct typescript/unstable/sync import establishes the dependency signal. Read the published typescript 7.1.0-dev.20260920.1 tarball: dist/api/sync/api.js:172 implements createSourceFile(fileName, sourceText, options), sends a standalone parsing request, and returns a source tree without opening a compiler project. npm repository metadata and GitHub commit metadata verify the repository and gitHead. (f29aeb9f825d)
  • Real command performance evidence: The supplied full PR body records an A–B–B–A comparison of node scripts/run-vitest.mjs test/control-ui-import-boundary.test.ts on one Linux x64 native Testbox with Node 24.19.0. All four runs passed the same test; baseline mean wall time was 9.32 seconds and candidate mean was 4.47 seconds. Parser/graph parity covered 16 syntax cases across eight extensions and two graph scenarios. The linked holder run was subsequently cancelled during lease cleanup; that workflow conclusion is not a benchmark failure. GitHub currently exposes no downloadable artifacts, so this review relies on the captured detailed results rather than independently re-verifying the archive. (test/control-ui-import-boundary.test.ts:9, 47ba44103ca9)
  • Verified merge composition: The raw test-merge record has exactly the pinned base followed by the original PR head. Its diff against that base contains only the parser refactor, confirming that endpoint drift does not belong to this PR. (scripts/lib/runtime-import-closure.mts:8, 16c62eb647d6)
  • CI attribution boundary: The merged change at refactor(skills): run skill library reads and selection authority in workers (skilllib A) #164165 adds the SkillLibraryError value import named by the failing inline-actions closure assertion. The PR body explicitly retains the red result and acknowledges that the exact CI merge was not replayed with the baseline parser through Bun; source provenance is established, but a full baseline execution comparison is not claimed. (src/state/openclaw-state-worker-error-identity.ts:28, a06f24e1edb6)

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 (4 earlier review cycles)
  • reviewed 2026-10-03T10:18:10.315Z sha 47ba441 :: needs changes before merge. :: none
  • reviewed 2026-10-03T10:24:24.814Z sha 47ba441 :: needs changes before merge. :: none
  • reviewed 2026-10-03T10:29:37.199Z sha 47ba441 :: needs changes before merge. :: none
  • reviewed 2026-10-03T12:16:30.744Z sha 47ba441 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

/allow-dependencies-change

@steipete
steipete merged commit e9edca4 into main Oct 3, 2026
205 of 208 checks passed
@steipete
steipete deleted the codex/test-runtime-import-syntax-parser branch October 3, 2026 12:53
@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

vincentkoc added a commit that referenced this pull request Oct 3, 2026
* origin/main:
  fix(test): restore fixture state and await async completion (#164222)
  refactor(sessions): stage and settle pending inputs in workers (#164284)
  fix: speech-only replies fail when models include reasoning (#164285)
  fix(nextcloud-talk): avoid webhook migration for unconfigured channels
  fix: guide background skill reviews through Workshop proposals (#164292)
  test(build): reject AI dependencies in retained config repairs
  refactor(channels): require canonical private-network settings (#163535)
  fix(memory): migrate embedding cache in bounded batches and record oversized rows (#164303)
  feat(state): incognito actor memory and Codex history routing (P5c, inactive) (#164224)
  refactor(synology-chat): remove unused route account ID (#164280)
  test(ui): await web push preference publications (#164295)
  perf(scripts): avoid compiler projects for runtime import parsing (#164243)
  fix(worktrees): create workspaces from nested Windows repositories (#164249)
  test(agents,channels,cli): remove low-value tests (batch d173) (#164302)
  perf(workboard): serve cards per board revision and push changes instead of polling (#164301)
  refactor(sqlite): deslop sqlite stores (#164271)
  chore(ui): refresh control ui locales (#164299)
  refactor(events): deslop listener and disposal plumbing (#164221)
  fix: canonicalize fresh worker reasoning signatures (#164287)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
…enclaw#164243)

Use the pinned native TypeScript standalone syntax API inside the runtime import graph. Keep compiler-based configuration and module resolution with the existing outer project.

Validation: independent source review and Linux parser/graph contract parity passed. Whole-command timing and consumer/static checks remain pending remote admission.
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