Documentation
¶
Overview ¶
Package blips is the repair for wake-blip charges: rows the recorder wrote when a truck woke from sleep, its first vehicleState frame replayed the pre-sleep "charging_active" and the next frame, about a second later, said complete (fixed in the recorder by liveCharge.blip, #1254). A blip is a live charge shorter than 20 s that moved the battery less than half a point.
Unlike internal/repair/phantom this tool FINDS its candidates, by that one predicate, and an apply must present the count and the sha256 of the sorted id list of an approved dry run: anything else aborts the transaction. It deletes in one transaction, backs every row and its cascading dependents up (CSV and charges_deleted_backup, the phantom repair's format, so phantom.Restore and phantom.RestoreRows undo it), and refuses rows a user touched.
Index ¶
Constants ¶
const ( MaxDuration = 20 * time.Second MaxSoCDelta = 0.5 // RecentOpenWindow: an open live charge touched within this long means a truck is charging // now; the repair does not run then (the recorder is writing, and it is not a quiet hour). RecentOpenWindow = 15 * time.Minute )
The recorder's bounds (internal/rivian liveChargeBlipMax and liveChargeBlipSoC): the repair uses the same predicate on stored rows.
Variables ¶
var ErrDrift = errors.New("blips: the rows to delete differ from the approved dry run; nothing deleted")
ErrDrift: the rows no longer match the approved dry run (nothing was deleted).
var ErrOpenCharge = errors.New("blips: a live charge was written in the last 15 minutes; run in a quiet hour")
ErrOpenCharge: a truck is charging now; the repair does not run.
Functions ¶
func Apply ¶
func Apply(ctx context.Context, d *sql.DB, batchID uuid.UUID, wantCount int, wantDigest, reason string, allowOpen bool, sink func([]phantom.BackupRow) error) (int, error)
Apply deletes the blips in ONE transaction. It locks and re-selects the candidates, re-applies the rule, and aborts unless the count AND the digest of the sorted ids equal the approved dry run's. The backup rows (the charges and their cascading pack-health samples) go to sink (the durable CSV; an error aborts before anything is deleted) and to charges_deleted_backup when it exists. It aborts if the deleted count differs.
Types ¶
type Plan ¶
Plan is the classified candidates.
type Queryer ¶
type Queryer interface {
QueryContext(ctx context.Context, q string, args ...any) (*sql.Rows, error)
QueryRowContext(ctx context.Context, q string, args ...any) *sql.Row
}
Queryer is *sql.DB or *sql.Tx.
type Row ¶
type Row struct {
ID uuid.UUID
UserID uuid.UUID
VehicleID uuid.UUID
StartedAt time.Time
EndedAt time.Time
StartSoC *float64
EndSoC *float64
FinalState string
Source string
CostSource string
// What a person or another table says about the row.
HasRestamp bool
HasReceipt bool
Edited bool // a place or location override, a note or a tag
HasPack bool // a pack-health sample points at it (cascades; backed up)
}
Row is a candidate: a live charge shorter than MaxDuration, with what the rule needs.