milestone

package
v0.0.0-...-804b954 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package milestone builds retained status evidence and notification attempts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AcceptedRequirementIDs

func AcceptedRequirementIDs() []string

AcceptedRequirementIDs returns a copy of the binding 183-ID requirement manifest.

func NewDeliveryFailure

func NewDeliveryFailure(code FailureCode) error

NewDeliveryFailure creates a validated classified notifier failure.

func ValidateCatalog

func ValidateCatalog(catalog Catalog, ledger Ledger) error

ValidateCatalog rejects a partial, unknown, or otherwise non-canonical ledger.

func VerifyRequired

func VerifyRequired(catalog Catalog, ledger Ledger, required []RequirementID) error

VerifyRequired validates completeness before requiring named entries to be green.

Types

type ArtifactRef

type ArtifactRef string

ArtifactRef identifies retained evidence without embedding a storage URL.

type Catalog

type Catalog struct {
	// Version selects the catalog schema.
	Version int `json:"version"`
	// Requirements contains the complete generated ownership register.
	Requirements []CatalogRequirement `json:"requirements"`
}

Catalog is the complete canonical weighted requirement register.

func ParseCatalog

func ParseCatalog(input io.Reader) (Catalog, error)

ParseCatalog decodes and validates the accepted 183-row weighted catalog.

type CatalogRequirement

type CatalogRequirement struct {
	// ID is the permanent requirement identifier.
	ID RequirementID `json:"id"`
	// Milestone is the explicit owner sourced from the work map.
	Milestone MilestoneID `json:"milestone"`
	// Weight is the positive contribution to the overall estimate.
	Weight int `json:"weight"`
}

CatalogRequirement assigns one permanent requirement to an owning milestone and weight.

type CommandID

type CommandID string

CommandID identifies a reviewed verification command without embedding argv.

type Delivery

type Delivery string

Delivery records the observable delivery state of retained milestone evidence.

const (
	// DeliveryPending means evidence is retained and delivery has not succeeded.
	DeliveryPending Delivery = "pending"
	// DeliveryFailed means delivery failed and remains retryable.
	DeliveryFailed Delivery = "failed"
	// DeliverySent means the configured notifier accepted the report.
	DeliverySent Delivery = "sent"
)

type DeliveryFailure

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

DeliveryFailure is the typed error a notifier may return for retained classification.

func (DeliveryFailure) Error

func (failure DeliveryFailure) Error() string

Error returns a safe classified message without provider error content.

type Estimate

type Estimate struct {
	// Completed lists requirements with retained passing evidence.
	Completed []RequirementID `json:"completed"`
	// InProgress lists in-progress and not-started requirements.
	InProgress []RequirementID `json:"in_progress"`
	// Blocked lists requirements with a named blocker.
	Blocked []RequirementID `json:"blocked"`
	// Uncertainty lists bounded missing-proof conditions.
	Uncertainty []EvidenceReference `json:"uncertainty"`
}

Estimate is retained evidence context, deliberately separate from notifier transport.

type EvidenceKind

type EvidenceKind string

EvidenceKind classifies an entry within the notifier evidence_summary field.

const (
	// EvidenceCompleted identifies a completed requirement.
	EvidenceCompleted EvidenceKind = "completed"
	// EvidenceInProgress identifies an in-progress or not-started requirement.
	EvidenceInProgress EvidenceKind = "in_progress"
	// EvidenceBlocked identifies a blocked requirement.
	EvidenceBlocked EvidenceKind = "blocked"
	// EvidenceUncertainty identifies bounded uncertainty or a missing proof condition.
	EvidenceUncertainty EvidenceKind = "uncertainty"
)

type EvidenceRef

type EvidenceRef string

EvidenceRef identifies bounded, caller-safe status evidence.

type EvidenceReference

type EvidenceReference struct {
	// Kind describes how the reference contributes to status.
	Kind EvidenceKind `json:"kind"`
	// Reference is a bounded safe requirement or uncertainty reference.
	Reference EvidenceRef `json:"reference"`
}

EvidenceReference is a structured, bounded status entry; it never contains raw output.

type EvidenceStore

type EvidenceStore interface {
	// Retain stores a pending record before delivery.
	Retain(context.Context, Record) error
	// Lookup returns a previously retained record.
	Lookup(context.Context, MilestoneID) (Record, error)
	// MarkFailed records a classified retryable delivery failure.
	MarkFailed(context.Context, MilestoneID, FailureCode) (Record, error)
	// MarkSent records successful delivery.
	MarkSent(context.Context, MilestoneID) (Record, error)
}

EvidenceStore persists milestone evidence before a notifier attempt.

type FailureCode

type FailureCode string

FailureCode is a safe classified notifier failure, never provider error text.

const (
	// FailureUnavailable means the notifier was temporarily unavailable.
	FailureUnavailable FailureCode = "unavailable"
	// FailureRejected means the notifier rejected a validly shaped delivery request.
	FailureRejected FailureCode = "rejected"
	// FailureUnclassified means an adapter returned an untyped failure.
	FailureUnclassified FailureCode = "unclassified"
)

type FakeNotifier

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

FakeNotifier is a deterministic typed notifier adapter for S12 tests.

func NewFakeNotifier

func NewFakeNotifier(failures ...error) *FakeNotifier

NewFakeNotifier creates a FakeNotifier that consumes failures in order.

func (*FakeNotifier) Deliver

func (notifier *FakeNotifier) Deliver(ctx context.Context, notification Notification) error

Deliver records a notification and returns the next configured failure.

func (*FakeNotifier) Deliveries

func (notifier *FakeNotifier) Deliveries() []Notification

Deliveries returns attempted notifications in order.

func (*FakeNotifier) SetFailures

func (notifier *FakeNotifier) SetFailures(failures ...error)

SetFailures replaces the deterministic failure sequence.

type FileStore

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

FileStore persists one retained milestone record per opaque milestone identifier.

func NewFileStore

func NewFileStore(directory string) (*FileStore, error)

NewFileStore creates a private directory-backed EvidenceStore.

func (*FileStore) Lookup

func (store *FileStore) Lookup(ctx context.Context, milestone MilestoneID) (Record, error)

Lookup returns a previously retained record.

func (*FileStore) MarkFailed

func (store *FileStore) MarkFailed(ctx context.Context, milestone MilestoneID, code FailureCode) (Record, error)

MarkFailed retains the latest classified failed delivery result.

func (*FileStore) MarkSent

func (store *FileStore) MarkSent(ctx context.Context, milestone MilestoneID) (Record, error)

MarkSent retains the successful delivery result.

func (*FileStore) Retain

func (store *FileStore) Retain(ctx context.Context, record Record) error

Retain stores a pending record before delivery without overwriting prior evidence.

type HTTPClient

type HTTPClient interface {
	// Do submits an HTTP request and returns the provider response.
	Do(*http.Request) (*http.Response, error)
}

HTTPClient is the injected HTTP boundary used by NtfyNotifier.

type Ledger

type Ledger struct {
	// Version selects the ledger schema.
	Version int `json:"version"`
	// Requirements contains exactly one row per canonical requirement.
	Requirements []Requirement `json:"requirements"`
}

Ledger is a versioned evidence snapshot; it cannot supply weights itself.

func ParseLedger

func ParseLedger(input io.Reader) (Ledger, error)

ParseLedger decodes and validates a version-one evidence ledger.

type MemoryStore

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

MemoryStore is a deterministic in-memory EvidenceStore for focused tests.

func NewMemoryStore

func NewMemoryStore() *MemoryStore

NewMemoryStore creates an empty MemoryStore.

func (*MemoryStore) Events

func (store *MemoryStore) Events() []string

Events returns the retained transition ordering.

func (*MemoryStore) Lookup

func (store *MemoryStore) Lookup(ctx context.Context, key MilestoneID) (Record, error)

Lookup returns retained evidence unless the context is cancelled.

func (*MemoryStore) MarkFailed

func (store *MemoryStore) MarkFailed(ctx context.Context, key MilestoneID, code FailureCode) (Record, error)

MarkFailed records a safe failure unless the context is cancelled.

func (*MemoryStore) MarkSent

func (store *MemoryStore) MarkSent(ctx context.Context, key MilestoneID) (Record, error)

MarkSent records success unless the context is cancelled.

func (*MemoryStore) Retain

func (store *MemoryStore) Retain(ctx context.Context, record Record) error

Retain stores a pending record unless the context is cancelled.

type MilestoneID

type MilestoneID string

MilestoneID is a bounded operator-facing milestone name.

type Notification

type Notification struct {
	// Topic is the fixed operator-configured ntfy endpoint.
	Topic string `json:"-"`
	// Report is the exact structured request body.
	Report Report `json:"-"`
}

Notification binds a report to the configured allowlisted topic.

type Notifier

type Notifier interface {
	// Deliver submits one notification while honoring cancellation.
	Deliver(context.Context, Notification) error
}

Notifier submits only a typed, fixed-topic report.

type NtfyNotifier

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

NtfyNotifier posts exact status reports only to the configured ntfy topic.

func NewNtfyNotifier

func NewNtfyNotifier(client HTTPClient) (*NtfyNotifier, error)

NewNtfyNotifier creates a notifier with an explicit HTTP transport.

func (*NtfyNotifier) Deliver

func (notifier *NtfyNotifier) Deliver(ctx context.Context, notification Notification) (resultErr error)

Deliver posts the exact seven-field report to the fixed ntfy topic.

func (*NtfyNotifier) SetBearerToken

func (notifier *NtfyNotifier) SetBearerToken(token string)

SetBearerToken accepts authorization only from validated operator configuration.

type Proof

type Proof struct {
	// Revision identifies the immutable source state checked.
	Revision RevisionRef `json:"revision"`
	// UTCTime records when the check completed in UTC.
	UTCTime time.Time `json:"utc_time"`
	// Level identifies the proof scope.
	Level ProofLevel `json:"proof_level"`
	// CommandID identifies reviewed argv stored outside this record.
	CommandID CommandID `json:"command_id"`
	// ArtifactRef identifies the retained machine-readable result.
	ArtifactRef ArtifactRef `json:"artifact_ref"`
	// Result is completed only when its literal value is passed.
	Result string `json:"result"`
}

Proof is a bounded, secret-safe reference to one retained verification result.

type ProofLevel

type ProofLevel string

ProofLevel describes the scope of retained evidence.

const (
	// ProofUnit identifies deterministic unit or property evidence.
	ProofUnit ProofLevel = "unit"
	// ProofWorkflow identifies deterministic orchestration and replay evidence.
	ProofWorkflow ProofLevel = "workflow"
	// ProofContract identifies black-box interface or adapter conformance evidence.
	ProofContract ProofLevel = "contract"
	// ProofIntegration identifies a real dependency integration result.
	ProofIntegration ProofLevel = "integration"
	// ProofLocalTiltE2E identifies a complete local-stack public-path result.
	ProofLocalTiltE2E ProofLevel = "local_tilt_e2e"
	// ProofLinuxKVME2E identifies Linux/KVM security or Firecracker evidence.
	ProofLinuxKVME2E ProofLevel = "linux_kvm_e2e"
	// ProofManual identifies retained operator evidence that cannot be automated.
	ProofManual ProofLevel = "manual"
	// ProofDocumentation identifies published or generated documentation evidence.
	ProofDocumentation ProofLevel = "documentation"
	// ProofIndependentReview identifies an independent standards or spec review.
	ProofIndependentReview ProofLevel = "independent_review"
	// ProofRelease identifies immutable release or main-delivery evidence.
	ProofRelease ProofLevel = "release"
	// ProofMainCI identifies a required main-branch CI result for an immutable revision.
	ProofMainCI ProofLevel = "main_ci"
)

type Record

type Record struct {
	// Report is the exact notifier payload.
	Report Report `json:"report"`
	// Estimate retains richer local evidence context.
	Estimate Estimate `json:"estimate"`
	// Delivery is the current notifier delivery state.
	Delivery Delivery `json:"delivery"`
	// Attempts counts recorded notifier outcomes.
	Attempts int `json:"attempts"`
	// Failure is the last safe classified failure.
	Failure FailureCode `json:"failure,omitempty"`
}

Record retains a transport report, rich estimate, and secret-safe delivery state.

func BuildRecord

func BuildRecord(catalog Catalog, ledger Ledger, input ReportInput) (Record, error)

BuildRecord calculates an estimate only from a complete canonical catalog.

type Report

type Report struct {
	// Milestone identifies the reported milestone.
	Milestone MilestoneID `json:"milestone"`
	// EstimatedOverallPercent is the weighted green share of all requirements.
	EstimatedOverallPercent int `json:"estimated_overall_percent"`
	// EvidenceSummary carries structured completed, in-progress, blocked, and uncertainty entries.
	EvidenceSummary []EvidenceReference `json:"evidence_summary"`
	// NextMilestone identifies the next observable milestone.
	NextMilestone MilestoneID `json:"next_milestone"`
	// CommitOrRevision identifies the immutable source state.
	CommitOrRevision RevisionRef `json:"commit_or_revision"`
	// UTCTime is the injected report time normalized to UTC.
	UTCTime time.Time `json:"utc_time"`
	// Status summarizes the most severe evidence state.
	Status Status `json:"status"`
}

Report is the exact seven-field notifier transport schema from ADR-0007.

type ReportInput

type ReportInput struct {
	// Milestone identifies the current milestone.
	Milestone MilestoneID
	// NextMilestone identifies the next observable milestone.
	NextMilestone MilestoneID
	// Revision identifies the immutable source state when available.
	Revision RevisionRef
	// TerminalRequirementIDs names the bounded requirement rows that decide this milestone's status.
	TerminalRequirementIDs []RequirementID
	// Uncertainty names bounded missing proof or external conditions.
	Uncertainty []EvidenceReference
}

ReportInput supplies safe operator-facing context for a status report.

type Requirement

type Requirement struct {
	// ID is the permanent requirement identifier.
	ID RequirementID `json:"id"`
	// Status is the current evidence state.
	Status RequirementStatus `json:"status"`
	// Evidence contains retained proof references for completed status.
	Evidence []Proof `json:"evidence,omitempty"`
}

Requirement is one requirement evidence state from a ledger snapshot.

type RequirementID

type RequirementID string

RequirementID is a permanent binding requirement identifier.

type RequirementStatus

type RequirementStatus string

RequirementStatus classifies the evidence state of a binding requirement.

const (
	// RequirementCompleted means the requirement has retained passing evidence.
	RequirementCompleted RequirementStatus = "completed"
	// RequirementInProgress means implementation or evidence work has started.
	RequirementInProgress RequirementStatus = "in_progress"
	// RequirementBlocked means a named external condition prevents progress.
	RequirementBlocked RequirementStatus = "blocked"
	// RequirementNotStarted means implementation evidence does not yet exist.
	RequirementNotStarted RequirementStatus = "not_started"
)

type RevisionRef

type RevisionRef string

RevisionRef is a bounded immutable source revision reference.

type Service

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

Service coordinates retained evidence and notifier delivery at seam S12.

func NewService

func NewService(config runtimeconfig.NotifierConfig, source clock.Clock, store EvidenceStore, notifier Notifier) (*Service, error)

NewService creates a Service from explicit configuration and dependencies.

func (*Service) Publish

func (service *Service) Publish(ctx context.Context, catalog Catalog, ledger Ledger, input ReportInput) (Record, error)

Publish retains complete-catalog evidence before one notifier attempt.

func (*Service) Retry

func (service *Service) Retry(ctx context.Context, milestone MilestoneID) (record Record, resultErr error)

Retry retries delivery only for retained failed evidence.

type Status

type Status string

Status classifies an overall milestone report without overstating completion.

const (
	// StatusCompleted means every canonical requirement has green evidence.
	StatusCompleted Status = "completed"
	// StatusInProgress means unfinished work exists without an active blocker.
	StatusInProgress Status = "in_progress"
	// StatusBlocked means at least one canonical requirement is blocked.
	StatusBlocked Status = "blocked"
)

Jump to

Keyboard shortcuts

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