Commit Graph

258 Commits

Author SHA1 Message Date
Dave
076324c470 Fix pipe buffer deadlock in quality gate test runner
run_command_with_timeout piped stdout/stderr but only read them after
the child exited. When test output exceeded the 64KB OS pipe buffer,
the child blocked on write() while the parent blocked on waitpid() —
a permanent deadlock that caused every merge pipeline to hang.

Drain both pipes in background threads so the buffers never fill.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 12:49:12 +00:00
Dave
7c6e1b445d Make merge_agent_work async to avoid MCP 60-second tool timeout
The merge pipeline (squash merge + quality gates) takes well over 60
seconds. Claude Code's MCP HTTP transport times out at 60s, causing
"completed with no output" — the mergemaster retries fruitlessly.

merge_agent_work now starts the pipeline as a background task and
returns immediately. A new get_merge_status tool lets the mergemaster
poll until the job reaches a terminal state. Also adds a double-start
guard so concurrent calls for the same story are rejected.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 12:15:42 +00:00
Dave
ebbbfed1d9 Add 10-minute timeout to test commands and disable e2e in merge pipeline
Test commands in run_project_tests now use wait-timeout to enforce a
600-second ceiling, preventing hung processes (e.g. Playwright with no
server) from blocking the merge pipeline indefinitely. Also disables
e2e tests in script/test until the merge workspace can run them safely.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 11:32:44 +00:00
Dave
be61803af0 story-kit: merge 255_story_show_agent_logs_in_expanded_story_popup 2026-03-17 00:49:43 +00:00
Dave
2fae9066e2 story-kit: merge 254_story_add_refactor_work_item_type 2026-03-17 00:40:37 +00:00
Dave
b9f3449021 story-kit: support agent assignment via story front matter (story 249)
Adds an optional `agent:` field to story file front matter so that a
specific agent can be requested for a story. The auto-assign loop now:

1. Reads the front-matter `agent` field for each story before picking
   a free agent.
2. If a preferred agent is named, uses it when free; skips the story
   (without falling back) when that agent is busy.
3. Falls back to the existing `find_free_agent_for_stage` behaviour
   when no preference is specified.

Ported from feature branch that predated the agents.rs module refactoring.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 00:03:49 +00:00
Dave
7c3a756a5c Refactor agents.rs (7631 lines) into agents/ module directory
Split the monolithic agents.rs into 6 focused modules:
- mod.rs: shared types (AgentEvent, AgentStatus, etc.) and re-exports
- pool.rs: AgentPool struct, all methods, and helper free functions
- pty.rs: PTY streaming (run_agent_pty_blocking, emit_event)
- lifecycle.rs: story movement functions (move_story_to_qa, etc.)
- gates.rs: acceptance gates (clippy, tests, coverage)
- merge.rs: squash-merge, conflict resolution, quality gates

All 121 original tests are preserved and distributed across modules.
Also adds clear_front_matter_field to story_metadata.rs to strip
stale merge_failure from front matter when stories move to done.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-16 23:06:14 +00:00
Dave
225137fbdc story-kit: instruct coder agents to find root causes for bugs (story 252)
Add "Bug Workflow: Root Cause First" guidance to all coder agent prompts
and system prompts. Adds a test ensuring all coder-stage agents include
root cause, git bisect/log, and anti-workaround instructions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-16 19:33:54 +00:00
Dave
ec652a6fe8 story-kit: enforce cryptographic identity verification for Matrix commands (story 246)
Remove the require_verified_devices config toggle. The bot now always requires
encrypted rooms and cross-signing-verified devices before executing any command.
Messages from unencrypted rooms or unverified devices are rejected.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-14 19:56:38 +00:00
Dave
3a430dfaa2 story-kit: done 240_story_btw_side_question_slash_command
Implement /btw side question slash command — lets users ask quick
questions from conversation context without disrupting the main chat.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 18:09:30 +00:00
Dave
6a477de2e1 story-kit: merge 227_bug_thinking_traces_visible_in_agents_panel_in_release_builds_only 2026-03-13 18:36:29 +00:00
Dave
c166fe24f5 story-kit: merge 238_story_mergemaster_handles_merge_conflicts_by_resolving_them_automatically 2026-02-28 10:14:17 +00:00
Dave
894231428e story-kit: merge 236_story_show_test_results_for_a_story_in_expanded_work_item 2026-02-28 09:38:51 +00:00
Dave
7574e3b4bc story-kit: done 225_story_surface_merge_conflicts_and_failures_in_the_web_ui 2026-02-27 16:41:20 +00:00
Dave
1433115f9b fix: add missing closing brace and #[test] attribute in context.rs
The permission_decision_equality test was missing its closing brace,
causing it to swallow the not_found_returns_404_status test function.
This was likely caused by a bad merge conflict resolution.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 11:22:42 +00:00
Dave
101bfd78fe story-kit: merge 224_story_expand_work_item_to_full_screen_detail_view 2026-02-27 11:21:46 +00:00
Dave
f8c13ec274 story-kit: merge 230_story_prevent_duplicate_stage_agents_on_same_story 2026-02-27 11:05:24 +00:00
Dave
38a2de472b story-kit: merge 232_story_fix_incorrect_bug_tool_descriptions_in_mcp_tools_list 2026-02-27 10:57:35 +00:00
Dave
0fe894c5a4 story-kit: merge 231_bug_agent_silently_disappears_when_worktree_creation_fails 2026-02-27 10:53:09 +00:00
Dave
850ca15a6c story-kit: merge 226_bug_mergemaster_accepts_stories_without_squash_merging_code 2026-02-27 10:39:45 +00:00
Dave
f8bbe1ea31 story-kit: merge 225_story_surface_merge_conflicts_and_failures_in_the_web_ui 2026-02-27 10:26:28 +00:00
Dave
eeec745abc story-219: add Always Allow button to web UI permission dialog
Cherry-pick from feature branch — code was never squash-merged
despite story being accepted (bug 226).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 10:00:33 +00:00
Dave
8f0624f012 story-kit: merge 216_story_merge_quality_gates_should_use_project_toml_components_and_script_test_instead_of_hardcoded_frontend_pnpm 2026-02-26 19:33:21 +00:00
Dave
80904dc2d1 fix: permission-prompt-tool response format and scaffold .claude/settings.json
- Return { behavior: "allow", updatedInput: <input> } from prompt_permission
  to match the Claude Code SDK expected format (was returning just
  { behavior: "allow" } which failed validation)
- Scaffold .claude/settings.json with sensible permission defaults (Edit,
  Write, common Bash commands, mcp__story-kit__*) so fresh projects don't
  trigger constant permission prompts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 19:02:11 +00:00
Dave
733b92337e story-kit: merge 217_story_scaffold_generates_claude_md 2026-02-26 18:31:36 +00:00
Dave
2148531a46 fix: auto-assign after merge, persistent server logs, remove duplicate pnpm install
- Call auto_assign_available_work at end of merge_agent_work so the next
  story gets picked up without waiting for the PTY exit handler
- Add persistent file logging to .story_kit/logs/server.log so server
  logs survive restarts
- Remove duplicate pnpm install block in run_squash_merge

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 18:24:27 +00:00
Dave
c952341fc8 story-kit: merge 214_story_scaffold_creates_complete_project_structure 2026-02-26 17:19:11 +00:00
Dave
d908a54fc4 story-kit: merge 180_bug_web_ui_permissions_handling_unreliable 2026-02-26 17:10:54 +00:00
Dave
ac087f1a58 chore: add MERGE-DEBUG traces for project_root lifecycle
Temporary diagnostic logging to track why project_root becomes None
during merge pipeline operations. Tagged with MERGE-DEBUG for easy
grep-and-remove once the root cause is confirmed fixed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 17:01:38 +00:00
Dave
774a731042 bug-210: prevent pipeline from moving story to done when mergemaster reports failure
The pipeline advancement logic was ignoring report_merge_failure and
blindly trusting the server-owned completion gates_passed result. Now
report_merge_failure sets a flag on the agent entry that the pipeline
checks before advancing — stories stay in 4_merge/ when merge fails.

Squash merge of feature/story-210

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-26 16:12:23 +00:00
Dave
930708ebac fix: add missing port argument to open_project test calls
The merge of story-209 (positional path argument) added a port parameter
to open_project, but two test call sites were not updated.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 15:46:36 +00:00
Dave
8e0082f6cd story-209: accept optional positional path argument on startup
Add CLI path argument support: `story-kit-server /path/to/project` opens
the given project directly (scaffolding .story_kit/ if needed) instead of
relying on auto-detection. Resolves conflict with story-208's port parameter.

Squash merge of feature/story-209

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-26 15:17:40 +00:00
Dave
17fd3b2dc2 story-kit: merge 208_bug_project_scaffold_does_not_write_mcp_json_to_project_root 2026-02-26 14:59:19 +00:00
Dave
40d96008c9 feat(story-200): auto-prune worktrees when stories are archived
- Add `prune_worktree_sync` to worktree.rs: removes a story's worktree
  if it exists, delegating to `remove_worktree_sync` (best-effort,
  failures logged internally)
- Update `sweep_done_to_archived` to accept `git_root` and call
  `prune_worktree_sync` after promoting a story from 5_done to 6_archived
- Add Part 2 to the sweep: scan 6_archived and prune any stale worktrees
  for stories already there (catches items archived before this feature)
- All worktree removal failures are logged but never block file moves
- Add 5 new tests: prune noop, prune real worktree, sweep-on-promote,
  sweep-stale-archived, sweep-not-blocked-by-removal-failure

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-26 14:58:52 +00:00
Dave
81065a3ada fix: replace fast-forward with cherry-pick in mergemaster squash-merge
The mergemaster pipeline used git merge --ff-only to apply the squash
commit from a merge-queue branch onto master. This raced with the
filesystem watcher which auto-commits pipeline file moves to master,
causing the fast-forward to fail. The mergemaster agent would then
improvise by manually moving stories to done without the code merge.

- Replace --ff-only with cherry-pick so concurrent watcher commits
  don't block the merge
- Add report_merge_failure MCP tool for explicit failure handling
- Update mergemaster prompt to forbid manual file moves
- Fix cleanup_merge_workspace to handle stale directories

Squash merge of feature/story-205

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 14:16:35 +00:00
Dave
819b72523f story-kit: merge 203_story_move_story_to_current_before_checking_agent_availability_in_start_agent 2026-02-26 12:41:12 +00:00
Dave
77547972c4 feat(story-193): clickable code references in frontend 2026-02-26 12:34:57 +00:00
Dave
2dbfd42c6e story-kit: done 199_story_web_ui_submits_all_queued_items_at_once 2026-02-26 12:16:07 +00:00
Dave
08e23e3830 feat: enable Matrix E2EE with cross-signing verification on bot
Add end-to-end encryption support to the Matrix bot using the matrix-sdk
crypto features. The bot now:
- Enables E2EE on the Matrix client with cross-signing bootstrapping
- Auto-verifies its own cross-signing identity on startup
- Handles key verification requests from other users automatically
- Sends encrypted messages in E2EE-enabled rooms
- Adds MATRIX_STORE_PATH config for persistent crypto store

Squash merge of feature/story-194_story_enable_matrix_e2ee_with_cross_signing_verification_on_bot

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 10:41:29 +00:00
Dave
d20f9b8018 Fixed up @ mentions on the bot 2026-02-25 17:00:29 +00:00
Dave
0361322361 story-kit: merge 192_bug_code_fences_lose_newlines_when_pasted_from_agent_output 2026-02-25 16:47:34 +00:00
Dave
ae4fb3ae2c feat(matrix): bot only responds when directly addressed
Story 191: Matrix bot should only respond when directly addressed.
The bot now checks if it was mentioned by name or replied to before
responding, preventing it from answering every message in a room.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 16:33:30 +00:00
Dave
411653ab15 story-kit: merge 190_story_auto_select_available_agent_for_stage_in_start_agent 2026-02-25 16:17:38 +00:00
Dave
d4f23051aa feat(matrix): render bot messages with HTML formatting
Add HTML formatted_body to Matrix bot messages so that markdown-style
formatting (code blocks, bold, italic, lists) renders properly in Matrix
clients. Uses the pulldown-cmark crate to convert markdown to HTML and
sets the message format to org.matrix.custom.html.

Story: 188_story_render_matrix_bot_messages_with_html_formatting
2026-02-25 16:08:57 +00:00
Dave
4b4d221d6c story-kit: merge 182_story_matrix_bot_conversation_context_and_multi_room 2026-02-25 15:25:13 +00:00
Dave
ebcd627a45 Fix: remove agent from pool immediately on completion and add Matrix bot user allowlist 2026-02-25 14:59:20 +00:00
Dave
e682b64890 Stream Matrix bot responses on double-newline paragraph boundaries
Instead of waiting for the full LLM response and sending it as a single
message, stream bot responses to Matrix as they are generated. Paragraphs
are delimited by double-newline boundaries, giving users incremental
feedback while the model is still thinking.

Story: 184_story_stream_bot_responses_to_matrix_on_double_newline_boundaries
2026-02-25 14:17:55 +00:00
Dave
23e1830da2 Adding some Matrix bot debug code 2026-02-25 13:46:20 +00:00
Dave
a1d25d756b story-kit: merge 183_story_refactor_matrix_bot_to_use_claude_code_provider_instead_of_direct_anthropic_api 2026-02-25 12:42:11 +00:00
Dave
aa423cae22 story-kit: merge 177_bug_no_mcp_tool_to_edit_story_acceptance_criteria 2026-02-25 11:34:37 +00:00