Documentation
¶
Overview ¶
Package state is the SQLite state store — schema v1. The store is the system of record: every paging Event corresponds to a durable state change written here first. There is no migration path from the Python schema; existing deployments start cold and re-baseline.
Index ¶
- type AcceptedDigest
- type Attempt
- type AuditFilter
- type CandidateObservation
- type CandidateRecord
- type Key
- type NotifierHealth
- type PendingProposal
- type ProposalRecord
- type Status
- type Store
- func (s *Store) AcceptedDigest(key Key) (string, bool, error)
- func (s *Store) AcquireLease(now time.Time, ttlSeconds int) (string, bool, error)
- func (s *Store) Attempts(limit int) ([]Attempt, error)
- func (s *Store) AuditPage(filter AuditFilter) ([]Attempt, error)
- func (s *Store) Candidate(key Key) (*CandidateRecord, error)
- func (s *Store) Candidates() ([]CandidateRecord, error)
- func (s *Store) ClearBreaker(reason string, now time.Time) error
- func (s *Store) ClearPendingProposal(key Key) (bool, error)
- func (s *Store) ClearSuppression(event, stack, service string) error
- func (s *Store) Close() error
- func (s *Store) LastAttempt(key Key) (*Attempt, error)
- func (s *Store) NotifierDestination() (string, error)
- func (s *Store) NotifierHealth() (NotifierHealth, error)
- func (s *Store) ObserveCandidate(key Key, digest string, now time.Time) (CandidateObservation, error)
- func (s *Store) OpenBreaker(reason string, now time.Time) error
- func (s *Store) PendingProposal(key Key) (*PendingProposal, error)
- func (s *Store) RecordAttempt(attempt Attempt, now time.Time) error
- func (s *Store) RecordNotifierFailure() error
- func (s *Store) RecordNotifierSuccess(now time.Time) error
- func (s *Store) ReleaseLease(token string) error
- func (s *Store) ResetSuppression() error
- func (s *Store) SetAcceptedDigest(key Key, digest string, now time.Time) error
- func (s *Store) SetNotifierDestination(fingerprint string) error
- func (s *Store) SetPendingProposal(key Key, digest, proposalURL string, now time.Time) error
- func (s *Store) SetSuppressionState(event, stack, service, state string, now time.Time) error
- func (s *Store) Status(now time.Time) (Status, error)
- func (s *Store) SuppressionState(event, stack, service string) (string, bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AcceptedDigest ¶
AcceptedDigest pairs a Key with its accepted Baseline digest.
type Attempt ¶
type Attempt struct {
// ID is the audit trail's own order. It is the cursor `ripen audit`
// pages by, and it never appears in the JSON surface.
ID int64
Key Key
RunID string
Actor domain.Actor
OldDigest string
NewDigest string
Result domain.ResultCode
Detail string
AttemptedAt time.Time
}
Attempt is one recorded Transaction attempt.
type AuditFilter ¶
type AuditFilter struct {
Limit int
Cursor int64
RunID string
Backend domain.Backend
Stack string
Service string
Result domain.ResultCode
}
AuditFilter narrows and pages the audit trail. Every field is optional; an empty filter reads the newest attempts.
type CandidateObservation ¶
CandidateObservation is one observed Candidate digest and its history.
type CandidateRecord ¶
type CandidateRecord struct {
Key Key
Digest string
FirstSeen time.Time
LastSeen time.Time
Count int
}
CandidateRecord is one observed Candidate, with its Key.
type Key ¶
Key identifies one Service's state: backend, stack, and service, with service empty for a stack-level policy. The Python schema's state_key column pretended this was one string; schema v1 stores the three parts.
type NotifierHealth ¶
NotifierHealth is the persisted Notifier delivery health.
type PendingProposal ¶
PendingProposal is an open Proposal (PR) awaiting review.
type ProposalRecord ¶
ProposalRecord pairs a Key with its pending Proposal for Status.
type Status ¶
type Status struct {
BreakerOpen bool
BreakerReason string
AcceptedDigests []AcceptedDigest
LeaseActive bool
PendingProposals []ProposalRecord
}
Status is the durable state snapshot behind `ripen status`.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the SQLite-backed state store.
func Open ¶
Open opens (creating if needed) the state database at path, creating the parent directory when missing.
func (*Store) AcceptedDigest ¶
AcceptedDigest returns the accepted Baseline digest for a Key.
func (*Store) AcquireLease ¶
AcquireLease takes the run lease when no unexpired lease exists, returning an owner token. BEGIN IMMEDIATE serializes contenders.
func (*Store) AuditPage ¶
func (s *Store) AuditPage(filter AuditFilter) ([]Attempt, error)
AuditPage reads the audit trail newest first, narrowed by the filter and paged by attempt id. The audit trail is the attempts table — never the Event stream, which is a notification channel and not a record.
func (*Store) Candidate ¶
func (s *Store) Candidate(key Key) (*CandidateRecord, error)
Candidate returns one Key's observed Candidate, or nil.
func (*Store) Candidates ¶
func (s *Store) Candidates() ([]CandidateRecord, error)
Candidates returns every observed Candidate, oldest Key first.
func (*Store) ClearBreaker ¶
ClearBreaker closes the Circuit breaker; the operator's reason is mandatory and recorded.
func (*Store) ClearPendingProposal ¶
ClearPendingProposal removes a Key's Proposal record, reporting whether one existed.
func (*Store) ClearSuppression ¶
ClearSuppression drops one suppression key, re-arming it. Recovery uses this: a stack that failed, recovered, and fails again must page the second time.
func (*Store) LastAttempt ¶
LastAttempt returns the newest audit entry for one Key, or nil. The Key is matched exactly, empty service included, which is why this does not go through the audit filter.
func (*Store) NotifierDestination ¶
NotifierDestination reads the fingerprint of the destination the suppression table was built against.
func (*Store) NotifierHealth ¶
func (s *Store) NotifierHealth() (NotifierHealth, error)
NotifierHealth reads the persisted Notifier delivery health.
func (*Store) ObserveCandidate ¶
func (s *Store) ObserveCandidate(key Key, digest string, now time.Time) (CandidateObservation, error)
ObserveCandidate records one observation of a Candidate digest. A new digest replaces any previous Candidate for the Key; re-observing the same digest increments its count, preserving first_seen.
func (*Store) OpenBreaker ¶
OpenBreaker opens the Circuit breaker with a reason.
func (*Store) PendingProposal ¶
func (s *Store) PendingProposal(key Key) (*PendingProposal, error)
PendingProposal returns the Key's open Proposal, or nil.
func (*Store) RecordAttempt ¶
RecordAttempt appends one Transaction attempt to the audit trail.
func (*Store) RecordNotifierFailure ¶
RecordNotifierFailure increments the persisted failure streak.
func (*Store) RecordNotifierSuccess ¶
RecordNotifierSuccess records a successful delivery, resetting the failure streak.
func (*Store) ReleaseLease ¶
ReleaseLease releases the lease if the token still owns it; releasing a superseded token is a no-op.
func (*Store) ResetSuppression ¶
ResetSuppression clears every suppression record — used when the webhook destination changes, so the new destination pages current state once (which is correct).
func (*Store) SetAcceptedDigest ¶
SetAcceptedDigest records a digest as the accepted Baseline and clears the Key's Candidates and pending Proposal: accepting is the terminal state of both.
func (*Store) SetNotifierDestination ¶
SetNotifierDestination records which destination the suppression table belongs to.
func (*Store) SetPendingProposal ¶
SetPendingProposal records an open Proposal for a Key.
func (*Store) SetSuppressionState ¶
SetSuppressionState records the state a notification was last sent for.