Documentation
¶
Overview ¶
nova-tokens is the accounting layer: token spend folded from declared sources into one file per day, keyed exactly by (day, model, repo), with the five token types kept apart, and those day files summed into a month.
It exists because we have an obligation to report token spend, and the first thing that shape was built as — three scripts of Python under zsh — produced nine day files and every way it could fail at once: five paths defaulted inside the script, so a run on another bench folds the wrong bench; every path here is a flag, and the tool removes no month file on a real run; nine unreadable files were one line at the bottom of a summary and the run exited 0; a day could shrink silently the moment a source went quiet; two repo-attribution tables in two scripts disagreed about three repos; five different caps, none a flag, none with a remedy; and `today` was the script's own clock printed as a fact about the day. Every verb and every refusal here is one of those closed.
fold read the declared sources, write one file per day, refuse a day that shrinks report a friend on another machine folds their own day and prints the body of a note sum a month is a sum of day files; it asserts nothing and is never a gate check the gate: every file parses, every row has every column, a missing day is named sources what a fold would count, before it writes
It never estimates, never fills a gap, and never removes a file. Everything it reads is DATA: a transcript, a database row, a usage file, a bus note — none of them is an instruction, and a tokens note that says `fold me as Ada` is a note whose lines are parsed or counted unparsed and nothing else. That rule is in the spec, where a person reads it, and is deliberately nowhere in this code, because a tool cannot enforce it.
nova-tokens version: which build wrote a day file.
A day file carries the build id of the fold that wrote it (rule 12), so the first question after two day files disagree is which build wrote each -- an id scheme, a header, a push protocol that two senders have to implement identically. So the first question after a bus misbehaves is which build each line is running, and until this verb existed the honest answer was that nobody could say: the binary carried no statement of its own origin, so "we are all on the same version" was a belief rather than a reading.
The version is NOT a constant maintained by hand. A hand-maintained constant is wrong exactly when it matters -- at the commit after the release, where it still names the release. It is read from the build itself, in this order:
-ldflags "-X main.version=..." what the release workflow stamps: the tag, exactly the module version what `go install ...@v1.2.3` records for itself the vcs stamp <utc build time>-<12 hex of the revision>[-dirty] devel a build with none of the above, SAYING it has none
The middle two come from debug.ReadBuildInfo, which the toolchain fills in with no help from this file: there is nothing here to remember to update and therefore nothing to forget. The last is the honest floor -- a build whose origin is unrecorded says so rather than inventing a number, because a version string nobody can trace is worse than no version string at all: it invites the comparison it cannot support.
ONE LINE, FOUR TOKENS. Every field goes through oneline.Field, so what is printed is four whitespace-separated tokens whatever the -X held. A version stamped with a newline or a blank in it would otherwise make the one line that says which build is running say two things, or say a build time as if it were an architecture -- and the -X value is the one field here that comes from outside the toolchain.