Files
releasekit/docs/roadmap/implementation.md

697 lines
45 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Next release implementation plan
## Purpose and execution
Implement the settled target in [the feature roadmap](next-release.md), including
explicit local/CI credentials, readiness validation, the actual Woodpecker
delivery rehearsal, and general source releases with calendar versions.
[ADR 0007](../adr/0007-general-source-release-identity.md) and
[ADR 0008](../adr/0008-woodpecker-rehearsal-lifecycle.md) record the architectural
decisions. The implementation baseline is v0.10.0; the subsequent commits contain
planning documents. The next release number remains unassigned.
Follow Stage 1 through Stage 15 in order. Each stage is a bounded implementation
unit for a Luna agent. Record completion and useful verification evidence in
this document. Follow the repository's normal commit discipline. Stages belong
to one sprint and may leave temporary compilation failures while interfaces
are being changed. Complete the integrated implementation before assessing
release readiness. These stages introduce no pilot releases, external actions,
or intermediate human-review gates.
Read [development guidance](../development.md) and the applicable policies.
Preserve the root orchestration facade, the lightweight `buildinfo` facade,
neutral forge contracts, and CLI ownership of credential loading. Public types
belong to the root facade; implementation types and external service clients
remain internal. Use existing Git, process, artifact, delivery, and Go-tool
boundaries. Package and private-helper names below describe responsibility;
ordinary internal naming can follow the implementation.
The decisions below finalize interface and encoding details left by the feature
roadmap. They preserve the selected product scope. Automatic version selection,
general non-Go builds, new YAML/JSON validators, secret registration, and CI
cancellation remain separate work. ReleaseKit's own release policy and ordinary
source-publication completion point continue to apply.
## Stage 1: Normalize source, Go, and publication selection
**Work:** refactor profile loading in `cmd/releasekit/internal/cli/config.go` and
introduce the shared internal selection model in `internal/releaseidentity`.
1. Adopt these profile fields:
| Field | Meaning |
| --- | --- |
| `source.dir` | Repository-relative physical source directory, default `.`. When Go is selected, this is the selected module directory and its resolved location determines source scope. |
| `source.tag_prefix` | Optional product prefix for general source tags. Omission derives it from the source directory; an explicit empty string selects unprefixed tags. |
| `go` | A non-null object selects Go module validation/build capabilities. Its initial shape is `{}`; suite options remain in `validation.go`. Omission or `null` in the explicit model selects no Go capability. |
| `publication.mode` | `source` or `go-module`. Default `source` in the explicit model. `go-module` requires Go capability. |
| `version.format` | `semver`, `date`, or `year-month`; default `semver`. |
| `version.prefix` | `"v"` or `""`; default `"v"` for SemVer and `""` for calendar formats. An explicit empty value is significant. |
2. Preserve the existing module shorthand: a profile containing no non-null
`source`, `go`, `publication`, or `version` object uses the current
`module_dir` selection, Go capability, Go module publication, and stable
prefixed SemVer. Null selection objects count as omitted; `source: {}`
explicitly selects a source-only root release.
The absence of a root `go.mod` does not silently change that interpretation.
In the explicit model, an omitted `source.dir` can take its directory from
`module_dir`. If both are supplied, they must name the same normalized
directory; conflicting directories produce an actionable selection error.
Consumers need maintain only one directory.
3. Normalize selection once per operation. Separate selection/configuration
checks from reading a working or committed module declaration. A source-only
selection requires a Git source directory but no `go.mod`. A Go selection
reads that directory's declaration and retains its physical location and
declared import path as distinct values.
4. Add a facade-owned `SourceSpec` with `Dir`, `GoEnabled`, `Publication`,
`VersionFormat`, optional `VersionPrefix`, and optional `TagPrefix`. Add an
optional `Source *SourceSpec` to `ReleaseRequest`, `BuildRequest`, and
`DeliveryRequest`. A nil pointer retains the existing `ModuleDir` shorthand;
a non-nil value selects the explicit model. An omitted `Dir` can take the
shorthand directory; matching directories are accepted and conflicting
selections fail. Use facade-owned string enums for publication modes and
version formats. The explicit zero spec means a root source release with
SemVer defaults and no Go capability.
5. Keep strict JSON decoding. Report obsolete flat credential fields specially
in Stage 6. Preserve operation-scoped delivery requirements: a source check
or publication does not need hosted credentials.
6. Update ADR 0007's status to reflect adoption of this plan and mark ADR 0005
partially superseded as described there. Update current references only as
the corresponding behavior lands.
**Coverage:** legacy root/nested module profiles; explicit source-only, Go
application, and Go module profiles; omission versus explicit values; consistent
and conflicting directory selections; no implicit module publication from
`go: {}`. Parser tests own configuration mapping and domain tests own selection.
## Stage 2: Resolve complete production and diagnostic identities
**Work:** refactor `internal/versioncontract` and `internal/releaseidentity`.
1. Validate caller-supplied production identifiers against these exact grammars
after removing the configured prefix, which must match exactly:
| Format | Grammar and validation |
| --- | --- |
| `semver` | `MAJOR.MINOR.PATCH`; ASCII decimal components, no leading zeroes except `0`, stable versions only. |
| `date` | `YYYY-MM-DD` or `YYYY-MM-DD.R`; four-digit year `0001`–`9999`, two-digit month/day, valid Gregorian date, positive revision without leading zeroes. The first spelling has no suffix; `.0` is invalid. |
| `year-month` | `YYYY.MM.R`; the same year range, two-digit month `01`–`12`, required nonnegative revision, no revision leading zeroes except `0`. |
Preserve numeric component strings without imposing machine-integer limits
on revisions. Accept dates independently of today's date. Do not increment,
sort, or canonicalize a caller's identifier into a different spelling.
2. Go module publication selects prefixed stable SemVer and existing import-path
major compatibility and tag rules. General source releases select their
grammar independently of an optional Go module's major version. A valid
selected Go declaration remains required for Go work.
3. General source tags are `<prefix>/<identifier>`, omitting the slash when the
prefix is empty. The default prefix is the normalized physical source
directory, with root represented by an empty prefix. Preserve a physical
`/vN` component. Go module publication retains the existing declared-major
directory rule. A source-product prefix override applies to `source` mode;
report an incompatible override in `go-module` mode rather than silently
publishing a non-module tag. Validate complete refs with Git's rules.
4. Production notes use `<source>/docs/releases/<identifier>.md` and retain the
existing exact product/version title matching. Existing file/path rules
remain in force. The selected grammars produce literal filename components.
5. Introduce one internal resolved identity containing kind, repository root,
source directory/subdirectory, optional Go module identity, publication mode,
version format/prefix, exact identifier, full tag, note path, and captured
commit when available. Preserve working-tree versus committed declaration
semantics. Pass this value through resolved operations instead of deriving
it again in each package.
6. Define diagnostic kind separately: attempt ID is 16 cryptographically random
bytes encoded as 32 lowercase hexadecimal characters; tag is
`releasekit-test/<selector>/<attempt-id>`; injected diagnostic version is
`releasekit-test-<attempt-id>`. The selector is one valid Git ref component.
Diagnostic construction retains source and optional Go selection but
supplies its own version and note. It consumes no production version and
makes no Go module publication claim. Production paths continue validating
their own selected grammars.
**Coverage:** date/leap-year boundaries, padding, revisions, prefixes, unchanged
SemVer behavior, nested and physical-major source tags, product overrides,
unsuffixed Go applications releasing `v2.0.0` or a date, and Go module major
compatibility. Test diagnostic construction through its supported domain seam.
## Stage 3: Generalize committed candidate and publication checks
**Work:** adapt `internal/candidate`, `internal/validation`, `internal/publish`,
the `Check`/`Publish` facade bridge, and configured child checks.
1. Capture the committed source identity once and carry it through validation,
callbacks, post-validation checks, exact annotated-tag creation, push, and
publication evidence. Preserve repository-wide branch, cleanliness,
authoritative `main`, exact candidate, unused tag, and uncertain-push guards.
2. Run the standard offline Go suite, selected vet, and package compilation
only when Go capability is selected. An explicitly enabled Go execution
check without that capability is a configuration error. A nonempty build
target selection also requires Go capability. Empty target selections do
no binary work.
3. Retain selected file checks and custom commands for both source kinds. Go
selections retain independent nested-module input boundaries. Source-only
selections inspect committed descendants of their selected source scope;
a `go.mod` encountered as data does not itself create a new release boundary.
Preserve shared-file omission/empty/explicit semantics, reference resolution,
and repository-wide forbidden-file scope. Text/file checks such as formatting
or declaration inspection remain usable when explicitly selected without
executing the Go toolchain.
4. Execute configured product commands from the source directory. Add
`RELEASEKIT_SOURCE_DIR` to their context. Populate existing Go module context
values for Go selections and provide empty module values for source-only
selections. Continue setting version, tag, candidate, and repository values
per child without changing the process environment.
5. Extend facade candidates and results with source and selection evidence;
retain existing version/tag/commit and module fields, populated from the
resolved identity. Empty module fields express source-only releases.
**Coverage:** a real temporary configuration repository without `go.mod` through
`Check` and `Publish`, scoped Markdown/shared/forbidden-file checks, custom check
working directory/environment, and unchanged exact-object publication/recovery
behavior. Reuse existing publication failure fixtures.
## Stage 4: Carry general identity through builds and hosted delivery
**Work:** adapt `internal/build`, `internal/artifact`, `internal/delivery`,
`internal/preparation`, and facade conversions.
1. Use the resolved identity for builds, runtime injection, filenames, tagged
checkout verification, page titles/bodies, manifests, and prebuilt binding.
Preserve `Build`'s working-tree semantics and delivery's committed source
semantics. Audit suffix splitting and numeric-triple assumptions.
2. Support Go application source releases whose product version differs from
the module import-path major. Retain static pure-Go builds, host-native
smoke checks, and the lightweight `buildinfo` dependency boundary.
3. Support page-only delivery with no Go declaration or compiler. Select its
committed source note and literal full tag through the same identity model.
Preserve automatic read-only preflight, local verification before hosted
writes, additive retries, immutable production contents, and outcome classes.
4. Make tagged preparation accept a valid full ref and expected commit without
assuming its final component is SemVer. After checkout and profile loading,
resolve the production identity and compare its complete tag. Diagnostic
dispatch performs Stage 9's manifest checks instead. Application dependency
preparation runs only for selected binary targets.
5. Add `--expected-source DIR` to publication/CI invocation mapping. Retain
`--expected-module DIR` for module-backed launchers; apply either comparison
to the normalized selected directory and report conflicting expectations.
Delay production-version validation until the profile's format is known.
**Coverage:** calendar-version build-and-run injection and asset names, page-only
source delivery, module-specific prebuilt rejection, full source-tag matching,
and existing cancellation, cleanup, partial-upload, and immutable-retry tests.
## Stage 5: Update identity evidence and publication recovery
**Work:** update facade evidence, CLI receipts, publication codecs, recovery
handoffs, and their integration references.
1. Write publication record format 3. Retain the current evidence envelope and
flat fields; add source directory/subdirectory, Go capability, publication
mode, version format/prefix, identity kind, and note path. Module fields may
be absent. Retain optional `evidence_bytes` overrides for exact non-UTF-8
string bytes using the existing codec's rules.
2. Continue reading formats 1 and 2 for existing publication recovery. Their
legacy evidence remains partial when fields were not captured. Recovery
observes the recorded endpoint/ref/object without applying current profile,
calendar, or module validation. Preserve redaction and typed decoding causes.
3. Write build receipt schema 2 with the full source/production-or-diagnostic
identity and existing compiler/target/artifact evidence. Read schema 2;
identify older receipts with a clear instruction to rebuild. Bind prebuilt
delivery to the captured commit, source selection, kind, identifier, and tag.
4. Existing recovery JSON schema 1 can gain additive source evidence fields;
keep its established state/diagnostic interpretation. New command schemas
defined below start at version 1. Bump a format when interpretation changes,
rather than rejecting harmless unknown additive fields in a supported
evidence version.
5. Preserve module-selected recovery entry points for Go consumers. Source-only
recovery uses the selected installed tool and committed pin from Stage 8,
with a durable handoff after the original launcher exits. Recording or
handoff warnings continue to leave source-publication status unchanged.
**Coverage:** new source and calendar evidence round trips, exact byte retention,
legacy partial-record reconciliation, stale receipts, and source-only recovery
after the launcher has exited. Use isolated synthetic module caches.
## Stage 6: Select local and CI credentials explicitly
**Work:** replace flat delivery credential configuration and share CLI loading.
1. Adopt `delivery.credentials.local.token_file` and
`delivery.credentials.ci.token_environment_variable`. The latter defaults to
`RELEASEKIT_DELIVERY_TOKEN` when the CI credential declaration is present but
its name is omitted. A local declaration requires a nonblank file path.
Require only the selected context's declaration when its operation runs.
2. Ordinary `deliver` uses local context; `ci-deliver` uses CI context.
`validate` selects context explicitly as specified in Stage 7. The rehearsal
coordinator uses local context and its job uses CI context. Ambient values
never switch contexts, override a local file, or provide fallback credentials.
3. Share one CLI resolver returning the token and safe source/context metadata.
Preserve root-relative/absolute paths and trimming. Missing, unreadable, or
blank selected files and unset/blank selected CI variables are errors.
Pass tokens explicitly to library requests and exclude them from diagnostics,
reports, records, and result markers.
4. Detect `delivery.token_file` and `delivery.token_env` with an actionable error
showing their new locations. Do not retain environment-over-file selection.
An explicitly named `RELEASEKIT_GITEA_TOKEN` remains valid in the new CI field.
5. Migrate the repository profile and maintained profiles/templates together.
Keep the existing stored-secret name usable, and comment the distinction
between a Woodpecker stored secret and its injected job variable. Document
ignore rules and the optional `forbidden_files` check together.
**Coverage:** conflicting workstation variables, unavailable local file with a
valid ambient token, CI delivery with no local file, context-specific errors,
legacy migration errors, retained CI variable names, and secret-safe diagnostics.
## Stage 7: Implement readiness validation and its CLI
**Work:** add internal readiness orchestration, a root `Validate` operation,
facade-owned request/report types, and `releasekit validate`.
1. Adopt this CLI shape; options precede positional arguments as elsewhere:
```text
releasekit validate [--repo DIR] [--config FILE] [--context local|ci]
[--operation NAME ...] [--offline] [--assets DIR] [--json]
```
There is no version argument. Context defaults to `local`. Operation names
are `publication`, `go`, `build`, `delivery`, and `rehearsal`. Repeated
`--operation` flags replace defaults with their deduplicated selection.
Defaults select publication, Go when enabled, build when targets exist, and
delivery when declared. Rehearsal is explicit. An explicitly selected
capability that the profile does not declare produces a configuration finding.
2. Inspect current working configuration and inputs. Report this source before
results. Check normalized source selection, relevant readable declarations,
build settings/main-package inputs, Go tool availability and declared minimum
when Go work is selected, destination settings, and selected credentials.
Generated build outputs need not exist. `--assets` explicitly selects an
existing receipt/artifact set for identity/size/digest verification and
requires delivery selection. Inspect its captured identity without requiring
a new version-matched note.
3. Support optional `readiness.required_files`, a list of literal root-relative
or absolute input files whose readability the operator deliberately selects,
for example a specifically required SSH key. This is diagnostic input, not
Git authentication configuration. Ordinary Git checks use native Git/SSH,
agents, hardware-backed keys, and custom commands. Do not infer mandatory
private-key files from conventional filenames or optional SSH identities.
4. Online is the default. For publication, resolve and compare any expected
push URL and perform a native read of authoritative `main` at that effective
endpoint. Local readiness also checks the Git identity needed for annotated
tag creation, including in offline mode. Report read-access evidence without
claiming write permission or requiring a final `main` candidate. Delivery uses
`PreflightDelivery`. Rehearsal includes publication/delivery prerequisites
and Stage 10's Woodpecker read access. Offline omits these requests explicitly;
context remains independent of network scope.
5. Validate declarations for the other credential context without reading its
unavailable runtime secrets. In local rehearsal readiness, report actual
job-secret injection as unchecked; the job/rehearsal supplies that evidence.
Delivery readiness alone has no Woodpecker credential requirement.
6. `ValidateRequest` carries resolved product selection, selected operations,
context and safe credential-source descriptions, explicit destination tokens,
Woodpecker observation settings when selected, offline selection, required
files, optional prebuilt inputs, and output.
File/environment token loading stays in the CLI. `Validate` runs neither
candidate checks nor custom product commands, builds, dependency downloads,
checkout changes, or remote writes. Report dependency-cache/build execution
evidence as unchecked rather than promising a future offline build.
7. `ValidationReport` identifies operations, context, working-input source,
destinations, credential-source descriptions, and ordered check results.
Each result has a stable check identifier, operation, status (`passed`,
`failed`, `skipped`, `unchecked`), reason category, safe message, and cause
where applicable. Aggregate independent failures; skip dependent checks when
prerequisites fail. Distinguish excluded/offline checks from selected checks
that could not complete. Return the partial report with typed errors.
8. `--json` emits one `schema_version: 1`, `command: "validate"` document after
valid arguments, including configuration failures. Human output shows scope
and evidence limits. Exit 0 means all selected checks completed successfully
within declared scope; 2 denotes usage/configuration/required-credential
errors; 1 denotes other failures, incomplete selected checks, cancellation,
or output failure. A declared offline omission alone is not failure.
**Coverage:** profile-driven defaults/narrowing, both contexts online/offline,
aggregated failures and skipped dependencies, malformed profiles, validation
before final notes or generated outputs, explicit prebuilt inputs, optional
SSH-agent authentication without a private-key file, and no remote writes.
## Stage 8: Supply one tool pin for source-only repositories
**Work:** add maintained source-only launcher/bootstrap examples and shared
installation guidance; extend recovery tooling where needed.
1. Adopt repository-root `.releasekit-version`: one stable ReleaseKit Go module
version such as `v0.10.0`, with surrounding whitespace/newline trimmed.
Reject empty or multiple values with an actionable error. This pins the
release tool, independently of the consumer's product-version grammar.
Maintained examples select a release implementing their demonstrated
interfaces; the version above illustrates only the pin's syntax.
2. Provide maintained local and Woodpecker installed-tool launchers that read
this file. Install `go.maximumdirect.net/releasekit/cmd/releasekit@VERSION`
into a private, version/host-specific directory under ignored `.releasekit`.
Use the selected Go toolchain's host target, `GOTOOLCHAIN=local`, and
`GOWORK=off`, preserving supported proxy/checksum/cache settings. Invoke the
resulting absolute executable and preserve its exit status. Installation
may use the network; candidate validation remains offline.
3. Keep this mechanical launcher maintained by ReleaseKit; consumers copy it
and change the pin, profile, and product facts. Use the committed pin from
the verified tag in CI, and keep Go module-backed bootstrap driven by tagged
module files. Source-only consumers require no placeholder module or tool
registration in a fabricated application module.
4. Add a complete small YAML/JSON source-only example, profile, release note,
ignore rules, pin, local launcher, and installed-tool delivery workflow.
The installation mechanism must support both production and diagnostic
invocation and source-publication recovery. A failed install must leave
no apparently usable partial executable; successful installed tools can be
reused. No automatic garbage collector is required.
**Coverage:** local and tagged CI selection from the same pin, changed pins,
host-target overrides, failed installation, retained executable/exit status,
and a source-only fixture with no module. Use a local synthetic module proxy
and a temporary `GOMODCACHE`; do not install from live services in the suite.
## Stage 9: Define rehearsal identity transport and durable attempts
**Work:** add internal rehearsal contracts/storage and diagnostic tag support.
1. Adopt `rehearsal.selector`, default `root`, and
`rehearsal.woodpecker.{base_url,repository_id,workflow,step,token_file}`.
Repository ID is Woodpecker's numeric ID; workflow and step are their exact
API names. Require these fields only for rehearsal operations. The local
Woodpecker credential file uses the same path/trim/error semantics as the
local forge credential but carries a separate token.
2. Start from `HEAD` by default; `--ref REF` selects another commit. Resolve a
full commit and read the selected profile from that commit. Normalize an
absolute in-checkout profile path to its repository-relative path. Rehearsal
profiles must be committed within the repository so CI can read the same
selection. Report an external/uncommitted profile with that concrete reason.
Resolve local secret-file paths against the checkout root. Branch, index,
and worktree may remain unchanged and need not be a final release candidate.
3. Create an annotated diagnostic tag using Stage 2's name. Its annotation is
`ReleaseKit rehearsal v1`, a newline, and one compact JSON manifest with
`schema_version`, `attempt_id`, `selector`, `commit`, `profile_path`,
`profile_sha256`, `source_dir` (repository-relative), `go_enabled`, optional
`module_path`, `publication_mode`, `version_format`, `version_prefix`,
`diagnostic_version`, and `tag`. Production format/mode fields describe the
captured profile; the diagnostic identifier uses its separate kind.
Bind the manifest to the actual annotated target and committed profile bytes.
Use optional `identity_bytes` overrides, keyed by string field name with
base64 values, for exact non-UTF-8 identity strings. Omit their lossy JSON
string forms, following the publication codec's convention. The manifest
contains no token or workstation file contents.
4. The selector in the ref permits dispatch before tool bootstrap. Single-product
templates recognize `root`; the maintained multi-product selector maps the
diagnostic selector to the existing selector row. After bootstrap, the CLI
verifies the annotation, tag spelling, event commit, profile digest, and
normalized selection together. A namespace match alone grants no deletion
authority and supplies no successful verification evidence.
5. Save an owner-private `format_version: 1` attempt record at
`<Git common directory>/releasekit/rehearsals/<attempt-id>.json`, with an
optional `--record-dir` override following existing private-store rules.
Reuse exact-byte encoding conventions for private paths/endpoints. Record
immutable identity, profile path/digest, effective Git endpoint/remote,
forge destination, Woodpecker settings, expected page title/body digest,
intended tag object, timestamps, observed resource IDs, and phase outcomes.
Store no resolved token. Retain the record after completion for operator
retention; do not auto-discover and choose a recovery attempt.
6. Persist all planned CI-created resources before the diagnostic tag push,
and persist intent before subsequent coordinator writes. Checkpoint local
observations and in-job results after effects. Unlike optional production
publication recording, failure to save the initial rehearsal record prevents
its first remote write: later cleanup depends on that record. Update records
with standard temporary-file/rename techniques and private permissions.
Preserve recoverable evidence on later
write/recording failure; do not claim application-level crash durability.
7. Update ADR 0008's status to reflect adoption and its explicitly temporary
resources. Diagnostic cleanup does not alter production release immutability.
**Coverage:** captured versus working profiles, exact commit/digest binding,
selector transport, malformed annotations, collisions, record round trips,
initial recording failure before writes, independent simultaneous attempt IDs,
and partial records after uncertain writes.
## Stage 10: Add Woodpecker observation and diagnostic forge effects
**Work:** implement an internal Woodpecker client and extend internal forge/Git
boundaries with the effects needed for recorded diagnostics.
1. Use a small `net/http` Woodpecker adapter with explicit token input and
request contexts. The documented API supplies repository reads, paginated
pipeline listing, exact pipeline detail with workflows/steps, and step-log
download. Use `GET /api/repos/{id}`, `/api/repos/{id}/pipelines`,
`/api/repos/{id}/pipelines/{number}`, and
`/api/repos/{id}/logs/{number}/{step}/download`.
See the [Woodpecker API reference](https://woodpecker-ci.org/api).
2. Normalize required response fields inside the adapter. Correlate tag events
using exact ref and commit, then retain exact pipeline/workflow/step IDs.
A listing filter is only a search aid, not identity evidence. Follow
pagination; handle unrelated runs, reruns, missing jobs, rejected access,
malformed responses, and unavailable observation without choosing “latest.”
3. Stream step logs for result parsing. Keep protocol status/error translation
and authentication inside the adapter. Reuse credential-redaction and
cross-origin credential-handling patterns already established by Gitea.
Local readiness verifies repository observation access with read-only calls;
it does not inspect or register CI secrets.
4. Add internal forge deletion of an explicitly identified diagnostic release
and its assets, plus exact resource observation for recovery. Keep handles
and Gitea HTTP details inside `internal/gitea`; orchestration depends on the
neutral contract. Persist stable resource IDs, not serialized opaque adapter
handles. Reuse existing page/asset reads and streamed comparison.
5. Add Git diagnostic tag create/push/observe/delete effects with explicit refs
and captured endpoint. Never force-create or move a diagnostic tag over a
conflicting object. Delete only when the recorded object/commit still
matches, using conditional deletion where the transport supports it. Reuse
ordinary ambiguous-write observation rather than equating a request error
with absence.
**Coverage:** paginated lists, exact correlation, terminal/active/unknown states,
log downloads, canceled requests, authentication errors, lost write/delete
acknowledgments, foreign resource conflicts, and backend dependency boundaries.
Use local HTTP servers and temporary Git remotes throughout.
## Stage 11: Run and verify the diagnostic delivery inside CI
**Work:** extend CI preparation and shared delivery with the diagnostic identity.
1. `ci-deliver` recognizes a verified diagnostic manifest after normal exact-tag
checkout preparation. It uses CI credential context, the captured profile,
and ordinary destination, target, toolchain, dependency preparation, build,
version injection, manifest, and upload mechanics. Supply a deterministic
temporary note and title identifying product, attempt, commit, and profile.
2. Keep diagnostic delivery in the shared resolved delivery path. Add internal
diagnostic verification before managed build output is removed; do not
create a second build/upload implementation or change public `Deliver`'s
normal ownership of temporary files.
3. Read back the exact hosted page and each declared binary/checksum manifest
inside the job while local expected bytes still exist. Compare the page's
tag/target/title/body and actual uploaded contents using the existing
streamed comparison machinery. Record each artifact's name, size, and
SHA-256. Page-only profiles report no generated artifacts and verify the page.
4. Emit a complete one-line result to job output, prefixed with
`RELEASEKIT_REHEARSAL_RESULT_V1 `. The remainder is JSON containing
`schema_version: 1`, attempt/tag/commit/selector/profile digest, source and
diagnostic identity, scope (`page` or `page-and-assets`), build/delivery/
verification outcomes, page ID, artifact evidence, and safe diagnostics.
Use the manifest's exact-string encoding for transported path identity.
Emit available failed-stage evidence too. Missing results after bootstrap
failure remain an explicitly incomplete verification outcome.
5. The coordinator obtains this result from the recorded delivery step's log
download after completion. Parse the framed line without assuming one HTTP
chunk equals a line or imposing a scanner's incidental small-line limit.
Accept equivalent retransmitted results once; conflicting matching results,
malformed results, or identity mismatches prevent successful verification.
Ignore ordinary log lines and never echo raw logs as credential diagnostics.
**Coverage:** real shared builds with injected diagnostic versions; exact
page-only and binary read-back; missing/tampered assets; job credential failure;
chunked logs, absent/foreign/conflicting results; and temporary output lifetime.
## Stage 12: Coordinate rehearsal start and CI observation
**Work:** implement `internal/rehearsal` coordination and the root facade.
1. Expose `Rehearse(ctx, RehearsalRequest) (RehearsalResult, error)`. The request
supplies repository/ref/profile selection, explicit forge and Woodpecker
credentials, normalized product/build selections from the committed profile,
record location, observation timeout, cleanup timeout, and progress output.
Bind supplied selection to the recorded profile digest through the CLI
adapter; the library accepts explicit selections and never loads ambient
tokens. Facade-owned results/errors preserve partial outcomes and causes.
2. Perform selected rehearsal readiness before the first write, using the same
checks with a committed-input reader for the captured revision. Ordinary
`validate` uses its working-input reader; rehearsal checks must not substitute
files from a different working `HEAD`. Capture the effective publication
endpoint and enforce its configured expectation. Check that the captured
profile declares CI delivery credentials; actual secret injection remains
job evidence. Check the committed profile and temporary tag availability, save
the attempt, then push only that diagnostic annotated tag. The coordinator
performs no local build or hosted-page creation in place of CI.
3. Observe exact tag/commit-correlated pipelines with bounded sequential polling
and cancelable waits. Record discovered IDs and links. The default observation
timeout in the CLI is 30 minutes; API zero or explicit CLI zero permits
observation until context cancellation. A positive override supports longer
jobs. Poll intervals are internal tuning details rather than public timing
guarantees.
4. Require the selected delivery workflow and step to finish successfully and
supply a matching successful content-verification result. Overall pipeline
success alone is insufficient. Report other workflow outcomes separately;
they do not substitute for the selected delivery workflow. Track every
matching run encountered so an active rerun is visible to cleanup.
5. Return separate workflow execution, artifact generation, hosted verification,
and cleanup outcomes, observed IDs/URLs, remaining resources, record path,
and actionable diagnostics. A timeout, missing pipeline/result, unavailable
observation, or cancellation does not certify absence or quiescence.
6. On interruption, stop local observation and preserve the independent job and
record. Do not cancel or restart CI. Trigger Stage 13 cleanup only when its
quiescence requirements can be established.
**Coverage:** no pipeline yet, delayed dispatch, incorrect commit, unrelated
pipelines, skipped/missing delivery workflow, build failure, successful pipeline
without evidence, successful page-only/binary evidence, reruns, timeout, and
cancellation. Use controlled clocks/waits at the external boundary where useful.
## Stage 13: Implement cleanup, resume, and uncertain-state recovery
**Work:** complete rehearsal lifecycle coordination and public recovery calls.
1. Expose `ResumeRehearsal` and `CleanupRehearsal`, each accepting an explicit
record path, current explicitly supplied credentials, timeout settings, and
output. Resume observes the existing attempt and then coordinates cleanup;
it does not push a new tag or rerun CI. Reuse recorded completed verification
evidence when resources have already been cleaned. Cleanup reports cleanup
independently of an earlier verification failure.
2. When a recorded attempt stopped before remote dispatch and that fact is
established, clean only its local resources. For a dispatched or uncertain
push, establish terminal completion of the matching pipeline and
relevant delivery jobs, including observed reruns. Recheck correlation and
active matching runs immediately before cleanup. Unknown CI state, an active
job, or no evidence that dispatch has completed leaves cleanup pending or
unknown. An observation timeout is not proof that no job will run.
3. Delete the recorded diagnostic page (including its assets), remote tag, and
matching local diagnostic tag, in that order after quiescence. Reobserve
resources before deletion and verify exact identity/ownership against the
record and diagnostic marker. If the create response was lost, locate the
page by the recorded tag and validate its target/title/body before adopting
its handle. Preserve conflicting or unidentifiable resources and report them.
4. Treat already-absent recorded resources as cleaned. After uncertain deletes,
query state and classify confirmed absence, known remaining state, or unknown
outcome. Retain tag/commit/page IDs and unresolved write evidence until
cleanup is confirmed. Do not use production deletion or immutability paths.
5. Use a fresh bounded cleanup context independent of a canceled observation
context, with a two-minute default and a positive configurable timeout. API
zero selects this default; the CLI cleanup timeout must be positive. A
cleanup run can remain pending when CI is still active; avoid indefinite
background goroutines. Persist observations and offer explicit continued
recovery. Serialize updates made through one operation/handle and ensure
simultaneous independent attempts retain separate records and resources.
6. Recovery credentials come from the committed profile selected by the record
in the CLI, resolved against its recorded checkout. Provide explicit file
overrides for credentials that have moved. Recovery targets the captured
destinations, not a changed working profile. The library takes tokens
explicitly. Report a missing checkout/profile as recoverable input failure;
the override path remains available for cleanup with saved evidence.
7. Explain the evidence boundary: cleanup describes recorded resources and
observed CI completion. Later operator-initiated reruns, persistent CI
history, notifications, and webhook effects are outside that result.
**Coverage:** interruption/resume, active/unknown CI deferring cleanup, lost
create/delete responses, partially created pages/assets, already-absent
resources, changed tag/page identity, failed recording, canceled observation
with bounded cleanup, and preservation of unrelated/production releases.
## Stage 14: Wire rehearsal CLI and maintained workflows
**Work:** finish CLI presentation and CI examples across root, nested Go, and
source-only products.
1. Adopt these commands:
```text
releasekit test [--repo DIR] [--config FILE] [--ref REF] [--record-dir DIR]
[--timeout DURATION] [--cleanup-timeout DURATION] [--json]
releasekit test-resume --record FILE [--timeout DURATION]
[--cleanup-timeout DURATION] [--json]
releasekit test-cleanup --record FILE [--cleanup-timeout DURATION] [--json]
```
Both recovery commands also accept `--token-file FILE` and
`--woodpecker-token-file FILE` overrides. They require an explicit record;
there is no production version argument or implicit newest-attempt selection.
2. JSON is one `schema_version: 1` document with command, safe attempt identity,
phase outcomes, resource/CI links, record path, remaining resources, and
diagnostics. Human output emphasizes the same separate outcomes and exact
resume/cleanup commands. After valid arguments, preserve structured output
on failures. Exit 0 means verification and cleanup succeeded for `test` and
`test-resume`, or cleanup alone succeeded for `test-cleanup`; 2 denotes
usage/configuration/required-input failure before effects; 1 denotes known
workflow/verification/cleanup failure or reporting failure; 3 denotes
unresolved remote/CI state or pending cleanup. Preserve observed outcomes
when mapping a later error to an exit status.
3. Update maintained tag filters to include the configured production format
and `refs/tags/releasekit-test/<selector>/*`. Keep exact event/tag commit
verification before tool selection. Route diagnostic refs by selector and
production refs by the existing product tag mapping. Then verify the
manifest/profile after bootstrap before diagnostic delivery.
4. Extend the maintained four-column selector map for source-only products:
selector, production tag pattern, tool-module directory, profile path.
Use `-` in the tool-module column to select installed-tool bootstrap from
`.releasekit-version`; retain `.` and physical module paths for existing Go
bootstrap. Go rows supply an expected module directory. Source-only rows
obtain source scope from the profile/verified manifest, never by treating
`-` as a source path. Apply an expected-source check when the launcher
actually supplies one.
5. Provide complete root-module, nested-module, self-bootstrapped ReleaseKit,
and source-only workflow examples using the same CI credential declaration,
image selection, shared delivery command, and diagnostic verification path
as their production counterpart. Keep secret injection and its explanatory
comment visible. `ci-deliver` itself selects CI context; any explicit
readiness invocation in a workflow supplies `--context ci`.
6. The coordinator observes the actual tag-triggered job. Workflows neither
replace it with a manual/local API exercise nor add rehearsal to normal
publication gates. Live commands remain explicitly invoked diagnostics.
**Coverage:** CLI argument/exit/JSON mapping, exact recovery record selection,
real maintained shell/YAML fixture execution, production/calendar/diagnostic
dispatch, wrong-selector/profile rejection, tagged tool pin/dependency
selection, and CI secret source selection.
## Stage 15: Complete documentation and integrated verification
1. Update canonical configuration, CLI, GoDoc, consumer adoption/check/build/
publication/delivery guides, integration schemas, internal inventory, and
maintainer runbook as their behavior lands. Add focused readiness/rehearsal
guidance and integration-format documentation where substantive content
warrants it. Link to maintained complete examples. Preserve the distinction
between routine publication, optional readiness, and live rehearsal.
2. Supply next-release migration guidance covering context-specific credential
fields, retained CI secret/variable names, legacy module defaults versus
explicit source/Go/publication choices, calendar grammars, source-only pin
setup, workflow/selector changes, receipt regeneration, and existing
publication-record recovery. Explain diagnostic deletion permissions and
persistent CI effects. Use a roadmap-owned draft if the release number is
still unassigned; place the final note in release history once assigned.
3. Run a representative offline assembled workflow for each of: legacy Go module
publication; Go application source release with a different product major;
calendar-version binary release; and a YAML/JSON-only repository. Across
these fixtures exercise candidate validation, publication, delivery,
readiness, rehearsal verification, cleanup, and saved recovery. Compose
local Git remotes, local forge/Woodpecker servers, and existing real build
helpers rather than duplicating algorithms in test mocks.
4. Update compiled API checks for the deliberate facade additions and preserve
their ownership/dependency protections. Run `go test ./...` and
`go run ./internal/apicheck`. Run the race detector on new rehearsal,
observation, cancellation paths, and affected packages where supported.
Keep the default suite deterministic, offline, and credential
independent. Use test-owned module caches for synthetic tool versions.
Broaden checks only where an unresolved risk or new failure warrants them.
5. Review all identity consumers and encoded formats for old unconditional
`go.mod`, stable-version, module-major, final-tag-component, and filename
assumptions. Review request/response body lifetime, polling cancellation,
credential redaction, destructive resource matching, and cleanup quiescence.
Verify local links and prose whitespace, inspect the complete diff, and
record the final implementation/verification status.
The sprint is complete when the four settled capabilities work through their
supported CLI and facade paths with documentation and offline regression
coverage. Running a live consumer rehearsal, choosing the next release number,
and tagging a release are subsequent operator decisions, not implementation
dependencies. No product-scope questions remain open in this plan.