Commit graph

3 commits

Author SHA1 Message Date
Ouroboros
ae9fac5ad3 Read the rolling-24h consciousness allowance off the ledger; keep young attempts unfolded
Background Consciousness redesign, P3 (accounting). The daily allowance
(`OUROBOROS_CONSCIOUSNESS_DAILY_USD`, owner decisions В11/В18) gates NEW
starts on the money the whole consciousness tree accounted in the last 24 h.
There is no root index: `consciousness_allowance.allowance_window` names the
roots by the category of their FINAL ledger rows younger than the fold horizon
(`consciousness` = a wake's own rows, `consciousness_task` = a started root's),
then sums every money row kind under those roots (attempt /
subscription_session / external_unmetered — never a folded
usage_baseline_group or legacy_* row) with `ts` inside the window through the
ONE money reducer `_usage_rows._summary`. `accounted_usd` is the number
(reservations included, disclosed), `unknown_unmetered` makes it "at least",
`resets_at` = the oldest counted spend + 24 h. The row selection is memoized
by ledger fingerprint through the same `_render_cached` seam as
`usage_projection`; the time filter runs on every call, so an exhausted window
frees itself without a new write. An unreadable ledger is the typed
`allowance_unknown` outcome; `remaining_allowance_usd()` is the P2 helper.

The compactor makes the window readable: `_foldable_attempt_ids` keeps every
attempt whose final row is younger than `USAGE_LEDGER_FOLD_MIN_AGE_SEC`
(48 h, SSOT in runtime_limits, re-exported from config) in the live file with
its true `ts`; a group row carries the compaction instant and stays outside
the window by kind. The fold's clock is a module attribute, so the existing
compaction pins run on a fixture clock one horizon ahead and every
money-conservation assertion is unchanged. `_usage_rows.row_ts_epoch` is the
one ISO reader for both.

Co-authored-by: Ouroboros <311266734+ouroboros-agent@users.noreply.github.com>
2026-09-16 05:13:19 +03:00
Ouroboros
ee029fb1c9 Merge lane/windows-kernel-tier: LockFileEx on one byte beyond the owner stamp; Windows runs the kernel tier again (owner batch №13 item 1 = B)
The compaction suite's data_root fixture (now in tests/fixtures_usage_compaction.py
after the split) no longer skips on Windows; ledger union-merged. The
Windows-executed proof is the next CI matrix.
2026-09-02 20:37:17 +00:00
Ouroboros
a5af60cbc4 test(usage): split the compaction suite at the archive-reader boundary
tests/test_usage_compaction.py stood at exactly 1600 lines — the hard cap —
leaving the next monetary-accounting pin nowhere to land. Owner batch №13
item 11 = A: split the module at its natural organ boundary rather than
raise the cap.

The archive reader (invariant 5, the CPL-5 join across chained compactions;
and invariant 8, structural validation of a compacted ledger — every one of
those tests drives _validate_records over a baseline block, i.e. reads a
compacted ledger rather than running a pass) moves to the new
tests/test_usage_compaction_archive.py. The compaction pass keeps its own
module: monetary exactness and budget equality, in-flight rows, crash-safety,
the lock and swap window, idempotent kinds, trigger policy.

Fixtures both modules need live in tests/fixtures_usage_compaction.py,
following the existing tests/fixtures_*.py convention rather than a conftest.
The three fixtures are re-exported through the module object instead of being
imported by name: a test's data_root PARAMETER shadows a bare import of that
name and F811 fires on every such test, while pytest_plugins would cost the
fixture module its assertion rewriting.

No behaviour change: no test dropped or edited, and the two files collect the
same 64 node ids as the old single file (diffed name by name). The four
tier-agnostic pins still run on Windows through data_root_any_tier, and the
data_root fixture still skips there, byte-identical.

900 + 660 + 123 lines. The size-ratchet manifest names none of these files, so
no band entry is needed and --check stays green unregenerated.

Hooks repointed: the ADOPTION CPL-4 verification column now names all three
files with what each holds; DESIGN_USAGE_COMPACTION.md §12 names both suites
and the invariants each pins; the C6 packet's close-out line records the
owner's answer where it said the decision was still owed. The append-only
round records are left as written.
2026-09-02 20:26:45 +00:00