Skip to content

feat(workflow)!: let a workflow own its copy, hand runs to a person, clean up run branches, and read a step's PR - #1704

Merged
SaulMoro merged 89 commits into
Tencent:mainfrom
hz89Dev:fix/issue-1689
Nov 4, 2026
Merged

SaulMoro merged 89 commits into
Tencent:mainfrom
hz89Dev:fix/issue-1689

Conversation

@hz89Dev

@hz89Dev hz89Dev commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Running a software factory end to end hit four gaps (#1689):

  • a sub-workflow could not run both on its own and inside a copy;
  • resume --next refused any run that might need a person later;
  • nothing cleaned up teamai/<run>/… branches;
  • a deliver: pr step with nothing to deliver looked the same as one that opened a pull request.

This PR implements every decision in the issue's Resolution, plus its two smaller output notes, in one change.

 # 1. a workflow declares that it works in a copy
+name: review-and-fix
+workspace: new          # on its own: one copy for the whole run; inside a copy: reuses it
 steps: [review, fix, review-again]

 # 2. a runner takes a run, and hands it to a person when it reaches one
-resume --next: skip a run if any step left may need a person
+resume --next: skip a run only if a step ready now needs a person
+               runner reaches a person step -> publishes the run offered, releases leases, exits 0
+               resume list: "needs a person" now, "may need a person at <step>" later

 # 3. run branches are cleaned up
+run succeeds  -> delete teamai/<run>/* branches whose tip a kept branch holds
+                 (kept: PR branches, the final copy)
+doctor --fix  -> past workflows.retention (default 14d, or never): branches, worktrees,
+                 kept refs, base pins; other machines' runs found through teamai-reports
+durations     -> new unit d (timeout included)

 # 4. expressions read the pull request a step delivered
+steps.fix.pr                       # { url } | null, only on deliver: pr
+steps.<id>.results[n].pr / .passes[n].pr
+if: steps.fix.pr == null           # "nothing to deliver"

Where it lives:

src/workflow/
├── workspace.ts, parse.ts, describe.ts    # 1: one helper builds the chain of copies, with a root copy
├── engine.ts, handoff.ts, drivers/skill/  # 2: person steps offered, not failed; onlyPersonAnswers is the one rule
├── leftovers.ts, retention.ts, records.ts # 3: success cleanup, doctor sweep, retainedUntil
├── expression.ts, parse-context.ts, delivery-*.ts  # 4: steps.<id>.pr
src/dashboard/                             # Member settings source, hand-off needs, run Branches
src/doctor.ts, src/member-settings-report.ts

Dashboard: Member settings shows where workflows.retention comes from. Handed-off runs say whether a run needs a person now or may need one later, with the claim command. A settled run's details list its Branches: kept with the reason, deleted, not deleted with the error, or kept for inspection with the date doctor --fix may remove them.

375 768 1280 zh-CN 375
Member settings
Handed-off runs
Succeeded run
Succeeded run, Branches
Failed run, Branches

The screenshots show the real dashboard page, with its API answered from typed fixtures.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature causing existing behavior to change)
  • Documentation only
  • Refactor / internal cleanup

Behavior that changes:

  • a succeeded run now deletes its intermediate branches;
  • an unattended person step now waits and hands off instead of failing hitl_required;
  • a pr read on a step without deliver: pr is now rejected by pull.

Test Plan

  • npm run typecheck passes
  • npm run lint passes (oxlint plus node scripts/check-docs.mjs)
  • npx vitest run passes: the full suite was not run; only the tests the change reaches (below)
  • Added/updated tests for the change

Every behavior was written test-first, at the public seam: parse diagnostics, local-driver runs, conformance scenarios.

Command Files Result
LC_ALL=C npx vitest run --changed <base of the review fixes>, at 1e497ee3 615 passed
LC_ALL=C npx vitest run --changed HEAD^1 (after merging main) 542 541 passed, 1 timeout under load
↳ rerun alone: npx vitest run src/__tests__/workflow-reconciliation.test.ts 1 7/7 passed
npx vitest run src/__tests__/workflow-leftovers.test.ts src/__tests__/workflow-run-controls.test.ts (latest commits) 2 141/141 passed
Global tests the import graph does not reach: scripts/check-docs.test.ts, docs, default-workflows, workflow-skill-literals, workflow-conformance, workflow-git-conformance, dashboard-ui 7 320/320 passed
Each edited E2E file, one at a time: npm run test:e2e -- <file> 8 8 passed, 83/83 tests
After publishing a cleaned-up run was fixed: npx vitest run --changed HEAD 541 passed

Real CLI, built dist/, scratch repos with bare origins, fake claude/gh. Provider: git; agent: Claude. Other providers and agents are left to CI.

1. workspace: new header: on its own, and inside ship-issue's copy
$ teamai workflow start review-and-fix --driver local --confirmed
{"data":{"done":{"run":"rf7b3fa8c93a55df1","outcome":"succeeded","record":"published"},"cancelled":[]}}
ℹ Run rf7b3fa8c93a55df1 left its changes on branch teamai/rf7b3fa8c93a55df1/_run. Bring them in with: git merge teamai/rf7b3fa8c93a55df1/_run
$ git show teamai/rf7b3fa8c93a55df1/_run:fixed.txt
F
$ git status --short   # the checkout did not change
?? .teamai/workflows/

$ teamai workflow start ship-issue --driver local --tools default=claude --confirmed
{"data":{"done":{"run":"rb35d59c9ac02cfca","outcome":"succeeded","record":"published"},"cancelled":[]}}
$ git branch --list 'teamai/rb35d59c9ac02cfca/*'   # one copy, change's
  teamai/rb35d59c9ac02cfca/change/p1
$ git show teamai/rb35d59c9ac02cfca/change/p1:fixed.txt teamai/rb35d59c9ac02cfca/change/p1:change.txt
F
C
2. A runner takes a run, offers it back at a person step, a second runner leaves it, a person finishes it
## alice publishes a run stopped during build
$ teamai workflow publish r464d5806f4542590
{"data":{"run":"r464d5806f4542590","publication":"published","stateRevision":1,"offered":true,...}}

## an unattended coding session takes offered runs with the skill driver
$ TEAMAI_MODE=unattended teamai workflow resume --next --driver skill
✔ Claimed r464d5806f4542590 (release) from alice
$ teamai workflow next r464d5806f4542590 --driver skill
{"data":{"turn":{...,"actions":[{"kind":"person","why":"offered","steps":["ship"],"message":"Step \"ship\" needs a person, so run r464d5806f4542590 is offered on teamai-reports. A person continues it with: teamai workflow resume r464d5806f4542590 --claim",...}]}}}

## a second runner, in CI and as a skill session
$ CI=true teamai workflow resume --next --auto-approve
ℹ Left r464d5806f4542590 (release) offered for a person: only a person can answer the approval at ship
{"data":{"idle":{"offered":1}}}

## carol, a person
$ teamai workflow resume
RUN                WORKFLOW  STATUS          OWNER                       WHERE
r464d5806f4542590  release   needs a person  runner (install 77568cb0…)  offered on teamai-reports, only a person can answer the approval at ship: a person runs teamai workflow resume r464d5806f4542590 --claim
$ teamai workflow resume r464d5806f4542590 --claim   # answers: yes
{"data":{"done":{"run":"r464d5806f4542590","outcome":"succeeded","record":"published"},"cancelled":[]}}
3. Success cleanup, then a retry brings the branches back
$ teamai workflow start review --driver local --auto-approve --confirmed
{"data":{"done":{"run":"r72c19aa340cd992b","outcome":"succeeded","record":"published"},"cancelled":[]}}
$ git -C ../origin.git branch --list 'teamai/*'
  teamai/r72c19aa340cd992b/join/p1

$ teamai workflow retry r72c19aa340cd992b decide
{"data":{"retried":{"step":"decide","pass":2},"reopened":true,...}}
$ git -C ../origin.git branch --list 'teamai/*'
  teamai/r72c19aa340cd992b/change/p1
  teamai/r72c19aa340cd992b/join/p1

$ teamai workflow resume r72c19aa340cd992b
{"data":{"done":{"run":"r72c19aa340cd992b","outcome":"succeeded","record":"published"},"cancelled":[]}}
$ git -C ../origin.git branch --list 'teamai/*'
  teamai/r72c19aa340cd992b/join/p1
  teamai/r72c19aa340cd992b/join/p2
4. fix-ci: steps.fix.pr == null picks the end
$ teamai workflow start fix-ci --driver local    # patch changes nothing
{"data":{"done":{"run":"r9e42c889c83f5231","outcome":"succeeded","end":"nothing-to-fix","record":"published"},"cancelled":[]}}

$ teamai workflow start fix-ci --driver local    # patch writes fix.txt
{"data":{"done":{"run":"rcb77cfe3e0665bbc","outcome":"succeeded","end":"fixed","prs":["https://github.com/fixture/app/pull/1"],"record":"published"},"cancelled":[]}}
# gh calls
gh pr create -R fixture/app -B main -H teamai/rcb77cfe3e0665bbc/fix/p1 -t fix-ci: fix ...
gh pr edit https://github.com/fixture/app/pull/1 --add-label ci-fix

$ teamai pull    # a workflow reading pr on a step without deliver: pr
⚠ [workflows] workflows/bad-pr.yaml:17: field "steps[1].if": step "nothing-to-fix" if reads steps.fix.pr, but step "fix" has no deliver: pr, so it has no pr
⚠ [workflows] workflows/bad-pr.yaml has no runnable version

Related Issues

Closes #1689

Notes for Reviewers

Decisions that go beyond the Resolution, or read it one way:

Decision Why Alternative
Past workflows.retention, doctor --fix also deletes a succeeded run's final copy branch; PR branches stay The Resolution's doctor bullet lists every leftover except PR branches Keep final copies forever and sweep only intermediates
Retention counts from a run's first end (retainedUntil, set once, published with the run) A deadline renewed on every end lets one install's unpublished retry outlive the deadline another install deletes by Count from the last end, which needs every end to be published
Another install's run is swept only 7 days past its published deadline It covers a retry that started before the deadline on the owning machine No grace, which risks deleting an active retry
A retry past the deadline is refused with run_expired Its branches may already be gone on another machine Allow it and restore what can be restored
A retry of a succeeded run restores the branches the run recorded, and is refused with branches_not_restored when one is at a different commit A person's commit on a kept branch is never reset Reset the branch to the recorded commit
next gets no branch field; drivers read the copy from the run file The Resolution says no change to next Add the field
Dashboard: Branches section, needs-now vs may-need, retention source The Resolution asks for the Member settings source; the rest shows what the CLI already knows Member settings only

After merging #1700:

Known limitation: a narrow race between two installs. Install A has just succeeded and its cleanup is deleting branches. In that same window, install B claims the run, retries it, and publishes the reopened run. A's deletion can then remove a branch B restored, and B's next end reports commit_missing.

  • Why I think it is acceptable. No commit is lost: cleanup only deletes a branch whose tip a kept branch holds. Retrying again on B should restore the branch, though I have not verified that.
  • What would close it. A cleanup claim shared across installs, held on teamai-reports, that claim and retry wait on. That is a distributed lock for a sub-second window, so I left it out. I'd like a maintainer's call.

Accepted residual: a retry that starts before the deadline and is still running 7 days after it can lose branches to another install's sweep.

…iver: pr

A workflow could not tell a step that delivered a pull request from one
that had nothing to deliver. Pull now accepts steps.<id>.pr, its url, the
pr of each pass and of each for_each result, and a workflow output that
passes it on. It rejects a read of pr on a step without deliver: pr, on a
for_each step (whose pull requests are per item), and of any field other
than url.
A step with deliver: pr now keeps { url } once its delivery opens or takes a
pull request, the same way it keeps its outputs: on the step for its current
pass, on each archived pass, and on each for_each result. A step with nothing
to deliver keeps none, so steps.<id>.pr reads null and a fix-ci workflow can
end nothing-to-fix instead of fixed. The field is optional, so run files and
snapshots written before it still read; a snapshot publishes it as it does
deliveries.
A bare-path origin opens no pull request, so the fix-ci acceptance runs
against the delivery cases' fake provider. A patch that changes the copy
delivers one pull request, which fix keeps as its pr, and the run ends
fixed; a patch that changes nothing opens none and the run ends
nothing-to-fix. The stub drivers now report a step that changed nothing
with no commits instead of failing to commit.
The Deliver a PR section now says a deliver: pr step with no commits
succeeds and opens no pull request, and shows a fix-ci workflow that ends
nothing-to-fix or fixed by reading steps.fix.pr, with the output of both
runs. The expression reference lists pr on a step, a pass and a for_each
result.
…nly one can take

resume --next refused any offered run with a step left that might need a
person, so a runner never took ship-issue, whose pair step runs only when a
choice picks it. The static check cannot tell whether a step is reachable;
the runner now finds out by running.

- A runner leaves an offered run only when a step ready now in the published
  state needs a person. The steps that may need one later are listed as
  information: "may need a person at <step>".
- A local driver with nobody at its terminal no longer fails a required
  approval or an unanswered choice with hitl_required. The step waits, held
  for hitl like an interactive step, and the driver publishes the run offered,
  says on stderr which step needs a person and the resume --claim command,
  and exits 0.
- When the run cannot be offered (no teamai-reports, origin down, no origin),
  the step fails hitl_required, saying why and how to continue the run from
  this machine, which keeps its state.
…once it is

A local driver that drove a run another terminal cancelled answered done
with "record":"pending": its next found the run already ended and read the
record queue once, while the cancel was still pushing the record to
teamai-reports. A next that finds a settled run's record still queued now
publishes the queue for that run first, so done says published when the
record reached teamai-reports, and pending only when it still could not.
score --drain groups the step sessions it skips by reason, but each reason
named its session id and the session lookup's message, so one ship-issue run
printed eleven "Skipped 1 step session" lines. A session the tool does not
keep here, or cannot read, now gets one reason per kind of failure, and the
drain prints one line per run with every step and pass it skipped.
The CI recipe's required approval now ends with the run offered on
teamai-reports and the job exiting 0. A runner that takes release before its
build ran hands it back at ship, leaves its own offer alone afterwards, and the
person who started it sees it as needing a person.
…ake runs

The guide shows a CI start that reaches a required approval, the run offered
on teamai-reports, a runner that leaves it, and a person who claims and
finishes it, plus a ship-issue run a runner takes although its pair step may
need a person. The --next table, the HITL notes and the local workflow skill
say the step waits and the run is handed over, failing hitl_required only
when the run cannot be offered.
…hat hands the run off

A driver without HITL that does not hand runs off keeps the wait reason it had.
The levels around a step were built five times: ancestorsOf and roleLevelsOf
at lease time, describe's visit, deliveryProblem and the parse-time role walk.
None of them had a level for the run itself, and copyRoleFailure named the step
that opened a copy by indexing the step path with a level index, which only
holds while every level is a path segment.

Every walk now starts from runLevels(definition), which holds the run's own
copy once a workflow header can open one, and the lease-time walk is one
function, levelsTo, that the mode, role, clone-branch and planned-branch
lookups share. Role failures name the opener and the namer by the instance
each level records. describe and deliveryProblem share one writesBranch.

Nothing sets the header yet, so behaviour is unchanged.
review-and-fix is meant to run on its own and inside ship-issue's change
copy. Its fix step continues whatever copy is around it, so on its own it
ran read-only in the member's checkout and failed read_only_dirty, while
workspace: new on fix broke the nested case by opening a branch of its own.

A header workspace: new says the whole workflow works in one copy:

- started on its own, the run opens that copy, on teamai/<run>/_run, and
  workflow start ends by naming the branch and the git merge that brings
  it in;
- run by a step that has a copy or is inside one, its steps continue that
  copy and open no other;
- run by a step with no copy around it, that step opens one, as
  workspace: new on it would, so deliver: pr on that step delivers it.

pull rejects any other header value, a header deliver (delivery belongs
to the step that runs the workflow), and a workspace: read-only step that
runs such a workflow, naming both. Role conflicts and the skill driver's
local route name the run's copy instead of an empty step id. next,
report and driver.can are unchanged: drivers get the copy through the
leases they already take.

Git conformance runs review-and-fix on its own, inside ship-issue's
change copy, and from a step with no copy, under every driver under test.
Shows review-and-fix with workspace: new in its header, run on its own,
with the branch the run names at its end, and inside the copy of the step
that runs it, plus the pull refusal for a read-only step that runs it.
…place

workflow start names the run copy's branch when a run whose header says
workspace: new left commits on it. The skill driver's done needs the same
rule, so it moves into workspace.ts as changedRunCopy, next to
runCopyBranch. Behaviour is unchanged.
A run whose header says workspace: new, started on its own, leaves its
changes on teamai/<run>/_run. workflow start --driver local names that
branch on stderr, but a run an agent drives ended with a done that carried
only outcome, prs and failure, so the person was never told where the
changes went.

The engine's done now carries branch when a succeeded run left commits on
its own copy. The skill driver keeps it with the end and shows it on the
done action, next to prs, and the workflow skill tells the person the
branch and the git merge that brings it in. A failed run names no branch.
The field is optional, so drivers that do not read it are unaffected.

Git conformance expects the branch on done for the standalone
review-and-fix run under every driver under test.
The start example's done now carries branch, as the engine answers, and
the guide says an agent driving the run names the same branch and git
merge line when it ends.
The local driver told a person to merge the copy of a run whose header
says workspace: new even when the run failed, while the skill driver
names the branch only for a succeeded run. Both now read the branch from
the engine's done, which carries it only for a succeeded run that left
commits on its copy.

Tested: a failed run's stderr names no git merge, and the succeeded case
still does (workflow-commands.test.ts, 59 passed).
A retention of two weeks reads as 14d. Every duration teamai reads goes
through durationMs, so a workflow timeout, a step timeout, --timeout and a
benchmark suite timeout take d as well.
A run left every teamai/<run>/... branch behind, here and on origin, so
for_each items and steps already merged piled up. Once a run succeeds and
its end is published, each run branch whose tip a branch that stays holds
is deleted: the branches its pull requests use and its final copy stay.
A deletion that fails warns with the branch and is recorded on the run;
a branch checked out where the host put it stays in the checkout. Failed
and cancelled runs keep everything. The git conformance scenarios now
check that merged branches are gone.
How long doctor --fix leaves what a settled run left behind: a duration
or never, 14d by default. It is read like every member setting, from the
scope's config, then ~/.teamai/config.yaml, then the team's teamai.yaml.
Each level keeps the value as written, so a wrong one never fails its
file: it is skipped with a warning and shown as not used, and the next
level decides.
…tention

doctor --fix now deletes again the branches a succeeded run could not
delete as it settled, and removes what a run that settled longer ago than
workflows.retention left: its branches but those a pull request uses, the
worktrees teamai made on them, its kept refs and its base pin on origin.
It finds runs other machines started, such as CI runners, through their
end records on teamai-reports, which now name the branches their pull
requests use. A second run, or one after a crash midway, ends the same.
… may need a person

A run's details now list the branches a succeeded run kept and why, the
ones it deleted and the ones teamai doctor --fix still has to delete; for
a failed or cancelled run, from when doctor --fix removes them under
workflows.retention. The handoff panel tells steps that need a person now
from steps that may need one, and offers resume --claim for the latter.
…branches

It removes them all but the pull request branches; the time it may do so
now follows as its own label, which also reads right in Chinese.
…on, and doctor --fix

Show the branch list before and after a succeeded run, the retention
levels and their doctor output, what doctor --fix removes, the dashboard's
Branches and may-need-a-person rows, and the d duration unit.
…deletes

A succeeded run deletes the step branches a kept branch holds, so these
tests read the commit the run recorded instead of the branch name, and
expect only the kept branches on origin.
…engine's done

The resolution for Tencent#1689 keeps `next` unchanged, so the engine's `done` no
longer carries `branch`. `runCopyToMerge` derives it from a succeeded run's
file: `workflow start`/`resume` read it to print the `git merge` line, and the
skill driver gets it from the run file it already reads at D16 and still puts
it on its own `done` action.

The CLI tests for a succeeded and a failed header-copy run and the skill
transition tests for D16 pass unchanged.
…e CLI

The CLI git conformance wrote only the scenario's own workflow, so the two
scenarios that run review-and-fix from another workflow could not start. It
now writes `scenario.workflows` into the team repo, checks the copies the run
records and holds on origin, and, for the local driver, that `workflow resume`
names the run's copy branch and its `git merge` line only when the scenario
expects one.

Before: 6 failed, 27 passed. After, filtered to the header-copy scenarios and
one other: 12 passed.
… no workspace

Tencent#1689 reports review-and-fix whose `fix` prompt sets no `workspace`. The
conformance copy used a command with `workspace: continue`, which never
exercised a writing step inheriting the run's copy. `fix` is now that prompt.

A git conformance prompt is a shell command the scenario's agent runs in the
step's place: the in-process local driver gets an adapter that does so, the
protocol driver runs a prepared prompt lease the same way, and the CLI runner
puts a fake `claude` on PATH that runs its `-p` text.

Before the runners could run it, every profile failed with the lease shown:
`fix` leased `continue` on `teamai/<run>/_run` standalone, on `change/p1`
nested, and on `check/p1` under a step with no copy, so the engine needed no
change. In-process and CLI: 9 passed for the three header-copy scenarios.
… on origin only

A branch the host had checked out was deleted on origin but kept here, so
the cleanup ledger did not list it, and publishing still asked origin for
it. The ledger cannot answer this, so publishing a succeeded run now goes by
what cleanup guarantees: a missing branch passes when a branch still on
origin contains its recorded commit.
@hz89Dev

hz89Dev commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Confirmed and fixed in 74673bb.

This finding showed that the cleanup ledger is the wrong source for this rule. A branch deleted on origin but kept locally (host worktree, or a local update-ref -d that failed) is not in leftovers.deleted. So I removed withoutCleanedUp and moved the rule into checkOrigin, which follows what cleanup guarantees instead of what it recorded.

  • When a succeeded run is published, a recorded branch missing on origin passes if a branch of the run still on origin contains its commit (merge-base --is-ancestor, in heldOnOrigin).
  • Cleanup deletes only such branches, and a retry brings them back from run.copies.
  • The base pin is still pinned again on publish, and the claim side is unchanged.
  • Running runs are unaffected. When the publishing checkout lacks the objects needed for the comparison, the publish is still refused with commit_missing.

Tests:

  • The host-worktree test now also publishes the run after cleanup. It fails without this change.
  • The earlier claim-and-retry test still passes.
  • vitest run --changed HEAD: 541 files passed.
  • The built-CLI publish of a never-published, cleaned-up run still exits 0.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

No new findings I’m confident are real in the current diff.

  • Earlier findings: Both cleanup-related publication failures are resolved, including origin-only deletions with host-managed worktrees.
  • Testing: The PR description documents sufficient built real-CLI verification. One provider/agent combination suffices; the others are explicitly deferred to CI.

I only read the diff; I ran, built, and installed nothing from the PR.

…nothing to clean up

The end of every run took the run's cleanup lock before it checked that the
run succeeded. A retry right after cancelling a run could meet the driver
finishing the cancelled run inside that lock and answer busy. The checks now
run before the lock as well, and again under it.
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
  • [P2 non-blocking] Include host-retained branches in the Branches summary — src/workflow/leftovers.ts:167: In the added host-worktree left → join scenario, cleanup preserves local left/p1 but excludes it from deleted without adding it to kept or failed. Since settledBranches returns this recorded summary, the dashboard omits a branch that still exists. Record host-retained branches as kept, with the appropriate reason.

Earlier findings: Both cleanup-related publication failures are resolved, including origin-only deletions with host-managed worktrees.

Testing: The PR description provides sufficient built real-CLI verification. One provider/agent combination suffices; the others are explicitly deferred to CI.

I only read the diff and trusted base review criteria; I ran, built, and installed nothing from the PR.

…succeeded run kept

Cleanup deletes such a branch on origin and leaves it in the checkout, but
recorded it nowhere, so the dashboard's Branches left out a branch that
still exists. It is now kept, as checked out by the host.
@hz89Dev

hz89Dev commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Fixed in da2ba52.

deleteBranches now returns the branches it left because the host has them checked out. A succeeded run records each one in leftovers.kept with a new reason, host, which the dashboard shows as "Checked out by the host" (zh-CN: "宿主已检出"). The branch is still deleted on origin, and a retention sweep handles it as before.

The host-worktree test now expects { branch: left/p1, why: 'host' } in kept. It failed before this change and passes now. vitest run --changed HEAD: 622 files passed.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
  • [P2 non-blocking] Preserve host-retained branches in retention summaries — src/workflow/leftovers.ts:617: After retention expires, removeRun preserves a branch checked out in a host-managed worktree but discards deleteBranches’s hostKept result. The replacement leftovers summary therefore omits a branch that still exists locally. Carry these branches into kept with reason host.

Earlier findings: Both cleanup-related publication failures and the success-cleanup Branches omission are resolved.

Testing: The PR description documents sufficient built real-CLI verification. One provider/agent combination suffices; the others are explicitly deferred to CI.

I only read the specified diff and trusted base review criteria; I ran, built, and installed nothing from the PR.

@SaulMoro

SaulMoro commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

@hz89Dev, the cleanup and publish fixes look good. The one thing still holding my approval is the CHANGELOG entry from my review. An existing team meets five changes on upgrade:

  • run branches deleted after a run succeeds;
  • failed runs' worktrees removed after 14 days;
  • an unattended person step exiting 0 with handoff instead of 1 with hitl_required;
  • run_expired on a late retry;
  • pull rejecting a pr read on a step without deliver: pr.

Please add a bullet per group in [Unreleased] plus a "Changed" entry that names those five. Once that is in and CI is green, I'll approve and merge.

…ctor --fix kept

Past workflows.retention, doctor --fix deletes such a branch on origin and
leaves it in the checkout, but recorded only pull request branches as kept,
so the run's Branches left it out. It is now kept, as checked out by the host.
@hz89Dev

hz89Dev commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Fixed in cdc4d49.

removeRun now returns kept with reasons: pr for the branches it keeps, and host for the ones deleteBranches left because the host has them checked out. The retention summary records them as returned, so the run's Branches lists the branch as "Checked out by the host", the same as after a success cleanup.

New test: "lists a branch the host keeps checked out among what it kept, past the retention". A failed run's branch is checked out in a host worktree, and the run is swept at +14d. The test expects the branch deleted on origin, still present locally, and recorded as { why: 'host' }. It failed before this change and passes now. vitest run --changed HEAD: 541 files passed.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

No new findings I’m confident are real in the current diff.

  • Earlier findings: All are resolved, including both cleanup-related publication failures and host-retained branch omissions in success and retention summaries.
  • Testing: The PR description provides sufficient built real-CLI verification. One provider/agent combination suffices; the others are explicitly deferred to CI.

I only read the specified diff and trusted base review criteria. I ran, built, and installed nothing from the PR.

@hz89Dev

hz89Dev commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

The Windows failure on cdc4d49 is a timeout, and this PR doesn't touch the code involved. resolveCliPath on Windows > prefers the .cmd sibling… returned null after 5,189 ms. That is just past CLI_DETECT_TIMEOUT_MS (5,000 ms), so where timed out on the runner. This PR doesn't change src/utils/cli-path.ts or that test, and the same job passed on main at f49b6cb. I can't rerun jobs here; could a maintainer rerun "Windows (paths, hook rendering, hook shells)"?

@SaulMoro

SaulMoro commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Agreed: resolveCliPath returned null at 5,189 ms, just past CLI_DETECT_TIMEOUT_MS, and this PR does not touch src/utils/cli-path.ts or its test. I will rerun the Windows job once the rest of the run finishes; GitHub refuses a job rerun while its run is still in progress.

@SaulMoro

SaulMoro commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

@hz89Dev #1700 is merged (8ab9a2a), so this branch now conflicts with main. When you rebase, please add the CHANGELOG entry too. I will re-review the conflict resolutions and the Windows job on the new head, and approve and merge once it holds.

# Conflicts:
#	docs/dev/workflow-engine.md
#	docs/guide/dashboard.md
#	docs/guide/zh-CN/dashboard.md
#	oxlint-plugin-teamai/failure-codes.js
#	skill-data/workflow/SKILL.md
#	src/__tests__/score-drain.test.ts
#	src/__tests__/workflow-expression.test.ts
#	src/__tests__/workflow-skill-transitions.test.ts
#	src/dashboard/client.ts
#	src/dashboard/locales.ts
#	src/dashboard/workflow-runs.ts
#	src/session-flow/session-publish.ts
#	src/workflow-commands.ts
#	src/workflow/describe.ts
#	src/workflow/drivers/local/local-driver.ts
#	src/workflow/drivers/skill/preflight.ts
#	src/workflow/drivers/skill/skill-state.ts
#	src/workflow/drivers/skill/tick.ts
#	src/workflow/drivers/skill/transitions.ts
#	src/workflow/drivers/skill/turn.ts
#	src/workflow/engine.ts
#	src/workflow/expression.ts
#	src/workflow/handoff.ts
#	src/workflow/parse.ts
#	src/workflow/protocol.ts
#	src/workflow/run-controls.ts
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

No new findings I’m confident are real in the specified diff.

  • Earlier findings: All are resolved, including both cleanup-related publication failures and host-retained branch omissions in success and retention summaries.
  • Testing: The PR description documents sufficient built real-CLI verification. One provider/agent combination suffices; the others are explicitly deferred to CI.

I only read the specified diff and trusted base review criteria. I ran, built, and installed nothing from the PR.

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

This was generated by AI during triage.

I checked the merge of main (549900e). Nothing from either side is lost.

  • #1700: the kept-patch queue, confined steps, private, continue_on_failure, $TEAMAI_RUN_DIR and the three-argument retryContainers are intact.
  • This PR: workspace: new, the person-step handoff and resume --next, success cleanup, the retention sweep and steps.<id>.pr are intact.

On a build of this head I reran my earlier fixtures. The handoff and the doctor --fix sweep behave as before. A run that was never published now publishes after cleanup with exit 0, where ab622df exited 1 with commit_missing. A scored step on the local driver still goes through one teamai-score run, with one judge launch and the label written.

Two things are left:

[P2 non-blocking] The CHANGELOG entry for the breaking change is still missing, and it is the only thing holding my approval. Please add a bullet per group under [Unreleased], plus a "Changed" entry naming the five upgrade-visible changes from my review.

[P3 nit] docs/dev/workflow-engine.md:25 still says the run is offered back at "(D28)". Main took D28 and D29, and this PR's rows moved to D30–D32, so that should read D30.

I agree with the CI review that the earlier findings are resolved, but it does not cover the CHANGELOG or the merge. CI was still running at this head.

…e the hand-off row D30

One bullet per part of the change, and a Changed entry with the five things
an existing team runs into on upgrade, before teamai starts deleting run
branches. The engine notes still named the hand-off row by its number before
the merge of main.
@hz89Dev

hz89Dev commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

@SaulMoro both are in 202f791.

  • CHANGELOG: four bullets under [Unreleased] → Features, one per group: workspace: new in the header, the runner hand-off, branch cleanup and workflows.retention, and steps.<id>.pr together with the two output notes. A Changed entry names the five upgrade-visible changes from your review, including the CI exit code moving from 1 (hitl_required) to 0 (handoff).
  • D30: docs/dev/workflow-engine.md:25 now names the hand-off row D30.

Sorry for answering this late: I acted on the CI review and missed your review until now.

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

This was generated by AI during triage.

Approving at 202f791.

Since 549900e this head changes only CHANGELOG.md and one word in docs/dev/workflow-engine.md, and both close what my last comment left open:

  • CHANGELOG: four Features bullets, one per group of #1689, and a Changed entry that lists the five things an upgrade changes for a team, including the hitl_required exit 1 that becomes a handoff exit 0 for CI jobs. That was the part I most wanted written down.
  • D28 → D30: the skill-driver hand-off paragraph now names the right decision row.

No runtime code moved, so the real-CLI record from the earlier rounds still covers this head. The CI review of 549900e raised nothing we had not already resolved. The Codex review of this head is still running, and I'll read it before merging.

[P3 nit] The four new Features bullets sit after a blank line, apart from the existing bullets, so some renderers will show them as a separate list. Optional.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

No new findings I’m confident are real in the specified diff.

  • Earlier findings: All are resolved, including both cleanup-related publication failures and host-retained branch omissions in success and retention summaries.
  • Testing: The PR description documents sufficient built real-CLI verification. One provider/agent combination suffices; the others are explicitly deferred to CI.

I only read the specified diff and trusted base review criteria. I ran, built, and installed nothing from the PR.

@hz89Dev

hz89Dev commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. I'm leaving the blank line before the four Features bullets as it is, so this head doesn't start another CI run and Codex review. If you'd rather have it fixed before merging, I'll push the one-line change.

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.

workflow: design gaps found running a software factory end to end

3 participants