Skip to main content

Module memory

Module memory 

Source
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_changed record: 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.rs Judged, main.rs pending; 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 is VETOED_W), one result per (session, lesson), vetoed > corrected > changed > ignored. asked_not_corrected (settled by borg learn) without a change is ignored. A correction counts twice, as in outcome.rs; 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.rs regretted), each regret once, at most REGRET × 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). 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), weighed TESTED_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). Weights holds the hand-set weights so that borg debug ope (ope.rs) can replay the belief under other values offline; the counts derive returns are constant-free.
  • Weight = squash(A) × (0.5 + x), where x is 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 + x lies 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_SESSIONS distinct 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.rs early).
  • 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.rs rank), 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.rs deliverable: a session’s repo is its working directory’s (hook.rs repo_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.rs gate) 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 a tested result (about the session’s work).
Memory
One lesson’s memory.
Rng
SplitMix64.
Weights
The belief’s hand-set weights (design-chosen; borg debug ope estimates others offline, never applies them).

Constants§

CONSOLIDATE_SESSIONS
D
DORMANT_BELOW
D_CONSOLIDATED
NOVEL_WORDS
Undeclared, a change needs this many of the lesson’s distinctive words new in the drone’s work.
REGRET
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
What one tested result (outcome.rs) adds to α: half a change (design-chosen, borg debug ope estimates others): the session’s own runner said the work passes.
VETOED_W
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.
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.rs pending).
round_seeded
x rounded to an integer at random, unbiased: ⌊x⌋ + 1 with probability frac(x), drawn from seed. An integer x is 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 items for session (Fisher-Yates on Rng): 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.