Skip to content

The envelope charge is an approximation beside the renderer, not derived from it #259

Description

@nikolay-e

Found while reviewing #241 on 2026-08-30. The envelope charge is real and the budget now holds, but the estimate is approximate in ways worth writing down before someone reads it as exact.

It under-charges, so the artifact overshoots slightly. envelope_token_cost charges the commit message, the listed paths, 4 tokens per entry and a fixed 24. Rendered but not charged: the per-section headers beyond the fixed 24 (**Deleted files:**, **Renamed files:**, **Lock files changed:**, ~6 each), the — omitted marker (~3 per omitted entry, which on a wide range is most of them), the omitted-legend line (~20), and the policy-excluded sentence (~25). A rename is charged 4 but renders as - `from` → `to` ≈ 6. Direction is overshoot, and it grows with the omitted count.

It is calibrated for markdown. YAML and txt are close; --format json at indent=2 is materially heavier and unmodelled. Same class as overhead_per_fragment: 40, whose own comment says it is the YAML estimate.

The harness charges a strictly smaller envelope than the product. memory_pipeline passes changed_paths and no commit message; the product also passes deleted/renamed/lockfile/ignored. That is internally consistent — the harness renders no such lists — but the invariant as written in the commit message ("one function, so the harness spends the budget the same way") is not what the code enforces, and nothing tests the parity.

The corpus feels the charge ~10× harder than production. calculate_budget floors at 500 and was not adjusted, so a 10-path case loses 15-25% of its selection budget where production at 8k-48k loses 2-5%. Corpus budgets already sit on the cliff this pass documented for kubernetes_001 ("below ~2000 the greedy stops before a 0.069-scoring fragment").

Close condition: the envelope estimate is derived from the renderer rather than approximated beside it (one function the writer and the charge both call), and calculate_budget accounts for it so corpus cases measure the production operating point. Q-class — see #256.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions