Skip to content

test(plugin-sdk): avoid duplicate full API render - #122402

Merged
steipete merged 1 commit into
mainfrom
perf/plugin-sdk-api-baseline-tests
Aug 12, 2026
Merged

steipete merged 1 commit into
mainfrom
perf/plugin-sdk-api-baseline-tests

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

src/plugin-sdk/api-baseline.test.ts rebuilt a TypeScript program across 14 real Plugin SDK entrypoints before running otherwise narrow serializer and fixture tests. That duplicated the dedicated plugin-sdk:api:check CI lane, which already renders the complete canonical public SDK inventory and compares every committed module contract.

The duplicate compile dominated this Vitest file: 62.89s of Vitest time / 69.77s wall locally, and 57.00s in the prior hosted baseline.

Why This Change Was Made

  • Replace the whole-repository Vitest setup with two small in-memory module surfaces for serializer, artifact drift, and Git merge/patch-stability tests.
  • Remove source-by-source declaration assertions that reasserted generated contract contents already protected by the dedicated full-repository contract gate.
  • Keep all 18 tests and all unique renderer contracts through narrow TypeScript fixtures.
  • Strengthen those fixtures to explicitly retain class implementation stripping, public alias rendering, path-free contract serialization, closure reachability, deterministic hashing, and artifact repair coverage.
  • Leave plugin-sdk:api:check unchanged as the canonical whole-repository composition/drift gate.

This removes duplicate work rather than adding workers, weakening the contract gate, or hiding latency behind reshards.

User Impact

No runtime or Plugin SDK API behavior changes. Pull-request test shards finish sooner and use substantially less memory.

Production LOC: +0/-0. Test LOC: +49/-101. Test count: 18 before and after.

Evidence

Before

src/plugin-sdk/api-baseline.test.ts: 18/18 passed
Vitest: 62.89s
wall:   69.77s
RSS:    4,049,140 KiB
Hosted baseline: 57.00s

After

src/plugin-sdk/api-baseline.test.ts: 18/18 passed
Vitest:  6.11s (90.3% faster)
wall:   12.79s (81.7% faster)
RSS:    722,176 KiB (82.2% lower)

Validation:

  • node scripts/run-vitest.mjs src/plugin-sdk/api-baseline.test.ts — 18/18 passed
  • pnpm plugin-sdk:api:check — canonical full-repository contract current (OK docs/.generated/plugin-sdk-api-baseline)
  • oxfmt --check src/plugin-sdk/api-baseline.test.ts — passed
  • node scripts/run-oxlint.mjs src/plugin-sdk/api-baseline.test.ts — passed
  • node scripts/check-changed.mjs --dry-run — classified expected core/coreTests/extension contract lanes
  • git diff --check — passed
  • Autoreview's TruffleHog preflight — clean; model review unavailable because no supported reviewer executable is installed in the orb

@clawsweeper

clawsweeper Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 12, 2026 03:06
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Aug 12, 2026
@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 Aug 12, 2026
@clawsweeper

clawsweeper Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 11, 2026, 11:12 PM ET / August 12, 2026, 03:12 UTC.

ClawSweeper review

What this changes

This PR replaces full Plugin SDK rendering in a Vitest suite with small in-memory module fixtures while retaining the separate full API-contract CI check.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

No blocking findings. This focused test refactor removes duplicate full-SDK rendering while the dedicated contract lane still renders all public entrypoints; keep it open for normal maintainer handling and completion of exact-head CI.

Priority: P3
Reviewed head: 0b0e02672c848dfb4eb98fcec17463cc1364934b

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, well-supported test cleanup with no identified correctness defect.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored test-only refactor changes no user-visible behavior; focused-test timing and the dedicated full contract CI lane are the relevant evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored test-only refactor changes no user-visible behavior; focused-test timing and the dedicated full contract CI lane are the relevant evidence.
Evidence reviewed 6 items Focused test refactor: The branch replaces the suite-wide rendered SDK fixture with two typed in-memory module surfaces, retaining serializer, artifact, declaration-stripping, and aliased-export assertions.
Canonical full-render owner: The production wrapper renders all canonical public entrypoints before writing or comparing API contract artifacts, so full composition remains outside this narrow serializer suite.
Dedicated CI gate: The generator's check mode fails when its full render differs from committed contract records, and the CI workflow runs that command in its own Plugin SDK API-baseline lane.
Findings None None.
Security None None.

How this fits together

The Plugin SDK baseline generator compiles public SDK subpaths into deterministic contract records. The Vitest suite checks serializer and artifact-repair behavior, while CI runs the full generator against the committed contract inventory.

flowchart LR
  A[Public SDK entrypoints] --> B[API baseline generator]
  B --> C[Contract records]
  C --> D[Dedicated CI contract check]
  E[Small module fixtures] --> F[Serializer and artifact tests]
  D --> G[Contract drift result]
  F --> H[Test result]
Loading

Before merge

  • Resolve merge risk (P1) - The supplied status rollup still has exact-head jobs running, so merge should wait for their completion.
  • Resolve merge risk (P1) - The review checkout has no installed TypeScript sources and network access failed, so the direct compiler API contract could not be independently re-read; the passing dedicated contract check is the available exact-version evidence.
  • Complete next step (P2) - No repair lane is needed: no concrete defect was found, and this protected maintainer PR needs ordinary maintainer handling after CI completes.
Agent review details

Security

None.

PR surface

Tests -52. Total -52 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 49 101 -52
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 49 101 -52

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0; tests +49/-101 (net -52) The branch removes duplicate test setup without changing runtime or Plugin SDK API code.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the full generator as the single canonical composition/drift gate and keep this Vitest suite limited to fast serializer and artifact invariants.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the full generator as the single canonical composition/drift gate and keep this Vitest suite limited to fast serializer and artifact invariants.

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

Not applicable as a defect report: source shows the former suite-wide setup invoked the full renderer, and the PR supplies before/after focused-test timings plus a passing full contract check.

Is this the best way to solve the issue?

Yes. The dedicated CI lane owns whole-SDK composition and drift detection, while compact fixtures are the narrower maintainable place to test serializer-specific behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a bounded test-performance cleanup with no user-facing or runtime behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored test-only refactor changes no user-visible behavior; focused-test timing and the dedicated full contract CI lane are the relevant evidence.

Label justifications:

  • P3: This is a bounded test-performance cleanup with no user-facing or runtime behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored test-only refactor changes no user-visible behavior; focused-test timing and the dedicated full contract CI lane are the relevant evidence.

Evidence

What I checked:

  • Focused test refactor: The branch replaces the suite-wide rendered SDK fixture with two typed in-memory module surfaces, retaining serializer, artifact, declaration-stripping, and aliased-export assertions. (src/plugin-sdk/api-baseline.test.ts:26, 0b0e02672c84)
  • Canonical full-render owner: The production wrapper renders all canonical public entrypoints before writing or comparing API contract artifacts, so full composition remains outside this narrow serializer suite. (src/plugin-sdk/api-baseline.ts:550, 38a5390e2e29)
  • Dedicated CI gate: The generator's check mode fails when its full render differs from committed contract records, and the CI workflow runs that command in its own Plugin SDK API-baseline lane. (scripts/generate-plugin-sdk-api-baseline.ts:13, 38a5390e2e29)
  • Exact-head contract result: The supplied check rollup reports check-plugin-sdk-api-baseline successful for the PR head, independently exercising the retained full-render contract path. (0b0e02672c84)
  • Current baseline provenance: Current renderer and baseline-suite code dates to the same feature introduction; blame attributes the full-render owner path to joshavant. (src/plugin-sdk/api-baseline.ts:403, a2ca2ac8e711)
  • Pinned compiler dependency: The changed test directly uses TypeScript compiler APIs; the repository pins TypeScript 6.0.3, although this read-only checkout has no installed dependency sources for a second direct type-source pass. (package.json:2072, 38a5390e2e29)

Likely related people:

  • joshavant: Introduced the current API-baseline renderer and test suite that own the full-render and serialization boundaries. (role: current baseline implementation author; confidence: high; commits: a2ca2ac8e711; files: src/plugin-sdk/api-baseline.ts, src/plugin-sdk/api-baseline.test.ts, src/plugin-sdk/api-baseline-declaration-print.ts)
  • steipete: Recent history includes baseline ordering, private-type, CI-contract, and hotspot work in this exact area. (role: recent Plugin SDK contract contributor; confidence: high; commits: e09b0ebfbaa3, 1b4a60be15a1, c1dab6a5e021; files: src/plugin-sdk/api-baseline.ts, src/plugin-sdk/api-baseline.test.ts, .github/workflows/ci.yml)

Rank-up moves

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

  • Wait for the remaining exact-head CI checks to finish green before merging.

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.

Copy link
Copy Markdown
Contributor Author

Land-ready evidence on exact head 0b0e02672c848dfb4eb98fcec17463cc1364934b:

  • Hosted CI run 31559012451: green on the exact head.
  • Hosted api-baseline.test.ts: 18/18 passed in 6.02s versus the prior 57.00s hosted baseline, an 89.4% reduction.
  • Local focused proof: Vitest 62.89s → 6.11s (90.3% faster); wall 69.77s → 12.79s (81.7% faster); peak RSS 4,049,140 KiB → 722,176 KiB (82.2% lower).
  • The independent whole-repository pnpm plugin-sdk:api:check gate passed unchanged (OK docs/.generated/plugin-sdk-api-baseline).
  • Targeted oxfmt, oxlint, changed-lane classification, git diff --check, and TruffleHog passed.
  • Production LOC: +0/-0. Test LOC: +49/-101. Test count remains 18.

The initial CodeQL infrastructure attempt failed downloading its bundle because of the runner's self-signed certificate; failed-job rerun 31559012402 passed without a code change. ClawSweeper found no actionable defects; its only rank-up move was to wait for exact-head CI, now satisfied.

@steipete
steipete merged commit b024f01 into main Aug 12, 2026
192 of 194 checks passed
@steipete
steipete deleted the perf/plugin-sdk-api-baseline-tests branch August 12, 2026 03:20

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

2 participants