Skip to content

refactor(fleet-data): extract shared toposort::waves from binaries#154

Merged
NagyVikt merged 1 commit into
mainfrom
agent/refactor-toposort-extract
May 16, 2026
Merged

refactor(fleet-data): extract shared toposort::waves from binaries#154
NagyVikt merged 1 commit into
mainfrom
agent/refactor-toposort-extract

Conversation

@NagyVikt
Copy link
Copy Markdown
Contributor

Summary

  • Move the duplicated waves() Kahn topological sort out of fleet-waves/src/main.rs and fleet-plan-tree/src/main.rs into a new fleet-data::toposort module
  • Both binaries now import fleet_data::toposort::waves instead of carrying byte-identical inlined copies
  • Adds 6 unit tests covering empty graph, single node, linear chain, parallel chains, multi-dep node, and the existing missing-predecessor behavior

Behavior

Byte-identical to the previous inlined copies. Verified by fleet-waves' existing insta render snapshot (passes unchanged).

Two pre-existing quirks documented but preserved (no behavior change):

  • Empty input returns vec![vec![]] (one empty wave), not vec![]
  • Missing predecessors are silently memoised at level 0 and emitted as phantom entries in wave 0
  • Cycles cause stack overflow — callers (Colony) currently guarantee acyclic input. Module doc flags this. Cycle handling is out of scope for this pure-refactor PR but could be a follow-up.

Test plan

  • cargo check -p fleet-data -p fleet-waves -p fleet-plan-tree — clean
  • cargo test -p fleet-data -p fleet-waves -p fleet-plan-tree — 60/60 pass incl. insta snapshot
  • Visual smoke-test of waves view in a live fleet (optional — snapshot covers the rendered output)

🤖 Generated with Claude Code

The Kahn topological-level grouping for plan subtasks was byte-identical
in fleet-plan-tree::waves and fleet-waves::waves. Promote it to
fleet_data::toposort::waves and have both binaries depend on the shared
copy. Behaviour is preserved verbatim — covered by the existing
fleet-waves render snapshot plus new unit tests for empty / single /
linear / parallel-chain / multi-dep / missing-dep inputs.
@NagyVikt NagyVikt merged commit 083b2e1 into main May 16, 2026
2 checks passed
@NagyVikt NagyVikt deleted the agent/refactor-toposort-extract branch May 16, 2026 15:13
NagyVikt added a commit that referenced this pull request May 16, 2026
scripts/codex-fleet/demo/ — bring up the production tmux layout
populated by fake plan / pane / counter / quality-score files so the
real fleet-state / fleet-plan-tree / fleet-waves binaries render against
synthetic data. No real codex sessions, no API spend.

For design iteration: change a renderer, kill + restart the demo, see
the result.

Structure:
- up.sh           seeds /tmp/claude-viz/, spawns tmux session
                  codex-fleet-demo with overview (8 worker panes) +
                  fleet/plan/waves/watcher dashboard windows, starts
                  tick simulator
- down.sh         tears tmux down, removes synthetic state, deletes
                  runtime plan copy so working tree stays clean
- tick.sh         mutates the runtime plan every 3s (configurable
                  via CODEX_FLEET_DEMO_TICK_INTERVAL): assign idle
                  agents, advance claimed → in_progress → completed,
                  refresh pane scrollback. Loops when all 12 tasks
                  complete (set CODEX_FLEET_DEMO_LOOP=0 to stop)
- agent-auth      PATH shim so fleet-data::accounts::load_via_agent_auth()
                  reads 8 synthetic accounts instead of the real binary
- scenarios/refactor-wave/plan.json  committed template; up.sh copies
                  to openspec/plans/<slug>/ at runtime

8 agents named after herbs; clover is scripted to be "capped" so the
PaneState::Capped branch is exercised. Plan has 12 tasks across 3
dependency waves modelled after the recent refactor PRs (#154-159).

Usage: bash scripts/codex-fleet/demo/up.sh

Prereqs: tmux, jq, release builds of fleet-state, fleet-plan-tree,
fleet-waves (+ optionally fleet-watcher) under rust/target/release/.

Co-authored-by: NagyVikt <nagy.viktordp@gmail.com>
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