Skip to content

feat: verify runtime slice and subtraction operands by proven range - #931

Merged
flyingrobots merged 8 commits into
mainfrom
feat/proven-dynamic-slice
Oct 21, 2026
Merged

flyingrobots merged 8 commits into
mainfrom
feat/proven-dynamic-slice

Conversation

@flyingrobots

Copy link
Copy Markdown
Owner

Summary

Echo's lowerer, verifier and native helper checker accepted core.bytes.slice and core.integer.subtract only with literal operands, so Jim's isUtf8(slice(text, 0, at)) with a runtime offset could not verify. This implements Edict's existing proven-range semantics, independently in each component, without weakening verification.

  • Rules. A slice needs start <= end and end <= len(bytes) over that same operand, which is its actual length, not its declared maximum. A subtraction needs right <= left. An order holds for equal terms, a zero right side, ordered constants, an input constraint, or an earlier conjunct of the same all. Conditional predicates, negations, later conjuncts and helper callers prove nothing. Terms are compared by canonical encoding within each component's work ceiling.
  • Read route. The bounded-read relations type both calls, so a read guard at <= len(text) && isUtf8(slice(text, 0, at)) lowers and verifies. Runtime all short-circuits, so an out-of-range at makes the guard false and the program takes its authored path. A program without the guard is refused before installation.
  • Types. Slices are typed Bytes<max=N> (the operand's maximum, no minimum), as Edict types them. Previously a literal slice was narrowed, so isUtf8<Bytes<max=N>> of a literal slice was refused.
  • Function-less Cores. A Core without a function table that contains either call is now judged in full, including its declared budget, as addition already was. Previously it skipped that judgment, so an unproven runtime slice was not refused before installation.

Finding: retained leaf-slice budget

Jim's compiler-produced leaf-slice package (crates/warp-core/tests/fixtures/edict-byte-slice) declares a 1,048,576-step budget. Echo's worst-case charge for slicing its whole 1 MiB operand is 1,048,669 steps, 93 over, so both components now refuse that retained package. Edict's static cost model accepted the budget; Echo's says a maximal slice would exhaust it at runtime. The conformance tests here run the same program with a 2 MiB step budget: it is accepted, and refused once its len constraint is dropped. Reconciling the two cost models is follow-up work. The runtime evaluation test for that fixture is unchanged and passes.

Tests

  • warp-core edict_pure::proven_range_tests (3): admitted guarded prefix, zero and end offsets, guarded suffix, guarded and literal subtraction; refused unguarded, guard after use, guard on another operand, guard on another offset, guard by declared capacity, disjunctive (negated) guard, guard in a conditional, guard in a sibling branch, unguarded, reversed and underflowing subtraction; runtime boundary results at offsets 0 to 4 and u64::MAX, with out-of-range offsets returning the authored result rather than failing.
  • Lowerer and verifier source_functions::proven_ranges (3): the same cases in both judgments, plus an intent-level subtraction proven by an input constraint and refused without it.
  • bounded_read::source_functions::slice (3): guarded runtime slice of a read fact lowers and verifies; unguarded and late-guard forms refused by both.
  • pure_relation (2): Jim's compiler-produced leaf slice is accepted by both when proven by its input constraints. Without its length constraint, the lowerer refuses it, and so does the verifier independently, against an accepted rebinding control.
  • Existing suites pass: lowerer, verifier, wesley-gen, warp-core lib (917) and every edict_* integration test.

Component promotion follows from this PR's det-gates candidates.

Stacked on #929. Refs flyingrobots/amblicit#269.

Echo's lowerer, verifier and native helper checker accepted
core.bytes.slice and core.integer.subtract only with literal operands,
so Jim's isUtf8(slice(text, 0, at)) with a runtime offset could not
verify. Each now implements Edict's proven-range rules independently: a
slice needs start <= end <= len(bytes) over that same operand, a
subtraction needs right <= left, and an order holds for equal terms, a
zero right side, ordered constants, an input constraint or an earlier
conjunct of the same `all`. Conditional predicates, negations, later
conjuncts and helper callers prove nothing.

The bounded-read relations type both calls, so a read guard such as
`at <= len(text) && isUtf8(slice(text, 0, at))` verifies; short-circuit
evaluation sends an out-of-range offset down the authored path. Slices
are typed Bytes<max=N> as Edict types them, so isUtf8 of a literal slice
type-checks. A Core without a function table that contains either call
is now judged in full, including its budget, as addition already was.

Refs flyingrobots/amblicit#269
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 33 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: flyingrobots/echo/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: db2b572d-9325-4b3e-b21a-1f01f10a45b3
📥 Commits

Reviewing files that changed from the base of the PR and between d36b56d and 6e39916.

⛔ Files ignored due to path filters: 6
  • crates/echo-wesley-gen/assets/v1/edict-provider/package/v1/components/lowerer.echo-dpo.component.wasm is excluded by !**/*.wasm
  • crates/echo-wesley-gen/assets/v1/edict-provider/package/v1/components/verifier.echo-dpo.component.wasm is excluded by !**/*.wasm
  • schemas/edict-provider/components/v1/lowerer.echo-dpo.component.wasm is excluded by !**/*.wasm
  • schemas/edict-provider/components/v1/verifier.echo-dpo.component.wasm is excluded by !**/*.wasm
  • schemas/edict-provider/package/v1/components/lowerer.echo-dpo.component.wasm is excluded by !**/*.wasm
  • schemas/edict-provider/package/v1/components/verifier.echo-dpo.component.wasm is excluded by !**/*.wasm
📒 Files selected for processing: 26
  • CHANGELOG.md
  • crates/echo-edict-provider-lowerer/src/executable_operation/bounded_read/relation/types.rs
  • crates/echo-edict-provider-lowerer/src/executable_operation/source_functions.rs
  • crates/echo-edict-provider-lowerer/src/executable_operation/source_functions/order.rs
  • crates/echo-edict-provider-lowerer/src/executable_operation/source_functions/unsigned_addition.rs
  • crates/echo-edict-provider-verifier/src/executable_operation/bounded_read/audit/types.rs
  • crates/echo-edict-provider-verifier/src/executable_operation/source_functions.rs
  • crates/echo-edict-provider-verifier/src/executable_operation/source_functions/order.rs
  • crates/echo-edict-provider-verifier/src/executable_operation/source_functions/unsigned_addition.rs
  • crates/echo-edict-provider-verifier/tests/bounded_read/source_functions.rs
  • crates/echo-edict-provider-verifier/tests/bounded_read/source_functions/slice.rs
  • crates/echo-edict-provider-verifier/tests/pure_relation/mod.rs
  • crates/echo-edict-provider-verifier/tests/source_functions/mod.rs
  • crates/echo-edict-provider-verifier/tests/source_functions/proven_ranges.rs
  • crates/echo-wesley-gen/assets/v1/edict-provider/package/v1/provider-manifest.echo.json
  • crates/echo-wesley-gen/tests/provider_package.rs
  • crates/echo-wesley-gen/tests/provider_package_corpus.rs
  • crates/warp-core/src/edict_pure.rs
  • crates/warp-core/src/edict_pure/functions.rs
  • crates/warp-core/src/edict_pure/proven_order.rs
  • crates/warp-core/src/edict_pure/proven_range_tests.rs
  • docs/topics/GeneratedRules.md
  • schemas/edict-provider/README.md
  • schemas/edict-provider/components/v1/README.md
  • schemas/edict-provider/package/v1/provider-manifest.echo.json
  • xtask/src/provider_lowerer_component.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 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-21T12:43:43.757079Z 50ac6f3 Manual request
ℹ️ 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.

Promotes the byte-identical G4 candidates from det-gates run 39583101692:
lowerer sha256:6aed0c24 (491,504 bytes) and verifier sha256:083096b1
(510,119 bytes). Copies them into both provider packages, refreshes the
manifest component digests, the provider digest
sha256:41a77967 and the manifest raw digest 7e985673 in the package
goldens, and the component READMEs.

Refs flyingrobots/amblicit#269
@flyingrobots

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

…at/proven-dynamic-slice

# Conflicts:
#	crates/echo-wesley-gen/assets/v1/edict-provider/package/v1/components/lowerer.echo-dpo.component.wasm
#	crates/echo-wesley-gen/assets/v1/edict-provider/package/v1/components/verifier.echo-dpo.component.wasm
#	crates/echo-wesley-gen/assets/v1/edict-provider/package/v1/provider-manifest.echo.json
#	crates/echo-wesley-gen/tests/provider_package.rs
#	crates/echo-wesley-gen/tests/provider_package_corpus.rs
#	schemas/edict-provider/README.md
#	schemas/edict-provider/components/v1/README.md
#	schemas/edict-provider/components/v1/lowerer.echo-dpo.component.wasm
#	schemas/edict-provider/components/v1/verifier.echo-dpo.component.wasm
#	schemas/edict-provider/package/v1/components/lowerer.echo-dpo.component.wasm
#	schemas/edict-provider/package/v1/components/verifier.echo-dpo.component.wasm
#	schemas/edict-provider/package/v1/provider-manifest.echo.json
#	xtask/src/provider_lowerer_component.rs
Promotes the byte-identical G4 candidates from det-gates run 39591924108,
built from the merge of feat/byte-count-runtime (named count bounds) with
the proven-range slice and subtraction proofs: lowerer sha256:6271a912
(492,758 bytes) and verifier sha256:5b156096 (509,828 bytes). Refreshes
both package manifests, the provider digest (sha256:ce95e09c), the
manifest raw digest golden, and the component READMEs.
…at/proven-dynamic-slice

# Conflicts:
#	crates/echo-edict-provider-lowerer/src/executable_operation/source_functions/unsigned_addition.rs
#	crates/echo-edict-provider-verifier/src/executable_operation/source_functions/unsigned_addition.rs
#	crates/echo-edict-provider-verifier/tests/bounded_read/source_functions.rs
#	crates/echo-wesley-gen/assets/v1/edict-provider/package/v1/components/lowerer.echo-dpo.component.wasm
#	crates/echo-wesley-gen/assets/v1/edict-provider/package/v1/components/verifier.echo-dpo.component.wasm
#	crates/echo-wesley-gen/assets/v1/edict-provider/package/v1/provider-manifest.echo.json
#	crates/echo-wesley-gen/tests/provider_package.rs
#	crates/echo-wesley-gen/tests/provider_package_corpus.rs
#	schemas/edict-provider/README.md
#	schemas/edict-provider/components/v1/README.md
#	schemas/edict-provider/components/v1/lowerer.echo-dpo.component.wasm
#	schemas/edict-provider/components/v1/verifier.echo-dpo.component.wasm
#	schemas/edict-provider/package/v1/components/lowerer.echo-dpo.component.wasm
#	schemas/edict-provider/package/v1/components/verifier.echo-dpo.component.wasm
#	schemas/edict-provider/package/v1/provider-manifest.echo.json
#	xtask/src/provider_lowerer_component.rs
…ting

Promotes the byte-identical G4 candidates from det-gates run 39600796482,
built from the merge of feat/byte-count-runtime (count judgment gating and
reused addition caps) with the proven-range proofs: lowerer
sha256:b52ec57c (493,449 bytes) and verifier sha256:e1426a80 (510,251
bytes). Refreshes both package manifests, the provider digest
(sha256:e82a973b), the manifest raw digest golden, and the component
READMEs.
@flyingrobots

Copy link
Copy Markdown
Owner Author

@codex review please, focus on the merged judgment gating (add, subtract, slice, count), the combined read fixture helpers, and the promoted component digests

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 50ac6f3c9e

ℹ️ 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".

Base automatically changed from feat/byte-count-runtime to main October 21, 2026 12:52
@flyingrobots
flyingrobots merged commit c1841df into main Oct 21, 2026
44 checks passed
@flyingrobots
flyingrobots deleted the feat/proven-dynamic-slice branch October 21, 2026 13:03
flyingrobots added a commit that referenced this pull request Oct 21, 2026
Brings in count (#929) and proven-range slice and subtraction (#931).
edict_pure::infer and check_predicate keep #921's crate visibility and
take main's proof parameter; the effect instruction relation passes
Proof::none(), so runtime slices and subtractions in effect programs
still need literal operands until effect programs carry their proofs.
Provider components and goldens take main's set until re-promotion.
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