WS07 lockfile#173
Conversation
… diff, build, validate Implements WS07 (Adapter v2 / Distribution track) for the .criteria.lock.hcl format and helpers. New package workflow/lockfile/: - schema.go, types.go — HCL grammar and Go types for Lockfile, LockedAdapter, LockedSignature, LockedContainerImage, LockedRemote, Change/ChangeKind. - io.go — Read, Write, ReadFromDir. Write emits canonical HCL: adapters sorted by <type>.<name>, fixed field order, consistent nested-block order. - diff.go — Diff(old, next) producing sorted Change slices for Added, Removed, DigestChanged, SignerChanged, PlatformsChanged, ContainerImageChanged, RemoteChanged, OverrideChanged. - build.go — BuildEntry(*BuildInput) assembling LockedAdapter from pull results with defensive copying. - validate.go — ValidateAgainstWorkflow checking every workflow adapter has a lock entry and vice-versa, returning sorted missing/stale lists. Tests: - io_test.go — round-trip canonical write/read, byte-stability, fixture parsing for full/minimal/remote/container_image cases. - diff_test.go — table-driven coverage of all change kinds plus nil inputs and multi-change sorting. - build_test.go — full field flow, key/keyless signers, nil optional fields, missing-field errors, slice isolation. - validate_test.go — all-match, missing, stale, nil inputs, sorted output. Fixtures in testdata/: full.lock.hcl, minimal.lock.hcl, remote.lock.hcl, container_image.lock.hcl. Also adds github.com/opencontainers/go-digest to workflow/go.mod. All tests pass (make test), import boundaries clean (make lint-imports), and golangci-lint green across all modules (make lint-go). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Changes BuildEntry from the BuildInput struct pattern to the explicit
parameter signature required by the workstream:
BuildEntry(ref oci.Reference, dg digest.Digest, m *manifest.Manifest,
signer *signing.SignerIdentity, remote *RemoteFields)
The function now extracts SourceURL, SDKProtocolVersion, Platforms,
ContainerImage, and Signature directly from the manifest and signer
types rather than expecting pre-extracted fields.
Type and Name are intentionally left empty for the caller (WS08 CLI)
to populate, since they are workflow-scoped adapter instance identifiers
not present in the pull inputs.
Also adds testify to workflow/go.mod (used by lockfile tests).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
brokenbot
left a comment
There was a problem hiding this comment.
Automated PR Review: WS07 — .criteria.lock.hcl format and helpers
Verdict: APPROVE (blocked by GitHub self-review restriction)
What was verified
Compile & tests:
workflow/lockfile/compiles cleanly- All 34 tests pass: 6 build tests, 11 diff tests, 10 io tests, 7 validate tests
- Byte-stable canonical output confirmed by
TestWrite_ByteStability - Full
make testsuite passes across all three modules
Workstream step coverage:
- ✅ Step 1 (grammar):
schema.gowithLockfilestruct — matches spec - ✅ Step 2 (types):
types.gowithLockedAdapter+ all nested types,Change/ChangeKind,RemoteFields - ✅ Step 3 (IO + diff):
Read/Write/ReadFromDir+ canonical sorting by<type>.<name>;Diffcovering all 8 change kinds - ✅ Step 4 (build):
BuildEntryassembles from OCI ref + digest + manifest + signer + remote; nil/error handling correct - ✅ Step 5 (validate):
ValidateAgainstWorkflowdetects missing/stale adapters; nil-safe; sorted output - ✅ Step 6 (tests): io, diff, build, validate test files + 4 fixture lockfiles (minimal, full, remote, container_image)
Boundary checks:
make lint-importsclean- No edits to prohibited files
- HCL tags use named labels (
hcl:"type,label") vs spec's unnamed (hcl:",label") — functionally equivalent, defensible choice
Security: No shell construction, no path traversal, no secrets in output. ✅
Exit criteria: All met. Package compiles, tests pass, canonical formatting is byte-stable.
Blocking issue
GitHub does not permit self-approval; PR author and reviewer are both brokenbot. A different reviewer account is needed to merge.
brokenbot
left a comment
There was a problem hiding this comment.
Review: APPROVED (on merits)
All 31 tests pass; compile and vet clean. The lockfile package implements the full grammar, canonical HCL read/write with byte-stable output, field-level diff, BuildEntry construction helper, and ValidateAgainstWorkflow — exactly as specified in WS07.
Verified:
- Schema types match the HCL grammar from the workstream
- Write produces reproducible byte-identical output across runs (TestWrite_ByteStability)
- Diff covers all 8 ChangeKind variants with stable sort order
- BuildEntry correctly maps manifest/OCI/signing inputs to LockedAdapter; nil-optional and error paths tested
- ValidateAgainstWorkflow handles missing, stale, nil inputs, and sorted output
- Test fixtures cover full, minimal, remote, and container_image cases
- No cross-module import violations; no forbidden files touched
- No security concerns
Note: GitHub self-approval policy prevents a formal APPROVE review event; this is an accepted environmental constraint.
WS07 —
.criteria.lock.hclformat and helpersPhase: Adapter v2 · Track: Distribution · Owner: Workstream executor · Depends on: WS04, WS05, WS06. · Unblocks: WS08, WS09, WS20. · Base branch:
adapter-v2Context
README.mdD5, D7: per-workflow.criteria.lock.hclrecords, for each referenced adapter: full OCI ref, resolved digest, signer identity, SDK protocol version, source URL, and any remote-endpoint pin (from WS20). Committed to VCS. Updated bycriteria adapter pullandcriteria adapter lock. Compile auto-pulls based on lockfile.Prerequisites
In scope
Step 1 — Lockfile grammar
workflow/lockfile/schema.go:Step 2 — Go types
workflow/lockfile/types.go:The override fields are populated by the compiler (WS09) when a workflow's
adapter "X" "Y" { compatible_environments_override = [...] }is used to relax a manifest-declared constraint. The lockfile thus records every override;criteria adapter list --show-overridesand CI gates can flag them.(plus the nested types, all decoded via
gohcl.DecodeBody).Step 3 — Read / write / diff
workflow/lockfile/io.go:Writing is canonical: sorted by
<type>.<name>, blocks always in the same order, field order consistent. This minimizes diff noise. Usehclwrite.NewEmptyFile()andhclwrite.AppendNewBlock()builders so the output is reproducible byte-for-byte across runs.workflow/lockfile/diff.go:Used by
criteria adapter lockto print "this changed" rather than dumping a full file diff.Step 4 — Construction helpers
workflow/lockfile/build.go:RemoteFieldsis populated by WS20 when an adapter is bound to aremoteenvironment.Step 5 — Validation against workflow
workflow/lockfile/validate.go:Step 6 — Tests
io_test.go— round-trip canonical write/read; byte-identical for stable inputs.diff_test.go— table-driven over change kinds.build_test.go— every field flows from inputs to output.validate_test.go— missing/stale detection.Out of scope
criteria adapter lock/criteria adapter pullverbs — WS08.BuildEntry).Reuse pointers
hcl/v2andhclwritefor grammar + canonical output.digest.Digestfromimage-spec(already in WS04's deps).Behavior change
No. Adds a package; no caller yet.
Tests required
workflow/lockfile/*_test.gopass.make cigreen.Exit criteria
workflow/lockfile/package compiles and tests pass.Files this workstream may modify
workflow/lockfile/*.go(all new)workflow/lockfile/testdata/*.hcl(new fixtures)Files this workstream may NOT edit
workflow/schema.go,workflow/compile*.go— touched by WS09.internal/cli/— owned by WS08.internal/adapter/oci/,manifest/,signing/— owned by WS04/WS05/WS06.