Skip to content

feat(sv)!: solve scalar class constraints during randomize - #2194

Merged
mergify[bot] merged 1 commit into
masterfrom
stack/tignear/feat/aplite/solve-scalar-class-constraints-randomize--0bbc4db8
Oct 26, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
stack/tignear/feat/aplite/solve-scalar-class-constraints-randomize--0bbc4db8

Conversation

@tignear

@tignear tignear commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Connect named scalar class constraints to Aplite through a serializable heap program. Support 1-64 bit two-state integer comparisons, Boolean and bitwise operators, and addition/subtraction/multiplication with SV context sizing. Inherit constraints and replace same-name blocks in derived classes, including calls through base handles.

Read state and random modes after pre_randomize. Apply a complete satisfying assignment atomically; proved UNSAT returns 0 without changing random fields or calling post_randomize. Restore temporary member selections on failure. Check-only calls consume no object random draws. Resource exhaustion raises a heap fault instead of masquerading as UNSAT.

Use seeded SAT search for the initial integration. This avoids hash-cell acceptance failures and makes no uniformity claim; distribution work is tracked in #2187. Constrained enums/randc, inside, dist, solve-before, inline with, conditional/soft/foreach constraints and external/static blocks remain diagnosed as unsupported. The publishing consumer requires the independent aplite 0.1.0 release before publishing celox-heap.

Validation: 129 randomization regressions across native, Cranelift, Wasm and parallel backends; 25 heap, 832 analyzer and 132 syntax tests plus doctests; focused failure/replay and unsupported-form tests; affected-crate clippy and rustdoc with warnings denied; NAPI cargo check; formatting and package/release guards. Verilator passes scalar mode/selection and width/inheritance cases. Retained evidence records its post_randomize-on-UNSAT disagreement and Icarus unsupported constraint declarations, with narrow tool-specific exclusions and unchanged Celox assertions. No local release build.

BREAKING CHANGE: ObjectOp and heap Fault gain constraint randomization variants.

Depends-On: #2193

@tignear

tignear commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor Author

This pull request is part of a Mergify stack:

# Pull Request Link
1 perf(aplite): reduce affine XOR rows before bit blasting #2183
2 feat(aplite): generate approximate projected sample batches #2184
3 feat(sv-syntax)!: retain named constraint expressions #2193
4 feat(sv)!: solve scalar class constraints during randomize #2194 👈

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T19:11:17.759133Z 40976fd New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@tignear

tignear commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Revision history

# Type Changes Reason Date
1 initial 7ac70a1 2026-10-26 18:13 UTC
2 content 7ac70a1 → 2a5c1ce Record the four newly reviewed external-tool exclusions in retained class reports; retained-report validation requires matching rows. Passing historical evidence is unchanged. 2026-10-26 18:13 UTC
3 content 2a5c1ce → e49026c Fix #2194 CI type inference ambiguity in the zero-width string formatting test after serde_json becomes a transitive dependency. 2026-10-26 18:38 UTC
4 content e49026c → 40976fd Fix #2194 CI dependency-scope exclusions and publication ordering after Aplite and heap become runtime dependencies; validate all repository scripts. 2026-10-26 19:08 UTC

@tignear
tignear force-pushed the stack/tignear/feat/aplite/solve-scalar-class-constraints-randomize--0bbc4db8 branch from 7ac70a1 to 2a5c1ce Compare October 26, 2026 18:13
@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 26, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2a5c1ced47

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +199 to +201
match serde_json::from_slice::<crate::randomization::Program>(
self.string(b as Handle),
) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Align program deserialization depth with accepted expressions

For sufficiently deep expressions accepted by the binder, the generated program fails at runtime because serde_json::from_slice uses its default 128-level recursion limit. For example, a constraint comparing a left-associated sum of 64 occurrences of an 8-bit field against 32'd0 stays within the binder's 64-level expression limit, but the externally tagged Binary objects and inserted Resize objects exceed the JSON limit. A satisfiable constraint therefore raises ConstraintRandomization before reaching the solver. Align the accepted expression depth with the serialized representation, or deserialize compiler-generated programs using a suitably bounded higher limit.

Useful? React with 👍 / 👎.

Comment on lines +870 to +871
let block_name = block.name.spelling.clone();
constraints.retain(|(name, _)| *name != block_name);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Normalize constraint names before replacing inherited blocks

When a base constraint and its derived override use escaped and unescaped spellings of the same identifier, this comparison retains both blocks instead of replacing the inherited one. For example, a base block named \bounds requiring x == 1 and a derived block named bounds requiring x == 2 make derived-object randomization incorrectly return UNSAT. The parser preserves the backslash in Name.spelling, while instances::normalize_identifier explicitly handles these equivalent identifiers elsewhere in class binding. Normalize the block name before storing and comparing it.

Useful? React with 👍 / 👎.

@tignear
tignear force-pushed the stack/tignear/feat/aplite/solve-scalar-class-constraints-randomize--0bbc4db8 branch from 2a5c1ce to e49026c Compare October 26, 2026 18:39
Connect named scalar class constraints to Aplite through a serializable heap program. Support 1-64 bit two-state integer comparisons, Boolean and bitwise operators, and addition/subtraction/multiplication with SV context sizing. Inherit constraints and replace same-name blocks in derived classes, including calls through base handles.

Read state and random modes after pre_randomize. Apply a complete satisfying assignment atomically; proved UNSAT returns 0 without changing random fields or calling post_randomize. Restore temporary member selections on failure. Check-only calls consume no object random draws. Resource exhaustion raises a heap fault instead of masquerading as UNSAT.

Use seeded SAT search for the initial integration. This avoids hash-cell acceptance failures and makes no uniformity claim; distribution work is tracked in #2187. Constrained enums/randc, inside, dist, solve-before, inline with, conditional/soft/foreach constraints and external/static blocks remain diagnosed as unsupported. The publishing consumer requires the independent aplite 0.1.0 release before publishing celox-heap.

Validation: 129 randomization regressions across native, Cranelift, Wasm and parallel backends; 25 heap, 832 analyzer and 132 syntax tests plus doctests; focused failure/replay and unsupported-form tests; affected-crate clippy and rustdoc with warnings denied; NAPI cargo check; formatting and package/release guards. Verilator passes scalar mode/selection and width/inheritance cases. Retained evidence records its post_randomize-on-UNSAT disagreement and Icarus unsupported constraint declarations, with narrow tool-specific exclusions and unchanged Celox assertions. No local release build.

BREAKING CHANGE: ObjectOp and heap Fault gain constraint randomization variants.

Change-Id: I0bbc4db8256385015e506817f5ea46fd3fcdd006
@tignear
tignear force-pushed the stack/tignear/feat/aplite/solve-scalar-class-constraints-randomize--0bbc4db8 branch from e49026c to 40976fd Compare October 26, 2026 19:08
@mergify mergify Bot added the queued Mergify queue entry label Oct 26, 2026
@mergify

mergify Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 1 hour 27 minutes 23 seconds in the queue, including 28 minutes 24 seconds running CI.

Required conditions to merge

Base automatically changed from stack/tignear/feat/aplite/retain-named-constraint-expressions--c0c2bccf to master October 26, 2026 20:45
@mergify
mergify Bot merged commit fa8fae0 into master Oct 26, 2026
26 of 27 checks passed
@mergify
mergify Bot deleted the stack/tignear/feat/aplite/solve-scalar-class-constraints-randomize--0bbc4db8 branch October 26, 2026 21:14
@mergify mergify Bot removed the queued Mergify queue entry label Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-ready Request merging through Mergify after required checks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant