audit

package
v0.8.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 30 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DefaultDeepMaxArchiveBytes  int64 = 20 << 30
	DefaultDeepMaxDatabaseBytes int64 = 100 << 30
	DefaultDeepMaxTempBytes     int64 = 120 << 30
	DeepMaxObjects                    = 1_000_000
	DeepMaxPages                      = 10_000
	DeepMaxConcurrency                = 8
)
View Source
const (
	FreshnessCurrent FreshnessStatus = "current"
	FreshnessUnknown FreshnessStatus = "unknown"

	FreshnessNotFound FreshnessReason = "not_found"
	FreshnessStale    FreshnessReason = "stale"
)
View Source
const (
	MaxDailyEvidence  = 366
	MaxByKindEvidence = 64
	MaxMissingFields  = 32
)
View Source
const (
	DefaultPendingWarn = 24 * time.Hour
	DefaultPendingFail = 72 * time.Hour
	DefaultBackupWarn  = 36 * time.Hour
	DefaultBackupFail  = 72 * time.Hour
)
View Source
const (
	SchemaV1 = "dbrain.audit.v1"
	SchemaV2 = "dbrain.audit.v2"
)
View Source
const (
	InventoryMaxIdentities = 100_000
	InventoryMaxPages      = 10_000
)
View Source
const AlertStateSchemaV1 = "dbrain.audit.alert-state.v1"
View Source
const MaxWebhookBytes int64 = 64 << 10

Variables

View Source
var (
	ErrDeepProfileRequired   = errors.New("deep audit entry point requires deep profile")
	ErrDeepBudget            = errors.New("deep audit budget exhausted")
	ErrDeepInterrupted       = errors.New("deep audit interrupted")
	ErrDeepCandidateInvalid  = errors.New("deep archive candidate invalid")
	ErrDeepListingIncomplete = errors.New("deep inventory listing incomplete")
)
View Source
var (
	ErrInventoryInvalid    = errors.New("upstream inventory result invalid")
	ErrInventoryIncomplete = errors.New("upstream inventory traversal incomplete")
	ErrInventoryBudget     = errors.New("upstream inventory budget exhausted")
)
View Source
var ErrDeepUnsupported = errors.New("deep audit requires the explicit RunDeep CLI --profile deep entry point")

Functions

func ApplyAlertObservation

func ApplyAlertObservation(state AlertState, report Report, opts AlertOptions) (AlertState, AlertDecision, error)

func DurationAllowance

func DurationAllowance(durations []time.Duration) (time.Duration, DurationAllowanceSource, Confidence)

func ExitCode

func ExitCode(report Report) int

func FinalizeReport

func FinalizeReport(report *Report)

func FreshnessDeadline

func FreshnessDeadline(profile Profile, syncInterval, standardInterval time.Duration) time.Duration

func HasExecutor

func HasExecutor(id CheckID) bool

func HashUpstreamFeedIdentity

func HashUpstreamFeedIdentity(feedKey, identity string) (string, error)

HashUpstreamFeedIdentity preserves feed identity evolution by binding an entry identity (guid:, link:, or stored identity_key) to its feed key.

func HashUpstreamIdentity

func HashUpstreamIdentity(source Source, identity string) (string, error)

HashUpstreamIdentity produces a content-free, source-domain-separated value suitable for local set membership. The raw identity is never report evidence.

func Overall

func Overall(checks []Check) (Status, Confidence)

func ParseDuration

func ParseDuration(value string) (time.Duration, error)

func SchedulerThresholds

func SchedulerThresholds(interval, jitter, allowance time.Duration) (time.Duration, time.Duration)

func ValidateAlertState

func ValidateAlertState(state AlertState) error

func ValidateEvidence

func ValidateEvidence(id CheckID, evidence Evidence) error

func ValidateReport

func ValidateReport(report Report) error

Types

type AlertChange

type AlertChange struct {
	CheckID CheckID               `json:"check_id"`
	Status  Status                `json:"status"`
	Summary string                `json:"summary"`
	Reason  AlertResolutionReason `json:"reason,omitempty"`
}

type AlertDecision

type AlertDecision struct {
	Profile         Profile       `json:"profile"`
	Notify          bool          `json:"notify"`
	OverallRecovery bool          `json:"overall_recovery"`
	Changes         []AlertChange `json:"changes"`
}

type AlertOptions

type AlertOptions struct {
	ConsecutiveObservations int
	RepeatAfter             time.Duration
	WebhookConfigured       bool
	Now                     time.Time
}

type AlertResolutionReason

type AlertResolutionReason string
const AlertResolvedByConfiguration AlertResolutionReason = "resolved_by_configuration"

type AlertState

type AlertState struct {
	Schema   string                        `json:"schema"`
	Profiles map[Profile]ProfileAlertState `json:"profiles"`
}

func MarkAlertDelivered

func MarkAlertDelivered(state AlertState, decision AlertDecision, deliveredAt time.Time) AlertState

type ArchiveLister

type ArchiveLister interface {
	List(context.Context) (SQLiteArchiveListing, error)
}

type ArchiveObject

type ArchiveObject struct {
	Key          string
	ValidKey     bool
	SizeBytes    int64
	LastModified time.Time
}

type ArchivedMediaRecord

type ArchivedMediaRecord struct {
	Key             string
	SizeBytes       int64
	ArchivedAt      time.Time
	ArchivedAtValid bool
}

type Boundary

type Boundary struct {
	Layout                string `json:"layout"`
	ConfigVerified        bool   `json:"config_verified"`
	DatabaseVerified      bool   `json:"database_verified"`
	Version               string `json:"version"`
	Commit                string `json:"commit"`
	GitStatus             string `json:"git_status"`
	Platform              string `json:"platform"`
	SecurityBaseline      string `json:"security_baseline"`
	SecurityBaselineEpoch int    `json:"security_baseline_epoch"`
	SchemaVersion         int    `json:"schema_version"`
	SchemaCompatibility   string `json:"schema_compatibility"`
}

type Category

type Category string
const (
	CategoryBoundary   Category = "boundary"
	CategoryScheduler  Category = "scheduler"
	CategoryImports    Category = "imports"
	CategoryPipeline   Category = "pipeline"
	CategorySemantic   Category = "semantic"
	CategoryDurability Category = "durability"
)

func (Category) Valid

func (c Category) Valid() bool

type Check

type Check struct {
	ID          CheckID    `json:"id"`
	Category    Category   `json:"category"`
	Status      Status     `json:"status"`
	Confidence  Confidence `json:"confidence"`
	Required    bool       `json:"required"`
	Summary     string     `json:"summary"`
	ObservedAt  time.Time  `json:"observed_at"`
	Threshold   *Threshold `json:"threshold,omitempty"`
	Evidence    Evidence   `json:"evidence"`
	Remediation string     `json:"remediation,omitempty"`
	SkipReason  SkipReason `json:"skip_reason,omitempty"`
	ErrorCode   ErrorCode  `json:"error_code,omitempty"`
}

type CheckAlertState

type CheckAlertState struct {
	Confirmed        Status                `json:"confirmed,omitempty"`
	Pending          Status                `json:"pending,omitempty"`
	PendingCount     int                   `json:"pending_count,omitempty"`
	LastObserved     Status                `json:"last_observed,omitempty"`
	Required         bool                  `json:"required"`
	LastNotifiedAt   time.Time             `json:"last_notified_at,omitempty"`
	ResolutionReason AlertResolutionReason `json:"resolution_reason,omitempty"`
	DeliveryPending  bool                  `json:"delivery_pending,omitempty"`
}

type CheckID

type CheckID string
const (
	CheckBoundaryConfig                      CheckID = "boundary.config"
	CheckBoundaryRuntime                     CheckID = "boundary.runtime"
	CheckBoundarySecurityBaseline            CheckID = "boundary.security_baseline"
	CheckBoundaryDatabase                    CheckID = "boundary.database"
	CheckIntegritySchemaIdentity             CheckID = "integrity.schema_identity"
	CheckIntegrityMigrationCompatibility     CheckID = "integrity.migration_compatibility"
	CheckIntegritySQLiteQuickCheck           CheckID = "integrity.sqlite_quick_check"
	CheckIntegrityForeignKeys                CheckID = "integrity.foreign_keys"
	CheckSchedulerLatestSync                 CheckID = "scheduler.latest_sync"
	CheckSchedulerStageCoverage              CheckID = "scheduler.stage_coverage"
	CheckSchedulerContinuity                 CheckID = "scheduler.continuity"
	CheckMetricsWindow                       CheckID = "metrics.window"
	CheckImportsAppleNotesPoll               CheckID = "imports.apple_notes.poll"
	CheckImportsAppleNotesArrivals           CheckID = "imports.apple_notes.arrivals"
	CheckImportsSafariTabsPoll               CheckID = "imports.safari_tabs.poll"
	CheckImportsSafariTabsArrivals           CheckID = "imports.safari_tabs.arrivals"
	CheckImportsXBookmarksPoll               CheckID = "imports.x_bookmarks.poll"
	CheckImportsXBookmarksArrivals           CheckID = "imports.x_bookmarks.arrivals"
	CheckImportsGitHubStarsPoll              CheckID = "imports.github_stars.poll"
	CheckImportsGitHubStarsArrivals          CheckID = "imports.github_stars.arrivals"
	CheckImportsYouTubeLikedPoll             CheckID = "imports.youtube_liked.poll"
	CheckImportsYouTubeLikedArrivals         CheckID = "imports.youtube_liked.arrivals"
	CheckImportsYouTubeWatchLaterPoll        CheckID = "imports.youtube_watch_later.poll"
	CheckImportsYouTubeWatchLaterArrivals    CheckID = "imports.youtube_watch_later.arrivals"
	CheckImportsFeedsPoll                    CheckID = "imports.feeds.poll"
	CheckImportsFeedsArrivals                CheckID = "imports.feeds.arrivals"
	CheckPipelineHydrationPartition          CheckID = "pipeline.hydration.partition"
	CheckPipelineHydrationPendingAge         CheckID = "pipeline.hydration.pending_age"
	CheckPipelineExtractionPartition         CheckID = "pipeline.extraction.partition"
	CheckPipelineExtractionPendingAge        CheckID = "pipeline.extraction.pending_age"
	CheckPipelineSummaryPartition            CheckID = "pipeline.summary.partition"
	CheckPipelineSummaryPendingAge           CheckID = "pipeline.summary.pending_age"
	CheckPipelineTranscriptionPartition      CheckID = "pipeline.transcription.partition"
	CheckPipelineTranscriptionPendingAge     CheckID = "pipeline.transcription.pending_age"
	CheckPipelineOCRPartition                CheckID = "pipeline.ocr.partition"
	CheckPipelineOCRPendingAge               CheckID = "pipeline.ocr.pending_age"
	CheckPipelineItemSummaryProvenance       CheckID = "pipeline.item_summary.provenance"
	CheckPipelineItemOCRProvenance           CheckID = "pipeline.item_ocr.provenance"
	CheckPipelineXMediaTranscriptProvenance  CheckID = "pipeline.x_media_transcript.provenance"
	CheckPipelineSourceSummaryProvenance     CheckID = "pipeline.source_summary.provenance"
	CheckDurabilityMediaLocalCoverage        CheckID = "durability.media_local_coverage"
	CheckDurabilityMediaRemote               CheckID = "durability.media_remote"
	CheckDurabilitySQLiteBackupConfiguration CheckID = "durability.sqlite_backup_configuration"
	CheckDurabilitySQLiteBackupAge           CheckID = "durability.sqlite_backup_age"
	CheckDurabilityOKFFreshness              CheckID = "durability.okf_freshness"
	CheckDurabilityOKFValidation             CheckID = "durability.okf_validation"
	CheckUpstreamAppleNotesParity            CheckID = "upstream.apple_notes.parity"
	CheckUpstreamSafariTabsParity            CheckID = "upstream.safari_tabs.parity"
	CheckUpstreamXBookmarksParity            CheckID = "upstream.x_bookmarks.parity"
	CheckUpstreamGitHubStarsParity           CheckID = "upstream.github_stars.parity"
	CheckUpstreamYouTubeLikedParity          CheckID = "upstream.youtube_liked.parity"
	CheckUpstreamYouTubeWatchLaterParity     CheckID = "upstream.youtube_watch_later.parity"
	CheckUpstreamFeedsParity                 CheckID = "upstream.feeds.parity"
	CheckDurabilityMediaRemoteOnly           CheckID = "durability.media_remote_only"
	CheckDurabilitySQLiteRestore             CheckID = "durability.sqlite_restore"
	CheckSemanticCurrentReadiness            CheckID = "semantic.current_readiness"
	CheckSemanticLatestAttachedRefresh       CheckID = "semantic.latest_attached_refresh"
	CheckSemanticStageSummary                CheckID = "semantic.stage_summary"
)

type Confidence

type Confidence string
const (
	ConfidenceHigh     Confidence = "high"
	ConfidenceModerate Confidence = "moderate"
	ConfidenceLow      Confidence = "low"
	ConfidenceUnknown  Confidence = "unknown"
)

func (Confidence) Valid

func (c Confidence) Valid() bool

type DatabaseInspection

type DatabaseInspection struct {
	SchemaCompatibility                           string
	MigrationCompatibility                        string
	MissingTableCount, MissingColumnCount         int
	QuickCheck                                    string
	QuickViolationCount, ForeignKeyViolationCount int
	UserVersion, SupportedVersion, AppliedCount   int
}

type DatabaseInspector

type DatabaseInspector interface {
	Inspect(context.Context, bool) (DatabaseInspection, error)
}

type DeepArchiveReader

type DeepArchiveReader interface {
	Open(context.Context, string) (io.ReadCloser, error)
}

type DeepArchiveResult

type DeepArchiveResult struct {
	CompressedBytes          int64
	DecompressedBytes        int64
	QuickCheck               string
	QuickCheckObserved       bool
	ForeignKeyViolationCount int
	ForeignKeysObserved      bool
	SchemaCompatibility      string
	SchemaObserved           bool
	MigrationCompatibility   string
	MigrationObserved        bool
}

type DeepArchiveVerifier

type DeepArchiveVerifier interface {
	Verify(context.Context, io.ReadCloser, *vaultfs.PrivateTemp, DeepLimits) (DeepArchiveResult, error)
}

type DeepDependencies

type DeepDependencies struct {
	Archives             DeepArchiveReader
	VerifyArchive        DeepArchiveVerifier
	Media                DeepMediaInventory
	MediaErrorCode       ErrorCode
	NewTemp              func() (*vaultfs.PrivateTemp, error)
	CleanupTemp          func(*vaultfs.PrivateTemp) error
	RecordCleanupFailure func(string)
	FreeSpace            func(*vaultfs.PrivateTemp) (uint64, error)
	Limits               DeepLimits
	Upstream             UpstreamInventories
}

type DeepLimits

type DeepLimits struct {
	MaxArchiveBytes  int64
	MaxDatabaseBytes int64
	MaxTempBytes     int64
	MaxObjects       int
	MaxPages         int
	MaxConcurrency   int
	RequestTimeout   time.Duration
	ReadIdleTimeout  time.Duration
	RunTimeout       time.Duration
}

func DefaultDeepLimits

func DefaultDeepLimits() DeepLimits

type DeepMediaInventory

type DeepMediaInventory interface {
	ListPage(context.Context, string, int) (MediaInventoryPage, error)
}

type Dependencies

type Dependencies struct {
	Features       Features
	Store          StoreSnapshot
	Database       DatabaseInspector
	Metrics        MetricsReader
	Archives       ArchiveLister
	Media          MediaArchiveInspector
	MediaErrorCode ErrorCode
	OKF            OKFInspector
	Semantic       SemanticInspector
	Runtime        RuntimeVersion
	Clock          func() time.Time
}

type DurationAllowanceSource

type DurationAllowanceSource string
const (
	DurationAllowanceP95         DurationAllowanceSource = "p95"
	DurationAllowanceMaxObserved DurationAllowanceSource = "max_observed"
	DurationAllowanceNone        DurationAllowanceSource = "none"
)

type ErrorCode

type ErrorCode string
const (
	ErrorUnavailable          ErrorCode = "unavailable"
	ErrorTimeout              ErrorCode = "timeout"
	ErrorCanceled             ErrorCode = "canceled"
	ErrorInterrupted          ErrorCode = "interrupted"
	ErrorRead                 ErrorCode = "read_error"
	ErrorParse                ErrorCode = "parse_error"
	ErrorBudgetExhausted      ErrorCode = "budget_exhausted"
	ErrorConfiguration        ErrorCode = "configuration_error"
	ErrorCredentialResolution ErrorCode = "credential_resolution_error"
	ErrorDestinationRejected  ErrorCode = "destination_rejected"
	ErrorListingIncomplete    ErrorCode = "listing_incomplete"
	ErrorManifest             ErrorCode = "manifest_error"
	ErrorDatabase             ErrorCode = "database_error"
)

func (ErrorCode) Valid

func (e ErrorCode) Valid() bool

type Evidence

type Evidence map[string]any

type EvidenceKind

type EvidenceKind string
const (
	EvidenceInteger        EvidenceKind = "integer"
	EvidenceBoolean        EvidenceKind = "boolean"
	EvidenceTimestamp      EvidenceKind = "timestamp"
	EvidenceEnum           EvidenceKind = "enum"
	EvidenceDaily          EvidenceKind = "daily"
	EvidenceByKind         EvidenceKind = "by_kind"
	EvidenceMissingByField EvidenceKind = "missing_by_field"
	EvidenceIdentifier     EvidenceKind = "identifier"
	EvidenceSemanticStages EvidenceKind = "semantic_stages"
)

type Features

type Features struct {
	Layout                            string
	ConfigSource                      string
	ConfigVerified                    bool
	DatabaseOpenedQueryOnly           bool
	SchedulerEnabled                  bool
	SchedulerInterval                 time.Duration
	SchedulerJitter                   time.Duration
	SelectedStages                    []string
	Sources                           map[Source]bool
	Stages                            map[PipelineStage]bool
	MediaLocalEnabled                 bool
	MediaRemoteEnabled                bool
	MediaProvider                     string
	SQLiteArchiveCapabilityConfigured bool
	SQLiteBackupSchedulerEnabled      bool
	SQLiteBackupAuditRequired         bool
	SQLiteProviderConfigured          bool
	SQLiteCredentialConfigured        bool
	SQLiteResolutionError             bool
	OKFEnabled                        bool
	// SemanticConfigured is intentionally separate from feature eligibility:
	// semantic audit checks stay visible when disabled or unsupported.
	SemanticConfigured          bool
	SemanticCapabilityAvailable bool
	Timeouts                    map[TimeoutClass]time.Duration
	RemoteRequestTimeout        time.Duration
}

type Freshness

type Freshness struct {
	Status          FreshnessStatus `json:"status"`
	Reason          FreshnessReason `json:"reason,omitempty"`
	AgeSeconds      *int64          `json:"age_seconds,omitempty"`
	DeadlineSeconds int64           `json:"deadline_seconds"`
}

type FreshnessReason

type FreshnessReason string

type FreshnessStatus

type FreshnessStatus string

type InventoryBudget

type InventoryBudget struct {
	MaxIdentities int
	MaxPages      int
}

InventoryBudget is a fixed, caller-owned upper bound. Importer adapters may stop earlier, but cannot widen these ceilings.

func DefaultInventoryBudget

func DefaultInventoryBudget() InventoryBudget

type InventoryResult

type InventoryResult struct {
	IdentityHashes []string
	PageCount      int
	Complete       bool
}

InventoryResult intentionally contains no raw identities or source content. Complete is asserted only by the importer after observing its natural end.

type KindPartition

type KindPartition struct {
	Kind                                                        string
	Total, Current, Pending, Blocked, Terminal, Failed, Unknown int
	PartitionValid                                              bool
}

type MediaArchiveInspector

type MediaArchiveInspector interface {
	HeadObject(context.Context, string) (ObjectMetadata, error)
}

type MediaInventoryObject

type MediaInventoryObject struct {
	Key       string
	SizeBytes int64
}

type MediaInventoryPage

type MediaInventoryPage struct {
	Objects   []MediaInventoryObject
	NextToken string
	Complete  bool
}

type MediaLocalEvidence

type MediaLocalEvidence struct{ EligibleLocalCount, UncoveredPrunedCount, OrphanCount int }

type MediaSample

type MediaSample struct {
	Records                                                        []ArchivedMediaRecord
	RecentPopulation, RecentChecked, OlderPopulation, OlderChecked int
	InvalidCount                                                   int
	Mode                                                           string
	Confidence                                                     Confidence
}

func SelectMediaSample

func SelectMediaSample(records []ArchivedMediaRecord, since time.Duration, now time.Time, provider string) MediaSample

type MetricsReader

type MetricsReader interface {
	Read(context.Context, time.Time) (metrics.Window, error)
}

type OKFInspection

type OKFInspection struct {
	ManifestValid                                        bool
	ExportedAt                                           time.Time
	DocumentCount, BrokenLinkCount, ValidationErrorCount int
	TraversalComplete                                    bool
}

type OKFInspector

type OKFInspector interface {
	Inspect(context.Context, bool) (OKFInspection, error)
}

type ObjectMetadata

type ObjectMetadata struct {
	Exists    bool
	SizeBytes int64
}

type PipelineEvidence

type PipelineEvidence struct {
	Total, Current, Pending, Blocked, Terminal, Failed, Unknown int
	PartitionValid                                              bool
	OldestPendingAt                                             time.Time
	OldestPendingKnown                                          bool
	ByKind                                                      []KindPartition
}

type PipelineStage

type PipelineStage string
const (
	PipelineHydration     PipelineStage = "hydration"
	PipelineExtraction    PipelineStage = "extraction"
	PipelineSummary       PipelineStage = "summary"
	PipelineTranscription PipelineStage = "transcription"
	PipelineOCR           PipelineStage = "ocr"
)

type PresentedReport

type PresentedReport struct {
	Report    *Report   `json:"report"`
	Freshness Freshness `json:"freshness"`
}

func PresentReport

func PresentReport(report *Report, profile Profile, syncInterval, standardInterval time.Duration, now time.Time) PresentedReport

PresentReport adds non-persisted freshness metadata to an immutable exact- profile report. It never rewrites the report's health status.

type Profile

type Profile string
const (
	ProfileFast     Profile = "fast"
	ProfileStandard Profile = "standard"
	ProfileDeep     Profile = "deep"
)

func (Profile) Valid

func (p Profile) Valid() bool

type ProfileAlertState

type ProfileAlertState struct {
	Checks map[CheckID]CheckAlertState `json:"checks"`
}

type ProvenanceEvidence

type ProvenanceEvidence struct {
	CheckID                                                                     CheckID
	SuccessfulCount, CompleteCount, LegacyMissingCount, PostCutoverMissingCount int
	CutoverAt                                                                   time.Time
	CutoverKnown                                                                bool
	MissingByField                                                              map[string]int
}

type RegistryEntry

type RegistryEntry struct {
	ID             CheckID
	Category       Category
	Source         Source
	Profiles       []Profile
	RequiredWhen   RequiredCondition
	Timeout        TimeoutClass
	EvidenceFields map[string]EvidenceKind
	// contains filtered or unexported fields
}

func Lookup

func Lookup(id CheckID) (RegistryEntry, bool)

func Registry

func Registry() []RegistryEntry

func RegistryForSchema added in v0.8.8

func RegistryForSchema(schema string) ([]RegistryEntry, bool)

RegistryForSchema returns the exact registry valid for persisted reports of the supplied schema. V1 is frozen so old reports cannot acquire new checks.

func (RegistryEntry) InProfile

func (e RegistryEntry) InProfile(profile Profile) bool

type Report

type Report struct {
	Schema      string     `json:"schema"`
	AuditID     string     `json:"audit_id"`
	Profile     Profile    `json:"profile"`
	Scope       Scope      `json:"scope"`
	StartedAt   time.Time  `json:"started_at"`
	CompletedAt time.Time  `json:"completed_at"`
	Status      Status     `json:"status"`
	Confidence  Confidence `json:"confidence"`
	Boundary    Boundary   `json:"boundary"`
	Summary     Summary    `json:"summary"`
	Checks      []Check    `json:"checks"`
}

func NewReport

func NewReport(profile Profile, started time.Time) Report

func Run

func Run(ctx context.Context, req Request, deps Dependencies) (Report, error)

func RunDeep

func RunDeep(ctx context.Context, req Request, deps Dependencies, deep DeepDependencies) (Report, error)

type ReportReader

type ReportReader struct {
	// contains filtered or unexported fields
}

ReportReader exposes only exact-profile persisted report reads. Unlike ReportStore construction, it never creates directories, changes modes, or receives report/state write operations.

func NewReportReader

func NewReportReader(logDir string) (*ReportReader, error)

func (*ReportReader) History

func (r *ReportReader) History(profile Profile, limit int) ([]Report, error)

func (*ReportReader) Latest

func (r *ReportReader) Latest(profile Profile) (*Report, error)

type ReportStore

type ReportStore struct {
	// contains filtered or unexported fields
}

func NewReportStore

func NewReportStore(logDir string) (*ReportStore, error)

func (*ReportStore) History

func (s *ReportStore) History(profile Profile, limit int) ([]Report, error)

func (*ReportStore) Latest

func (s *ReportStore) Latest(profile Profile) (*Report, error)

func (*ReportStore) LoadAlertState

func (s *ReportStore) LoadAlertState() (AlertState, error)

func (*ReportStore) Save

func (s *ReportStore) Save(report Report) error

func (*ReportStore) SaveAlertState

func (s *ReportStore) SaveAlertState(state AlertState) error

type Request

type Request struct {
	Profile    Profile
	Since      time.Duration
	Categories []Category
	Sources    []Source
	// SourceOverrides marks sources explicitly selected by a source-specific
	// command. It grants parity inventory authority without pretending that the
	// scheduler or configured source is enabled.
	SourceOverrides []Source
	CheckIDs        []CheckID
	ExpectCommit    string
}

type RequiredCondition

type RequiredCondition string
const (
	RequiredAlways          RequiredCondition = "always"
	RequiredNever           RequiredCondition = "never"
	RequiredScheduler       RequiredCondition = "scheduler_enabled"
	RequiredSourceScheduler RequiredCondition = "source_and_scheduler_enabled"
	RequiredSource          RequiredCondition = "source_enabled_or_explicit"
	RequiredStage           RequiredCondition = "stage_enabled"
	RequiredMediaLocal      RequiredCondition = "media_local_enabled"
	RequiredMediaRemote     RequiredCondition = "media_remote_enabled"
	RequiredSQLiteBackup    RequiredCondition = "sqlite_backup_required"
	RequiredOKF             RequiredCondition = "okf_enabled"
	RequiredSemantic        RequiredCondition = "semantic_enabled_supported"
)

func (RequiredCondition) Valid

func (r RequiredCondition) Valid() bool

type RequiredStatusCounts

type RequiredStatusCounts struct {
	Pass    int `json:"pass"`
	Warn    int `json:"warn"`
	Fail    int `json:"fail"`
	Unknown int `json:"unknown"`
}

type RuntimeVersion

type RuntimeVersion struct {
	ReleaseVersion        string
	Commit                string
	GitStatus             string
	Platform              string
	SecurityBaselineID    string
	SecurityBaselineEpoch int
}

type SQLiteArchiveListing

type SQLiteArchiveListing struct {
	ConfigurationState string
	Complete           bool
	Objects            []ArchiveObject
}

type Scope

type Scope struct {
	Categories  []Category `json:"categories"`
	Sources     []Source   `json:"sources"`
	CheckIDs    []CheckID  `json:"check_ids"`
	Filtered    bool       `json:"filtered"`
	WholeSystem bool       `json:"whole_system"`
}

type SemanticAuditSnapshot added in v0.8.8

type SemanticAuditSnapshot struct {
	Configured, CapabilityAvailable bool
	Backend                         SemanticBackend
	ProfileID                       SemanticProfileIdentifier
	ActiveGenerationID              SemanticGenerationIdentifier
	Readiness                       SemanticReadiness
	DirtyParentCount                int
	PendingParentCount              int
	DueEmbeddingCount               int
	BlockedEmbeddingCount           int
	FailedEmbeddingCount            int
	IndexedVectorCount              int
	L0VectorCount                   int
	TombstoneCount                  int
	SegmentCount                    int
	Latest                          SemanticRefreshSnapshot
}

type SemanticBackend added in v0.8.8

type SemanticBackend string

func (SemanticBackend) Valid added in v0.8.8

func (v SemanticBackend) Valid() bool

type SemanticErrorCode added in v0.8.8

type SemanticErrorCode string

func (SemanticErrorCode) Valid added in v0.8.8

func (v SemanticErrorCode) Valid() bool

type SemanticGenerationIdentifier added in v0.8.8

type SemanticGenerationIdentifier string

func (SemanticGenerationIdentifier) Valid added in v0.8.8

type SemanticIdentifier added in v0.8.8

type SemanticIdentifier string

func (SemanticIdentifier) Valid added in v0.8.8

func (v SemanticIdentifier) Valid() bool

Valid applies the same closed, content-free identifier boundary enforced for semantic evidence before adapters bind store values to audit snapshots.

type SemanticInspector added in v0.8.8

type SemanticInspector interface {
	InspectAuditSemantic(context.Context) (SemanticAuditSnapshot, error)
}

SemanticInspector is the bounded query-only seam populated by the app adapter. It deliberately carries only evidence fields declared by the v2 registry; raw run IDs, paths, checkpoints, and error text do not cross it.

type SemanticProfileIdentifier added in v0.8.8

type SemanticProfileIdentifier string

func (SemanticProfileIdentifier) Valid added in v0.8.8

func (v SemanticProfileIdentifier) Valid() bool

type SemanticReadiness added in v0.8.8

type SemanticReadiness string

func (SemanticReadiness) Valid added in v0.8.8

func (v SemanticReadiness) Valid() bool

type SemanticRefreshSnapshot added in v0.8.8

type SemanticRefreshSnapshot struct {
	State                                                         SemanticRefreshState
	StartedAt, CompletedAt, FailureAt                             time.Time
	Duration                                                      time.Duration
	ErrorCode                                                     SemanticErrorCode
	CountersComplete                                              bool
	ProjectedParentCount, EmbeddedChunkCount                      int
	FlushedVectorCount, CompactedVectorCount, VerifiedVectorCount int
	SuccessorRunCount                                             int
	Stages                                                        []SemanticStageSnapshot
}

type SemanticRefreshState added in v0.8.8

type SemanticRefreshState string

func (SemanticRefreshState) Valid added in v0.8.8

func (v SemanticRefreshState) Valid() bool

type SemanticStage added in v0.8.8

type SemanticStage string

func (SemanticStage) Valid added in v0.8.8

func (v SemanticStage) Valid() bool

type SemanticStageSnapshot added in v0.8.8

type SemanticStageSnapshot struct {
	Stage    SemanticStage
	Status   SemanticStageStatus
	Duration time.Duration
}

type SemanticStageStatus added in v0.8.8

type SemanticStageStatus string

func (SemanticStageStatus) Valid added in v0.8.8

func (v SemanticStageStatus) Valid() bool

type SkipReason

type SkipReason string
const (
	SkipProfileExcluded SkipReason = "profile_excluded"
	SkipFeatureDisabled SkipReason = "feature_disabled"
)

func (SkipReason) Valid

func (s SkipReason) Valid() bool

type Source

type Source string
const (
	SourceAppleNotes        Source = "apple-notes"
	SourceFeeds             Source = "feeds"
	SourceGitHubStars       Source = "github-stars"
	SourceSafariTabs        Source = "safari-tabs"
	SourceXBookmarks        Source = "x-bookmarks"
	SourceYouTubeLiked      Source = "youtube-liked"
	SourceYouTubeWatchLater Source = "youtube-watch-later"
)

func (Source) Valid

func (s Source) Valid() bool

type Status

type Status string
const (
	StatusPass    Status = "pass"
	StatusWarn    Status = "warn"
	StatusFail    Status = "fail"
	StatusUnknown Status = "unknown"
	StatusSkipped Status = "skipped"
)

func ClassifyAge

func ClassifyAge(age, warn, fail time.Duration) Status

func MetricsWindowStatus

func MetricsWindowStatus(requested, covered time.Duration, completedAttempts int, latestAttempt, latestCompleted bool, interval time.Duration) Status

func (Status) Valid

func (s Status) Valid() bool

type StatusCounts

type StatusCounts struct {
	Pass    int `json:"pass"`
	Warn    int `json:"warn"`
	Fail    int `json:"fail"`
	Unknown int `json:"unknown"`
	Skipped int `json:"skipped"`
}

type StoreSnapshot

type StoreSnapshot interface {
	Pipeline(context.Context) (map[PipelineStage]PipelineEvidence, error)
	Provenance(context.Context) ([]ProvenanceEvidence, error)
	MediaLocal(context.Context) (MediaLocalEvidence, error)
	ArchivedMedia(context.Context) ([]ArchivedMediaRecord, error)
	CountLocalIdentityMatches(context.Context, Source, []string) (int, error)
}

type Summary

type Summary struct {
	All      StatusCounts         `json:"all"`
	Required RequiredStatusCounts `json:"required"`
}

type Threshold

type Threshold struct {
	WarnAfterSeconds int64 `json:"warn_after_seconds,omitempty"`
	FailAfterSeconds int64 `json:"fail_after_seconds,omitempty"`
}

type TimeoutClass

type TimeoutClass string
const (
	TimeoutBootstrap            TimeoutClass = "bootstrap"
	TimeoutLocalQuery           TimeoutClass = "local_query"
	TimeoutMetricsOrManifest    TimeoutClass = "metrics_or_manifest"
	TimeoutSQLiteOrOKFIntegrity TimeoutClass = "sqlite_or_okf_integrity"
	TimeoutRemoteMetadata       TimeoutClass = "remote_metadata"
	TimeoutUpstreamInventory    TimeoutClass = "upstream_inventory"
	TimeoutDeepStream           TimeoutClass = "deep_stream"
)

func (TimeoutClass) Valid

func (t TimeoutClass) Valid() bool

type UpstreamInventories

type UpstreamInventories map[Source]UpstreamInventory

UpstreamInventories is keyed by the closed Source enum. Validation rejects future or misspelled keys rather than silently granting them authority.

type UpstreamInventory

type UpstreamInventory interface {
	Inventory(context.Context, InventoryBudget) (InventoryResult, error)
}

type Webhook

type Webhook struct {
	// contains filtered or unexported fields
}

func NewWebhook

func NewWebhook(cfg WebhookConfig) (*Webhook, error)

func (*Webhook) Configured

func (w *Webhook) Configured() bool

func (*Webhook) Deliver

func (w *Webhook) Deliver(ctx context.Context, report Report, decision AlertDecision) error

type WebhookConfig

type WebhookConfig struct {
	URL                string
	BearerTokenRef     string
	AllowPrivateOrigin bool
	AdminOrigin        string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL