Repository navigation
Conversation
Signed-off-by: Rodrigo Quelhas <rodrigo_quelhas@outlook.pt>
Plugin Test Summary 1 files 3 suites 1s ⏱️ Results for commit e706c06. ♻️ This comment has been updated with latest results. |
Signed-off-by: Rodrigo Quelhas <rodrigo_quelhas@outlook.pt>
Compactc E2E Test Summary3 106 tests 3 106 ✅ 22m 26s ⏱️ Results for commit e706c06. |
This was referenced Aug 16, 2026
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
Add
compactc --run-hook <file.ss>: load a user Scheme file and call the procedure it defines under the namehookafter every compiler pass, with the raw intermediate representation. The flag threads the file's procedure through thetest-hookargument thatgenerate-everythingalready has (compiler/passes.ss:52), the same plumbing the unit tests use (compiler/test.ss:355). No pass changes, no new files: the diff is the flag incompactc.ssand library visibility in theflake.nixbuild.This implements the hook half of the direction from the 2026-08-12 community call on a language-agnostic contract representation: give a consumer a hook to capture the output of a chosen pass, and let the consumer write its own Scheme processor for it.
Why a hook, not the printed IR
An SDK that wants to execute circuits needs information that the unparsed (printed) form of the IR does not carry: the ledger operations' Impact VM templates (
vm-code), the export table, theexported/pureid flags, the native entries, and the eventemitcode. All of that exists only in process. A hook runs in process, so a consumer-owned processor can serialize whatever its SDK needs, and the project does not commit to any output format or version.Packaging: hooks are enabled by default
Importing the compiler's libraries from loaded code requires
compile-whole-programto keep the libraries visible (libs-visible?), and visibility defeats whole-program pruning. This branch enables it in the default build, so everycompactccan run hooks. The costs, measured on this machine (macOS, Chez 10.3.0):--version, 5-run average--skip-zk, 3-run averageThe time delta is constant across workloads, so it is boot-time registration of the visible libraries, paid once per invocation. Selective visibility would not help:
libs-visible?is a single boolean, and the one library a hook cannot live without,(langs)with the nanopass language definitions, is 6.7 MB of the 12.2 MB of all library objects, so a hypothetical hooks-only subset costs nearly the same. If the size or latency on the default path is unacceptable, the previous commit on this branch packaged visibility as an opt-incompactc-hooksvariant instead, with the default binary unchanged; both forms are in the branch history.The hook contract
The hook receives
(pass-name unparser pretty-formats . pass-output-values)after every pass. A minimal example that reports each exported circuit and its purity:(import (except (chezscheme) errorf) (langs) (nanopass) (utils) (pass-helpers)) (define hook (lambda (pass-name unparse formats . x*) (when (eq? pass-name 'save-contract-info) (nanopass-case (Lloweredemit Program) (car x*) [(program ,src (,contract-type* ...) ((,export-name* ,name*) ...) ,pelt* ...) (for-each (lambda (pelt) (nanopass-case (Lloweredemit Program-Element) pelt [(circuit ,src ,function-name (,arg* ...) ,type ,expr) (printf "circuit ~s exported=~s pure=~s\n" (id-sym function-name) (id-exported? function-name) (id-pure? function-name))] [else (void)])) pelt*)]))))Notes for hook authors, learned while building a real one:
save-contract-inforeturns the analyzedLloweredemitprogram;proof-circuit-name*reaches no hook directly and can be recovered from theLflattenedprogram at the final circuit pass, which runs earlier.(target-directory)from(pass-helpers)names the output directory.Verification
nix build .#compactcsucceeds. The unit suite is a separate step,nix develop --command ./compiler/go:packages.compactcdefines acheckPhasebut never setsdoCheck = true, sonix buildalone does not run it.contract-info.jsonfor the bulletin-board example is byte-identical to a pristine build of the base commit.emitevents,serialize, and a cross-contract call) and produces identical output to an equivalent in-tree pass.Status
Draft for review in this fork before proposing upstream. The companion draft, #16, adds an in-tree flag-gated
analyzed-ir.sexpartifact built on the same analyzed IR. The two are alternative transports for the same consumer, and the upstream discussion can weigh them together.