Repository navigation
fix(agbossjs/agboss#727): the ledger adds each entry once — migration 0022 agboss_cost_entries; core at 53216599 - #42
Merged
Conversation
… 0022 agboss_cost_entries; a two-process test of a sibling child's spend in flight; core at 53216599 The core writes each tallied spend to the ledger at once, under a ledgerId, and CostLedgerRepository.saveAll adds a record with a ledgerId once. PostgresCostLedgerRepository inserts the ids into agboss_cost_entries (migration 0022) in the statement that adds their cost to the counters: a repeated or racing save of an id adds nothing. tests/processes/spend-in-flight: two processes, a child holding $0.60 at A's gate, the other child on B held back at $1.20. Refs agbossjs/agboss#727, agbossjs/agboss#732 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012Kh8JmysuhZyQRSpNyJdPg
This was referenced Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs agbossjs/agboss#727
Refs agbossjs/agboss#732
The core (agbossjs/agboss#761,
53216599) writes each tallied spend to the ledger the moment it is made, under aledgerId.CostLedgerRepository.saveAllnow adds a record with aledgerIdonce.PostgresCostLedgerRepository.saveAllis one statement. It inserts the entries' ids intoagboss_cost_entries(ON CONFLICT DO NOTHING RETURNING), then adds the cost of the inserted ones, plus the records without an id, to the counters. A repeated id, or a racing save of the same id, adds nothing: the unique key makes the later save wait for the earlier one.0022_cost_ledger_entriesadds the table.tests/migrations/cost-entries-migration.test.tscovers it: a counter written before 0022 keeps its spend, and an entry saved twice after it counts once. The other migration tests now leave out 0022 too.tests/processes/spend-in-flight.test.tsruns twonodeprocesses on one database, one step slot each, with an execution budget of $1. A's child pays $0.60 and waits at A's gate. B's child pays its $0.60 and is held back at its next step, at $1.20. Bite: with the core pinned at3f180577(main before #761), B's child pays both of its next steps.costLedgerContractcases pass throughstoreConformance: a repeated entry counts once; concurrent saves count one entry once and lose none; a save with no counters keeps no entry.Local: format, suppressions, installs, real-time, types, lint, typecheck, build, vitest with coverage (63 files, 690 tests, the explorer included) and the API report are all green.
🤖 Generated with Claude Code
https://claude.ai/code/session_012Kh8JmysuhZyQRSpNyJdPg