Skip to content

feat: support field-specific binary constraint files#1483

Open
DavePearce wants to merge 1 commit into
mainfrom
1480-feat-support-field-specific-binary-constraint-files
Open

feat: support field-specific binary constraint files#1483
DavePearce wants to merge 1 commit into
mainfrom
1480-feat-support-field-specific-binary-constraint-files

Conversation

@DavePearce
Copy link
Copy Markdown
Contributor

@DavePearce DavePearce commented Feb 9, 2026

Note

Medium Risk
Bumps the binfile format and changes gob serialization/registration across ASM/HIR/MIR/AIR and assignments, which can break backwards compatibility or cause decode/runtime issues if registrations/config mismatches occur.

Overview
Binary constraint files (.bin) now optionally embed a field-specific, pre-compiled schema (CompiledSchema) alongside the existing MacroHirProgram, and the binfile major version is bumped to 11.

The CLI/schema pipeline is refactored from SchemaStacker.Build() producing in-memory layers to a SchemaStack that carries CompiledSchema blobs; commands (check, trace, inspect, debug, generate, verify) now extract concrete schemas via binfile.ExtractSchema and use AbstractSchema() for propagation.

To support gob encoding/decoding of embedded compiled schemas, the PR adds broad gob registrations for micro/macro programs, AIR/MIR/HIR schema/constraint/term types, micro instructions, and various assignments/gadgets; it also standardizes many internal wrappers and constraint/assignment structs to store/export pointer-backed fields and exported struct members for gob.

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

@DavePearce DavePearce linked an issue Feb 9, 2026 that may be closed by this pull request
Comment thread pkg/ir/hir/constraint.go
@DavePearce DavePearce force-pushed the 1480-feat-support-field-specific-binary-constraint-files branch from 1b2b4cf to d9f90e4 Compare February 9, 2026 21:05
Comment thread pkg/cmd/corset/util/schema_stack.go Outdated
@DavePearce DavePearce force-pushed the 1480-feat-support-field-specific-binary-constraint-files branch from d9f90e4 to 7092f66 Compare March 9, 2026 21:30
Comment thread pkg/cmd/corset/util/schema_stack.go Outdated
Comment thread pkg/test/util/check_legacy.go
Comment thread pkg/test/util/check_legacy.go
@DavePearce DavePearce force-pushed the 1480-feat-support-field-specific-binary-constraint-files branch 2 times, most recently from 2ea4020 to 2102b9a Compare March 11, 2026 22:06
Comment thread pkg/ir/air/constraint.go
Comment thread pkg/ir/hir/schema.go
Comment thread pkg/ir/hir/schema.go
Comment thread pkg/ir/mir/schema.go
Comment thread pkg/ir/hir/schema.go
@DavePearce DavePearce force-pushed the 1480-feat-support-field-specific-binary-constraint-files branch from 65dd955 to ed68256 Compare March 15, 2026 20:50
Comment thread pkg/ir/hir/schema.go
Comment thread pkg/ir/mir/schema.go
Comment thread pkg/cmd/corset/util/schema_stacker.go Outdated
Comment thread pkg/cmd/corset/util/schema_stacker.go Outdated
Comment thread pkg/binfile/compiled.go Outdated
Comment thread pkg/binfile/compiled.go Outdated
Comment thread pkg/binfile/compiled.go Outdated
Comment thread pkg/binfile/compiled.go Outdated
Comment thread pkg/cmd/corset/util/schema_stack.go
@DavePearce DavePearce force-pushed the 1480-feat-support-field-specific-binary-constraint-files branch from 0446a6b to c6006fd Compare March 16, 2026 07:32
Comment thread pkg/cmd/corset/root.go
Comment thread pkg/cmd/corset/root.go
Comment thread pkg/cmd/corset/util/schema_stacker.go Outdated
Comment thread pkg/cmd/corset/util/schema_stacker.go
@DavePearce DavePearce force-pushed the 1480-feat-support-field-specific-binary-constraint-files branch 4 times, most recently from 555a089 to 3563efd Compare March 18, 2026 23:35
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread pkg/cmd/corset/util/schema_stacker.go
This updates the binfile.BinaryFile format to support the embedding of
compiled constraints.  Specifically, it now includes both the top-level
"abstract" constraints, along with an (optional) embedding of the
low-level (e.g. AIR) constraints.  The latter is fixed to a specific
field, whilst the former is not.  Attempting to use the latter under a
different field results in a runtime failure.

The approach to implementing this feature was to replace the existing
encoding for the binfile (which was a mixture of GOB and ad-hoc
translations) with just a GOB encoding.  This required ensuring that
lower-level IRs (MIR/AIR) can be GOB encoded (i.e. since these pathways
were not previously tested).

To ensure that adequate testing is done of this, the test framework
always goes through the gob encoder/decoder to access the underlying
constraints.
@DavePearce DavePearce force-pushed the 1480-feat-support-field-specific-binary-constraint-files branch from 3563efd to b965d40 Compare April 24, 2026 00:11
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.

feat: support field-specific binary constraint files

1 participant