Skip to content

docs(history): add a host example and Criterion benchmarks - #986

Draft
Lef Ioannidis (elefthei) wants to merge 5 commits into
microsoft:mainfrom
elefthei:upstream/history-4-examples-benches
Draft

Lef Ioannidis (elefthei) wants to merge 5 commits into
microsoft:mainfrom
elefthei:upstream/history-4-examples-benches

Conversation

@elefthei

@elefthei Lef Ioannidis (elefthei) commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

examples/history/main.rs compiles a release policy with two rules. history.require allows a release only if that principal edited the same resource. history.forbid blocks the release if anyone removed the resource. The example interns the paths in an Arc<HistoryStore>, appends the events and attaches the store to a RegoVM.

cargo run --example history --features history prints:

alice releases doc after editing it: allow = true
bob releases doc without editing it: allow = false
alice releases doc after it was removed: allow = false

The root manifest declares the example with required-features = ["history"]. cargo xtask ci-release runs it through run_example.

cargo bench --features history --bench history_table runs the Criterion benchmarks in benches/history_table.rs at batch size 256 on histories of 16, 256 and 4,096 events. The policy [any, {principal == p, action == "edit", resource == r}, any] can accept after one matching edit. star({action == "edit"}) has to check every event in these all-edit histories.

For each policy, the benchmarks time a decision on an unchanged warm prefix, after appending one event to a retained prefix, and after truncation forces a replay from the root. Truncation invalidates the prefix cursor; the graph and successor caches stay warm during replay. Setup, interning and request staging happen before timing. The cases that modify history use iter_batched to keep truncation and appends outside the timer too.

docs/builtins.md links to the example from "Native boundary" and describes the cases under "Benchmarks".

Stacked on #985, after #982, #983 and #984. Review the last commit; it changes no library code.

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.
@elefthei
Lef Ioannidis (elefthei) force-pushed the upstream/history-4-examples-benches branch from 550ac4c to 10df62e Compare November 21, 2026 04:52
- 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.
- examples/history: compile a require/forbid policy, append events to a shared HistoryStore and print three decisions.
- benches/history_table: warm, append-one and invalidated-replay decisions over 16/256/4096 events.
- ci-release runs the example; docs/builtins.md links it and describes the benchmarks.
@elefthei
Lef Ioannidis (elefthei) force-pushed the upstream/history-4-examples-benches branch from 10df62e to 83f6ab4 Compare November 21, 2026 05:32
@elefthei Lef Ioannidis (elefthei) changed the title docs(history): host example and criterion benchmarks docs(history): add a host example and Criterion benchmarks Nov 21, 2026
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.

1 participant