Expand description
Usefulness as the memory dynamics of a collective brain (internal evaluation “phase-r”, “R1 design”, not published).
Everything here is derived from the append-only outcome log (outcome.rs), so merging two logs merges
memory, whatever the line order. The belief readers derive it from the team view (outcome.rs
read_team): this machine’s log plus the redacted results the mesh syncs from teammates, each
remote session under its hashed id and counted once per lesson, so teammates converge on one
memory. The activity clock then counts the collective’s sessions on every node, not this machine’s
alone. BORG_SHARE_OUTCOMES=off keeps it this machine’s view. Per lesson:
- Uses. A use is an
asked_then_changedrecord: after the Stop block asked the lesson, the drone changed its work on that point and the change avoids the consequence, as judged by the consequence model at a later Stop call of the session (predict.rsJudged, main.rspending; no extra call). The lesson’s creation counts as one use too, so a new lesson is not invisible. - Activation (ACT-R base-level learning; equally a pheromone trail of evaporating deposits):
A = ln(Σ_j Δt_j^(−d))over the uses j,d = 0.5(D_CONSOLIDATED= 0.3 once consolidated). Δt counts sessions of the collective since the use (the activity clock,Clock), plus one, never wall time: a holiday erases nothing. Uses spread over time keep a lesson active longer than the same number massed early; with a fixed d that comes from the later last use (a decay that depends on the activation at each use, Pavlik and Anderson’s spacing model, is a possible refinement). - Usefulness belief
Beta(1 + changed + ½·tested, 1 + ignored + 2·corrected + 3·vetoed + regretted)(the veto’s 3 isVETOED_W), one result per (session, lesson), vetoed > corrected > changed > ignored.asked_not_corrected(settled byborg learn) is censored, no result: the judge never said whether the drone acted on the lesson. A placebo’s result and an unclear verdict are none either (outcome.rsis_result). A correction counts twice (outcome.rsCORRECTED_W); a veto (borg no, veto.rs) three times, above a correction as the design asks (no eval behind the 3 yet). Regretted is the weighted share of later fixes of decisions the lesson was asked before (outcome.rsregretted), each regret once, at mostREGRET× 0.875: a separate, later event, added on top of the session’s result unless that result is a correction or a veto (the stronger result already counts it). One deciding session’s regrets give a lesson at mostregret_capof that session’s corrections by the engineer (is_correction: a miss a regret wrote is none). A fractional β is sampled by randomised rounding (round_seeded).tested(outcome.rs) is the session’s own tests going green after the ask, one per (lesson, session), weighedTESTED_W: additive to the session’s result (it is about the work, a session result about the engineer’s reaction), never a use, no tick, and nothing for a session whose result is a correction or a veto. A fractional α (a candidate weight) is rounded the same way (draw).Weightsholds the hand-set weights so thatborg debug ope(ope.rs) can replay the belief under other values offline; the countsderivereturns are constant-free. - Weight =
squash(A) × (0.5 + x), wherexis a Thompson sample from the belief, seeded by (session, lesson) so a session sees one stable ranking, or the belief’s mean without a session.squash(A) = 2 / (1 + e^(−A/2))lies in (0, 2) and is 1 at A = 0, a lesson created this session;0.5 + xlies in (0.5, 1.5) with mean 1 for a lesson without outcomes. So a new lesson ranks as BM25 ranks it, in expectation; uncertain lessons get tried (their samples spread), proven ones win, harmful ones fade. The sample is tempered (±50 %) so that a lesson with no evidence cannot drop a strong BM25 match to nothing. In ranking (conscience.rs), the relative bar uses the mean weight and the session’s draw orders the lessons over the bar for the limited slots: exploration never pushes a strong match under the bar, it decides who gets asked when more qualify than fit. - Consolidated (long-term): changed in at least
CONSOLIDATE_SESSIONSdistinct sessions, across at least two repos or authored by at least two engineers. Consolidated lessons decay slower and may be delivered early even without a scope (main.rsearly). - Dormant: not consolidated and
A < DORMANT_BELOW(about 54 sessions of the collective without a use). Never deleted: a dormant lesson is recalled only on a strong match (conscience.rsrank), and one use reactivates it. - Whose sessions count. Disuse is measured where the lesson could have been used, by its reach,
on whichever node the sessions ran. ACT-R’s decay stands for
the opportunities a memory had and missed; a session that could never have recalled the lesson is
no such opportunity. So a team lesson ages with every session of the collective, a teammate’s
included: they all see it, and a lesson none of their drones acts on for ~54 sessions has stopped
mattering to the people it reaches, even when its own author’s node is quiet. A repo convention ages
only with the sessions in its repo (
Clock::eligible, by the repo of each session’s lines), so neither a teammate’s busy week elsewhere nor an engineer’s own work in another repo lets it fade. This is coarser than reach.rsdeliverable: a session’s repo is its working directory’s (hook.rsrepo_of), not every repo it touched, so a session started in one repo that edits another is no tick for the other’s conventions (a use there still counts: it ranks at the next eligible tick). The system gate (systems.rsgate) is not applied, so a lesson scoped to other systems ages with every session its reach allows. In the team view each repo is a case-sensitive tag, so a clone whose directory name differs in case from the lesson’s repo does not age it.
Structs§
- Clock
- The collective’s activity clock: its sessions in the order they first appear in the outcome log
(by first ms, then id: independent of line order). Only the kinds the team shares
(outcome.rs
SHARED_KINDS) tick it, so every node counts the same sessions from the same first ms: a session that only graded never moves it, and neither does atestedresult (about the session’s work) nor a placebo’s (never shared, outcome.rsis_result). - Memory
- One lesson’s memory.
- Rng
- SplitMix64.
- Weights
- The belief’s hand-set weights (design-chosen;
borg debug opeestimates others offline, never applies them).
Constants§
- CONSOLIDATE_
SESSIONS - Baseline: the distinct sessions that changed their work on a lesson before it is consolidated (with two repos or two engineers), design-chosen.
- D
- Baseline: ACT-R’s decay of a use’s activation (
din the module doc), the value of the ACT-R literature; not fitted to borg’s outcomes. - DORMANT_
BELOW - Baseline: the activation below which an unconsolidated lesson is dormant (about 54 sessions without
a use at
D), design-chosen; a dormant lesson is recalled only on a strong match, never deleted. - D_
CONSOLIDATED - Baseline: the slower decay of a consolidated lesson (module doc), design-chosen.
- NOVEL_
WORDS - Baseline: undeclared, a change needs this many of the lesson’s distinctive words new in the drone’s work (design-chosen: one or two shared words happen by chance).
- REGRET
- Baseline: what one regret at full strength adds to a lesson’s β: half a correction (a correction is same-session, same-concern evidence; a regret is delayed and shared among the lessons asked). A veto weighs more than a correction, so regret < corrected < vetoed.
- TESTED_
W - Baseline: what one
testedresult (outcome.rs) adds to α: half a change (design-chosen,borg debug opeestimates others): the session’s own runner said the work passes. - VETOED_
W - Baseline: what one veto (
borg no, veto.rs) adds to a lesson’s β: above a correction’s 2, as the design asks (design-chosen, no eval behind it yet). - WEIGHTS
- The weights in force.
Functions§
- activation
ln(Σ age^(−d))over ages in ticks (each at least 1); −∞ without any.- declared
<id>: applies(Some(true)) or<id>: skip(Some(false)) in a lowercased message; brackets, backticks, a dash or a colon between, the last such line winning.- derive
- Each lesson’s memory as of
session(its tick; the next tick when absent or None). - draw
- A Thompson draw from Beta(alpha, beta), both randomised-rounded (
round_seeded); integer parameters draw exactly as before. - regret_
cap - The most regret credit one deciding session gives a lesson: that session’s corrections in the log
(distinct times of its
is_correctionresults), at least one, as one session counts once for a lesson’s other results. Guard: one session whose work later took many fixes (a long build’s review findings: 193 regrets of one session blamed every lesson it asked, 12,577 lines) would otherwise outweigh every other session of the lesson. - resolve
- The word rule: what the drone did with each asked lesson after it was delivered: (changed, ignored).
Never an outcome: its labels measured shared vocabulary (55% “changed” against 38% on a mismatched
control, internal evaluation “phase-r” R1, not published). It only decides whether an early-delivered lesson counts as done
(main.rs
early_acted) and serves the offline replay (borg debug resolve); asked lessons are labelled by the consequence model (main.rspending). - round_
seeded xrounded to an integer at random, unbiased: ⌊x⌋ + 1 with probability frac(x), drawn fromseed. An integerxis returned as is without a draw, so a lesson without regrets samples as before.- sample_
beta - A Beta(a, b) draw for integer a, b ≥ 1: X / (X + Y) with X ~ Gamma(a), Y ~ Gamma(b), each a sum of exponentials. Counts above 1000 are scaled down to keep the cost bounded (the shape barely moves).
- seed
- FNV-1a over
session \0 lesson: a stable seed (std’s hasher may change between Rust versions). - shuffle
- A deterministic shuffle of
itemsforsession(Fisher-Yates onRng): the order questions are shown in, so that no lesson always sits first (position bias). - squash
2 / (1 + e^(−A/2)): (0, 2), 1 at A = 0.- strip_
declaration textwithout the drone’s declarations of lessonid(every<id>: applies|skipthatdeclaredreads, the id and the word both): the judge’s evidence for a question whose declaration it must not see (hook.rsstripped). Other lessons’ declarations and the rest of the text stay.