Repository navigation
fix(review): run adopter setup on the base tree, not the PR's - #806
Conversation
`tend-review` checked out the fork's tree and then ran the adopter's `setup:` steps against it. Those steps execute as the runner user, which holds sudo and, until the harness's sandbox setup strips it, the checkout PAT in `.git/config` — so a contributor's build backend, added dependencies, or local `uses: ./` action ran with that access, ahead of the containment the harness exists to build. Review now checks out the base tree, runs `setup:`, then lands the PR's tree with `clean: false` so setup's workspace output survives. That is the ordering every other generated workflow already had; review was the exception. `sandbox_setup:` is the lever for project setup that must see the PR's own manifests. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
tend-agent
left a comment
There was a problem hiding this comment.
The ordering change and clean: false reasoning both check out — traced the second checkout against actions/checkout v7: with clean false it reuses the existing repo, --force-reconciles tracked files to the merge tree, and leaves setup's untracked output in place. Tests and regtests are consistent (284 pass).
One design observation, non-blocking: for adopters with an empty setup:, the review job now runs two full actions/checkout@v7 steps (fetch-depth: 0) with nothing between them — visible in the regenerated test_workflow_minimal_regtest[review] output. The base checkout exists only to give setup: a reviewed tree; with no setup it's a full-history clone of the base branch that the second checkout immediately supersedes, so it's pure overhead on every review run for that subset. The other generated workflows have this too, but they run a single checkout — review is the one place the base checkout is genuinely redundant when there's no setup.
Guarding the base checkout + <<setup>> behind {% if setup %} in review.yaml.j2 would keep the security ordering when setup is present and drop the wasted clone when it isn't (the second clean: false checkout clones fine into an empty workspace — clean only affects the existing-repo path). The tradeoff is template uniformity vs. avoiding the redundant fetch. Happy to push that if you'd prefer it; otherwise this is fine as-is.
The base checkout exists to give `setup:` a reviewed tree. With no setup it was a full-history clone of the base branch that the PR checkout immediately superseded, on every review run. `clean` goes with it: the action consults that input only when it finds an existing repo, which a lone checkout never does. Adopters without `setup:` now generate byte-identical output to before the reordering. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Took the suggestion — pushed in a9aefae. The base checkout is The result is stronger than avoiding the extra fetch — all three no-setup regtest snapshots ( Added
|
Bumps the generator to 0.1.13, syncs the lockfile, and adds the CHANGELOG section the release workflow publishes verbatim as the GitHub Release notes. 13 commits since 0.1.12. The release's substance is the security work: the operational secrets move into a gated `tend` deployment environment, with a secretless review-event relay in `tend-mention` and two new `tend check` checks ([#810](#810)), and `tend check` now verifies the bot cannot bypass the merge restriction ([#795](#795)). Alongside those: the `claude-interactive` harness is removed ([#804](#804)), `tend-review` runs the adopter's `setup:` on the base tree rather than the PR's ([#806](#806)), tend's uv is pinned and isolated from the adopter's ([#807](#807)), and the proxy readiness check waits for the port instead of trusting the CA file ([#811](#811)). Adopters have manual work after this ships: the environment gate is inert until each repo's regenerated workflows name the environment and its secrets are re-minted into it. `TODO.md` carries the per-repo recipe. Once this merges: tag `0.1.13`, which publishes to PyPI and creates the GitHub Release, then regenerate tend's own workflows against the published version. > _This was written by Claude Code on behalf of max-sixty_
tend-reviewchecked out the fork's tree and then ran the adopter'ssetup:steps against it. Those steps execute as the runner user, which holds sudo and — untilproxy/setup-sandbox.shstrips it — the checkout PAT in.git/config. So a contributor's build backend, added dependencies, or localuses: ./action ran with that access, ahead of the containment the harness exists to build. Root on the runner before the sandbox is set up makes everything downstream of it decorative.Review now checks out the base tree, runs
setup:, then lands the PR's tree. That is the ordering every other generated workflow already had —mentionrunssetup:before itsgh pr checkout, and the rest check out the default branch — so this removes an exception rather than adding a rule.The base checkout renders only alongside
setup:, since giving setup a reviewed tree is the whole reason it exists. Where it does render, the PR checkout carriesclean: false. Verified againstactions/checkout'sgit-directory-helper.tsatv7: withcleanfalse,prepareExistingDirectoryskipsgit clean -ffdx && git reset --hard, keeps the existing repo since the fetch URL matches, and only detaches HEAD and prunes local branches. Setup's untracked output survives; tracked files are overwritten by the PR tree, which is what a reviewer should see. The merge-ref tree is preserved, so this doesn't reopen the tradeoff settled in #723.Adopters with no
setup:generate byte-identical output to before this PR —cleanis omitted along with the base checkout, since the action consults that input only on the existing-repo path, which a lone checkout never reaches.Scope
This strengthens defense in depth, not a load-bearing boundary. The merge restriction still stops the worst outcome, unchanged either way. Under the codex harness the effect is close to cosmetic: that harness runs the agent on the runner with
sandbox: danger-full-accessand passes both credentials directly, so the agent executes the same code with the same access moments later.Adopter impact
Setup no longer sees the PR's manifests. Project setup that must (installing the PR's dependencies) belongs in
sandbox_setup:, which runs as the sandbox user with the workspace as cwd — documented indocs/tend.example.yaml. Adopters whose setup only installs toolchains, or who have none, need no change.Verification
285 tests pass,
pre-commit run --all-filesclean, andactionlintpasses on generated workflows both with and without setup steps.