reflection

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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).

View Source
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

func Ask(in *bufio.Reader, out io.Writer, text string) (reaction string)

Ask prints the telling and reads the reaction. Anything but 1/2/3 (including EOF) is a free skip.

func HasBudget

func HasBudget(s *store.Store, nowMs int64) (bool, error)

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

func Detect(before *Snapshot, repo core.Repo, nowMs int64) ([]Candidate, error)

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.

func (Candidate) Text

func (c Candidate) Text() string

Text renders the candidate's spoken line (deterministic voice templates — the LLM verbalization seat of ADR-0015 Decision 4 stays reserved, but the mirror must not need Ollama awake to speak).

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).

func TakeSnapshot

func TakeSnapshot(repo core.Repo, nowMs int64) (*Snapshot, error)

TakeSnapshot derives the before-state. Call it immediately before the perception/Apply batch whose discoveries should be tellable.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL