bridge

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package bridge implements the migration-only current-state readiness adapter.

Index

Constants

View Source
const ApprovalPath = ".awf/current-state-migration.yaml"
View Source
const JournalVersion = 1

JournalVersion is the only accepted current-state upgrade journal schema.

Variables

This section is empty.

Functions

func CommitTransaction

func CommitTransaction(root string, ops []Operation, log io.Writer) error

CommitTransaction journals ops, makes the journal durable, applies every non-lock replacement, writes the lock last, marks the journal lock-committed, and deletes it. A failure before the lock is written rolls back to the prior images and clears the journal; a failure after leaves the attested lock plus a recoverable journal. It prints one deterministic operation line per applied path.

func CutoffFacts

func CutoffFacts(root string) (int, []int, error)

CutoffFacts returns the ADR-format-v1 cutoff (the highest ADR number plus one) and the sorted absent lower ADR numbers for the corpus under root. Migration normalization never changes an ADR number, so these facts are identical over the legacy HEAD and the prepared tree.

func Digest

func Digest(root string, mutations []Mutation) (string, error)

Digest computes the stable current-state attestation tree digest over the post-normalization prepared inputs. The universe is exactly the config file, every domain sidecar, every topic input, every ADR, every file matched by the prepared config's marker source globs, and the required migration approval file; no other path enters it. For each universe path the image is the planned mutation's after-image when a normalization mutation targets it, otherwise the current on-disk bytes and permission mode. Terminal output writes and legacy deletions never touch a universe path, so the merged mutation set yields the post-normalization image for every member. Digest is byte-for-byte read-only.

func JournalPath

func JournalPath(root string) string

JournalPath returns the fixed journal path under root.

func JournalPresent

func JournalPresent(root string) bool

JournalPresent reports whether a journal file exists under root.

func LockRel

func LockRel() string

LockRel is the repo-relative lock path every journal ends on.

func Recover

func Recover(root string, log io.Writer) error

Recover applies the journal recovery decision table. It is the only project mode permitted while a journal exists.

func ValidateLegacySnapshot

func ValidateLegacySnapshot(root string, preparedCorpus adr.Corpus, prepared Inventory, mappings []Mapping, mutations []Mutation) error

ValidateLegacySnapshot closes the migration-only legacy fact set against HEAD. Authored migration history may change disposition, but declarations, backing classes, carriers, markers, cutoff facts, and identities may not drift.

Types

type Adjudication

type Adjudication struct {
	Key, Disposition, Destination, Origin, Backing string
	Approved                                       bool
}

type Approval

type Approval struct {
	Key         string `json:"key"`
	Destination string `json:"destination"`
}

type Approvals

type Approvals struct {
	Present bool
	Entries []Approval
}

func LoadApprovals

func LoadApprovals(root string) (Approvals, error)

func ParseApprovals

func ParseApprovals(data []byte, present bool) (Approvals, error)

type Finding

type Finding struct {
	Code, Path, Detail string
}

type Image

type Image struct {
	Present bool   `json:"present"`
	Mode    uint32 `json:"mode"`
	Content []byte `json:"content"`
}

Image is one file's exact recorded state: present with an octal permission mode and content, or absent (present:false, mode 0, empty content).

type InvariantKey

type InvariantKey string

type Inventory

type Inventory struct{ Entries []LegacyInvariant }

func BuildInventory

func BuildInventory(corpus adr.Corpus) (Inventory, error)

type Journal

type Journal struct {
	Version         int         `json:"version"`
	Phase           string      `json:"phase"`
	FinalLockSHA256 string      `json:"finalLockSHA256"`
	Operations      []Operation `json:"operations"`
}

Journal is the durable transaction record. Version is always 1; Operations are unique, sorted, and end with the lock operation; FinalLockSHA256 is the SHA-256 of the sealed lock content the transaction commits.

func LoadJournal

func LoadJournal(root string) (Journal, error)

LoadJournal reads and validates the journal under root. A malformed or contract-violating journal is a hard error naming the Git-restoration escape, so no caller mutates the tree on a journal it cannot trust.

type LegacyInvariant

type LegacyInvariant struct {
	Key                  InvariantKey `json:"-"`
	Declarer, Slug       string
	DeclarerPath         string
	Backing              string
	Carrier, CarrierPath string
	CarrierDecisionItem  int
	Active               bool
	History              *MigrationHistoryEntry
}

type Mapping

type Mapping struct {
	Key, Destination, Origin, Backing string
	Approved                          bool
}

func ApplyApprovals

func ApplyApprovals(inventory Inventory, mappings []Mapping, approvals Approvals) ([]Mapping, error)

func DeriveMappings

func DeriveMappings(inventory Inventory, topics []topic.Topic) ([]Mapping, error)

type MigrationHistoryEntry

type MigrationHistoryEntry struct {
	Date, Key, Basis, Rationale string
	ADR                         string
}

func ParseMigrationHistory

func ParseMigrationHistory(data []byte, adrNumber string, effective map[string]Retirement) ([]MigrationHistoryEntry, error)

ParseMigrationHistory accepts one optional exact section outside Markdown fences.

type Mutation

type Mutation struct {
	Path          string `json:"path"`
	BeforePresent bool   `json:"beforePresent"`
	BeforeMode    uint32 `json:"beforeMode"`
	BeforeSHA256  string `json:"beforeSHA256"`
	AfterPresent  bool   `json:"afterPresent"`
	AfterMode     uint32 `json:"afterMode"`
	AfterSHA256   string `json:"afterSHA256"`
	Before, After []byte `json:"-"`
}

func PlanNormalization

func PlanNormalization(root string, cfg *config.Config, corpus adr.Corpus, inventory Inventory, mappings []Mapping) ([]Mutation, error)

type Operation

type Operation struct {
	Path        string `json:"path"`
	Prior       Image  `json:"prior"`
	Replacement Image  `json:"replacement"`
}

Operation records one path's prior and replacement images. The final journal operation is always the lock replacement.

func OperationsFromMutations

func OperationsFromMutations(root string, mutations []Mutation, lockPrior, lockFinal Image) ([]Operation, error)

OperationsFromMutations converts sorted mutations plus the sealed lock image into journal operations with the lock operation last. It reads each path's current image as the prior so recovery can restore it exactly.

type Report

type Report struct {
	Ready                  bool
	Findings               []Finding
	InvariantAdjudications []Adjudication
	PlannedMutations       []Mutation
}

func Check

func Check(root string) Report

type Retirement

type Retirement struct {
	Carrier, CarrierPath string
	DecisionItem         int
}

Jump to

Keyboard shortcuts

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