migrate

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Overview

Package migrate converts a project from the legacy project-local content store (<project>/.gskill/store) to the user-level global store (spec 015 US5, FR-037/038). Migration is verified, deduplicating, and rollback-safe by construction: links switch only after every object is admitted and verified globally and every affected link is known re-pointable, and the local store is removed only after complete success.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LockedSkill

type LockedSkill struct {
	Name        string
	ContentHash string
	// Origin describes the entry's recorded source for global metadata.
	Origin globalstore.Origin
}

LockedSkill is one lock entry's migration-relevant facts, supplied by the caller (the app layer owns lockfile parsing).

type Plan

type Plan struct {
	Root          string
	LocalObjects  int
	AlreadyGlobal int
	ToCopy        int
	// SavingsBytes is the net disk the migration frees: the whole local
	// store goes away, minus the bytes newly copied into the global store.
	SavingsBytes int64
	// Corrupt lists local objects whose content no longer matches their key;
	// they are skipped (with their skills left on the local store) and
	// reported.
	Corrupt []string
}

Plan describes what a migration would do (dry-run output, FR-037).

func BuildPlan

func BuildPlan(root string, gs *globalstore.Store) (Plan, error)

BuildPlan inspects the project's local store against the global store without changing anything (FR-037 dry-run).

type Result

type Result struct {
	Plan
	// AdmittedObjects is how many local objects now exist globally (reused
	// or copied).
	AdmittedObjects int
	// Relinked lists the skills whose active links now point into the
	// global store.
	Relinked []string
	// LocalStoreRemoved reports whether the legacy store directory was
	// deleted (only after complete success).
	LocalStoreRemoved bool
	// BlockedLinks lists active-layer entries that still resolve into the
	// legacy store but are not re-pointed by this migration — typically
	// entries another tool manages. Their presence blocks link switching
	// and legacy-store removal (FR-038).
	BlockedLinks []string
}

Result reports an executed migration.

func Run

func Run(ctx context.Context, root string, gs *globalstore.Store, skills []LockedSkill) (Result, error)

Run executes the migration (research R11): verify each local object, dedupe-or-copy into the global store, verify, re-point the project-active links for the given lock entries, and remove the legacy store and cache only after complete success. Links are switched only when the whole migration is known to complete: a corrupt or unadmittable object, or an active link migration cannot re-point (an external tool's entry resolving into the legacy store), leaves every link and the local store untouched so the project stays fully usable (FR-038).

Jump to

Keyboard shortcuts

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