Skip to content

generator: per-workflow harness override - #612

Merged
max-sixty merged 4 commits into
mainfrom
per-workflow-harness
May 27, 2026
Merged

max-sixty merged 4 commits into
mainfrom
per-workflow-harness

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Why

Lets adopters trial a new harness on a single workflow without flipping the whole bot. Concrete use case: try harness: claude-interactive on nightly while keeping PR review / mention on the production claude harness. Trial-safe rollout for the interactive harness added in #609 / #611.

What

  • WorkflowConfig gains an optional harness field. Config.load validates the value is a known harness and (cross-family only) compatible with the top-level model.
    • Same-family overrides (claude ↔ claude-interactive) share the model set, no compatibility error.
    • Cross-family overrides (codex → claude/claude-interactive with a codex model name like gpt-5.5, or vice versa with a per-workflow model unset) fail at config load with a clear message: "workflows.X.harness 'claude' is incompatible with the top-level model 'gpt-5.5'… Cross-family per-workflow harness overrides require setting model: per-workflow too, or changing the top-level model."
  • workflows.py: a new _effective_cfg(cfg, wf) helper returns cfg unchanged when there's no override, or dataclasses.replace(cfg, harness=wf.harness) otherwise. Each generator function (review, mention, triage, ci-fix, scheduled, notifications) calls it once and passes the effective config to both the template and default_prompt. No template changes — agent_step still reads cfg.harness from whatever cfg it gets.
  • Tests: per-workflow override targets only the named workflow (sibling workflows keep the top-level harness), unknown harness rejected, cross-family model mismatch rejected, same-family override loads cleanly.

Example

bot_name: tend-agent
harness: claude
# Trial the interactive harness on nightly only — review/mention/triage
# stay on the SDK-based claude harness until we're confident.
workflows:
  nightly:
    harness: claude-interactive

Test plan

  • 252 tests pass (4 new); existing snapshots untouched
  • pre-commit run --all-files passes

Adds workflows.<name>.harness for trialing a different harness on one
workflow without flipping the whole bot. Concrete use case driving this:
trial harness: claude-interactive on nightly while keeping review,
mention, etc. on the production claude harness.

- WorkflowConfig grows an optional `harness` field. Config.load validates
  it's known and (cross-family only) compatible with the top-level model.
  Same-family overrides (claude ↔ claude-interactive) share the model
  set; cross-family overrides without a per-workflow model are a hard
  error with a clear message.
- workflows.py: a new _effective_cfg(cfg, wf) helper returns cfg
  unchanged when no override, or a dataclasses.replace clone with the
  workflow's harness. Each generator function calls it once and passes
  the effective config to the template + default_prompt. No template
  changes — agent_step still reads cfg.harness from whatever cfg it gets.
- Tests: per-workflow override targets only the named workflow,
  unknown harness rejected, cross-family model mismatch rejected, and
  same-family override loads cleanly.

All 252 tests pass (4 new). Existing snapshots untouched — the helper
returns cfg unchanged when there's no override.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

@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.

One correctness gap in the cross-family validation: the check fires only when the target harness has a model allowlist, so the claude → codex direction slips through. With top-level harness: claude, model: opus and workflows.nightly.harness: codex, Config.load accepts the config and the renderer emits model: opus on the codex action — which codex won't accept. The PR description says cross-family overrides fail "vice versa with a per-workflow model unset"; that direction currently doesn't fail.

Related: the error message tells the user to set model: per-workflow, but WorkflowConfig doesn't have a model: field, so following the suggestion has no effect.

Pick whichever fix matches your intent — close the asymmetry by family (option in the inline comment), or add a per-workflow model: field and validate the effective pair.

Comment thread generator/src/tend/config.py Resolved
…verride

Reviewer caught two related gaps:
- The cross-family validation only fired when the *target* harness had
  a model allowlist. claude → codex (model 'opus' → codex action) slipped
  through, would render `model: opus` on a codex step at runtime.
- The error message told users to set `model:` per-workflow, but
  WorkflowConfig had no `model:` field — the suggestion was uncallable.

Fix:
- Add `model: str | None` to WorkflowConfig; _effective_cfg uses it
  when set.
- Validate both directions in Config.load. Target-allowlist check fires
  when the new harness has an allowlist the effective model isn't in
  (e.g. gpt-5.5 → claude). Source-family check fires when the override
  crosses families away from a harness with an allowlist and no
  per-workflow model is set (e.g. claude → codex without overriding
  the model).
- Two new tests cover both directions. A third confirms the per-workflow
  `model:` field unblocks cross-family overrides.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@max-sixty

Copy link
Copy Markdown
Owner Author

Both gaps fixed in 6d42cf4.

  1. Symmetric validation: added a second guard for the cross-family-source direction. With harness: claude top-level and workflows.nightly.harness: codex, Config.load now errors with: "workflows.nightly crosses harness families (claude → codex) without a model override. Set workflows.nightly.model: to a valid codex model."

  2. Per-workflow model: field: WorkflowConfig now has it, and _effective_cfg applies it. The error message now points users to a field that exists.

Test coverage:

  • test_per_workflow_harness_incompatible_model_rejected_codex_target — the original direction (codex source → claude target, gpt-5.5 not in claude allowlist).
  • test_per_workflow_harness_incompatible_model_rejected_codex_source — the previously-missed direction (claude source → codex target, opus → codex without model override).
  • test_per_workflow_model_override_unblocks_cross_family — confirms the new model: field unblocks cross-family overrides; renders model: gpt-5.5 on the codex step while sibling workflows keep model: opus.

254 tests pass (+2 over the previous push).

This was written by Claude Code on behalf of Maximilian.

@tend-agent

Copy link
Copy Markdown
Collaborator

Both fixes look right — symmetric source-family guard fires before _effective_cfg ever sees an unsupported pair, and the new WorkflowConfig.model field makes the error message actionable. The three new tests cover both directions and the unblock path. Resolved on my end.

@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.

The symmetric cross-family validation closes the gap from the prior review — both directions error with actionable messages now. One remaining hole, inline: a per-workflow model: override without a harness: change skips validation entirely (both checks gate on wf_harness is not None). Verified locally — workflows.nightly.model: opus-99 with no harness: loads cleanly and the renderer emits model: opus-99 into a claude action step.

Likely a minor concern in practice (the docstring frames model as pairing with harness), but easy to close — see the inline suggestion.

Comment thread generator/src/tend/config.py Resolved
max-sixty added a commit that referenced this pull request May 27, 2026
…mer (#613)

## Why

Second smoke-test retry on `main`
(https://github.com/max-sixty/tend/actions/runs/26488931127) still timed
out at 300s. The supervisor's transcript dump showed `claude` blocked on
a third onboarding dialog after the trust + theme picker — the
**"WARNING: Bypass Permissions mode"** disclaimer, shown the first time
`claude` is invoked with `--permission-mode bypassPermissions`:

```
WARNING: Claude Code running in Bypass Permissions mode
In Bypass Permissions mode, Claude Code will not ask for your approval before running potentially dangerous commands.
…
❯ 1. No, exit
  2. Yes, I accept
```

The disclaimer state has no documented pre-seed key in `~/.claude.json`,
and the binary's own error message for `--bg` says it must be accepted
via an interactive run — which the supervisor can't replicate.

## What

Switch to `--permission-mode dontAsk` with an explicit allow list.
`dontAsk` auto-denies anything not pre-approved (no prompt, no
disclaimer); flat tool names like `"Bash"` match all invocations, so the
effective permission surface matches the `bypassPermissions` intent for
CI use.

- `interactive/action.yaml`: drop `--permission-mode bypassPermissions`
in the wrapper script; write `permissions.defaultMode: dontAsk` + an
`allow` list (built from `inputs.allowed_tools` via `jq`) into
`.claude/settings.local.json`. Pass `--permission-mode dontAsk` on the
CLI too as belt-and-suspenders.
- Comment in the Run-Claude step block explains why we avoid
bypassPermissions and what dontAsk does for us.

No generator changes; no test changes (no behavior visible at
config-render time).

## Test plan

- [ ] Re-run `interactive-smoke` after merge — expect status=ok, turns >
0
- [ ] Eventually exercise on a real CI workflow (post-merge, after #612
lands)

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Reviewer (round 2) caught the remaining hole: both validation branches
gated on `wf_harness is not None`, so a per-workflow `model:` change
WITHOUT a `harness:` change skipped validation entirely. Verified
locally — `workflows.nightly.model: opus-99` would load and render
`model: opus-99` into a claude action step.

Restructure: gate on `wf_harness is not None OR wf_model is not None`,
then collapse cases A (model typo) and B (cross-family target with bad
model) into a single check against the effective harness's allowlist.
Case C (cross-family flip away from allowlist without model) stays as
the source-allowlist check.

Two new tests:
- test_per_workflow_model_typo_without_harness_rejected: the specific
  gap the reviewer found.
- test_per_workflow_model_only_override_valid: positive case — `model:
  haiku` (no harness change) renders cleanly with siblings still on opus.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@max-sixty

Copy link
Copy Markdown
Owner Author

Closed in 95f047b. Restructured the validation: the outer guard is now wf_harness is not None OR wf_model is not None, which catches the model:-only override path you flagged.

Cases the new logic covers (all gated on "the workflow overrode something"):

Case Example Caught by
A. model typo, no harness change model: opus-99 (top-level claude) effective-harness allowlist check
B. cross-family flip, target has allowlist, bad model top: codex/gpt-5.5; wf: harness=claude same effective-allowlist check
C. cross-family flip OUT of allowlist, no per-workflow model top: claude/opus; wf: harness=codex source-allowlist check

Tests:

  • test_per_workflow_model_typo_without_harness_rejected — the specific gap you found.
  • test_per_workflow_model_only_override_valid — positive case: model: haiku (no harness change) loads + renders.

256 tests pass (+2).

This was written by Claude Code on behalf of Maximilian.

@tend-agent

Copy link
Copy Markdown
Collaborator

Restructure looks right — the outer wf_harness is not None or wf_model is not None guard now covers the model-only path, and collapsing A+B into the effective-allowlist check is cleaner than the prior two-branch form. Verified the new tests pass locally. No remaining concerns from my side.

Ruff F841 — variable computed but no longer referenced after the
case-A/B collapse. Caught by CI on the prior push.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 324226e into main May 27, 2026
6 checks passed
@max-sixty
max-sixty deleted the per-workflow-harness branch May 27, 2026 04:03
@max-sixty max-sixty mentioned this pull request May 27, 2026
max-sixty added a commit that referenced this pull request May 27, 2026
## Why

Cut the 0.1.2 release so consumer repos (and tend's own nightly regen)
pick up the new
`claude-interactive` harness and per-workflow `harness`/`model`
overrides.

## What's new since 0.1.1

**New `claude-interactive` harness**
(`max-sixty/tend/[email protected]`) — opt-in
alternative to the released `claude` harness. PTY-supervised interactive
`claude` via
`script(1)`, end-of-turn detected through Stop/StopFailure hooks. Built
as the
trial path ahead of Anthropic's June 15 billing split between Agent-SDK
metering and
the flat Claude Code subscription. Smoke tested end-to-end on tend
itself. PRs:
#609, #611, #613, #614, #615, #616.

**Per-workflow `harness` / `model` override** — adopters can flip a
single workflow
to a different harness or model without changing `.config/tend.yaml`
defaults. #612.

**Skill refinements** — nightly upstream-bot rebases (#605),
running-in-ci PR bar
(#604) and recheck (#573), env-filter loophole fix (#599),
authorAssociation warning
(#600), review-gates Gate 1 (#602).

**Bug fix** — mention queue-delay now uses `comment.updated_at` so edit
events report
accurately (#595).

## Compatibility

Released `claude` harness path is byte-identical; `claude-interactive`
is strictly
additive and opt-in. Consumer repos that don't touch `harness:` see no
change beyond
the new skill text and the mention-edit fix.
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