Skip to main content

Module stats

Module stats 

Source
Expand description

What Borg did, counted: the collective’s usage statistics.

Two files per collective store:

  • stats/events.jsonl (local, never synced): one line per event, written by the hook or command where it happened (record). It holds session ids and repos, so it stays on this machine.
  • stats.jsonl (synced by the mesh, borg-mesh lines.rs SYNCED): one rollup per (node, engineer, UTC day), folded from the local events (rollup). A bucket is a versioned record (id + version), so the mesh’s settle keeps its latest version on every machine with no merge logic of its own. Only the node that owns a bucket writes it, so buckets never conflict. A rollup carries counts, cost and lesson ids, never prompts or sessions.

Recording fails open and costs one append: a broken store never disturbs the drone.

Structs§

Bucket
One node’s counts for one engineer on one UTC day: a line of stats.jsonl.
Event
Said
One session’s corrections and vetoes (per_session).

Constants§

ANSWERED
The rollup count of the answers to a drone’s own questions (a CORRECTION event whose why is learn.rs ANSWER; fold).
ASSIMILATED
One imported chunk of team documents (n: lessons, usd).
BLOCK
A block: one extra round of agent work (n: questions, lessons: the asked ids).
CHANGED
Outcomes of asked lessons (outcome.rs): used, ignored, corrected anyway, not corrected.
CHECK
One turn-end model call (n: lessons shown, usd, dur_ms; why: "failed" when it gave no answer).
CORRECTED
CORRECTION
The engineer corrected the drone (an episode): why is rejected_tool, pushback, regret or answer (learn.rs ANSWER: an answer to the drone’s own question), text a snippet. An answer is rolled up under ANSWERED, never as a correction: the corrections tiles keep counting rejected tool calls and pushback.
EARLY
Lessons handed over free at a prompt or touch (n, lessons).
FEED_CHARS
Display: the characters of a feed excerpt (excerpt): one line of borg web’s activity feed.
GATE_SKIP
The free gate skipped the model call (why: the score, or noedit).
IGNORED
LESSON_MERGED
LESSON_NEW
A lesson written (why: its source, session/import/queen/veto) or merged into an existing one.
LIVE_ASK
Live mode, before 0.7.6 (removed; history only): grade-3 lessons a live check asked, delivered with the next prompt or tool call (n, lessons). Never an extra round: the drone answered as it worked.
LIVE_CHECK
Live mode, before 0.7.6 (removed; history only): one model call during the turn (n, usd, dur_ms, why: "failed", as check).
MODEL_CALL
A model call outside the turn end (why: learn, assimilate, facets, expert, judge: the session-end judge, hook.rs judge_session, with n the lessons sent to the judge; usd, dur_ms).
MSG_DELIVERED
MSG_DROPPED
MSG_SENT
Messages between sessions (msg.rs): one sent (why: tell/ask), shown to a session (why: its kind), and dropped (why: window, the sender’s window to its recipient was full, msg.rs window_for; events before 0.6.0 say rate; bounds, n lines the log’s bound, msg.rs MEMBER_BYTES, cut).
NOT_A_LESSON
borg learn judged an episode not to be a lesson.
NOT_CORRECTED
PAUSE_REFUSED
QUEEN_ANSWERED
QUEEN_DELIVERED
QUEEN_DISMISSED
QUEEN_MISSED
QUEEN_NO
The queen’s attention reward (escalation.rs), once per event: an escalation answered by changing course, one answered “yes, fine”, and a “no” after merge from a session never escalated (why: the kind, or veto/regret; text starts with the question, episode or link id).
QUEEN_QUEUED
The queen’s queue: a question queued, handed to a drone, answered (dur_ms: time to answer), skipped, dismissed.
QUEEN_SKIPPED
QUEEN_STAMP
QUEUED_FREE
Grade-2 and grade-1 lessons queued to arrive free at the next prompt (n, lessons).
REGRETTED
A later fix, or a review finding, counted against a lesson asked before the decision (outcome.rs regretted; lessons: the blamed lesson).
REVIEW_FINDING
A review step’s finding that a fix step fixed before any commit, recorded as an episode (review_fix.rs; why: its severity, text: its redacted title, for this machine’s feed only).
STEER_DELIVERED
STEER_DROPPED
STEER_ISSUED
Steering: a directive issued, shown to a drone (why: say/pause/resume), refused on receipt (why: the reason), and a tool call refused because the drone was paused (why: the tool).
TESTED
borg learn credited a lesson asked before the session’s own tests went green (outcome.rs tested; lessons: that lesson).
TURN_END
A turn end the conscience saw (one per Stop that was not the rework after its own block).
VETO
The engineer said no (borg no, veto.rs): lessons the lessons shown so far (credited vetoed), n their number, why cli, prompt or mesh, text the reason.
VETO_REPEAT
borg learn merged a veto into a lesson an earlier veto made: the same “no” said twice, dated when that veto was said (its episode’s ms), so it falls in the week of its own veto.

Functions§

backfill
Derives, once per store, the events that happened before live counting began from the logs Borg kept anyway: corrections (episodes), outcomes, lessons, the queen’s queue, imports, expert and facet calls, steering drops, and the turn ends recorded in the session state (dated by the state file’s time). Only what happened before the first live event counts, so nothing is counted twice. Returns how many events it wrote; 0 when it ran before.
backfill_path
count
Records one event in the store home now; fill adds the details. The engineer defaults to the one presence.rs recorded for the session, so callers need not ask git again.
current
Every bucket the page shows: other nodes’ published rollups, and this node’s own counts folded fresh from its local events, so local activity shows before the next rollup.
day
YYYY-MM-DD (UTC) of an epoch-ms time.
days_between
Every YYYY-MM-DD from first to last (UTC), both included; empty if either is malformed.
events
Every local event: the history derived once from the older logs (backfill) and the live ones.
events_path
excerpt
The first max characters of text on one line (a feed excerpt, FEED_CHARS).
fold
The local events folded into this node’s buckets, keyed by bucket id (version 0).
live
The live events only (stats/events.jsonl), without the derived history.
live_since
When live counting began in home: its first live event (None: none yet). A repeated veto is dated when it was said, earlier than its line, so it never marks the start. What backfill derives is before it; a series backfill cannot derive (merges, repeated vetoes) is unknown there.
node
This machine’s id in the collective’s statistics, created once (stats/node). Not the mesh key: stats work in local collectives too, and nothing here should need the member key.
per_session
Per session, what the engineer said against its work: every correction and veto, whether or not borg learn merged it into a lesson (a merge is what outcome.rs sees; most corrections merge into none). The denominator for how often a mistake was seen at all, beside the results.
purpose
record
Appends ev to the local event log. Fails open; records nothing with BORG_LEARN=off (eval drones).
rollup
Publishes this node’s buckets whose counts changed since their last line in stats.jsonl, each with the next version. Returns how many lines it appended (0 when nothing changed).
rollups
The latest version of every bucket in stats.jsonl (every node’s, after the mesh merged them). Two lines of one version (two rollups at once) are ranked as borg-mesh lines.rs settle ranks them, by the line’s blake3 hash, so every node shows the same one whatever order the lines arrived in.
rollups_path
set_purpose
What this process’s model calls are for (learn, assimilate, facets), set once by the command.
source
An episode’s Event::source: its harness and harness_version, joined; empty for the hooks’ (and imports from before 0.7.2).