Skip to content

refactor: simplify generation and runtime - #182

Merged
samzong merged 1 commit into
mainfrom
refactor/simplify-codebase
Sep 16, 2026
Merged

samzong merged 1 commit into
mainfrom
refactor/simplify-codebase

Conversation

@samzong

@samzong samzong commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

Lathe repeated declaration rendering, parameter conversion, workflow interpolation, host loading, and spec-copy logic across large files. This change consolidates those paths and separates parsing, schema handling, command construction, request execution, catalog projection, and Skill rendering by responsibility.

  • Replace handwritten Go declaration serializers with one deterministic typed-literal writer; generated CLIs still compile static runtime declarations.
  • Share Swagger/OpenAPI document conversions and spec-file copying, remove impossible GraphQL error propagation, and use existing standard-library and parser helpers.
  • Unify strict/optional host loading, workflow expression scanning, parameter validation and catalog projection while preserving their distinct policies.
  • Reuse test fixtures and assertion helpers; retain existing behavior scenarios and remove one duplicate workflow test.
Measurement Base This PR
Tracked effective LOC (cloc, excluding blank/comment lines) 38,664 34,965
Largest Go file, including tests 2,018 466
Statement coverage 74.7% 76.0%

Net effective reduction is 3,699 lines (9.57%). The requested 30% overall reduction is not met; this PR remains a draft.

Verification

  • make check
  • go test -race -json -coverprofile=.local/simplify-codebase/final-cover.out ./...
  • Regenerated and compiled Petstore, RichAPI and GraphQL examples; each passed __lathe verify --json. Full catalogs, catalog schemas, search results, every command detail and all generated Skill files matched the base revision.
  • Initialized the Go starter, linked the changed runtime, compiled its CLI, and passed __lathe verify --json.
  • Completed a user-scope Skill installation dry-run and an actual project-scope installation in scratch.
  • Compared exported Go declarations against the base: existing public signatures and types are unchanged.

Compatibility

Generated Go formatting changes; compiled declarations, public APIs, catalog schema versions, command surfaces, authentication policy and supported features are preserved. No new dependencies or generated artifacts are committed. The catalog schema source-file reference in the contracts document follows the new file location.

Checklist

  • Tests or focused verification cover the changed surface.
  • User-facing behavior changes are documented.
  • Generated output under internal/generated/, .cache/, and ad-hoc skills/<cli-name>/ directories is not committed.
  • Commits are signed off when this is ready to merge.

Signed-off-by: samzong <samzong.lu@gmail.com>
@codspeed

codspeed Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will improve performance by 35.92%

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 21 improved benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ yaml-large 15.7 ms 10.2 ms +54.77%
⚡ small 203.5 µs 139.2 µs +46.13%
⚡ yaml 5.5 ms 3.8 ms +46.02%
⚡ large 2.6 ms 1.8 ms +44.24%
⚡ BenchmarkFindCatalogCommand 9 µs 6.3 µs +43.4%
⚡ BenchmarkCatalogJSON 3.1 ms 2.2 ms +40.57%
⚡ json-small 275.9 µs 199.8 µs +38.1%
⚡ BenchmarkFormatTableInferredColumns 1,204.2 µs 873 µs +37.94%
⚡ hit 3.8 ms 2.7 ms +37.72%
⚡ miss 3.7 ms 2.7 ms +37.71%
⚡ table 779.9 µs 566.4 µs +37.7%
⚡ large 2.3 ms 1.7 ms +37.67%
⚡ large 1.7 ms 1.3 ms +36.39%
⚡ small 146.3 µs 107.8 µs +35.71%
⚡ small 152.5 µs 112.7 µs +35.34%
⚡ json 1.4 ms 1 ms +33.02%
⚡ BenchmarkParseNormalize 6.5 ms 4.9 ms +32.82%
⚡ json-large 3.3 ms 2.6 ms +24.03%
⚡ small 100.8 µs 81.8 µs +23.25%
⚡ large 1.3 ms 1.1 ms +19.94%
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing refactor/simplify-codebase (83b56ab) with main (1dde095)

Open in CodSpeed

@samzong
samzong marked this pull request as ready for review September 16, 2026 13:24
@samzong
samzong merged commit a6e4f11 into main Sep 16, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant