package wire import "time" // Housekeeping is Equipo's tidying loop (spec // 2026-11-08-equipo-housekeeping.md): detectors notice things, a ledger // with a state machine records what each finding became, and everything // the loop does leaves a receipt with Undo. These are its person API v1 // resources and events. // EventHousekeeping tells the person their housekeeping changed: resource // "action" carries a HousekeepingAction, resource "housekeeping" a // HousekeepingSummary (Pause, a detector switched). const EventHousekeeping = "housekeeping" // CardHousekeeping is the daily digest line in the conversation (State // CardDigest, Question the line). The combined card, a receipt with // Undo, keeps its kind and carries ActionID and VisibleAt. const ( CardHousekeeping = "housekeeping" CardDigest = "digest" ) // Action states: the ledger's state machine. A row only moves forward. const ( ActionClaimed = "claimed" ActionHeld = "held" ActionDone = "done" ActionUndone = "undone" ActionRefused = "refused" ActionFailed = "failed" ActionVetoed = "vetoed" ActionExpired = "expired" ) // Reasons on an action. const ( // ReasonHousekeepingForbidden: the housekeeping principal failed a // check in the store; nothing it tried survived. ReasonHousekeepingForbidden = "housekeeping_forbidden" // ReasonSubjectMoved: the subject changed while the finding waited. ReasonSubjectMoved = "subject_moved" // ReasonHeldBudget, ReasonHeldCeiling, ReasonHeldStandDown: why a // finding is held. ReasonHeldBudget = "budget" ReasonHeldCeiling = "ceiling" ReasonHeldStandDown = "stand_down" // ReasonHeldOverflow: more held findings than a person keeps. ReasonHeldOverflow = "held_overflow" // ReasonDetectorFailures: a detector switched off for the person after // two failures (Undos count) within seven days. ReasonDetectorFailures = "failures" ) // Housekeeping is GET /api/v1/housekeeping: the person's own loop. type Housekeeping struct { Paused bool `json:"paused"` // Quiet is the person's quiet hours: receipts made in them wait. Quiet QuietHours `json:"quiet"` Budget HousekeepingBudget `json:"budget"` Detectors []HousekeepingDetector `json:"detectors"` // Actions are the newest actions, newest first; Refusals the newest // refused and failed rows. Actions []HousekeepingAction `json:"actions"` Refusals []HousekeepingAction `json:"refusals"` Revision int64 `json:"revision"` } // HousekeepingBudget is today's three budgets, reserved and charged. type HousekeepingBudget struct { Turns BudgetMeter `json:"turns"` Tokens BudgetMeter `json:"tokens"` Retries BudgetMeter `json:"retries"` } // BudgetMeter is one of the day's budgets. type BudgetMeter struct { Reserved int64 `json:"reserved"` Charged int64 `json:"charged"` Limit int64 `json:"limit"` } // HousekeepingDetector is one detector as the person sees it. type HousekeepingDetector struct { ID string `json:"id"` Class string `json:"class"` Enabled bool `json:"enabled"` DisabledReason string `json:"disabled_reason"` DisabledAt *time.Time `json:"disabled_at"` } // HousekeepingSubject is what an action is about. type HousekeepingSubject struct { Kind string `json:"kind"` ID string `json:"id"` } // HousekeepingEvidence is structured, never prose: the tasks the finding // is about, how alike they read and how many words they share. type HousekeepingEvidence struct { Tasks []TaskRef `json:"tasks"` Similarity float64 `json:"similarity"` Shared int `json:"shared"` } // HousekeepingAction is one ledger row: what a finding became. type HousekeepingAction struct { ID string `json:"id"` Revision int64 `json:"revision"` Detector string `json:"detector"` Class string `json:"class"` State string `json:"state"` Reason string `json:"reason"` Subject HousekeepingSubject `json:"subject"` Evidence HousekeepingEvidence `json:"evidence"` // Undoable: Undo is offered now; UndoUntil is when it stops. Undoable bool `json:"undoable"` UndoUntil *time.Time `json:"undo_until"` // VisibleAt is when its receipt shows in the conversation (quiet // hours); null when it showed at once. VisibleAt *time.Time `json:"visible_at"` At time.Time `json:"at"` UndoneAt *time.Time `json:"undone_at"` } // HousekeepingActions is GET /api/v1/housekeeping/actions?before=&limit=. type HousekeepingActions struct { Items []HousekeepingAction `json:"items"` Before string `json:"before"` } // SetHousekeeping is PUT /api/v1/housekeeping: Pause, and quiet hours // when given. type SetHousekeeping struct { Paused bool `json:"paused"` Quiet *QuietHours `json:"quiet,omitempty"` Revision int64 `json:"revision"` } // QuietHours is a window in whole hours (0 to 23) of the person's zone, // UTC until a zone is known; From equal to Until is none. The default is // 22 to 8. type QuietHours struct { From int `json:"from"` Until int `json:"until"` } // SetDetector is PUT /api/v1/housekeeping/detectors/{id}. type SetDetector struct { Enabled bool `json:"enabled"` Revision int64 `json:"revision"` } // HousekeepingSummary is Snapshot.housekeeping_summary and the data of a // housekeeping event with resource "housekeeping". type HousekeepingSummary struct { OpenSuggestions int `json:"open_suggestions"` Paused bool `json:"paused"` Disabled []string `json:"disabled"` Revision int64 `json:"revision"` } // ActionConflict is the 409 body of an Undo that can no longer apply: // the action as it is now. type ActionConflict struct { Code string `json:"code"` CopyKey string `json:"copy_key"` RequestID string `json:"request_id"` Action HousekeepingAction `json:"action"` }