Skip to content

fix(workflow): three role fixes from #1668's review: command-first clones, named workflows, members.yaml - #1672

Merged
SaulMoro merged 7 commits into
Tencent:mainfrom
hz89Dev:fix/workflow-step-role-review
Nov 2, 2026
Merged

SaulMoro merged 7 commits into
Tencent:mainfrom
hz89Dev:fix/workflow-step-role-review

Conversation

@hz89Dev

@hz89Dev hz89Dev commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

#1668 merged before three findings from its review were fixed. Each makes a role workflow fail, or run with roles other than the ones it names:

Workflow Before After
A role: review clone whose first step is command: npm ci, for a member with Claude and Hermes enabled The clone fails role_unavailable: Hermes takes its skills from ~/.hermes/skills The clone opens. A later step on Claude runs with the role. One on Hermes, under a driver with can.role that launches it, fails role_unavailable; --driver local without Hermes on PATH fails it tool_unavailable first
A pinned clone runs workflow: look, whose continuing step names the clone's role old-review, since renamed Sync refuses look with bad_role Cached: the clone's setup checks the role at the revision it pins
A clone whose team.selection names primaryRole: review, while manifest/members.yaml at its revision assigns the member audit Installs audit, and nothing says so Fails clone_prepare_failed, saying to drop the roles from the selection, and to give the step role: review for that role's knowledge. A benchmark arm, whose selection holds the member's roles at start, is told to run on a revision whose members.yaml assigns the same ones

Where a clone's role is checked:

 preparePlace, clone
   installTeam: the step that opens the clone
+    members.yaml at the clone's revision assigns the roles the selection names?   else clone_prepare_failed
-    roleCopyRefusal for every tool the install delivers to
+    roleCopyRefusal for the tools that step launches (a command: the docs only)
     child `teamai pull --team-ref <rev>`
-    cloneRoleProblem for every tool the install delivers to
+    cloneRoleProblem for the tools that step launches
+  a later step in the clone, as it is prepared
+    cloneRoleProblem for the tools it launches: roleCopyRefusal, then the record's delivery
 local driver, before launch
   cloneRoleProblem for the launched tool (now with roleCopyRefusal)

And at sync:

 roleDiagnostics: a step that continues a copy no step in this file opens
-  check its role and the defaults.role it takes against the roles.yaml pulled now
+  another workflow this sync settles runs the file by name (WorkflowFiles.isRunByName)?
+    leave them to that file, whose walk sees the copy, and to the lease
+  else
+    check them against the roles.yaml pulled now, as before
 roleDiagnostics: a step continuing a copy with a role other than the copy's
   "remove role from step X, or set it on step Y"
+    " once manifest/roles.yaml declares <role>, which it does not: it declares …", when it does not

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

Test Plan

  • npx tsc --noEmit passes (npm run typecheck)
  • npm run lint passes, including the docs checks
  • npx vitest run passes: 687 files, 21454 tests, 24 skipped
  • Added/updated tests for the change

Each new test failed before its fix, for the reason it names:

Test Failed before with
workflow-clone-place: prepares a clone that runs with a role for the command step that opens it, though the member enables Hermes role_unavailable: hermes takes its skills from <home>/.hermes/skills
workflow-clone-place: fails a later step in a clone that runs with a role when that step launches Hermes a lease: the step was prepared with no check
workflow-cache: caches a workflow a pinned clone runs by name, whose step continues the clone with its role, by its own role or its defaults.role bad_role on look.yaml and defaulted-look.yaml
workflow-clone-place: fails a clone whose team selection names a role members.yaml at the clone's revision does not assign the member the clone's own pull ran
workflow-cache: refuses a role the team pulled now does not declare on a step that continues a copy no step opens, in a file no workflow runs by name look cached, no diagnostic
workflow-parse: says to declare a role manifest/roles.yaml does not declare before setting it on the step that opens the copy the message ended at or set it on step "change"
e2e benchmark-team-arms: fails an arm on a team revision whose manifest/members.yaml assigns the member other roles than the ones they run with new: the arm path had no test; asserts trial error and the step's clone_prepare_failed message

npm run test:e2e -- workflow-clone-role workflow-worktree-role workflow-container-role workflow-item-role benchmark-team-arms score-delivered-run-1247: 6 files, 24 tests pass at fb82153d. At a5f7e4cc only the new benchmark-team-arms test was run locally; the rest of the e2e suite is left to CI. Codex, CodeBuddy and OpenCode, and the gitlab and github providers: left to CI.

Real-CLI verification

Built from this branch at fb82153d (npm run build) and run on 2026-11-02 with Claude Code 2.1.316, macOS and Node 24.21.0, in a throwaway HOME with local bare team.git and billing.git origins. The member holds frontend and enables claude and hermes. The team declares review with the rv-only skill.

steps:
  - id: review
    role: review
    workspace:
      clone:
        commit: 8fc1b669…
        team: { revision: 872cf47c…, selection: { additionalRoles: [], projects: [], excludedSkills: [] }, treatment: pulled }
    workflow:
      steps:
        - { id: test, workspace: continue, command: npm test }
        - { id: look, needs: [test], workspace: continue, permissions: unattended, prompt: Read src/customers.js and write your findings to REVIEW.md. }
$ teamai workflow start clone-review --driver local --sandbox
{"data":{"done":{"run":"r7a23bdbf37d5676e","outcome":"succeeded","record":"published"},"cancelled":[]}}
$ jq -r '.steps[] | "\(.id) \(.status) \(.agent.team.selection.stepRole // "-")"' <dataHome>/workflows/runs/r7a23bdbf37d5676e.json
review succeeded -
review.test succeeded -
review.look succeeded review
$ ls ~/.hermes/skills
fe-only  teamai  teamai-session-to-task  teamai-share-session

Before this branch, the same workflow failed its first step: role_unavailable, hermes takes its skills from ~/.hermes/skills.

95995fd0, after this run, changes only the text of the members.yaml refusal.

SaulMoro's check of rows 2 and 3, at 95995fd0 (built CLI; the claude and hermes tools are stand-ins that log the copy they run in). Builds: main 813559197 and 95995fd0, each npm run build. Setup: isolated HOME, local bare team and app origins through insteadOf, init --provider git --agent claude,hermes --scope workspace, workflows.sandbox: false, max_parallel: 1, workflow start <name> --driver local.

Row 2 (pinned clone runs the named workflow `look`; its step names the role `old-review`, renamed at HEAD):
- main: `pull` warns that look.yaml has role old-review, which manifest/roles.yaml does not declare; `workflow start` exits 1 (workflow_not_found).
- 95995fd0: `pull` is silent; `workflow start` exits 0; the clone's step runs with old-review as the pinned revision declares it.
  When the pinned revision does not declare old-review: exits 1, role_unavailable on the step.

Row 3 (team selection primaryRole review; members.yaml at the pinned revision assigns audit):
- main: `workflow start` exits 0; the clone installs audit and the review skill is absent.
- 95995fd0: exits 1, clone_prepare_failed, which names the audit assignment at the pinned revision.
  Remove primaryRole and additionalRoles from the selection: exits 0.
  Keep the selection and add `role: review` to the step: exits 1, the same error.
  Remove the selection and add `role: review`: exits 0, and the review skill is in the copy.

At a5f7e4cc (npm run build), in the same throwaway HOME, with a team file lone-look.yaml whose only step continues a copy with role: old-review and that no workflow runs:

$ teamai pull
⚠ [workflows] workflows/lone-look.yaml:6: field "steps[0].role": step "look" has role old-review, which manifest/roles.yaml does not declare; add it there, or name a role it declares: frontend, review, spec
⚠ [workflows] workflows/lone-look.yaml has no runnable version
$ teamai workflow start lone-look
{"error":{"code":"workflow_not_found","message":"Workflow \"lone-look\" has no runnable version. Check workflows/lone-look.yaml and pull again."}}

At 95995fd0 the same pull was silent and start failed workspace_base. The new benchmark-team-arms e2e runs the built CLI for the arm case.

Related Issues

Follow-up to #1668: the CI review's P1 and P2, and members.yaml overriding a clone's recorded roles, which #1668 left as pre-existing.

Notes for Reviewers

  • members.yaml still decides a member's roles. The clone refuses a selection the file overrides instead of honoring it, so a workflow cannot give a step the hooks, MCP servers or env of a role the member does not hold. For a role's knowledge, role: on the step does that. A benchmark arm records the member's assigned roles, so the same member at the same revision passes. An arm pinned to a revision whose members.yaml assigned the member other roles now fails rather than run with them, and the refusal says to run the arm on a revision that assigns the same ones; the e2e covers it.
  • A later step in a role clone is checked as it is prepared, for any driver that prepares it, not only before the local driver launches it, as a worktree step already is.
  • Merge danger:
    • Door: two-way. No file format or record changes.
    • Blast radius: role clones and clone selections. A clone that installed the roles members.yaml assigns, while its selection named others, now fails.

…nches

A clone that runs with a role checked, as its first step was prepared,
that every tool its install delivers to takes the role's knowledge
inside the clone. A command step that opens the clone names no tool, so
the check covered every tool the member enables, and a member with
Hermes, which takes skills from their home, could not run a role
workflow that starts with `npm ci` in a clone.

The clone's setup now checks the tools the step that opens it launches,
none for a command, as a worktree copy does. Each later step in the
clone is checked as it is prepared, for the tools it launches, so a
later step on Hermes fails role_unavailable rather than run without the
role.
A workflow file whose steps continue a copy a step running it opens was
checked on its own, as if that copy ran with the team pulled now. A
continuing step that named a pinned clone's role, or took it from the
file's defaults.role, was refused with bad_role once the team renamed
the role, though the clone checks it at its own revision.

Such a file now leaves the role to the file that runs it, whose walk
sees the copy: a pinned clone's setup checks the role at its revision,
a copy of the team pulled now is checked against its manifest, and a
role other than the copy's is a conflict there. The lease checks it
again.
…errides

A clone writes its team selection's primaryRole and additionalRoles as
its install's own, and every load in the clone then applies
manifest/members.yaml at the clone's revision, which decides a
member's roles while it exists. A selection naming other roles
installed the assigned ones instead, and nothing said so.

The clone's setup now resolves the roles that file assigns before the
clone's own pull, and fails clone_prepare_failed when they differ from
the ones the selection names, saying how to run as that role's
knowledge instead. members.yaml still decides the roles, so a workflow
cannot give a step the hooks, MCP servers or env of a role the member
does not hold.
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
  • [P2 non-blocking] Correct the suggested role: workaround — src/workflow/place/clone.ts:520: The error suggests adding role: review as an alternative to removing conflicting selection roles, but assignedOverSelection rejects the selection before inspecting lease.role. Adding the suggested role therefore produces the same failure. Clarify that using role: also requires removing the conflicting selection roles, and update both guide translations.

The PR description documents sufficient testing, including a representative real-CLI run at the reviewed head. No testing-related blocking finding. Nothing from the PR was run, built, or installed.

…n's roles removed even with role:

The refusal offered role: on the step as an alternative to removing the
selection's roles, but the selection is checked first, so adding role:
alone fails the same way.
@hz89Dev

hz89Dev commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Fixed in 95995fd0. The selection is checked before the step's role, so role: alone fails the same way. The message now says to remove the selection's roles, and to also give the step role: review for that role's knowledge:

… Remove primaryRole and additionalRoles from the selection to install the roles it assigns, and to run the step with review's knowledge, also give it role: review.

Both guide pages now say the same: leave the roles out, and also set role for a role's knowledge. The workflow-clone-place test asserts the new message. It failed against the old message before the fix.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

No new findings in the scoped diff.

  • Resolved: The earlier [P2 non-blocking] workaround finding is fixed. The refusal text and both guide translations now explain that conflicting selection roles must be removed before also setting role: review.
  • Testing: The PR description documents sufficient testing, including a representative real-CLI run at fb82153d. It states that the subsequent head changes only refusal wording; no testing-related blocking finding.
  • Nothing from the PR was run, built, or installed.

@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. I built main (8135591) and this head and checked all three rows on an isolated home. The body's real-CLI record covers row 1 only, so here is a record for rows 2 and 3 you can paste in:

Real-CLI check of rows 2 and 3 (built CLI; the claude and hermes tools are stand-ins that log the copy they run in).
Builds: main 813559197 and 95995fd0, each `npm run build`. Setup: isolated HOME, local bare team and app origins through insteadOf,
`init --provider git --agent claude,hermes --scope workspace`, `workflows.sandbox: false`, `max_parallel: 1`, `workflow start <name> --driver local`.

Row 2 (pinned clone runs the named workflow `look`; its step names the role `old-review`, renamed at HEAD):
- main: `pull` warns that look.yaml has role old-review, which manifest/roles.yaml does not declare; `workflow start` exits 1 (workflow_not_found).
- 95995fd0: `pull` is silent; `workflow start` exits 0; the clone's step runs with old-review as the pinned revision declares it.
  When the pinned revision does not declare old-review: exits 1, role_unavailable on the step.

Row 3 (team selection primaryRole review; members.yaml at the pinned revision assigns audit):
- main: `workflow start` exits 0; the clone installs audit and the review skill is absent.
- 95995fd0: exits 1, clone_prepare_failed, which names the audit assignment at the pinned revision.
  Remove primaryRole and additionalRoles from the selection: exits 0.
  Keep the selection and add `role: review` to the step: exits 1, the same error.
  Remove the selection and add `role: review`: exits 0, and the review skill is in the copy.

The refusal text from 95995fd fixes the CI review's point: following its advice now works.

[P2 non-blocking] A top-level continuing step with an undeclared role no longer fails at pull

On main, pull warns bad_role. Here pull is silent and workflow start fails with workspace_base ("continues a workspace, but no enclosing step opens one"). Nothing runs, so this is safe. But docs/guide/workflow-advanced.md line 539 (and the zh-CN page) still says pull refuses this as bad_role. The cause is the enclosing_copy branch in parse-roles.ts: it skips ownRoleDeclared for every continuing step with no known copy, including steps in files no other workflow runs. Keeping the current-team check for those, and the caller's-copy check only for named sub-workflows, would keep the pull warning.

[P2 non-blocking] Benchmark arms pinned to an older revision now refuse, with no test

Plan selection now applies to every pulled and ref clone arm (start.ts:197,496, plan.ts:394). An arm pinned to a revision whose members.yaml assigns the member differently now fails clone_prepare_failed. The body and the guide disclose this, but benchmark-team-arms.test.ts never writes members.yaml, so nothing covers it.

[P3 nit] Smaller points

  • The sub-workflow message's second option ("set it on step outer") works only when the role is declared; with the same undeclared role pull still fails bad_role. The message could say so.
  • The body says a Hermes step fails role_unavailable. On --driver local it fails tool_unavailable first ("the driver of this run cannot launch here"). Say which driver that row describes.
  • The members.yaml item came from your comment on #1668, not from a maintainer review's P3.

…ng step no workflow runs by name

A step that continues a copy no step in its file opens left its role to
the workflow running the file, even in a file no workflow runs by name.
Pull then cached it silently, though it can only run with the team
pulled now. The sync now tells the parse whether another workflow runs
the file by name, and checks the role against the current
manifest/roles.yaml when none does.
…at opens the copy

A step continuing a copy with another role was told to set its role on
the step that opens the copy. When manifest/roles.yaml does not declare
that role, doing so fails pull again; the message now says so, and lists
the roles the manifest declares.
…ion assigns other roles

An arm's clone takes its selection from the member's roles as the run
starts, so the refusal's advice to edit the selection did not apply to
it. The refusal now says to run the arm on a team revision whose
manifest/members.yaml assigns the same roles, and the arm case is
covered end to end.
@hz89Dev

hz89Dev commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Each point is addressed, and your record for rows 2 and 3 is in the body:

  • [P2] A top-level continuing step's undeclared role (3066d70e): the sync now tells the parse whether another workflow it settles runs the file by name (WorkflowFiles.isRunByName). When none does, such a step's role is checked against the roles.yaml pulled now, as on main. Pull warns bad_role again, and workflow start says workflow_not_found (real-CLI output in the body). A file that a pinned clone runs by name is still left to that workflow, so row 2 holds. One limit: a file run only as a workflow: { from: … } output is not known at sync, so it gets the current-team check.
  • [P2] Benchmark arms on an older revision (a5f7e4cc): benchmark-team-arms now has "fails an arm on a team revision whose manifest/members.yaml assigns the member other roles than the ones they run with". The now arm passes, before ends error, and trials.r1.fix.before.prompt fails clone_prepare_failed. Writing the test showed the refusal's advice did not fit an arm, because the plan writes the selection from the member's roles at start. The message now adds: "A benchmark writes the selection from your roles as the run starts, so run its arm on a team revision whose manifest/members.yaml assigns you the same ones."
  • [P3] The sub-workflow message (bd0d164d): when the team pulled now does not declare the role, the second option now ends "once manifest/roles.yaml declares audit, which it does not: it declares review". Where the copy is a pinned clone it is unchanged, because the clone checks its own revision.
  • [P3] Body: the Hermes row now names the driver: a driver with can.role that launches Hermes gets role_unavailable, and --driver local without Hermes on PATH gets tool_unavailable first. Related Issues now credits the members.yaml item to my own note on feat(workflow): run a step as a team role, and link every result to the harness that produced it #1668.

Each new test failed first for the reason it names. Unit suite: 687 files, 21454 tests. The rest of the e2e suite is left to CI.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

No new findings in the scoped diff.

  • Resolved: The earlier [P2 non-blocking] workaround finding is fixed in the refusal text and both guide translations.
  • Testing: The PR description documents sufficient testing, including a representative real-CLI run at fb82153d. The record predates the reviewed head, but that alone is not blocking under the trusted review rules.
  • Nothing from the PR was run, built, or installed.

@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 again at a5f7e4c. I built it and re-ran the fixtures from my last review:

Top-level continuing step with an undeclared role:
  pull: steps[0].role: step "look" has role nope, which manifest/roles.yaml does not declare  (refused at pull again, as on main)
Sub-workflow whose continuing step has an undeclared role:
  pull: ... remove role from step "look", or set it on step "outer" once manifest/roles.yaml declares nope, which it does not: it declares frontend, review
Row 2 (pinned clone, named workflow, role renamed at HEAD): succeeds; the copy has rv-only and the review rule.

The undeclared-role case is refused at pull again, so docs/guide/workflow-advanced.md line 539 is accurate again. The sub-workflow message now says the role must be declared first. The new benchmark-team-arms case covers an arm pinned to a revision whose members.yaml assigns other roles. That covers all three of my notes.

@SaulMoro
SaulMoro merged commit fdbe061 into Tencent:main Nov 2, 2026
18 checks passed
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.

3 participants