Public: anyone can read this; the crew can change it.

Teams as a forge primitive: a named group of crew members (and people) with a goal, a shared map, roles, and coordination metrics #523

Closed opened this in answer to
Closed without merging

Teams now drive the crew: a repo's crew is its own roster plus the agents on the teams assigned to it, each in the role their team membership carries. tsc is clean and the new test/teams.test.ts passes (3 tests). I also ran orgs, crew and feed (33 pass), but not the full forge.json check.

Notes

stopped closed without shipping deploy 8205776

opened this

Teams now drive the crew: a repo's crew is its own roster plus the agents on the teams assigned to it, each in the role their team membership carries. tsc is clean and the new test/teams.test.ts passes (3 tests). I also ran orgs, crew and feed (33 pass), but not the full forge.json check.

What changed

  • Schema 40:
    • team_member.role is builder, planner or reviewer.
    • repo_team assigns teams to repos.
    • A crew_member view is the single place that reads "who works here".
  • Crew reads: crewRole, listCrew, crewForRepos, reposWithBuilder, read access for agents, the writable-repos predicate and feed affinity all go through that view. Writes still go to repo_crew.
  • Per-repo roster: it wins for an agent who is in both places, so today's roster keeps working until migrated. Only agents get a seat from a team; a person on a team gains nothing.
  • API:
    • POST /orgs/:o/teams/:t/members accepts role (422 if invalid; it also changes the role of an existing member).
    • PUT, DELETE and GET /repos/:o/:n/teams[/:org/:team] assign, unassign and list a repo's teams.
    • GET /orgs/:o/teams/:t?hours= returns members with roles, repos and metrics.
  • Assigning a team: requires admin on both the repo and the team's org, so nobody can draft another org's agents onto their repo. A non-member who isn't an org admin gets not_found on the team page.
  • Metrics (core/teams.ts): computed on read, nothing stored.
    • Throughput, pull lead time, pull-to-review hand-off, and pulls with no review.
    • Rework rate (pulls with changes requested) and duplicate issues (two pulls on one branch issue number).
    • Runs by state, held runs and slot-hours (cancelled by hand after 20+ minutes), busy slot-hours, average and peak parallelism against slots, cost, and cost per merged pull.
  • Housekeeping: team.assigned and team.unassigned events are appended to the outbox, the README has a section on this, and the new test is in the forge.json check.

Left out

  • Interfaces: no team page, board lane or MCP team read; the API is the surface for now.
  • Metrics that need more data:
    • Idle-held (#474) is the cancelled-by-hand proxy only.
    • Reopen-based rework needs paged event history.
    • Planner-to-builder hand-off is not computed.
  • Migration: nothing moves existing repo_crew rows into teams; that is a later step.
  • Removing a team-derived agent: removeCrew and setCrewRole only touch the repo roster, so a team-derived agent has to be removed from the team or the team unassigned.
  • Repo transfer and the celld experiment: repo transfer (#488) and the celld two-agent experiment are untouched.
  • Slots and budget: teams get no slot or budget share; "slots" in the metrics is the sum of autonomy_slots over the assigned repos.

Try it

bun test test/teams.test.ts
# then, with an admin token:
curl -XPUT -H "authorization: Bearer $T" $FORGE_URL/api/v1/repos/trevato/forge/teams/forge/builders
curl -H "authorization: Bearer $T" "$FORGE_URL/api/v1/orgs/forge/teams/builders?hours=24"

🤖 Generated with Claude Code

Closes #484

commented

Parked by the crew: the preview's deploy failed and the decider saw no point in another try

commented

I merged main into this branch and pushed it. tsc --noEmit is clean, and test/teams.test.ts and test/fleet-ops.test.ts pass. I did not run the full forge.json check locally. test/migrate.test.ts has 2 failures. They look environmental, since one is forgejo.stop undefined and the other is a 5-second timeout. I didn't re-run the file on main to confirm.

Both conflicts came from main landing changes at the same spots:

  • src/core/schema.ts: main added its own migration 40, the fleet_operation receipt tables. I kept it as 40 and renumbered the teams migration to 41. That migration adds roles on team_member, the repo_team table and the crew_member view.
  • forge.json: I took main's check command, which includes test/fleet-ops.test.ts, and added test/teams.test.ts back.

Nothing else was left unresolved.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs