@nidvue/teamwork 1.1.2 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +326 -3
  2. package/README.md +80 -26
  3. package/package.json +1 -1
  4. package/skills/teamwork/AGENTS.md +57 -2
  5. package/skills/teamwork/SKILL.md +129 -25
  6. package/skills/teamwork/references/Adapters.md +4 -0
  7. package/skills/teamwork/references/Audit.md +3 -1
  8. package/skills/teamwork/references/Concurrency.md +22 -7
  9. package/skills/teamwork/references/Coordination.md +203 -0
  10. package/skills/teamwork/references/Dissent.md +10 -1
  11. package/skills/teamwork/references/Docs.md +3 -1
  12. package/skills/teamwork/references/Engineering.md +47 -8
  13. package/skills/teamwork/references/Evidence.md +18 -1
  14. package/skills/teamwork/references/Remotes.md +25 -7
  15. package/skills/teamwork/references/Roles.md +22 -4
  16. package/skills/teamwork/references/State.md +96 -12
  17. package/skills/teamwork/references/Testing.md +3 -1
  18. package/skills/teamwork/roles/ceo.md +50 -3
  19. package/skills/teamwork/roles/developer.md +8 -0
  20. package/skills/teamwork/roles/product-manager.md +4 -0
  21. package/skills/teamwork/roles/reviewer.md +97 -12
  22. package/skills/teamwork/scripts/check_release_consistency.py +1805 -0
  23. package/skills/teamwork/scripts/privacy_scan.py +105 -2
  24. package/skills/teamwork/src/teamwork/bundle.py +0 -7
  25. package/skills/teamwork/src/teamwork/config.py +53 -2
  26. package/skills/teamwork/src/teamwork/engine.py +2652 -385
  27. package/skills/teamwork/src/teamwork/gitutil.py +148 -10
  28. package/skills/teamwork/src/teamwork/harness.py +753 -0
  29. package/skills/teamwork/src/teamwork/hooks.py +400 -0
  30. package/skills/teamwork/src/teamwork/layout.py +10 -4
  31. package/skills/teamwork/src/teamwork/portable.py +6 -1
  32. package/skills/teamwork/src/teamwork/records.py +20 -0
  33. package/skills/teamwork/src/teamwork/resources.py +41 -7
  34. package/skills/teamwork/src/teamwork/version.py +1 -1
  35. package/skills/teamwork/templates/AGENTS.md +57 -2
@@ -82,16 +82,26 @@ settings are adapted (`references/Adapters.md`, `references/Remotes.md`).
82
82
  reads the runtime environment (the agent host and the model it exposes) and
83
83
  routes the strongest available model to the decision lanes and the economy one
84
84
  to the mechanical lanes, so quality is maximised where it compounds and cost is
85
- minimised where it does not. Model choice never changes the
85
+ minimised where it does not. This is cost-aware routing, never an invented
86
+ model id. Set `TEAMWORK_MODEL_ALT` when two verification lanes are staffed:
87
+ independent review on the same model twice is one check sampled twice
88
+ (`references/Coordination.md`). Model choice never changes the
86
89
  protocol: the gates, the review and the ledger hold anyway.
87
- The CEO sets the lanes in one step with `teamwork.py model auto --apply`, which
88
- detects the running agent host where the environment identifies it and routes
89
- the strongest available model to the decision lanes and the economy model to
90
- the mechanical lanes - automatic cost-aware routing, never an invented model id.
91
90
  13. **Warnings are errors.** The toolchain fails on them by configuration, the
92
91
  cause is fixed, and a third-party warning is suppressed narrowly with a
93
92
  reason. CI annotations (a deprecated action, a cache notice, a runner banner)
94
93
  count as warnings and are fixed, not ignored.
94
+ 14. **Independence is structural.** Verification lanes do not share a model when
95
+ a second one is available; a Reviewer records its own run, never the author's
96
+ line copied; one task owns one branch; a duplicate task, branch or shared
97
+ reference is a defect, not parallel efficiency.
98
+ 15. **No lane wars.** Never deny a peer a resource - no killing its process,
99
+ deleting its worktree, starving its lease or overwriting its files. A
100
+ conflicting directive is resolved by a measurable contest or by the CEO, never
101
+ by force. `reclaim` refuses a lane that still holds a live slot.
102
+ 16. **Consensus is not evidence.** A single source is provisional, a unanimous
103
+ zero-finding run is sampled, and lowering a gate so the team can agree is
104
+ collusion. Trust is conditional and recorded (`references/Coordination.md`).
95
105
 
96
106
  ## The org
97
107
 
@@ -144,12 +154,12 @@ default; `--agents` overrides it for a roster you name exactly.
144
154
 
145
155
  | Tier | Instances | Startup read |
146
156
  |---|---|---|
147
- | `slim` (default) | 6 | 226 kB |
148
- | `standard` | 9 | 336 kB |
149
- | `full` | 16 | 586 kB |
157
+ | `slim` (default) | 6 | 263 kB |
158
+ | `standard` | 9 | 384 kB |
159
+ | `full` | 16 | 660 kB |
150
160
 
151
161
  Startup read = every instance's `AGENTS.md` plus its own role charter, summed -
152
- the text a full roster pays for before any work starts, and 2.6x what `slim` costs.
162
+ the text a full roster pays for before any work starts, and 2.5x what `slim` costs.
153
163
 
154
164
  A role earns a seat only if it owns a deliverable, a test layer and a decision
155
165
  right no other role holds. Everything else is a **lane, not a role**: it costs no
@@ -184,7 +194,10 @@ Two rules keep a slim roster honest, and both are enforced:
184
194
  `init` prints the folded lanes and warns when a gate-critical role is missing.
185
195
  Scale writers with the critical path: add `developer-N`/`tester-N` before adding a
186
196
  coordination role. **The Reviewer is not optional**, and two Reviewer lanes are the
187
- minimum - one verifies, a different one merges.
197
+ minimum: the review queue fans one deliverable per lane, a re-submitted fix is
198
+ reviewed from scratch, and a second lane gives a sampled or high-risk deliverable
199
+ an independent verdict. A pass merges - the lane that verified the revision lands
200
+ it.
188
201
 
189
202
  ## Workspace layout
190
203
 
@@ -221,7 +234,7 @@ is committed. All team-created names are **PascalCase**.
221
234
  │ └── Artifacts/ Reports/ Scratch/
222
235
  └── Runtime/ # ephemeral
223
236
  ├── LedgerHead.json # fast-path checkpoint for the chain
224
- ├── Locks/ # per-file and per-role locks
237
+ ├── Locks/ # per-file and per-role locks; memory-<Role>.claim
225
238
  ├── Worktrees/<Instance>/ # created by `branch start --worktree`
226
239
  └── Slots/<Provider>/<Agent>.slot
227
240
  ```
@@ -234,6 +247,19 @@ and `Developer-2` read and write one `Roles/Developer/` memory and claim from on
234
247
  `Roles/Developer/TaskQueue.md`. `Role.md` is per role; only `StartHere.md`, `WorkLog.md`, `Inbox.md`,
235
248
  `Artifacts/`, `Reports/` and `Scratch/` are private to an instance.
236
249
 
250
+ **Any role scales, and one instance at a time holds its memory pen.**
251
+ `instance add <role> --count N` runs a second (third, fourth) instance of *any*
252
+ role - CTO, Architect, Product Manager, whoever the brief needs - against the same
253
+ shared memory and queue. Only one instance of a role may revise that memory at a
254
+ time: `memory claim <role> --by <instance>` takes the pen for a multi-entry update
255
+ and `memory release` gives it back, a single `remember` takes it only for its own
256
+ duration, and every other instance of that role is read-only meanwhile (reads and
257
+ `recall` always work). A dead holder's lease expires, and `memory status` shows who
258
+ holds which role now. **A lease that runs long is contested, not waited out**: a
259
+ peer of the role runs `memory contest <role> --by <instance> --reason '<why>'`,
260
+ which puts a `P0` case on the arbiter's queue, and the **CTO** rules - more time
261
+ (`memory extend`) or the lock removed (`memory revoke`) - on the record.
262
+
237
263
  ## Bootstrap procedure (CEO)
238
264
 
239
265
  Run these in order. Use `SKILL` for this skill's directory.
@@ -394,7 +420,8 @@ reports STOP.
394
420
  python3 "$SKILL/scripts/teamwork.py" criteria list # are the goals actually met?
395
421
  python3 "$SKILL/scripts/teamwork.py" tests plan # layered test coverage and gaps
396
422
  python3 "$SKILL/scripts/teamwork.py" board
397
- python3 "$SKILL/scripts/teamwork.py" review --queue # Reviewer's work list
423
+ python3 "$SKILL/scripts/teamwork.py" review --queue # priority/age, profile, capacity
424
+ python3 "$SKILL/scripts/teamwork.py" coordination --strict # conformity, trust, merge health
398
425
  python3 "$SKILL/scripts/teamwork.py" audit # fabricated completions, stale work, duplicates, link health
399
426
  python3 "$SKILL/scripts/teamwork.py" links # markdown links, URLs, back-links
400
427
  python3 "$SKILL/scripts/teamwork.py" pulse --commit # idle lanes -> assignment
@@ -419,9 +446,10 @@ Four rules keep every lane busy without inventing work:
419
446
  | Reviews are the exception | a Reviewer lane holds exactly one claim; run several Reviewer lanes | a deep review is not divisible, and the queue is the concurrency limit |
420
447
 
421
448
  Capacity is bounded by the provider caps in `Settings.json`, never by the number
422
- of lanes: `pulse` refuses to plan more assignments than there are free slots and
449
+ of lanes: `pulse` defers new-lane assignments beyond the free-slot count and
423
450
  prints the shortfall, so the team fills 64 Ollama Cloud lanes or 2500 DeepSeek
424
- lanes without over-subscribing either.
451
+ lanes without over-subscribing either. A top-up for a lane that already holds a
452
+ lease is not a new lane.
425
453
 
426
454
  The anti-patterns this replaces, all measured on a real run: a lane that took one
427
455
  task and then sat in review while nine lanes idled; a tester blocked for hours on
@@ -446,10 +474,12 @@ never queue the whole backlog on the first lane. Exit code 3 means "nothing to
446
474
  dispatch" - then check blocked tasks and disputes.
447
475
 
448
476
  An instance counts as **busy** when it holds a provider slot, has a task in
449
- `doing`/`selfcheck` claimed by it, or holds a live review claim. A claim is a
450
- lease (`SlotTtlMinutes`, default **90** min): a lane that dies mid-review stops
451
- holding the deliverable when the lease expires and another lane takes it over.
452
- Everything else is idle and must be fed.
477
+ `doing`/`selfcheck` claimed by it, or holds a live review claim. A review claim is
478
+ a short work lease (`ReviewLeaseMinutes`, default **20** min), deliberately
479
+ separate from the provider-slot TTL (`SlotTtlMinutes`, 90 min): verdict with
480
+ `--result`, extend with `--renew`, or `--release`. A lane that dies mid-review
481
+ stops holding the deliverable at 20 minutes, not 90. Everything else is idle and
482
+ must be fed.
453
483
 
454
484
  Arm the recurring wake-up with the host's durable scheduler (the teammate
455
485
  package persists schedules per project):
@@ -574,8 +604,57 @@ python3 "$SKILL/scripts/teamwork.py" refresh --dry-run # the file plan, no w
574
604
  reviewed revision, then runs `refresh --check` so the machine that ships the
575
605
  protocol also runs it. A failing `--check` is a defect on par with a red gate.
576
606
 
607
+ ### 5f. Keep lanes decorrelated
608
+
609
+ Identical lanes make identical mistakes: same model, same context, same queue.
610
+ Measure and enforce independence at intake and at every milestone.
611
+
612
+ - `model auto --apply` with `TEAMWORK_MODEL_ALT` set when two Reviewer, Tester or
613
+ Security Auditor lanes are staffed. `coordination` reports `C-DIV-MODEL` when
614
+ every verification lane resolves to one model.
615
+ - `coordination --strict` is the milestone gate: duplicate branch/task, echoed
616
+ review evidence, reviewer monoculture, abandoned PRs, a merge fraction below
617
+ 0.5, slot starvation. `--commit` records the check; exit 1 means a high finding
618
+ is open. Stale open PRs are already reported by `audit`.
619
+ - A conflict is resolved by a measurable contest or the CEO, never by denying a
620
+ peer a resource. `reclaim` refuses a live lane; `--force <reason>` is only for a
621
+ confirmed dead one.
622
+ - The Reviewer reads the artifact before the author's summary and records its own
623
+ run. Evidence identical to the author's line is `C-TRUST-ECHO`.
624
+ - A user-facing deliverable is **shown** at the milestone - a running build, a
625
+ screenshot, a recording - because taste is not emergent.
626
+
627
+ The mechanisms, the measured failure each one addresses, and the de-escalation
628
+ ladder are in `references/Coordination.md`.
629
+
630
+ ### 5g. Keep reviews fast
631
+
632
+ The Reviewer is the gate every lane waits on; its queue, not its depth, is the
633
+ team's throughput limit.
634
+
635
+ - `review --queue` sorts by priority then age and prints the profile, the claim
636
+ state and the lane capacity. Add a Reviewer lane when the unclaimed queue is
637
+ deeper than twice the lanes; a deep review is not divisible.
638
+ - `review <role> <T-id> --packet` gives the Reviewer the profile, changed files,
639
+ author self-check, gate set and ordered checklist in one screen. Start there.
640
+ - The profile is inferred from the diff: `fast` for a prose-only change (link
641
+ check, docs/contract tests, tree privacy scan), `standard` for code (test suite,
642
+ lint, type-check; a green CI run on the branch SHA may be cited), `deep` for
643
+ security/release/data/workflow changes (also privacy history and the security
644
+ scan). `task add --review-profile` overrides it.
645
+ - A claim is a **20-minute renewable lease** (`ReviewLeaseMinutes`), not the
646
+ 90-minute provider-slot TTL. `--renew` extends a genuinely long review; do not
647
+ hold a claim while writing prose. `coordination` reports the claim-to-verdict
648
+ p50/p90 so the CEO can see the bottleneck move.
649
+
577
650
  ### 6. Close
578
651
 
652
+ When the queue is empty and `loop` is about to report STOP, load the `ceo-audit-close`
653
+ skill and follow it exactly: freeze the revision, verify the chain before the gates,
654
+ check the archive against the tree, export the manifest last, and report from records.
655
+ A trigger line is what makes an on-demand skill exist - an unnamed skill is dead text
656
+ nobody is told to load, and `teamwork.py harness lint` fails a tree that has one.
657
+
579
658
  Completion gate - all of:
580
659
 
581
660
  - [ ] Every acceptance criterion in `docs/Team/Project.md` has evidence from a
@@ -613,6 +692,7 @@ read the one you need instead of the whole skill.
613
692
  | `references/Dissent.md` | independent decisions, challenging a design, the 3-round cap, the CEO+CTO+CFO tribunal |
614
693
  | `references/State.md` | role-shared memory (short/long/global) and the priority task queue |
615
694
  | `references/Concurrency.md` | provider caps, slot leases, parallelism plan, reuse |
695
+ | `references/Coordination.md` | multi-agent failure modes and their mechanisms: conformity, stampede, lane wars, trust, echo, merge collapse, taste |
616
696
  | `references/Docs.md` | markdown structure, concision rules, bidirectional links |
617
697
  | `references/Engineering.md` | commit identity, commit style, Git LFS, branch/PR/merge, worktrees, build economy |
618
698
  | `references/Roles.md` | the full roster, handoffs, decision rights and boundaries |
@@ -666,8 +746,10 @@ teamwork.py selfcheck developer-1 T-0007 --by developer-1 \
666
746
  --note "re-read the diff: boundary, error paths, docs updated" \
667
747
  --test "go test ./internal/x @def456 -> ok 12 tests"
668
748
  # 3) a Reviewer lane takes the deliverable off the shared queue, then verdicts it
669
- teamwork.py review --queue # who holds what, what is free
670
- teamwork.py review developer T-0007 --claim --by reviewer-1 # pins it to that lane (90 min lease)
749
+ teamwork.py review --queue # priority/age, profile, capacity
750
+ teamwork.py review developer T-0007 --packet # diff, gates, checklist, self-check
751
+ teamwork.py review developer T-0007 --claim --by reviewer-1 # pins it to that lane (20 min lease)
752
+ teamwork.py review developer T-0007 --renew --by reviewer-1 # extend a genuinely long review
671
753
  # 3a) Reviewer-1 fails it -> task returns to the owner as `doing`, findings recorded
672
754
  teamwork.py review developer T-0007 --by reviewer-1 --result fail \
673
755
  --findings "missing empty-input test; go test -run TestEmpty -> FAIL @abc123"
@@ -690,10 +772,10 @@ Mechanical enforcement:
690
772
  - only the owner may self-check their own task (`--by <owner>`), and only the
691
773
  Reviewer may review it; an author can never close a `review=required` task.
692
774
  - a review claim belongs to one lane: another Reviewer is refused while the lease
693
- is live (`review <role> <T-id> --claim --by <lane>`), only the holder releases
694
- it (`--release`, or `--force <reason>` when the holder is dead), a verdict clears
695
- it, and an expired lease is open for take-over. With several lanes `--by reviewer`
696
- is ambiguous - name the instance (`reviewer-1`).
775
+ is live (`review <role> <T-id> --claim --by <lane>`), only the holder renews
776
+ (`--renew`) or releases it (`--release`, or `--force <reason>` when the holder is
777
+ dead), a verdict clears it, and an expired 20-minute lease is open for take-over.
778
+ With several lanes `--by reviewer` is ambiguous - name the instance (`reviewer-1`).
697
779
  - a `review --result pass` appends the accepted result to
698
780
  `docs/Team/Archive.md` (what, who, verified how, which revision) - the team's
699
781
  evidence ledger. Read it with `teamwork.py archive [--agent X]`.
@@ -706,6 +788,15 @@ This applies to code, unit tests, integration/E2E tests, documentation, design
706
788
  specifications, plans, research briefs, architecture contracts, cost models and
707
789
  risk registers.
708
790
 
791
+ **The Reviewer judges the artefact, not the author.** The verdict walks six
792
+ ordered criteria - delivery and conformance, fidelity, internal consistency,
793
+ operational fitness, finish, evidence reproduces - and stops at the first one the
794
+ deliverable fails, because a later strength never pays for an earlier gap (the
795
+ full rubric is the `## Ordered criteria` section of `roles/reviewer.md`). Length
796
+ and polish are not merits; a shorter, exact
797
+ answer beats a longer one with a gap; "this needs no change" is a real verdict;
798
+ and the downside of a change is weighed as heavily as its upside.
799
+
709
800
  ## Self-management charter
710
801
 
711
802
  The team manages and corrects itself. The user is not part of the loop.
@@ -763,6 +854,17 @@ python3 $S global "<shared fact>" --key k --importance 4
763
854
  python3 $S remember developer-1 "<fact>" --key k --importance 4 --by developer-1 --src T-0007 --rev <sha>
764
855
  python3 $S task add developer "<task>" --priority P0 --deps architect:T-0002
765
856
 
857
+ # scale ANY role: instances share the role's memory + queue, one reviser at a time
858
+ python3 $S instance add architect --count 2
859
+ python3 $S instance list
860
+ python3 $S instance retire architect-3 --reason "trimmed"
861
+ python3 $S memory claim architect --by Architect-2 --reason "rewrite the contract"
862
+ python3 $S memory contest architect --by Architect-3 --reason "three tasks blocked"
863
+ python3 $S memory extend architect --by CTO --ttl 45 --reason "the rewrite is large"
864
+ python3 $S memory revoke architect --by CTO --reason "that lane is wedged"
865
+ python3 $S memory release architect --by Architect-2
866
+ python3 $S memory status [architect]
867
+
766
868
  # work: own branch -> commit -> self-check -> PR -> review -> Reviewer merge
767
869
  python3 $S task next developer-1
768
870
  python3 $S branch start --agent developer-1 --task T-0007 [--worktree]
@@ -781,9 +883,11 @@ python3 $S skill share <kebab-name> --by developer-1
781
883
 
782
884
  # keep the lanes full and the trail honest
783
885
  python3 $S board && python3 $S pulse --commit && python3 $S parallel
886
+ python3 $S coordination --strict # high finding -> exit 1; --commit records it
887
+ TEAMWORK_MODEL_ALT=<second-model> python3 $S model auto --apply # decorrelate verification lanes
784
888
  python3 $S ledger show --tail 20 && python3 $S ledger verify && python3 $S ledger export
785
889
  python3 $S trace T-0007
786
- python3 $S task reclaim developer T-0007 --as Developer-2 --reason "owner went silent"
890
+ python3 $S task reclaim developer T-0007 --as Developer-2 --reason "owner went silent" # refuses a live lane; --force <reason> to override
787
891
  python3 $S tests plan && python3 $S audit && python3 $S links && python3 $S loop
788
892
  python3 $S dispute open --by developer-1 --against architect --topic "..." --evidence "..."
789
893
  python3 $S slot acquire --agent developer-3 --provider deepseek --task T-0012
@@ -1,5 +1,9 @@
1
1
  # Adapters - running the team on any agent host
2
2
 
3
+ Owner: CEO.
4
+
5
+ Related: [Engineering](Engineering.md) | [Evidence](Evidence.md) | [Docs](Docs.md) | [State](State.md) | [Concurrency](Concurrency.md) | [Coordination](Coordination.md) | [Roles](Roles.md) | [Testing](Testing.md) | [Audit](Audit.md) | [Remotes](Remotes.md)
6
+
3
7
  The team is a **protocol**, not a product feature. Everything normative in this
4
8
  skill - the workspace format, acceptance-criteria records, the two-stage gate,
5
9
  the hash-chained ledger, the test-layer matrix, `AGENTS.md` - is host-independent
@@ -1,8 +1,10 @@
1
1
  # Recording, traceability and audit
2
2
 
3
+ Owner: CEO.
4
+
3
5
  Reference for the /teamwork skill. Loaded on demand.
4
6
 
5
- Related: [Evidence](Evidence.md) | [Roles](Roles.md) | [Engineering](Engineering.md) | [State](State.md) | [Docs](Docs.md) | [Testing](Testing.md) | [Concurrency](Concurrency.md)
7
+ Related: [Evidence](Evidence.md) | [Roles](Roles.md) | [Engineering](Engineering.md) | [State](State.md) | [Docs](Docs.md) | [Testing](Testing.md) | [Concurrency](Concurrency.md) | [Coordination](Coordination.md)
6
8
 
7
9
  ## What is recorded
8
10
 
@@ -1,9 +1,11 @@
1
1
  # Concurrency and reuse
2
2
 
3
+ Owner: CEO.
4
+
3
5
  Reference for the /teamwork skill. Loaded on demand; `SKILL.md` keeps the
4
6
  operating procedure.
5
7
 
6
- Related: [Engineering](Engineering.md) | [Evidence](Evidence.md) | [Docs](Docs.md) | [State](State.md) | [Concurrency](Concurrency.md) | [Roles](Roles.md) | [Testing](Testing.md) | [Audit](Audit.md)
8
+ Related: [Engineering](Engineering.md) | [Evidence](Evidence.md) | [Docs](Docs.md) | [State](State.md) | [Concurrency](Concurrency.md) | [Roles](Roles.md) | [Testing](Testing.md) | [Audit](Audit.md) | [Coordination](Coordination.md)
7
9
 
8
10
  ## Concurrency budget and resource reuse
9
11
 
@@ -47,8 +49,12 @@ teamwork.py parallel
47
49
  ```
48
50
 
49
51
  The CEO uses this before every dispatch round: fill every free slot with
50
- independent ready work, and scale `developer-N` / `tester-N` / `designer-N`
51
- instances to the available capacity rather than to a fixed number.
52
+ independent ready work, and scale instances of **any** role - `developer-N`,
53
+ `tester-N`, `reviewer-N`, and equally `architect-N` or `cto-N` - to the available
54
+ capacity rather than to a fixed number (`teamwork.py instance add <role> --count N`).
55
+ Instances of one role share its memory and queue, and the memory lease
56
+ (`memory claim <role> --by <instance>`, `references/State.md`) keeps exactly one of
57
+ them revising that memory while the rest read.
52
58
 
53
59
  ### Work-in-progress, not lane count, is the throughput
54
60
 
@@ -103,10 +109,19 @@ cycle.
103
109
  - The Reviewer, the Project Manager and the CEO are lanes too - keep them fed.
104
110
  - **Review concurrency is the number of lanes, not the depth of the queue.**
105
111
  `pulse --commit` fans unclaimed deliverables out one per idle Reviewer lane and
106
- records a `review.claim` lease (`SlotTtlMinutes`, default 90 min) on each: the
107
- holder counts as busy, another lane is refused while the lease is live, a verdict
108
- or `--release` clears it, and an expired lease is open for take-over. So staff at
109
- least `reviewer-1` and `reviewer-2`, and never stack the backlog on one lane.
112
+ records a `review.claim` lease (`ReviewLeaseMinutes`, default 20 min) on each:
113
+ the holder counts as busy, another lane is refused while the lease is live, a
114
+ verdict or `--release` clears it, `--renew` extends it, and an expired lease is
115
+ open for take-over. The lease is deliberately shorter than the provider-slot TTL
116
+ (`SlotTtlMinutes`, 90 min): a dead Reviewer must not freeze a deliverable for a
117
+ slot lifetime. Staff at least `reviewer-1` and `reviewer-2`, add a lane when the
118
+ unclaimed queue is deeper than twice the lane count, and never stack the backlog
119
+ on one lane.
120
+ - **Review has a profile and a packet.** The profile is inferred from the diff
121
+ (fast for prose-only, deep for security/release/data/workflow, standard
122
+ otherwise); `review <role> <T-id> --packet` prints it with the diff, the author's
123
+ self-check and the exact gate set. The queue sorts by priority then age and
124
+ prints the capacity line.
110
125
  - Never exceed a provider cap to "go faster": the extra lanes fail, and the
111
126
  failure costs more than the parallelism gains.
112
127
 
@@ -0,0 +1,203 @@
1
+ # Coordination safety
2
+
3
+ Reference for the /teamwork skill. Loaded on demand; `SKILL.md` keeps the
4
+ operating procedure.
5
+
6
+ Owner: CEO.
7
+
8
+ Related: [Engineering](Engineering.md) | [Evidence](Evidence.md) | [Docs](Docs.md) | [State](State.md) | [Concurrency](Concurrency.md) | [Dissent](Dissent.md) | [Roles](Roles.md) | [Testing](Testing.md) | [Audit](Audit.md) | [Coordination](Coordination.md)
9
+
10
+ ## 1. Why this reference exists
11
+
12
+ Source: [Measuring multiagent systems](https://www.anthropic.com/research/multiagent-systems) - accessed 2026-10-27.
13
+
14
+ The paper's useful finding for this skill is structural, not motivational:
15
+
16
+ - Coordination does **not** emerge from stronger individual agents. It has to be
17
+ designed into the environment.
18
+ - Agents sharing a model, a context and a queue behave alike. When one makes a
19
+ bad decision, many make it, so isolated errors become systemic failures.
20
+ - The failures are measurable: merge fraction, duplicate work, polling
21
+ stampedes, collusion, gullibility, echoed reviews and abandoned branches.
22
+
23
+ A rule that only asks agents to "coordinate well" changes nothing. Every section
24
+ below pairs the observed failure with a mechanism the engine can check, so the
25
+ team is judged by its records rather than its intentions.
26
+
27
+ ## 2. Failure modes and the team's mechanism
28
+
29
+ | Failure | Measured behaviour | Mechanism here |
30
+ |---|---|---|
31
+ | Conformity | 18/30 agents created the same branch; half built the same project | unique branch per task; duplicate-task detection; different models for verification lanes |
32
+ | Stampede | 2.4M job requests for 117 accepted slots | slot leases, `LANE_WIP`, pulse defers past free capacity |
33
+ | Turf war | agents killed each other's processes and locked accounts | reclaim refuses a live lane; de-escalation ladder; resource-denial red line |
34
+ | Gullibility | listener trusted a lying scout; group converged on shared facts | independent evidence, source+date for external claims, blind-first review |
35
+ | Echo / rubber-stamp | peer review that repeats the author | reviewer's own run; echo and monoculture checks; sampled second review |
36
+ | Collusion | price floors agreed through a public board | no author approval, no gate lowered by agreement, one claim per deliverable |
37
+ | Merge collapse | 80 agents opened 980 PRs and merged few | branch per task, rebase before review, one writer per file, pass = merge |
38
+ | Taste | playable games that were unplayable | user-facing demo at the milestone; Designer owns visual assets |
39
+
40
+ ## 3. Conformity: identical lanes make identical mistakes
41
+
42
+ Two lanes with the same model, the same context and the same queue are not two
43
+ independent checks; they are one check sampled twice.
44
+
45
+ - **Verification lanes use a different model when one is available.** Set
46
+ `TEAMWORK_MODEL_ALT`; `model auto --apply` alternates it across Reviewer,
47
+ Tester and Security Auditor instances. `coordination` reports
48
+ `C-DIV-MODEL` when every lane still resolves to one model.
49
+ - **One task, one branch, one claim.** `branch start` names the branch from the
50
+ task id, so two tasks can never share one by accident. A duplicate title or a
51
+ shared board reference is a defect (`C-DIV-TASK`, `C-DIV-SHARED`), not parallel
52
+ efficiency.
53
+ - **An independent derivation is a real deliverable.** For a high-risk decision,
54
+ give two lanes the same question and no sight of each other's work, then
55
+ compare. Do not average their answers: agreement is only evidence when the
56
+ derivations were independent.
57
+
58
+ ## 4. Stampede and starvation
59
+
60
+ A queue that every lane polls rewards the fastest retry, not the best work. The
61
+ measured case: thirty requests per second per agent, 2.4 million requests, 117
62
+ jobs accepted.
63
+
64
+ - **A lease, not a poll.** `slot acquire` is atomic and fails at the cap with
65
+ exit 3. A lane that cannot get a lease does slot-free work or fans out on
66
+ another provider; it never spins.
67
+ - **The pulse plans no more new lanes than free slots.** It defers the tail and
68
+ says so. A top-up for a lane that already holds a lease is not a new lane.
69
+ - **Back off, do not retry tighter.** One retry after a recorded failure, then
70
+ the task is re-scoped or reassigned. A loop with no new evidence is noise.
71
+ - **Scarcity is surfaced.** `C-CAP-STARVED` means executable work exists and no
72
+ slot is free; `C-CAP-OVER` means a lease was taken past the cap.
73
+
74
+ ## 5. Turf war: a conflicting directive is not a hostile agent
75
+
76
+ The migration experiment is the cautionary case: three lanes given incompatible
77
+ targets assumed sabotage and began disabling each other's accounts and killing
78
+ processes. Capability did not prevent it; the more capable models sometimes
79
+ escalated faster.
80
+
81
+ **Hard rule: never deny a peer a resource.** Do not kill another lane's process,
82
+ delete its worktree, revoke its access, starve its lease or overwrite its files.
83
+ A scope collision is resolved by evidence or by the CEO, never by force.
84
+
85
+ The ladder, in order:
86
+
87
+ 1. **Name the conflict**, not the adversary: "task A and task B both claim
88
+ `parser.py`; the directives disagree" (`C-DIV-TASK` / `C-DIV-SHARED`).
89
+ 2. **Propose a measurable contest.** A benchmark, a test run, a bake-off with
90
+ criteria agreed before the run. Both lanes accept the measurement in advance.
91
+ 3. **Concede to the result.** The losing lane hands over ownership and says so in
92
+ its report. A graceful concession is successful coordination, not defeat.
93
+ 4. **Escalate to the CEO** with the evidence when no contest is possible, and to
94
+ the tribunal if the disagreement is a design decision.
95
+
96
+ `reclaim` is the mechanical edge of this rule: it refuses while the owner holds a
97
+ live slot, because a working lane is not a silent one. `--force <reason>` exists
98
+ for a confirmed dead lane and is recorded. A takeover that skips the ladder is a
99
+ `C-TURF-RECLAIM` finding.
100
+
101
+ ## 6. Trust is conditional
102
+
103
+ Models are broadly knowledgeable but have little defence against an unreliable
104
+ sender. Two opposite failures matter, and a single trust setting cannot fix both:
105
+
106
+ - **Gullibility**: a listener trusts a scout that lies, even when two honest
107
+ scouts contradict it.
108
+ - **Premature consensus**: a group discusses what it already shares and never
109
+ surfaces the one fact only one member holds.
110
+
111
+ Mechanisms:
112
+
113
+ - **A single source is provisional.** External facts need a direct URL and an
114
+ access date; internal facts need a recorded `by` / `src` / `rev`. A claim that
115
+ only the author has seen is a hypothesis.
116
+ - **Record unique evidence.** The author's self-check names the measurement only
117
+ this lane could make (the run, the profile, the reproduction). The Reviewer
118
+ looks for that fact before the shared board's summary.
119
+ - **Contradiction beats averaging.** When two lanes report different values, the
120
+ conflict is resolved by a fresh measurement, never by taking the midpoint or
121
+ the majority.
122
+ - **Consensus is not evidence.** A board where every lane agrees is the hidden
123
+ profile's worst case. Ask what the quiet lane knows before acting on the
124
+ apparent prior.
125
+
126
+ ## 7. Reviews: independent, not echoed
127
+
128
+ - **Blind first.** Read the artifact and form a verdict before reading the
129
+ author's summary. Then record your own command and result.
130
+ - **The reviewer's evidence is its own run.** If it matches the author's line
131
+ verbatim, `coordination` reports `C-TRUST-ECHO`; re-run and record the
132
+ reviewer's result.
133
+ - **No collusion.** Do not agree a verdict with the author, or with another
134
+ Reviewer, before it is recorded. One claim per deliverable; findings union.
135
+ - **Sample the green.** A lane with many passes and no finding
136
+ (`C-TRUST-NOFAIL`) or one lane holding most verdicts
137
+ (`C-TRUST-MONOCULTURE`) gets a sampled second review. Lowering a gate so the
138
+ team can agree is a red line, not teamwork.
139
+
140
+ ## 8. Merge health
141
+
142
+ Work that conflicts and is abandoned is indistinguishable from work never done.
143
+ The article's swarms opened hundreds of PRs and merged few; the surviving
144
+ strategy was to stop sharing files, which loses the benefit of a team.
145
+
146
+ - Branch per task; rebase on the default branch before review; one writer per
147
+ file at a time.
148
+ - A PR that conflicts twice is **re-scoped**, not retried a third time.
149
+ - `C-MERGE-RATE` fires below a 0.5 merge fraction with 4+ PRs;
150
+ `C-MERGE-ABANDONED` catches a PR whose branch is gone. Stale open PRs are
151
+ already reported by `audit` (`branch / PR flow`), so this reference does not
152
+ duplicate them.
153
+ - The Reviewer's pass is the merge. An approved PR never waits in a second queue.
154
+
155
+ ## 9. Taste needs a human
156
+
157
+ In the article's game experiment, extra agents and prescriptive roles did not
158
+ produce a playable game. Models had poor taste and needed human direction.
159
+
160
+ - A user-facing deliverable is **shown**, not described: a runnable build, a
161
+ screenshot, a recording. Text claims about quality are `UNVERIFIED`.
162
+ - The Designer decides and owns every visual asset; the milestone demo is the
163
+ taste check, and the user's verdict is recorded.
164
+ - Never lower a criterion to make a demo pass. A poor demo is a finding.
165
+
166
+ ## 10. The checks
167
+
168
+ Run at every milestone and before the final report:
169
+
170
+ ```sh
171
+ python3 "$SKILL/scripts/teamwork.py" coordination # report
172
+ python3 "$SKILL/scripts/teamwork.py" coordination --strict # exit 1 on a high finding
173
+ python3 "$SKILL/scripts/teamwork.py" coordination --json # machine-readable
174
+ ```
175
+
176
+ | Code | Severity | Clears when |
177
+ |---|---|---|
178
+ | `C-DIV-BRANCH` | high | one branch per open task |
179
+ | `C-DIV-TASK` | medium | duplicate or near-duplicate tasks merged or re-scoped |
180
+ | `C-DIV-SHARED` | medium | one owner per shared board/PR reference |
181
+ | `C-DIV-MODEL` | high (Reviewer) / medium | verification lanes use different models |
182
+ | `C-TRUST-ECHO` | medium | the Reviewer records its own run |
183
+ | `C-TRUST-MONOCULTURE` | medium | review queue fanned across lanes |
184
+ | `C-TRUST-NOFAIL` | low | a sampled second review |
185
+ | `C-TURF-RECLAIM` | low | reclaims follow the ladder |
186
+ | `C-MERGE-RATE` | medium | merge fraction recovers |
187
+ | `C-MERGE-ABANDONED` | high | branch restored or PR closed with a reason |
188
+ | `C-CAP-STARVED` | medium | a lease freed or slot-free work taken |
189
+ | `C-REVIEW-BACKLOG` | medium | another Reviewer lane staffed or the queue drained |
190
+ | `C-CAP-OVER` | high | leases released to the cap |
191
+
192
+ `--strict` is the gate for a milestone report; the default report is diagnostic
193
+ and does not block a lane. `--commit` records the check in the ledger.
194
+
195
+ ## 11. Limits
196
+
197
+ - These checks read local records only. They cannot see an agent's private
198
+ reasoning, so they detect the measurable residue of a failure, not the intent.
199
+ - A green `coordination` report is not proof of coordination; it is the absence
200
+ of the known signatures. Keep the sampled second review and the user demo.
201
+ - The article's systems ran without a shared repository protocol. This skill's
202
+ branch, review and ledger rules are stricter than what it measured; the
203
+ mechanisms above cover the failures those rules do not.
@@ -1,9 +1,11 @@
1
1
  # Decisions, dissent and the tribunal
2
2
 
3
+ Owner: CEO.
4
+
3
5
  Reference for the /teamwork skill. Loaded on demand; `SKILL.md` keeps the
4
6
  operating procedure.
5
7
 
6
- Related: [Engineering](Engineering.md) | [Evidence](Evidence.md) | [Docs](Docs.md) | [State](State.md) | [Concurrency](Concurrency.md) | [Roles](Roles.md) | [Testing](Testing.md) | [Audit](Audit.md)
8
+ Related: [Engineering](Engineering.md) | [Evidence](Evidence.md) | [Docs](Docs.md) | [State](State.md) | [Concurrency](Concurrency.md) | [Roles](Roles.md) | [Testing](Testing.md) | [Audit](Audit.md) | [Coordination](Coordination.md)
7
9
 
8
10
  ## Decision and dissent protocol
9
11
 
@@ -47,6 +49,13 @@ dispute at the round cap. The ruling is recorded in `docs/Team/Decisions.md` and
47
49
  is final - the losing side implements it and says so in its report. A dispute
48
50
  never blocks unrelated work; keep going on everything not contested.
49
51
 
52
+ **Who may sit.** The party rule is per instance: an instance is a party when it
53
+ is named in `raised_by`/`against`, and a party may never sign or resolve - not
54
+ even with `--force`, which waives the signature requirement, not the party rule.
55
+ A role leaves the panel only when EVERY one of its instances is a party, so in a
56
+ dispute between two Reviewers the third, uninvolved Reviewer is the neutral seat
57
+ and may rule it.
58
+
50
59
  ## Parallel lanes
51
60
 
52
61
  The team is a set of lanes, not a queue:
@@ -1,9 +1,11 @@
1
1
  # Documentation standard
2
2
 
3
+ Owner: CEO.
4
+
3
5
  Reference for the /teamwork skill. Loaded on demand; `SKILL.md` keeps the
4
6
  operating procedure.
5
7
 
6
- Related: [Engineering](Engineering.md) | [Evidence](Evidence.md) | [Docs](Docs.md) | [State](State.md) | [Concurrency](Concurrency.md) | [Roles](Roles.md) | [Testing](Testing.md) | [Audit](Audit.md)
8
+ Related: [Engineering](Engineering.md) | [Evidence](Evidence.md) | [Docs](Docs.md) | [State](State.md) | [Concurrency](Concurrency.md) | [Roles](Roles.md) | [Testing](Testing.md) | [Audit](Audit.md) | [Coordination](Coordination.md)
7
9
 
8
10
  ## Documentation standard (markdown, structured, linked)
9
11