Skip to content

Add accumulation yield estimator and controller to the numerical library - #91

Merged
chian merged 4 commits into
mainfrom
feat/accumulation-yield
Dec 5, 2026
Merged

chian merged 4 commits into
mainfrom
feat/accumulation-yield

Conversation

@chian

@chian chian commented Dec 3, 2026 •

Copy link
Copy Markdown
Owner

Accumulation yield estimator and controller

Adds episode_workflow's accumulation yield estimator to the numerical function
library and binds it to Grain.controller. The Chao2 estimator, its
composition and approved Architecture bindings are unchanged.

This revision replaces the estimator first copied in this PR. That one
classified each observation as productive or dry and decided from those
counts. The estimator now fits one curve to the whole accumulated score. There
is no window, no count threshold and no tally of productive or dry steps.

The math

The input is an ordered score record: a starting score, then one score per
completed unit. initial_expectation is the yield expectation before the first
observation, in credit per observation. It is the starting value of that one
number, not a multiplier on it: every observation then moves it, a gain up by
its size and an observation without gain down.

gained            = score now - starting score
yield_expectation = (initial_expectation + gained) / (observations + 1)

A record that never gains reads initial_expectation / (observations + 1).

With weigh_outstanding, one rate is fitted against the credit still on offer
at each point of the record:

exposure          = outstanding at the start + outstanding before each observation
yield_rate        = (initial_expectation + gained) / exposure
yield_expectation = outstanding now * yield_rate

The Episode stops when, after at least one observation, the expectation is
below score_resolution (saturated), or at once when nothing is outstanding
or the score has reached max_score (complete).

A record that loses credit is fitted on the most credit held so far. Credit
earned back is not a new gain and the observations it took are still exposure,
so 0, 1, 2, 3, 4, 1, 2, 3, 4 is fitted as gained 4 over 9, and the
expectation falls smoothly through the recovery instead of dropping at it.

Behaviour to know before choosing parameters

  • Patience is initial_expectation / score_resolution observations for a
    record that never gains, and each credit gained adds 1 / score_resolution
    observations. A coarse resolution with a small initial expectation therefore
    stops quickly, including during a recovery.
  • Only credit gained and exposure enter the fit; the order of gains does not.
    In episode_workflow a free two-parameter saturating fit stopped 17 of 29
    recorded runs before later credit, because those runs find a few values
    early and then go long stretches dry.
  • With constant outstanding credit the weighted form equals the unweighted
    one; outstanding credit changes the expectation only as it is earned.

What is in the change

  • numeric_control_library/accumulation.py: the source file, byte-identical
    (SHA-256 71e29778cbe46b27794c9b1dcdc7aa0091683790f090b864674795409d0159bb).
    The source file is not yet committed in episode_workflow, so the hash is its
    only identifier.
  • numeric_control_library/accumulation_control.py: registers
    rarefaction.accumulation_yield_v1 and
    controller_composition.compose_accumulation_controller, with
    AccumulationObservation at the closed-record boundary.
    • Parameters: required score_resolution and initial_expectation;
      optional max_score and weigh_outstanding.
    • estimate_accumulation_yield(score_record, parameters, outstanding_history=None)
      takes the outstanding credit at every score. The controller keeps that
      history; an unknown start takes the first stated value.
    • Report fields: should_yield, outcome, score, max_score,
      observations, gained, exposure, yield_rate, yield_expectation,
      stop_below, score_resolution, initial_expectation, outstanding.
    • Eight admission scenarios: initial expectation, decay without gain, a gain
      raising the expectation, gain size, outstanding weighing and immediate
      completion, withdrawal and recovery, early patience, determinism.
  • EpisodeBuilder catalog, constructor admission and emitter contract.
  • docs/openchia/accumulation_yield.md and a README pointer.

Removed relative to the first revision: efficiency_fraction,
initial_productive, initial_dry, the scalar outstanding= argument, and
the report fields productive_observations, dry_observations and
yielding_rate.

Not ported

  • In the source repository the root observes every descendant unit and a
    stopped ancestor stops its descendants. That wiring lives in its engine.
    Here each Episode path keeps its own record, and a parent observes one unit
    per child return.
  • The source estimator lets initial_expectation default to max_score; the
    binding here requires it.

Tests

scripts/run_tests.sh tests/numeric_control_library/ tests/episode_builder/ \
  tests/function_library/ tests/method_loop/ -q
  • tests/numeric_control_library/test_accumulation_yield.py and
    tests/episode_builder/test_accumulation_catalog.py: 37 passed.
  • The four suites together, after merging main (which now includes Add value-of-computation yield estimator and reusable Episode adapter #89): 130 passed, 5 failed. The same 5 fail on main
    and are unrelated to this change:
    • tests/episode_builder/test_api_failure_continuation.py::test_api_failure_stops_builder[emission]
    • tests/episode_builder/test_repeatable_call_materialization.py (2)
    • tests/method_loop/test_episode_tree_recursion.py (2)
  • ruff check on the changed files and git diff --check are clean.

🤖 Generated with Claude Code

Copy episode_workflow's accumulation yield estimator unchanged into the
numerical function library and bind it to Grain.controller.

The estimator judges an ordered score record by the chance that its present
dry stretch is only a gap at the record's own yielding rate. With outstanding
credit stated, it stops when that chance times the credit still on offer falls
below the score resolution. There is no window and no unit count.

- numeric_control_library/accumulation.py: the source file, byte-identical.
- numeric_control_library/accumulation_control.py: registers
  rarefaction.accumulation_yield_v1 and
  controller_composition.compose_accumulation_controller, with
  AccumulationObservation at the closed-record boundary.
- EpisodeBuilder catalog, constructor admission and emitter contract.

The Chao2 estimator, its composition and approved Architecture bindings are
unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

running on fd83ef6 — Merge main into feat/accumulation-yield


Still running 17 jobs: Desktop core E2E / Desktop core E2E (Linux), Desktop update E2E / Desktop install/update E2E (Linux, app-update), Desktop update E2E / Desktop install/update E2E (Linux, build-fail), Desktop update E2E / Desktop install/update E2E (Linux, first-run), Desktop update E2E / Desktop install/update E2E (Linux, update-concurrency), OS-specific tests / Windows E2E (real processes), OS-specific tests / Windows install + update E2E / Windows install.ps1 + hermes update E2E, OS-specific tests / Windows-only tests, OS-specific tests / Windows-only tests (arm64), Python tests / Run tests, Python tests / e2e, Python tests / e2e-upgrade (core), Python tests / e2e-upgrade (git), Python tests / e2e-upgrade (handoff), Python tests / e2e-upgrade (hosts), Python tests / e2e-upgrade (network), Python tests / e2e-upgrade (pm)

❌ Job failures

OS-specific tests / macOS-only tests · View job

Job OS-specific tests / macOS-only tests failed.

chian and others added 3 commits December 3, 2026 21:15
…cumulation curve

The estimator copied in the previous commit turned every observation into
productive or dry and decided from those counts. The source repository has
replaced it, and this brings the copy and its bindings in line.

The estimator now fits one curve to the whole accumulated score. It starts
from a stated initial expectation, in credit per observation, which every
observation then moves: a gain up by its size, an observation without gain
down.

    yield_expectation = (initial_expectation + credit gained) / (observations + 1)

With outstanding credit weighed, one rate is fitted against the credit on
offer at each point of the record:

    exposure          = outstanding at the start + outstanding before each observation
    yield_rate        = (initial_expectation + credit gained) / exposure
    yield_expectation = outstanding now * yield_rate

The Episode stops when the expectation is below the score resolution, or at
once when nothing is outstanding or the score has reached its ceiling. A
record that loses credit is fitted on the most credit held so far, so credit
earned back is not a new gain and recovery does not stop the record.

- numeric_control_library/accumulation.py: the new source file, byte-identical
  (SHA-256 71e29778cbe46b27794c9b1dcdc7aa0091683790f090b864674795409d0159bb).
- numeric_control_library/accumulation_control.py: parameters are the required
  score_resolution and initial_expectation and the optional max_score and
  weigh_outstanding; efficiency_fraction, initial_productive and initial_dry
  are removed. estimate_accumulation_yield and the controller pass the
  outstanding credit at every score instead of one scalar, an unknown start
  taking the first stated value. The admission scenarios test the fitted
  behaviour and none tests a count.
- Emitter contract, docs page and README pointer state the new parameters,
  formulas and report fields.
- Tests rewritten against the formulas; none reads a removed field.

Registration ids and interfaces are unchanged. Not ported, as before: the
source repository's root observes every descendant unit and a stopped ancestor
stops its descendants; here each Episode path keeps its own record.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Main gained the value-of-computation estimator (#89), which registers in the
same catalog, admission and export lists as the accumulation estimator. Both
sets of entries are kept.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Both this branch and the preferential discovery estimator merged in #90
register an estimator in the same places and describe it in the README.
Keep both.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FfzyrvFGRVKR5LMMXbXonU
@chian
chian merged commit c9d789a into main Dec 5, 2026
5 checks passed
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