Skip to content

Charge v2 allocation for values built by prelude calls - #340

Merged
flyingrobots merged 1 commit into
mainfrom
fix/v2-result-allocation
Nov 19, 2026
Merged

flyingrobots merged 1 commit into
mainfrom
fix/v2-result-allocation

Conversation

@flyingrobots

Copy link
Copy Markdown
Owner

Plain-English Walkthrough

TL;DR

Under the shared-read (v2) cost schedule, values built by prelude calls (byte concat and slice, text concat, integer and Option operations) were charged no allocated bytes. That made the static bound unsound against the definition of maxAllocatedBytes as cumulative logical allocation [claim:unsound, confidence:1.00]. They are now charged their result's full size, as the documentation already stated. Jedit's flat ReplaceRange minimum rises from 175.3 MB to 213.5 MB (203.6 MiB) [claim:rope, confidence:0.95].

Walkthrough

Bug. In fold_work/shared_reads.rs, shared_own charged every Call one step. The call rule then added only copying-schedule steps for typed prelude operations, never bytes.

Fix. A prelude call without a shared-read rule is now charged value(result).evaluation(), its cells plus one step and its full bytes, as under v1. List operations keep their shell rules, and listAt still returns a shared reference. The source checker and native Target use this same meter, so their minimums stay equal. echo#1016 must mirror the rule.

Verification.

  • RED: on main, the reference evaluator metered 13,333 bytes against a v2 minimum of 4,309, and eight extra rounds added only 3,088 and 2,600 bytes.
  • GREEN: 4 of 4 tests pass. Each extra round now adds at least its concat and slice results, or its present Option; native Target refuses one byte below the source minimum; and the evaluator, extended with byte values and Option constructors, stays within budget.
  • Existing schedule tests still pass and stay sound. cargo xtask verify exits 0.

Flat ReplaceRange (jedit#410 at 67a85dc): 261,523,656 → 261,826,990 steps and 175,260,814 → 213,473,665 bytes. Target lowers at the new minimum; the build then stops at the provider, as before.

The docs are agent-written and not yet human-reviewed.

Appendix: Citations
Claim Evidence Confidence Notes
claim:unsound built_byte_and_option_values_stay_within_budget RED on main; crates/amblicit-syntax/src/target_ir/fold_work/shared_reads.rs @4ffc7c68 1.00
claim:rope CLI builds in scratch, with binaries from main and from this branch 0.95 Not a committed test.

Closes #339

Under the shared-read schedule every Call node was charged one step and
no allocation, and byte, text, integer and Option operations added steps
only. So core.bytes.concat, core.bytes.slice and the Option operations
built values for zero charged bytes, contradicting the README and
maxAllocatedBytes as cumulative logical allocation (#328). A prelude
call without a shared-read rule is now charged its result's full size,
as under v1. Source and native Target share the meter.

The reference evaluator gains byte values, concat, slice, length and
the Option constructors.

RED: the evaluator metered 13,333 bytes against a 4,309-byte v2 minimum,
and eight extra rounds added only 3,088 / 2,600 bytes.
GREEN: 4/4; existing schedule tests sound; cargo xtask verify exit 0.
Flat ReplaceRange (jedit#410 @ 67a85dc): 261,523,656 -> 261,826,990
steps, 175,260,814 -> 213,473,665 bytes; Target lowers at the new minimum.

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

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

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

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: f06d5daa-093e-46bb-99d4-5cca895d39ae
Commits

Reviewing files that changed from the base of the PR and between 57b35d2 and 4ffc7c6.

Files selected for processing: 6

  • CHANGELOG.md
  • crates/amblicit-syntax/src/target_ir/fold_work/shared_reads.rs
  • crates/amblicit-syntax/tests/core_cost_schedules/reference.rs
  • crates/amblicit-syntax/tests/shared_read_result_allocation.rs
  • docs/topics/core-cost-schedules/README.md
  • docs/topics/core-cost-schedules/test-plan.md
  • 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

@flyingrobots
flyingrobots marked this pull request as ready for review November 19, 2026 07:11
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-19T07:11:30.743627Z
We couldn’t complete this review. Comment @codex review to try again.
4ffc7c6 Draft marked ready
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@flyingrobots
flyingrobots merged commit 26a201e into main Nov 19, 2026
6 checks passed
@flyingrobots
flyingrobots deleted the fix/v2-result-allocation branch November 19, 2026 07:11
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.

v2 cost schedule charges zero allocation for byte and Option results

1 participant