Repository navigation
Description
What happened
The workstation's spend ledger (.data/ai/spend.db, the default SpendLedger path) holds rows that only a test makes: on 2026-10-19 at 18:39 to 18:44 UTC five pydantic_ai_direct / direct_sync rows with model test (54 tokens) and fake-model (30 tokens each), and on 2026-10-21 at 23:27 UTC one gateway / chat_dispatch row with model demo-model on server example.com:4000. Found on 2026-10-24 while reading the local AI savings of 2026-10-01 to 2026-10-21. A test run (or a test helper run outside pytest) wrote its fake model calls into the real ledger, so the hermetic floor does not keep the spend ledger in the test's own directory.
What should happen
Every test that makes a model call records it in a ledger under its own tmp_path (or records nothing), and a test fails when a test run opens the workstation's real ledger path. The six rows are removed from the ledger by a documented command, or the report ignores rows whose model is a test fake.
Evidence
sqlite3 'file:.data/ai/spend.db?mode=ro' "select timestamp, provider, server, model, request_type, total_tokens from ai_spend_records where model in ('fake-model','test','demo-model')"
Acceptance criteria
- A test (in the hermetic floor's invariants) fails when a test run writes to the default
SpendLedgerpath. - The tests that make the
test,fake-modelanddemo-modelcalls write to a ledger undertmp_path.
Proposed design
Problem statement
Tests that make fake model calls write rows into the workstation's real spend ledger at .data/ai/spend.db. Six rows with models test, fake-model and demo-model were found in the real ledger. The hermetic floor does not keep the spend ledger inside the test's own directory, so test data pollutes the production record.
Acceptance criteria
- Criterion 1: A test in the hermetic floor invariants fails when a test run writes to the default SpendLedger path.
Verification: Run the hermetic floor invariant tests. Confirm that a test asserts failure when any write targets.data/ai/spend.db. - Criterion 2: The tests that make the
test,fake-modelanddemo-modelcalls write to a ledger undertmp_path.
Verification: Run the affected test files. Confirm no new rows appear in.data/ai/spend.dband that the ledger file exists under the pytesttmp_pathdirectory.
Key questions
- Where is the hermetic floor's invariant test suite?: The invariant tests live in
tests/test_architectural_invariants.py. [sources: tests/test_architectural_invariants.py] - Which test files are known to use SpendLedger and may write to the real path?: The five files are
tests/test_ai_served_by.py,tests/test_ai_spend_dispatch.py,tests/test_ai_spend_ledger.py,tests/test_review_profile.pyandtests/test_telemetry_instruments.py. [sources: CHANGELOG.md:507] - Should the fix redirect tests to
tmp_pathor should the report filter out test-fake model rows?: Redirect the tests totmp_pathand add the invariant test. Both acceptance criteria are required. (proposed)
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsReady
- StatusShow more project fieldsNew
Activity
dan-petty commentedon Oct 24, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.
The candidate describes a fix for how tests record model calls, which is a testing concern.This issue impacts test reliability and correctness but does not block core functionality.Fixing test isolation improves confidence in CI results and reduces false positives.The fix involves redirecting test ledger writes to a temporary path, which is a straightforward change.Both items involve the spend ledger but differ in focus: one deals with test isolation and the other with discrepancies in request counts.dan-petty commentedon Oct 28, 2026
Status set to Ready at bb46660 (see proposed design in issue body).
chore(main): release 0.37.0 (#2964)