Skip to content

go/shadow - #956

Closed
jdx wants to merge 2 commits into
go/generatefrom
go/shadow
Closed

go/shadow#956
jdx wants to merge 2 commits into
go/generatefrom
go/shadow

Conversation

@jdx

@jdx jdx commented Aug 17, 2026

Copy link
Copy Markdown
Owner

Stack created with GitHub Stacks CLIGive Feedback 💬


Note

Low Risk
Mostly generated data, docs, and CI guards; runtime behavior changes only if the checked-in tables or emitter output differ from expectations.

Overview
Introduces a mise-scale Go shadow (go/internal/shadow/mise): checked-in binding tables from benches/mise.usage.kdl and tests that exercise real command lines, default-subcommand resolution, dense unique Keys, and zero-allocation parsing at full CLI size.

Adds mise run gen-go to regenerate tables.go, and extends the test workflow so render, gen-shadow, and gen-go must all leave a clean git tree.

go/README.md now documents usage generate go / //go:generate, the shadow package, updated corpus binding counts (122 binding / 30 post-binding skipped), and drops the generator from “what is missing.”

Reviewed by Cursor Bugbot for commit dcd3446. Bugbot is set up for automated code reviews on this repo. Configure here.

jdx and others added 2 commits August 17, 2026 01:36
…ft unnoticed

The generator landed in the commit before this one with snapshot tests over small
fixtures, which prove it emits what it meant to and nothing about whether the
result works. This is the other half: mise's committed spec, generated into
`go/internal/shadow/mise`, checked in, and parsed against.

Checked in rather than built by the test, for the two reasons the Rust shadows
are: a reviewer can read the diff when the emitter's vocabulary changes, and CI
runs `mise run gen-go` and fails if regenerating produces one. A change to the
generator that nobody meant now has to be committed rather than discovered.

mise is the fixture because it is the largest usage CLI there is — 211 commands,
711 flags, 128 positionals, four deep — and because every shape that has been
awkward to express came from it. The cases are invocations out of its own docs,
hand-written on purpose: what the generator produces is only worth checking if
it parses the words users actually type. They cover the `[ARGS]… [-- ARGS_LAST]…`
split that made the Rust derive's validation wrong, a hidden alias selecting a
command, and a root global reaching a command two levels down.

Two properties are measured here rather than at fixture scale, because scale is
what would break them:

Keys are unique and dense. Generated code dispatches on a Key, so two entries
sharing one would bind the wrong field. The Rust derive hashes its way around
this because two macro expansions cannot see each other; a generator sees the
whole spec and can count, so a collision would be inexcusable rather than
unlucky — and this checks it across all 989 entries.

A parse still allocates nothing. A scope lookup that collected flags into a
slice, or a walk that built one per token, is invisible on a spec with four flags
and obvious on one with 711. 110ns and 0 allocations for `mise use -g node@20`.

One case pins a hole rather than a property: `run --wat` is `unexpected_arg`,
because mise's spec gives `run` no positional at all — it clears them and adds
`mount run="mise tasks --usage"`, so task names come from running that, and
binding does not resolve mounts. When mounts are answered that case changes, and
pinning it means it changes loudly.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…t wrong

The one-line diff is the whole point of checking this file in: `DefaultSubcommand`
went from `cmdOciRun` to `cmdRun`, which is what the fix in the commit before this
one produces. A reviewer reading the generated diff is how the bug was found, and
regenerating is how the fix is shown to be real.

Also pins it as a test. Nothing in the parse of an ordinary command line shows the
difference — `mise build` reports `unexpected_arg` either way, because mise's spec
gives `run` no positional and task names come from a mount — so the pointer is
asserted directly, against `cmdRun` and specifically not against `cmdOciRun`, the
one a whole-tree search used to win with.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 18dfd43e-10a1-49a8-a243-e97f1b061e9c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

jdx commented Aug 17, 2026

Copy link
Copy Markdown
Owner Author

Closing: gh stack submit re-proposed this branch after #931, #932 and #943 had already merged, so this is a duplicate of work that is on main. The two PRs that carry new work — #958 and #959 — are being rebased onto main and will remain open.

This comment was generated by Claude Code.

@jdx jdx closed this Aug 17, 2026
@greptile-apps

greptile-apps Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds a checked-in Go parser shadow generated from mise’s specification and extends CI to verify that regeneration is reproducible.

  • Adds generated tables for mise’s command, flag, and argument tree.
  • Adds real-command-line, key-integrity, default-subcommand, allocation, and benchmark coverage.
  • Documents Go table generation and updates the Go implementation status and conformance figures.
  • Adds gen-go to mise tasks and the generated-diff CI check.

Confidence Score: 5/5

The PR appears safe to merge with no actionable correctness, security, or build failures identified.

The generated fixture’s inspected parser relationships match the source spec, its tests follow existing parser contracts, and the new CI task uses the repository’s established generation setup.

Important Files Changed

Filename Overview
go/internal/shadow/mise/tables.go Adds generated static argv tables for mise; the inspected high-risk relationships and argument modes align with the source specification.
go/internal/shadow/mise/parse_test.go Adds focused behavior, table-integrity, allocation, and benchmark coverage without an identified correctness issue.
.github/workflows/test.yml Extends the existing generated-artifact check to regenerate Go tables before asserting a clean working tree.
mise.toml Adds a reproducible Go-table generation task using the repository’s established build and executable-resolution pattern.
go/README.md Documents generated-table usage, updated conformance status, and the new mise-scale shadow fixture.

Reviews (1): Last reviewed commit: "fix(go): regenerate mise's tables, and p..." | Re-trigger Greptile

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