Repository navigation
feat(history): add a symbolic history evaluator with Verus proofs - #985
Draft
Lef Ioannidis (elefthei) wants to merge 4 commits into
Draft
Lef Ioannidis (elefthei) wants to merge 4 commits into
Lef Ioannidis (elefthei) wants to merge 4 commits into
Conversation
Step mode suspends after every Continue. handle_instruction_suspend advanced the top frame's pc whenever frame.pc <= self.pc, so after CallRule pushed a callee laid out before its caller, the callee frame's entry pc was bumped past RuleInit and the rule body ran from the wrong instruction. Only an explicit InstructionOutcome::Suspend now advances the frame pc; the Continue arm already did, and a pushed callee frame owns its pc. - tests/rvm/vm/suites/call_rule.yaml: call_rule_callee_laid_out_before_caller
…n unimplemented) - Added the history-syntax and junco-core crates (rule syntax, portable flat sources, flattening, validation); LimitError moved into junco-core and is re-exported at its old path. - With feature `history`, the RVM compiler lowers history.require/forbid to one row of Program::history_tables[0] plus one HistoryStep; executing it fails with the fatal HistoryUnimplemented (HistoryFeatureDisabled without the feature). - Program format version 7 is additive: HistoryStep is the last Instruction variant and history data lives in a trailing binary section, so version-6 blobs still decode completely. - CI runs the history tests and the std,arc,history feature subset; docs cover the syntax, HistoryStep and the v7 layout.
…ator - Add the history-store crate: interned identities and committed histories with revisions. - Add junco-core lower_flat and the runtime reference evaluator (depth 256, 65536 nodes). - RegoVM::attach_history/set_history_input; HistoryStep pins a revision at its first dispatch, folds at most batch_size events per dispatch and repeats at the same PC. - Replace HistoryUnimplemented with typed fatal history errors; recheck the revision on resume and completion. - load_program always cancels a suspended execution. - Port the history_table suite; CI tests history-store.
Lef Ioannidis (elefthei)
force-pushed
the
upstream/history-3-symbolic
branch
from
November 21, 2026 04:49
3775dbd to
8d45f8a
Compare
- Add history-semantics (normalization, symbolic derivatives, cursor-batched RuleRuntime) and run it from HistoryStep. - history-store gains hash-consed graphs (hashconsius 0.1.4, bumpus 0.1.2), bounded caches and the typed Store<E>/History<E> views. - Restore the Verus specs and proofs; verus.yml verifies the default, history and no-default history,arc,std configurations. - Keep the reference evaluator as a test-util oracle; the exhaustive word test checks it against the regex oracle and the RVM. - Balance generated alternations in history_tables tests under the parser's expression depth limit.
Lef Ioannidis (elefthei)
force-pushed
the
upstream/history-3-symbolic
branch
from
November 21, 2026 05:30
8d45f8a to
a2ee965
Compare
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.
The 4,096-node rule graph in
tests/history_table.rsround-trips in #984, but the reference evaluator returnsGraphBudgetwhen it unfolds that graph into a tree. It caps each expansion or derivative at depth 256 and 65,536 nodes.HistoryStepnow evaluates the same rule on a graph that preserves shared subexpressions. The Rego syntax, v7 program format and nativeHistoryStore/RegoVMAPI stay the same.The new
src/history-semanticscrate normalizes rules, computes symbolic derivatives on hash-consed graphs and advances aRuleRuntimecursor one batch at a time. It starts at the declared root even if that isn't the last node, without unfolding unused nodes. The crate is publishable and exposesCompiledRule,ValidatorandTracePolicyfor typed callers.src/junco-coreaddsbitsand the numerickernel; its unverifiedreferenceevaluator from #984 now builds only undertest-util.rvm::vm::history_tablesdrivesRuleRuntime. VMs attached to the sameHistoryStorewrapper share bounded caches, keyed by program, for compiled rule graphs and retained per-history prefixes. An active continuation pins its graph. If a batch fails, its cursor stays where the batch began. If a lazily built graph exceeds its 100 KiB payload budget, the rule gets one retry per decision on a fresh graph.Store and dependencies
src/history-storeaddsgraph,cacheandkeyedmodules and typedStore<E>andHistory<E>views. Its graph arenas usehashconsius 0.1.4andbumpus 0.1.2from crates.io. Both crates are MIT-licensed and verified with Verus.hashconsiusalso pinsbumpus =0.1.2, so Cargo resolves one copy. Locking usesparking_lotwithstdandspinwithout it.The root
historyfeature enables the store and semantics runtimes;cacheforwardshistory-semantics?/cache. The history crates also uselruandsmallvec. Thesmallvecpin (=1.16.2) takes the workspace lockfile back from 1.16.4.history-syntaxusesfrunk_corefor event coproducts. The binding lockfiles include the new path crates.What Verus checks
When evaluation succeeds, the Boolean agrees with the source rule on the pinned history prefix. The proofs cover lowering owned rules, encoding their constants, the numeric compiler and evaluator, agreement between typed and numeric histories, and reuse of cached decisions.
src/verify/history_host.rschecks Regorus's construct, resume and advance calls under host limits. It assumes the specifications forExecutionTimer,monotonic_nowand the memory-limit checks. Regorus's Rego-to-rule lowering and native byte interner are outside that proof.The root crate and all four history crates set
[package.metadata.verus] verify = true. About 22,000 of the history crates' 74,000 lines are injunco-core/src/{spec,verify}andhistory-semantics/src/{spec,verify}; runtime modules also contain inlineverus!contracts and proofs. None of the history proofs usesrc/verify/value_{assumptions,numeric,specs}.rsor the matchingValue,Array,ObjectandSetview annotations from the source branch, so those changes aren't in this PR..github/workflows/verus.ymluses Verus0.2026.10.04.426d8b0. The root and all four history crates pinvstdto=0.0.0-2026-10-04-0306. The Verus release selects Rust 1.98.1 for the proof job; normal builds stay on 1.95.0. The job runscargo verus verify --lockedwith defaults, with--features historyand with--no-default-features --features history,arc,std. Inlib.rs,#![cfg_attr(verus_keep_ghost, feature(allocator_api))]enables the allocator API during verification.RegoVMderivesDebugonly outside Verus builds because the history records have no ghostDebugmodel.Tests
For every generated word,
tests/history_table.rscompares the split-word regex oracle,junco_core::referenceon the loweredFlatPair<u64>, and the RVM. It runs the RVM in both modes at batch sizes 1, 2, 64, 256 and 1024.typed_semantics_and_rego_history_rules_agreecompares the typedStore/CompiledRuleAPI with compiled Rego in both modes, including requests that don't match a constant in the head.staging_requires_attachment_and_each_domain_membershipchecks that the byte-domain facade rejects IDs issued only by a typedStore<E>.CI runs
cargo test -p history-syntax -p junco-core -p history-store -p history-semantics --features history-semantics/test-util,history-store/test-util. This covers thehistory-semanticstests, graph, cache and typed-store tests inhistory-store, thehistory-syntaxDSL tests and the reference evaluator's unit tests.Stacked on #984, after #982 and #983. Review the last commit.