Commit Graph

3274 Commits

Author SHA1 Message Date
dave 06035f20ad fix: restore #[tokio::main] on main(), #[cfg(unix)] on platform tests, #[allow] on run_pty_session/AuthListenerResult
The biggest miss is #[tokio::main] — without it, async fn main() doesn't compile,
and the binary in every worktree fails 'cargo check'. Agents in those worktrees
burn their turn budgets trying to fix the build before they can do real work, then
get killed by the watchdog. That's why all three in-flight stories failed.

Other restored attributes:
- #[cfg(unix)] on 4 tests in merge/squash and scaffold (skip on non-Unix)
- #[allow(dead_code)] on AuthListenerResult test enum
- #[allow(clippy::too_many_arguments)] on run_pty_session

Same root cause as the earlier #[test] attribute losses: my line ranges started
at the fn line, missing the leading attribute on the previous line.
2026-04-26 23:38:17 +00:00
dave eca15b4ee7 refactor: split agents/pool/start.rs into mod.rs + validation.rs + spawn.rs
The 1630-line start.rs is split into a sub-module directory:

- validation.rs: validate_agent_stage + read_front_matter_agent helpers (69 lines)
- spawn.rs: run_agent_spawn — the background async work that was inlined as
  a tokio::spawn closure body inside start_agent (359 lines)
- mod.rs: AgentPool::start_agent orchestrator + tests (1062 lines)

Stage validation and front-matter agent reading are pre-lock pure helpers that
naturally extract.  The spawn closure body becomes a free async fn that takes
the previously-cloned values as parameters; rebound to the original _clone /
_owned names at the top of the body so the actual work code is a verbatim copy.

No behaviour change. All 23 start tests pass; full suite green.
2026-04-26 22:12:04 +00:00
dave 40f1794d41 fix: restore #[test] attributes on parse_no_args, peer_receives_op_encoded_via_wire_codec, keepalive_constants_are_correct
Same root cause as 0d805313: when extracting a test that's the FIRST inside its
mod block, the slicer started at the fn line and missed the leading #[test]
attribute on the previous line. Test count now matches pre-split count (2636).
2026-04-26 22:04:12 +00:00
dave 0d805313d6 fix: restore #[test] and #[should_panic] attributes on panics_on_duplicate_agent_names
Lost in commit db00a5d4 when extracting tests from main.rs into cli.rs;
the line range used for the panics_on_duplicate_agent_names test in main.rs
started at the fn signature instead of the attribute line.
2026-04-26 22:01:06 +00:00
dave 0e09a1ed4b refactor: extract auth handshake from crdt_sync/server.rs into handshake.rs
The 1680-line server.rs is split:

- handshake.rs: perform_auth_handshake helper + close_with_auth_failed + auth tests
  + start_auth_listener / close_listener_auth_failed test helpers + AuthListenerResult enum
- server.rs: crdt_sync_handler (now invokes perform_auth_handshake) + wait_for_sync_text
  + broadcast/e2e/keepalive tests

Auth handshake (Steps 1-3 of the WebSocket handshake) is a self-contained sequence
that takes &mut SplitSink + &mut SplitStream and returns Option<AuthMessage>. The
caller observes None to mean the connection has already been closed with the
appropriate close code.

No behaviour change. All 63 crdt_sync tests pass; full suite green.
2026-04-26 21:49:46 +00:00
dave db00a5d4b5 refactor: split main.rs by extracting CLI parsing into cli.rs
The 1258-line main.rs is split into:

- main.rs: mod declarations, async fn main + panics_on_duplicate_agent_names test (894 lines)
- cli.rs: CliArgs struct, parse_cli_args, print_help, resolve_path_arg + their tests (372 lines)

main.rs cannot itself become a directory (binary crate must have main.rs at the
crate root); cli.rs is a sibling module.

No behaviour change. All cli tests pass; full suite green.
2026-04-26 21:41:39 +00:00
dave a86448f6a6 refactor: split chat/transport/matrix/config.rs into mod.rs + loading.rs
The 1260-line config.rs is split into:

- mod.rs: BotConfig struct + small impl + default helpers + tests (1047 lines)
- loading.rs: BotConfig::load + save_ambient_rooms (223 lines)

Tests stay co-located.

No behaviour change. All 41 matrix::config tests pass; full suite green.
2026-04-26 21:37:39 +00:00
dave ca72f36c78 refactor: split agents/pool/pipeline/advance.rs into mod.rs + helpers.rs
The 1353-line advance.rs is split into:

- mod.rs: impl AgentPool with run_pipeline_advance + start_mergemaster_or_block + tests (1244 lines)
- helpers.rs: spawn_pipeline_advance, resolve_qa_mode_from_store, write_review_hold_to_store, should_block_story (128 lines)

Tests stay co-located with run_pipeline_advance which they exercise.

No behaviour change. All 10 advance tests pass; full suite green.
2026-04-26 21:35:04 +00:00
dave 5aedf94512 refactor: split pipeline_state.rs into 4 sub-modules with co-located tests
The 1411-line pipeline_state.rs is split into:

- mod.rs: types, transition(), execution_transition(), labels + transition tests (885 lines)
- events.rs: TransitionFired, EventBus, TransitionSubscriber + event-bus tests (114 lines)
- projection.rs: ProjectionError, TryFrom<&PipelineItemView>, read_typed + projection tests (379 lines)
- subscribers.rs: 5 concrete TransitionSubscriber stubs (95 lines)

Tests stay co-located.

No behaviour change. All 42 pipeline_state tests pass; full suite green.
2026-04-26 21:30:55 +00:00
dave f1e42710b5 refactor: split llm/providers/claude_code.rs into mod.rs + parse.rs + events.rs
The 1427-line claude_code.rs is split into:

- parse.rs: parse_assistant_message + parse_tool_results + tests (332 lines)
- events.rs: process_json_event + handle_stream_event + tests (749 lines)
- mod.rs: doc, types (ClaudeCodeResult, ClaudeCodeProvider), chat_stream, run_pty_session (395 lines)

Tests stay co-located.

No behaviour change. All 44 claude_code tests pass; full suite green.
2026-04-26 21:22:08 +00:00
dave ce94dd0af4 refactor: split agents/merge.rs into mod.rs + squash.rs + conflicts.rs
The 1772-line merge.rs is split into:

- conflicts.rs: try_resolve_conflicts + resolve_simple_conflicts + tests (351 lines)
- squash.rs: run_squash_merge orchestrator + cleanup + run_merge_quality_gates + tests (1306 lines)
- mod.rs: doc, types (MergeJobStatus, MergeJob, MergeReport, SquashMergeResult), re-exports (52 lines)

Tests stay co-located.

No behaviour change. All 20 merge tests pass; full suite green
(2635 tests with --test-threads=1).
2026-04-26 21:15:06 +00:00
dave 851324740c refactor: split http/mcp/story_tools.rs into 5 sub-modules by item type
The 1864-line story_tools.rs is split into:

- story.rs: story creation/lifecycle/management (903 lines incl. tests)
- criteria.rs: acceptance-criteria tools (534 lines)
- bug.rs: bug item tools (318 lines)
- spike.rs: spike item tools (120 lines)
- refactor.rs: refactor item tools (60 lines)
- mod.rs: re-exports (25 lines)

Tests stay co-located with the code they exercise; setup_git_repo_in and
setup_story_for_update test helpers are duplicated into the modules that need
them rather than centralised, since they are tiny and test-only.

No behaviour change. All 60 story_tools tests pass; full suite green
(2635 tests with --test-threads=1).
2026-04-26 21:11:09 +00:00
dave 0dff2d5c47 refactor: split http/mcp/mod.rs into 3 logical files
The 1882-line mod.rs is split into:

- tools_list.rs: handle_tools_list — the static schema for every MCP tool (1172 lines)
- dispatch.rs: handle_tools_call — the tool-name → *_tools router (157 lines)
- mod.rs: doc, sub-mod decls, JsonRpc structs, Poem handlers, handle_initialize (586 lines)

Tests stay co-located with the code they exercise.

No behaviour change. All 267 http::mcp tests pass; full suite green
(2635 tests with --test-threads=1).
2026-04-26 21:05:07 +00:00
dave 8f91f55cd1 refactor: split io/fs/scaffold.rs into 4 sub-modules with co-located tests
The 2045-line scaffold.rs is split into a sub-module directory:

- templates.rs: STORY_KIT_* and DEFAULT_* template constants (161 lines)
- detect.rs: detect_components_toml + detect_script_{build,lint,test} + tests (989 lines)
- helpers.rs: write_*_if_missing, generate_project_toml, gitignore helpers (166 lines)
- mod.rs: scaffold_story_kit orchestrator + scaffold tests (756 lines)

include_str! paths in templates.rs are adjusted (one extra ../) for the deeper
nesting. Tests stay co-located with the code they exercise per Rust convention.

No behaviour change. All 77 scaffold tests pass; full suite green
(2635 tests with --test-threads=1).
2026-04-26 21:00:31 +00:00
dave 23e22ba49c refactor: split crdt_state.rs into 6 sub-modules with co-located tests
The 2122-line crdt_state.rs is split into a sub-module directory:

- types.rs: CRDT/view types + CrdtEvent (247 lines)
- state.rs: CrdtState struct, statics, init, apply_and_persist (531 lines)
- ops.rs: sync API + apply_remote_op + delta-sync tests (455 lines)
- write.rs: write_item + bug_511 test (273 lines)
- read.rs: read API + dump + dep helpers (469 lines)
- presence.rs: node identity + claim API + heartbeat (176 lines)
- mod.rs: doc, sub-module decls, re-exports, hex helper (53 lines)

Tests are co-located with the code they primarily exercise per Rust convention.

No behaviour change. All 26 crdt_state tests pass; full suite green
(2635 tests with --test-threads=1).
2026-04-26 20:54:15 +00:00
dave 8bdaabd06c refactor: split crdt_sync.rs into auth/wire/server/dispatch/client modules
The 3672-line crdt_sync.rs is split into a sub-module directory with
co-located tests per Rust convention:

- auth.rs: trusted-keys + bearer-token validation (230 lines)
- wire.rs: ChallengeMessage / AuthMessage / SyncMessage types (141 lines)
- server.rs: WebSocket server handler (1680 lines)
- dispatch.rs: incoming-message dispatch + bulk/clock/op handling (1028 lines)
- client.rs: rendezvous client + reconnect/backoff (464 lines)
- mod.rs: doc, cross-cutting constants, re-exports (75 lines)

No behaviour change. All 65 crdt_sync tests pass; full suite green
(2635 tests with --test-threads=1).
2026-04-26 20:36:40 +00:00
dave 795b172bba Revert "refactor: split top-5 largest files into mod.rs + tests.rs"
This reverts commit 65a3767a7a.
2026-04-26 20:15:58 +00:00
dave 65a3767a7a refactor: split top-5 largest files into mod.rs + tests.rs
Five files in server/src/ exceeded 1500 lines, with 50–75% of the line
count being inline `#[cfg(test)] mod tests { ... }` blocks. Agents
working on these files have to navigate huge buffers via Read calls,
costing turn budget that could go toward actual work.

Pattern: convert `foo.rs` to `foo/mod.rs` + `foo/tests.rs`.
Rust resolves `mod foo;` to either form, so no parent-module changes
needed.

Before / after (production-code lines, what an agent has to navigate
when editing the module):

  crdt_sync.rs:           3672 → 1003 (mod.rs) + 2667 (tests.rs)
  crdt_state.rs:          2122 → 1263 (mod.rs) + 854  (tests.rs)
  io/fs/scaffold.rs:      2045 →  702 (mod.rs) + 1342 (tests.rs)
  http/mcp/mod.rs:        1882 → 1410 (mod.rs) + 472  (tests.rs)
  http/mcp/story_tools.rs: 1864 →  725 (mod.rs) + 1137 (tests.rs)

Side change: scaffold/mod.rs's include_str! paths got an extra `../`
because the file moved one directory deeper.

Tests: full `cargo test` suite passes (2635 passed, 0 failed).
Formatting: cargo fmt --check clean.

Motivation: today's agent thrashing on 644 / 650 / 652 was partly due to
cumulative-counting (now fixed by 650) but also genuinely due to file
size — sonnet's 50-turn budget barely covers reading these files plus
making the change. Smaller production-code files mean more turn budget
left for the actual work.

Committed straight to master because this is an enabling refactor for
agent autonomy work; running it through the normal pipeline would
require an agent that has to navigate the very files it's about to
split, defeating the purpose.
2026-04-26 20:08:24 +00:00
dave ff51a1a465 huskies: merge 651_bug_remove_git_reset_clean_behaviour_from_bug_645_s_recovery_path_uncommitted_work_in_worktrees_is_never_junk 2026-04-26 16:46:25 +00:00
dave 365b907ba4 huskies: merge 650_bug_watchdog_turns_used_and_budget_used_usd_accumulate_across_all_sessions_restart_counts_against_limits_from_prior_runs 2026-04-26 16:24:10 +00:00
dave 148c88bd40 huskies: merge 646_bug_watchdog_from_bug_624_is_not_actually_enforcing_max_turns_max_budget_usd_in_production 2026-04-26 13:11:48 +00:00
dave 8673e563a9 huskies: merge 643_story_web_ui_consumer_for_the_unified_status_broadcaster 2026-04-26 11:30:32 +00:00
dave f88bb5f486 huskies: merge 645_bug_agent_runtime_panics_with_output_write_bytes_is_ok_assertion_marking_stories_falsely_blocked 2026-04-26 10:54:58 +00:00
dave d8f9be5b23 huskies: merge 641_story_unified_status_update_delivery_across_chat_web_ui_and_top_level_agent_context 2026-04-26 02:27:34 +00:00
dave dc7ae3a23c huskies: merge 637_story_peer_mesh_discovery_via_crdt_node_presence_list 2026-04-26 01:57:31 +00:00
dave b84ce1f6bb huskies: merge 636_story_full_crdt_snapshot_compaction_with_cross_node_coordination 2026-04-26 01:19:05 +00:00
dave c12a49487e huskies: merge 634_story_deterministic_claim_priority_via_hash_based_tie_break 2026-04-25 22:27:20 +00:00
dave 7548486a53 huskies: merge 633_story_crdt_sync_bearer_token_connection_auth 2026-04-25 22:13:42 +00:00
dave d826daaf41 huskies: merge 632_story_crdt_sync_handshake_with_explicit_ready_ack 2026-04-25 21:51:09 +00:00
dave fd52c29302 huskies: merge 631_story_crdt_delta_sync_via_vector_clocks_replace_full_bulk_dumps 2026-04-25 21:32:39 +00:00
dave 853f53e8e6 huskies: merge 630_story_crdt_sync_websocket_keepalive_ping_pong 2026-04-25 21:10:06 +00:00
dave 14b158d0b2 huskies: merge 629_refactor_migrate_commanddispatch_and_commandcontext_to_services_bundle 2026-04-25 20:41:19 +00:00
dave 2a3f88fdcf huskies: merge 639_refactor_migrate_whatsapp_transport_to_services_bundle 2026-04-25 19:51:59 +00:00
dave 120745d102 huskies: merge 640_bug_create_story_create_refactor_create_bug_silently_drop_the_depends_on_parameter 2026-04-25 19:37:55 +00:00
dave e4dd4bbe2c huskies: merge 638_refactor_migrate_discord_transport_to_services_bundle 2026-04-25 19:33:01 +00:00
dave 33cb2bed3e huskies: merge 627_refactor_migrate_slack_discord_and_whatsapp_transports_to_services_bundle 2026-04-25 19:01:45 +00:00
dave 4b089c1ed8 huskies: merge 626_refactor_introduce_services_bundle_and_migrate_appcontext_matrix_transport 2026-04-25 15:08:46 +00:00
dave aeff0b55be huskies: merge 628_story_websocket_connect_time_mutual_auth_using_node_identity_primitives 2026-04-25 14:33:47 +00:00
dave 9e3d2f6a69 huskies: merge 602_spike_node_identity_keypair_foundation_for_distributed_huskies 2026-04-25 14:03:59 +00:00
dave 61da29a904 huskies: merge 625_bug_cannot_add_acceptance_criteria_to_a_spike_that_s_been_converted_to_a_story 2026-04-25 13:42:56 +00:00
dave 2097787e1f docs: add pipeline state machine reference (current + planned transitions)
Captures the dual representation we have today (legacy filesystem stage
strings + front-matter flags vs the typed Stage/ArchiveReason/ExecutionState
enums in pipeline_state.rs that are defined-but-not-wired) and itemises the
transitions and behaviours we have identified as missing or partially
implemented (first-class supersede/abandon/hold verbs, type-conversion side
effects, pinned-agent honouring under contention, blocked-flag enforcement
beyond auto-assign, ghost-story recovery, etc.).

Section (b) is intended as a living dumping ground — append new
transitions and incidents as they come up so that the state-machine
roadmap (spike 613 in backlog) has a ready-made input.
2026-04-25 13:33:57 +00:00
dave e20083a283 huskies: merge 624_bug_agent_turn_and_budget_limits_not_enforced_coder_1_ran_5_6x_over_max_turns 2026-04-25 13:11:30 +00:00
dave b70ee1aa4b huskies: merge 622_story_wrap_react_state_updates_in_act_to_silence_frontend_test_warnings 2026-04-24 23:02:52 +00:00
dave e1bfbf4232 huskies: merge 619_story_service_common_consolidation_sweep 2026-04-24 21:36:49 +00:00
dave c16d9e471d huskies: merge 618_story_extract_mcp_only_domain_services 2026-04-24 21:16:19 +00:00
dave 360bca45c8 huskies: merge 617_story_split_gateway_into_service_and_transport 2026-04-24 18:43:26 +00:00
dave 271f8ea6a8 huskies: merge 616_story_extract_notifications_service 2026-04-24 18:05:42 +00:00
dave eca0ef792c huskies: merge 615_story_extract_timer_service 2026-04-24 17:43:53 +00:00
dave 62bfaf20f4 huskies: merge 611_story_extract_settings_service 2026-04-24 17:11:55 +00:00
dave da6ae89667 huskies: merge 610_story_extract_wizard_service 2026-04-24 16:46:09 +00:00