migrate

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package migrate ports a project's awf config across schema generations. It is the sole reader of the legacy single-file .claude/awf.yaml (ADR-0010 inv: legacy-read-isolation, the named exemption to ADR-0009 inv: config-root) and is imported by nothing on the render/sync/check load path. It reads the compile-time catalog (internal/catalog) for the ADR-0081 close-enabled-set migration - a leaf import that keeps this package off the render path.

Output convention: a migration that mutates the tree prints one line per performed operation to its out writer, prefixed with its registry Name (`<name>: <op>`), so an upgrade's config changes are readable from the command output rather than git archaeology; a no-op run prints nothing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthorityLockPath added in v0.22.0

func AuthorityLockPath(root string) string

AuthorityLockPath returns the lock belonging to the active config layout. It keeps all knowledge of retired layout paths inside the migration package.

func Current

func Current() int

Current is the current schema generation (the highest registered To).

func GateState

func GateState(root string) (string, int, error)

GateState classifies a project ("ok" | "gate" | "autobump" | "ahead") and returns the generation it classified, so callers need only one Generation call for both the state and their messages.

func GateStateForGeneration added in v0.22.0

func GateStateForGeneration(gen int) string

GateStateForGeneration classifies an already-loaded schema generation with the same migration-registry semantics as GateState. Snapshot-aware callers use it after loading a lock from their own universe instead of rereading the working tree.

func Generation

func Generation(root string) (int, error)

Generation reports the project's schema generation. Detection is by layout: a .awf/ tree reports its lock's SchemaVersion (or Current() when no lock yet - fresh init / just-upgraded); a pre-relocation .claude/awf/ tree reports its lock's schema, or 1 when no lock - such a tree is the tree-layout port's output (the port deletes the legacy lock), so every later migration up to and including the To:3 relocation must still apply; the legacy single file reports 0; nothing present reports Current(). A present-but-unreadable lock in either lock-bearing layout is a hard error, never a sentinel generation (ADR-0076 Decision 2, narrowing ADR-0016 Decision 6's presence keying).

func ProjectPresent added in v0.11.0

func ProjectPresent(root string) bool

ProjectPresent reports whether any awf config layout (current tree, pre-relocation tree, or legacy single file) exists under root - the distinction Generation cannot express, since "nothing present" reports Current() (ADR-0076 Decision 4).

func ProjectPresentFromFiles added in v0.22.0

func ProjectPresentFromFiles(has func(string) bool) bool

ProjectPresentFromFiles reports project presence through a repository-relative file lookup. Snapshot consumers use it so current and legacy layout knowledge remains owned by the migration package rather than being duplicated.

func Upgrade

func Upgrade(root string, out io.Writer) ([]string, error)

Upgrade applies every registered migration with To > Generation(root), in ascending To order, and returns the applied migration names. Idempotent: at the current generation it applies nothing and returns an empty slice, nil error. After applying any migration it restamps an existing tree lock to Current() so Generation reflects the new state and the terminal sync's schema gate passes (a tree→tree upgrade keeps its lock, unlike the legacy 0→1 port which drops it).

Types

type Migration

type Migration struct {
	To              int
	Name            string
	Apply           func(root string, out io.Writer) error
	OwnsSchemaStamp bool
}

A Migration ports a project from the generation below To up to To.

Jump to

Keyboard shortcuts

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