Skip to content

A2 follow-up: the people budget records consumption only - #2044

Merged
neuromechanist merged 9 commits into
feature/issue-2005-epic-compute-corefrom
feature/issue-2007-a2b-people-budget-consumption-only
Nov 5, 2026
Merged

neuromechanist merged 9 commits into
feature/issue-2005-epic-compute-corefrom
feature/issue-2007-a2b-people-budget-consumption-only

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to phase A2 (#2007, epic #2005): makes the owner's decision of 2026-11-04 true in code, option A, the people budget records consumption only. Nothing an administrator or a person does to a person's pool credits the budget back. No migration change: the 0114 triggers already allowed either option.

What changed

  • refundJob, REFUND_INSERT_SQL, refundKey and the refund reason default are deleted (preferred option: the refund had no production caller, only A2's own tests, and compensation is a grant). The refund kind stays in the table's vocabulary and nothing writes it.
  • adjustPool refuses, with invalid_argument and nothing written, a charge correction that lowers a charge and names a budget, and ADJUST_INSERT_SQL carries the same refusal as a WHERE term (?2 IS NULL OR ?4 > 0), so the exported statement writes nothing when bound directly with a budget and a charged change that does not raise it; the admin route names the people budget only when the charge is raised. A lowering correction moves the person's or partner's pool alone. A correction of the granted amount is unaffected, and platform pools stay owner-only and name no budget.
  • settleFinal is unchanged in behaviour and is documented (comments and tests) as the one entry that names the budget and may lower it, because it corrects a figure that was recorded as consumption; its delta is the job's own, so it cannot take back more than the job consumed.
  • Comments and docs: ledger module doc, route doc, CLI pool adjust help (the only entries that lower the budget are a job's final settlement and the owner's own correction of the platform budget, and a raise made by mistake is undone only by that owner correction), migration 0114 comment block (comment-only edit), ADR 0118 (inline superseded markers and one amendment line at the end of item 5 of the A2 amendment, nothing deleted or renumbered), implementation notes.

Tests

  • New backend/test/compute-ledger-budget.test.ts: lowering a charge leaves the budget's charged and held totals as they were (account and partner pools), raising raises both, a grant correction moves neither, the final settlement lowers by the job's difference and never below what other jobs consumed, an enumerated table of every service operation against the budget (exactly one lowers it), a check that the rows cover every kind in the vocabulary but refund, and the refund path no longer exists.
  • A2 suites updated: the seeded random sequence now checks after every step that the budget's charged total never falls except by a final settlement or the owner's own platform correction, and a ledger scan says every entry naming the budget that lowers it is a final settlement; a source scan refuses any shipped ledger insert that has a refund literal that is not a comparison, or a kind that is not a plain literal in the kind column's position (a later column, a SELECT list, a bound or computed kind; a statement cut short by a template interpolation is seen only as far as the interpolation, which the behavioural tests cover); route and CLI tests show the budget unchanged after a decrease.
  • Targeted suites green (ledger, rules, budget, race, migration, pool and policy routes, jobs, admin compute CLI, compute-state and contract unit tests, ADR index), typecheck, biome on touched files, and migrations:d1-check once. Each guard was mutated one at a time and watched fail.
  • A test binds ADJUST_INSERT_SQL directly with a budget and a charged change that is negative or zero and asserts nothing is written. The header of compute-ledger-budget.test.ts lists every guard and where it is held.
  • Not run: the full bun test and CI, because the standing rule is targeted tests only; would check the rest of the suite before the epic merges to dev.

After A5 (#2041) merged

  • Rebased onto the epic branch (A5 is in). The one conflict, in the implementation notes at the budget-semantics lines, is resolved in favour of this PR's wording, and the lines now also point at section 10.
  • A5's sentences that became false are reworded with inline markers and nothing deleted: the implementation notes no longer say "the code of this phase is still option B", ADR 0118's A5 amendment item 2 carries a superseded marker saying the A2 follow-up made the change (and a second marker on the line that names the deleted refundJob), the notes' section 10 and the compute-lifecycle.ts header comment no longer name refundJob as callable, the ADR index row says the ledger code is option A now, and the LEDGER_ENTRY_KINDS and COMPUTE_LEDGER_REASONS comments in shared/compute-state.ts say the refund kind has no writer. The other refund wording in shared/compute-state.ts and compute-s3.ts was already fixed by A5.
  • Reran the A2 ledger, policy and route suites, the A5 lifecycle suites that share compute-ledger.ts (compute-lifecycle*, compute-full-path, callbacks, jobs, source scan), the admin compute CLI suites, the compute-state and contract unit tests and the ADR index test, plus typecheck, biome on touched files and migrations:d1-check once. Three guards were mutated again after the rebase and each still fails the suites that cover it.

Optional hardening for the owner (not done)

The table would still accept a lowering correction that names the budget, or an entry of kind refund; the code and its tests hold option A. Migration 0114 is unreleased, so a BEFORE INSERT trigger could refuse a budget-naming entry with a negative charged delta unless it is a job's adjust, and refuse kind refund, which would make option A a table rule. It was left out on purpose (no migration change in this PR).

Commit efa3268's message says the invented archiveIncludeLaunchFiles field name was replaced; that fix landed in A5 and the rebase dropped it from this branch, so the message is inaccurate on that point and is left as it is (the history is not rewritten).

Delete refundJob and its statement (no production caller), refuse a charge correction that lowers a charge and names the budget, and have the admin route name it only when the charge rises. Final settlement stays the one entry that may lower the budget. Tests show the budget does not move.
The help said the people budget follows a charge correction; it now says raising counts against it and lowering does not. The CLI test also checks the budget after a decrease.
Comment-only edit: the owner chose option A, so the table comments say the code owns the rule and no longer call it open.
ADR 0118 gets inline superseded markers and one amendment line, implementation notes say the code implements option A, and the invented archive field name is replaced by the real Tapis one.
Comment-only: the ledger kind and reason lists keep refund for the table vocabulary, and the comments now say nothing writes it.
The ADR 0118 index row says the ledger code is option A now.
@neuromechanist
neuromechanist force-pushed the feature/issue-2007-a2b-people-budget-consumption-only branch from 0bf0c03 to ddc300a Compare November 5, 2026 01:46
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR2044

Version: 0.10.28-PR2044.558cbdf
Commit: 558cbdf


🤖 Updated on each push.

The scan flags any refund literal in a shipped ledger insert that is not a comparison, and a kind that is not a plain literal in the kind column's position. Planted shapes cover a later column, a SELECT list, and a bound kind.
The help and route doc said only a final settlement lowers it; the owner's own correction of the platform budget does too. Help gains the sentence on undoing a raise made by mistake, and the route comment says what the owner rule settles.
ADJUST_INSERT_SQL now writes nothing for a budget with a charged change that does not raise it, so a caller that binds it directly cannot credit the budget. A test binds it directly. The budget test header lists the guards.
@neuromechanist
neuromechanist merged commit 405ec3b into feature/issue-2005-epic-compute-core Nov 5, 2026
17 of 20 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-2007-a2b-people-budget-consumption-only branch November 5, 2026 04:32

This branch was previously deployed

1 inactive deployment
npm — 558cbdf0 Deployed Nov 5, 2026 by neuromechanist via publish #4192
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