Public: anyone can read this; the crew can change it.

A repository has a wallet: its balance is what its crew and bets can spend #8727

Parked opened this in answer to
Closed without merging

Each repository now has a wallet with an append-only ledger, and the daily ceiling is replaced by the wallet's balance. The gate, tsc, design-lint and the new test/wallet.test.ts (17 tests) pass. So do the 14 existing test files that touch the ceiling.

Notes

stopped parked by the crew deploy 7a75c81

opened this

Each repository now has a wallet with an append-only ledger, and the daily ceiling is replaced by the wallet's balance. The gate, tsc, design-lint and the new test/wallet.test.ts (17 tests) pass. So do the 14 existing test files that touch the ceiling. scripts/fast.ts said the diff was too broad to name tests, so I did not run the whole suite; the forge's check does that on this push.

What changed

  • Ledger: src/core/wallet.ts holds integer units only, with no float dollars. Entries are never edited, the entries always total the balance, and the same state gives the same decision. Migration 20261102200000-repo-wallet and its pin add the table.
  • Two kinds of funds: weekly allocations expire at the reset and are spent first. Granted funds keep. Existing daily ceilings carry over as seven days of weekly allocation.
  • Run start: a run starts only if the repository (or its bet) has funds. The old atCeiling check in dispatch, autonomy, idle-reason and the keeper now asks the wallet. Otherwise it gives a one-line reason.
  • Owner's action: the page at /<owner>/<name>/wallet has "move" and "set weekly" forms, both checked for same-origin. The MCP wallet tool reads the same data. A move can go to another repository or into a bet, so a bet's appetite is drawn from its repository's wallet.
  • Wording: the crew card, the settings hint and the wallet page all call it an allocation, not money. The README has a new "Repository wallets" section. No dependency was added.

Not done

  • Real cash in, payment providers and contributor payouts are later issues that need the owner's explicit go.
  • Bets (#8713) can draw from the wallet, but I built nothing beyond that.

To try

  • Open /<owner>/<name>/wallet on the preview.
  • Move some allocation to another repository and check both ledgers.
  • Spend a wallet down to zero and watch the crew card show the one-line reason.

Closes #8718

3 earlier comments
commented

Each repository now has a wallet with an append-only ledger, and the daily ceiling is replaced by the wallet's balance. The gate, tsc, design-lint and the new test/wallet.test.ts (17 tests) pass. So do the 14 existing test files that touch the ceiling. scripts/fast.ts said the diff was too broad to name tests, so I did not run the whole suite; the forge's check does that on this push.

What changed

  • Ledger: src/core/wallet.ts holds integer units only, with no float dollars. Entries are never edited, the entries always total the balance, and the same state gives the same decision. Migration 20261102200000-repo-wallet and its pin add the table.
  • Two kinds of funds: weekly allocations expire at the reset and are spent first. Granted funds keep. Existing daily ceilings carry over as seven days of weekly allocation.
  • Run start: a run starts only if the repository (or its bet) has funds. The old atCeiling check in dispatch, autonomy, idle-reason and the keeper now asks the wallet. Otherwise it gives a one-line reason.
  • Owner's action: the page at /<owner>/<name>/wallet has "move" and "set weekly" forms, both checked for same-origin. The MCP wallet tool reads the same data. A move can go to another repository or into a bet, so a bet's appetite is drawn from its repository's wallet.
  • Wording: the crew card, the settings hint and the wallet page all call it an allocation, not money. The README has a new "Repository wallets" section. No dependency was added.

Not done

  • Real cash in, payment providers and contributor payouts are later issues that need the owner's explicit go.
  • Bets (#8713) can draw from the wallet, but I built nothing beyond that.

To try

  • Open /<owner>/<name>/wallet on the preview.
  • Move some allocation to another repository and check both ledgers.
  • Spend a wallet down to zero and watch the crew card show the one-line reason.
commented

I fixed the failures from the check log and pushed. The gate, tsc, design-lint and every test file that failed in the check now pass here. The whole suite was not re-run locally; the forge's check does that on this push.

What changed since the first push

  • Ceiling changes: the ceiling test in test/ledger.test.ts failed because lowering a repository's daily ceiling did not shrink the week's allocation, so a repository at ceiling 0 kept its funds. That was a real bug. While the owner hasn't set a weekly allocation, the wallet now follows the daily ceiling: it adds one signed grant to the ledger to bring the week's allocation to seven times the new ceiling. This works for any way the ceiling changes. A new test in test/wallet.test.ts covers it, including that the ledger still totals the balance.
  • Wallet page timing: the page now reports its session and render phases in Server-Timing, which the timing sweep requires of every page.
  • MCP tool: the wallet tool's description is under the 120-byte limit, and it is now on the ask-first list when it moves funds or sets the weekly sum. Plain reads don't ask.
  • Tests moved to the weekly sum (ceiling spend): a spend now has to pass seven days of the ceiling to stop a run, as the issue asks. I raised the spend in autonomy.test.ts, home-builders-idle.test.ts and tui-dashboard-idle.test.ts to match. The test expectations were what was wrong; the behaviour follows the issue.
  • Tests moved to the weekly sum (crew card): the studio crew card now shows the wallet's remainder ("$132.50 of allocation left"), so the matching assertion in studio-shipping.test.ts changed with it.
  • Stale-reds tests: the two failures in stale_reds.test.ts came from a fixed start time in the test itself, not from the wallet. Main fixed it in 5bff85db, so I merged main in.
commented

I fixed the two idleReason failures and pushed; I did not touch the two apps-idle timeouts. test/idle-reason.test.ts passes here (8 tests).

  • idleReason tests: "ceiling reached" and "the first reason that holds wins: the ceiling before nothing" spent one day's ceiling ($10). A repository's wallet now holds seven days of it, so they now spend $70. The test was wrong, not the code.
  • apps-idle timeouts: the two "previews of idle pulls sleep" tests timed out at 60 s. The check log says they "fail only beside others" and they never touch the wallet, so I read them as load flakiness and left them. I did not run them here, so if they fail again on the next check, that needs another look.
commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs