Documentation
¶
Overview ¶
Package engine assembles one explicit daily memory synthesis run: it reads the live memory.synthesis configuration, builds the material sources and the model-backed synthesizer, and drives memorysynthesis.Service. It sits above memorysynthesis (and uses job for the one-shot model call) so the entry layers (httpapi, commands) only bind parameters and forward (G021); nothing in memorysynthesis imports it back (G022).
Index ¶
Constants ¶
const ScheduledBy = "schedule"
ScheduledBy is the CreatedBy of the runs the built-in daily trigger starts.
Variables ¶
var ( // ErrDisabled: memory.synthesis.enabled is false. ErrDisabled = errors.New("memory synthesis is disabled: set memory.synthesis.enabled to true in the server configuration") // ErrProject: the project is unknown or not listed in memory.synthesis.projects. ErrProject = errors.New("memory synthesis project not available") // ErrAgent: the configured synthesis agent cannot run a read-only, tool-less call. ErrAgent = errors.New("memory synthesis agent unusable") // ErrDay: the day is not a YYYY-MM-DD date. ErrDay = errors.New("memory synthesis day must be YYYY-MM-DD") )
Errors a caller maps to an answer; the wrapped text says what to change.
Functions ¶
This section is empty.
Types ¶
type Deps ¶
type Deps struct {
Store *jobstore.Store
Doctor sources.DoctorReader
Config func() *config.Config
OneShot OneShot
Now func() time.Time
// Loc is the server time zone of the business day (nil = time.Local).
Loc *time.Location
}
Deps are the engine's collaborators. Config returns the live configuration generation (hot reload takes effect on the next run).
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine runs explicit synthesis requests and the built-in daily trigger (Tick).
func (*Engine) Enabled ¶
Enabled reports whether memory.synthesis.enabled is on in the live configuration.
func (*Engine) Run ¶
Run executes one explicit synthesis: disabled configuration is refused before anything is read or sent; otherwise the run record, reuse and force semantics are those of memorysynthesis.Service.
func (*Engine) Tick ¶ added in v0.208.0
func (e *Engine) Tick(ctx context.Context) []TickResult
Tick is the built-in daily trigger. The serve loop calls it every minute or so; it is cheap and idempotent: nothing happens when the feature is off, before the trigger time, or once the day is settled. It runs the model at most once per project per target day (more only when daily_limit allows and the input changed), never in parallel with itself for the same project, and survives restarts because every decision is read back from the run records (limits, running, backoff after a failure). Tick is not safe to call concurrently with itself; the loop is a single goroutine.
The trigger time and the day boundary use the server time zone (Deps.Loc). The target day is the previous local day, so its window is complete.
type JobOneShot ¶
JobOneShot is the production memorysynthesis.OneShot: one read-only, tool-less, single-turn job of a cli-agent on the server's own runner, with the summarizer's internal tag (hidden from ordinary lists and excluded from the synthesis materials) and no project rules.
func (JobOneShot) Check ¶
func (o JobOneShot) Check(agentKey string) error
Check says why the agent cannot run a synthesis ("" nil = usable), before any record exists.
func (JobOneShot) Run ¶
func (o JobOneShot) Run(ctx context.Context, r memorysynthesis.OneShotRequest) (string, error)
type OneShot ¶
type OneShot interface {
memorysynthesis.OneShot
Check(agent string) error
}
OneShot is memorysynthesis.OneShot plus the up-front usability check.
type Request ¶
type Request struct {
Project string
// Day is YYYY-MM-DD in the server time zone; "" means today.
Day string
CreatedBy string
// Origin is the ceiling owner of the model call (the calling person).
Origin string
Force bool
// Scheduled marks the built-in daily trigger: it is held to daily_limit and
// retry_after, while an explicit run only to the (larger) manual ceiling.
Scheduled bool
}
Request is one explicit run.
type TickResult ¶ added in v0.208.0
type TickResult struct {
Project string
Day string
// State is a memorysynthesis.Outcome* value; empty when Err is set.
State string
Run jobstore.MemorySynthesisRun
Err error
}
TickResult is what one Tick did for one project.