Skip to content

refactor(actions): share step scripts; name actions by harness - #712

Merged
max-sixty merged 1 commit into
mainfrom
dedup-harness-actions
Jun 19, 2026
Merged

max-sixty merged 1 commit into
mainfrom
dedup-harness-actions

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Two related cleanups to tend's composite actions, in one branch. No behavior change for adopters.

1. De-duplicate the shared step bodies

The three harness actions repeated ~700 lines of identical preflight/setup/teardown bash. Each body now lives once as a script under shared/steps/, invoked by a thin wrapper that passes inputs via env — the same github.action_path-relative script pattern the proxy already uses, so there's no self-version-pin and the scripts stay branch-smoke-testable (a nested composite sub-action would have forced both). Five scripts are shared by all three actions; five by the two Claude actions. Bodies moved verbatim — the only edits are a set -eo pipefail header (matching GitHub's shell: bash default) and lifting three ${{ }} interpolations to env vars.

2. Name every action by its harness

The generator stamps the uses: ref from the harness: config, so the unnamed max-sixty/tend@X Claude default was an asymmetry. action.yaml → claude/, interactive/ → claude-interactive/, and the proxy moved to a top-level proxy/ shared by both Claude actions. All three actions are now one level deep, so every shared-infra reference is uniformly ../shared/ / ../proxy/.

Reviewing

  • shared/steps/*.sh — the extracted bodies.
  • claude/action.yaml, claude-interactive/action.yaml, codex/action.yaml — now thin wrappers.
  • generator/src/tend/templates/macros.yaml.j2 — stamps max-sixty/tend/{claude,claude-interactive,codex}@X.
  • .pre-commit-config.yaml — an input-parity guard keeps the two Claude actions swap-compatible (they share the generator's with: block); a shellcheck hook restores the lint coverage the inline run: blocks had via actionlint.

Compatibility

Nothing breaks. Existing uses: refs are pinned to immutable tags (0.1.5/0.1.6) whose layout is unchanged; harness-named refs only appear at the next release's regen. The committed tend-*.yaml workflows (@0.1.6) and review-reviewers.yaml (/interactive@0.1.5) are intentionally left on their old pins.

Testing

pre-commit (actionlint, shellcheck, the parity guard), generator tests (255), proxy tests (21), and a programmatic check that every extracted body is byte-equivalent to its original — all green. The end-to-end runtime path changed (steps now bash script.sh), so dispatch claude-smoke.yaml --ref dedup-harness-actions (and interactive-smoke.yaml) to validate on a real runner before relying on it — those need repo secrets and aren't exercised by PR CI.

This was written by Claude Code on behalf of max

Two related cleanups to the composite actions.

1. De-duplicate the shared `run:` step bodies. The three harness actions
   (claude, claude-interactive, codex) repeated ~700 lines of identical
   preflight/setup/teardown bash. Each body now lives once as a script under
   `shared/steps/`, invoked by a thin wrapper that passes inputs via env —
   the same `github.action_path`-relative script pattern the proxy already
   uses. Five scripts are shared by all three actions; five by the two Claude
   actions. Bodies moved verbatim; the only edits are a `set -eo pipefail`
   header (matching GitHub's `shell: bash` default) and lifting three `${{ }}`
   interpolations to env vars (BOT_NAME, SYSTEM_PROMPT_FILE, MARKETPLACE_ROOT).

2. Name every action by its harness; drop the bare-root default. The generator
   stamps the `uses:` ref from the `harness:` config, so the unnamed
   `max-sixty/tend@X` Claude default was an asymmetry. `action.yaml` → `claude/`,
   `interactive/` → `claude-interactive/`, and the proxy moved to a top-level
   `proxy/` shared by both Claude actions. All three actions are now one level
   deep, so every shared-infra reference is uniformly `../shared/` / `../proxy/`.

A `claude-action-input-parity` pre-commit hook keeps the two Claude actions'
input surfaces in sync (they share the generator's `with:` block); a shellcheck
hook restores the lint coverage the inline `run:` blocks had via actionlint.

Consumers updated: generator macro + regtest snapshots, both smoke workflows,
`ci.yaml`'s proxy-test job, the running-tend weekly pin-bump recipe, and the docs.

Existing pinned refs (committed `tend-*.yaml` on `@0.1.6`, `review-reviewers.yaml`
on `/interactive@0.1.5`) are left untouched — they resolve against immutable
tags whose layout is unchanged; harness-named refs appear at the next release.

Validated: pre-commit (actionlint, shellcheck, parity), generator tests (255),
proxy tests (21), and a programmatic check that every extracted body is
byte-equivalent to its original. End-to-end smoke needs repo secrets and is run
manually.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@tend-agent tend-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the mechanics this refactor turns on, all clean:

  • Env-var lifting is complete. Every bash ../shared/steps/*.sh wrapper passes exactly the env the script reads (GITHUB_TOKEN, BOT_NAME, SYSTEM_PROMPT_FILE, EXTRA, CLAUDE_VERSION, MARKETPLACE_ROOT, …); the rest are auto-provided GITHUB_* / SANDBOX / AGENT_* from $GITHUB_ENV. The byte-equivalence test only guards the bodies, so this was the spot a missed lift would slip through — none did, across all three actions including codex's shared subset.
  • set -eo pipefail correctly reconstitutes GitHub's default shell: bash flags (-eo pipefail, no -u) that bash script.sh would otherwise drop — matches prior behavior.
  • Paths resolve uniformly via ../shared/ and ../proxy/ off the full-repo checkout (the proven github.action_path-relative pattern the proxy already used); shared/system-prompt.md is in place.
  • Input parity between claude/ and claude-interactive/ is exact (12 inputs, same defaults), so the new parity hook passes; shellcheck hook scopes to shared/steps/*.sh + proxy/setup-sandbox.sh.
  • Generator + regtests stamp max-sixty/tend/{claude,claude-interactive,codex}@X consistently; the intentionally-pinned old refs (tend-*.yaml@0.1.6, review-reviewers@/interactive@0.1.5) are correctly left untouched.

One thing to confirm rather than a defect: #705 ("feat: add max-sixty/tend/claude harness subpath") is still open and targets the same harness-naming goal over a near-identical file set (claude/action.yaml, codex/action.yaml, macros.yaml.j2, the same regtest outputs, security-model.md). This PR looks like the fuller version — it also renames interactive/ → claude-interactive/, extracts the shared step bodies, and hoists the proxy. Worth closing one as superseded so they don't fight over the same files.

@max-sixty
max-sixty merged commit 4b7baf7 into main Jun 19, 2026
7 checks passed
@max-sixty
max-sixty deleted the dedup-harness-actions branch June 19, 2026 00:38
@max-sixty max-sixty mentioned this pull request Jun 23, 2026
max-sixty added a commit that referenced this pull request Jun 23, 2026
Bumps generator version to 0.1.7, syncs the lockfile, and adds the
`## 0.1.7` CHANGELOG section (published verbatim as the GitHub Release
notes on tag push).

Changes since 0.1.6: pin actions/checkout to v7 with review opting into
the fork-PR checkout guard (#725); bump claude-code to 2.1.185 (#719);
running-in-ci surfaces blocking scope rules instead of routing around
them (#717) and caps CI-poll loops to the Bash 10-min limit (#695);
nightly workflow-regen bases its worktree on an open PR rather than
branch-ref existence (#721); de-duplicate composite-action step bodies
under shared/steps/ with harness-named action paths (#712); correct the
codex effort list (#710); review-reviewers and worker-deploy doc fixes
(#707, #711).
max-sixty added a commit that referenced this pull request Jun 23, 2026
Stamps the 0.1.7 generator into tend's own workflows: harness-named action ref max-sixty/tend/claude@0.1.7 (#712), actions/checkout v7 with review's allow-unsafe-pr-checkout opt-in (#725), and the header version line.
max-sixty pushed a commit to max-sixty/worktrunk that referenced this pull request Jun 25, 2026
Automated nightly regeneration of tend's workflow files.

**tend version:** 0.1.6 → 0.1.7

**Notable changes:**

- **Fork-PR review checkout fixed properly** (max-sixty/tend#725) —
`tend-review` now uses `actions/checkout@v7` with
`allow-unsafe-pr-checkout: true`, the upstream-intended way to re-enable
fork-PR ref checkout that v7 blocks by default. This supersedes the
manual `actions/checkout@v6` stopgap pinned in #3176: the generator now
carries the fix, so the regen restores v7 with the explicit opt-in
rather than the downgrade.
- **CI-poll loops trimmed to fit the Bash tool's 10-min cap**
(max-sixty/tend#695) — `running-in-ci` CI-monitoring loops are sized so
they don't auto-background and drop a gated follow-up.
- **Scope blockers surfaced instead of routed around**
(max-sixty/tend#717) — when a scope rule blocks the correct action, the
bot now reports the blocker on the thread rather than silently
substituting a workaround.
- **Nightly regen worktree bases on the open PR, not the branch ref**
(max-sixty/tend#721) — keeps the regen diff incremental and the PR body
accurate.
- **Shared step scripts; actions named by harness** (max-sixty/tend#712)
— explains the regenerated comment in `tend-notifications.yaml` ("the
harness action's post-step").

Compare: max-sixty/tend@0.1.6...0.1.7

Co-authored-by: worktrunk-bot <worktrunk-bot@users.noreply.github.com>
max-sixty added a commit that referenced this pull request Aug 3, 2026
…#814)

The weekly bump section covered the four `*_version` action inputs. The
third-party `uses:` refs had nothing watching them, and the reason is
worth stating: the bundled weekly skill *reviews* dependency PRs,
filtering `gh pr list` for `dependabot[bot]` and `renovate[bot]`.
Neither has ever run on this repo (`gh pr list --author app/dependabot
--state all` is empty, as is renovate's; there is no
`.github/dependabot.yml`, vulnerability alerts return 404 "disabled",
and `automated-security-fixes` is `{"enabled":false}`). So the weekly
run has been a reviewer for a bot that doesn't exist here, and a ref
only ever moved when someone needed a behavior from it —
`actions/checkout@v7` in the generator arrived in #725 to opt into v7's
fork-PR checkout, and `actions/cache@v4` has not moved since #712.

What that leaves today, from the new scan:

```
actions/cache                  v4        -> v6.1.0
actions/checkout               v6        -> v7.0.1
actions/download-artifact      v7        -> v8.0.1
actions/setup-node             v4        -> v7.0.0
actions/upload-artifact        v6        -> v7.0.1
astral-sh/setup-uv             v6        -> v9.0.0
astral-sh/setup-uv             v7        -> v9.0.0
pypa/gh-action-pypi-publish    v1.13.0   -> v1.14.2
```

An action listed twice is the signature of the failure mode: `setup-uv`
sits at v6 in `.config/tend.yaml`'s `setup:` and at v7 in `ci.yaml`,
because whoever needed v7 needed it in one file. `checkout` and
`upload-artifact` are split the same way.

The scan skips `max-sixty/tend/*`, which the release owns and "Nightly:
restamp the hand-maintained workflow refs" already covers, and the
`generator/tests` fixtures, where a bump churns regtest snapshots and
proves nothing. Results sort into two buckets because the PR shape
differs: the generator templates and the two composite actions render
into adopters' repos, so each gets its own PR naming what the majors it
crosses change; the hand-maintained workflows and `.config/tend.yaml`
reach only us and go in one.

## Why not dependabot

<details>
<summary>It would reach two of the three places these live, and this is
the one that's ours to schedule</summary>

Dependabot's `github-actions` ecosystem scans `.github/workflows` plus a
root `action.yml`, so `claude/action.yaml` and `codex/action.yaml` need
an explicit `directories:` entry
([dependabot-core#6704](dependabot/dependabot-core#6704)
is open; the workarounds are in its thread).
`generator/src/tend/templates/macros.yaml.j2` renders
`actions/checkout@v7` into every adopter's workflows and is a Jinja
template — no manager parses it, and dependabot has no regex manager.
That one is the highest-stakes ref in the repo and the least reachable,
so the rule has to cover it either way.

This also corrects the parenthetical in #811, which cited
dependabot-core#6936 as "closed not-planned". It was closed as a
duplicate of #6704, which is open. The claim that mattered there is
unaffected: dependabot updates `uses:` refs, never a `default:` under
`inputs:`, which is why the four `*_version` pins needed a skill rule.

</details>

The scan was run verbatim out of the skill file to produce the table
above.

> _This was written by Claude Code on behalf of max-sixty_

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
max-sixty added a commit that referenced this pull request Aug 3, 2026
Removes the `claude-smoke` workflow and, once this merges, the
`tend-manual` environment that existed only to feed it secrets.

The smoke was scaffolding for building the headless proxy harness: it
ran 4 times ever, all June 17–19 while #704–#712 were under
construction, and none of the ~15 harness changes since (sandbox PATH,
uv isolation, sandbox levers, removing `claude-interactive`, the proxy
readiness fix) dispatched it. Its deterministic half is covered per-PR
by CI's `test-proxy` job at the production-pinned mitmproxy, and a
harness broken in a release surfaces within a day through tend's own
scheduled workflows dogfooding it, with a fix-forward release costing
about an hour.

`tend-manual` was the reviewer-gated companion environment
`claude-smoke` needed because its whole point — dispatching on feature
branches — is what the `tend` ref policy exists to refuse. With its only
consumer gone, the environment goes too, which also drops one paste from
the credential migration in `TODO.md`. The `credential-environments`
sweep is untouched: it verifies any reviewer-gated environment a repo
declares, keyed on the credential rather than the name (its tests assert
exactly that), and `docs/security-model.md` keeps documenting the
pattern as the answer for bot-steerable triggers.

Also carried on this branch: two TODO.md corrections from the migration
work — dropping the deleted cargo-affected `BOT_TOKEN` leftover, and
replacing the wrong claim that a `main`-only policy can never admit the
worktrunk/prql hand-maintained workflows' refs (probed live:
`pull_request_target` runs at `refs/heads/main` and is admitted; a tag
push is admitted once the policy carries a tag entry).

> _This was written by Claude Code on behalf of max-sixty_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants