Commit Graph
1077 Commits
Author SHA1 Message Date
swaitsandClaude Sonnet 5.5 d3d5effafc docs: the tab threads, the kept-state keys and the review's tests
architecture.md says how a tab owns its threads and what is kept under
what key; testing.md lists the tests, how each fix was shown to matter,
and why the sidenav window sizes were not restored (15 and 11 points
short at 519).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 19:03:26 -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 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 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 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 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 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 79f0cfc13e docs(plan): D-89, books that have not taken the transaction format take no writes
The owner chose one write path over two: an un-upgraded company opens
and is read, and every write waits for his format upgrade. The unsafe
path does not stay in the program beside the proved one.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-20 11:57:40 -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 c1fbeab7c1 docs: the tab bar spans the window above the sidebar; the tests that say so
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 11:41:10 -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 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 d7358b605b docs: the viewer is one window with a tab per company; the tabs' test record
architecture.md: what a CompanyView owns, how ids are scoped, what a tab
behind keeps doing, how start-up restores tabs. testing.md: a record for
each new test, what it can't reach, mutation targets for P12, and why the
bar runs beside the sidebar (the owner's 519-point window).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 09:29:34 -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
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 Sonnet 5.5 f7f75fb380 feat(mcp): open and close one book while the server runs, and say who is connected
The desktop app is a window with a tab per company (plan/p15-app-and-relay.md
3.1, D-77, D-78): a company must be reachable by agents exactly while its tab
is open, so the books server can now open and close ONE book at run time
instead of opening every book at start and closing only with the process.

Close is ordered so that a call either ran completely (and is in the journal)
or was refused unrun: the book's door (a per-book gate every route enters
before it touches the book, its access log included) is shut and the book is
listed closed, so no new call gets in; SharedStore::close stops tools
starting and waits for those that did; the gate is waited empty for the
upload, download, export and MCP handlers inside; sessions end; the last
backup of the server's own close runs; and the store is let go, releasing
its writer lock. Only then is 'closed' answered. Another book's door, store
and sessions are never touched or waited on.

A closed book is a state of its own (not a problem): listed closed, and a
call for it is told apart from one for a book that does not exist, on the MCP,
upload, download and export routes, in words an agent can relay. Start gains
--open all|none|IDS (default all).

Sessions: a small in-memory board per book (sessions.rs) keeps what the
client said at initialize, the agent's self-report, calls running and the
last call, joined with the sessions the server already binds to tokens; the
admin 'sessions' request lists the token's NAME, never its text or hash, and
doctor prints it. Backups of a book let go push and record nothing more.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 09:02:02 -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 2f38648d2c docs(plan): P15, the owner's answers on sign-in, web permissions and certificates
Decided 2026-11-20: the app is its own sign-in server and a new web
assistant is approved in its window (D-83); a web assistant reads and
drafts but does not post until the owner allows it for that connection
(D-86); each app holds its own certificate (D-87). D-84 and D-85 stay
the lead's engineering proposals.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-20 08:29:17 -07:00
swaitsandClaude Fable 5.2 9c053b572f docs(plan): P15, why each app holds its own certificate and what that does not promise
The owner asked whether one wildcard certificate at the relay, with our
own encryption behind it, could replace a certificate per user. It
cannot be end to end, because the vendor's server speaks only HTTPS to a
trusted name, so whoever holds the certificate reads the traffic. He
kept the certificate per app. The plan now says what that leaves open
(we control the DNS, so a taken-over relay could get a certificate; the
app watches the public logs for one) and names a second authority as
the fallback.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-20 08:27:59 -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 6a579ebf5b docs(plan): CI on the batch's push, all four gates green
The five-part check ran on CI for the first time (the slowest part done
43 minutes after the push, where the one job took 72), with deny,
notices-check and kernel-only in its lint part.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-10 06:29:34 -07:00
swaitsandClaude 8ec1b79958 docs(plan): the batch's gate, as it ran
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
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
just prove on 0178809a3 and just check on 3bc198594, the latter in two
runs since a two-hour limit stopped the first with nothing failed. What
is still unseen: CI on the push, and a built AppImage with the new rule.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-10 04:39: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 0178809a3d docs(plan): the status, the roadmap and the hand-off as of the evaluation batch
STATUS gets a section for 2026-11-10: what the evaluation batch landed,
what is not verified yet (the one gate, CI, a package build), and what
is next. The roadmap said the parity floor was 21 rows enforced by
review; it is 36, enforced by a test and by CI, and its "Next" described
units that have all landed. The hand-off described `just check` and
`just prove` as they were before the five parts, the supply-chain and
notices gates, the kernel-only gate and the per-harness cap.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-10 01:55:11 -07:00
swaitsandClaude 5debaa1be1 docs(core): the legacy close bound is one close's worst case, and says so
The audit allows a member's running total (n-1)/2 units of drift, floored
at a unit, until the first close under the cumulative rule trues it up.
That figure is derived for one last-absorbs close. Books that made
several before their first cumulative close can carry more, each close
having rounded on its own, and the audit raises it. That is the safe
direction (a finding to read, which the next close that posts removes),
but the spec block did not say the bound stops at one close. It does now.

A comment only: no code changes.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-10 01:55:11 -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 e444a41071 merge: the viewer's Decimal arithmetic goes through the kernel (K-U12)
The viewer was the last crate with arithmetic of its own on amounts: 123
places in books.rs, the demo books and the pages. Each now calls the
kernel or money.rs's helpers over it, so a sum of posted figures is exact
(BS-entry-3, BS-entry-4), a quotient or a share is the kernel's, and a
figure exact arithmetic cannot hold is a blank cell or a refusal where a
raw operator panicked.

No figure moves. Three places name a rounded product, since one factor is
a quotient or the old code relied on rust_decimal's product: a party's
cash scaled by its fraction of an entry, a member's share times a hundred
for display, and the "running hot" limit of 1.25 times an average. The
demo books round to a step of 25 or 50 through the kernel, a half to the
even step, as Decimal::round did.

Read line by line against the per-site table before merging.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-10 01:10:23 -07:00
swaitsandClaude e4c41ccb3f refactor(gui): the viewer's Decimal arithmetic goes through the kernel (K-U12)
The detector (scripts/raw-decimal-arith.sh ledger-gui) counted 123 places
in the viewer that did Decimal arithmetic outside the kernel; it counts 0
now. No figure the viewer shows changes: a raw operator panicked when the
exact answer did not fit, and add_in_range / sub_in_range / neg panic in
exactly that case; rust_decimal's checked_* methods, which round past 96
bits, became the kernel's Amount::checked_* (exact or None), with the
existing None handling untouched.

Places that are not plain sums or differences, and what each became:
- Sums of balances and posted lines (receivables, due to members, a
  disposal's true-up, a statement row across columns, cleared total):
  kernel::total / total_of; a refused sum is an expect where the figure
  is drawn from the books, and a blank cell in the cash-flow keyed rows
  (which already blank a refused statement).
- The share split (books.rs): share_of(v, share, net), the same multiply
  then divide; the scaled parts use checked_mul_rounded because the
  fraction is a quotient, truncated to cents on the next line.
- Percents of a share (capital, company, reports): checked_mul_rounded
  by 100, exactly what * did.
- Averages and runway (monthly burn, cash runway, net per month, a
  third of an amount, build-in pct): Amount::checked_div, a None joins
  the None or "can't compute" the code already has.
- The 125% watch threshold: checked_mul_rounded and is_some_and.
- Rescale to one place (pct): rescale_exact, keeping the value when it
  would round.
- The demo's rounding to a step ((x / 50).round() * 50): to_step, the
  same half-to-even rounding through round_places.
- f32 widths and usize counts: plain folds, no allow.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-10 01:07:35 -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 a167766dd4 merge: the tools', the exports' and the imports' Decimal arithmetic goes through the kernel (K-U12)
Fifty places in ledger-mcp (19), ledger-import (18) and ledger-package
(13), now zero. Signs come from money::neg, signed_amount and on_side;
sums of posted figures from the kernel's exact total and add_in_range /
sub_in_range; the checked sums that already had a "too large" outcome
keep it and now get it from the exact operation, where rust_decimal's
own would have rounded and gone on.

No figure changes. What is not a plain sign or sum:

- A template's equal shares (100 / n, to two places, the last taking the
  remainder) are the same three steps through the kernel; no owners now
  gives no shares where the raw division panicked (no caller can ask).
- The exports' money and share text padded to two places with
  Decimal::rescale, which can round; kernel::rescale_exact cannot.
- The tools' own profit and loss by class signs each line with
  money::on_side, one statement of the rule the two matches spelled out.
- The payment summary adds what was deposited after the engine has
  accepted the settlement (on the books or on a probe), so those figures
  are in range.

Worker: Claude Sonnet 5.5, high effort, from a per-site table. The diff
was read line by line against the table; the detector and the three
suites were run again here before the crates joined kernel_only_crates.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-10 00:45:21 -07:00
swaitsandClaude 1d612d25b8 refactor(mcp): Decimal arithmetic goes through the kernel (K-U12)
The raw-decimal-arith detector counted 19 places in ledger-mcp before
and counts 0 after. No figure changes.

Sides become signs through money::on_side and money::signed_amount
(server delta, report movement, the P&L-by-class normal-side figure,
which collapses two matches into one call); sums and differences of
books figures through add_in_range and sub_in_range; the checked sums in
helpers and documents through Amount::checked_add with their error
handling untouched. The count of withdrawn attachments (a usize, not a
Decimal) is the length of the flattened withdraw lists instead of an
Iterator::sum of their lengths: the same number.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-10 00:39:41 -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 5ef5f47ebf refactor(package): Decimal arithmetic goes through the kernel (K-U12)
The raw-decimal-arith detector counted 13 places in ledger-package
before and counts 0 after. No figure changes.

Negations go through money::neg; the two differences of books figures
(attention, k1_tax) through sub_in_range; the checked sums in the
attention checks through Amount::checked_add / checked_sub with their
"cannot compute" handling untouched.

Not a plain sum or sign: text.rs padded a number to two places with
rescale (which rounds when 96 bits do not hold the padded digits); it
now uses rescale_exact and keeps the number as it was if padding would
round, so the printed text never rounds.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 23:57:22 -07:00
swaitsandClaude 0fb19b4b25 refactor(import): Decimal arithmetic goes through the kernel (K-U12)
The raw-decimal-arith detector counted 18 places in ledger-import before
and counts 0 after. No figure changes.

Signs (bank_csv, iif, invoice_pdf, report) go through money::neg and
money::signed_amount; sums and differences of figures from the books
(report, xlsx) through total_of, add_in_range and sub_in_range, which
are exact and panic only where the raw operator panicked.

Not a plain sum or sign: equal_shares (templates) now divides through
Amount::checked_div, rounds half-to-even to two places through
round_places, and gives the last owner a hundred minus the shares
given. Same numbers as before for every n >= 1; for n = 0 it returns no
shares where the raw division panicked (its one caller passes the
owners of a partnership, at least two).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 23:55:32 -07:00
swaitsandClaude 0de906e9ed docs(plan): K-U11a landed: the triage and the status say so
The kernel rule holds in ledger-core and is held by the lint part for
five crates; the six outer crates with places left are K-U12. The
traceability gate's counts are 62 functions and 16 listed exceptions
(kernel::rescale_exact is the sixteenth).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 23:42:15 -07:00