Skip to content

Comments

fix: sync pact-protocols.md with v3.5.0 and tighten imPACT/wrap-up#207

Closed
michael-wojcik wants to merge 3 commits intoSynaptic-Labs-AI:mainfrom
michael-wojcik:fix/sync-protocols-v350
Closed

fix: sync pact-protocols.md with v3.5.0 and tighten imPACT/wrap-up#207
michael-wojcik wants to merge 3 commits intoSynaptic-Labs-AI:mainfrom
michael-wojcik:fix/sync-protocols-v350

Conversation

@michael-wojcik
Copy link
Collaborator

Summary

Test plan

  • Verify pact-protocols.md imPACT section matches standalone imPACT protocol
  • Verify pact-protocols.md algedonic section includes broadcast HALT
  • Verify imPACT.md "When to terminate" is concise but complete
  • Verify wrap-up.md retains 3 cleanup steps without the Note

Closes #206

…erformance (#1)

* feat: add TeamDelete to wrap-up and session_end cleanup

Add team cleanup section to wrap-up command (shutdown teammates,
then TeamDelete). Add best-effort cleanup_stale_teams() to
session_end.py as safety net for sessions ending without wrap-up.

* feat: use last_assistant_message in validate_handoff (SDK v2.1.47)

Prefer last_assistant_message field over transcript parsing in
SubagentStop hook, with fallback for older SDK versions. Add 16
new tests covering both paths.

* feat: enrich worktree_guard error with corrected path suggestion

When blocking edits outside the worktree, include "Did you mean:
{corrected_path}" in the error message to help agents retry faster.
Add 3 new tests for path suggestion logic.

* feat: add TeammateIdle hook for stall detection and idle cleanup

New hook with two responsibilities:
- Stall detection: alerts orchestrator when agent goes idle with
  in_progress task (enables automated imPACT triggering)
- Idle cleanup: tracks consecutive idle events, suggests shutdown
  at 3, instructs orchestrator to send shutdown_request at 5

Also marks session_end, file_size_check, and file_tracker hooks
as async for reduced latency on non-critical paths.

Includes 36 new tests.

* feat: broadcast for HALT signals and TaskStop in imPACT

- HALT algedonic signals now use SendMessage broadcast to stop all
  teammates simultaneously instead of manual relay
- Add Terminate as fifth imPACT outcome using TaskStop for
  unrecoverable agents (infinite loops, context exhaustion)

* feat: model haiku for memory-agent, clarify memory scope in docs

- Set model: haiku for pact-memory-agent (purely mechanical tasks)
- Clarify in all agent skill tables and pact-agent-teams SKILL.md
  that pact-memory is for project-wide institutional knowledge only,
  not agent-level domain expertise (handled by SDK memory frontmatter)

* test: add 75 comprehensive tests for SDK optimization

Edge cases and error paths across all modified modules:
- session_end cleanup_stale_teams: 16 tests (filesystem mocking)
- teammate_idle stall/cleanup interaction: 18 tests
- validate_handoff last_assistant_message: 15 tests
- worktree_guard path suggestion: 17 tests
- hooks.json structural validation: 13 tests (new file)

1079 total tests pass, zero regressions.

* fix: address review blocking issues

- Fix task ID string comparison in teammate_idle.py (lexicographic
  "3" > "20" bug) — use int() with fallback for non-numeric IDs
- Scope cleanup_stale_teams to current session's team only via
  CLAUDE_CODE_TEAM_NAME env var (prevents cross-session deletion)
- Fix TOCTOU in write_idle_counts — acquire lock before truncating

1078 tests pass.

* fix: idle count reset on task change + worktree path validation

- Reset idle count to 0 when teammate is assigned new work (detects
  task ID change via structured idle_counts.json format)
- Validate file belongs to same project root before suggesting
  worktree path (prevents misleading suggestions from nested repos)
- Require project marker at common ancestor in fallback path
  suggestion (prevents false matches across unrelated projects)

* test: add truncation and matcher validation tests

- Test summary truncation >80 chars in session_end snapshot
- Validate pipe-separated matcher syntax in hooks.json
- Validate SubagentStart matcher covers all 11 agent types
  (auto-detects new agents from agents/ directory)

1083 tests pass.

* fix: resolve TOCTOU race in idle count tracking

Add _atomic_update_idle_counts() that locks the file (flock) around the
full read-modify-write cycle, preventing concurrent TeammateIdle events
from losing increments. Add top-level try/except to main() for defensive
error handling matching session_end.py pattern.

* fix: address review minor findings

- Simplify redundant condition in worktree_guard _find_project_root
- Add explicit tasks_dir param to cleanup_stale_teams for testability
- Document snapshot-before-cleanup ordering dependency in session_end
- Add 2 legacy idle count migration tests (int-to-dict format)
- Clarify TaskStop as force-stop in imPACT and pact-workflows protocols

* chore: bump plugin version to 3.5.0 (minor release)
Update 3 stale sections to match their source-of-truth files:
- imPACT: "Two questions, Three outcomes" → "Three questions, Five outcomes"
- Algedonic: add broadcast HALT for parallel agents
- Stall Detection: already in sync, no changes needed

Closes part of Synaptic-Labs-AI#206
- imPACT.md: condense "When to terminate" from 12 lines to 1 paragraph
- wrap-up.md: remove belt-and-suspenders note about session_end.py

Closes Synaptic-Labs-AI#206
@michael-wojcik
Copy link
Collaborator Author

Reopening on fork repo

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.

Sync pact-protocols.md with v3.5.0 and tighten imPACT/wrap-up additions

1 participant