Ambyte cost v2: persistent lists so append is not charged (or copied) at the declared maximum

Open
#438 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
rust

Research direction

Start by reading the v2 cost spec and the named compiler and Echo paths: echo-edict-pure/src/shared_reads/value.rs, expression.rs, and fold_work/shared_reads.rs. Then trace list append through the compiler and Echo judges, and review the conformance vectors from #424 and #432. Done means append uses a persistent representation, all components agree on its charge, the verifier rejects an undercharge, and the rope package comparison is recorded.

Written by the indexing model from the issue text.

Description

enhancement release:target-ir type: goalpost
.dag: issue-dag/2
.id: ambyte-lang/ambyte#438
.kind: task
.type: feature
.blocks: [flyingrobots/jim#5]
.size_hours: 16

Outcome

Under edict.core-cost/v2, listAppend on a list with a large declared maximum costs O(log n) or O(1), not a full shell. Echo's shared runtime stores lists in a persistent structure, for example a chunked Rc tree with 32-way nodes, so an append really is O(log n). The spec, the compiler, and Echo's lowerer, verifier and evaluator all charge it the same way, as #424 and #432 did.

Findings (2026-12-03, amblicit a0542b53, echo fe06a8ef)

  • Passing or carrying a value is not charged by its size under v2. Calling a helper with a 4,352-byte atom argument costs the same as with a U64: 10 extra calls add 389,120 vs 394,240 steps on jedit#410's rope package.
  • Echo really copies on append. echo-edict-pure/src/shared_reads/value.rs stores a list as Rc<[Shared]>, so expression.rs:660 copies the reference array, which is O(actual length), and charges a shell of length + 1.
  • The compiler charges every append at the declared maximum. fold_work/shared_reads.rs list_shell uses the proven length when it has one and the declared maximum otherwise. The rope arena's lists (stored 256, branches 128, the 512-entry queue, the 256-entry walk order) are appended to inside folds, so every append is charged 129 to 513 cells.
  • Where the bytes go. On jedit#410 (static U 83,964,734 steps, 173,660,515 bytes), the folds that append carry most of the allocation: loadStep 31.4M, flatStep 22.6M, compareStep 14.2M, walkStep 11.9M, checkStep 11.0M.

Scope

  • A persistent list representation in Echo's shared runtime, with append, at and length in O(log n).
  • A charge rule for append as a constant plus a log-depth term, independent of the declared maximum, in the spec, the compiler and every Echo judge.
  • Conformance vectors shared by the compiler and Echo.

Test Plan

  • RED: a fold appending to a List<U64, max=256> is charged about 257 cells per append.
  • GREEN: the charge is the same for declared maxima 16 and 256; Echo's runtime append does not copy the item array (pointer test); the verifier refuses a module that claims a lower charge.
  • Rebuild jedit#410's rope package and record static U and allocation before and after.
Dominant language
Rust
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from flyingrobots/edict

All issues in flyingrobots/edict

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.