Skip to content

Conversation

@michael-wojcik
Copy link
Collaborator

Summary

Integrates the PACT framework with Claude Code's native Task system (TaskCreate, TaskUpdate, TaskGet, TaskList) per the design at docs/plans/2026-01-28-task-system-integration-design.md.

Goals achieved:

  • Visibility: Users can track PACT workflow progress via /tasks
  • Future-proofing: Align with Claude Code's development direction
  • Deep integration: Map VSM systems (S1-S5) onto Task infrastructure

Changes:

  • Agent templates (8 files): Added self-contained Task tracking protocol with {task_id} placeholder
  • Commands (7 files): Added Task hierarchy operations to all workflows (orchestrate, comPACT, imPACT, plan-mode, rePACT, peer-review, wrap-up)
  • Hooks (6 files): Rewritten to use TaskList as primary state source with transcript fallback
  • Protocols (2 files): Updated algedonic and S2 coordination for Task integration

Key architectural decisions:

  • Agents own their Task status (S1 autonomy preserved)
  • Orchestrator creates hierarchy, agents self-report
  • Blockers/algedonic create Tasks with blockedBy dependencies
  • TaskList-first with fallback ensures backward compatibility

Test plan

  • All 708 existing tests pass
  • Hook behavior verified (TaskList-first with fallback)
  • Command Task flows verified against design
  • Agent Task tracking verified
  • Design alignment verified

Add self-contained Task tracking section to all 8 PACT agents:
- pact-architect, pact-backend-coder, pact-frontend-coder
- pact-database-engineer, pact-preparer, pact-test-engineer
- pact-memory-agent, pact-n8n

Each agent now has {task_id} placeholder for orchestrator injection,
with on-start, on-blocker, on-algedonic, and on-completion protocols.

Part of Task system integration per docs/plans/2026-01-28-task-system-integration-design.md
Update orchestrate, comPACT, and imPACT commands with Task operations:
- orchestrate: Full Task hierarchy (Feature → Phase → Agent tasks)
- comPACT: Simpler hierarchy (Feature → Agent tasks)
- imPACT: Operates on existing blocker Tasks via TaskGet/TaskUpdate

Each adds Signal Monitoring section referencing CLAUDE.md.

Part of Task system integration per docs/plans/2026-01-28-task-system-integration-design.md
Update plan-mode, rePACT, peer-review, and wrap-up with Task operations:
- plan-mode: Planning + Consultation task hierarchy
- rePACT: Nested sub-feature + phase structure
- peer-review: Review → Reviewer → Remediation → Step → Approval tasks
- wrap-up: TaskList audit logic with cleanup rules

Part of Task system integration per docs/plans/2026-01-28-task-system-integration-design.md
Update algedonic.md:
- Add Task creation flow for algedonic signals
- Agent blocks self with addBlockedBy
- Orchestrator amplifies scope (ALERT → phase, HALT → feature)

Update pact-s2-coordination.md:
- Add Task System Integration section
- Reference TaskList for conflict detection and parallel agent visibility

Part of Task system integration per docs/plans/2026-01-28-task-system-integration-design.md
Major rewrite of PACT hooks to use Task system:
- compaction_refresh.py: Read TaskList directly (Tasks survive compaction)
- phase_completion.py: Check Task statuses instead of transcript parsing
- validate_handoff.py: Verify Task protocol compliance (status, metadata)
- session_init.py: Read TaskList for resumption context
- precompact_refresh.py: Add deprecation note (Tasks make this redundant)
- stop_audit.py: New Python hook to audit orphaned in_progress Tasks

All hooks use "TaskList first, fallback to transcript" for backward compatibility.

Part of Task system integration per docs/plans/2026-01-28-task-system-integration-design.md
Extract get_task_list() and helper functions to hooks/shared/task_utils.py:
- get_task_list()
- find_feature_task()
- find_current_phase()
- find_active_agents()
- find_blockers()

Update 4 hooks to import from shared module instead of local definitions:
- compaction_refresh.py (~130 lines saved)
- phase_completion.py
- session_init.py
- stop_audit.py

Addresses DRY violation identified in PR review.
Add 40 tests covering Task system functions:
- get_task_list(): 7 tests (valid files, empty dir, malformed JSON, env vars)
- find_feature_task(): 6 tests (top-level detection, phase filtering)
- find_current_phase(): 5 tests (in-progress detection, all prefixes)
- find_active_agents(): 6 tests (agent detection, case insensitivity)
- find_blockers(): 7 tests (blocker/algedonic types, completed filter)
- build_refresh_from_tasks(): 7 tests (message formatting)
- Integration: 2 tests (Task-first main() path)

Addresses test coverage gap identified in PR review.
plan-mode.md:
- Add note explaining how orchestrate references Planning tasks
- Clarifies the plan-orchestrate Task linkage flow

wrap-up.md:
- Add note about relationship to stop_audit.py hook
- Keep cleanup rules table as intentional redundancy for self-contained commands

Addresses documentation gaps identified in PR review.
Remove explicit `tools` field from all 8 agent definitions. Per Claude Code
docs, omitting this field grants agents access to ALL tools from the parent
conversation, including TaskCreate, TaskUpdate, TaskGet, TaskList.

This enables agents to:
- Mark themselves in_progress on start
- Create blocker/algedonic Tasks directly
- Mark themselves completed with metadata

Fixes the "S1 agents own their status" design by giving agents actual
Task tool access.
- Remove tools: field from all agents (grants all tool access by default)
- Standardize permissionMode to acceptEdits for all agents
- Standardize PACT operational sections to bold format (HANDOFF, AUTONOMY CHARTER, BEFORE COMPLETING, TASK TRACKING, HOW TO HANDLE BLOCKERS)

This enables agents to manage their own Task state via TaskCreate/TaskUpdate tools.
- Create pact-task-tracking skill with task tracking protocol
- Add skills: [pact-task-tracking] to all 8 agent frontmatter fields
- Remove duplicated TASK TRACKING sections from agent bodies (~30 lines x 8 agents)

The skill is auto-loaded when agents are invoked via Task tool, ensuring
consistent task tracking behavior without relying on agents to remember
to invoke it manually.
- Remove HOW TO HANDLE BLOCKERS from pact-task-tracking skill
- Restore generic blocker section to 6 agents (backend, frontend, database, test, preparer, architect)
- Domain-specific blocker sections remain in pact-n8n and pact-memory-agent

Future DRY opportunity tracked in issue #119.
Address peer review minor items (M1-M7):
- M1: Add Claude Code Task System docs link to skill
- M2: Add task ID placeholder note explaining orchestrator injection
- M3: Update skill description to mention auto-loading
- M4: Verify section ordering (already correct)
- M5: Add permissionMode documentation comment
- M6: Create skills README with naming conventions
- M7: Add 9 pytest tests for skill loading validation

Address future item F4:
- Create pact-task-hierarchy.md documenting Feature→Phase→Agent model
- Add Task Hierarchy section to pact-protocols.md
- Reference hierarchy from pact-task-tracking skill
Add Task System Integration subsection to S2 Coordination in
pact-protocols.md, matching content already in the extract file.
Update verify-protocol-extracts.sh line ranges to account for
the 21 new lines added to the SSOT.

All 10 protocol extracts now pass verification.
Clarify Feature task as parent container (not blocker) in hierarchy
docs. Add explicit CODE-blocked-by-ARCHITECT step to match blocking
diagram. Move skill_content fixture to module level to eliminate
duplication between test classes.
Both agents were missing the standard blocker protocol section that all
other 6 agents have. Added it immediately before each file's existing
DOMAIN-SPECIFIC BLOCKERS section.
Replace the brief reference stub in pact-protocols.md with the full
Task Hierarchy content (74 lines). Convert pact-task-hierarchy.md to
a verbatim extract. Add verification entry to the extract script.
All 11 extracts now pass verification.
@michael-wojcik michael-wojcik merged commit 21bca1c into main Jan 28, 2026
michael-wojcik added a commit that referenced this pull request Jan 28, 2026
Add PR #118 key feature entry, update protocol extract count to 11,
update test count to 757.
michael-wojcik added a commit that referenced this pull request Jan 28, 2026
michael-wojcik added a commit that referenced this pull request Jan 29, 2026
…tration (#118)"

This reverts commit 21bca1c (PR #118), giving us a clean baseline
for reimplementation with the orchestrator-only architecture.

The original integration assumed sub-agents could call Task tools
(TaskCreate, TaskUpdate, etc.), but empirical testing revealed this
is a Claude Code platform limitation — only the parent orchestrator
process has access to these tools.

Reimplementation follows the revised plan at
docs/plans/2026-01-28-task-system-revised-design.md
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