Add a Galley setup executor preflight that prepares fresh worktrees before implementation, learns a successful environment.setup plan when missing or stale, persists it to environment.yaml, and routes setup evidence through later AFK…#71
Conversation
…earned-environment-setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
Add a Galley setup executor preflight that prepares fresh worktrees before implementation, learns a successful environment.setup plan when missing or stale, persists it to environment.yaml, and routes setup evidence through later AFK execution.
Acceptance Criteria
AC1environment.yaml shall support a first-class setup field that describes how Galley prepares a fresh task worktree before implementation begins.AC2When environment.setup is present, Galley shall run that setup plan before acceptance skeleton preflight and before the implementation executor.AC3When environment.setup is absent, Galley shall run a setup executor that receives the full environment.commands map, repository manifests, lockfiles, setup docs, and quality required checks as context, then attempts to make the worktree ready.AC4Galley shall provide both Claude and Codex setup executor prompt paths with the same setup-result contract, selecting the setup executor provider from the task executor backend.AC5The Claude setup executor prompt shall be authored from the existing Claude executor, Claude supervisor, and Claude/test-creator prompt patterns, and the Codex setup executor prompt shall be authored from the existing Codex executor, Codex supervisor, and Codex/test-creator prompt patterns; neither prompt shall be a mechanical diff or direct wording transplant from the other provider.AC6The setup executor shall first consider any existing environment.setup plan and environment.commands entries, but if those commands do not make the worktree ready, it may discover and return the command sequence that actually succeeds.AC7When setup succeeds with a new or changed setup plan, Galley shall update the repository environment.yaml setup field so subsequent tasks use the successful setup without rediscovery.AC8Setup success evidence shall be persisted and routed to the implementation executor, supervisor evidence, task verification history, and PR/task output when the setup plan was added or changed.AC9If setup cannot make the worktree ready, Galley shall fail the setup phase before spending implementation attempts, with structured evidence that identifies attempted commands, command source, inspected files, stdout/stderr excerpts, and next repair guidance.AC10Setup readiness checks shall exclude acceptance skeleton obligations, so setup does not fail merely because task-specific skeleton tests have not been implemented yet.AC11Galley troubleshooting guidance shall cover setup_failed runs and explain how to use setup_result.json and environment_update.json to repair environment.setup when the learned setup later fails.Final Verification
go test ./internal/daemon -count=1: passedgo run ./cmd/galley profile validate --kind environment examples/environment-local.yaml: passedgo vet ./...: passedgofmt -l .: passedgo build ./...: passedtest -z "$(find . -name '*.go' -not -path './.git/*' -print | xargs gofmt -l)": passedgo test ./...: passedgo build -o /tmp/galley ./cmd/galley: passedgo run ./cmd/galley schema check: passedgo run ./cmd/galley task validate examples/afk-task.yaml: passedgo run ./cmd/galley profile validate --kind quality examples/quality-default.yaml: passedpython3 -m json.tool schemas/claude-result.schema.json >/dev/null: passed./scripts/smoke-local.sh: passedKey Decisions
claude-decision-1How to make TestSetupPreflightSequencesBeforeSkeletonAndExecutor actually exercise the setup preflight, given that SetupExecutorPreflight short-circuits when Profiles.Environment is nil? -> Write a real authored environment profile (with setup.commands: touch setup.sentinel) and pass it via Options.EnvironmentProfileFile so the daemon resolves a Profiles.Environment and runs the authored plan, which creates the sentinel and yields the 'environment.yaml=unchanged' excerpt the test asserts. The previous runner override is reshaped into a t.Fatalf trap so any drift back to discovery fails loudly.claude-decision-2How to reconcile TestSetupPreflightAtomicProfileRewriteAndSecondRunReuse's strings.Contains(body, 'base: main') assertion with the YAML node-style round-trip? -> Change the test input from quoted base: "main" to unquoted base: main so the assertion tests the contract the assertion was written for: that the YAML node style of unrelated scalars is preserved across the atomic rewrite.Discussion Items
discussion-1Scope expansion: Accepted diff includes changes outside task.scope.allowed_paths: internal/supervisor/adapter.go, internal/supervisor/supervisor.go. Review whether this scope expansion belongs in this PR.Risks
R1contract: environment.setup is a new environment profile contract and must stay synchronized across Go structs, validation, generated schemas, examples, docs, and bundled skill references.R2runtime: Setup executor runs before implementation and can update repository environment profiles, so evidence ownership, update ordering, and failure classification must be explicit.R3maintainability: Claude and Codex setup prompts must be independently shaped from their provider-specific prompt families rather than copying one provider's wording into the other.