is_logbook 0.6.1
is_logbook: ^0.6.1 copied to clipboard
An add-only logbook of bytes: each entry chained to the one before it, naming the bytes and the hash of the code that wrote it.
Changelog #
0.6.1 #
- A compiled build names its code only by the hash it was compiled
with. At run time a compiled build resolves packages through whatever
.dart_tool/package_config.jsonsits above the binary, so it used to hash source it was not necessarily compiled from. When that source had been deleted, for example by a pub-cache clean,Logbook.openthrew aPathNotFoundExceptioneven though the build had-Dis_logbook.code. Now a compiled build opens with the define and never reads source. Without the define, a compiled build doesn't open, even when it sits beside its package's source. A run from source still measures its source and refuses a define that doesn't match. - A run from source whose package folder is missing now gets null from
ownHashinstead of an exception. - The code hash changes:
87358f1ce7ed6a1745e28de8db94d14212cd016bda4631dbf7c615a8a03c5336.
0.6.0 #
- Breaking: the service writes its own
users-assigned-uidsentry straight after eachusers-assigned-to-trajectoryit accepts, recording the two users' uids (https://github.com/intersyntactic/logbook/issues/27, finding 10). A restart takes the trajectory's users from it instead of looking the names up again, so renumbering or removing a unix user no longer changes who owns a trajectory. The entry is a root of its own, so the assignment stays its chain's tip, and senders change nothing. At each start, every open trajectory without one gets one: those assigned before 0.6.0, and any whose entry a crash lost (lost bytes are kept again, not added twice). - It's a fourth ownership kind.
ownership_kindsprints it, and a sender table that names it, or lists it as attaching, is refused, asstartedis. A reader subscribed to*sees these entries. - The code hash changes:
f3adb1e730454b990ecedee2fa0903710daaed176d6992fd0bf88c99f424fd57.
0.5.2 #
dart run is_logbook:ownership_kindsprints the kinds that decide chain ownership in this release, one per line. A deploy can read them from the source it's about to build instead of keeping its own copy. The service now decides ownership only throughOwnershipKind, and a test checks thatlib/names those kinds nowhere else, so the list it prints is the list the service acts on.- The code hash changes:
227aebe08f5b51055ae491af640cebdba6ff26ce417774483b552344f176da14.
0.5.1 #
- One lost object no longer reopens closed missions and trajectories after
a restart (https://github.com/intersyntactic/logbook/issues/27, finding
1). An entry whose bytes are missing or corrupt is now a hole. Entries
that name it join a chain that starts at the hole, so a
mission-endedortrajectory-closedafter a hole still closes what it names. Before, every entry after the hole on its chain was dropped on restart. - A hole freezes every chain it might have extended: the chain it
starts, and every chain whose tip comes before it. Each one is refused
refused hole <id>, so no chain can fork from a tip that a lost entry had already moved on from. - Sending a hole's bytes again heals it (finding 2). The resend keeps
the bytes, adds no entry, and is answered
ok <id>, where it used to getrefused duplicate. The service heals its own loststartedentry at the next start if the sender table hasn't changed.Logbook.keepkeeps bytes for an entry that already names them. - The code hash changes:
a85ab1ae0c78a2fe868c9420a5bfa0c565a81a19b44a902bbe537222e89f3b28.
0.5.0 #
- Breaking: every entry line names the trajectory the entry is on.
subscribesendsentry <id> <kind> <previous> <length> <trajectory>, andgetsends the same line with the 96 bytes after it: the trajectory that owns the entry's chain, or-. The service already knew it, to decide who may write. A reader no longer has to subscribe to every kind and walkpreviouslinks to find out, so it can ask for only the kinds it uses (https://github.com/intersyntactic/logbook/issues/31, step 1).is_logbook_clientbefore the release that reads the sixth word refuses these lines, so every reader must move to it. - The code hash changes:
b6c5841d50590bd1cdbbb38a6a161a86e3d25d7f09eca13c6ded1caa3d3119ae.
0.4.4 #
- A reader that stops reading no longer makes the service's memory grow.
Each subscriber is now a place in the logbook's order. The service sends
the entries it wants about 64 KiB at a time, and the next batch only once
the reader has taken the last (
flush()has completed), so a stalled reader holds one batch, not every entry it is owed. Before, each entry was queued on every subscriber's socket as it was written, without limit (https://github.com/intersyntactic/logbook/issues/37). - A backlog no longer goes out in one burst.
subscribe … from startused to queue the whole backlog at once. The backlog and the live entries are now one walk through the order, paced the same way. What a reader receives is unchanged: the same entries, in the same order, withcaught-up <head>between the backlog and the first new entry. - The code hash changes:
91daed8d68635772940756a9434c66f3b2b3a44221323ef76590bc2de522bd22.
0.4.3 #
- Everything the service does is now in
lib/, so the code hash covers it. The newpackage:is_logbook/run_service.dartholdsrunLogbookService(env, {out, err, stop}), which returns the exit code (0, orcannotStart, 78), andbin/service.dartis one line that calls it and exits. Before,bin/service.dartread the settings, opened the logbook and handled the stop signals outside the hash, and it could have added any entry stamped with an approved hash. - The README says exactly what the hash covers: the
lib/folders, notbin/, the program around the library or the compiler. - The code hash changes:
104d3dcad26b6134d6d996c2c411d228af56c65cbff2116c8009c7fd253b52f2.
0.4.2 #
- The service prints its code hash at start, after the line saying
where it writes and listens:
code <hash> approvedwhen the hash is a line ofapproved, orcode <hash> NOT approvedwhen it isn't. It is a warning, not a refusal, so a missing line never stops the writer. A deploy can now be checked against what the person approved from the start log alone. - A stop sent once the start lines are out closes the service cleanly. It now watches SIGTERM and SIGINT before printing them; before, a signal in that gap killed it without closing the sockets.
- The code hash is unchanged:
f380b8822a153e102f8bef83d2dd4774c22d1b22e105e08471ea87aa179b9b58. Onlybin/changed, and the hash coverslib/.
0.4.1 #
- Depends on
is_unix_socket_user_check^0.2.1, which prints every reason a user could not be read on one line, folding any line break into a space. The service passes the reason on as it is, rather than folding\rand\nitself, so a refusal stays one line whatever line break the operating system's error holds. A program that depends onis_logbooknow gets 0.2.1 or later. - The code hash changes:
f380b8822a153e102f8bef83d2dd4774c22d1b22e105e08471ea87aa179b9b58.
0.4.0 #
- Depends on
is_unix_socket_user_check^0.2.0, whose reader says why it could not name the user on the other end of a socket. A program that depends onis_logbookcan now move to 0.2.0 too. - A write whose user the kernel did not name is refused with why, on
one line:
refused kind <kind> for user unknown: <why>, for example... unknown: the kernel reported the overflow uid 65534. It used to end atunknown. It is still refused in every such case. - A subscription holds its kinds as
Kinds, read once when it is parsed. - The code hash changes, because
is_unix_socket_user_checkis in it:09064cbe199733ce67abd2ef97eeb8e1f2b421e00ceb0c9fd9423d728f93ad72.
0.3.2 #
pubspec.lockis committed, so the service a tag deploys is built from the same dependency versions every time (dart pub get --enforce-lockfile). No code changed, and the code hash is the same as 0.3.1's: the lock is outsidelib/, and it pinsis_content_id0.2.0,is_logbook_format0.1.0 andis_unix_socket_user_check0.1.0, the versions 0.3.1 is approved with. A package that depends onis_logbookstill resolves its own versions; pub ignores a dependency's lock.
0.3.1 #
- The format moved to
is_logbook_format:LogbookEntry,EntryHashandKind, unchanged. This package re-exports them where they were (Kindfromservice.dart, the rest fromis_logbook.dart), so nothing that imports them changes. A program that only talks to the service, such asis_logbook_client, can now depend on the format without depending on the writer, which let it open the logbook's directory and append past the service. Kind.readnames the rule the service wrote out twice: a recorded kind isstartedor oneKind.parsetakes.- The code hash covers
is_logbook_format, which lays out every entry's bytes. The README's command hashes it too. The approved code hash changes with this release.
0.3.0 #
- Breaking: users are
UserIds, fromis_unix_socket_user_check, which the service library re-exports withSocketUserReader.uidOfreturnsUserId?andSenderTable.allowstakes aUserId. - A sender table naming 65534,
nobody, 4294967294 or 4294967295 is refused (FormatExceptionno user ...), as is ausers-assigned-to-trajectorynaming one (refused no-user ...). The kernel reports a user unmapped in the service's user namespace as 65534, so such a line used to let in every unmapped user. - Upgrading from 0.2.x: a trajectory whose loop user is 65534 or
nobodycan no longer be extended. Itsusers-assigned-to-trajectorywas accepted before, but the user is read back on every start and is now no user, so every entry on its chains is refusednot-owner. That is the point: under 0.2.x every unmapped user could extend it. A suit of 65534 ornobodychanges nothing, since only the loop user writes. Before upgrading, look for an assignment naming either. - Who is on the other end of the socket is read by
SocketUserReader, whichLogbookService.starttakes assocketUserReader(the running kernel's by default), so a test can fake any user. - The code hash covers
is_unix_socket_user_check, as it coversis_content_id: it decides who may write, so a new version of it changes the hash. The README's command hashes it too. - The approved code hash changes with this release:
lib/changed and the hash now covers a third package. Approve the new hash before running it.
0.2.2 #
trajectory-closed(Kind.trajectoryClosed) closes one trajectory, asmission-endedcloses a mission: its chain and every chain attached to it are refused from then on (refused trajectory-closed <trajectory>), and its users are free again. The service reads only the body'strajectory(refused trajectory-closed-bodywhen it names none). It cannot attach. Closing twice changes nothing, and a restart reads it back.- A trajectory can be closed before its users are assigned: its
users-assigned-to-trajectoryis then refused (refused trajectory-closed <trajectory>). - A
users-assigned-to-trajectoryfor a mission already ended is refused (refused mission-ended <mission>). It used to be accepted, so a loop could start in a closed mission and have every entry refused. - The code hash changes:
lib/service.dartchanged.
0.2.1 #
LogbookService.starttakesuidOf, asSenderTable.parsedoes, with the real lookup as the default, so a test can start the service with users this machine does not have (suit-1,loop-1). Nothing on the wire changes.- The code hash changes:
lib/service.dartchanged.
0.2.0 #
- Breaking: the service speaks text ids. An entry's id on the socket
is the sha256 of the bytes sent, header and all (
ObjectId), not the hash of the 96 bytes that chain the logbook. That coversok,refused not-tip, a header'sprevious, an attached root's parent line,get,tip,subscribe … from,caught-up, and each subscribed entry's id. A sender can compute an id before sending, and a reader checks every subscribed entry by hashing its bytes.getstill sends the 96 bytes, whose bytes 64–95 are the id. - Breaking:
refused duplicate <id>for bytes the logbook already holds, checked before the tip, so a resend after a lost answer learns the entry got in. Two entries with the same kind, previous and body are one. - Each
startednames the laststartedas previous, so no two starts are the same bytes. - The 96-byte format and
is_logbook/1are unchanged; a logbook written by 0.1.0's service names 96-byte hashes in its headers, which 0.2.0 does not read as ids, so a live logbook starts empty again. - The code hash changes:
lib/service.dartchanged.
0.1.0 #
The first release as is_logbook. Up to 0.9.0 this package was is_journal; its history is below.
- Breaking: the package is is_logbook (repository
intersyntactic/logbook). The library is
package:is_logbook/is_logbook.dart, the classLogbook(andLogbookEntry,LogbookCheck,NoLogbook,LogbookService), the executablesis_logbook:serviceandis_logbook:code_hash, and the define a compiled build names its code withis_logbook.code. - Breaking: the format is
is_logbook/1. The first entry names the sha256 ofis_logbook/1as the entry before it, so no logbook written by is_journal chains here. None is carried over: a logbook starts empty. - Breaking: the service reads
LOGBOOK_DIR,LOGBOOK_SOCKET,LOGBOOK_SENDERSandLOGBOOK_READ_SOCKET, and no longer theJOURNAL_*names. The README's example sockets arelogbook.sock. - The code hash changes: the package is named
is_logbookin the hash's list, andlib/changed. - Breaking: a journey is now a mission, and a journey path a
trajectory (Nick, 17 Nov). The kinds are
users-assigned-to-trajectory(wasusers-assigned-to-journey-path) andmission-ended(wasjourney-ended). The first one's body is exactly{"trajectory","mission","loopUser","suit"}(wasjourneyPath,journey), and the second's names itsmission(wasjourney). - Refusals renamed with them: an entry on an ended mission's chain is
refused
mission-ended <mission>, and a body that names no missionmission-ended-body.users-assigned-againnow names the trajectory. - No entry of the old kinds was ever written to a live logbook, and the readers don't accept the old names: each reader reads one version.
- Sender tables naming the old kinds must change in the same deploy.
- No kind is newly reserved: only
-andstartedare refused byKind.parse.
Before the rename: is_journal #
0.9.0 #
- Breaking: two kinds renamed, under the naming rulings (a name says
literally what the thing is).
assignedis nowusers-assigned-to-journey-path, andendedis nowjourney-ended. The old names are no longer special: a sender table may list them as ordinary kinds. No entry of either old kind was ever written to a live logbook, so nothing has to read them. - Refusals renamed with them:
assigned-body,assigned-not-rootandassigned-againare nowusers-assigned-body,users-assigned-not-rootandusers-assigned-again;ended-bodyisjourney-ended-body; and an entry on an ended journey's chain is refusedjourney-ended <journey>, notclosed <journey>(a closed thing can be reopened; an ended journey can't). - Sender tables naming the old kinds must change in the same deploy.
- No kind is newly reserved: only
-andstartedare refused byKind.parse, as in 0.8.0. - The code hash changes:
lib/changed.
0.8.0 #
- Chain ownership. An
assignedentry starts a journey path's chain, and only the user it names asloopUsermay extend that chain. Anendedentry closes every chain of its journey. A kind on the sender table's newattaching:line starts a chain that names its parent on its first body line and belongs to the parent's path. The README's "Chains a journey path owns" gives the rules and each refusal. assignedandendedare now refused unless their bodies read as the README says. Any other kind is treated as it was.- A sender table with an
attaching:line is refused by 0.7.0 and older, which readattaching:as a user. - Who owns which chain is rebuilt from the journal on every start.
- The code hash changes:
lib/changed.
0.7.0 #
- Breaking, on the read socket:
follow <kinds> <after>is nowsubscribe <kinds> from <entry>, withstartfor the journal's start in place of-. The old request is refused (refused not-a-request); there is no transition.caught-upsaysstart, not-, when there is no entry to name.-now means only "no previous entry". - The header's second line is called
<previous>, not<follows>, in the docs and the code: the entry before this one in its chain. Only the name changed: no byte a writer sends, no entry and no hash differs. - The code hash changes:
lib/changed.
0.6.0 #
- The read socket answers
get <entry>: the entry with its bytes, asfollowsends it, plus its 96 bytes in hex, so a reader can check that the entry hashes to its name and the bytes to the object it names. Ornonewhen the journal holds no such entry,unreadable … missing|corruptwhen it does but its bytes are gone or changed, orfailed. - The service indexes every entry, including one whose object is lost or
that has no header, so
getnever saysnonefor an entry that was recorded, before or after a restart. When something other than the service has written to the journal, it reads the journal back. - A journal holds a lock on its
writer.<pid>while open, and opening deletes the claims no process holds, left by a process that ended without closing (aSIGKILL, or running out of memory). A journal 0.5.0 or older holds no such lock, so don't open a directory from both at once. - The code hash changes:
lib/changed.
0.5.0 #
package:is_journal/service.dartanddart run is_journal:service: a journal's one writer, which other processes send entries to over a Unix socket. It refuses a kind the sender's user may not write (read from the socket:SO_PEERCREDon Linux,LOCAL_PEERCREDon macOS) and an entry that does not follow its chain's tip, and adds astartedentry holding the sender table on every start. The checks are inlib/, so the code hash covers them.- A read socket (
JOURNAL_READ_SOCKET, optional), for readers who can only read:follow <kinds> <after>sends the matching entries after a point and then each new one as it is added, andtip <entry>answers a chain's tip. Every entry comes with the hashokanswered for it. Journal.addEntryadds asadddoes and returns the hash of the entry it wrote.
0.4.0 #
The format is unchanged, but every code hash changes: approve 0.4.0's anew.
- The code hash covers the
is_content_idthe journal runs with, not only this package: thelib/files of both, each path under its package's name. A newis_content_idchanges the hash, whichever version an app resolves,dependency_overridesincluded. - So the dependency is
^0.2.0again. 0.3.0's exact pin kept any app from combining the journal with a library that needs anis_content_idfix. - The README's bash check hashes both packages, finding them through
.dart_tool/package_config.json, from this package's root or an app's.
0.3.0 #
The format is unchanged: journals written by 0.2.0 read the same, and an entry 0.2.0 padded with zeros stays as it is.
- An entry torn by a crash is cut off before the next entry is written,
instead of padded with zeros and chained from. Its add never returned and
its object was never kept, so nothing recorded is lost, and
check()reports the journalIntactagain rather thanBrokenfor good. addthrowsObjectNotKept, aFileSystemExceptioncarrying the id, when its entry went in but its object did not, so a caller can tell that adding again would record the bytes twice.- The library comment says what "written and flushed" covers: this process crashing, not a power cut, since the renames that keep objects are not flushed to their folder.
- A compiled build can keep a journal.
dart run is_journal:code_hashprints-Dis_journal.code=<hash>from the source about to be compiled, andJournal.openuses it when there is no source to hash. Run from source,openthrows aStateErrorwhen that define is not this code's hash. - Depends on
is_content_id0.2.0 exactly, not ^0.2.0, and the library comment names that version, so the code hash changes when the pin does: the same code hash means the sameis_content_id. A test fails ifpubspec.yamlandlib/disagree, or if the pin becomes a range.
0.2.0 #
The format is unchanged: journals written by 0.1.0 read the same.
- The code hash is an
is_content_idFileSetId, the name of a set of files, whichis_content_id0.2.0 now holds.CodeHashis gone:Journal.codeHash,Journal.ownHash(),JournalEntry.codeandapproved()areFileSetIds. The samelib/has the same 32-byte hash. - Depends on
is_content_id^0.2.0, and re-exports it, soFileSetIdandListedPathcome with the journal.
Fixes from a review of 0.1.0:
- Processes take turns through a lock on a new file,
lock, instead of onentries. Closing any descriptor on a file gives up every lock its process holds on it, so anything in a writing process that readentriesended the lock, and two processes could write at once and break the chain. - A
Journalcannot be sent to another isolate. Sending copied it, and the copy wrote as a second writer that its claim could not see. openresolves a relative directory, so the journal stays where it opened when the working directory moves.closesucceeds when itswriter.<pid>is already gone.approved()reads past bytes that are not UTF-8.- The README's bash check says when there is no journal, or no
xxd, rather than reporting an empty journal.
0.1.0 #
- First release:
Journal, withJournalEntry,EntryHash,CodeHash,JournalCheck(NoJournal,Intact,Broken) andCorruptObject, onis_content_id'sObjectIdand sha256. Everyaddadds an entry of three names, in journal formatis_journal/1, and keeps the bytes whole.openclaims the directory for its process untilclose. Which code the person approved is read fromapprovedbyapproved(), never written into an entry.