Skip to content

Add dynamic expert add design and task specs#70

Open
Cassin01 wants to merge 6 commits into
mainfrom
dinamic_expert_add
Open

Add dynamic expert add design and task specs#70
Cassin01 wants to merge 6 commits into
mainfrom
dinamic_expert_add

Conversation

@Cassin01
Copy link
Copy Markdown
Owner

@Cassin01 Cassin01 commented May 5, 2026

Summary

  • Add design spec for dynamic expert add feature (.macot/specs/dynamic-expert-add-design.md) covering CLI (macot expert add) and tower TUI flow to append an expert to a running session without restarting.
  • Add task breakdown for the implementation (.macot/specs/dynamic-expert-add-tasks.md).

Scope

  • Spec/design only — no code changes.
  • Adds-only scope; expert remove is out of scope.
  • Dynamic adds attach to the existing tmux session as new windows; new sessions are not in scope.
  • Role selection covers built-in roles plus external templates at .macot/templates/roles/{role}.md.

Test plan

  • Review design doc for correctness against current expert lifecycle (experts_manifest.json, status/expertN, queue/messages paths).
  • Confirm task list is sequenced so each step is independently reviewable.

Cassin01 added 6 commits May 5, 2026 13:15
Specifies CLI (`macot expert add`) and tower TUI flow to append an
expert to a running session without restarting, plus the implementation
task breakdown.
Add experts to a running session without restarting it, per the design at
.macot/specs/dynamic-expert-add-design.md.

Core
- ExpertAddService coordinates ID allocation, role resolution, manifest
  commit (temp + atomic rename), and tmux window spawn under a 5s
  advisory file lock at .macot/.lock.
- Monotonic ID allocation reconciled against on-disk manifest on every
  add to survive concurrent writers.
- Roles: built-in (architect / planner / general) plus custom templates
  resolved against .macot/templates/roles/{name}.md and
  ~/.config/macot/roles/{name}.md.
- NamePool with 12 literary names and Expert{NN} fallback once exhausted.
- Rollback unwinds manifest, role assignment, and per-expert files when
  tmux launch fails so state remains all-or-nothing.

CLI
- `macot expert add` with --session/--role/--name/--prompt-file/
  --worktree/--worktree-branch/--dry-run/--json.
- `macot expert list` reads experts_manifest.json read-only.

Tower TUI
- F2 opens the Add Expert modal.
- notify-rs watcher reloads the Expert Panel on manifest changes.

Dependencies
- fs2 0.4 (advisory file lock), notify 6 (manifest change events).

Tests
- Unit + property tests for NamePool, RoleResolver determinism,
  ManifestPersistor atomicity, ID monotonicity.
- E2E suite in tests/e2e_dynamic_expert_add.rs (gated behind
  `make test-e2e` / `--ignored`, requires tmux on PATH).

Docs
- doc/cli.md: full reference for the new subcommands and F2 binding.
- CHANGELOG.md: Unreleased entry.
Resolves clippy::collapsible-match errors on KeyCode::Up/Down arms
in the add expert modal handler.
Linux inotify can emit setup-related events when attaching to a
freshly created directory, causing the quiescent-disk test to fail
in CI. Drain initial events within a short settling window before
asserting no further changes.
Surface the F2 (Open Add Expert modal) keybinding in the F1 help
modal's Global section so users can discover it from inside the app.
…xperts

Resolves Property 8' (Tower Liveness Under Add, ≤1s): experts added via
`macot expert add` or the F2 modal now appear in the tower Experts panel
within ≤1s of the manifest commit.

Root cause: `refresh_status` and `poll_messages` iterated
`self.config.experts` (a startup snapshot), so new experts surfaced in
`ExpertRegistry` were never projected onto `status_display`. Migrate
both call sites and `reload_from_manifest` to the registry via a shared
`push_registry_to_status_display` helper. Document `Config::experts` as
startup-only and add `make check-no-stale-mirror` to prevent regression.

Tests: T1 reload-then-display, T2 Property 8' ≤1s timing, T3 proptest
registry/display sync, T4 poll_messages iterates registry.

See `.macot/specs/expert-panel-manifest-sync-design.md` §2.3.
@Cassin01 Cassin01 marked this pull request as ready for review May 14, 2026 22:30
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.

1 participant