Documentation
¶
Overview ¶
Package record persists Decision, Finding and Artifact records as one file per record under .devsys/{decisions,findings,artifacts}/<id>.yaml (方案 §14.3, 实施计划 M1.5). IDs are decision-<N> / finding-<N> / artifact-<N> with a per-kind sequence; Artifact versions are immutable files chained by previous_id (方案 §5.5).
Index ¶
- Variables
- type Kind
- type Store
- func (s *Store) AppendArtifactVersion(ctx context.Context, currentID string, expected []byte, ...) (string, error)
- func (s *Store) ArtifactHistory(ctx context.Context, id string) ([]*domain.Artifact, error)
- func (s *Store) CreateArtifact(ctx context.Context, a *domain.Artifact) (string, error)
- func (s *Store) CreateDecision(ctx context.Context, d *domain.Decision) (string, error)
- func (s *Store) CreateFinding(ctx context.Context, f *domain.Finding) (string, error)
- func (s *Store) GetArtifact(ctx context.Context, id string) (*domain.Artifact, error)
- func (s *Store) GetDecision(ctx context.Context, id string) (*domain.Decision, error)
- func (s *Store) GetFinding(ctx context.Context, id string) (*domain.Finding, error)
- func (s *Store) ListArtifacts(ctx context.Context) ([]*domain.Artifact, error)
- func (s *Store) ListDecisions(ctx context.Context) ([]*domain.Decision, error)
- func (s *Store) ListFindings(ctx context.Context) ([]*domain.Finding, error)
- func (s *Store) NewArtifactVersion(ctx context.Context, currentID string, next *domain.Artifact) (string, error)
- func (s *Store) ReadArtifact(ctx context.Context, id string) (*domain.Artifact, []byte, error)
- func (s *Store) ReadDecision(ctx context.Context, id string) (*domain.Decision, []byte, error)
- func (s *Store) ReadFinding(ctx context.Context, id string) (*domain.Finding, []byte, error)
- func (s *Store) UpdateDecision(ctx context.Context, d *domain.Decision, expected []byte) error
- func (s *Store) UpdateFinding(ctx context.Context, f *domain.Finding, expected []byte) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("record not found") ErrBadID = errors.New("invalid record id") ErrBadKind = errors.New("unknown record kind") ErrConflict = storage.ErrConflict )
Errors reported to callers.
var ErrSuperseded = errors.New("record: artifact already has a newer version")
ErrSuperseded reports that the artifact already has a newer version: the version chain is linear, so a second append from the same parent is refused instead of forking history. Re-read the head and append from it.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store binds record operations to a project root.
func New ¶
New binds the record layer to a project root (the directory containing .devsys, which must exist).
func (*Store) AppendArtifactVersion ¶
func (s *Store) AppendArtifactVersion(ctx context.Context, currentID string, expected []byte, mutate func(*domain.Artifact)) (string, error)
AppendArtifactVersion appends a new artifact version: the previous version is read inside the write transaction, the caller's expected bytes (from ReadArtifact) must still match, mutate may patch the copy, and the result is written as a new file (previous_id links back; the old file is never rewritten). It returns the new artifact's ID.
The append is refused with ErrSuperseded when a child of currentID already exists, so concurrent appends cannot fork the chain or duplicate version numbers.
func (*Store) ArtifactHistory ¶
ArtifactHistory walks the previous_id chain backwards from id and returns the versions newest-first; a broken link is reported, not skipped.
func (*Store) CreateArtifact ¶
CreateArtifact stores the first version of an artifact (version 1, no previous link) and returns its assigned ID.
func (*Store) CreateDecision ¶
CreateDecision stores a decision and returns its assigned ID.
func (*Store) CreateFinding ¶
CreateFinding stores a finding and returns its assigned ID.
func (*Store) GetArtifact ¶
GetArtifact decodes one artifact version.
func (*Store) GetDecision ¶
GetDecision decodes one decision.
func (*Store) GetFinding ¶
GetFinding decodes one finding.
func (*Store) ListArtifacts ¶
ListArtifacts returns every artifact version in ascending ID order.
func (*Store) ListDecisions ¶
ListDecisions returns every decision in ascending ID order.
func (*Store) ListFindings ¶
ListFindings returns every finding in ascending ID order.
func (*Store) NewArtifactVersion ¶
func (s *Store) NewArtifactVersion(ctx context.Context, currentID string, next *domain.Artifact) (string, error)
NewArtifactVersion appends a new version of an artifact: it reads the current file, copies every field into next, then writes next as a NEW file with version+1 and previous_id pointing at the current ID. Existing files are never modified, so history stays immutable and traversable.
func (*Store) ReadArtifact ¶
ReadArtifact reads one artifact with its raw bytes.
func (*Store) ReadDecision ¶
ReadDecision reads one decision with its raw bytes: the version hash the surfaces report and the guard an update consumes both derive from them.
func (*Store) ReadFinding ¶
ReadFinding reads one finding with its raw bytes.
func (*Store) UpdateDecision ¶
UpdateDecision rewrites a decision under the version guard (the caller's expected bytes come from ReadDecision).