Skip to content

Remove write-budget gate: apply is offered whenever a finding is apply_capable - #707

Merged
anshss merged 3 commits into
mainfrom
purge-write-budget
Aug 7, 2026
Merged

anshss merged 3 commits into
mainfrom
purge-write-budget

Conversation

@anshss

@anshss anshss commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

What changed

Removes the write-budget gate entirely. core/optimize/write_budget.py and core/optimize/write_allocation.py are deleted, along with:

  • The suppression-reason strings and constants: MIN_NET_WRITE_USD (the $5 floor), MAX_OFFERED_WRITES, AGENT_FILE_STANDING_CEILING_TOKENS, AGENT_FILE_GROWTH_SHARE_PER_WINDOW, WRITE_BUDGET_TOKENS, MIN_WRITE_BUDGET_TOKENS, the placeholder-fix quality floor (MIN_FIX_CHARS / _PLACEHOLDER_PATTERNS / is_placeholder_fix), and the seven REASON_* sentences.
  • The model fields that existed only to carry that gate's verdict: write_offered, write_blocked_reason, write_blocked_short, standing_cost_tokens_per_session, standing_cost_tokens, standing_cost_usd, standing_cost_basis, payback_ratio, net_negative, gross_recoverable_usd, gross_recoverable_tokens, write_exposure_sessions — removed from CostProposal and RelearnCluster, plus their UI and CLI rendering (the payback-arithmetic disclosure, the write-gate line, the short-label stamping).

apply_blocked_reason is untouched: it belongs to a separate, unrelated mechanism (why a model-swap or MCP-server-removal precheck failed — no registered source path, a dirty git tree, an already-removed config entry), not to the write budget.

New behavior

Apply is now offered whenever an analyzer marks a finding apply_capable. There is no budget, payback-ratio, or instruction-file-size ceiling gating that offer any more — the only reasons a rule is not offered are the ones that were always separate from the budget: the user already applied it, it's already present in their own files, they dismissed it, there's no resolved workspace/destination, or the family is advisory-only (the harness already self-corrects, so there's genuinely nothing to write).

Delivery-mechanism cost pricing (how many tokens a rule/skill/hook adds to every future session) is not gone — it moved from the deleted module into core/rulewrite/delivery.py, because rule_placement.py still uses it to choose between a project-scoped and a user-global destination (a rule confined to fewer sessions is cheaper to keep). That pricing is purely informational now: it changes which destination a rule lands in, never whether it's offered.

Guards that are untouched

Dry-run-by-default plus an explicit --go (CLI) / go: true (API) remains the only guard on an actual write. Owner checks, content-hash and symlink protections, and relearn's undo/backup machinery are all unchanged — this PR only removes the offer-side economics gate, not the write-safety machinery.

Accepted trade-off

tokenjam can now offer to write a permanent rule whose standing context cost may exceed its savings, into an already-large instruction file. This is a deliberate, explicit operator decision, not an oversight — the product no longer second-guesses whether a permanent rule is "worth" its own keep before offering it.

Test changes

tests/unit/test_write_budget.py (tested the deleted module directly) is deleted, along with its tests/write_allocation_helpers.py support module. Across the other touched test files: assertions that pinned the old suppression/gating behavior were removed or inverted to assert the new always-offered behavior; assertions about other features that merely happened to size their fixtures past the old $5 floor or token ceiling were kept, with only the stale scaling comment cleaned up. New tests pin the contract directly: an apply_capable cost proposal and an apply-capable relearn cluster are both offered regardless of how large the recoverable figure or the implied rule size is, and a dry-run apply call still writes nothing without go=True.

…pply action

Deletes core/optimize/write_budget.py and core/optimize/write_allocation.py
entirely, along with their suppression-reason strings and constants
(MIN_NET_WRITE_USD, MAX_OFFERED_WRITES, AGENT_FILE_STANDING_CEILING_TOKENS,
AGENT_FILE_GROWTH_SHARE_PER_WINDOW, WRITE_BUDGET_TOKENS, the placeholder-fix
quality floor, and the REASON_* strings). Apply is now offered whenever an
analyzer marks a finding apply_capable, with no budget, payback-ratio, or
instruction-file-size ceiling gating the offer.

The model fields that existed only to carry that gate's verdict are removed
from CostProposal and RelearnCluster (write_offered, write_blocked_reason,
write_blocked_short, standing_cost_*, payback_ratio, net_negative,
gross_recoverable_*, write_exposure_sessions), along with their UI and CLI
rendering. The apply_blocked_reason field survives unchanged: it belongs to
the unrelated model-swap / MCP-server-removal precheck plumbing, not the
write budget.

Delivery-mechanism cost pricing (standing_tokens_per_session, used to choose
between a project-scoped and a user-global destination) moves from the
deleted module into core/rulewrite/delivery.py, since rule placement still
needs it to pick the cheaper destination -- it just no longer feeds an
offer/suppress decision.

Dry-run-by-default plus explicit --go / go:true remains the only guard on an
actual write, and the owner/content-hash/symlink protections and relearn's
undo/backup machinery are untouched.

Accepted trade-off: tokenjam can now offer to write a permanent rule whose
standing context cost may exceed its savings, into an already-large
instruction file. This is a deliberate operator decision, not an oversight.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_019rAPK7A1ctiVJgxdP4VtXf
@anshss
anshss requested a review from anilmurty as a code owner August 7, 2026 17:12
@greptile-apps

greptile-apps Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

Removes the economic write-budget gate so every apply-capable finding is offered while retaining destination pricing and existing write-safety checks.

  • Deletes write allocation, payback, value-floor, size-ceiling, and offer-cap logic.
  • Simplifies cost and relearn proposal models and their API, CLI, and dashboard rendering.
  • Moves delivery standing-cost helpers into the rule-write delivery module.
  • Updates tests to assert unconditional offers and dry-run behavior.

Confidence Score: 5/5

The pull request appears safe to merge because no blocking failure remains within the eligible follow-up-review scope.

No blocking failure remains.

Important Files Changed

Filename Overview
tokenjam/core/optimize/analyzers/relearn.py Removes write-budget accounting and derives offerability directly from persona, workspace, and advisory-family state.
tokenjam/core/optimize/cost_proposals.py Removes budget decisions and netting while retaining informational destination placement for write-bearing proposals.
tokenjam/core/rulewrite/delivery.py Relocates artifact and standing-cost pricing helpers from the deleted budget module without using them to gate offers.
tokenjam/core/rulewrite/plan.py Treats cost proposals with an artifact and delivery as offered and derives relearn offers from target and advisory state.
tokenjam/ui/index.html Removes budget and payback disclosures and gates apply controls directly on apply-capable or non-advisory state.
tokenjam/core/optimize/write_budget.py Deletes the write-budget, quality-floor, netting, family-allocation, and suppression-reason implementation.
tokenjam/core/optimize/write_allocation.py Deletes the shared cross-lane write-allocation pass and its serialized report decisions.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Analyzer finding] --> B{Apply capable?}
  B -->|No| C[Advisory-only presentation]
  B -->|Yes| D[Resolve placement]
  D --> E[Offer apply action]
  E --> F{Explicit go?}
  F -->|No| G[Dry-run only]
  F -->|Yes| H[Safety checks]
  H --> I[Write artifact]
Loading

Reviews (3): Last reviewed commit: "test: prune the fix-prose ratchet entrie..." | Re-trigger Greptile

anshss and others added 2 commits August 7, 2026 22:46
# Conflicts:
#	tokenjam/core/optimize/write_allocation.py
Removing the write-budget netting pass from cost_proposals.py deleted the
PAST_OVERSPEND_OBSERVED_NOTE tense-suffix composition and the
_apply_write_decisions/_driver_role_proposals evidence assembly that used to
concatenate standing-cost disclosure text into the advise/evidence slots.
The ratchet's 16 corresponding entries are now stale — the underlying prose
is gone, not moved, confirmed by diffing the offender scan against the
branch's pre-purge parent commit, where all 16 still matched.

Co-Authored-By: Claude <[email protected]>
@anshss
anshss merged commit ddda592 into main Aug 7, 2026
6 checks passed
@anilmurty
anilmurty deleted the purge-write-budget branch September 18, 2026 21:03
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