policyflow 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 (87) hide show
  1. policyflow-0.1.0/LICENSE +21 -0
  2. policyflow-0.1.0/PKG-INFO +450 -0
  3. policyflow-0.1.0/README.md +415 -0
  4. policyflow-0.1.0/policyflow/__init__.py +36 -0
  5. policyflow-0.1.0/policyflow/agent_execution.py +301 -0
  6. policyflow-0.1.0/policyflow/api.py +125 -0
  7. policyflow-0.1.0/policyflow/assets/agents/architecture-agent.md +50 -0
  8. policyflow-0.1.0/policyflow/assets/agents/planning-agent.md +46 -0
  9. policyflow-0.1.0/policyflow/assets/agents/qa-agent.md +46 -0
  10. policyflow-0.1.0/policyflow/assets/agents/review-agent.md +51 -0
  11. policyflow-0.1.0/policyflow/assets/agents/senior-dev-agent.md +49 -0
  12. policyflow-0.1.0/policyflow/assets/docs/concepts.md +30 -0
  13. policyflow-0.1.0/policyflow/assets/docs/extraction-notes.md +10 -0
  14. policyflow-0.1.0/policyflow/assets/docs/getting-started.md +282 -0
  15. policyflow-0.1.0/policyflow/assets/docs/governance-enforcement-roadmap.md +58 -0
  16. policyflow-0.1.0/policyflow/assets/docs/human-in-the-loop.md +26 -0
  17. policyflow-0.1.0/policyflow/assets/docs/overview.md +19 -0
  18. policyflow-0.1.0/policyflow/assets/docs/project-context-contract.md +42 -0
  19. policyflow-0.1.0/policyflow/assets/docs/public-api.md +87 -0
  20. policyflow-0.1.0/policyflow/assets/docs/release-and-upgrade.md +125 -0
  21. policyflow-0.1.0/policyflow/assets/docs/runner-contract.md +104 -0
  22. policyflow-0.1.0/policyflow/assets/docs/schema-compatibility.md +99 -0
  23. policyflow-0.1.0/policyflow/assets/examples/policyflow.github-governed.yml +29 -0
  24. policyflow-0.1.0/policyflow/assets/examples/policyflow.minimal.yml +7 -0
  25. policyflow-0.1.0/policyflow/assets/examples/project-context.yml +26 -0
  26. policyflow-0.1.0/policyflow/assets/github/ISSUE_TEMPLATE/architecture-change.yml +92 -0
  27. policyflow-0.1.0/policyflow/assets/github/ISSUE_TEMPLATE/bugfix.yml +97 -0
  28. policyflow-0.1.0/policyflow/assets/github/ISSUE_TEMPLATE/feature.yml +97 -0
  29. policyflow-0.1.0/policyflow/assets/github/PULL_REQUEST_TEMPLATE.md +57 -0
  30. policyflow-0.1.0/policyflow/assets/github/workflows/policyflow-governance.yml +84 -0
  31. policyflow-0.1.0/policyflow/assets/prompts/architecture-agent.prompt.md +11 -0
  32. policyflow-0.1.0/policyflow/assets/prompts/codex-feature-prompt.template.md +20 -0
  33. policyflow-0.1.0/policyflow/assets/prompts/codex-review-prompt.template.md +18 -0
  34. policyflow-0.1.0/policyflow/assets/prompts/planning-agent.prompt.md +11 -0
  35. policyflow-0.1.0/policyflow/assets/prompts/qa-agent.prompt.md +11 -0
  36. policyflow-0.1.0/policyflow/assets/prompts/review-agent.prompt.md +11 -0
  37. policyflow-0.1.0/policyflow/assets/prompts/senior-dev-agent.prompt.md +11 -0
  38. policyflow-0.1.0/policyflow/assets/rules/agent-handoff-contracts.md +36 -0
  39. policyflow-0.1.0/policyflow/assets/rules/confidence-governance.md +25 -0
  40. policyflow-0.1.0/policyflow/assets/rules/escalation-rules.md +20 -0
  41. policyflow-0.1.0/policyflow/assets/rules/qa-checklist.md +10 -0
  42. policyflow-0.1.0/policyflow/assets/rules/review-checklist.md +11 -0
  43. policyflow-0.1.0/policyflow/assets/rules/risk-classification.md +41 -0
  44. policyflow-0.1.0/policyflow/assets/rules/risk-review-matrix.md +57 -0
  45. policyflow-0.1.0/policyflow/assets/workflows/templates/architecture-change-workflow.template.yml +220 -0
  46. policyflow-0.1.0/policyflow/assets/workflows/templates/bugfix-workflow.template.yml +194 -0
  47. policyflow-0.1.0/policyflow/assets/workflows/templates/feature-workflow.template.yml +263 -0
  48. policyflow-0.1.0/policyflow/assets/workflows/templates/governance-fields.example.yml +48 -0
  49. policyflow-0.1.0/policyflow/assets/workflows/templates/handoff-fields.example.yml +63 -0
  50. policyflow-0.1.0/policyflow/assets/workflows/templates/low-risk-workflow.template.yml +151 -0
  51. policyflow-0.1.0/policyflow/bootstrap.py +378 -0
  52. policyflow-0.1.0/policyflow/cli.py +382 -0
  53. policyflow-0.1.0/policyflow/codex_runner.py +188 -0
  54. policyflow-0.1.0/policyflow/consumer_config.py +119 -0
  55. policyflow-0.1.0/policyflow/doctor.py +358 -0
  56. policyflow-0.1.0/policyflow/exceptions.py +9 -0
  57. policyflow-0.1.0/policyflow/github_approval.py +89 -0
  58. policyflow-0.1.0/policyflow/models.py +321 -0
  59. policyflow-0.1.0/policyflow/reporting.py +192 -0
  60. policyflow-0.1.0/policyflow/runtime.py +263 -0
  61. policyflow-0.1.0/policyflow/schemas.py +57 -0
  62. policyflow-0.1.0/policyflow/sync.py +135 -0
  63. policyflow-0.1.0/policyflow/validator.py +897 -0
  64. policyflow-0.1.0/policyflow/workflow_generator.py +228 -0
  65. policyflow-0.1.0/policyflow.egg-info/PKG-INFO +450 -0
  66. policyflow-0.1.0/policyflow.egg-info/SOURCES.txt +85 -0
  67. policyflow-0.1.0/policyflow.egg-info/dependency_links.txt +1 -0
  68. policyflow-0.1.0/policyflow.egg-info/entry_points.txt +2 -0
  69. policyflow-0.1.0/policyflow.egg-info/requires.txt +8 -0
  70. policyflow-0.1.0/policyflow.egg-info/top_level.txt +1 -0
  71. policyflow-0.1.0/pyproject.toml +75 -0
  72. policyflow-0.1.0/setup.cfg +4 -0
  73. policyflow-0.1.0/tests/test_asset_sync.py +123 -0
  74. policyflow-0.1.0/tests/test_bootstrap.py +118 -0
  75. policyflow-0.1.0/tests/test_codex_runner.py +153 -0
  76. policyflow-0.1.0/tests/test_consumer_config.py +134 -0
  77. policyflow-0.1.0/tests/test_consumer_github_workflow.py +61 -0
  78. policyflow-0.1.0/tests/test_doctor.py +197 -0
  79. policyflow-0.1.0/tests/test_github_approval.py +69 -0
  80. policyflow-0.1.0/tests/test_golden_consumer_smoke.py +229 -0
  81. policyflow-0.1.0/tests/test_pr_validator.py +229 -0
  82. policyflow-0.1.0/tests/test_public_api.py +129 -0
  83. policyflow-0.1.0/tests/test_release_packaging.py +68 -0
  84. policyflow-0.1.0/tests/test_repository_docs.py +200 -0
  85. policyflow-0.1.0/tests/test_runtime_cli.py +507 -0
  86. policyflow-0.1.0/tests/test_validator.py +455 -0
  87. policyflow-0.1.0/tests/test_workflow_generator.py +209 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
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,450 @@
1
+ Metadata-Version: 2.4
2
+ Name: policyflow
3
+ Version: 0.1.0
4
+ Summary: Lightweight governance validator for PolicyFlow workflows.
5
+ Author: Marcel Dankert
6
+ Project-URL: Repository, https://github.com/MarcelDankert/PolicyFlow
7
+ Project-URL: Documentation, https://github.com/MarcelDankert/PolicyFlow#readme
8
+ Project-URL: Issues, https://github.com/MarcelDankert/PolicyFlow/issues
9
+ Project-URL: Changelog, https://github.com/MarcelDankert/PolicyFlow/blob/main/CHANGELOG.md
10
+ Keywords: agentic-development,ai-governance,workflow,policy-as-code,github-actions
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Topic :: Software Development :: Quality Assurance
22
+ Classifier: Topic :: Software Development :: Version Control :: Git
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.11
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: pydantic>=2.0
28
+ Requires-Dist: pyyaml>=6.0
29
+ Requires-Dist: rich>=13.0
30
+ Requires-Dist: typer>=0.12
31
+ Provides-Extra: dev
32
+ Requires-Dist: build>=1.0; extra == "dev"
33
+ Requires-Dist: pytest>=8.0; extra == "dev"
34
+ Dynamic: license-file
35
+
36
+ # PolicyFlow
37
+
38
+ PolicyFlow is a reusable governance and lightweight workflow orchestration
39
+ framework for agent-assisted software delivery.
40
+
41
+ It provides policy-as-code style documentation, risk-aware workflow templates, explicit agent handoffs, human approval gates, and GitHub governance patterns that a target project can adopt without building its own process layer from scratch.
42
+
43
+ ## What PolicyFlow Is
44
+
45
+ - A template repository for agentic SDLC governance
46
+ - A set of reusable rules, workflows, prompts, and GitHub intake patterns
47
+ - A way to make agent-driven work more reviewable, risk-aware, and auditable
48
+ - A lightweight workflow orchestration layer for phase state, handoffs, runner
49
+ execution, and governance evidence
50
+
51
+ ## What PolicyFlow Is Not
52
+
53
+ - Not a product repository
54
+ - Not a full orchestration platform or hosted agent runtime
55
+ - Not a substitute for target-project architecture, contracts, or domain context
56
+
57
+ PolicyFlow is not a hosted scheduler, merge bot, or provider credential manager.
58
+
59
+ ## Why It Exists
60
+
61
+ Many teams want to use coding agents, review agents, and workflow automation, but they lack a consistent governance layer. PolicyFlow exists to separate reusable process logic from target-project domain logic so teams can adopt agent workflows with less ambiguity and less hidden risk.
62
+
63
+ ## Core Concepts
64
+
65
+ - Policy-as-code
66
+ - Risk-aware workflows
67
+ - Workflow execution state
68
+ - Phase evidence schema
69
+ - Agent role contracts
70
+ - Typed workflow overrides
71
+ - Runtime workflow orchestration
72
+ - Confidence governance
73
+ - Explicit agent handoffs
74
+ - Human-in-the-loop controls
75
+ - GitHub governance templates
76
+
77
+ ## Repository Structure
78
+
79
+ ```text
80
+ PolicyFlow/
81
+ ├── docs/
82
+ ├── rules/
83
+ ├── agents/
84
+ ├── workflows/
85
+ ├── prompts/
86
+ ├── github/
87
+ └── examples/
88
+ ```
89
+
90
+ ## Repository Agent Guidance
91
+
92
+ See [AGENTS.md](AGENTS.md) for PolicyFlow repository guidance for Codex and
93
+ other coding agents working on this framework.
94
+
95
+ ## How To Use It In A Consumer-Repo
96
+
97
+ Install a pinned PolicyFlow release:
98
+
99
+ ```bash
100
+ python -m pip install policyflow==0.1.0
101
+ ```
102
+
103
+ Use this command once `policyflow==0.1.0` is published. Until then, install from
104
+ this checkout for local evaluation:
105
+
106
+ ```bash
107
+ python -m pip install -e .[dev]
108
+ ```
109
+
110
+ Bootstrap the standard Consumer-Repo layout:
111
+
112
+ ```bash
113
+ policyflow init .
114
+ ```
115
+
116
+ Validate the local setup before the first governed change:
117
+
118
+ ```bash
119
+ policyflow doctor .
120
+ ```
121
+
122
+ Then make the minimal project-specific edits:
123
+
124
+ 1. update `ai/project-context.yml`
125
+ 2. choose local-only or GitHub-governed features in `policyflow.yml`
126
+ 3. configure `policyflow.runners.yml` if agent-owned phases should run through
127
+ a local CLI, hosted-adapter wrapper, or internal runner
128
+ 4. add project-specific overlays such as `ai/architecture.md`,
129
+ `ai/rules/project-overrides.md`, or `contracts/` if applicable
130
+ 5. create workflow instances for real work under `ai/workflows/features/` or the
131
+ configured workflow location before implementation starts
132
+
133
+ See [docs/getting-started.md](docs/getting-started.md) for the full Consumer
134
+ Quickstart, including PR validation, GitHub approval checks, runner setup, and
135
+ managed asset sync.
136
+
137
+ ## Workflow-First Delivery Standard
138
+
139
+ PolicyFlow treats `workflow-first delivery` as the required default process for all consumer repositories that adopt these templates. The workflow is not retrospective paperwork. It is created first and then used to steer implementation, review, and merge readiness.
140
+
141
+ Required order for every consumer repo:
142
+
143
+ 1. Create the workflow file first.
144
+ 2. Lock scope, non-goals, and risk before implementation.
145
+ 3. Declare the workflow execution state using canonical phases and states.
146
+ 4. Execute the workflow phases as real work: planning first, then architecture-check as required by risk, then implementation, review, and QA.
147
+ 5. Record machine-readable role contracts as phases complete so each canonical phase has an explicit owner agent and output contract.
148
+ 6. Record typed overrides only for explicit approved exceptions, and make them visible in the PR when they exist.
149
+ 7. Keep the execution state aligned with the current workflow phase, runtime status, and recorded handoffs.
150
+ 8. Implement inside the declared workflow.
151
+ 9. Allow small workflow refinements in the same PR when they stay within the same scope and risk posture.
152
+ 10. Do not silently expand scope, risk, or non-goals.
153
+ 11. Review the PR body, delivery evidence, declared overrides, and runtime handoffs against the workflow before merge.
154
+
155
+ Pragmatic-strict transition mode:
156
+
157
+ - the workflow file is mandatory from the start of the work
158
+ - the workflow guides the work from the beginning, not only in the PR write-up
159
+ - the workflow declares canonical execution phases with explicit states such as `pending`, `in_progress`, `completed`, and `blocked`
160
+ - workflow phases are operational steps, not only descriptive labels
161
+ - `planning`, `architecture-check`, `review`, and `qa` should be visible in how the work is executed and evidenced
162
+ - completed canonical phases should also carry matching machine-readable role contracts with the expected owner agent
163
+ - approved exceptions should be modeled as typed workflow overrides and explicitly confirmed in the PR
164
+ - runtime status and handoffs should be persisted as the workflow advances
165
+ - small same-scope clarifications in the same PR are allowed
166
+ - hidden scope, risk, or non-goal expansion is not allowed
167
+ - PolicyFlow documents, templates, and PR checks make the workflow visible and lightly enforceable
168
+
169
+ ## Example Installation Approach
170
+
171
+ Install a pinned PolicyFlow release in the target project:
172
+
173
+ ```bash
174
+ python -m pip install policyflow==0.1.0
175
+ ```
176
+
177
+ Then run bootstrap:
178
+
179
+ ```bash
180
+ policyflow init .
181
+ ```
182
+
183
+ Create the first governed workflow instance:
184
+
185
+ ```bash
186
+ policyflow new-workflow feature --id first-feature --risk LOW
187
+ policyflow validate ai/workflows/features/first-feature.yml
188
+ ```
189
+
190
+ See [docs/release-and-upgrade.md](docs/release-and-upgrade.md) for pinning,
191
+ release note, and upgrade guidance.
192
+
193
+ ## Current Status
194
+
195
+ - Template and governance framework
196
+ - Lightweight governance validator
197
+ - Workflow execution state schema
198
+ - Phase evidence schema
199
+ - Transition and gate validator
200
+ - PR evidence mapping
201
+ - GitHub governance workflow for PolicyFlow itself
202
+ - Agent role contract schema for canonical workflow phases
203
+ - Typed workflow override schema with PR visibility
204
+ - Runtime and handoff orchestration state with CLI mutation support
205
+ - Risk-review matrix enforcement
206
+ - Approval evidence enforcement for `HIGH` risk
207
+ - Protected-area escalation enforcement
208
+ - Lightweight runtime workflow orchestration with direct YAML mutation commands
209
+
210
+ ## Validator
211
+
212
+ PolicyFlow now includes a lightweight governance validator for workflow YAML files.
213
+
214
+ Consumer install:
215
+
216
+ ```bash
217
+ python -m pip install policyflow==0.1.0
218
+ ```
219
+
220
+ Developer install from a source checkout:
221
+
222
+ ```bash
223
+ python -m pip install -e .[dev]
224
+ ```
225
+
226
+ Validate a workflow file:
227
+
228
+ ```bash
229
+ policyflow validate workflows/examples/example-feature-workflow.yml
230
+ ```
231
+
232
+ Create a workflow instance in a Consumer-Repo:
233
+
234
+ ```bash
235
+ policyflow new-workflow feature --id first-feature --risk LOW
236
+ policyflow new-workflow bugfix --id parser-fix --risk MEDIUM
237
+ policyflow new-workflow architecture-change --id storage-boundary --risk HIGH
238
+ ```
239
+
240
+ Validate a PR body markdown file against a workflow:
241
+
242
+ ```bash
243
+ policyflow validate-pr workflows/examples/example-feature-workflow.yml path/to/pull-request.md
244
+ ```
245
+
246
+ Validate PR approval logins against GitHub review metadata:
247
+
248
+ ```bash
249
+ policyflow validate-github-approvals workflows/examples/example-architecture-change-workflow.yml path/to/pull-request.md path/to/pr-reviews.json
250
+ ```
251
+
252
+ Workflow reporting helpers:
253
+
254
+ ```bash
255
+ policyflow status workflows/examples/example-feature-workflow.yml
256
+ policyflow status workflows/examples/example-feature-workflow.yml --json
257
+ policyflow audit workflows/features
258
+ policyflow audit workflows/features --json
259
+ ```
260
+
261
+ Provider-neutral runner configuration:
262
+
263
+ ```bash
264
+ policyflow run-phase workflows/examples/example-feature-workflow.yml implementation
265
+ policyflow run-phase workflows/examples/example-feature-workflow.yml implementation --runner-config policyflow.runners.yml
266
+ ```
267
+
268
+ PolicyFlow executes agent-owned phases through a generic command runner
269
+ contract. The default `type: command` runner can be any local CLI, hosted model
270
+ adapter, or internal wrapper that reads PolicyFlow input JSON and writes
271
+ PolicyFlow result JSON. See [docs/runner-contract.md](docs/runner-contract.md)
272
+ for the full input/output contract, placeholders, exit-code behavior, and
273
+ examples.
274
+
275
+ The packaged Codex wrapper is a reference adapter, not a PolicyFlow
276
+ requirement:
277
+
278
+ ```text
279
+ python -m policyflow.codex_runner --input <input.json> --output <output.json>
280
+ ```
281
+
282
+ The wrapper calls `codex exec` and expects Codex to return a single JSON object
283
+ as its final response. If you choose the Codex adapter, install and authenticate
284
+ Codex CLI and verify the local environment with:
285
+
286
+ ```bash
287
+ codex doctor
288
+ ```
289
+
290
+ In CI, install PolicyFlow and the provider runner selected in
291
+ `policyflow.runners.yml` before the governance step. Provider credentials and
292
+ runtime setup stay outside PolicyFlow. If the configured runner is missing or
293
+ cannot run, PolicyFlow blocks the phase with an actionable runtime reason instead
294
+ of leaving the workflow in an ambiguous state.
295
+
296
+ Runner result contract:
297
+
298
+ - `phase`: must match the requested phase
299
+ - `owner_agent`: must match the expected PolicyFlow owner agent
300
+ - `status`: `completed` or `blocked`
301
+ - `summary`: short result summary
302
+ - `blockers`: required when the phase is blocked unless `summary` explains the block
303
+ - `evidence_updates`: optional object written into the phase evidence block
304
+ - `contract_updates`: optional object written into the phase contract block
305
+ - `handoff`: optional object with `to_phase`, `required_inputs`, and `produced_outputs`
306
+
307
+ Codex reference adapter exit codes:
308
+
309
+ - `0`: valid PolicyFlow result JSON was written
310
+ - `2`: Codex CLI command was not found
311
+ - `3`: Codex CLI ran but failed
312
+ - `4`: PolicyFlow input/output contract error
313
+
314
+ Runtime orchestration helpers:
315
+
316
+ ```bash
317
+ policyflow next-step workflows/examples/example-feature-workflow.yml
318
+ policyflow handoff-status workflows/examples/example-feature-workflow.yml
319
+ policyflow start-phase workflows/examples/example-feature-workflow.yml implementation
320
+ policyflow complete-phase workflows/examples/example-feature-workflow.yml implementation
321
+ policyflow block-phase workflows/examples/example-feature-workflow.yml implementation --reason "runtime contract uncertainty"
322
+ policyflow record-handoff workflows/examples/example-feature-workflow.yml --from-phase implementation --to-phase review --required-input implementation_summary --produced-output review_findings
323
+ ```
324
+
325
+ Managed asset upgrade helpers:
326
+
327
+ ```bash
328
+ policyflow sync .
329
+ policyflow sync . --apply
330
+ policyflow sync . --apply --force
331
+ ```
332
+
333
+ Successful validation prints:
334
+
335
+ ```text
336
+ [SUCCESS] Workflow validation passed.
337
+ ```
338
+
339
+ Validation failures print a readable error summary and return a non-zero exit code.
340
+
341
+ Current validator scope:
342
+
343
+ - requires `workflow` metadata
344
+ - requires `context.workflow_file`
345
+ - requires `context.risk_level`
346
+ - requires `context.confidence` with `planning`, `implementation`, `tests`, and `residual_uncertainty`
347
+ - requires `governance.required_reviews`
348
+ - requires `execution.mode`
349
+ - requires `execution.phases`
350
+ - accepts optional `evidence` blocks per workflow phase
351
+ - accepts optional `contracts` blocks per canonical workflow phase
352
+ - accepts optional typed `overrides` entries for approved exceptions
353
+ - accepts optional `runtime` and `handoffs` blocks for lightweight workflow orchestration
354
+ - accepts governance fields primarily from `context` + `governance`
355
+ - accepts equivalent root-level fields only as a backward-compatible fallback
356
+ - allows `LOW`, `MEDIUM`, or `HIGH` risk only
357
+ - requires workflow confidence to be explicit before implementation starts and treats PR `Confidence summary` as a summary of `context.confidence`
358
+ - requires `governance.required_reviews` to be a non-empty list
359
+ - allows execution states `pending`, `in_progress`, `completed`, and `blocked`
360
+ - validates canonical evidence blocks when present:
361
+ - `planning`: `summary`, `scope_locked`, `non_goals_locked`, `risk_rationale`
362
+ - `architecture-check`: `decision`, `constraints`, `approval_path`
363
+ - `review`: `outcome`, `findings_summary`, `residual_risk`
364
+ - `qa`: `outcome`, `evidence_summary`, `unresolved_risks`
365
+ - `approval`: `approved_by`, `reference`, `scope_confirmed`
366
+ - validates canonical role contracts when present:
367
+ - `planning`: `owner_agent`, `issue_brief`, `acceptance_criteria`, `approved_scope`, `non_goals`, `initial_risk_level`, `protected_areas_touched`, `confidence_summary`, `escalation_flags`
368
+ - `architecture-check`: `owner_agent`, `architecture_assessment`, `approved_scope`, `module_boundaries`, `contract_impact`, `risk_review_decision`, `required_reviews`, `implementation_constraints`
369
+ - `implementation`: `owner_agent`, `implementation_summary`, `changed_files`, `test_summary`, `docs_updates`, `known_limitations`, `unresolved_questions`
370
+ - `review`: `owner_agent`, `review_findings`, `required_fixes`, `severity`, `approval_status`, `review_approval`, `residual_risk`, `qa_focus_areas`, `test_expectations`
371
+ - `qa`: `owner_agent`, `qa_report`, `quality_gate_status`, `unresolved_risks`, `approval_required`, `merge_readiness`
372
+ - validates typed overrides when present:
373
+ - shared fields: `id`, `type`, `reason`, `scope_impact`, `risk_impact`, `mitigations`, `approved_by`, `approval_reference`, exactly one of `review_by` or `expires_on`
374
+ - `scope_exception`: `affected_scope_items`
375
+ - `risk_exception`: `original_risk`, `effective_risk`
376
+ - `phase_bypass`: `bypassed_phase`, `compensating_controls`
377
+ - `approval_bypass`: `approval_target`, `compensating_controls`
378
+ - `non_goal_exception`: `affected_non_goals`
379
+ - override lifecycle: `active` until the declared review/expiry window closes, `expiring` during the last 7 days before it closes, `revalidation_required` after it has passed
380
+ - validates runtime orchestration when present:
381
+ - `runtime.status`: `idle`, `in_progress`, `handoff_pending`, `blocked`, `completed`
382
+ - `runtime.current_phase`, `runtime.active_agent`, `runtime.last_transition`, `runtime.block_reason`
383
+ - `handoffs`: `from_phase`, `to_phase`, `status`, `required_inputs`, `produced_outputs`, `blockers`, `override_refs`
384
+ - enforces the first execution transition gates:
385
+ - `implementation` cannot start before `planning` is completed
386
+ - `MEDIUM`/`HIGH` implementation cannot start before `architecture-check` is completed
387
+ - `review` cannot start before `implementation` is completed
388
+ - `qa` cannot start before `review` is completed
389
+ - `approval` cannot start before `qa` is completed
390
+ - requires matching evidence blocks for completed evidence-bearing phases
391
+ - requires matching role contract blocks for completed canonical agent-owned phases
392
+ - requires approval metadata for `risk_exception` and `approval_bypass`
393
+ - emits non-blocking warnings for `expiring` overrides and blocks workflows that reach `revalidation_required`
394
+ - requires PR-visible override references for declared workflow overrides
395
+ - requires runtime `handoff_pending` states to point to an open pending handoff
396
+ - blocks handoffs that still reference overrides requiring revalidation
397
+ - requires concrete handoff input and output artifact lists
398
+ - requires canonical execution phases by risk:
399
+ - `LOW`: `planning`, `implementation`, `review`
400
+ - `MEDIUM`: `planning`, `architecture-check`, `implementation`, `review`, `qa`
401
+ - `HIGH`: `planning`, `architecture-check`, `implementation`, `review`, `qa`, `approval`
402
+ - enforces minimum `required_reviews` from `rules/risk-review-matrix.md`
403
+ - requires `governance.human_approval_required: true` for `HIGH` risk workflows
404
+ - requires non-empty `governance.approval_evidence` for `HIGH` risk workflows
405
+ - requires workflows that touch protected areas to:
406
+ - use `HIGH` risk
407
+ - set `governance.escalation_required: true`
408
+ - treats `governance.protected_areas_touched: [none]` as an explicit no-protected-area case
409
+ - validates PR body markdown files against the existing PR template with:
410
+ - a non-empty `Linked Issue` section
411
+ - a `Workflow File` entry matching `context.workflow_file`
412
+ - a `Declared risk level` entry matching `context.risk_level`
413
+ - a `Human approval login if required` entry matching `evidence.approval.approved_by` for approval-gated workflows
414
+ - override `Approved by login` entries matching workflow `approved_by` logins when present
415
+ - evidence references that point to existing workflow evidence blocks
416
+ - override references that point to existing typed workflow overrides
417
+ - a checked confirmation that the linked workflow governed the change
418
+ - a checked confirmation that the workflow governed the work from the start, not only as a retrospective reference
419
+ - a checked confirmation that scope, non-goals, and risk were fixed in the workflow before implementation started
420
+ - a checked confirmation that required workflow phases were executed as visible working steps, not only documented after the fact
421
+ - validates GitHub PR review metadata against workflow approval claims by requiring `APPROVED` reviews from the declared `approved_by` logins
422
+ - exposes workflow reporting views for a single workflow (`status`) and a directory tree (`audit`) with optional JSON output
423
+ - supports synchronous external agent execution for canonical agent-owned phases through a central runner config and JSON result contract
424
+ - supports dry-run and explicit-apply sync for PolicyFlow-managed Consumer-Repo assets
425
+
426
+ This runtime layer is intentionally small. It mutates only controlled workflow fields and does not execute agents, schedule work, or orchestrate GitHub runs directly.
427
+
428
+ PolicyFlow now acts as a lightweight workflow orchestration layer as well as a governance validator, but it is still not a full orchestration platform, scheduler, or agent runtime.
429
+
430
+ ## Compatibility
431
+
432
+ Follow the canonical workflow schema and migration guidance in
433
+ [docs/schema-compatibility.md](docs/schema-compatibility.md). Stable public
434
+ imports are documented in [docs/public-api.md](docs/public-api.md).
435
+
436
+ ## Project Status
437
+
438
+ PolicyFlow is release-ready for `0.1.0` packaging and publication once the PyPI
439
+ package and matching GitHub Release are created. Until that release exists,
440
+ install from this repository for evaluation and use the pinned
441
+ `policyflow==0.1.0` commands as the intended published Consumer-Repo path.
442
+
443
+ ## Future Roadmap
444
+
445
+ - release publishing automation after packaged release checks are proven
446
+ - additional consumer validation beyond AurumEdge once more repos adopt the workflow
447
+
448
+ ## License
449
+
450
+ See [LICENSE](LICENSE).