promotion

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package promotion prepares content-only publication artifacts. It deliberately has no network client or apply endpoint: host authority, bundle fencing and restart-safe activation are separate mandatory publication gates.

Index

Constants

View Source
const SchemaVersion = 1

Variables

View Source
var ErrBundle = errors.New("content bundle invalid or unsupported reference")
View Source
var ErrInvalid = errors.New("content snapshot invalid")
View Source
var ErrMapping = errors.New("content mapping invalid or ambiguous")

Functions

func VerifyBundle

func VerifyBundle(root string, manifest BundleManifest, pages []store.PageContent) error

VerifyBundle re-hashes the supplied directory, validates local references and rejects exact static route shadowing. Uploaded tenant media and admin paths remain unsupported; copying their URLs would leak review tenant identity.

Types

type BundleFile

type BundleFile struct {
	Path   string `json:"path"`
	SHA256 string `json:"sha256"`
	Size   int64  `json:"size"`
}

type BundleManifest

type BundleManifest struct {
	Files  []BundleFile `json:"files"`
	Digest string       `json:"digest"`
}

func InventoryBundle

func InventoryBundle(root string) (BundleManifest, error)

InventoryBundle hashes exact regular files only. Call with an immutable version directory, not a current symlink. No file content is logged.

func (BundleManifest) Validate

func (m BundleManifest) Validate() error

type DeleteSelection

type DeleteSelection struct {
	Key      string `json:"key"`
	TargetID int64  `json:"target_id"`
}

type Diff

type Diff struct {
	Key          string `json:"key"`
	TargetID     int64  `json:"target_id"`
	Action       string `json:"action"`
	OldPath      string `json:"old_path,omitempty"`
	NewPath      string `json:"new_path,omitempty"`
	BeforeDigest string `json:"before_digest,omitempty"`
	AfterDigest  string `json:"after_digest,omitempty"`
}

type Mapping

type Mapping struct {
	Key       string `json:"key"`
	TargetID  int64  `json:"target_id"` // zero explicitly creates a new page
	AllowMove bool   `json:"allow_move"`
}

func SuggestedMapping

func SuggestedMapping(s Snapshot, current store.PageSet) ([]Mapping, error)

type Plan

type Plan struct {
	Digest               string          `json:"digest"`
	SnapshotDigest       string          `json:"snapshot_digest"`
	BundleDigest         string          `json:"bundle_digest"`
	BundleBaselineDigest string          `json:"bundle_baseline_digest"`
	Batch                store.PageBatch `json:"batch"`
	Diffs                []Diff          `json:"diffs"`
}

func DryRun

func DryRun(s Snapshot, current store.PageSet, mappings []Mapping, deletes []DeleteSelection, targetBundle BundleManifest) (Plan, error)

DryRun requires an explicit mapping for every selected page. SuggestedMapping offers reviewable path matches, but never silently approves a rename/deletion. The caller must separately verify both on-disk bundles before publication.

func (Plan) ContentDigest

func (p Plan) ContentDigest() string

type Snapshot

type Snapshot struct {
	Schema     int            `json:"schema"`
	SourceSite string         `json:"source_site"`
	CreatedAt  time.Time      `json:"created_at"`
	Pages      []SnapshotPage `json:"pages"`
	Bundle     BundleManifest `json:"bundle"`
	Digest     string         `json:"digest"`
}

func Decode

func Decode(r io.Reader) (Snapshot, error)

Decode rejects unknown fields, duplicate JSON keys, trailing documents and oversize input. Errors are fixed; rejected keys/values are never returned.

func Export

func Export(ctx context.Context, pages store.PageStore, sourceTenantID int64, sourceSite string, ids []int64, bundleRoot string, now time.Time) (Snapshot, error)

Export freezes selected rows. It reads the supplied authorized tenant scope; it never consults a domain, credential, tenant setting or editor membership.

func (Snapshot) ContentDigest

func (s Snapshot) ContentDigest() string

func (Snapshot) Validate

func (s Snapshot) Validate() error

type SnapshotPage

type SnapshotPage struct {
	Key           string            `json:"key"`
	SourceID      int64             `json:"source_id"`
	SourceVersion int               `json:"source_version"`
	Content       store.PageContent `json:"content"`
}

Jump to

Keyboard shortcuts

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