pact-agents 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. pact_agents-0.1.0/.github/workflows/publish.yml +27 -0
  2. pact_agents-0.1.0/.gitignore +38 -0
  3. pact_agents-0.1.0/CLAUDE.md +240 -0
  4. pact_agents-0.1.0/LICENSE +21 -0
  5. pact_agents-0.1.0/Makefile +38 -0
  6. pact_agents-0.1.0/PKG-INFO +292 -0
  7. pact_agents-0.1.0/README.md +255 -0
  8. pact_agents-0.1.0/config.yaml +23 -0
  9. pact_agents-0.1.0/docs/.nojekyll +0 -0
  10. pact_agents-0.1.0/docs/index.html +622 -0
  11. pact_agents-0.1.0/pyproject.toml +66 -0
  12. pact_agents-0.1.0/src/pact/__init__.py +3 -0
  13. pact_agents-0.1.0/src/pact/agents/__init__.py +1 -0
  14. pact_agents-0.1.0/src/pact/agents/base.py +86 -0
  15. pact_agents-0.1.0/src/pact/agents/code_author.py +351 -0
  16. pact_agents-0.1.0/src/pact/agents/contract_author.py +172 -0
  17. pact_agents-0.1.0/src/pact/agents/research.py +290 -0
  18. pact_agents-0.1.0/src/pact/agents/shaper.py +306 -0
  19. pact_agents-0.1.0/src/pact/agents/test_author.py +284 -0
  20. pact_agents-0.1.0/src/pact/agents/trace_analyst.py +135 -0
  21. pact_agents-0.1.0/src/pact/agents/triage.py +202 -0
  22. pact_agents-0.1.0/src/pact/analyzer.py +303 -0
  23. pact_agents-0.1.0/src/pact/backends/__init__.py +64 -0
  24. pact_agents-0.1.0/src/pact/backends/anthropic.py +367 -0
  25. pact_agents-0.1.0/src/pact/backends/claude_code.py +276 -0
  26. pact_agents-0.1.0/src/pact/backends/claude_code_team.py +258 -0
  27. pact_agents-0.1.0/src/pact/backends/gemini.py +113 -0
  28. pact_agents-0.1.0/src/pact/backends/openai.py +318 -0
  29. pact_agents-0.1.0/src/pact/budget.py +272 -0
  30. pact_agents-0.1.0/src/pact/checklist_gen.py +252 -0
  31. pact_agents-0.1.0/src/pact/cli.py +1890 -0
  32. pact_agents-0.1.0/src/pact/config.py +517 -0
  33. pact_agents-0.1.0/src/pact/contracts.py +396 -0
  34. pact_agents-0.1.0/src/pact/daemon.py +471 -0
  35. pact_agents-0.1.0/src/pact/decomposer.py +447 -0
  36. pact_agents-0.1.0/src/pact/design_doc.py +119 -0
  37. pact_agents-0.1.0/src/pact/diagnoser.py +171 -0
  38. pact_agents-0.1.0/src/pact/drift.py +228 -0
  39. pact_agents-0.1.0/src/pact/events.py +300 -0
  40. pact_agents-0.1.0/src/pact/human/__init__.py +1 -0
  41. pact_agents-0.1.0/src/pact/human/context.py +182 -0
  42. pact_agents-0.1.0/src/pact/human/git.py +214 -0
  43. pact_agents-0.1.0/src/pact/human/linear.py +397 -0
  44. pact_agents-0.1.0/src/pact/human/slack.py +197 -0
  45. pact_agents-0.1.0/src/pact/implementer.py +1287 -0
  46. pact_agents-0.1.0/src/pact/incidents.py +228 -0
  47. pact_agents-0.1.0/src/pact/integrator.py +611 -0
  48. pact_agents-0.1.0/src/pact/interface_stub.py +1094 -0
  49. pact_agents-0.1.0/src/pact/lifecycle.py +345 -0
  50. pact_agents-0.1.0/src/pact/mcp_server.py +262 -0
  51. pact_agents-0.1.0/src/pact/pitch_utils.py +88 -0
  52. pact_agents-0.1.0/src/pact/project.py +683 -0
  53. pact_agents-0.1.0/src/pact/quality.py +69 -0
  54. pact_agents-0.1.0/src/pact/remediator.py +321 -0
  55. pact_agents-0.1.0/src/pact/research_cache.py +79 -0
  56. pact_agents-0.1.0/src/pact/resolution.py +67 -0
  57. pact_agents-0.1.0/src/pact/retrospective.py +265 -0
  58. pact_agents-0.1.0/src/pact/scheduler.py +928 -0
  59. pact_agents-0.1.0/src/pact/schemas.py +544 -0
  60. pact_agents-0.1.0/src/pact/schemas_monitoring.py +89 -0
  61. pact_agents-0.1.0/src/pact/schemas_shaping.py +113 -0
  62. pact_agents-0.1.0/src/pact/schemas_tasks.py +215 -0
  63. pact_agents-0.1.0/src/pact/sentinel.py +339 -0
  64. pact_agents-0.1.0/src/pact/signals.py +378 -0
  65. pact_agents-0.1.0/src/pact/standards.py +189 -0
  66. pact_agents-0.1.0/src/pact/task_list.py +391 -0
  67. pact_agents-0.1.0/src/pact/test_harness.py +400 -0
  68. pact_agents-0.1.0/src/pact/wavefront.py +209 -0
  69. pact_agents-0.1.0/task_r2.md +1092 -0
  70. pact_agents-0.1.0/task_r3.md +447 -0
  71. pact_agents-0.1.0/tests/__init__.py +0 -0
  72. pact_agents-0.1.0/tests/test_analyzer.py +370 -0
  73. pact_agents-0.1.0/tests/test_approve_matching.py +88 -0
  74. pact_agents-0.1.0/tests/test_artifact_metadata.py +102 -0
  75. pact_agents-0.1.0/tests/test_budget.py +146 -0
  76. pact_agents-0.1.0/tests/test_build_mode.py +192 -0
  77. pact_agents-0.1.0/tests/test_cache_threading.py +122 -0
  78. pact_agents-0.1.0/tests/test_checklist_gen.py +411 -0
  79. pact_agents-0.1.0/tests/test_cli_niceties.py +654 -0
  80. pact_agents-0.1.0/tests/test_cli_tasks.py +387 -0
  81. pact_agents-0.1.0/tests/test_compact_context.py +161 -0
  82. pact_agents-0.1.0/tests/test_config.py +219 -0
  83. pact_agents-0.1.0/tests/test_context_compression.py +140 -0
  84. pact_agents-0.1.0/tests/test_contracts.py +354 -0
  85. pact_agents-0.1.0/tests/test_daemon.py +135 -0
  86. pact_agents-0.1.0/tests/test_daemon_activity.py +47 -0
  87. pact_agents-0.1.0/tests/test_decomposer.py +91 -0
  88. pact_agents-0.1.0/tests/test_decomposer_modes.py +270 -0
  89. pact_agents-0.1.0/tests/test_design_doc.py +126 -0
  90. pact_agents-0.1.0/tests/test_diagnoser.py +44 -0
  91. pact_agents-0.1.0/tests/test_directive.py +142 -0
  92. pact_agents-0.1.0/tests/test_drift.py +205 -0
  93. pact_agents-0.1.0/tests/test_environment.py +87 -0
  94. pact_agents-0.1.0/tests/test_error_classification.py +74 -0
  95. pact_agents-0.1.0/tests/test_event_sourcing.py +97 -0
  96. pact_agents-0.1.0/tests/test_events.py +260 -0
  97. pact_agents-0.1.0/tests/test_external_deps.py +159 -0
  98. pact_agents-0.1.0/tests/test_focused_contract.py +129 -0
  99. pact_agents-0.1.0/tests/test_gemini_backend.py +164 -0
  100. pact_agents-0.1.0/tests/test_git_read.py +194 -0
  101. pact_agents-0.1.0/tests/test_hierarchy.py +161 -0
  102. pact_agents-0.1.0/tests/test_implementer.py +549 -0
  103. pact_agents-0.1.0/tests/test_incidents.py +251 -0
  104. pact_agents-0.1.0/tests/test_incremental_validation.py +94 -0
  105. pact_agents-0.1.0/tests/test_integration_context.py +225 -0
  106. pact_agents-0.1.0/tests/test_integrator.py +373 -0
  107. pact_agents-0.1.0/tests/test_interactive_impl.py +397 -0
  108. pact_agents-0.1.0/tests/test_interface_stub.py +387 -0
  109. pact_agents-0.1.0/tests/test_interview_v2.py +201 -0
  110. pact_agents-0.1.0/tests/test_lifecycle.py +102 -0
  111. pact_agents-0.1.0/tests/test_linear_read.py +243 -0
  112. pact_agents-0.1.0/tests/test_log_keys.py +126 -0
  113. pact_agents-0.1.0/tests/test_mcp_server.py +167 -0
  114. pact_agents-0.1.0/tests/test_model_tiers.py +97 -0
  115. pact_agents-0.1.0/tests/test_openai_backend.py +159 -0
  116. pact_agents-0.1.0/tests/test_parallel.py +920 -0
  117. pact_agents-0.1.0/tests/test_phase_budget.py +63 -0
  118. pact_agents-0.1.0/tests/test_project.py +392 -0
  119. pact_agents-0.1.0/tests/test_prompt_cache.py +119 -0
  120. pact_agents-0.1.0/tests/test_quality.py +138 -0
  121. pact_agents-0.1.0/tests/test_remediator.py +496 -0
  122. pact_agents-0.1.0/tests/test_research_cache.py +137 -0
  123. pact_agents-0.1.0/tests/test_research_sharing.py +83 -0
  124. pact_agents-0.1.0/tests/test_resume.py +100 -0
  125. pact_agents-0.1.0/tests/test_retrospective.py +190 -0
  126. pact_agents-0.1.0/tests/test_scheduler.py +158 -0
  127. pact_agents-0.1.0/tests/test_schemas.py +388 -0
  128. pact_agents-0.1.0/tests/test_schemas_monitoring.py +251 -0
  129. pact_agents-0.1.0/tests/test_schemas_tasks.py +491 -0
  130. pact_agents-0.1.0/tests/test_sentinel.py +216 -0
  131. pact_agents-0.1.0/tests/test_shaping.py +583 -0
  132. pact_agents-0.1.0/tests/test_shared_preamble.py +64 -0
  133. pact_agents-0.1.0/tests/test_signals.py +246 -0
  134. pact_agents-0.1.0/tests/test_slack_read.py +169 -0
  135. pact_agents-0.1.0/tests/test_standards.py +301 -0
  136. pact_agents-0.1.0/tests/test_systemic.py +115 -0
  137. pact_agents-0.1.0/tests/test_task_list.py +584 -0
  138. pact_agents-0.1.0/tests/test_test_harness.py +126 -0
  139. pact_agents-0.1.0/tests/test_timeouts.py +96 -0
  140. pact_agents-0.1.0/tests/test_triage.py +282 -0
  141. pact_agents-0.1.0/tests/test_wavefront.py +240 -0
@@ -0,0 +1,27 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions:
8
+ id-token: write
9
+
10
+ jobs:
11
+ publish:
12
+ runs-on: ubuntu-latest
13
+ environment: pypi
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - uses: actions/setup-python@v5
18
+ with:
19
+ python-version: "3.12"
20
+
21
+ - name: Build
22
+ run: |
23
+ pip install build
24
+ python -m build
25
+
26
+ - name: Publish to PyPI
27
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,38 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.egg-info/
6
+ *.egg
7
+ dist/
8
+ build/
9
+ .eggs/
10
+
11
+ # Virtual environments
12
+ .venv/
13
+ venv/
14
+ env/
15
+
16
+ # IDE
17
+ .idea/
18
+ .vscode/
19
+ *.swp
20
+ *.swo
21
+ *~
22
+
23
+ # Testing
24
+ .pytest_cache/
25
+ .coverage
26
+ htmlcov/
27
+
28
+ # OS
29
+ .DS_Store
30
+ Thumbs.db
31
+
32
+ # Project runtime state (generated per-project, not checked in)
33
+ .pact/
34
+
35
+ # Secrets
36
+ .env
37
+ *.key
38
+ *.pem
@@ -0,0 +1,240 @@
1
+ # CLAUDE.md -- Pact
2
+
3
+ Contract-first multi-agent software engineering. Decomposition produces contracts and tests, not code. Black-box implementations verified by functional tests at boundaries. Recursive composition.
4
+
5
+ ## Quick Reference
6
+
7
+ ```bash
8
+ cd ~/WanderRepos/pact
9
+ python3 -m pytest tests/ -v # Run all tests
10
+ pact init <project-dir> # Initialize project
11
+ pact status <project-dir> # Show state
12
+ pact components <project-dir> # List components
13
+ pact build <project-dir> <id> # Build specific component
14
+ pact run <project-dir> # Execute pipeline
15
+ pact tasks <project-dir> # Generate/display task list
16
+ pact analyze <project-dir> # Cross-artifact analysis
17
+ pact checklist <project-dir> # Requirements quality checklist
18
+ pact export-tasks <project-dir> # Export TASKS.md
19
+ pact directive <project-dir> <json> # Send structured directive to daemon
20
+ ```
21
+
22
+ **Entry point**: `pact = "pact.cli:main"` (pyproject.toml)
23
+
24
+ **Python**: >=3.12 | **Dependencies**: pydantic>=2.0, pyyaml>=6.0 | **Optional**: anthropic>=0.40
25
+
26
+ ## Architecture Overview
27
+
28
+ ### Research-First Agent Protocol
29
+
30
+ Every agent follows 3 phases: Research -> Plan+Evaluate -> Execute. Research and plan outputs are persisted alongside work products.
31
+
32
+ ### Core Workflow
33
+
34
+ 1. **Interview** -- System reads task+SOPs, identifies risks/ambiguities, asks user clarifying questions
35
+ 2. **Shape** -- (Optional) Produce a Shape Up pitch: appetite, breadboard, rabbit holes, no-gos
36
+ 3. **Decompose** -- Task -> DecompositionNode tree (2-7 components), guided by shaping context
37
+ 3. **Contract** -- For each component (leaves first), generate ComponentContract
38
+ 4. **Test** -- For each contract, generate ContractTestSuite with executable tests
39
+ 5. **Validate** -- Mechanical gate: all refs resolve, no cycles, test code parses
40
+ 6. **Implement** -- Each component independently by code_author agent, verified by contract tests
41
+ 7. **Integrate** -- Parent components: glue code wiring children, parent-level tests
42
+ 8. **Diagnose** -- On failure: I/O tracing, systematic error recovery
43
+
44
+ ### Execution Modes
45
+
46
+ Two independent levers:
47
+ - `parallel_components: true` -- Independent leaves implement concurrently (semaphore-limited)
48
+ - `competitive_implementations: true` -- N agents implement same component, best wins
49
+ - `plan_only: true` -- Stop after contracts, use `pact build` to target specific nodes
50
+ - `max_concurrent_agents: 4` -- Concurrency limit for parallel modes
51
+
52
+ ### Build Modes
53
+
54
+ Three build modes control decomposition behavior:
55
+
56
+ ```yaml
57
+ # pact.yaml
58
+ build_mode: auto # unary | auto | hierarchy
59
+ ```
60
+
61
+ - **unary**: Single agent session. Skips LLM decomposition, creates one component with the full task. Still produces contract+tests for verification.
62
+ - **auto** (default): LLM decides whether to decompose or implement directly. Improved prompts genuinely encourage `is_trivial=true` for straightforward tasks.
63
+ - **hierarchy**: Always decompose into multiple components (previous default behavior).
64
+
65
+ Project config overrides global config. Set at runtime via directive:
66
+ ```bash
67
+ pact directive ./my-proj '{"type": "set_mode", "mode": "unary"}'
68
+ ```
69
+
70
+ ### Global Standards
71
+
72
+ After decomposition, pact automatically collects shared conventions from contracts:
73
+ - Shared types (appearing in 2+ contracts)
74
+ - Common validator patterns
75
+ - Package requirements
76
+ - Coding conventions from SOPs
77
+
78
+ Standards are injected into every agent's handoff brief and persisted at `.pact/standards.json`.
79
+
80
+ ### Production Monitoring & Auto-Remediation
81
+
82
+ Opt-in (`monitoring_enabled: true`). Pact-generated code embeds `PACT:<project_hash>:<component_id>` log keys. The Sentinel watches log files, processes, and webhooks for errors, attributes them to components via log keys (or LLM triage), and spawns knowledge-flashed fixer agents that add a reproducer test and rebuild the black box. Multi-window budget caps (per-incident/hourly/daily/weekly/monthly) prevent runaway spend.
83
+
84
+ **Narrative retry**: On retry attempts, the remediator carries forward prior failures, test results, research reports, and plan evaluations — matching the `implementer.py` pattern. A heroic narrative reframe ("senior engineer brought in because the previous approach failed") prevents the model from falling into the same reasoning rut. `build_narrative_debrief()` is a pure, testable function.
85
+
86
+ **Budget hypervisor**: `estimate_tokens()` provides content-aware token estimation (symbol ratio → chars/token: 3.5 for code, 4.5 for prose). `record_tokens_validated()` cross-validates reported vs estimated counts using `max()` for conservative accounting. The `claude_code` backend no longer falls back to `len(text) // 4`. The `claude_code_team` backend now tracks spend via estimation.
87
+
88
+ ### Casual-Pace Scheduling
89
+
90
+ Poll-based, not event-loop. Agents invoked for focused bursts, state fully persisted between bursts.
91
+
92
+ ## Source Layout
93
+
94
+ ```
95
+ src/pact/
96
+ schemas.py # All Pydantic models
97
+ schemas_shaping.py # Shaping phase models (ShapingPitch, Breadboard, etc.)
98
+ pitch_utils.py # Pitch summary, formatting, handoff context
99
+ contracts.py # Contract validation (mechanical gates)
100
+ test_harness.py # Functional test execution
101
+ design_doc.py # Living design document
102
+ decomposer.py # Task -> Contracts workflow
103
+ implementer.py # Contract -> Code workflow (parallel + competitive)
104
+ integrator.py # Composition + I/O tracing (parallel depth groups)
105
+ resolution.py # Competitive resolution (score, pick winner)
106
+ diagnoser.py # Error recovery
107
+ scheduler.py # Casual-pace polling + component targeting
108
+ project.py # Project directory lifecycle + attempt storage
109
+ config.py # GlobalConfig + ProjectConfig + ParallelConfig
110
+ budget.py # Per-project spend tracking + content-aware token estimation
111
+ lifecycle.py # Run state machine
112
+ daemon.py # Event-driven FIFO-based coordinator
113
+ interface_stub.py # Interface stub generation + log key preamble
114
+ standards.py # Global standards collection + rendering
115
+ cli.py # CLI entry points
116
+
117
+ # Spec-kit capabilities (task list, analysis, checklist)
118
+ schemas_tasks.py # Task list, analysis, checklist Pydantic models
119
+ task_list.py # Task list generation + rendering (mechanical, no LLM)
120
+ analyzer.py # Cross-artifact consistency analysis (mechanical)
121
+ checklist_gen.py # Requirements quality checklist generation (mechanical)
122
+
123
+ # Monitoring subsystem
124
+ schemas_monitoring.py # Monitoring models (Signal, Incident, MonitoringBudget, etc.)
125
+ signals.py # Signal ingestion (LogTailer, ProcessWatcher, WebhookReceiver)
126
+ incidents.py # Incident lifecycle + multi-window budget enforcement
127
+ remediator.py # Knowledge-flashed fixer (reproducer test + rebuild + narrative retry)
128
+ sentinel.py # Long-running monitor coordinator
129
+
130
+ agents/
131
+ base.py # AgentBase (reuses Backend protocol)
132
+ research.py # Best-practices research + plan evaluation
133
+ contract_author.py # Generates interface contracts
134
+ test_author.py # Generates functional tests from contracts
135
+ code_author.py # Implements black boxes (embeds PACT log keys)
136
+ shaper.py # Shape Up pitch generation agent
137
+ trace_analyst.py # I/O tracing for diagnosis
138
+ triage.py # Error-to-component mapping + diagnostic reports
139
+
140
+ backends/
141
+ __init__.py # Backend protocol + factory
142
+ anthropic.py # Direct API backend
143
+ claude_code.py # Claude Code CLI backend (validated token tracking)
144
+ claude_code_team.py # Tmux-based full Claude Code agent sessions (budget-aware)
145
+
146
+ human/
147
+ __init__.py # Human integration facade
148
+ linear.py # Linear issue tracking
149
+ slack.py # Slack notifications
150
+ git.py # Git/PR management
151
+ ```
152
+
153
+ ## Per-Project Directory
154
+
155
+ ```
156
+ <project>/
157
+ task.md # Task description
158
+ sops.md # Operating procedures
159
+ pact.yaml # Per-project config
160
+ design.md # Living design document
161
+ .pact/
162
+ state.json # Run lifecycle state
163
+ audit.jsonl # All actions + decisions
164
+ decomposition/ # Tree + decisions
165
+ contracts/ # Per-component contracts + tests
166
+ implementations/ # Per-component code + attempts/
167
+ standards.json # Global standards (auto-generated after decomposition)
168
+ tasks.json # Phased task list (auto-generated after decomposition)
169
+ analysis.json # Cross-artifact analysis report
170
+ checklist.json # Requirements quality checklist
171
+ compositions/ # Integration glue
172
+ learnings/ # Accumulated learnings
173
+ monitoring/ # Incidents, budget state, diagnostic reports
174
+ incidents.json # All incidents with lifecycle state
175
+ budget.json # Running budget totals per window
176
+ reports/ # Per-incident diagnostic reports (markdown)
177
+ ```
178
+
179
+ ## Key Schemas
180
+
181
+ | Schema | Purpose |
182
+ |--------|---------|
183
+ | `DecompositionTree` | Tree of components with traversal (leaves, parallel groups, subtree) |
184
+ | `ComponentContract` | Typed interface: functions, types, invariants, dependencies |
185
+ | `ContractTestSuite` | Executable tests generated from contract |
186
+ | `TestResults` | Aggregated pass/fail with failure details |
187
+ | `ScoredAttempt` | Competitive attempt with pass rate + duration scoring |
188
+ | `RunState` | Mutable lifecycle: phase, status, component tasks, spend |
189
+ | `Incident` | Tracked production error with lifecycle (detected→triaging→remediating→resolved/escalated) |
190
+ | `MonitoringBudget` | Multi-window spend caps (per-incident, hourly, daily, weekly, monthly) |
191
+ | `Signal` | Raw error signal from log file, process, webhook, or manual report |
192
+ | `GlobalStandards` | Shared packages, types, conventions distributed to all agents |
193
+ | `BuildMode` | StrEnum: unary, auto, hierarchy |
194
+ | `Directive` | Structured FIFO command with type + payload |
195
+ | `TaskList` | Phased task list with dependency-aware ready_tasks() |
196
+ | `AnalysisReport` | Cross-artifact consistency findings (errors, warnings, info) |
197
+ | `RequirementsChecklist` | Quality validation questions with tri-state answers |
198
+
199
+ ## Task List & Analysis Commands
200
+
201
+ ```bash
202
+ pact tasks <project-dir> # Generate/display phased task list
203
+ pact tasks <project-dir> --regenerate # Force regeneration
204
+ pact tasks <project-dir> --phase setup # Filter by phase
205
+ pact tasks <project-dir> --component auth # Filter by component
206
+ pact tasks <project-dir> --complete T001 # Mark task as completed
207
+ pact tasks <project-dir> --json # Output as JSON
208
+ pact analyze <project-dir> # Run cross-artifact analysis
209
+ pact analyze <project-dir> --json # Output as JSON
210
+ pact checklist <project-dir> # Generate requirements checklist
211
+ pact checklist <project-dir> --json # Output as JSON
212
+ pact export-tasks <project-dir> # Export TASKS.md
213
+ ```
214
+
215
+ The task list is auto-generated after decomposition and auto-updated after each implementation/integration phase.
216
+
217
+ ## Directive Commands
218
+
219
+ ```bash
220
+ pact directive <project-dir> resume # Backward-compatible simple string
221
+ pact directive <project-dir> '{"type": "set_mode", "mode": "unary"}' # Change build mode at runtime
222
+ pact directive <project-dir> '{"type": "set_config", "key": "value"}' # Update config keys
223
+ pact directive <project-dir> '{"type": "inject_context", "context": "..."}'# Inject context for next agent
224
+ ```
225
+
226
+ ## Monitoring Commands
227
+
228
+ ```bash
229
+ pact watch <project-dir>... # Start Sentinel monitor (Ctrl+C to stop)
230
+ pact report <project-dir> <error> # Manually report a production error
231
+ pact incidents <project-dir> # List active/recent incidents
232
+ pact incident <project-dir> <id> # Show incident details + diagnostic report
233
+ ```
234
+
235
+ ## Testing
236
+
237
+ ```bash
238
+ make test # 1260 tests, ~5s
239
+ make test-quick # Stop on first failure
240
+ ```
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 J. Andrew McEntire
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,38 @@
1
+ .PHONY: all install dev test clean help
2
+
3
+ VENV := .venv
4
+ PYTHON := $(VENV)/bin/python
5
+ PIP := $(VENV)/bin/pip
6
+
7
+ all: install ## Default: create venv and install pact
8
+
9
+ $(VENV)/bin/activate:
10
+ python3 -m venv $(VENV)
11
+
12
+ install: $(VENV)/bin/activate ## Install pact in editable mode
13
+ $(PIP) install -e ".[dev]"
14
+ @echo ""
15
+ @echo " Pact installed. Activate with:"
16
+ @echo " source $(VENV)/bin/activate"
17
+ @echo ""
18
+ @echo " Then try:"
19
+ @echo " pact init my-project"
20
+ @echo " pact --help"
21
+
22
+ dev: $(VENV)/bin/activate ## Install with LLM backend support
23
+ $(PIP) install -e ".[dev,llm]"
24
+ @echo ""
25
+ @echo " Pact installed with LLM support."
26
+
27
+ test: $(VENV)/bin/activate ## Run all tests
28
+ $(VENV)/bin/python -m pytest tests/ -v
29
+
30
+ test-quick: $(VENV)/bin/activate ## Run tests (stop on first failure)
31
+ $(VENV)/bin/python -m pytest tests/ -x -q
32
+
33
+ clean: ## Remove venv, caches, build artifacts
34
+ rm -rf $(VENV) dist build *.egg-info .pytest_cache
35
+ find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
36
+
37
+ help: ## Show this help
38
+ @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
@@ -0,0 +1,292 @@
1
+ Metadata-Version: 2.4
2
+ Name: pact-agents
3
+ Version: 0.1.0
4
+ Summary: Contract-first multi-agent software engineering. Contracts before code. Tests as law. Agents that can't cheat.
5
+ Project-URL: Homepage, https://jmcentire.github.io/pact/
6
+ Project-URL: Repository, https://github.com/jmcentire/pact
7
+ Project-URL: Documentation, https://jmcentire.github.io/pact/
8
+ Author-email: "J. Andrew McEntire" <j.andrew.mcentire@gmail.com>
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: ai-agents,contracts,llm,multi-agent,software-engineering,testing
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: Quality Assurance
19
+ Classifier: Topic :: Software Development :: Testing
20
+ Requires-Python: >=3.12
21
+ Requires-Dist: pydantic>=2.0
22
+ Requires-Dist: pyyaml>=6.0
23
+ Provides-Extra: all-backends
24
+ Requires-Dist: anthropic>=0.40; extra == 'all-backends'
25
+ Requires-Dist: google-genai>=1.0; extra == 'all-backends'
26
+ Requires-Dist: openai>=1.0; extra == 'all-backends'
27
+ Provides-Extra: dev
28
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
29
+ Requires-Dist: pytest>=8.0; extra == 'dev'
30
+ Provides-Extra: gemini
31
+ Requires-Dist: google-genai>=1.0; extra == 'gemini'
32
+ Provides-Extra: llm
33
+ Requires-Dist: anthropic>=0.40; extra == 'llm'
34
+ Provides-Extra: openai
35
+ Requires-Dist: openai>=1.0; extra == 'openai'
36
+ Description-Content-Type: text/markdown
37
+
38
+ # Pact
39
+
40
+ **Contracts before code. Tests as law. Agents that can't cheat.**
41
+
42
+ Pact is a multi-agent software engineering framework where the architecture is decided before a single line of implementation is written. Tasks are decomposed into components, each component gets a typed interface contract, and each contract gets executable tests. Only then do agents implement -- independently, in parallel, even competitively -- with no way to ship code that doesn't honor its contract.
43
+
44
+ The insight: LLMs are unreliable reviewers but tests are perfectly reliable judges. So make the tests first, make them mechanical, and let agents iterate until they pass. No advisory coordination. No "looks good to me." Pass or fail.
45
+
46
+ ## When to Use Pact
47
+
48
+ Pact is for projects where **getting the boundaries right matters more than getting the code written fast.** If a single Claude or Codex session can build your feature in one pass, just do that -- Pact's decomposition, contracts, and multi-agent coordination would be pure overhead.
49
+
50
+ Use Pact when:
51
+ - The task has **multiple interacting components** with non-obvious boundaries
52
+ - You need **provable correctness at interfaces** -- not "it seems to work" but "it passes 200 contract tests"
53
+ - The system will be **maintained by agents** who need contracts to understand what each piece does
54
+ - You want **competitive or parallel implementation** where multiple agents race on the same component
55
+ - The codebase is large enough that **no single context window can hold it all**
56
+
57
+ Don't use Pact when:
58
+ - A single agent can build the whole thing in one shot
59
+ - The task is a bug fix, refactor, or small feature
60
+ - You'd spend more time on contracts than on the code itself
61
+
62
+ ## Philosophy: Contracts Are the Product
63
+
64
+ Pact treats **contracts as source of truth and implementations as disposable artifacts.** The code is cattle, not pets.
65
+
66
+ When a module fails in production, the response isn't "debug the implementation." It's: add a test that reproduces the failure to the contract, flush the implementation, and let an agent rebuild it. The contract got stricter. The next implementation can't have that bug. Over time, contracts accumulate the scar tissue of every production incident -- they become the real engineering artifact.
67
+
68
+ This inverts the traditional relationship between code and tests. Code is cheap (agents generate it in minutes). Contracts are expensive (they encode hard-won understanding of what the system actually needs to do). Pact makes that inversion explicit: you spend your time on contracts, agents spend their time on code.
69
+
70
+ The practical upside: when someone asks "who's debugging this at 3am?" -- agents are. The Sentinel watches production logs, detects errors, attributes them to the right component via embedded PACT log keys, spawns a knowledge-flashed fixer agent loaded with the full contract/test context, adds a reproducer test, rebuilds the module, and verifies all tests pass. The contract ensures they can't introduce regressions. The human reviews the *contract change* in the morning, not the code.
71
+
72
+ ## Quick Start
73
+
74
+ ```bash
75
+ git clone https://github.com/jmcentire/pact.git
76
+ cd pact
77
+ make
78
+ source .venv/bin/activate
79
+ ```
80
+
81
+ That's it. Now try:
82
+
83
+ ```bash
84
+ pact init my-project
85
+ # Edit my-project/task.md with your task
86
+ # Edit my-project/sops.md with your standards
87
+ pact --help
88
+ ```
89
+
90
+ ## How It Works
91
+
92
+ ```
93
+ Task
94
+ |
95
+ v
96
+ Interview -----> Shape (opt) -----> Decompose -----> Contract -----> Test
97
+ | | | |
98
+ v v v v
99
+ Pitch: appetite, Component Tree Interfaces Executable Tests
100
+ breadboard, risks |
101
+ v
102
+ Implement (parallel, competitive)
103
+ |
104
+ v
105
+ Integrate (glue + parent tests)
106
+ |
107
+ v
108
+ Diagnose (on failure)
109
+ ```
110
+
111
+ **Nine phases, all mechanical gates:**
112
+
113
+ 1. **Interview** -- Identify risks, ambiguities, ask clarifying questions
114
+ 2. **Shape** -- (Optional) Produce a Shape Up pitch: appetite, breadboard, rabbit holes, no-gos
115
+ 3. **Decompose** -- Task into 2-7 component tree, guided by shaping context if present
116
+ 4. **Contract** -- Each component gets a typed interface contract
117
+ 5. **Test** -- Each contract gets executable tests (the enforcement)
118
+ 6. **Validate** -- Mechanical gate: refs resolve, no cycles, tests parse
119
+ 7. **Implement** -- Each component built independently by a code agent
120
+ 8. **Integrate** -- Parent components composed via glue code
121
+ 9. **Diagnose** -- On failure: I/O tracing, root cause, recovery
122
+
123
+ ## Two Execution Levers
124
+
125
+ | Lever | Config Key | Effect |
126
+ |-------|-----------|--------|
127
+ | **Parallel Components** | `parallel_components: true` | Independent components implement concurrently |
128
+ | **Competitive Implementations** | `competitive_implementations: true` | N agents implement the SAME component; best wins |
129
+
130
+ Either, neither, or both. Defaults: both off (sequential, single-attempt).
131
+
132
+ ## Plan-Only Mode
133
+
134
+ Set `plan_only: true` to stop after contracts and tests are generated. Then target specific components:
135
+
136
+ ```bash
137
+ pact components my-project # See what was decomposed
138
+ pact build my-project sync_tracker # Build one component
139
+ pact build my-project sync_tracker --competitive --agents 3
140
+ ```
141
+
142
+ ## CLI Commands
143
+
144
+ | Command | Purpose |
145
+ |---------|---------|
146
+ | `pact init <project>` | Scaffold a new project |
147
+ | `pact run <project>` | Run the pipeline |
148
+ | `pact daemon <project>` | Event-driven mode (recommended) |
149
+ | `pact status <project> [component]` | Show project or component status |
150
+ | `pact components <project>` | List components with status |
151
+ | `pact build <project> <id>` | Build/rebuild a specific component |
152
+ | `pact interview <project>` | Run interview phase only |
153
+ | `pact answer <project>` | Answer interview questions |
154
+ | `pact approve <project>` | Approve with defaults |
155
+ | `pact validate <project>` | Re-run contract validation |
156
+ | `pact design <project>` | Regenerate design.md |
157
+ | `pact stop <project>` | Gracefully stop a running daemon |
158
+ | `pact log <project>` | Show audit trail (`--tail N`, `--json`) |
159
+ | `pact ping` | Test API connection and show pricing |
160
+ | `pact signal <project>` | Resume a paused daemon |
161
+ | `pact watch <project>...` | Start Sentinel production monitor (Ctrl+C to stop) |
162
+ | `pact report <project> <error>` | Manually report a production error |
163
+ | `pact incidents <project>` | List active/recent incidents |
164
+ | `pact incident <project> <id>` | Show incident details + diagnostic report |
165
+
166
+ ## Configuration
167
+
168
+ **Global** (`config.yaml` at repo root):
169
+
170
+ ```yaml
171
+ model: claude-opus-4-6
172
+ default_budget: 10.00
173
+ parallel_components: false
174
+ competitive_implementations: false
175
+ competitive_agents: 2
176
+ max_concurrent_agents: 4
177
+ plan_only: false
178
+
179
+ # Override token pricing (per million tokens: [input, output])
180
+ model_pricing:
181
+ claude-opus-4-6: [15.00, 75.00]
182
+ claude-sonnet-4-5-20250929: [3.00, 15.00]
183
+ claude-haiku-4-5-20251001: [0.80, 4.00]
184
+
185
+ # Production monitoring (opt-in)
186
+ monitoring_enabled: false
187
+ monitoring_auto_remediate: true
188
+ monitoring_budget:
189
+ per_incident_cap: 5.00
190
+ hourly_cap: 10.00
191
+ daily_cap: 25.00
192
+ weekly_cap: 100.00
193
+ monthly_cap: 300.00
194
+ ```
195
+
196
+ **Per-project** (`pact.yaml` in project directory):
197
+
198
+ ```yaml
199
+ budget: 25.00
200
+ parallel_components: true
201
+ competitive_implementations: true
202
+ competitive_agents: 3
203
+
204
+ # Shaping (Shape Up methodology)
205
+ shaping: true # Enable shaping phase (default: false)
206
+ shaping_depth: standard # light | standard | thorough
207
+ shaping_rigor: moderate # relaxed | moderate | strict
208
+ shaping_budget_pct: 0.15 # Max budget fraction for shaping
209
+
210
+ # Production monitoring (per-project)
211
+ monitoring_log_files:
212
+ - "/var/log/myapp/app.log"
213
+ - "/var/log/myapp/error.log"
214
+ monitoring_process_patterns:
215
+ - "myapp-server"
216
+ monitoring_webhook_port: 9876
217
+ monitoring_error_patterns:
218
+ - "ERROR"
219
+ - "CRITICAL"
220
+ - "Traceback"
221
+ ```
222
+
223
+ Project config overrides global. Both are optional.
224
+
225
+ ### Multi-Provider Configuration
226
+
227
+ Route different roles to different providers for cost optimization:
228
+
229
+ ```yaml
230
+ budget: 50.00
231
+
232
+ role_models:
233
+ decomposer: claude-opus-4-6 # Strong reasoning for architecture
234
+ contract_author: claude-opus-4-6 # Precision for interfaces
235
+ test_author: claude-sonnet-4-5-20250929 # Fast test generation
236
+ code_author: gpt-4o # Cost-effective implementation
237
+
238
+ role_backends:
239
+ decomposer: anthropic
240
+ contract_author: anthropic
241
+ test_author: anthropic
242
+ code_author: openai # Mix providers per role
243
+ ```
244
+
245
+ Available backends: `anthropic`, `openai`, `gemini`, `claude_code`, `claude_code_team`.
246
+
247
+ ## Project Structure
248
+
249
+ Each project is a self-contained directory:
250
+
251
+ ```
252
+ my-project/
253
+ task.md # What to build
254
+ sops.md # How to build it (standards, stack, preferences)
255
+ pact.yaml # Budget and execution config
256
+ design.md # Auto-maintained design document
257
+ .pact/
258
+ state.json # Run lifecycle
259
+ audit.jsonl # Full audit trail
260
+ decomposition/ # Tree + decisions
261
+ contracts/ # Per-component interfaces + tests
262
+ implementations/ # Per-component code
263
+ compositions/ # Integration glue
264
+ learnings/ # Accumulated learnings
265
+ monitoring/ # Incidents, budget state, diagnostic reports
266
+ ```
267
+
268
+ ## Development
269
+
270
+ ```bash
271
+ make dev # Install with LLM backend support
272
+ make test # Run full test suite (950 tests)
273
+ make test-quick # Stop on first failure
274
+ make clean # Remove venv and caches
275
+ ```
276
+
277
+ Requires Python 3.12+. Core has two dependencies: `pydantic` and `pyyaml`. LLM backends require `anthropic`.
278
+
279
+ ## Architecture
280
+
281
+ See [CLAUDE.md](CLAUDE.md) for the full technical reference.
282
+
283
+ ## Background
284
+
285
+ Pact is one of three systems (alongside Emergence and Apprentice) built to test
286
+ the ideas in [Beyond Code: Context, Constraints, and the New Craft of Software](https://www.amazon.com/dp/B0GNLTXVC7).
287
+ The book covers the coordination, verification, and specification problems that
288
+ motivated Pact's design.
289
+
290
+ ## License
291
+
292
+ MIT