workbench

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CrosswalkArtifactContractName is the recommended filename for the
	// separately provisioned site trust anchor used with Crosswalk bundles.
	CrosswalkArtifactContractName = "crosswalk-workbench-contract.json"
	// CrosswalkArtifactContractVersion is the trust-anchor contract understood
	// by this release.
	CrosswalkArtifactContractVersion = 1
)
View Source
const (
	// CrosswalkArtifactManifestName is the fixed manifest name in a Crosswalk
	// Workbench artifact directory.
	CrosswalkArtifactManifestName = "crosswalk-artifacts.json"
	// CrosswalkArtifactManifestVersion is the manifest contract understood by
	// this release.
	CrosswalkArtifactManifestVersion = 1
	// CrosswalkStagedPOSIXPathMode identifies Crosswalk's normalized Workbench
	// context-host path policy.
	CrosswalkStagedPOSIXPathMode = "staged-posix"
	// CrosswalkSpecVersion is the transformation-specification contract used by
	// version 1 manifests.
	CrosswalkSpecVersion = "1"
)

Variables

This section is empty.

Functions

func DefaultMediaColumns

func DefaultMediaColumns() []string

DefaultMediaColumns returns the file-bearing columns produced by Crosswalk and the retired Fabricator workflow.

func NormalizeSiteURL

func NormalizeSiteURL(rawURL string) (string, error)

NormalizeSiteURL returns the canonical HTTP(S) origin and base path used to compare a Workbench host with a sitectl-resolved Drupal endpoint.

func ParseRollbackCSV

func ParseRollbackCSV(r io.Reader) ([]uint64, error)

ParseRollbackCSV validates an exact Workbench rollback artifact and returns its unique node IDs in artifact order.

func ValidateDeleteConfig

func ValidateDeleteConfig(r io.Reader) error

ValidateDeleteConfig verifies that a Workbench configuration is explicitly scoped to the destructive delete task.

func ValidateMediaRetryLog

func ValidateMediaRetryLog(r io.Reader, rows []RetryRow, siteURL string) error

ValidateMediaRetryLog requires one and only one Workbench success entry for every planned retry row, in addition to rejecting all ERROR entries.

func ValidateRollbackLog

func ValidateRollbackLog(r io.Reader, nodeIDs []uint64, siteURL string) error

ValidateRollbackLog requires one and only one Workbench node-deleted entry for every validated rollback node ID.

func ValidateTaskConfig

func ValidateTaskConfig(r io.Reader, expected string) error

ValidateTaskConfig verifies that a Workbench configuration is explicitly scoped to the expected task.

func WriteAddMediaCSV

func WriteAddMediaCSV(w io.Writer, rows []AddMediaRow) error

WriteAddMediaCSV writes deterministic Workbench add_media input.

func WriteMediaRetryCSV

func WriteMediaRetryCSV(w io.Writer, rows []RetryRow) error

WriteMediaRetryCSV writes deterministic Workbench add_media retry input.

Types

type AddMediaRow

type AddMediaRow struct {
	NodeID      string
	File        string
	MediaUseTID string
	Published   string
}

AddMediaRow is one idempotent Islandora Workbench add_media input row.

func ReconcileSupplementalMedia

func ReconcileSupplementalMedia(createCSV, rollbackCSV, existingAddMedia io.Reader, pending []SupplementalArtifact) ([]AddMediaRow, error)

ReconcileSupplementalMedia resolves create IDs to rollback node IDs and merges pending artifacts with existing Workbench add_media input.

type ArtifactContract

type ArtifactContract struct {
	Version            int             `json:"version"`
	Spec               ArtifactSpec    `json:"spec"`
	ProfileFingerprint string          `json:"profile_fingerprint,omitempty"`
	ModelFingerprint   string          `json:"model_fingerprint,omitempty"`
	Policy             *ArtifactPolicy `json:"policy,omitempty"`
}

ArtifactContract is trusted site configuration installed independently from an uploaded Crosswalk batch. It contains no per-batch filenames or digests.

func ParseArtifactContract

func ParseArtifactContract(r io.Reader) (ArtifactContract, error)

ParseArtifactContract decodes and validates a bounded, strict Crosswalk trust anchor. Unknown fields, duplicate names, and trailing values are rejected using the same JSON rules as artifact manifests.

func (ArtifactContract) Validate

func (c ArtifactContract) Validate() error

Validate verifies the static trust-anchor schema independently from any uploaded batch.

func (ArtifactContract) ValidateManifest

func (c ArtifactContract) ValidateManifest(manifest ArtifactManifest) error

ValidateManifest requires every trusted specification, profile/model, and policy value to match the uploaded batch manifest. Allowed absolute roots are a set, so their order is not significant. Absence is significant: an unprofiled or policy-free contract cannot trust a manifest that self-declares those values.

type ArtifactDescriptor

type ArtifactDescriptor struct {
	Path      string `json:"path"`
	MediaType string `json:"media_type"`
	SHA256    string `json:"sha256"`
	Bytes     int64  `json:"bytes"`
	CSVRows   int    `json:"csv_rows"`
}

ArtifactDescriptor records the exact bytes and CSV data-row count of one normalized relative file in a Crosswalk Workbench artifact directory.

type ArtifactManifest

type ArtifactManifest struct {
	Version            int                  `json:"version"`
	Spec               ArtifactSpec         `json:"spec"`
	ProfileFingerprint string               `json:"profile_fingerprint,omitempty"`
	ModelFingerprint   string               `json:"model_fingerprint,omitempty"`
	Policy             *ArtifactPolicy      `json:"policy,omitempty"`
	Artifacts          []ArtifactDescriptor `json:"artifacts"`
}

ArtifactManifest binds one complete Crosswalk Workbench output set to the exact specification, optional site profile, and policy that produced it.

func ParseArtifactManifest

func ParseArtifactManifest(r io.Reader) (ArtifactManifest, error)

ParseArtifactManifest decodes and validates one bounded, strict Crosswalk Workbench artifact manifest. Unknown fields, duplicate JSON names, and trailing JSON values are rejected so producer and consumer cannot silently disagree about policy.

func (ArtifactManifest) Artifact

func (m ArtifactManifest) Artifact(name string) (ArtifactDescriptor, bool)

Artifact returns the descriptor for one exact normalized manifest path.

func (ArtifactManifest) Validate

func (m ArtifactManifest) Validate() error

Validate verifies the static manifest contract independently from artifact transport. Artifact bytes are verified separately with ValidateArtifact.

func (ArtifactManifest) ValidateArtifact

func (m ArtifactManifest) ValidateArtifact(name string, data []byte) error

ValidateArtifact verifies exact byte length, SHA-256, valid CSV structure, and data-row count for one artifact listed in the manifest.

type ArtifactPolicy

type ArtifactPolicy struct {
	PathMode                           string    `json:"path_mode,omitempty"`
	StagingRoot                        string    `json:"staging_root,omitempty"`
	AllowedAbsoluteRoots               *[]string `json:"allowed_absolute_roots,omitempty"`
	SupplementalMediaUseTID            string    `json:"supplemental_media_use_tid,omitempty"`
	PendingSupplementalPublished       string    `json:"pending_supplemental_published,omitempty"`
	UnpublishedSupplementalMediaUseTID string    `json:"unpublished_supplemental_media_use_tid,omitempty"`
	UnpublishedSupplementalPublished   string    `json:"unpublished_supplemental_published,omitempty"`
}

ArtifactPolicy records operational values selected by the Crosswalk transformation. sitectl validates and consumes these values but does not invent institution-specific defaults.

type ArtifactSpec

type ArtifactSpec struct {
	Name        string `json:"name"`
	Version     string `json:"version"`
	Fingerprint string `json:"fingerprint"`
}

ArtifactSpec identifies the immutable Crosswalk transformation used to produce a Workbench artifact set.

type Config

type Config struct {
	Task string
	Host string
	// contains filtered or unexported fields
}

Config contains the Workbench settings sitectl must validate before delegating an Islandora mutation.

func GuardedConfigSnapshot

func GuardedConfigSnapshot(data []byte, expectedTask, logPath string) ([]byte, Config, error)

GuardedConfigSnapshot returns an execution-only copy of a validated config with both Workbench logging phases pinned to the caller-selected fresh log.

func ParseConfig

func ParseConfig(r io.Reader) (Config, error)

ParseConfig reads the task and host from one Workbench YAML document.

func ValidateGuardedExecutionConfig

func ValidateGuardedExecutionConfig(r io.Reader, expected string) (Config, error)

ValidateGuardedExecutionConfig validates a Workbench config for sitectl's exact-input execution profile and rejects hooks, acquisition, and row selection settings that could expand or alter the requested operation.

type MediaReference

type MediaReference struct {
	Row    int
	Column string
	Path   string
}

MediaReference identifies one file value in a Workbench input CSV.

func ParseMediaReferences

func ParseMediaReferences(r io.Reader, columns []string) ([]MediaReference, error)

ParseMediaReferences extracts non-HTTP file references from selected CSV columns. Pipe-separated Workbench values become individual references.

type PathInspection

type PathInspection struct {
	Reference    MediaReference
	ResolvedPath string
	Status       PathStatus
	Err          error
}

PathInspection is the result of checking one Workbench media reference.

func InspectMediaReferences

func InspectMediaReferences(references []MediaReference, stagingRoot string, allowedRoots []string, inspector PathInspector) ([]PathInspection, error)

InspectMediaReferences applies Workbench staging path normalization and classifies every reference without conflating missing and unreadable paths.

type PathInspector

type PathInspector interface {
	Lstat(name string) (fs.FileInfo, error)
	Readable(name string) error
}

PathInspector supplies context-host metadata and an effective-user readability probe without coupling path policy to local or SSH transport.

type PathStatus

type PathStatus string

PathStatus describes whether Workbench can acquire a referenced media file.

const (
	// PathAvailable means the path is a readable regular file.
	PathAvailable PathStatus = "available"
	// PathMissing means the path or one of its ancestors does not exist.
	PathMissing PathStatus = "missing"
	// PathUnreadable means permissions or an access error prevent acquisition.
	PathUnreadable PathStatus = "unreadable"
	// PathInvalid means the path is outside policy, traverses a symlink, or is
	// not a regular file.
	PathInvalid PathStatus = "invalid"
)

type RetryRow

type RetryRow = AddMediaRow

RetryRow is retained as the semantic name for a retry-planner result.

func PlanMediaRetry

func PlanMediaRetry(r io.Reader) ([]RetryRow, error)

PlanMediaRetry parses a Workbench log and returns retry rows only when every logged error belongs to an allowlisted media-upload timeout cascade.

type SupplementalArtifact

type SupplementalArtifact struct {
	Name               string
	Reader             io.Reader
	DefaultMediaUseTID string
	DefaultPublished   string
}

SupplementalArtifact describes a Crosswalk supplemental-media artifact and the defaults to apply only when its optional cells are empty.

Jump to

Keyboard shortcuts

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