Commit Graph
675 Commits
Author SHA1 Message Date
swaitsandClaude Fable 5.2 e34b18ec73 feat(gui): one Another assistant card, a popover for Ask your assistant, one Books menu entry
The four untested tools shared one text four times: now one card. The
copied sentence no longer pushes the page down: a popover under the
button. The Books menu's two connect entries became one that opens the
Connect page. Link::Working has no glyph (it is a drawn arc). Shape
baselines re-blessed: assist_{working,none,connected,connect_page,ask}
in light and dark.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 10:16:26 -07:00
swaitsandClaude Fable 5.2 f58191c9de fix(gui): the word a person reads is assistant, with no tool names
The bottom panel, the welcome steps, empty states and notices said
agent, bookkeeper or a books.* tool name; they now say assistant.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 10:16:26 -07:00
swaitsandClaude Fable 5.2 f218bf4552 test(cli): the roster and a key's revoke, through the real books server
A bridge session opened with a key is on the roster; revoking the key
takes the key and its session off, refuses the session's next call and
deletes the token file's copy.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 10:16:26 -07:00
swaitsandClaude Fable 5.2 022c0c642f feat(gui): each company's assistants: three states, Ask your assistant, the Connect page, a warning before closing
P15 unit A4, plan 3.3 and D-79. The window only reads the books, so it
now says so by what it offers. Each company is in one of three states
(no assistant, connected, working) read from the books server's own
sessions answer, never waited for, drawn as a shape on its tab and said
in words with the last thing done at the right of the top bar; the
sidebar gives up no height, because the links must all fit at 1479x519.
Where a button that edits would be there is "Ask your assistant", which
copies a ready sentence. The Connect page has a row per local tool with
exact commands, the keys with who is on each, and Revoke through the
existing command path. Closing the window or a tab with an assistant
connected warns first, before and never beside the server's own close.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 10:03:35 -07:00
swaitsandClaude Fable 5.2 1d1a2a5a88 feat(host,gui): the command that reaches a company's books is made in one place
The Connect page of P15 unit A4 shows an assistant the exact command it
must run to reach a company (`<this program> mcp --book ID`, with --root
when a root was named). `connect` already built that command, so it is
now one function (`bridge_serve_args`/`command_line`) used by both, and
the step `connect` does first (the company's default key exists and its
copy is in the token file) is `ensure_key`, which the page offers by
itself for assistants it has no button for.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 10:03:35 -07:00
swaitsandClaude Fable 5.2 016f1b2afc feat(host,gui): the window can ask the books server who is connected, and end a token
Unit A4 of plan P15 needs the window to read who is connected to each
open company and to end a token. Both go through admin requests the
server already answers (Sessions, TokenList, TokenRevoke): the window's
server handle gains a quick roster (an Err in words while the server is
starting, gone or slow; never a wait) and a revoke that does what
`wanderbooks token revoke` does, including removing the token file's
copy. The command that reaches a company's books is now made in one
place (`bridge_serve_args`) for `connect` and for the Connect page.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 09:28:50 -07:00
swaitsandClaude Fable 5.2 02468a824d Merge branch 't3/p15-a2-app-hosts-books-server': the app starts and stops the books server (P15 A2)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 09:21:46 -07:00
swaitsandClaude Fable 5.2 9f3f292bf5 fix(gui): a failed start can be tried again, and a close that was not whole stays on screen
The window retries a failed server start when the next tab opens or when the
person asks, says a server still starting is starting, tells the person which
wanted companies did not open, and when the close reports an incomplete last
backup or a bad exit it stays up with a Close anyway button. ViewerOwner only
forwards to AppHost now, and the format upgrade goes to the window's own server.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 09:21:20 -07:00
swaitsandClaude Fable 5.2 acc17a7703 fix(host): the window's server is managed or stopped, its close and upgrade are said in words
AppHost holds what the window does with its books server, so what the tests
drive is what the window runs. A server that is alive but not ready is waited
for; a failed start, or a window closed before the child was stored, closes
the child's input and waits for it, so no server runs that nothing manages.
The close first closes each open company, so a closing backup that was not
whole, and a server that exited badly, come back as words. The format
upgrade goes to the server as an admin request (there is no host to ask),
and the companies the window wanted that the server did not open are told.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 09:21:20 -07:00
swaitsandClaude Fable 5.2 7357a30c73 test(app): the child's lifetime, tabs driving the server, and the bridge's two messages
The server child starts, closes on input close and on the window's death (a
killed stand-in window leaves no server and a whole book), a stop that runs out
of time leaves it closing and says so, a start is refused while a server or host
holds the books; a tab opened or closed opens or closes that company, in order,
with failures said in words; closing the window waits in view and asks the owner
once; the bridge answers 'Wanderbooks isn't running' and 'Company X isn't open'
in one running session, starting no host. Claims for WB-app-1 to WB-app-4 name
them.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 09:07:34 -07:00
swaitsandClaude Fable 5.2 f476c95a64 feat(gui): a tab is a company open in the app's books server; closing the window closes it in view
The window starts the server with the companies it restores, a tab opened or
closed opens or closes that company in it (one queue per company, so one
company's backup at close delays no other), failures and incomplete backups are
notices under the tab bar, and asked to close the window waits, saying so, for
the server's bounded close (WB-app-2, WB-app-4). The viewer no longer starts a
detached host.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 08:58:51 -07:00
swaitsandClaude Fable 5.2 c8c0f5e0d9 feat(host): the app's books server is a child process; the bridge says in words when the app isn't running or a company isn't open
The desktop app is the host (D-77, D-84): AppServer starts the books server
from the program's own executable, closes it by closing its input, and never
signals it. A window that dies closes the same pipe, so the books close
cleanly. A start is refused in words when host.lock or server.lock is held.
Starting writes run/app-hosted; for such a root with no host the bridge holds
no lease and starts no host, and answers 'Wanderbooks isn't running' or
'Company X isn't open' (WB-app-1, WB-app-3). Owner commands and the viewer
take a lease-less hold on the app's server instead of starting a host beside
it; closing the books and wanderbooks serve say the app has them.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 08:58:51 -07:00
swaitsandClaude Fable 5.2 124be0afd8 test(cli): macOS refuses socket options on a cut connection; a failure names what it waited for
Raw::until_closed set a read timeout on a connection the server had already
cut. macOS answers EINVAL to setsockopt on a socket whose peer has closed,
where Linux accepts it, so five tests failed there before they could observe
the cut they wait for. Such a socket cannot block a read, so that refusal
alone is passed over (a zero bound is asserted against, and any other error
still fails); a read that reports NotConnected is the same cut. The timers
test now says which timer never held, and the hammer test how long each close
took, so a platform failure names its cause. The deaf shim flag (see the
store commit) is used by the lock test.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 08:34:04 -07:00
swaitsandClaude Fable 5.2 b9ef35592c test(mcp): the tree digest names files with / on every system
handles_from_before_a_close_do_nothing_after_the_book_is_open_again adds the
planted stray file to the digest as uploads/stray.bin, but the walk keyed the
same file by the system's path, uploads\stray.bin on Windows, so the two
maps could never be equal there. The helper now keys with / everywhere; the
assertion (an old handle changes no file) is untouched.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 08:34:04 -07:00
swaitsandClaude Fable 5.2 e9dc03a44a test(store): a git that cannot end on SIGTERM is deaf to it, not stopped
On macOS a SIGTERM sent to a SIGSTOPped git ended it inside the grace and it
removed its own locks, so the three tests that need a git the kill must end
failed there (the grace was not waited, no lock was left). A blocked signal
stays pending on every system, and the mask is inherited through exec and
through git's own children: the test shim blocks SIGTERM for a git when a
deaf flag file exists. The program's stop (SIGTERM, grace, SIGKILL) is
unchanged. Checked here with the stop turned off: the tests still pass.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 08:27:50 -07:00
swaits 40d818fb5e Merge branch 't3/fix-linux-ci-failures' 2026-11-20 22:43:10 -07:00
swaitsandClaude Sonnet 5.5 e42c3909fa fix(gui): the tab strip's width is folded, not summed, so kernel-only passes
scripts/raw-decimal-arith.sh refuses an Iterator::sum of any type (it cannot
tell widths from money without types it does not have). The tab widths are f32
layout, no money; a fold says the same and the check reads 0 places.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 22:17:20 -07:00
swaitsandClaude Sonnet 5.5 13e676a101 fix(gui): the tab bar's pictures are compared as shapes, and no picture depends on a temporary name
The stored tab-bar images were compared pixel for pixel on every machine.
GitHub's software renderer rasterizes the same shapes differently from the
GPU that made them (thousands of faint pixels, dozens strong along glyph
edges); sidenav.rs already says so and compares shapes everywhere, pixels
only locally. The tab bar now does the same: a hash of the visible shapes
(tests/snapshots/<name>.shapes, TABS_BLESS=1 writes them), the pixels with
TABS_PIXELS=1. The images are unchanged and still pass locally.

The hash is of a description of each shape, not of its debug form, for
two things in the debug form depended on the run, not on the books: a
glyph's place in egui's font atlas changes with which tests ran in the
process before (the same view hashed differently alone and beside another
test), and the page under a short bar holds the current time, clipped
away, which no picture shows. Shapes whose clip is off the window are
left out.

A new test renders the same companies from two differently named
temporary folders, light and dark, and requires the same hue keys (the
book ids), the same shapes and the same pixels. The sidenav fixture's
copy outside a data root is in a folder of a fixed name, not the temporary
folder's random one, since that folder's name is its badge's hue key.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 21:48:18 -07:00
swaits 7801455336 fix(store): a store's writer lock is free when it is dropped, even with a child forked from another thread
Cause: a book's writer lock is a flock, which lasts as long as any copy of
its open file description does. A child forked by another thread of the
server (git, for another book's backup, on a timer) holds a copy of every
descriptor from its fork until its exec, so a close of book B, answered
after its Store was dropped, could be followed by an open of B that found
the lock still held: "another program has these books open". The open's
failed attempt left B failed, and the next close found it not open. This
broke the unit's rule that a close answers only once the lock is released,
and that closing book A never refuses a job on book B (the hammer's maker
thread saw it on GitHub's slower runner; with a 40 ms fork-to-exec delay in
the backup's git it fails on every cycle).

Fix: every child the crate starts goes through lock::spawn, which holds a
process-wide gate while it runs (it returns once the child has exec'd);
dropping the Store's WriterLock closes the file, waits for the gate to
empty of spawns begun before, then takes the lock afresh and lets it go
(the kernel lets go of a closed file's last copy a moment after the exec),
for 500 ms at most. A test with a child held between fork and exec fails
without it.
2026-11-20 21:36:57 -07:00
swaitsandClaude Sonnet 5.5 c072e68fda docs(store): the doc link to take_lock_notes is a method link
rustdoc -D warnings refused [`take_lock_notes`]: a method is linked as Self::take_lock_notes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 21:23:44 -07:00
swaitsandClaude Sonnet 5.5 5c9c980072 fix(gui): jobs.rs cites the plan, not a product rule no claims file defines
WB-GUI-2 was never written into docs/spec/claims/, so the source-line test
could not find it. What the module rests on is plan 3.2 (D-78: a tab's
threads end with it); the hold on a change an owner has begun is a
CONVENTION, named as one.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 21:23:44 -07:00
swaitsandClaude Sonnet 5.5 15845f71c8 fix(gui): the dock compiles on Windows, where the agent ends when its pty drops
check / check (cli) (push) Canceled after 0s
check / check (gui-tests) (push) Canceled after 0s
check / check (gui-unit) (push) Canceled after 0s
check / check (lint) (push) Canceled after 0s
check / check (rest) (push) Canceled after 0s
portable-macos / portable (macos-latest) (push) Canceled after 0s
portable-windows / portable (windows-latest) (push) Canceled after 0s
two-user / two-user (push) Canceled after 0s
Pty::child exists only on Unix; the child's pid is now Some on Unix and
None on Windows, so the kill after the grace happens only where it can.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 20:50:41 -07:00
swaitsandClaude Fable 5.2 b994a901bf merge: P15 A3a, the viewer is one window with a tab per open company
The viewer was a read-only window on one company per process. D-78 makes
a company reachable exactly while it has a tab, so the window now holds
one tab per open company, each with its own loader, navigation, page
state and assistant dock, and nothing shared between them. The company
is named once in the frame, on its tab; the status card at the foot of
the sidebar carries its badge and name with the live state; each company
has its own badge colour. A restore or a format upgrade in progress is
never abandoned by closing its tab or the window. The viewer still
writes nothing to the books.

docs/testing.md: both units added their test records at the end; both
are kept.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-20 20:30:01 -07:00
swaitsandClaude Sonnet 5.5 6f916f8bbd fix(gui): the status card's live word at its right edge, the event on hover, and no line ever wraps
The heading row is badge and name (elided) at the left, the live dot and word at the right edge; the event is the heading's hover and the live word's accessible label, not a printed row. The check lines are as before, with no event. Every text elides to one line; a test lays the card out in every state with a very long name and event 1,234,567. The heading is its badge's height and the card's vertical padding 8, so the sidebar still fits at 1479x519.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 20:29:23 -07:00
swaitsandClaude Sonnet 5.5 ee58d1ab10 test(cli): a close's own backup is asserted without a timer's backup beside it
a_close_whose_backup_fails... asserted a plain Closed, but with the timers
looking every 20 ms a timer's open-time backup could be in flight at the
close. The close hurries it; under heavy load its git can miss the 5 s
terminate grace, be killed, and leave a lock in the target folder, and the
close's own backup then fails against it, so the close truthfully answers
ClosedBackupIncomplete. The timers now look once an hour in this test, so the
first look (at the server's start, before the book exists) is the only one
and no timer backup runs; the assertion stays exact.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 20:21:56 -07:00
swaitsandClaude Sonnet 5.5 49ae7c0d13 fix(store): a stopped heal leaves no copy and no rebuild, and the bound names the heal
verify_and_heal copied the database aside before looking at the stop, so a
verification or an open that was stopped right after finding a drift left a
.mismatch copy behind. The look now comes first (heal_drift), before anything
is done: a stopped heal leaves the database and the folder exactly as they
were. The rebuild and its verification stay unstoppable once begun, since
stopped half way the live ledger would be part replayed.

INVARIANT 10's close bound said that heal was one pass over the journal and
named no term for it. It is about six (three in the rebuild, three in the
verification) plus the copy and one hash of each stored file, so it is now the
fourth named exception to the bound, with that cost, and 'an open stops
anywhere' says where it cannot.

Test: a stop before the heal leaves no copy and no rebuild; the same drift
heals when not stopped. It fails with the look moved back after the copy.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 20:20:24 -07:00
swaitsandClaude Sonnet 5.5 30e5fcf6da fix(mcp): a CPA package the build will refuse leaves no decision on record
The override decisions (exporting without an audit, with open drafts) were
journaled once only the two named refusals were past, but build_package can
still refuse for what the books say, such as a member whose capital account
is not in the chart. That left 'was exported' on record with no package, and
a new decision on every retry.

When a decision is to be recorded, the build now runs once first, in memory:
it is read-only (the books by shared reference, written nowhere), so it
changes nothing, and it is left without the stored files and the vault, which
only a failing machine can refuse. Only if it succeeds is the decision
journaled and the package built for real. The spec block says what can still
fail after a decision (the machine) and that the decision then stands, with
the reason in the access log.

Test: a package refused for an unknown capital account, with an override
reason, journals nothing, on the first try and on the retry; it fails without
the dry run (the journal grows).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 20:18:39 -07:00
swaitsandClaude Sonnet 5.5 b70a8ab8eb fix(mcp): a close never waits behind a preview, and stops every job holding its book's turn
A restore preview changes nothing, yet it took the book's turn and then
queued on books.lock and cloned, so a close of that book (which waits for
the turn) waited for the whole preview, and behind it for any adoption
holding books.lock. An adoption held the turn through its preview and
placement on the server's stop alone, so the comment saying a close of the
id stops its opening was not true.

A preview (restore, unconfirmed adopt) now takes no turn, and only the
server's close stops it. Every job that does hold an id's turn (adopt,
create, a confirmed restore, open) listens to that id's stop, which a close
raises before it waits for the turn, and which the server's close raises
too. A close of X stops the work making or replacing X before its point of
no return and never waits behind it; a close of another book still touches
nothing.

Tests: a close is answered while a preview of its book is held; a close of
an id stops the adoption making it. Each fails with the fix disabled.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 20:16:13 -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 Sonnet 5.5 d05d1ed7ec fix(mcp): a package's decisions are journaled only once it will be made
books.export_cpa_package journals the reason given to export without an audit
or with open drafts as a decision, and did so before it knew the package
would be made: a later refusal (open drafts after an audit reason) or a close
that stopped the build left a decision on record for a package that was never
made.

Every refusal is now decided first, then the decisions are journaled. They stay
ahead of the build for a reason the code states: the package counts them (its
README and every report footer carry the journal's event count at the build),
so moving them after would change the package's contents. A close is looked
for once, immediately before the first decision is journaled; from there to the
hand-over nothing looks at the stop (the build is entered without the close's
cancel scope), so a decision on record is a package handed over. What is
journaled and what the package holds are unchanged.

Test: an open draft that refuses the package after an audit reason journals no
decision (mutation-checked: journaling before the refusal fails it).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 19:57:16 -07:00
swaitsandClaude Sonnet 5.5 6d7044c284 fix(store): an adoption that does not finish leaves no lock file in the source; a queued job leaves its turn when stopped
An adoption copies books in from a folder the owner names and promises the
original is left as it was. Taking the source's writer lock creates the lock
file when the source never had one, and a close that stopped the adoption (or
a refusal, or a panic) left that file behind. The lock is now a guard
(SourceLock): a lock file the adoption made is removed again on every way out
but success, exactly that file (on Unix, only while the path still names the
very file the guard holds), and one the source already had is never removed.
A success still leaves the one it made and reports it (source_lock_created),
as before; a restore's and a put-aside's locks are the root's own and are kept.

Books are made, adopted and restored one at a time across processes
(run/books.lock). A job queued for that turn blocked in flock with no look at
its stop, so a close that stopped it could not make it leave; the wait now
tries the lock every few milliseconds and gives up with Stopped when asked.

Tests: stopped at each of the seven phases, refused after the lock, panicking,
a lock swapped in by someone else, a source that had its lock, and a success;
a queued create stops when asked and otherwise waits its turn. Each was
mutation-checked (no removal; a blocking wait).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 19:57:16 -07:00
swaitsandClaude Sonnet 5.5 d8ff776a52 feat(gui): the status card's heading carries the live state; one row fewer, so the sidebar fits the owner's 519 again
The heading row is the badge and name with the live dot and word at the right; the event ends the journal chain line. Folded, the card is the heading alone (or the heading over the failure line). The rail's badge carries the dot. The four sidenav tests are at their original sizes, the minimum window height is 400, and the goldens and snapshots are regenerated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 19:39:01 -07:00
swaitsandClaude Sonnet 5.5 ec436cfc02 feat(gui): a tab owns its threads; kept state belongs to its books; one dock layout
An independent review of the tab work found that closing a tab did not
end what the tab started, that what the viewer keeps was filed under the
book id alone, and a few smaller things. All of it is the viewer's own
state: nothing here writes the books.

Threads: every thread a tab starts (loader, receipts' workers, export,
owner job, the dock's start and its agent's reaper) is counted in one
per-view registry (jobs.rs). Dropping the view tells them to stop and the
registry says, on a condition, when the last has ended. An owner job that
changes something (restore, format upgrade, new books, connect, close the
books, check for updates, update) is never abandoned: its tab's close
control is off with a hover text saying what runs, App::close refuses, and
the window's close request is cancelled with a dialog that offers only to
wait. Read-only jobs (an export, a backup, the restore's check) stop with
the tab: an export checks at its phase boundaries and saves nothing (the
save is one atomic write of a new file; one the stop reaches too late is
removed). The dock's agent is hung up on and, if it ignores that for two
seconds, killed and reaped; the window's drop waits for that.

Release on close: the loader checks "gone" before every retry and between
the phases of a load, its retry wait is woken by the drop, and the viewer
presence is let go in the drop itself, not when a refresh in flight ends.
A thumbnail for a closed tab is not written.

Kept state: filed under a hash of the data root's canonical path and the
id (books outside any root: under their folder), with the books' identity,
the SHA-256 of the journal's first line, taken once they load. A stored
state whose identity differs from the loaded books' is discarded with the
remembered name. Old unkeyed keys are read without error and not used. A
start that names a company never writes the list of open companies.

The dock's height is the app's one layout in every tab (said in the spec
block and tested); the sidebar, rail and top bar panels now take ids made
from their view's, since egui keys a panel's size by the id as given.

Every new test was seen to fail with its fix switched off. The four
sidenav tests keep their BAR_H: at the owner's 519 they fail by 15 points
(sidebar) and 11 (rail) without it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 19:03:26 -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 Sonnet 5.5 6f174f3f87 fix(store): git is told to end before it is killed, and nothing in the owner's backup folder is ever deleted
A stopped git was killed outright and the program then removed lock files:
in the archive every lock found, in a folder target any lock new since the
push whose mtime held still for 1.5 s. Git does not touch a lock it is
holding, so an unchanged mtime does not prove a lock stale: another git (the
owner's, another machine's on a shared disk, a sync client's) stalled in a
hook or an fsync loses its lock to that rule, and two ref updates race. The
removal also re-resolved the repository and refs paths, so a folder swapped
for a link redirected it.

Now: SIGTERM goes to the git's process group first (git removes its own
locks on SIGTERM, a push's receiving end its quarantine), TERM_GRACE (3 s)
is waited for the group to end, and only then SIGKILL. A folder target is
never written to or deleted from except by git: a lock our kill left there
is left, noted with its whole path, and the push fails with LockLeft, which
tells the owner which file to remove and that it is only safe once nothing
else uses the folder. The archive keeps only two removals: the locks our own
stopped git made (not there when the command began), and at open and at the
start of a backup a lock older than ten minutes. Removals go through a
directory handle opened once, never follow links, and take only regular
files named as git names its locks (git_locks.rs).

Tests use real git: SIGTERM mid-commit, mid-add and mid-push leaves no lock
and no cleanup; a frozen group (SIGSTOP, so SIGTERM stays pending) is killed
after the grace and the archive's locks go while the target's stay and are
named; a git that traps SIGTERM is killed after the grace; fsck --strict on
both repositories right after a stop during a 48 MiB pack's receipt; the
archive's age rule; a swapped refs folder or archive path touches nothing
outside.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 16:31:58 -07:00
swaitsandClaude Sonnet 5.5 5cd0eded36 feat(gui): the eighth company badge hue is cyan, not slate; no hue may be a grey
A grey badge beside the others reads as disabled. Slate (475569 / 94A3B8)
is replaced in the same position, so no other company's colour moves, by
cyan (0E7490 / 22D3EE). The contrast test now prints every measured ratio
and asserts HSL saturation >= 0.4 for every hue.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 16:21:11 -07:00
swaitsandClaude Sonnet 5.5 7e5b698c1c test(mcp): say what the running-call test proves; name the phase watcher's type
The running-call test passes even with a cut that marks every request inside
(mutation check): the call runs in the session's task, past the handler's own
check for a cut, so what it proves is that the close waits for the call and
does not kill it. The line of the cut (a body read to its end is never cut) is
proved at its seat by local::tests::a_body_read_to_its_end_is_never_cut_and_one_not_yet_is,
which fails when a later poll can cut a whole body. Also a type alias for
clippy's type_complexity.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 15:51:12 -07:00
swaitsandClaude Sonnet 5.5 1b28da26e6 feat(gui): the company is named once in the frame: a tab, with a hue; its card at the foot; no header, no heading
The tab, the sidebar's header and the Overview's heading all said the
company's name side by side. Now the tab is the company's identity (badge
and name); the sidebar header and the Overview heading are gone (the
summary sentence leads the page, at the theme's heading size); and the
status card at the foot of the sidebar opens with a heading row, the
badge and the name (the rail shows the badge alone, the name on hover), so
"these are this company's books: verified, live" is on every page, at the
opposite corner from the tabs. The top of the sidebar is an empty
`top_slot` for the assistant's connection state, a later unit.

Each company has one of eight badge hues (theme::BADGE_HUES, light and
dark) chosen by FNV-1a of the id of its books: a function of the id alone,
so it is the same on its tab and its card, after a restart, in any order of
opening and on every machine. A test computes the contrast of every hue in
both themes: letter 4.5:1, badge 3:1 on each surface it sits on.

No figure, date or amount changed. Regenerated: the tall sidebar's shapes
and pixel goldens (header gone, links moved up, card heading row, hue) and
the eight tabs_* snapshots (hue, Overview lead, the rail's badge).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 15:47:56 -07:00
swaitsandClaude Sonnet 5.5 dce7898e96 test(gui): the live viewer's "update" test waits for the line it asserts on
A newer wanderbooks writes its lines one at a time, and the viewer may look
between two of them. With the unknown line last, nothing can check it, so the
viewer says "newer or damaged" (BS-format-1); once the next line lands it
says "update". Both are right. The test took the first error it saw and held
it to the "update" wording, so a look that fell between the test's two
appends failed it. The loader is unchanged by the fault: the test read the
first of two correct messages. The loader path is the same on main (0 of 30
runs failed there, 0 of 30 on the branch: the natural failure is rare, and
shows on a loaded machine); the branch's load only makes the gap likelier.
Seen deterministically by pausing the test 300 ms between its two appends.

The test now waits for the "update" and holds every message before it to the
"newer or damaged" one; a new test pins the between-the-lines look by waiting
on the viewer's first error before it writes the second line.

The same shape was in the background-tab test: it waited for the tab's seq to
move, which an entry's first journal line does, then asserted the posted
cash. It now waits for the cash itself.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 13:35:51 -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 10790d8794 fix(store): a killed git leaves no lock for anyone to remove, and a verification can be told to stop
A git killed (cancelled by a close, or silent for GIT_TIMEOUT) leaves the
lock files it held, and nothing removed them for 300 s (the archive) or ever
(a folder target): an immediate reopen's backup failed on index.lock and
waited 15 minutes, and a receive-pack killed holding a ref lock could stop
every later push. This process knows when it killed its own git, so once
the command is reaped AND everything it started is gone (the process group
is waited for: a killed process can still take a lock in its last
instructions) the locks it could have left are dealt with at once, each
noted for the caller's record.
 - the book's own archive: every lock is removed (this process holds the
   book's store lock, so no other wanderbooks process runs git on it); the
   same at open (clear_archive_locks), where a lock is a dead git's.
 - a target on this computer: D-30 makes the folder the owner's (an external
   disk, a synced folder), and nothing enforces that no other computer, data
   root with a book of the same id, or hand pushes to it (the only guard is
   the fast-forward rule). So a lock there is removed only if it was NOT
   there when the push began (one that was is left and noted) and it has
   stood unchanged for LOCK_SETTLE after the kill (a live writer holds a ref
   lock for the milliseconds of a ref update). Said in INVARIANT 5, with the
   one case this cannot see (a second writer stalled holding the lock past
   LOCK_SETTLE). A far repository is never touched.
 - a git killed inside `init` (found by the test with real git: the first
   backup of a book made HEAD.lock in a repository that isn't one yet, which
   stopped every later init) is covered the same way.
 - no git of ours starts another to go on after it (gc.auto=0,
   maintenance.auto=false), so 'everything it started is gone' is true.

Also: a drill or proof can be told to stop (the cancel flag), looked at
between phases, once per journal line replayed or applied, once per stored
file hashed or listed and once per 64 KiB chunk compared (cancel.rs, a
thread-scoped flag so nothing else can be stopped by it), and leaves nothing
(its scratch clone is removed). Tests use REAL git, made slow by a
reference-transaction hook that waits: killed mid-commit, mid-add (a huge
sparse file), mid-push; the next backup succeeds and git fsck passes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 13:10:26 -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 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 80a24a6262 feat(gui): the tab bar spans the window above the sidebar; tabs carry a badge and a name
A tab is the top level (D-78): the sidebar, with its badge, pages and
status, is the company in the tab, so the bar now runs across the whole
window above it. The bar's height (tabs::BAR_H) is taken from the window:
the four sidenav tests that size a window for the sidebar add it, through
that constant, and the smallest window is 400 points plus the bar. The
sidebar below the bar is pixel for pixel the old 1440x920 golden image;
only its shapes hash moved, with the shapes lower by the bar.

Tabs are as wide as badge plus name between a least and a greatest width,
the name elided with the full name in the hover; the one in front is the
lit surface with the accent bar, open at its foot. Room is left before the
close control for a later state mark. The + follows the last tab (at the
right edge, whole, when the tabs scroll), says 'Open a company' on hover,
and lists companies by remembered name with the id beside it; a name is
remembered when a company's books load (company.<id>.name) and titles a
tab before its books load.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 11:41:10 -07:00
swaitsandClaude Sonnet 5.5 1332c2a576 test(mcp): the sessions test waits for each client's name instead of assuming a notification was handled
initialized is a notification the server handles after its 202; on a loaded
machine the list was read first.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 11:29: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 Sonnet 5.5 181859d801 fix(store): logs, uploads, exports and git can be closed, so a handle from before a close can never write after it
A book closed while the server runs stays a book of the root: another
process may open it, or this one may open it again, and a new access log
is then opened against the file's own head. Any holder of the old handle
that appends (an access record written late), sweeps (a timer) or
renames (an upload part, a claim dropped) reaches the new book's files and
breaks its chain. Each of these now has a closed state, set under the
very lock every change to its files goes in under, so a change whose
work began before the close is whole and one after it is refused,
unwritten. git also takes a cancel flag: a command running is stopped
with all it started, and none starts, so a close can end a backup that
is still going instead of leaving it to run against books reported closed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 10:08:42 -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 dcf092e39e test(gui): tabs share nothing, follow their journals and end with their tab
A refactor that compiles and passes the old tests can still share state
between tabs, so these look for exactly that, on scratch data roots made
by Root::setup:

- two companies with different cash and rent show their own on the
  overview, the profit and loss and a register; a search, page, period,
  columns and comparison set in one leave the other's state and every
  text it paints as they were;
- a sidebar scrolled in one tab is at the top in the other (fails, as
  checked, when the view is not drawn inside push_id);
- a journal change in the tab behind is read while another is in front
  and is on screen on the first frames after it is shown; books.show
  moves its own tab only and brings nothing forward;
- closing a tab releases its viewer lock, ends its loader's thread and
  its dock's agent process (a stand-in agent on a real PTY, the tab's own
  owner), while the other tab's lock and loader are held;
- "+" lists only companies not open, none opens twice, the last tab
  closed leaves the empty window in plain words;
- start-up restores tabs, their order, the front one, and each one's page
  and period; a company that is gone or listed twice is skipped; the old
  per-app keys are still written;
- read-only: the demo's two companies made read-only on disk, one
  following live behind the other, every page rendered in it, the tabs
  shown in turn, every file's bytes, size and time as they were;
- pictures of the bar with one, two and ten tabs, of "+" open and of the
  empty window, light and dark.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 09:29:34 -07:00
swaitsandClaude Sonnet 5.5 48cf9e3a03 feat(gui): one tab per open company, each a window on that company alone (D-78)
The viewer was a window on one company: App mixed what is one company's
(loader, books, page, filters, receipts, dock, menus) with what is the
app's (the color scheme). Two companies in two tabs need those apart, or
a filter set in one tab shows in the other.

- company.rs: CompanyView owns everything per company, including its own
  loader, its own handle to the Owner (the process-wide set_owner stays
  the program's default, each view takes a handle when made and a test can
  give a view another), its own dock and so its agent process.
- app.rs: App holds the per-app state, the views and which is in front.
  A view not in front still reads its loader every frame and takes the
  agent's books.show for its own page, so showing it later is current at
  once and the loader's channel never piles up Books behind it.
- Every egui id a view makes is scoped by the view's own id (push_id around
  the view; the owner dialogs' and the palette's modals, the pages' split
  widths, the sidebar's footer memo and links memo take it too; the
  projects' figure cache is keyed by the books). Otherwise egui's memory
  (a scrolled sidebar) carries from one tab into the next.
- data.rs: dropping a Loader wakes its thread at once and the thread
  stops, so a closed tab lets go of its watcher and its viewer presence
  now and not at the thread's next look (up to 3 s); Loader::watch tells
  a test the thread has ended.
- tabs.rs: the tab bar. One tab per company (the books' name, else their
  id), the front one marked by a heavier name, an accent bar and
  "selected" to assistive technology, not colour alone; a close control
  on each (middle click too); "+" lists the data root's companies not
  open; overflow scrolls with a step control at each end. It runs beside
  the sidebar, not above it: above it the owner's 1479x519 window makes
  the sidebar's links scroll (sidenav.rs), with a bar of 36, 28 or 24
  points alike, so the sidebar keeps the window's whole height.
- lib.rs/app.rs: a company named on the command line is the only tab;
  otherwise the companies open at the last close come back, in order,
  with the same one in front and each one's page and report period; a
  company that is gone is skipped, none left opens the data root's first.
  The old per-app keys keep their names; open_companies, active_company
  and company.<id>.* are new. The window's title names the company in
  front.
- scheme_menu.rs: the scheme button and its state moved out of App as they
  are (one scheme for the window).

A new tab's dock opens closed with the front tab's agent chosen, so
opening a company never starts an agent nobody asked for.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 09:29:21 -07:00