agentflow-proof 1.0.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 (88) hide show
  1. agentflow_proof-1.0.0/CHANGELOG.md +99 -0
  2. agentflow_proof-1.0.0/LICENSE +21 -0
  3. agentflow_proof-1.0.0/MANIFEST.in +1 -0
  4. agentflow_proof-1.0.0/PKG-INFO +524 -0
  5. agentflow_proof-1.0.0/README.md +504 -0
  6. agentflow_proof-1.0.0/pyproject.toml +36 -0
  7. agentflow_proof-1.0.0/setup.cfg +4 -0
  8. agentflow_proof-1.0.0/src/agentflow/__init__.py +5 -0
  9. agentflow_proof-1.0.0/src/agentflow/__main__.py +5 -0
  10. agentflow_proof-1.0.0/src/agentflow/aggregate.py +1015 -0
  11. agentflow_proof-1.0.0/src/agentflow/artifacts.py +331 -0
  12. agentflow_proof-1.0.0/src/agentflow/capabilities.py +124 -0
  13. agentflow_proof-1.0.0/src/agentflow/cli.py +2108 -0
  14. agentflow_proof-1.0.0/src/agentflow/cli_contract.py +238 -0
  15. agentflow_proof-1.0.0/src/agentflow/contracts.py +263 -0
  16. agentflow_proof-1.0.0/src/agentflow/coverage.py +438 -0
  17. agentflow_proof-1.0.0/src/agentflow/draft_plan.py +402 -0
  18. agentflow_proof-1.0.0/src/agentflow/events.py +201 -0
  19. agentflow_proof-1.0.0/src/agentflow/execution.py +1027 -0
  20. agentflow_proof-1.0.0/src/agentflow/execution_coverage.py +646 -0
  21. agentflow_proof-1.0.0/src/agentflow/git.py +89 -0
  22. agentflow_proof-1.0.0/src/agentflow/handoff.py +112 -0
  23. agentflow_proof-1.0.0/src/agentflow/hunks.py +245 -0
  24. agentflow_proof-1.0.0/src/agentflow/locks.py +71 -0
  25. agentflow_proof-1.0.0/src/agentflow/mcp_server.py +710 -0
  26. agentflow_proof-1.0.0/src/agentflow/packs.py +398 -0
  27. agentflow_proof-1.0.0/src/agentflow/porcelain.py +1014 -0
  28. agentflow_proof-1.0.0/src/agentflow/proof.py +1062 -0
  29. agentflow_proof-1.0.0/src/agentflow/receipts.py +604 -0
  30. agentflow_proof-1.0.0/src/agentflow/recommend.py +299 -0
  31. agentflow_proof-1.0.0/src/agentflow/review.py +924 -0
  32. agentflow_proof-1.0.0/src/agentflow/review_runner.py +516 -0
  33. agentflow_proof-1.0.0/src/agentflow/risk.py +328 -0
  34. agentflow_proof-1.0.0/src/agentflow/runtime.py +863 -0
  35. agentflow_proof-1.0.0/src/agentflow/stuck.py +344 -0
  36. agentflow_proof-1.0.0/src/agentflow/validation.py +696 -0
  37. agentflow_proof-1.0.0/src/agentflow/versioning.py +120 -0
  38. agentflow_proof-1.0.0/src/agentflow/viewer.py +391 -0
  39. agentflow_proof-1.0.0/src/agentflow/workflow_contract.py +164 -0
  40. agentflow_proof-1.0.0/src/agentflow_proof.egg-info/PKG-INFO +524 -0
  41. agentflow_proof-1.0.0/src/agentflow_proof.egg-info/SOURCES.txt +86 -0
  42. agentflow_proof-1.0.0/src/agentflow_proof.egg-info/dependency_links.txt +1 -0
  43. agentflow_proof-1.0.0/src/agentflow_proof.egg-info/entry_points.txt +3 -0
  44. agentflow_proof-1.0.0/src/agentflow_proof.egg-info/top_level.txt +1 -0
  45. agentflow_proof-1.0.0/tests/test_aggregate.py +1687 -0
  46. agentflow_proof-1.0.0/tests/test_ai_kit.py +190 -0
  47. agentflow_proof-1.0.0/tests/test_artifact_versioning.py +172 -0
  48. agentflow_proof-1.0.0/tests/test_build_zipapp.py +145 -0
  49. agentflow_proof-1.0.0/tests/test_capabilities.py +211 -0
  50. agentflow_proof-1.0.0/tests/test_ci_proof_bundle.py +187 -0
  51. agentflow_proof-1.0.0/tests/test_cli.py +3652 -0
  52. agentflow_proof-1.0.0/tests/test_config_contract.py +42 -0
  53. agentflow_proof-1.0.0/tests/test_distribution.py +533 -0
  54. agentflow_proof-1.0.0/tests/test_draft_plan.py +619 -0
  55. agentflow_proof-1.0.0/tests/test_events.py +300 -0
  56. agentflow_proof-1.0.0/tests/test_example_aggregation.py +24 -0
  57. agentflow_proof-1.0.0/tests/test_example_mcp.py +21 -0
  58. agentflow_proof-1.0.0/tests/test_example_workflow_pack.py +24 -0
  59. agentflow_proof-1.0.0/tests/test_examples.py +54 -0
  60. agentflow_proof-1.0.0/tests/test_execution_contract.py +522 -0
  61. agentflow_proof-1.0.0/tests/test_execution_state.py +310 -0
  62. agentflow_proof-1.0.0/tests/test_execution_verification.py +940 -0
  63. agentflow_proof-1.0.0/tests/test_handoff.py +72 -0
  64. agentflow_proof-1.0.0/tests/test_hunks.py +273 -0
  65. agentflow_proof-1.0.0/tests/test_lease_enforcement.py +338 -0
  66. agentflow_proof-1.0.0/tests/test_lease_locking.py +82 -0
  67. agentflow_proof-1.0.0/tests/test_mcp_server.py +550 -0
  68. agentflow_proof-1.0.0/tests/test_packs.py +393 -0
  69. agentflow_proof-1.0.0/tests/test_porcelain.py +988 -0
  70. agentflow_proof-1.0.0/tests/test_proof.py +3046 -0
  71. agentflow_proof-1.0.0/tests/test_proof_compatibility.py +183 -0
  72. agentflow_proof-1.0.0/tests/test_public_project_contract.py +343 -0
  73. agentflow_proof-1.0.0/tests/test_receipt_concurrency.py +222 -0
  74. agentflow_proof-1.0.0/tests/test_receipts.py +785 -0
  75. agentflow_proof-1.0.0/tests/test_recommend.py +258 -0
  76. agentflow_proof-1.0.0/tests/test_release.py +661 -0
  77. agentflow_proof-1.0.0/tests/test_review.py +1489 -0
  78. agentflow_proof-1.0.0/tests/test_review_runner.py +748 -0
  79. agentflow_proof-1.0.0/tests/test_risk.py +157 -0
  80. agentflow_proof-1.0.0/tests/test_runtime.py +804 -0
  81. agentflow_proof-1.0.0/tests/test_schema_contracts.py +937 -0
  82. agentflow_proof-1.0.0/tests/test_schema_soak.py +1170 -0
  83. agentflow_proof-1.0.0/tests/test_stability_policy.py +446 -0
  84. agentflow_proof-1.0.0/tests/test_stop_gate.py +178 -0
  85. agentflow_proof-1.0.0/tests/test_stuck.py +315 -0
  86. agentflow_proof-1.0.0/tests/test_versioning.py +82 -0
  87. agentflow_proof-1.0.0/tests/test_view_proof.py +510 -0
  88. agentflow_proof-1.0.0/tests/test_workflow_contract.py +184 -0
@@ -0,0 +1,99 @@
1
+ # Changelog
2
+
3
+ All notable changes to Agentflow are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [1.0.0] - 2026-10-04
11
+
12
+ Agentflow 1.0.0 is the stability release. The eight artifact schemas (plan
13
+ lock, drift report, proof pack, execution contract, step runs, command
14
+ receipts, file receipts, and verification runs) are frozen at `1.0.0` after
15
+ the issue #5 soak; the Python distribution is named `agentflow-proof` while
16
+ the `agentflow` import package and the `agentflow` and `agentflow-mcp`
17
+ commands keep their names; and the promises in `docs/stability.md` and
18
+ `docs/compatibility.md` are now in force.
19
+
20
+ ### Added
21
+
22
+ - `tests/fixtures/compatibility/legacy-0.3/`: a byte-exact snapshot of the
23
+ 0.3-era CI proof bundle, now the compatibility matrix's preserved-legacy
24
+ fixture, so the historical `verify-proof` guarantee stays exercised after the
25
+ 1.0 transition regenerates the live `tests/fixtures/proof-bundle`.
26
+ - Amendment-ready review-manifest v1.0 fields with locked-plan ownership
27
+ validation, durable ledger/proof projection, and HTML proof viewing.
28
+ - Authoritative, actor-aware resumability state in `next-action --json` and
29
+ its MCP mapping, including lease evaluation, attempt-scoped receipts and
30
+ gates, structured diagnostics, and explicitly marked break-glass recovery.
31
+
32
+ ### Changed
33
+
34
+ - The eight artifact schemas are stamped `1.0.0` from the single soaked
35
+ candidate recorded in `docs/schema-freeze-soak.json`; proofs built by
36
+ Agentflow 0.4.0 or later stay verifiable under the surface documented in
37
+ `docs/compatibility.md` (#5).
38
+ - Legacy review manifests remain recordable and verifiable but are explicitly
39
+ marked non-amendment-ready. The proof-pack schema and review-run rows moved
40
+ to 0.10.0 and 0.6.0 for this change ahead of the 1.0.0 freeze; the manifest
41
+ schema uses a new major because amendment-ready rows add required repair
42
+ context.
43
+
44
+ ### Fixed
45
+
46
+ - The 1.0 schema transition is landable again, caught by rehearsing the full
47
+ test suite against a transitioned tree: the published proof-pack
48
+ `bundle_version` pattern now admits the historical `0.4.0+` range and
49
+ `1.0.x` (it is written from the same constant as `schema_version` but sits
50
+ outside the soak guard's pattern exception), and the guard's transition
51
+ window now lets the recorded transition regenerate the live CI proof bundle,
52
+ since `verify-run` carries no cross-major promise. Both changes reset the
53
+ soak candidate; the soak clock restarted on the corrected shape (the window
54
+ is 72 hours; see `docs/schema-freeze-audit.md`).
55
+ - `scripts/check_schema_soak.py` now reports an unresolvable
56
+ `candidate_commit` or `transition_commit` with the field, the recorded SHA,
57
+ and the squash-merge cause instead of `fatal: Needed a single revision`
58
+ (#36).
59
+ - The `aggregate-ledgers --json` contract now declares the two payload shapes
60
+ the runtime actually emits: analysis/collision (`status`, `sources`,
61
+ `collisions`, `planned`) and successful write (`status`, `sources`,
62
+ `written`). The previously documented single envelope (`source_count`,
63
+ `output`, `dry_run`, `rewrites`) never matched runtime output, so no
64
+ emitted payload changes.
65
+
66
+ ## [0.4.0] - 2026-07-10
67
+
68
+ ### Added
69
+
70
+ - Read-only runtime and MCP status evidence in proof packs.
71
+ - Single-writer step leases with renewal and stale-owner recovery.
72
+ - Cross-worktree ledger aggregation with collision detection and provenance.
73
+ - A public gate/ledger brand kit for the project and release artifacts.
74
+
75
+ ## [0.3.0] - 2026-07-03
76
+
77
+ _Released from the pre-public repository history; no tag exists in this
78
+ repository, so this heading is intentionally unlinked._
79
+
80
+ ### Added
81
+
82
+ - Portable execution contracts, step claims, command and file receipts,
83
+ resumable verification, and provider-neutral handoffs.
84
+ - Deterministic command-risk screening, the dependency-free MCP server, and
85
+ the POSIX Stop-hook enforcement gate.
86
+ - CI proof verification, review manifests, capability receipts, workflow
87
+ packs, workflow recommendation, and draft-plan generation.
88
+ - Hunk-level drift attribution, the static HTML proof viewer, and the Golem
89
+ integration guide.
90
+ - Single-file CLI and MCP zipapps with checksums and a tag-triggered GitHub
91
+ release workflow.
92
+
93
+ ### Changed
94
+
95
+ - Existing v0.2 proof artifacts remain valid when no execution contract exists.
96
+
97
+ [Unreleased]: https://github.com/kstruzzieri/agentflow/compare/v1.0.0...HEAD
98
+ [1.0.0]: https://github.com/kstruzzieri/agentflow/releases/tag/v1.0.0
99
+ [0.4.0]: https://github.com/kstruzzieri/agentflow/releases/tag/v0.4.0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Agentflow contributors
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 @@
1
+ include CHANGELOG.md
@@ -0,0 +1,524 @@
1
+ Metadata-Version: 2.4
2
+ Name: agentflow-proof
3
+ Version: 1.0.0
4
+ Summary: A model-agnostic workflow runner for drift-resistant agentic development.
5
+ Author: Agentflow contributors
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/kstruzzieri/agentflow
8
+ Project-URL: Documentation, https://github.com/kstruzzieri/agentflow#readme
9
+ Project-URL: Issues, https://github.com/kstruzzieri/agentflow/issues
10
+ Project-URL: Releases, https://github.com/kstruzzieri/agentflow/releases
11
+ Keywords: agents,audit,cli,proof,workflow
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Requires-Python: >=3.11
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Dynamic: license-file
20
+
21
+ <p align="center">
22
+ <picture>
23
+ <source media="(prefers-color-scheme: dark)" srcset="docs/branding/agentflow-lockup-dark.svg">
24
+ <img alt="agentflow" src="docs/branding/agentflow-lockup-light.svg" width="440">
25
+ </picture>
26
+ </p>
27
+
28
+ <h2 align="center">Gate the flow. Prove the work.</h2>
29
+
30
+ <p align="center">
31
+ <img alt="agentflow — proof" src="docs/branding/agentflow-badge.svg" height="34">
32
+ </p>
33
+
34
+ <p align="center">
35
+ <a href="https://github.com/kstruzzieri/agentflow/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/kstruzzieri/agentflow/actions/workflows/ci.yml/badge.svg"></a>
36
+ <a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-blue.svg"></a>
37
+ <img alt="Python 3.11+" src="https://img.shields.io/badge/python-3.11%2B-blue.svg">
38
+ </p>
39
+
40
+ # Agentflow
41
+
42
+ Agentflow is a lightweight, model-agnostic workflow runner that makes agentic software work auditable. It records the plan,
43
+ execution steps, validations, reviews, file-change evidence, drift checks, and final proof as local files, so a run can be
44
+ inspected, resumed, and verified outside any LLM chat.
45
+
46
+ The current implementation is intentionally lightweight:
47
+
48
+ - no runtime dependencies
49
+ - local file artifacts under `.agent/`
50
+ - JSON schemas and templates for the workflow and execution contracts
51
+ - a Python CLI for planning, runtime checks, execution receipts, drift audit,
52
+ proof-pack generation, and verification
53
+
54
+ The active task `.agent/` directory is local-only by default. See
55
+ [docs/agent-artifacts.md](docs/agent-artifacts.md) for when to keep it ignored,
56
+ upload proof as CI artifacts, attach proof to PRs, or commit a deliberate proof
57
+ bundle.
58
+ Supported interfaces and compatibility promises are defined in
59
+ [docs/stability.md](docs/stability.md).
60
+
61
+ ## Quick Start
62
+
63
+ Agentflow is not yet published as a PyPI package. The provisional Python
64
+ distribution agentflow-proof is not yet published; it is built and validated.
65
+ It keeps the `agentflow` imports and the `agentflow` and `agentflow-mcp`
66
+ commands. From `v0.4.0` on, prebuilt single-file artifacts (`agentflow.pyz`,
67
+ `agentflow-mcp.pyz`) are published on the
68
+ [GitHub Releases](https://github.com/kstruzzieri/agentflow/releases) page; for
69
+ development you install from this source repository.
70
+
71
+ **Prerequisite:** Python 3.11 or newer (see `requires-python` in
72
+ `pyproject.toml`). Agentflow has no runtime dependencies — only the standard
73
+ library.
74
+
75
+ ### Platform support
76
+
77
+ Linux and macOS are supported and tested in release-blocking CI on Python 3.11,
78
+ 3.12, and 3.13. Windows is **best effort**: the Python CLI may work, but Windows
79
+ has no release-blocking CI leg and no compatibility guarantee until this support
80
+ tier changes. The POSIX `sh` stop hook (`hooks/stop-gate.sh`) and shell-dependent
81
+ examples are POSIX-only; use a POSIX shell on Windows or do not use those parts.
82
+ A future supported Windows tier requires Windows CI plus adapted or replaced
83
+ POSIX-only hooks and tests.
84
+
85
+ ### Install from source
86
+
87
+ Use an editable install when you want command-line access to the local checkout.
88
+ Replace `/path/to/agentflow` with this repository's absolute path.
89
+ The `uv tool` and `pipx` options make `agentflow` available outside the repo
90
+ when their bin directory is on `PATH`. The `pip` option makes it available while
91
+ that Python environment is active.
92
+
93
+ ```bash
94
+ uv tool install --editable /path/to/agentflow
95
+ ```
96
+
97
+ ```bash
98
+ pipx install --editable /path/to/agentflow
99
+ ```
100
+
101
+ For a virtual environment or the current Python environment:
102
+
103
+ ```bash
104
+ python3 -m pip install -e .
105
+ ```
106
+
107
+ To test the locally built provisional wheel without publishing it:
108
+
109
+ ```bash
110
+ python3 -m pip install dist/agentflow_proof-*.whl
111
+ ```
112
+
113
+ If the permanent PyPI name becomes available later, only `project.name` changes;
114
+ imports and the `agentflow` and `agentflow-mcp` command names stay the same.
115
+
116
+ ### Smoke tests
117
+
118
+ After any editable install that exposes the console script:
119
+
120
+ ```bash
121
+ agentflow --version
122
+ agentflow --help
123
+ ```
124
+
125
+ For no-install usage from the repository root:
126
+
127
+ ```bash
128
+ PYTHONPATH=src python3 -m agentflow --version
129
+ PYTHONPATH=src python3 -m agentflow --help
130
+ ```
131
+
132
+ For no-install usage from another directory:
133
+
134
+ ```bash
135
+ PYTHONPATH=/path/to/agentflow/src python3 -m agentflow --version
136
+ PYTHONPATH=/path/to/agentflow/src python3 -m agentflow --help
137
+ ```
138
+
139
+ ### Single-file build (zipapp)
140
+
141
+ Build self-contained single-file artifacts (requires only a system
142
+ Python 3.11+ to run):
143
+
144
+ ```bash
145
+ python3 scripts/build_zipapp.py
146
+ ./dist/agentflow.pyz --version
147
+ python3 dist/agentflow-mcp.pyz --transport stdio
148
+ ```
149
+
150
+ To use a published build instead of building locally, download `agentflow.pyz`,
151
+ `agentflow-mcp.pyz`, `agentflow_proof-*.whl`,
152
+ `agentflow_proof-*.tar.gz`, and `SHA256SUMS` from the
153
+ [Releases](https://github.com/kstruzzieri/agentflow/releases) page, verify the
154
+ checksums, and run:
155
+
156
+ ```bash
157
+ sha256sum -c SHA256SUMS
158
+ python3 agentflow.pyz --version
159
+ ```
160
+
161
+ See `docs/packaging.md` for details, limitations, and the release checklist.
162
+
163
+ ### Basic workflow
164
+
165
+ After installing Agentflow, initialize a repository and inspect the generated
166
+ plan before locking or executing it:
167
+
168
+ ```bash
169
+ agentflow init
170
+ agentflow status
171
+ agentflow validate-plan .agent/plan.lock.json
172
+ agentflow audit-drift
173
+ agentflow runtime-status --json
174
+ agentflow build-proof --strict
175
+ agentflow verify-proof
176
+ ```
177
+
178
+ For no-install usage, replace `agentflow` with
179
+ `PYTHONPATH=src python3 -m agentflow` from the repository root.
180
+
181
+ ### Agent task loop
182
+
183
+ Codex, Claude Code, and other agents should use the same Agentflow task loop:
184
+
185
+ ```bash
186
+ agentflow init
187
+ # Populate .agent/plan.lock.json with the required plan contract:
188
+ # objective, scope, invariants, allowed_files, validation_gates, rollback_plan,
189
+ # and real steps. Include task files and .agent/ in allowed_files; then lock it.
190
+ agentflow lock-plan .agent/plan.lock.json
191
+ agentflow init-execution
192
+ STEP_ID=P1
193
+ VALIDATION_GATE="<matching step.validation entry>"
194
+ agentflow claim-step "$STEP_ID" --agent "$USER"
195
+ agentflow run --step "$STEP_ID" --gate "$VALIDATION_GATE" -- <validation-or-work-command>
196
+ agentflow record-file-change --step "$STEP_ID" --path <changed-path>
197
+ agentflow verify-step "$STEP_ID"
198
+ agentflow complete-step "$STEP_ID"
199
+ agentflow verify-run
200
+ agentflow audit-drift
201
+ agentflow build-proof
202
+ agentflow verify-proof
203
+ ```
204
+
205
+ The loop keeps each task tied to a plan step. `init` creates the planning
206
+ artifacts. Populate the full `.agent/plan.lock.json` contract before claiming
207
+ work; `init` starts with placeholder fields and an empty `steps` list.
208
+ `STEP_ID=P1` assumes the locked plan contains a step with id `P1`.
209
+ `VALIDATION_GATE` should match the step's legacy `validation` entry unless the
210
+ step uses structured command gates. Include `.agent/` in `allowed_files` when
211
+ the task uses Agentflow artifacts in the same worktree; `audit-drift` compares
212
+ all changed files from git status. `init-execution` creates execution ledgers,
213
+ `claim-step` assigns a step attempt, `run` records command receipts,
214
+ `record-file-change` maps edits to the step, `verify-step` and `complete-step`
215
+ close the step, and
216
+ `verify-run`, `audit-drift`, `build-proof`, and `verify-proof` prove the whole
217
+ run. Run `audit-drift` before `build-proof` so `.agent/proof-pack.md` includes
218
+ the current drift result from `.agent/drift-report.json`. To attach a follow-up
219
+ edit to an already-completed step (for example a review-feedback fix), use
220
+ `amend-step` — it opens an auditable new attempt linked to the prior completed
221
+ attempt rather than silently reusing it.
222
+
223
+ Adapter-backed workflows can provide the same plan contract as structured JSON
224
+ without hand-editing `.agent/plan.lock.json`:
225
+
226
+ ```bash
227
+ agentflow lock-plan --stdin --json < plan.json
228
+ agentflow lock-plan --from-json plan.json --json
229
+ ```
230
+
231
+ Both commands validate the supplied JSON through the normal plan validator, set
232
+ `locked` and `locked_at`, and write the canonical artifact to
233
+ `.agent/plan.lock.json` by default. Invalid input exits nonzero and emits a
234
+ machine-readable payload with `status: "invalid"` and stable diagnostic entries
235
+ under `errors`. The existing file-based form remains unchanged:
236
+ `agentflow lock-plan .agent/plan.lock.json` locks that file in place.
237
+
238
+ Adaptive workflows can also record the selected workflow policy as a durable
239
+ contract:
240
+
241
+ ```bash
242
+ agentflow workflow-contract --from-json workflow-contract.json
243
+ agentflow workflow-contract --validate
244
+ ```
245
+
246
+ This writes `.agent/workflow.contract.json` after stdlib validation. The
247
+ artifact records the selected workflow pack/profile, rationale, required
248
+ capabilities, review depth, validation policy, and proof policy. When present,
249
+ `build-proof` includes a concise workflow summary and hashes the contract, so
250
+ `verify-proof` detects stale or tampered workflow metadata.
251
+
252
+ The adaptive workflow track can go from a task brief to a draft plan
253
+ deterministically. `recommend-workflow` maps a machine-authored task brief to a
254
+ workflow posture, and `draft-plan` compiles that brief plus a workflow pack into
255
+ an unlocked, `validate-plan`-valid `.agent/plan.lock.json` draft:
256
+
257
+ ```bash
258
+ agentflow recommend-workflow --brief examples/briefs/small-bugfix.brief.json
259
+ agentflow draft-plan --brief examples/briefs/medium-feature.brief.json \
260
+ --workflow examples/packs/agentflow-draft-demo \
261
+ --objective "Add an events projection cache" --write
262
+ ```
263
+
264
+ `draft-plan` treats the recommendation as a lower-bound posture, selects the
265
+ least-strict pack profile that satisfies it, and hydrates that profile's plan
266
+ template with the brief (objective, unioned gates, `allowed_files` including
267
+ `.agent/`, stricter risk). It never locks a plan and fails closed on vague
268
+ briefs, missing candidate files, or unsatisfiable postures. See
269
+ [`docs/draft-plan.md`](docs/draft-plan.md) and
270
+ [`docs/recommend-workflow.md`](docs/recommend-workflow.md).
271
+
272
+ Agentflow v0.2 adds optional runtime metadata, runtime snapshots, structured
273
+ proof metadata at `.agent/proof-pack.json`, and `verify-proof` hash checks.
274
+ Runtime status is safe by default: configured commands are not spawned unless
275
+ `runtime-status --probe` is used.
276
+
277
+ `agentflow view-proof --html` renders the proof pack and execution ledgers
278
+ into a self-contained static HTML report (default
279
+ `.agent/proof-report.html`) for human review and sharing: no JavaScript, no
280
+ external references, all recorded content escaped, with links to receipt
281
+ stdout/stderr files where available. The report is a review aid only;
282
+ `verify-proof` remains the authoritative check.
283
+
284
+ ## Agentflow v0.3 Portable Runtime Contract
285
+
286
+ Agentflow v0.3 adds an optional execution layer under `.agent/`:
287
+
288
+ ```bash
289
+ agentflow init-execution
290
+ agentflow doctor
291
+ agentflow next-step --json
292
+ STEP_ID=P1
293
+ VALIDATION_GATE="python3 -m unittest discover -s tests"
294
+ agentflow claim-step "$STEP_ID" --agent "$USER"
295
+ agentflow run --step "$STEP_ID" --gate "$VALIDATION_GATE" -- python3 -m unittest discover -s tests
296
+ agentflow record-file-change --step "$STEP_ID" --path src/agentflow/example.py
297
+ agentflow verify-step "$STEP_ID"
298
+ agentflow complete-step "$STEP_ID"
299
+ agentflow verify-run
300
+ agentflow audit-drift
301
+ agentflow build-proof
302
+ agentflow verify-proof
303
+ ```
304
+
305
+ Execution ledgers are additive. Existing v0.2 proof artifacts remain valid when
306
+ no execution contract exists.
307
+
308
+ ## Agent Artifact Policy
309
+
310
+ Root `.agent/` is task-local by default. Commit or publish it only when the
311
+ workflow explicitly calls for a reviewed proof bundle. The policy in
312
+ [docs/agent-artifacts.md](docs/agent-artifacts.md) explains:
313
+
314
+ - local-only, CI-uploaded, PR-attached, and committed proof workflows
315
+ - which `.agent/` files are useful proof versus sensitive command output
316
+ - when plans should include `.agent/` in `allowed_files`
317
+ - how adapter-backed workflows such as Golem should retain and publish proof
318
+
319
+ ## MCP Server
320
+
321
+ Agentflow ships a dependency-free MCP server that exposes the core workflow
322
+ commands as MCP tools, so any MCP-capable front-end discovers them
323
+ automatically. It speaks JSON-RPC 2.0 over stdio (Claude Code, Codex CLI) and
324
+ Streamable HTTP (local LLMs such as Ollama/Open WebUI and llama.cpp). The server
325
+ is a thin wrapper that runs `agentflow.cli.main` in-process — no business logic
326
+ is duplicated and no new runtime dependency is added.
327
+
328
+ ```bash
329
+ # stdio (Claude Code reads .mcp.json, Codex reads .codex/config.toml)
330
+ PYTHONPATH=src python3 -m agentflow.mcp_server
331
+
332
+ # Streamable HTTP for local LLM front-ends
333
+ PYTHONPATH=src python3 -m agentflow.mcp_server --transport http --port 8765
334
+ ```
335
+
336
+ Exposed tools: `status`, `doctor`, `next_step`, `next_action`, `claim_step`,
337
+ `amend_step`, `reclaim_step`, `renew_lease`, `record_review`, `complete_step`,
338
+ `verify_step`, `finish_step`, `verify_run`, `finish_run`, `audit_drift`,
339
+ `build_proof`, `verify_proof`. The arbitrary-command tools (`run`,
340
+ `record-command`) are intentionally not exposed.
341
+ See [docs/mcp.md](docs/mcp.md) for transports, configs, and the security
342
+ boundary.
343
+
344
+ ## Stop Hook (Enforcement Gate)
345
+
346
+ Where the MCP server gives an agent *voluntary* access to the tools, the stop
347
+ hook (`hooks/stop-gate.sh`) is the *enforcement* twin: it blocks a session from
348
+ finishing until the proof chain passes (`verify-run` -> `build-proof` ->
349
+ `verify-proof`). It is runtime-agnostic — a POSIX `sh` script with no
350
+ third-party dependencies that signals through a universal exit-code contract
351
+ (`0` = proof satisfied or repo ungoverned, non-zero = block).
352
+
353
+ ```bash
354
+ # Bare invocation (CI, git pre-commit, OpenHands, Codex):
355
+ sh hooks/stop-gate.sh
356
+ ```
357
+
358
+ The hook is Agentflow-specific: with no locked `.agent/plan.lock.json` it exits
359
+ `0` and never runs the CLI, so it is safe to install in any repo. Example
360
+ runtime configs ship for Claude Code (`.claude/settings.json`, with a
361
+ `|| exit 2` adapter since Claude Code blocks only on exit 2) and OpenHands
362
+ ([`.openhands/hooks.json`](.openhands/hooks.json)). None auto-activate — copy the
363
+ snippet to turn the gate on. See [docs/stop-hook.md](docs/stop-hook.md) for
364
+ per-runtime wiring, idempotency, and the loop-safety notes.
365
+
366
+ ## Command Risk Screening
367
+
368
+ Before `agentflow run` executes a command, a deterministic, no-network, no-LLM
369
+ analyzer classifies it (`low`/`medium`/`high`) and records the result on the
370
+ command receipt. A `command_policy.risk_policy` of `warn`, `require-confirmation`
371
+ (the new-contract default), or `block` decides whether a high-risk command —
372
+ `rm -rf`, `chmod 777`, credential reads, `sudo`, `curl | sh`, writes outside
373
+ scope, blocked-path references — is blocked before it runs. This is deterministic
374
+ risk *screening*, not a security sandbox. See
375
+ [docs/command-risk.md](docs/command-risk.md) for the category catalog, the
376
+ `--confirm-risk` / `AGENTFLOW_CONFIRM_RISK` override, and detection limits.
377
+
378
+ ## Hunk-Level Attribution
379
+
380
+ When `record-file-change` records an edit, Agentflow captures a per-hunk
381
+ fingerprint of the diff against `HEAD` (sha256 of the changed lines, with
382
+ span-independent identity so unrelated line-number shifts do not invalidate it).
383
+ `audit-drift` and `verify-run` then flag any current diff hunk inside an allowed
384
+ file that matches no recorded receipt hunk as an `unmapped_hunk`. This
385
+ distinguishes the edits a step actually attested from stray or unrelated edits
386
+ in the same allowed file. The `proof_policy.hunk_attribution` knob
387
+ (`enforce` / `observe` / `off`) governs severity; the default is `enforce` when
388
+ an execution contract exists and `off` otherwise. Receipts store only hashes,
389
+ spans, and counts — never raw changed-line text. The workflow contract and
390
+ receipt behavior are documented in
391
+ [docs/agent-workflow.md](docs/agent-workflow.md).
392
+
393
+ ## Single-Writer Leases
394
+
395
+ The execution contract can enforce single-writer ownership of a plan step so
396
+ that only the agent holding a live lease may write to or close an attempt. It is
397
+ opt-in via `concurrency.lease_policy` (`advisory` by default, so existing plans
398
+ are unchanged); set it to `enforce` to gate claims, writes, and lifecycle
399
+ transitions on agent identity and a wall-clock lease. `reclaim-step` recovers a
400
+ crashed owner after its lease expires, `renew-lease` extends an owner's own
401
+ lease, and `fail-step` is the break-glass. Pass `--agent` on write and lifecycle
402
+ commands (or set `AGENTFLOW_AGENT_ID`). `multi_writer` remains rejected;
403
+ cross-worktree aggregation now ships separately via `aggregate-ledgers`
404
+ ([#30](https://github.com/kstruzzieri/agentflow/issues/30)), which merges
405
+ one-writer-per-worktree runs into a single canonical proof. See
406
+ [docs/single-writer-leases.md](docs/single-writer-leases.md) for the contract
407
+ fields, the full enforce loop, and the migration note.
408
+
409
+ ## GitHub Actions Proof Gate
410
+
411
+ This repository includes a dependency-free GitHub Actions gate in
412
+ `.github/workflows/ci.yml`. The workflow runs the unit test suite from the source
413
+ checkout, stages a configured proof root into a temporary git repository, then
414
+ runs:
415
+
416
+ ```bash
417
+ PYTHONPATH=src python3 -m agentflow verify-run --no-record --root "$PROOF_ROOT"
418
+ PYTHONPATH=src python3 -m agentflow verify-proof --root "$PROOF_ROOT"
419
+ ```
420
+
421
+ `verify-run --no-record` is for CI and other read-only checks: it validates the
422
+ execution ledger without appending a new entry to `.agent/verification-runs.jsonl`,
423
+ so `verify-proof` can still validate the committed proof hashes afterward.
424
+
425
+ The workflow uses `AGENTFLOW_PROOF_ROOT` to select the committed proof bundle.
426
+ This repository points it at `tests/fixtures/proof-bundle` so CI can regression
427
+ test the verifier itself without committing task-local root `.agent/` artifacts.
428
+ Repositories that commit the active task proof bundle should set
429
+ `AGENTFLOW_PROOF_ROOT` to `.`. On pull requests, the workflow uses the PR base
430
+ commit as the temporary git baseline before overlaying the current proof root, so
431
+ `verify-run` still sees source edits that lack file receipts. Set
432
+ `AGENTFLOW_PROOF_BASE_REF` explicitly when the baseline should be a different
433
+ commit:
434
+
435
+ ```yaml
436
+ env:
437
+ AGENTFLOW_PROOF_ROOT: .
438
+ AGENTFLOW_PROOF_BASE_REF: ${{ github.event.pull_request.base.sha }}
439
+ ```
440
+
441
+ Expected failure behavior:
442
+
443
+ - missing `.agent/proof-pack.json`: CI fails before verification starts
444
+ - stale proof metadata, hash mismatches, or modified receipt output files:
445
+ `verify-proof` exits non-zero
446
+ - incomplete execution ledgers, drift failures, or unmapped changed files:
447
+ `verify-run` exits non-zero
448
+
449
+ ## Project Status
450
+
451
+ Agentflow is at version `0.4.0`. Prebuilt single-file
452
+ artifacts (`agentflow.pyz`, `agentflow-mcp.pyz`, `SHA256SUMS`) are published on
453
+ the [Releases](https://github.com/kstruzzieri/agentflow/releases) page. The
454
+ implemented surface includes:
455
+
456
+ - v0.1 local planning, evidence, drift, and proof artifacts.
457
+ - v0.2 runtime metadata, runtime snapshots, structured proof metadata, and
458
+ reproducible proof verification.
459
+ - v0.3 portable execution contracts, step claims, command and file receipts,
460
+ step/run verification, replay support, provider-neutral handoffs, and
461
+ execution summaries in proof packs.
462
+ - Increments on the v0.3 line: command-risk screening, a stdlib-only MCP server,
463
+ a Stop-hook enforcement gate, a CI proof gate with a strict review gate, a
464
+ deterministic `review-manifest` producer, and hunk-level attribution (drift
465
+ audit distinguishes receipt-covered edits from unrelated edits inside the same
466
+ allowed file), plus durable adaptive workflow contract artifacts.
467
+ - Concurrency and interop: single-writer lease enforcement, cross-worktree
468
+ ledger aggregation via `aggregate-ledgers`, read-only MCP/runtime status
469
+ evidence in proofs, a static `view-proof --html` report, and a Golem adapter
470
+ integration guide.
471
+ - Distribution: a stdlib-only `zipapp` single-file build with a tag-triggered
472
+ release workflow (packaging phase 1).
473
+
474
+ The next priorities are tracked in [docs/roadmap.md](docs/roadmap.md).
475
+
476
+ ## Documentation
477
+
478
+ - [Agent workflow](docs/agent-workflow.md) — plan, execute, verify, and prove a run
479
+ - [Artifact policy](docs/agent-artifacts.md) — decide what stays local and what is safe to publish
480
+ - [Security model](docs/security-model.md) — trust boundaries, guarantees, and operator responsibilities
481
+ - [Command risk screening](docs/command-risk.md) — deterministic command classification and limits
482
+ - [MCP server](docs/mcp.md) — stdio and local HTTP transports
483
+ - [Workflow packs](docs/workflow-packs.md) — reusable workflow policy and planning profiles
484
+ - [Executable examples](examples/) — CI proof, MCP, workflow-pack, and aggregation walkthroughs
485
+ - [Packaging and releases](docs/packaging.md) — build and verify single-file artifacts
486
+ - [Roadmap](docs/roadmap.md) — current status and near-term priorities
487
+
488
+ ## Contributing and Security
489
+
490
+ Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for the local
491
+ development and pull-request workflow. Please report vulnerabilities privately
492
+ as described in [SECURITY.md](SECURITY.md).
493
+
494
+ ## Branding
495
+
496
+ The agentflow brand kit lives in [`docs/branding/`](docs/branding/); open
497
+ [`brand-guide.html`](docs/branding/brand-guide.html) for the full guide.
498
+
499
+ The mark is a **gate / ledger**: plan-step rails passing through a validation
500
+ gate — pending (gray) in, verified (teal) out — reusing the vertical bar in the
501
+ `agent│flow` wordmark. Teal `#00D4AA` is the primary accent; mint `#86EFAC` is
502
+ reserved for `PASS`/success states.
503
+
504
+ | asset | file |
505
+ |-------|------|
506
+ | primary mark | [`agentflow-mark.svg`](docs/branding/agentflow-mark.svg) |
507
+ | favicon (≤16px) | [`favicon.svg`](docs/branding/favicon.svg) |
508
+ | lockups | [`dark`](docs/branding/agentflow-lockup-dark.svg) · [`light`](docs/branding/agentflow-lockup-light.svg) |
509
+ | status badge | [`agentflow-badge.svg`](docs/branding/agentflow-badge.svg) |
510
+ | social card | [`agentflow-social.svg`](docs/branding/agentflow-social.svg) |
511
+
512
+ ## Core Rule
513
+
514
+ ```text
515
+ No fact without evidence.
516
+ No edit without a plan step.
517
+ No plan change without an amendment.
518
+ No completion without verification.
519
+ No context unless it pays rent.
520
+ ```
521
+
522
+ ## License
523
+
524
+ Agentflow is available under the [MIT License](LICENSE).