Ambyte fold: early stop with a value, charging only active rounds (2026-11-29 loop standard)

Open
#422 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Read SPEC_edict-language-v1.md and SPEC_ambyte-core-semantics-v0, especially the fold and loop-round rules in Table 5. Then inspect the oracle, Core IR, conformance fixtures, and docs named by the issue to determine where fold semantics are defined and tested. Decide and document the source form, add the new Core capability, and update the specs, oracle, docs, and CHANGELOG; done means the round-3-of-256 test charges three active rounds plus stop tests while preserving the full static bound, and the mutant that continues after stopping fails.

Written by the indexing model from the issue text.

Description

enhancement release:target-ir type: goalpost
.dag: issue-dag/2
.id: ambyte-lang/ambyte#422
.kind: task
.type: feature
.blocked_by: []
.size_hours: 8

Outcome

A source fold can stop before its bound with a value. The compiler's Core and its static cost follow the 2026-11-29 loop standard: rounds are charged one per active round, and no round is entered after the fold stops. The static bound stays the full literal bound.

Why

EDICT-LANG-FOLD-001 (SPEC_edict-language-v1.md, "There is no early exit … all N iterations still count") contradicts the owner's 2026-11-29 standard (SPEC_ambyte-core-semantics-v0, Table 5: "Loop round: once per active round … A fold round after a round with no result is not entered and is not charged").

In v0, a round with no result makes the fold's join inactive. A fold therefore cannot both stop early and return its accumulator, and that is the case ReplaceRange needs.

Measured on flyingrobots/jedit#410 @ 88554e1 (echo#1124 harness):

  • ReplaceRange's folds run 256 loadStep, 257 walkStep, 128 branchIdStep, 64 compareStep and 9×16 emission rounds whatever the edit.
  • Even with every idle round returning first, middle-ascii-insert still pays 82,806 steps in loadStep and 42,191 in walkStep, mostly in idle rounds.

Scope

  • Source form: either the step returns Stop(S) | Continue(S), or the fold takes a stop: S -> Bool helper. Decide which in this issue, and record the choice.
  • Core form: a new capability, for example core.fold-until/v1.
  • A fold of zero rounds returns its initial value. A stopped fold returns the last state.
  • Static cost is the full bound, unchanged. The runtime charge covers the entered rounds only, plus the stop test of each entered round.
  • The v0 semantics spec, the language spec, the oracle, and the docs and CHANGELOG.

Test plan

  • RED: a fold whose state finishes in round 3 of 256 charges 256 rounds today.
  • GREEN: the same fold charges 3 rounds plus the stop tests in the oracle, and its static bound is unchanged.
  • A mutant that keeps running after the stop fails.
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.