Documentation
¶
Overview ¶
Package memorysynthesis contains the bounded, privacy-filtered material envelope used by daily memory synthesis. The envelope (materials.go) has no database or agent dependency: callers provide already structured source items and Build performs the common ordering, de-duplication, secret scrubbing, budget enforcement, and digest calculation. service.go coordinates one run record through the jobstore; concrete material adapters live in the sources subpackage.
Index ¶
Constants ¶
const ( OutcomeSucceeded = "succeeded" OutcomeFailed = "failed" // OutcomeReused: a succeeded run with the same input digest exists; only last_checked_at moved. OutcomeReused = "reused" // OutcomeRunning: another run of the same project and day is in flight. OutcomeRunning = "running" // OutcomeEmpty: the window has no material, so no record was created. OutcomeEmpty = "empty" )
Outcome states reported by Service.Run.
const DayLayout = "2006-01-02"
DayLayout is the format of a business day ("2026-10-28").
const SchemaV1 = "daily-memory-materials.v1"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Item ¶
type Item struct {
ID string `json:"id"`
Kind string `json:"kind"`
OccurredAt string `json:"occurred_at,omitempty"`
Title string `json:"title,omitempty"`
Text string `json:"text,omitempty"`
SourceRef string `json:"source_ref"`
SourceRefs []string `json:"source_refs,omitempty"`
Sensitivity string `json:"sensitivity,omitempty"`
}
Item is one allow-listed fact from a source adapter. Text is never treated as instructions.
type Materials ¶
Materials is the persisted-safe result of preparing an envelope. The digest covers the canonical envelope, including omission counts, and is therefore stable for identical input.
type Outcome ¶ added in v0.205.0
type Outcome struct {
State string
Run jobstore.MemorySynthesisRun
}
Outcome is the result of one Service.Run call. Run is zero for OutcomeEmpty.
type RunStore ¶ added in v0.205.0
type RunStore interface {
BeginMemorySynthesisIfChanged(jobstore.MemorySynthesisBegin) (jobstore.MemorySynthesisRun, jobstore.MemorySynthesisBeginOutcome, error)
FinishMemorySynthesisRun(id string, f jobstore.MemorySynthesisFinish) (jobstore.MemorySynthesisRun, error)
}
RunStore is the persistence the coordinator needs; *jobstore.Store implements it.
type Service ¶ added in v0.205.0
type Service struct {
Store RunStore
Sources []Source
Options Options
Synth Synthesizer
// Loc is the server time zone used for the business-day window (default time.Local).
Loc *time.Location
Lookback time.Duration
// Timeout bounds a run; a running record older than this is treated as stale.
Timeout time.Duration
// KeepSnapshot stores the scrubbed envelope on the run record (keep_material_snapshot).
KeepSnapshot bool
Now func() time.Time
NewID func() string
}
Service coordinates material preparation and the run record. It owns no goroutines; callers (an explicit run command, later a scheduler) decide when to call Run.
func (*Service) Prepare ¶ added in v0.205.0
Prepare collects, scrubs and bounds the materials of one project day without touching the store.
type Source ¶
Source is a read-only structured material adapter. Adapters must not return transcripts, prompts, argv, environment values, or attachments.
type SynthResult ¶ added in v0.205.0
SynthResult is what a synthesizer hands back. P1 never calls a model: the function is a seam that tests (and later phases) fill in.
type Synthesizer ¶ added in v0.205.0
type Synthesizer func(context.Context, Materials) (SynthResult, error)
Synthesizer turns prepared (already scrubbed and bounded) materials into a result.
type Window ¶ added in v0.205.0
Window is the half-open interval [Start, End) of one business day in the server's time zone, optionally widened backwards by a longer lookback. A source keeps an event when Contains(unix) is true, so the day boundaries never double count or drop an event.
func DayWindow ¶ added in v0.205.0
DayWindow computes the window of `day` in loc. The window always ends at the next local midnight and starts at the day's own midnight; a lookback longer than 24h only moves the start earlier (End - lookback), a shorter or zero one keeps the plain day. Computing the midnights from calendar dates (not by adding 24h) keeps DST days 23 / 25 hours long.