Documentation
¶
Overview ¶
Package draft plans and safely publishes portable working-draft helpers.
Planning is read-only and captures every filesystem input used by a plan. Publication rechecks those exact captures, writes through temporary regular files, and rolls back already-published files if a later write fails. The package deliberately does not stage files, move accepted refs, or know how a managed Git worktree rendezvous is implemented; callers can provide that rendezvous through the Locker interface.
Index ¶
- Variables
- func PlanFmt(ctx context.Context, root string, options FmtOptions) (*Plan, FmtResult, error)
- func PlanFormat(ctx context.Context, root string, options FmtOptions) (*Plan, FmtResult, error)
- func PlanMove(ctx context.Context, root, from, to string, options MoveOptions) (*Plan, MoveResult, error)
- func PlanNew(ctx context.Context, root, typeName, logicalPath string, options NewOptions) (*Plan, NewResult, error)
- func PlanSchemaCopy(ctx context.Context, root, typeName string, options SchemaCopyOptions) (*Plan, SchemaCopyResult, error)
- type Error
- type ErrorKind
- type FileChange
- type FmtOptions
- type FmtResult
- type Locker
- type LockerFunc
- type MoveOptions
- type MoveResult
- type Mutation
- type NewOptions
- type NewResult
- type Phase
- type Plan
- type SchemaCopyOptions
- type SchemaCopyResult
- type Unlock
Constants ¶
This section is empty.
Variables ¶
var ( // ErrConcurrent is wrapped when an input captured by a plan changed before // publication or a cooperating writer already owns the rendezvous. ErrConcurrent = errors.New("draft input changed concurrently") // ErrRecoveryRequired is wrapped when rollback could not prove and restore // every already-published preimage. Callers must not report success. ErrRecoveryRequired = errors.New("draft recovery required") )
Functions ¶
func PlanFormat ¶
PlanFormat is a readable alias for PlanFmt for library callers.
func PlanMove ¶
func PlanMove(ctx context.Context, root, from, to string, options MoveOptions) (*Plan, MoveResult, error)
PlanMove computes one literal record move, all required link rewrites, and affected catalog regeneration without publishing any bytes.
func PlanNew ¶
func PlanNew(ctx context.Context, root, typeName, logicalPath string, options NewOptions) (*Plan, NewResult, error)
PlanNew generates and validates a deterministic record plus its containing catalog update without publishing either file.
func PlanSchemaCopy ¶
func PlanSchemaCopy(ctx context.Context, root, typeName string, options SchemaCopyOptions) (*Plan, SchemaCopyResult, error)
PlanSchemaCopy copies one exact embedded inventory entry into a new local schema path. It never creates a content directory; when needed it creates only the final scope-local .engram/schemas configuration chain.
Types ¶
type ErrorKind ¶
type ErrorKind string
ErrorKind is a stable, protocol-ready failure class.
const ( ErrorUsage ErrorKind = "usage" ErrorCancelled ErrorKind = "cancelled" ErrorInternal ErrorKind = "internal" ErrorCapability ErrorKind = "capability" ErrorConflict ErrorKind = "conflict" ErrorConcurrency ErrorKind = "concurrency" ErrorRepository ErrorKind = "repository" ErrorIO ErrorKind = "io" )
type FileChange ¶
FileChange is an immutable copy of one planned logical file update. Before is nil when the path must be absent. After is nil for a deletion. Create and Delete are mutually exclusive.
type FmtOptions ¶
FmtOptions controls literal README selection and read-only modes. With no Paths, every logical content-directory README is selected.
type FmtResult ¶
type FmtResult struct {
DryRun bool `json:"dry_run"`
Check bool `json:"check"`
Changed bool `json:"changed"`
Paths []string `json:"paths"`
}
type Locker ¶
Locker coordinates publication with other managed worktree writers. The portable draft package performs exact compare-and-swap-style rechecks even when no Locker is supplied, but a managed CLI should always supply its annex-defined worktree rendezvous.
type LockerFunc ¶
LockerFunc adapts a function to Locker.
type MoveOptions ¶
MoveOptions controls publication of one literal record move.
type MoveResult ¶
type MoveResult struct {
DryRun bool `json:"dry_run"`
Changed bool `json:"changed"`
From string `json:"from"`
To string `json:"to"`
Paths []string `json:"paths"`
Catalogs []string `json:"catalogs"`
}
MoveResult is the stable result shape of mv. Paths contains final logical paths of documents whose non-catalog link bytes changed; Catalogs contains README paths whose generated regions changed.
func Move ¶
func Move(ctx context.Context, root, from, to string, options MoveOptions) (MoveResult, error)
Move plans and, unless DryRun is set, publishes one complete record move.
type Mutation ¶
Mutation is the closed local effect set known after a draft publication error. Draft helpers never update refs, HEAD, or remotes.
func MutationOf ¶
MutationOf merges effect evidence across joined or wrapped draft errors. RecoveryRequired is the final snapshot: an outer mutation overrides its causes and the last evidence-bearing joined error overrides earlier ones.
type NewOptions ¶
type NewOptions struct {
Description string
Fields []byte
Body []byte
BodyProvided bool
Title string
TitleProvided bool
DryRun bool
Rendezvous Locker
}
NewOptions contains already-read option inputs. BodyProvided distinguishes an explicit body from generated-body mode; a non-nil Body also counts as provided. Fields is nil when --fields was absent.
type NewResult ¶
type Plan ¶
type Plan struct {
// contains filtered or unexported fields
}
Plan is a one-shot, immutable publication plan. Its exported methods return copies so callers cannot invalidate captured preimages or final bytes.
func (*Plan) Changes ¶
func (p *Plan) Changes() []FileChange
Changes returns planned file updates in publication order.
func (*Plan) Publish ¶
Publish applies a plan without an external rendezvous. Managed callers should normally call PublishWith with their worktree Locker.
func (*Plan) PublishWith ¶
PublishWith acquires locker, rechecks every exact captured input, publishes through synced temporary regular files, and rolls back on any later error.
type SchemaCopyOptions ¶
SchemaCopyOptions selects an existing logical content-directory scope. The empty Scope denotes the store root, matching the CLI default.
type SchemaCopyResult ¶
type SchemaCopyResult struct {
DryRun bool `json:"dry_run"`
Changed bool `json:"changed"`
Schema checker.SchemaDescription `json:"schema"`
Path string `json:"path"`
}
func SchemaCopy ¶
func SchemaCopy(ctx context.Context, root, typeName string, options SchemaCopyOptions) (SchemaCopyResult, error)
SchemaCopy plans and, unless DryRun is set, publishes one inventory schema.