4.1 KiB
Application Orchestration
Audience: developers and LLM coding agents changing internal/app.
Purpose
internal/app owns top-level application use cases: run, single-pipeline run, staged-source run, validate, inspect, manifest creation, and HTTP upload serving. It coordinates config loading, secret resolution, backend construction, source discovery, destination selection, publish planning/execution, notification handoff, output projection, and upload coordination.
Inputs And Outputs
Inputs include app option structs, contexts, config paths, pipeline ids, local source roots, dry-run/force flags, output format, stdout writers, HTTP requests, and optional notifier implementations.
Outputs include RunReport, validate/inspect/manifest results, CLI text/JSON projections, HTTP upload responses, upload status records, and errors. Destination-scoped failures can return a partial run report plus an aggregated error; fatal setup failures return before a complete report exists.
Boundaries
internal/app wires packages together but does not own manifest validation rules, destination state comparison, storage path rules, publish safety policy, transform rendering, config schema validation, or backend protocol behavior.
User-facing command parsing stays in internal/cli. User-facing config reference stays in docs/config.md. External contracts live under docs/integrations/.
Config Fields Used
The package consumes the loaded config.Config: server.http, secrets.directory, pipeline ids, source and destination backend fields, validation policy, publish policy, transform policy, path mapping, links, and transfer policy.
Config fields are validated and defaulted by internal/config before app workflows use them.
Adapters Used
The app backend factory registers runtime storage adapters for local filesystem, SSH/SFTP, and S3-compatible storage. It resolves explicit credentials through the config-owned environment resolver before opening S3 backends.
The app layer registers default transforms, including Markdown-to-HTML, and supplies a transform resolver to publish planning. It uses notify.Noop when no notifier is supplied.
State And Manifest Behavior
Run workflows discover and validate source bundles through internal/bundle. Destination state actions are prepared and written through internal/publish and internal/state; the app layer records report projections of those actions and results.
HTTP uploads stage and validate archives before enqueueing a pipeline run with a local staged source root.
Skip And Resume Behavior
Fan-out destinations are independent. A destination failure is recorded and does not prevent later destinations from being attempted. Dry-run builds plans and reports without destination writes, destination state writes, notifier calls, or SSH known-host persistence.
HTTP upload status is in memory. Accepted jobs move through accepted, queued, running, succeeded, or failed states and expire after configured retention.
Failure Behavior
Runtime setup fails for config load, config validation, secret loading, or credential resolution errors. Source setup failures stop the affected run before destination planning. Destination open, planning, execution, and notification failures are recorded as destination failures where a partial result exists.
HTTP upload startup fails if upload tokens are missing, empty, or duplicated. Upload requests can fail during authentication, content-type validation, queue admission, archive staging, source validation, or later publish execution.
Tests To Inspect
internal/app/*_test.gointernal/cli/root_test.gointernal/config/*_test.gointernal/ingest/*_test.gointernal/publish/*_test.go
Architectural Invariants
- App orchestration owns wiring, not low-level policy.
- Dry-run must not write outputs, destination state, notifier events, or SSH known-host entries.
- Fan-out destinations remain independent after a destination-scoped failure.
- Secret values are never printed; warnings may name variables only.
- Upload admission stages and validates a bundle before returning a run id.
- Runtime backend registration remains app-owned.