Skip to content

Run and meter effect programs under the v2 shared-read schedule - #1029

Draft
flyingrobots wants to merge 4 commits into
mainfrom
feat/effect-programs-v2
Draft

flyingrobots wants to merge 4 commits into
mainfrom
feat/effect-programs-v2

Conversation

@flyingrobots

Copy link
Copy Markdown
Owner

Closes #1016.

Draft, built family by family (owner-set order). Each family goes RED→GREEN across warp-core, the lowerer and the verifier against a compiler-produced corpus program.

Families

  • 1. Checked integers, min/max (with the Option consumers isSome/unwrap/default needed to observe them) — a4c7f5c
  • 2. v2 effect executor: effect steps and graph reads (shared values between instructions, conversion only at effect boundaries)
  • 3. Identity intrinsics (contentAddress, contentEdgeId, slotEdgeId, attachmentValueDigest)
  • 4. Option constructors, ordered records, fail/attempt
  • 5. Bytes (after amblicit#339 corrects the v2 result-allocation rule)
  • Corpus pin moved to Amblicit main (feat(core): add grant intent obstruction receipt shape #336 reachable list bounds, docs(core): define obstruction receipt boundary #338), then feat(core): add obstruction receipt skeleton #339; Echo's static passes mirror the reachable-bound rule
  • Merge main once, promote components, docs, CHANGELOG
  • ReplaceRange (jedit#410) measured through EffectPackageHost: static bound, runtime charge, elapsed time and peak memory reported separately

Evidence (family 1)

RED, GREEN and calibration are in the commit message. Existing corpus minimums and the v1 copying goldens are unchanged.

Known interim CI state

The lowerer and verifier sources changed, so the provider-component digest checks will fail until the final promotion.

Documentation

The corpus README and the module docs are updated. Canonical docs and the CHANGELOG come with the promotion.

Kind: new feature (echo#1016, family 1 of 5).

Pure modules that require core.cost.shared-reads/v1 may now use the
checked integer calls (checkedAdd/Sub/Mul/Div/Rem), min and max, and the
Option consumers isSome, unwrap and default. All three judges meter them
at their copying charge, as Amblicit's schedule requires:

- warp-core's shared evaluator holds a checked result's presence inline
  (new Shared::Absent/Present) and charges one step per operand cell;
- the lowerer and verifier charge one step per operand cell for the
  integer calls, plus operand and result bytes for the Option consumers.

Option constructors, bytes, identity, ordered records, fail and the
effect route remain refused under v2.

The corpus gains `integers`, an Echo program compiled by the pinned
Amblicit at its minimum (5898 steps, 7691 bytes, 181 output bytes). The
producer now reports the compiler's refusal instead of a bare ceiling
miss. Existing minimums are unchanged.

RED (before the change):
  cargo test -p warp-core --lib shared_reads_tests
    refused at the compiler minimum: UnsupportedProgram (4 failed)
  cargo test -p echo-edict-provider-{lowerer,verifier} --lib shared_reads_tests
    checked_integers_and_min_max_are_judged_at_the_compiler_minimum
    panicked: refused at the compiler minimum
GREEN: warp-core --lib 967 passed; lowerer and verifier all passed;
shared_reads tests 10/10 repeated runs green; corpus --check ok.
Calibration: dropping the Option result bytes from either static rule
fails with "admitted one step less"; overcharging the runtime integer
call fails with "refused at the compiler minimum: StepBudgetExceeded".

Agent-Session: AFC0A5E0-B032-49DC-8B18-CB932831DCC2
Agent-Tool: Claude Code
@coderabbitai

coderabbitai Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • 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

#340

Kind: deliberate behaviour change (echo#1016; the v2 static rules follow the
compiler's corrected schedule).

The shared edict.core-cost/v2 corpus is now produced by Amblicit 26a201e7,
which adds two rules all three Echo judges now follow:

- amblicit#336: a listAppend or listConcat shell is sized by the result's
  provable length when one exists. The lowerer (`reach`) and verifier
  (`bounds`) track list-length bounds through locals, record fields,
  branches, calls and folds, charging a fold round by round until its
  bounds stop changing, with call costs cached by argument bounds.
- amblicit#340: a prelude call that builds a value is charged that value in
  full. The static judges add it for integer operations and the Option
  readers; the runtime now charges a word, a checked result with its
  presence cell and an isSome flag as they are built (cumulative logical
  allocation), and unwrap/default still share their item.

New minimums: reads 22596/63551, fill 9420/87967, nested 24467/220065,
integers 5962/11531, rope 1326335/11721939; matches and every output bound
are unchanged. The v1 copying goldens are unchanged.

RED (bumped corpus, unchanged judges):
  lowerer and verifier shared_reads_tests: 4 failed each:
    fill, nested: "refused at the compiler minimum"
    reads, integers: "admitted one step less"
  warp-core integer_results_are_charged_as_new_values:
    unsigned add left: 128 right: 192
GREEN: warp-core --lib 968 passed; lowerer 94 and verifier 96 passed;
shared_reads 10/10 repeated runs; corpus --check ok; clippy clean.

Agent-Session: AFC0A5E0-B032-49DC-8B18-CB932831DCC2
Agent-Tool: Claude Code
Kind: new feature (echo#1016, family 2 runtime side).

An effect program whose Core requires core.cost.shared-reads/v1 now
prepares and runs under edict.core-cost/v2 instead of being refused:

- edict_effects/execution/shared.rs runs the same instructions with
  shared locals, metering every expression and predicate with the shared
  evaluator. Each effect step (atom read, graph read, emission,
  obstruction) and the intent's input and output keep their copying
  charge exactly; a value crosses into an effect step in canonical form
  and a step's result is shared from then on.
- Preparation refuses, before any work, a program with an operation the
  schedule has no Echo rule for yet (bytes, identity, Option
  constructors, ordered records, fail) in any helper, constraint,
  instruction or result.
- The effect route's typing relation and helper decoding admit the
  capability (typing is schedule-independent); the read route still
  refuses it.

Tests (differential oracle: the same package without the capability):
- edict_effect_package_tests shared_schedule: a read whose require
  fails, a node ensure, structured loops, branches and nesting give the
  same result, obstruction and mutations; byte operations stay refused;
  a repin control proves the refusal is the schedule's.
- public_effect_host_tests: the public graph-read link package, repinned
  with the capability and admitted under its own exact policy through
  EffectPackageHost, reads and links exactly as the copying package over
  six graphs, including all three graph-read obstructions.

RED: before the change every shared package failed to prepare
("package prepares: InvalidPackage"); calibration with the executor
refusing every program fails all six differentials and the graph-read
one ("case 0: output").
GREEN: clippy (all warp-core features, all targets) clean; warp-core
default suite (TMPDIR=/tmp/e1016), the trusted_runtime edict lane and the
pipeline/admission lane all pass.

Agent-Session: AFC0A5E0-B032-49DC-8B18-CB932831DCC2
Agent-Tool: Claude Code
Kind: deliberate behaviour change (echo#1016, family 2 static side).
The lowerer and verifier no longer refuse an effect program whose Core
requires core.cost.shared-reads/v1; they judge it under edict.core-cost/v2,
as warp-core now runs it:

- every expression and predicate in an effect body (basis, constraints,
  let, attempt, loop iterable, branch and require predicates, effect
  inputs, the result) is charged its shared-read cost, with list-length
  bounds kept for the body's lets (amblicit#336);
- an obstruction payload is charged as a shared record shell plus its
  fields' shared work;
- each effect step, the input and the output keep their copying charge,
  exactly as the runtime meters them;
- under v2 only, a closure read charges its declared selector, the only
  helper the runtime calls, instead of the module's costliest helper
  (owner decision); the copying schedule is unchanged.

Tests:
- lowerer and verifier: five shared programs are admitted, byte
  operations are refused, and both judges' minimum budgets under each
  schedule are pinned and equal (independent oracle: the other judge);
  the copying minimums are unchanged.
- warp-core: each program given exactly the lowerer's shared minimum as
  its Core budget runs its largest input to the copying result
  (runtime never exceeds static).

RED (new tests against the previous sources):
  lowerer: read-control left Err(UnsupportedProgram) right Ok(());
           "read-control: refused even with an ample budget"
  verifier: same two failures
Calibration: one extra allocated byte per runtime expression fails
"ensure-node-control: Err(...AllocationBudgetExceeded) vs Ok"; the
retained v1 corpus verdicts are unchanged.
GREEN: lowerer and verifier suites pass; warp-core effect suites pass;
clippy clean.

Not yet covered: a closure-read effect witness for the declared-selector
rule, and the compiler minimum (blocked on amblicit#341 templates).

Agent-Session: AFC0A5E0-B032-49DC-8B18-CB932831DCC2
Agent-Tool: Claude Code
@flyingrobots

Copy link
Copy Markdown
Owner Author

Checkpoint at 18e8633.

Done:

Remaining, in order:

  1. Family 2 follow-ups:
    • a closure-read effect witness showing the declared-selector charge stays at or above the runtime charge;
    • Echo's edict.target-profile.intrinsics/v3 catalog: effectCostRule per effect intrinsic, plus a parameters map with maxEdgeScans at graphReads.maxEdgeScans (uint) and selector at graphReads.closureSelector (helper);
    • a conformance test: template evaluation equals the lowerer's per-effect charge on every intrinsic and fixture, and Echo's helper cost never exceeds Amblicit's;
    • exact admission at the compiler minimum (needs amblicit#341).
  2. Family 3: identity intrinsics (contentAddress, contentEdgeId, slotEdgeId, attachmentValueDigest).
  3. Family 4: Option constructors, ordered records, fail/attempt.
  4. Family 5: bytes, under docs(process): record direct-main docs exception #340's result-allocation rule.
  5. Merge main once, promote the components, then docs and the CHANGELOG.
  6. Measure ReplaceRange (jedit#410) through EffectPackageHost, reporting static bound, runtime charge, elapsed time and peak memory separately.

Interim CI: the component-digest checks fail until 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.

Run and meter effect programs under the v2 shared-read schedule

1 participant