feat: plan 07 codegen - #22
Merged
Merged
Conversation
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements plan 07 (plans/07-codegen.md): two new crates,
nash-ir(Core IR) andnash-codegen(Can -> Core -> UPLC), plus the minimum Plan 09 hooks needed to run validators end to end (nash build). Fourteen commits: three research docs, one design doc, two frontend commits, three codegen commits, one build commit, two diagnostic fixes, two snapshot-hygiene commits, one changeset commit.Versioning: seven changesets. Minor bumps for
nash-ast,nash-can,nash-constrain,nash-solve,nash-plutus,nash-ir,nash-codegen,nash-driver,nash-report,nash-cli; patch fornash-nitpickandnash-parse. See.sampo/changesets/codegen-*.mdanddiagnostic-*.md.Design (
docs(codegen): define specialization identity,docs/research/*)docs/codegen.mdspecifies specialization identity: lexical definition identity + executable trait evidence + demanded runtime layouts. Complete substitutions are metadata, not key material. Layout demand propagates to a fixed point. Codegen diagnoses growing layouts as a resource error rather than looping. Trait-free polymorphic recursion through opaque values gets one body withTy::Erased.Frontend (
feat(solve),feat(frontend))assert,fail,todo,traceandcomptimecanonicalize and type-check with source locations, dependency tracking and nitpick coverage.Codegen (
feat(codegen): add executable Core foundation,feat(codegen): specialize source into UPLC)nash-ir: Core IR with explicit representations (Big/Const/Term/Erased), builders, exhaustive traversal helpers, pretty printer.nash-plutus: UPLC text printer with lexical DeBruijn names, checkedName -> DeBruijn, completeDefaultFunctioninventory, Flat encoding, single-wrapped CBOR.nash-codegen: Can -> Core lowering (can_to_core), lazy one-level ADT layout conversion (ty_of), complete Builtin mapping with force/arity checks, shared Maranget decision trees for little ADTs / tuples / native lists / Data patterns, checked Data casts with recursive validation, nominal records and labeled constructor layouts with scoped accessor sharing (decoders stay lazy in unselected branches), self and mutual recursion rewriting with static-argument handling, evidence normalization (Given,Super, defaults,ReflexiveLift,StructuralEq), layout-demand analysis, finite specialization worklist with explicit body/type-depth and work limits, trace levels, bounded comptime evaluation, reachable program assembly.Build (
feat(build): emit validator scripts and close plan 07)build_with(db, graph, origins, finish)retains solved module tables until the finish callback returns; failed frontend builds do not invoke it.check_main_parametersruns after solving; validator entry-point diagnostics added.nash build [PATH] --out build --trace-level silent|compact|verbose --compiler-tracescompiles every validator module to Plutus V3.uplc,.flatand.cbor(one CBOR byte string wrapping the Flat bytes). No optimizer yet.examples/vesting/:Vestingand parameterizedVestingParamwith a test-onlyCardano.Txcontext. Fixtures cover successful and failed claims and cancellations and record unoptimized budgets: claim 6,719,849 CPU / 28,411 mem; cancel 6,909,610 / 29,381; parameterized 6,933,057 / 29,113 and 6,957,610 / 29,681.plans/09-validators-build.mdrecords what was brought forward; Plan 09 is not marked complete.Diagnostics (
fix(report),fix(cli),test: …)snapshot_hygiene.rschecks snapshot metadata.Deferred
--optimize: Plan 08.BigFieldnode for optimizer reasoning about Big record access, if needed.Test plan
cargo fmt --all -- --checkcargo clippy --all-targets --all-features -- -D warningscargo insta test --workspace --check --unreferenced reject— 3,180 passed, 0 failed, 3 ignored; no pending or unreferenced snapshotscargo run -p nash-cli -- check tests/core— 23 modules, 215 declarationscargo run -p nash-cli -- build examples/vesting --trace-level verbose --compiler-traces— 25 modules,Vesting603 Flat bytes,VestingParam608 Flat bytes, all six output files writtencrates/nash-codegen/tests/vesting.rsandcrates/nash-driver/tests/vesting.rs: eight fixture outcomes, Flat/text round trips, rejection ofTermvalidator parametershttps://claude.ai/code/session_01ScuAeUCfNGXAznfEEKDH1X