Documentation
¶
Overview ¶
Package queue manages the learn inbox: job files written by the SessionEnd hook, a lockfile so only one worker mines at a time, and per-transcript byte cursors. Deletion is parse-gated (ecosystem lesson): a job is removed only after a successfully processed mine — crashes and retries never lose observations. Three failures move the job to inbox/failed/ (circuit break).
Index ¶
- Variables
- func Done(j Job) error
- func Enqueue(inboxDir string, job Job) error
- func Fail(j Job) (parked bool, err error)
- func ScannerBlockedTranscripts(inboxDir string) map[string]struct{}
- func ShouldMine(cur Cursor, size int64, sessionEnd bool, now time.Time) bool
- type Cursor
- type Cursors
- type Job
- type Lock
Constants ¶
This section is empty.
Variables ¶
var ErrLocked = errors.New("queue: another learn worker is running")
ErrLocked reports another live worker holds the lock — the caller should simply exit; the queue drains on the next run.
Functions ¶
func Done ¶
Done removes a successfully processed job (parse-gated: call only after the mine result was parsed and persisted).
func Enqueue ¶ added in v0.3.0
Enqueue atomically writes one stable transcript pointer. The filename is derived from source+session+path, so re-running a history scan (or a hook re-delivering the same session) overwrites in place instead of creating a duplicate job. Codex can reach this boundary through either a direct hook transcript path or the rollout scanner, so the stable key is an active cross-mechanism safety property.
func Fail ¶
Fail records one failed attempt. The job file survives under a .fN suffix until maxAttempts, then moves to inbox/failed/ for manual inspection. Returns true when the job was parked (no more retries).
func ScannerBlockedTranscripts ¶ added in v0.3.0
ScannerBlockedTranscripts returns transcript paths that a rollout scanner must not enqueue again. It includes active jobs, retry-renamed .json.fN jobs, and jobs parked after exhausting their retry ladder. Without the parked set, a periodic scan would silently resurrect a circuit-broken job every ten minutes. This read-only helper never repairs malformed entries.
Types ¶
type Cursor ¶
Cursor is one transcript's mining progress: everything before Offset has been mined once (plan §learning A — each region mined exactly once).
type Cursors ¶
type Cursors struct {
// contains filtered or unexported fields
}
Cursors is the persistent transcript_path → Cursor map.
func LoadCursors ¶
LoadCursors reads state/learn_cursors.json; a missing or corrupt file yields an empty map (worst case: some regions are mined twice — the dedup stage absorbs that).
type Job ¶
type Job struct {
SessionID string `json:"session_id"`
TranscriptPath string `json:"transcript_path"`
CWD string `json:"cwd"`
Source harness.Harness `json:"source,omitempty"`
Trigger string `json:"trigger,omitempty"`
EnqueuedAt string `json:"enqueued_at"`
// contains filtered or unexported fields
}
Job is one queued transcript, as enqueued by the SessionEnd hook.
func List ¶
List reads every pending job (including previously failed retries), newest first. A malformed job file is parked, never fatal.