Commit Graph
396 Commits
Author SHA1 Message Date
swaitsandClaude Fable 5.2 a19473b282 merge: P15 A1, the server opens and closes one book while it runs
The books server could only open every book at start and close them all
at exit. The app is becoming one window with a tab per open company
(D-77, D-78), so a company must be reachable exactly while its tab is
open. The server now opens and closes one book on request, refuses calls
to a closed book in words an agent can relay, and lists who is connected.

Four independent reviews shaped it. After a close is answered nothing in
the server can write to that book; a call either ran and is journaled or
was refused, cut or stopped and left nothing; a close ends within a
stated bound; closing one book never stops another's work; and nothing
is ever deleted in a backup folder the owner chose.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-20 20:24:00 -07:00
swaitsandClaude Fable 5.2 3a8e652ceb docs(plan): P15's follow-ups from the reviews of A1 and A3a, written down
The last rounds of both units fix what blocks a merge and no more. What
was left out on purpose is listed in the plan so it is not lost.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-20 20:07:12 -07:00
swaitsandClaude Fable 5.2 80e08291b8 docs(routing): long runs go to Haiku, short ones to Ember
Ember twice ended its turn while a long command ran, and the command
died with it; it was exact on short runs and on one hour-long single
command. The table now splits run-only work by length.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-20 20:04:08 -07:00
swaitsandClaude Sonnet 5.5 a66b56c5c7 fix(mcp): a close stops only the work on its own book; each book has its own turn
Closing or opening book A must never block, fail, stop or delay anything on
book B. Two things were server-wide: the stop a close raised for the admin
jobs (a close of one book stopped another's restore, create and adopt, and
refused opens of others while it ran), and the one lifecycle lock a close
held for its whole length (an open of another book waited out the close's
last backup).

Each book now has its own turn and its own stop (Books::lives). A close of X
stops the work on X only: an open of X and a restore that replaces X. A
create, an adoption and a restore that replaces nothing make a new book, which
no close of a book is the close of; only the server's own close stops them
(and every other job: stop_every_job). The stop is lowered while the book's
turn is still held, so an open queued behind a close is not told it was
stopped by a close that is over. The server's close no longer takes a lock:
every admin job has ended by then. "One at a time" remains for making books
(run/books.lock, ledger_store::root INVARIANT 5), where a queued job leaves at
once when stopped.

INVARIANT 10 now names the calls that are neither stoppable nor bounded by one
request, with their worst cases, so the close's bound as written is true:
books.import_bank_csv (a full import of the largest file accepted), a report
over the whole book, and a package after its decision is journaled (one build
over the whole book).

Tests: a restore over beta, a create and an adoption in flight while acme is
closed and opened over and over, its close slow, with another book opened and
closed during each close (mutations: a server-wide stop; one global lock);
a close stops the restore and open of its own book, and the server's close
stops every job; the hammer also makes books and cycles a third book; a close
before a package's decision journals nothing and one after it does not stop it
(mutations: no look before; a stoppable build after). Spec blocks,
docs/mcp-interface.md and docs/testing.md updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 19:57:16 -07:00
swaitsandClaude Fable 5.2 606e2bb4f9 docs(delegation-log): the tabs review and fixes, Ember's runs, P15 A1 round four
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-20 18:52:56 -07:00
swaitsandClaude Sonnet 5.5 aa64df9a25 fix(mcp,store): a close stops every call and job that can run long, and says so; an unrecorded refusal never ran
A close waited, unbounded, for a running books.back_up_now (git only Backups::shut
could cancel), for a restore, create or adopt (they hold the one lifecycle lock,
and at the server's close admin_jobs.wait() waited for them before anything was
released), and, through the store lock, for a verification or a package reading
every stored file. The bound's T_calls term was not finite.

Now a close calls hurry at its start, and the stoppable work looks at it:
books.back_up_now and timer-asked backups (git stopped, a stopped run records
'stopped' and no result of its own), books.verify (per journal line and file; a
heal of a drifted database is begun only if no stop came before it: stopped half
way it would leave the live ledger part replayed), books.export_cpa_package (per
stored file). Such a call answers that it was stopped because the books are
closing, and its access record says refused: stopped_by_close. On the admin
socket restore, adopt, create and open take a JobStop: asked at each phase and
file copied, they remove what they wrote and leave the root byte for byte as it
was; the renames that put the books in place are the point of no return, after
which they finish (two renames and two syncs). A close of any book, and the
server's own, raises the flag before it waits for the lifecycle lock.

A close whose last backup had to be killed in the owner's folder now says which
file was left, and the target's backup is marked failed by shut when the run's
future was dropped at its bound. INVARIANT 10 is rewritten so each term of the
bound is enforced by code, and lists the calls that can run long (and the one
known exception, books.import_bank_csv); INVARIANTS 8 and 9 say exactly which
refusals are recorded and why an unrecorded one never ran; the format upgrade's
wording says a stop is honoured up to its final look.

Tests: the close is held to the bound while a backup call, a verification, a
package and each admin job is running and would never end; the stopped job leaves
the root byte for byte as it was; a lock left in a backup folder is reported and
never removed. Sleeps that stood for 'the other side got there' now wait on the
condition (Expect: 100-continue for a half-sent body, a writable named pipe for a
fetch that is reading).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 17:15:36 -07:00
swaitsandClaude Fable 5.2 878382e5f9 docs(delegation-log): P15 A1's third round, its review and a run cut short
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-20 16:13:23 -07:00
swaitsandClaude Sonnet 5.5 f6daba558b fix(mcp): a close is bounded, the server's close is the book's close, and the tests prove what they claim
Close bound. A drill ran to its end however large the book, and a format
upgrade counted by the store's close held it, because only git was
cancellable. Now a close hurries them at its start (Backups::hurry): a drill
stops at its next look (git killed, journal line, file, chunk) and its
scratch clone is removed, nothing said of its target (it is due again at
open); a format upgrade is stopped before its journal.format_set line is
appended (reported not done, the books unchanged) and finishes once it is.
The close's last backup, and shut's stop of what is left of it, are not
hurried. INVARIANT 10 now states the bound as the sum of its named parts.
Lock files a stopped git left are removed by the store (previous commit) and
recorded here (lock_removed / lock_left, also those found at open).

Server's own close. It cut a stalled body only after admin jobs, store
closes and the serial 60 s backups, and never shut a gate or closed a log.
It is now Books::release for every open book (gates shut and the cut set for
one grace at the start, books released together, logs, uploads, exports,
backups and store closed), so there is one closing path; INVARIANT 15 says
what is true. A request that finds a shut door during the server's close is
refused as closing, not recorded.

Tests that passed with the fix removed. The timers test now holds a timer
between taking a book's handles and acting on them (--timer-hold), closes the
book in between and requires the tree not to move; the slow-upload test is
driven by conditions (a minute's grace) and has a mirror proving the cut of
an active upload; the line of the cut (a body read to its end is never cut)
has a unit test; a slow drill (--slow-steps) and a format upgrade are held by
the close test; REAL git killed inside init, a commit and a push by a close
leaves no lock and the next backup succeeds (this found that a killed init
left HEAD.lock, fixed in the store); the server's close with a stalled
upload and a stalled call exits 0 with both cut.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 13:10:41 -07:00
swaitsandClaude Sonnet 5.5 ca6f5aa982 fix(store,mcp): a type claims only what it does alone, and a restore never says 'no such books'
ledger-store: a file coming in (Uploads::receive) now writes each chunk under
the lock a close takes and stops at the first chunk after a close, removing
its part; an export fetch (Exports::get) reads under that lock, so a close
waits for it. The INVARIANTS say exactly this: after close() returns no byte
is written or kept and none is read for a caller; the one thing a request
begun before the close does after it is remove the part file only it made;
a request still waiting for its next bytes is not woken by the type (the
books server's gate waits for it and cuts one that never finishes).

ledger-mcp: a restore over an open book took the book out of the list
before it shut the door, so every call while the restore waited for what was
inside got 404 'no such books' for a book that exists. The door is shut
first and the book listed closed: such a call gets the closed refusal (503,
the words), as in a close. The drain test now requires 503 throughout.
(A refusal at a shut door is not written to the access log, as in a close:
INVARIANT 11.)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 12:22:19 -07:00
swaitsandClaude Fable 5.2 89e8a5531e docs(delegation-log): the day's build, fix, review and run tasks on P15
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-20 12:00:21 -07:00
swaitsandClaude Fable 5.2 d0bb3ef1ee docs(plan): D-88, every write is one transaction that happens exactly once
The owner's rule, given when a retried write after a lost answer turned
out to record twice. Reading the write path showed more than that: a
tool call may append several journal lines with nothing joining them, so
a crash between them leaves part of a call in the books. The plan now
says what the code does today and the rule that replaces it: a call's
lines commit together under a closing line, every write carries a
request key, a repeat returns the answer first given, and a failed write
is on record. It is a journal feature, built as its own unit before the
remote door.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-20 11:50:51 -07:00
swaitsandClaude Sonnet 5.5 ce636adbb5 fix(mcp): a close cuts a request that never finishes arriving, so a stalled client can't hold a book open
A client that begins an upload or an MCP POST and stops sending is inside
the book's door, and the close waited for it with no bound. Now, when the
close's answer grace runs out, every request inside whose body has not been
read to its end is cut: connection closed, an upload's part file removed by
receive's read error, the access record (written before the answer) says
cut_by_close. A body read to its end is whole and never cut, so a running
call still finishes. Nothing of an MCP call can be journaled by a cut: rmcp
reads the whole body (expect_json) before any message reaches a session or
tool, and the handler checks for the cut again before binding a session.
Holds for a book's close, a restore over an open book (Books::release) and
the server's close. The restore-waits test now uses a grace longer than its
5 s watch: an upload finishing within the grace is still waited for.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 11:44:13 -07:00
swaitsandClaude Sonnet 5.5 26b42c6d01 fix(mcp): after a close is answered nothing of this process can write to the book, and a close says when its last backup wasn't whole
A close ended with the process still alive, so the faults that process
exit used to bound now lived on: something of the server's own could
still write to a book that was reported closed, or, once the book was
opened again (here or by another process), to the new book's files. One
rule now: after a close is answered this process holds nothing that
writes to the book's folder, and every path that touches the book is
either counted by its gate or checks, under the lock of its own write,
that the book is still open. The close answers only when that is true.

 * A refusal's access record is written by a task that carries the
   request's place inside the door, so a client hanging up no longer
   leaves the record to land after the close; the access log, uploads,
   exports and backups are closed under their own locks by the close, so a
   record, sweep or run still on its way is refused, unwritten.
 * A restore over an open book lets go as a close does (drain, sessions,
   backups, closing the logs) before it moves the book to legacy/: an
   upload half received no longer leaves its part in legacy/ nor writes to
   the replaced book's log after.
 * The backup at a close is bounded, and a run past its bound is stopped
   (git killed with all it started) and waited for to end, instead of its
   future being dropped while its blocking task went on; the close answers
   closed_backup_incomplete, with why, when the last backup wasn't whole.
   The server's own close does the same.
 * Every timer (the sweep, the look for a backup due, the look for a drill
   due) works on handles closed with the book; the sweep also takes its
   place inside the door. They take --timers for tests.
 * A format upgrade, run, drill and record through a backup handle from
   before a close do nothing.
 * A call whose answer isn't read within the grace is the case of a
   connection dropped at any other moment: its record, written before its
   answer, says it ran. No journaled call carries a client key or a
   duplicate check, so a retry isn't made safe; said in INVARIANT 14, and
   left as an open design point.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 10:30:56 -07:00
swaitsandClaude Fable 5.2 fe44595840 docs(routing): Muse Ember is listed but refuses the account; run-only work stays with the scout row
Its first task failed at once with "model does not exist or you lack
access". The table keeps the row and the note says to try again at the
next batch. The delegation log gains the GL.iNet research line.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-20 09:51:39 -07:00
swaitsandClaude Sonnet 5.5 8056e3bbc8 fix(mcp): a close doesn't wait on a client's open event stream
A standalone event stream (the GET an MCP client keeps open) is no answer on
its way out and ends only with its session, which a close ends after it has
waited for the answers: counting it as an answer made every close sit out the
whole grace (10 s) whenever an assistant was connected, and a bridge asking
meanwhile could stall for its own 60 s. Only POSTs are counted, as the
server's own close counts them. A hand demonstration found it; the new test
(an rmcp client with its stream open, the close answered within 5 s) fails
without the fix (12 s).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 09:50:06 -07:00
swaitsandClaude Sonnet 5.5 89403a7159 fix(mcp): a close waits for the answers on their way out, and test it under a hammer
The first run of the hammer (agents calling two books while one is closed and
reopened over and over) found a real race: an MCP request's handler returns
as soon as the session's task has the request, and the tool's answer streams
back afterwards. A close that waited only for handlers and running tools
could end the sessions while an answer was still on its way, so a call that
did not run (refused as closing) reached its client as neither answered nor
refused. The gate now also counts answers on their way out (Answering,
carried in the response body as the server's own close counts them), and a
close waits for them, for ANSWER_GRACE at most, before it ends the sessions.

The hammer (tests/book_open_close.rs) replays both journals afterwards:
every acknowledged draft is there exactly once under the id it was told, no
refused call left anything, the closed book's journal and access log never
moved between the close answer and its reopening, the other book never
refused a call and kept answering while the first was closed. Beside it: a
server started with --open, the sessions request over the real socket, the
doctor's lines, and the docs (mcp-interface, architecture, testing).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 09:23:39 -07:00
swaitsandClaude Fable 5.2 526c27233e docs(plan): P15, certificate authorities are a list the relay serves; routing gains Muse Ember
The owner wants Let's Encrypt swappable. Every candidate speaks ACME,
so the app knows the protocol only and takes the authorities to try
from the relay service; a swap is a server-side change, and the tests
fail over between two configurations.

docs/routing.md: Muse Code lists muse-ember-1.0 as of today, so
run-only tasks go to it, as the owner asked on 2026-11-09.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-20 08:44:28 -07:00
swaitsandClaude Fable 5.2 81a50114bd docs(plan): P15, the relay serves the domain's DNS, and the certificate precedent with quotes
The relay answers for wanderbooks.link itself: every name is at the
relay, and a proof code is the one an app just handed in, so nothing is
stored per user. The owner doubted that a certificate per installation
is what Let's Encrypt is for; the plan now carries what Tailscale, Home
Assistant Cloud, Plex and Let's Encrypt's own pages say, the one denial
found, and the fallback authorities.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-20 08:37:21 -07:00
swaitsandClaude Fable 5.2 c18800e96c docs(plan): P15, the app as the host and a relay for web assistants
A design, nothing built. The detached host is what makes packaging hard
on each system, and the people the product is for use chat products in a
browser. So the app's window becomes the host (a tab per open company,
agents reach a company only while it is open), and web assistants reach
the app through a relay on wanderbooks.link that routes by name and
cannot read traffic, the app holding its own certificate.

The owner's decisions of 2026-11-20 are D-77 to D-82; D-83 to D-86 are
proposed and wait for him. The bookkeeping rules do not change: the
window still only reads, and every entry still goes through the tools.

The delegation log gains the nine research and reading tasks behind it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-20 08:25:56 -07:00
swaitsandClaude 3bc198594b fix(host): APPIMAGE is believed only when this program runs from that image
The AppImage launcher sets APPIMAGE (the image's file) and APPDIR (where
it is mounted) for the program it starts, and every program that one
starts inherits both: a terminal, an editor, an agent's app. The host's
start, the agent's pointer file, the host's check for a replaced program
and `update` each read APPIMAGE and believed it whenever it named a file.

So a wanderbooks run from inside another app's AppImage took that app's
image for its own:

- it started that image as the host, and the books never opened ("the
  books server keeps failing to start");
- `connect` would have written that image into the agent's pointer file;
- `wanderbooks update` replaced that app's file with wanderbooks.

Found by the batch's gate: the_host_outlives_the_app_scope_that_started_it
passes its own environment on (the other tests clear it), and this gate
ran in a session started from an AppImage app. The first and the third
are reproduced by two new tests, which fail without this change (the
update test read an ELF header where the other app's file had been).

The rule now (start.rs INVARIANT 6, from the AppImage documentation's
"Environment variables"): the image is this program's own only when
APPIMAGE is an absolute file, APPDIR an absolute folder, and the running
executable's file is inside APPDIR, compared as resolved paths. One
function decides (`own_appimage`), and all four readers ask it. The host
is handed APPDIR beside APPIMAGE, and neither unless both are its own.

No books and no figure are touched. The tests that pretend to be an
AppImage now set APPDIR as a launcher does; translocation.rs used a bare
APPIMAGE to stand in for a macOS path, the very thing this closes, and
names the program's folder as the mount.

The failing test's message now lists the lines that did arrive, which is
what showed the host was refused rather than slow.

Not checked against a built AppImage (none has been built with this
change): the first trial of one shows `update` and a restart find the
image.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-10 02:28:05 -07:00
swaitsandClaude ef86f7820a build(check): every crate is held at zero Decimal arithmetic outside the kernel (K-U12)
The viewer was the last crate with arithmetic of its own on amounts. With
it at zero, `just kernel-only` runs the detector over all eleven crates,
and it now fails when a folder under crates/ is not in its list, so a new
crate cannot do money arithmetic of its own from the day it is added.

Why it matters for the books: the proofs (Kani, Lean) are about the
kernel. A sum or a product computed anywhere else is one they say nothing
about, and rust_decimal's own operators either panic or round without
saying so. Bar item 1 of AGENTS.md is now a property the compiler checks
for the whole workspace, not a rule to remember.

Checked on main after the merge: the detector reads 0 places and 0
waivers for ledger-gui, the crate's whole test suite passes in one run
(300 passed, 0 failed, 1 ignored), clippy with warnings denied and fmt
are clean.

docs/proofs/k-u12.md is the account: the 183 places by crate, the rule
each kind followed, and the decision for every site that was not a plain
sum or sign.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-10 01:55:11 -07:00
swaitsandClaude 9e3440f5f1 build(check): the tools, exports and imports are held at zero (K-U12)
ledger-import, ledger-package and ledger-mcp join kernel_only_crates:
the detector reads 0 for each on main, their suites pass and clippy is
clean, so the lint part of `just check` now refuses a new raw Decimal
operator or rust_decimal method in ten of the eleven crates. ledger-gui
is the one left.

The delegation log has the task's line.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-10 01:00:04 -07:00
swaitsandClaude b0353c87d5 docs(routing): Muse Code still does not list Ember (checked before K-U12's delegations)
Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-10 00:27:15 -07:00
swaitsandClaude 1c28760d87 refactor(store,config): their Decimal arithmetic goes through the kernel (K-U12)
Ten places, now zero, and both crates join kernel_only_crates so the lint
part of `just check` holds them there.

ledger-store (8): a disposal's preview adds the asset's posted runs and
takes book value and gain or loss by subtraction; an attested receipt is
compared with the entry's debits; an older settlement's remainder is the
document's total less what was recorded. Each called rust_decimal's own
checked_add or checked_sub, which rounds where the exact answer needs
more than 96 bits and says nothing. They call the kernel's now
(kernel::total_of, Amount::checked_add and checked_sub): exact, or the
refusal each of these places already had (too_large, or no figure to
compare). Two unary minuses go through money::neg. Posted lines are
bounded (BS-entry-3, BS-entry-4), so no figure in real books changes.

ledger-config (2): a member's "50%" is divided by a hundred through
Amount::checked_div (the raw `/` computed the same quotient), and the
members' shares are added by kernel::total_of. Shares that cannot be
added exactly are refused with a sentence saying to write them with
fewer places, where the raw sum would have rounded them and then
compared the rounded figure with one. ledger-core's own check of the
same setting already did this.

Checked: the detector reads 0 for both; both crates' suites pass (682
tests); clippy with -D warnings.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-10 00:27:14 -07:00
swaitsandClaude a7b6ed0304 build(check): no Decimal arithmetic outside the kernel, held by the lint part (K-U11a)
AGENTS.md's bar says money arithmetic lives in the kernel and nowhere
else, because the proofs are about the kernel only and because a raw
operator panics where rust_decimal's own methods round silently. Nothing
checked it, and 210 places in ledger-core broke it.

`just kernel-only` runs scripts/raw-decimal-arith.sh over the crates
named in kernel_only_crates and fails on the first place found; the lint
part of `just check` runs it. The list is ledger-core, now at zero, and
the four outer crates that never had a place (ledger-cli, ledger-host,
ledger-reader, ledger-vault). The other six join as K-U12 brings each to
zero.

docs/proofs/k-u11.md is the unit's account: what was measured, what each
group of sites became, what exact arithmetic refused and why, and what
the detector does not show (that a site calls the right kernel function;
the tests and a reading of every long figure carry that).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 23:27:24 -07:00
swaitsandClaude c5c57aaf4b docs(plan): K-U10 landed: the triage, the status and the log say so
The triage marked exact Decimal arithmetic and the tie rule as in
flight; both are on main. It now says what each closed, the one figure
a new foreign line can book differently (the exact product's cent,
10500000099.89 where the double rounding booked .90; posted lines are
not recomputed), and what the checks found that the workers' own runs
did not: an exact division that accepted a rounded quotient, the six
review findings, and the Kani cover the tie change made unreachable.

The comment in add_line_fx said a 20-place product past 7.9e8 rounds
twice; since K-U10 the kernel holds that product in 256 bits and rounds
once. The K-U1 note's open edge points at the unit that closed it.

Three lines in the delegation log: the two hard implementations and the
review.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 22:41:34 -07:00
swaitsandClaude 5e9591725a merge: a tie between shares goes to the earlier part, exactly (K-U10b, D-76)
The rule (BS-partner-1, bookspec's Apportion) is that leftover cents go
to the largest remainders, ties to the earlier part. The engine ranked
the difference of quotients rounded at Decimal's 28th digit, so an exact
tie went where that digit sent it: 20.00 by 4/1/1 came out 13.33 / 3.34 /
3.33. It now ranks the exact remainder, whole x weight - part x total,
and gives 13.34 / 3.33 / 3.33. The owner decided for the exact ranking on
2026-11-09 (D-76, recorded here).

What moves: no golden, nothing between two parts or by equal weights, at
most a cent a part elsewhere (tests/kernel_bridge/ties.rs measures it).
Of the engine's splits only the K-1 worksheet's share of contributed
property divides by a total that is not one; a convention's split and the
frozen close rule already ranked exactly. Posted splits are not
recomputed.

Changed in the merge:
- The ranking's two products are the rounding ones (checked_mul_rounded).
  The kernel's checked_mul is exact or refused since K-U10a, and would
  refuse a split by weights of 27 places; the split is made, ranked by
  the nearest figures Decimal holds. A test splits by thirds, sevenths,
  ninths and elevenths at 27 and 28 places, both signs.
- Kani failed the unit as it came: with the exact ranking a part whose
  share is exact never takes a leftover unit (5 by 2/3/5 is 1, 2, 2, where
  i64's truncated quotients gave 2, 1, 2), so the cover "a part exactly
  one step above its truncated share" could not be reached. The harness
  split_by_weights_within_one_step now asserts the strict bound and that
  an exact share takes no unit; both covers are reached.
- docs/verification.md also takes K-U10a's account (sums and products
  exact or refused), which closes the edges it listed as pinned.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 22:39:13 -07:00
swaitsandClaude e632855f13 merge: Decimal sums and products are exact or refused (K-U10a)
rust_decimal rounds a sum or a product whose exact figure needs more than
its 96-bit mantissa or 28 places, and says nothing. The kernel's Amount
for Decimal now refuses instead: checked_add, checked_sub and checked_mul
return the exact figure or None. Two products keep their meaning under
their own names: checked_mul_rounded (a proportional share by a weight of
many places, a rounded figure by construction) and
checked_mul_round_to_step (a foreign amount at a rate: the exact product,
held in 256 bits, rounded once). checked_div_exact no longer accepts a
rounded quotient that happens to multiply back.

Within the line cap (10^15, ten places) sums and differences are the old
ones to the character, and no golden moves. One figure a new line can
book does move, the one the old double rounding got wrong: a foreign
amount at a rate whose exact product passes 96 bits (1050000010.0000000001
x 9.9999999999) books 10500000099.89, the exact product's cent, where it
booked 10500000099.90. A line already posted is not recomputed: replay
reads the booked amount.

Reviewed before merging by a second model, which sampled the 256-bit
arithmetic (no wrong figure) and found the properties proved soundness
only. They now prove the other direction too, from the rational alone:
nothing Decimal could hold is refused. One refusal is new and stated: a
product that is not exact, rounded to a step of 27 or 28 places.
docs/proofs/k-u10.md has the whole account.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 22:39:13 -07:00
swaitsandClaude 5777787b69 test(core): exact Decimal arithmetic refuses nothing it could hold
The independent review of K-U10 found the bridge properties proved one
direction only. They compared the kernel with an expectation built from
rust_decimal's own result, so they showed a figure returned is exact, and
could not show that an exact figure is never refused. Each of add,
subtract, multiply and exact division is now also Some exactly when the
rational result is a Decimal (a mantissa under 2^96 at a scale of 0 to
28), decided from the rational alone. All hold: no change to the kernel.

Also from the review:
- the FX product rounded once is checked at steps of every scale, not 0 to
  3 places, and a None is accepted only at the two bounds the code states;
- one refusal the docs did not state is now stated and pinned: a product
  that is not exact, at a step of 27 or 28 places, is None though its
  rounded figure can be a Decimal (the one rounding needs two places
  below the step and Decimal ends at 28). No currency's step is near it;
- running totals are checked over thousands of lines, and the first
  refusal is pinned (line 7,923 of the largest ten-place amount, where
  rust_decimal drops a place and rounds);
- three stale sentences: percent_of's product is exact or refused since
  this unit (only its division rounds), the header of allocate.rs, and
  the table in docs/proofs/k-u10.md, which now records the review.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 22:18:54 -07:00
swaitsandClaude 164adc0b32 docs(plan): the notices landed: what checking them found, and the log line
Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 22:00:44 -07:00
swaitsandClaude 7568bca7b0 build(notices): a crate's own licence file where the generator gave a placeholder
MIT, BSD and ISC ask that the copyright notice itself travel with a copy,
not only the licence's words. For 70 of the crates the program links,
cargo-about could give only the licence's standard text, whose copyright
line is a placeholder ("Copyright (c) <year> <copyright holders>"):
the crate's own licence file is a compound one it cannot match (chrono
and libm put two licences in one file, aws-lc's is 316 lines of several,
the windows crates indent theirs), or the crate was packaged with no
licence file at all (egui, objc2, wasmi and 32 more).

scripts/notices-packaged.py reads cargo-about's output, finds every
section with such a placeholder, and adds a part to the file: the licence
files those crates were packaged with, whole, each distinct text once
under the crates that carry it, and for the 35 packaged with none the
repository their manifest names. It reads the crates where cargo has them
(cargo metadata, locked and offline), so the text still depends on
Cargo.lock alone; two runs are byte-identical. The file grows from 551 KB
to 707 KB. The test for `wanderbooks licenses` now asks for a copyright
line that only a compound file holds.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 22:00:44 -07:00
swaitsandClaude 9d1cb28f22 merge: third-party licence notices, generated, checked and printed by the program (checked, small rework)
Every MIT, Apache, BSD and ISC crate and every bundled font asks that its
notice travel with a copy of the binary. THIRD-PARTY-NOTICES.txt is
generated from the lock file (cargo-about) and the font licences, compiled
into the program and printed by `wanderbooks licenses`; the lint part of
`just check` fails when it is out of date.

Checked before merging: the accepted list equals deny.toml's; two runs are
byte-identical; the check exits 1 on a changed file and 0 after
regenerating; no path or user name in the text; the three ledger-cli test
files pass (licenses 4, hostile_args 6, one_executable 9); fmt and clippy
clean.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 21:46:23 -07:00
swaitsandClaude 7992c78d30 build(notices): say why the generator is offline, and what to do when it fails
cargo-about is run with --offline so the notices text is the same on
every machine: it reads only the files each crate was packaged with, and
never looks in a crate's repository for a licence file the package left
out. Today the two give the same text, byte for byte. The cost is that
every crate in Cargo.lock has to be in the local registry, every
platform's included, so a failure now says to run `cargo fetch --locked`.

The check is not seconds: it reads every crate's files for licence text,
about two minutes of wall clock. docs/testing.md says so.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 21:46:23 -07:00
swaitsandDeepSeek V4.1 Flash 9baf71b2a5 feat(cli): wanderbooks licenses prints the notices compiled into the program
The notices must reach the person holding the binary, not only the
repository: THIRD-PARTY-NOTICES.txt is compiled in with include_str!,
so `wanderbooks licenses` prints the program's version line and then
every crate's and font's licence without opening books or reading a
file. A closed pipe (`| head`) is ignored, not a panic.

Tests check the version line, the notices required in the output, that
the bytes after the header are exactly the repository's file, and that
the mode takes no arguments and must come first like every other.

Docs: the testing table says what `just notices` writes and how
`notices-check` fails on a stale file; the architecture's list of modes
names licenses.

Co-Authored-By: DeepSeek V4.1 Flash
2026-11-09 21:17:56 -07:00
swaitsandClaude e46fa4fc6e fix(core): an exact division refuses a rounded quotient
`Amount::checked_div_exact` promises the exact quotient or nothing: "never
a rounded share". On Decimal it checked the quotient by multiplying back,
but with rust_decimal's own product, which rounds. A rounded quotient
times the divisor rounds back to the dividend (10 / 3 is 3.333...3 at 28
places, and 3.333...3 x 3 is held as 10), so a third, a seventh and a
ninth all passed as exact.

No figure in the books was wrong: the one caller divides a basis-point
product by 10,000, which is always exact. The contract was broken for
the next caller. The check now multiplies back exactly (K-U10's
`exact_mul`), so a rounded quotient is refused.

The bridge gets the property (a quotient returned, times the divisor, is
the dividend as a rational) and the named cases. The FX rounding
property also takes steps of 5 and 25 units, whose half steps sit one
place below the step: the wide product keeps that digit real.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 21:05:43 -07:00
swaitsandClaude c09f492c46 docs(verification): every Ledger command, and the step of the Lean model it is
bookspec proves its laws (the trial balance, the accounting equation,
posted is forever) for every state its steps reach. The engine has 119
public commands and the model 14 steps, and nothing said which command is
which step, so "every reachable state" read wider than it was.

docs/command-steps.md is that map, command by command: 71 are the
`record` step (they change how the books are kept and no figure), 11 are
one step, 19 are several steps run as one, 17 are the doors a journal is
replayed through, and one, `renumber_account`, is no step at all.

What the map shows that was not written down before:

- A renumber changes the chart's codes and the model has no step for it.
- Four doors apply a journaled change without a check the model's step
  requires (a draft dated in a closed period, a period overlapping
  another, a reversal dated before its original). Books replayed from an
  old journal can therefore be outside the model's reachable states. The
  laws resting on distinct codes, acceptable entries and known accounts
  still hold by reading their proofs; no theorem says so yet.
- The registers (assets, schedules, recurring entries, payroll runs) have
  proved arithmetic and no model of how they change over time.
- No proof ties a Rust command to its step: bookspec's examples and the
  differential test do, and the page lists what that test does not reach.

Each closes with Lean in bookspec; the triage (P2.5) lists them.

tests/command_steps.rs keeps the map whole: a command with no row, a row
with no command, a step the model does not have, or a new command marked
as no step without being added to the pinned list fails the build.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 21:00:11 -07:00
swaitsandClaude Sonnet 5.5 38da08b2c2 fix(core): Decimal sums and products are exact or refused
rust_decimal's checked_add and checked_mul return None only when the
integer part overflows. When the exact result needs more than 96 bits of
mantissa, or a scale past 28, they round it and return Some: MAX + 0.4 is
Some(MAX) (K-U4), 0.01 + 792281625142643375935439503.35 is ...503.4
(K-U8), 1050000010.0000000001 x 9.9999999999 is 10500000099.895 where the
exact product is 10500000099.89499999999999999999 (K-U1), and
123456789.0123456789 squared loses its last digits (K-U3). The kernel's
contract is exact or None, and BS-ledger-1 says a product the arithmetic
cannot hold MUST be refused.

impl Amount for Decimal now runs rust_decimal's operation and checks, in
256-bit integers (kernel/decimal_exact.rs), that the figure equals the
exact sum or product as a rational; otherwise None. It builds no rounded
figure of its own, and an exact result is returned as rust_decimal gave
it, scale and all, so nothing exact moves. Comparing values is complete
where the K-U10 row's "result scale fell below the operands'" test is not:
100 x 0.3333333333333333333333333333 is exact with a full-scale mantissa
past 96 bits (trailing zeros), and percent_of computes it for every
ratio. checked_sub is rust_decimal's subtraction under the same check
(the trait default gave -0 for 0 - 0). Money::checked_add and
checked_sub go through Amount; sum_exact*, add_exact and sub_exact already
did.

Two products could not simply become exact, and the suite found both:
- Shares multiply a cent amount by a many-place percent
  (33.333333333333333333333333333, 27 places) and then divide, which
  rounds anyway (spec_cash_flow's government payment). They use the new
  Amount::checked_mul_rounded, rust_decimal's own product, so every share
  is the figure it always was.
- A foreign amount at a rate (fx_booked) rounds once, from the exact
  product: Amount::checked_mul_round_to_step holds it in 256 bits, cuts it
  only as far as Decimal needs with a sticky digit for what was cut, and
  rounds with round_step. The one posted-range figure that moves is the
  one the old double rounding got wrong: 1050000010.0000000001 x
  9.9999999999 books 10500000099.89, the exact product's cent, not
  10500000099.90.

checked_div and checked_div_exact are unchanged. Inherent
Decimal::checked_* calls outside the kernel are listed in
docs/proofs/k-u10.md and not converted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 20:46:19 -07:00
swaitsandClaude ae23efe5a3 docs(plan): K-U9 landed: the log line, and the outer crates' counts after it
The detector, run again on the three crates K-U9 touched: ledger-gui
123 places of money arithmetic outside the kernel (was 137),
ledger-import 18 (was 22), ledger-package 13 (unchanged: its sums are
totals, not display rounding).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 20:44:40 -07:00
swaitsandClaude 0e9990f111 merge: one rounding for display, percentages in Decimal (K-U9; checked, one fix)
Three crates each rounded an amount for display in their own way, and
the viewer computed its percentages in f64. Money is never a float, not
for a ratio either (AGENTS.md's first rule), and a figure shown should
not depend on which renderer drew it.

- `ledger_import::format::round_display(amount, places)`: half away
  from zero through the kernel's `round_places`, never a negative zero.
  The reports' text, the PDFs, the spreadsheet, the CPA package's text
  and the viewer's formatting all call it.
- The viewer's percentages (`fmt::pct_change`, the Profit page, the
  reports' change and share-of-income columns) are the kernel's
  `percent_of` on Decimals.

What a reader sees differently, by principle and not by accident:
- `compact` rounds half away from zero like every other figure:
  1,250,000 reads $1.3M (was $1.2M), 10,500 reads $11k (was $10k).
- A change against a base that is zero or negative shows no percentage
  ("—"), where it used to show one with a misleading sign: from a loss
  of 100 to a loss of 50 is not "50% down".

No booked figure moves and no golden changed. One fix on merge: the
demo books' platform fee is a booked amount, so it uses the kernel's
rounding with the rule it always had (a half to the even cent), not the
display rounding the branch had put there; the demo books are unchanged.

Shown on main: clippy clean on the three crates; ledger-import's unit
tests 44 passed and spec_import, labels, templates 91 passed;
ledger-package 49 passed; the viewer's unit tests 62 passed, and
display_rounding, view_model, sidenav, spec_gui, odd_cent 59 passed;
ledger-core's bookspec checks 78 passed (the worker's one failure there
was its old base, which lacked the pin at bookspec 79cb439).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 20:43:00 -07:00
swaitsandClaude 1726c8b6dd build(deny): a supply-chain gate: advisories, licences, sources (cargo-deny)
Nothing checked what the program is built from. `just deny` now does, in
the lint part of `just check` and weekly in scheduled.yml (an advisory
is published when it is, not when we push), from one file, deny.toml:

- advisories: no crate in the lock file with a known vulnerability
  (RustSec), none yanked; an unmaintained crate is refused when it is
  one of our own direct dependencies. Two advisories are lived with,
  each with its reason and date: the quick-xml 0.38 that typst's
  citation reader brings, which no XML from outside reaches.
- licences: the permissive ones, plus MPL-2.0 for one unchanged crate
  (option-ext) and CDLA-Permissive-2.0 for Mozilla's root certificates.
  No font licence is allowed, so a crate that carries fonts is refused
  and every font we ship is a file here beside its licence. A crate
  offering only a copyleft licence is refused.
- sources: crates.io and the bookspec repository, nothing else.
- bans: no dependency by wildcard version.

The crates are marked `publish = false` (one line in the workspace,
inherited by all eleven): they are parts of one program, not libraries
for crates.io, and with that cargo-deny accepts their path dependencies
on each other.

cargo-deny 0.20.2 is a build tool pinned in mise.toml, not a dependency
of the program.

Shown: `just deny` prints advisories ok, bans ok, licenses ok, sources
ok on this tree.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 20:03:51 -07:00
swaitsandClaude 7359d700d9 docs(plan): the 2026-11-09 triage: what a full evaluation found, in order
One page (plan/2026-11-09_TRIAGE.md) of what is missing or not as the
manual promises, each item with how it is known, what closes it and who
does it. The engine's numbers are not in question; the gaps are in what
the gates did not see: a red Windows gate nobody read, 210 places in
ledger-core and 201 in the outer crates that do money arithmetic outside
the kernel, Decimal sums that round silently, a tie between shares that
went where the 28th digit sent it (the owner's decision D-76: the
earlier part, exactly), no supply-chain gate, no third-party notices in
the packages, and a Lean model of 14 steps against about 100 commands.

docs/routing.md: Muse Code still lists no Ember (19:30 MST).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 19:50:40 -07:00
swaitsandClaude 5e84ff7a79 docs(testing): CI's check is five parts, from the justfile's one list
5544a3e66 split the `check` job into five parts on five runners; the
page still said one job runs `just check`. It now names the parts, how
to run one here, and that the lint part fails when the workflow's list
is not the justfile's.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 19:50:40 -07:00
swaitsandMuse Wonder 1.0 2463c10af9 test: display rounding and percent rules (K-U9)
Tests encode the display rules: half away from zero, no negative zero, no percent of a zero or negative base, plus a scoped source check that no round_dp or float conversion remains in the money display paths. view_model's pct_change(-100, -50) expectation moves from Some(50.0) to None under the new rule. docs/proofs/display.md is the unit note (no Kani, no Lean for display, per the audit).

Co-Authored-By: Muse Wonder 1.0
2026-11-09 18:54:30 -07:00
swaitsandClaude fe3b10e2d1 test(prove): a cut-off Kani run names what failed and what never finished
`just prove` ran its 97 fast harnesses under one 30-minute `timeout` and
nothing else. On a machine busy with other builds the run was ended with
exit 124 and no harness named, so a proof that failed could not be told
from a proof that was only slow, and the answer was to run it again and
hope. A gate that cannot say which is not a gate.

Now each harness has its own cap (Kani's --harness-timeout,
KANI_HARNESS_CAP, 900 s: the fast harnesses each take under four minutes
on a busy machine, the longer ones are in kani_slow under their own
caps), the whole set's cap is KANI_FAST_CAP (1800 s as before), and a
run that does not verify every harness lists each one that failed, each
that ran past its cap, and each that never finished.

No proof changes: the caps bound how long a harness may take, not what
it must show, and the count of verified harnesses and the cover check
are as they were.

Checked: the report read against a real run in which one harness passed
and one hit a 15 s cap (the second named as past its cap); and
`KANI_FAST_CAP=2 just _kani fast` exits 1 naming all 97 as not finished.
A full `just prove` is the batch's gate.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 17:54:45 -07:00
swaitsandClaude 647302f7e5 docs(routing): V-D3 in the delegation log; Muse Code still lists no Ember
Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 17:32:57 -07:00
swaitsandClaude abafa94a53 merge: the audit checks a close's split at the allocation's unit, and a legacy close by its member count (V-D3)
The audit took a cent for every currency, so a JPY close (split in whole
yen) was checked a hundred times too finely, and a code with no minor
unit too coarsely. The unit now comes from the one helper the split
itself uses. Before the true-up, a last-absorbs close's last member may
carry half a unit for each of the others (BS-partner-1 statement 6), so
the bound is max(u, (n-1)u/2), derived and marked so, not one unit.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 17:02:26 -07:00
swaitsandClaude 8ad55e82a8 docs(routing): keep checking Muse Code for Ember, and use it from the day it is listed
Muse Ember was released today and the Muse Code provider does not list it
yet; only OpenCode does. The owner's rule: do not take the OpenCode
listing, check the Muse Code provider before each batch of delegations,
and route run-only work to Ember once it is there. Until then run-only
tasks stay on the scout row.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 16:38:39 -07:00
swaitsandClaude 05da2dd867 docs(routing): which model gets which delegated work, and a log to check it against
The owner's rule from 2026-11-09: delegated work is routed by what the
task is (scouting, running things, bulk implementation, hard
implementation, review), not by a random draw, and the routing is
adjusted from evidence. `docs/routing.md` is the current table with the
exact provider and model ids; `docs/delegation-log.md` gets one line per
task once it is verified or abandoned.

One row is open: the plan names Muse Ember through Muse Code for run-only
tasks, and that provider does not list it here (OpenCode does). The file
says so, and those tasks go to the scout row until the owner chooses.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 16:27:26 -07:00
swaitsandClaude 129a90dcf1 fix(test): recorded failures are replayed again; a seed file no test reads fails the build
A failure a property test once found is kept as a seed and replayed on
every run: that is what makes a fixed bug stay fixed. Proptest finds
the seed file from the test's source path and says nothing when the
file is not there, so a seed file left behind by a moved test is never
read again, silently.

Four findings, one cause:

- The kernel bridge's three recorded failures (the constructive split
  with a short remainder, and two cash-application cases) sat in
  tests/kernel_bridge.proptest-regressions. Since 0cf013b57 the bridge
  is a folder (tests/kernel_bridge/main.rs), and a folder test reads
  tests/proptest-regressions/main.txt. The three had not been replayed
  since. Moved there.
- K-U8 found a control-total case (a sum that touches Decimal's top,
  f = [0, -1, -79228162514264337593543950335, 0, 5]) and the seed was
  never checked in; it lay untracked in the unit's worktree. Added as
  tests/proptest-regressions/control.txt, where control.rs reads it.
- ledger-mcp's proptest-regressions/local_files.txt recorded failures
  of a module removed in b26c099a6 (files reach the books as uploads
  by hash now). No test can read it. Removed.
- Nothing checked any of this. tests/seed_files.rs walks every crate
  and fails when a seed file has no property test that reads it.

How the reading rule was established, not assumed: a marker line in
each candidate file, and proptest's "unparsable line" warning names
the file it really opens.

With the seeds back, the bridge passes whole (101 tests), so nothing
had regressed behind the gap. The guard was red before the move (it
named both orphans) and is green after: 21 seed files, each read by a
property test.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 16:02:06 -07:00
swaitsandClaude Sonnet 5.5 294cb99a58 fix(core): a tie between shares goes to the earlier part, exactly (held for the owner's decision)
split_by_weights_into's largest-remainder policy ranked the leftover
cents by the rounded quotient's remainder (Decimal keeps 28 significant
digits), so an exact tie was decided by the quotient's last digit, not
given to the earlier part as apportion's docs and bookspec's Lean model
(Apportion.lean: remW = x*w % W, ties to the earlier member) say.
20.00 by 4/1/1 over 6 gave 13.33, 3.34, 3.33 where the exact tie of
remainders (0.02 over 6 each) belongs to the first: 13.34, 3.33, 3.33.

It now ranks the exact integer remainder whole x weight - part x total
(the quantity share_floor_with returns), sign-flipped for a negative
total so the order stays the share's own. The parts still sum to the
whole and each is within one step; only which part takes a tied cent
changes. Stored entries never move (posted is forever); a report
recomputed for a past period can move a cent between parties.

The finding test is flipped into the law (ties_go_to_the_earlier_part),
the bridge's ranking property now includes ties, and the spec block,
k-u3.md and verification.md say ties go to the earlier part, exactly.

This branch is held: the owner decides whether the cents may move
(see tests/kernel_bridge/ties.rs for what it moves).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 15:37:06 -07:00