Skip to content

Commit .codegen/cli.json sharded to keep every file under 1MB - #7399

Draft
janniklasrose wants to merge 1 commit into
mainfrom
janniklasrose/shard-cli-json
Draft

janniklasrose wants to merge 1 commit into
mainfrom
janniklasrose/shard-cli-json

Conversation

@janniklasrose

Copy link
Copy Markdown
Member

Changes

  • generate-clijson-post splits genkit's .codegen/cli.json into shards and removes it (the plain file is gitignored):
    • .codegen/index.json: commands without services, plus the ordered service IDs
    • .codegen/schemas/<pkg>.json: 40 files, largest catalog at ~370KB
    • .codegen/commands/<pkg>/<Name>.json: 194 files, largest postgres/Postgres at ~214KB
  • New clijson.Split / clijson.ReadDir (internal/clijson/shard.go) plus a go run ./internal/clijson/split entry point. Shards carry each entry's raw JSON, so the round trip is lossless.
  • Readers take the .codegen directory: clijson.Parse and the cligen/schema tests go through ReadDir; the Python direct generators merge schemas/*.json.
  • Paths updated in Taskfile.yml, update-schema-docs.yml, cligen's --input, .codegen/.gitattributes (eol=lf on shards) and agent docs.

Why

cli.json is 9.7MB. Alternative to #7250 (gzip): shards stay plain text, so spec bumps still produce small, readable git deltas instead of a new ~0.85MB blob each time. References between schemas and services are resolved by name after the full document is reassembled, so sharding doesn't affect them.

Tests

  • shard_test.go: round trip with out-of-order services, stale shard removal, rejection of unknown blocks and IDs/keys without a package, and TestCommittedShardsAreCanonical (re-splitting the committed shards reproduces them byte for byte).
  • The shards reassemble to exactly the original cli.json (also checked independently with jq).
  • task generate-cligen generate-schema generate-direct produce no diff.
  • go test ./internal/clijson/... ./internal/cligen/... ./bundle/internal/schema/..., task fmt checks ws lint pass.

This pull request and its description were written by Isaac.

Alternative to gzipping cli.json. genkit still writes a single ~10MB
.codegen/cli.json; generate-clijson-post now splits it into:

  .codegen/index.json                  commands minus services, plus ordered service IDs
  .codegen/schemas/<pkg>.json          schemas entries for that package
  .codegen/commands/<pkg>/<Name>.json  one service

The largest shard is ~370KB. Shards keep each entry's raw JSON, so the
split is lossless. clijson.ReadDir reassembles the document for all Go
readers via clijson.Parse; the Python direct-engine generators merge
schemas/*.json. TestCommittedShardsAreCanonical fails if the committed
shards drift from what Split produces.

Co-authored-by: Isaac <no-reply@databricks.com>
@github-actions github-actions Bot added the DABs DABs related issues label Nov 8, 2026

This branch has not been deployed

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

Labels

DABs DABs related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant