Documentation
¶
Overview ¶
Package reflection is the organ that mirrors Tomo's discoveries back to the human (ADR-0015): Curiosity learns for Tomo, Tomo's question asks for Tomo — Reflection alone exists so the *user* grows. It is a projection: candidates are derived from ledger events already computed elsewhere, the telling is never stored, and only two facts become truth — 「語った事実」 (tomo.reflected) and 「反応」 (experiences kind='reflection').
Index ¶
Constants ¶
const ( // BudgetWindowMs: 1日1つ — the question budget's shape, borrowed. BudgetWindowMs = 24 * 3600 * 1000 // ReversalBand is the hysteresis width on 逆転 detection (ADR-0002's // Schmitt trigger, borrowed): the new leader must be ahead by this much // in posterior mean, so a photo-finish jitter is never narrated. ReversalBand = 0.1 )
Knobs (ADR-0015 Consequences).
const ( ReactionUnexpected = "unexpected" // 意外 — the telling had value ReactionKnown = "known" // 知ってた — low value ReactionWrong = "wrong" // それ違う — refutes the content itself )
Reaction vocabulary (Outcome.Reaction).
Variables ¶
This section is empty.
Functions ¶
func Ask ¶
Ask prints the telling and reads the reaction. Anything but 1/2/3 (including EOF) is a free skip.
func HasBudget ¶
HasBudget: no tomo.reflected in the trailing window (the question budget's shape — a skip still spends it, ADR-0007の型).
func RecordAndApply ¶
func RecordAndApply(s *store.Store, en *core.Engine, cand Candidate, seed int64, reaction, askedAfter string, extractorVer int, nowMs int64) error
RecordAndApply writes the two truths: the telling (tomo.reflected — a skip still spends the budget) and, when the user reacted, the reflection experience. 「それ違う」 additionally carries a layer-2 verdict against the subject connection (ADR-0015 Decision 3: 内容の出所へ), which Apply routes through the normal capability path without births.
Types ¶
type Candidate ¶
type Candidate struct {
Type string // voice.Insight* (5 trigger types)
Scope core.Scope // the connection's scope — where feedback lands
Diff core.Scope // split only: the distinguishing tokens (for the line)
Provider string // the subject (winner, for reversal)
Other string // reversal only: the overtaken provider
OldToken string // reperceived only: the attribution that moved away
NewToken string // reperceived only: the attribution that moved in
}
Candidate is one tellable ledger event.
func Detect ¶
Detect compares the before-snapshot with the repo's current state and returns every tellable event, deterministically ordered.
func Pick ¶
func Pick(cands []Candidate, exps []*core.Experience, seed, nowMs int64) Candidate
Pick selects which candidate to tell: one Thompson draw per candidate from its type's reaction posterior (ADR-0015 Decision 3 — 語りの選択もJudgment by Math; the sampler is ADR-0012's). Blank types draw from Beta(1,1) and explore. Returns the seed's winner; deterministic per (ledger, seed).
func ReperceptionCandidates ¶
func ReperceptionCandidates(before, after []*core.Experience) []Candidate
ReperceptionCandidates is the 5th trigger (ADR-0019 Decision 4): compare the current-experience view before and after a perceive batch — a session whose current extraction was superseded at a higher version with different tokens means idle work re-read the past and the attribution moved.
type Snapshot ¶
type Snapshot struct {
// contains filtered or unexported fields
}
Snapshot is the derived state of every connection before an Apply batch — what Detect compares the after-state against. All four triggers are already-computed derivations; no new detector exists (ADR-0015 Decision 2).