Apply And Publish Contract
Homeboy uses a shared execution vocabulary for generated changes:
executeproduces proposed results.artifactpreserves proposed changes with provenance and digest metadata.approverecords the exact artifact, run, step, or file scope allowed to change.applymaterializes approved changes in a local worktree.publishcommits, pushes, opens a pull request, releases, or deploys.
apply is a local mutation boundary. An apply adapter verifies an approved
ChangeArtifact, checks safety policy, and changes files in the target worktree.
It does not commit, push, open a PR, release, or deploy. Those operations belong
to the publish layer, represented by PublishRequest and PublishResult.
Core Types
The core contract lives in src/core/execution.rs:
ExecutionPhasenames the canonical phase vocabulary.ChangeArtifactstores proposed changes with provenance.ApprovalScoperecords what is approved.ApplyRequestandApplyResultdescribe local worktree mutation.ApplyAdapterContractadvertises supported artifact types and preflight policy.ApplyPreflightFailurereports shared safety failures.PublishRequestandPublishResultdescribe post-apply externalization.
Apply Adapter Boundary
An apply adapter owns:
- resolving the target local worktree;
- verifying the artifact payload and provenance;
- validating approval coverage;
- checking snapshot drift when the artifact carries snapshot metadata;
- enforcing path confinement;
- mutating files in the local worktree;
- reporting changed files and preflight failures.
Publish owns:
- staging or committing the applied change;
- pushing branches or tags;
- opening or updating pull requests;
- creating releases;
- deploying artifacts.
Shared Preflight Checks
Adapters should express failures with ApplyPreflightCheck values:
clean_worktreefor uncommitted or untracked local changes when the adapter requires a clean target.protected_branchfor direct apply attempts on protected branch names such asmain,master, ortrunk.approval_coveragewhen the approval scope does not cover every file or artifact being applied.snapshot_driftwhen the current worktree no longer matches the artifact’s captured source snapshot.path_confinementwhen an artifact path escapes the target worktree.staged_file_expectationwhen the final staged/changed file set does not match what the artifact declared.
Lab Artifact Projection
runner.workspace.apply already applies Lab patch and delta inputs locally. Its
current JSON input can project into the shared contract without changing behavior:
- unified patches use artifact type
lab.patch.unified_diff; - deltas use artifact type
lab.delta.files; source_snapshotmetadata drivessnapshot_driftchecks;- delta file paths drive
path_confinementchecks; RunnerWorkspaceApplyOutput.modified_filesmaps toApplyResult.files_changed.
This issue only defines the shared contract. Existing Lab CLI behavior can keep its current input and output shape while adapters migrate.
WP Codebox Migration Path
The existing homeboy/wp-codebox-apply-adapter/v1 extension adapter can migrate
to the core contract in two steps:
- Return or accept
ApplyAdapterContractwith artifact types such aswp_codebox.bundleandwp_codebox.file, plus anApplyPreflightPolicy. - Map its current verify/apply/stage/commit/push/PR flow so verify and file
mutation return
ApplyResult, while commit, push, and PR creation move toPublishRequest/PublishResultor compatibility CLI flags that call publish after apply.
During migration, compatibility flags may preserve existing behavior, but the canonical contract remains apply first and publish second.