workflow-coordinator 0.1.0b1__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 (49) hide show
  1. workflow_coordinator-0.1.0b1/LICENSE +21 -0
  2. workflow_coordinator-0.1.0b1/PKG-INFO +120 -0
  3. workflow_coordinator-0.1.0b1/README.md +70 -0
  4. workflow_coordinator-0.1.0b1/pyproject.toml +75 -0
  5. workflow_coordinator-0.1.0b1/setup.cfg +4 -0
  6. workflow_coordinator-0.1.0b1/src/workflow_coordinator/__init__.py +1 -0
  7. workflow_coordinator-0.1.0b1/src/workflow_coordinator/adapter.py +150 -0
  8. workflow_coordinator-0.1.0b1/src/workflow_coordinator/claude_adapter.py +289 -0
  9. workflow_coordinator-0.1.0b1/src/workflow_coordinator/codex_adapter.py +395 -0
  10. workflow_coordinator-0.1.0b1/src/workflow_coordinator/codex_adapter_smoke.py +231 -0
  11. workflow_coordinator-0.1.0b1/src/workflow_coordinator/commissioning.py +432 -0
  12. workflow_coordinator-0.1.0b1/src/workflow_coordinator/evidence.py +481 -0
  13. workflow_coordinator-0.1.0b1/src/workflow_coordinator/execution_boundary.py +187 -0
  14. workflow_coordinator-0.1.0b1/src/workflow_coordinator/frontdoor/__init__.py +1 -0
  15. workflow_coordinator-0.1.0b1/src/workflow_coordinator/frontdoor/archive.py +1496 -0
  16. workflow_coordinator-0.1.0b1/src/workflow_coordinator/frontdoor/audit.py +589 -0
  17. workflow_coordinator-0.1.0b1/src/workflow_coordinator/frontdoor/cli.py +42 -0
  18. workflow_coordinator-0.1.0b1/src/workflow_coordinator/frontdoor/config.py +287 -0
  19. workflow_coordinator-0.1.0b1/src/workflow_coordinator/frontdoor/init.py +228 -0
  20. workflow_coordinator-0.1.0b1/src/workflow_coordinator/frontdoor/journal.py +284 -0
  21. workflow_coordinator-0.1.0b1/src/workflow_coordinator/frontdoor/lifecycle.py +1093 -0
  22. workflow_coordinator-0.1.0b1/src/workflow_coordinator/frontdoor/plan.py +311 -0
  23. workflow_coordinator-0.1.0b1/src/workflow_coordinator/frontdoor/postrun.py +254 -0
  24. workflow_coordinator-0.1.0b1/src/workflow_coordinator/frontdoor/preservation.py +132 -0
  25. workflow_coordinator-0.1.0b1/src/workflow_coordinator/frontdoor/report.py +222 -0
  26. workflow_coordinator-0.1.0b1/src/workflow_coordinator/frontdoor/request.py +170 -0
  27. workflow_coordinator-0.1.0b1/src/workflow_coordinator/frontdoor/verify.py +137 -0
  28. workflow_coordinator-0.1.0b1/src/workflow_coordinator/git_facts.py +1258 -0
  29. workflow_coordinator-0.1.0b1/src/workflow_coordinator/implementation_identity.py +68 -0
  30. workflow_coordinator-0.1.0b1/src/workflow_coordinator/model.py +958 -0
  31. workflow_coordinator-0.1.0b1/src/workflow_coordinator/operator.py +1915 -0
  32. workflow_coordinator-0.1.0b1/src/workflow_coordinator/persistence.py +599 -0
  33. workflow_coordinator-0.1.0b1/src/workflow_coordinator/prompt.py +272 -0
  34. workflow_coordinator-0.1.0b1/src/workflow_coordinator/proof_harness.py +295 -0
  35. workflow_coordinator-0.1.0b1/src/workflow_coordinator/reducer.py +2006 -0
  36. workflow_coordinator-0.1.0b1/src/workflow_coordinator/resources/agent_operating_contract_v6.txt +97 -0
  37. workflow_coordinator-0.1.0b1/src/workflow_coordinator/resources/roles/reviewer.txt +41 -0
  38. workflow_coordinator-0.1.0b1/src/workflow_coordinator/resources/roles/simple-self-check.txt +6 -0
  39. workflow_coordinator-0.1.0b1/src/workflow_coordinator/resources/roles/worker.txt +24 -0
  40. workflow_coordinator-0.1.0b1/src/workflow_coordinator/serialization.py +2392 -0
  41. workflow_coordinator-0.1.0b1/src/workflow_coordinator/slice4.py +411 -0
  42. workflow_coordinator-0.1.0b1/src/workflow_coordinator/structured_result_schema.py +266 -0
  43. workflow_coordinator-0.1.0b1/src/workflow_coordinator/vertical.py +597 -0
  44. workflow_coordinator-0.1.0b1/src/workflow_coordinator.egg-info/PKG-INFO +120 -0
  45. workflow_coordinator-0.1.0b1/src/workflow_coordinator.egg-info/SOURCES.txt +47 -0
  46. workflow_coordinator-0.1.0b1/src/workflow_coordinator.egg-info/dependency_links.txt +1 -0
  47. workflow_coordinator-0.1.0b1/src/workflow_coordinator.egg-info/entry_points.txt +2 -0
  48. workflow_coordinator-0.1.0b1/src/workflow_coordinator.egg-info/requires.txt +7 -0
  49. workflow_coordinator-0.1.0b1/src/workflow_coordinator.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Stefan Schade
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,120 @@
1
+ Metadata-Version: 2.4
2
+ Name: workflow-coordinator
3
+ Version: 0.1.0b1
4
+ Summary: Bounded repository-native agent workflow coordination.
5
+ Author: Stefan Schade
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 Stefan Schade
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Repository, https://github.com/StefanSchade/workflow-coordinator
29
+ Project-URL: Issues, https://github.com/StefanSchade/workflow-coordinator/issues
30
+ Classifier: Development Status :: 4 - Beta
31
+ Classifier: License :: OSI Approved :: MIT License
32
+ Classifier: Programming Language :: Python :: 3
33
+ Classifier: Programming Language :: Python :: 3.10
34
+ Classifier: Programming Language :: Python :: 3.11
35
+ Classifier: Programming Language :: Python :: 3.12
36
+ Classifier: Programming Language :: Python :: 3.13
37
+ Classifier: Operating System :: POSIX :: Linux
38
+ Classifier: Environment :: Console
39
+ Classifier: Topic :: Software Development
40
+ Requires-Python: >=3.10
41
+ Description-Content-Type: text/markdown
42
+ License-File: LICENSE
43
+ Requires-Dist: PyYAML>=6
44
+ Provides-Extra: dev
45
+ Requires-Dist: build>=1.2; extra == "dev"
46
+ Requires-Dist: pytest>=8.2; extra == "dev"
47
+ Requires-Dist: pytest-cov>=5; extra == "dev"
48
+ Requires-Dist: ruff>=0.6; extra == "dev"
49
+ Dynamic: license-file
50
+
51
+ # Workflow Coordinator
52
+
53
+ Workflow Coordinator is a Git-based coordinator for controlled agentic
54
+ execution: explicit authorization boundaries, independent review, trusted
55
+ commits and recorded run evidence. This first beta is qualified and
56
+ practically focused on software-development workflows, on one qualified
57
+ platform (CPython 3.13, Linux x86-64). Its core mechanics are designed to
58
+ stay domain-neutral for work on versioned artifacts more broadly -- an
59
+ enabling component of a longer-term "Agentic Anything Factory" direction, a
60
+ strategic target image rather than a feature this release delivers.
61
+
62
+ Workflow Coordinator is a bounded, repository-native engine for serial agent
63
+ workflows with explicit Git, evidence, authority, and human-stop boundaries.
64
+
65
+ ## Where to start
66
+
67
+ - **Install / Quickstart** -- [consumer quickstart](https://github.com/StefanSchade/workflow-coordinator/blob/v0.1.0b1/docs/operator_manual/ch09_consumer_quickstart/01_quickstart.adoc): prerequisites, installation and the plan/run/status walkthrough.
68
+ - **Run a small demo** -- [a first consumer example](https://github.com/StefanSchade/workflow-coordinator/blob/v0.1.0b1/docs/operator_manual/ch09_consumer_quickstart/02_first_run_example.adoc): one verified, copy-pasteable Run on a tiny demo repository.
69
+ - **Claude Code + WFC** -- [the Level-1 operating pattern](https://github.com/StefanSchade/workflow-coordinator/blob/v0.1.0b1/docs/operator_manual/ch10_level1_orchestration/_chapter.adoc): using an external Claude Code session to decompose a goal into bounded Commissions that WFC executes.
70
+ - **Operator Manual** -- [the full manual](https://github.com/StefanSchade/workflow-coordinator/blob/v0.1.0b1/docs/operator_manual/operator_manual.adoc): all ten chapters, including failure modes and recovery.
71
+ - **Limitations / Release Notes** -- this Beta's [honest limitations](https://github.com/StefanSchade/workflow-coordinator/blob/v0.1.0b1/docs/operator_manual/ch09_consumer_quickstart/01_quickstart.adoc#beta-limitations) and the [release notes](https://github.com/StefanSchade/workflow-coordinator/blob/v0.1.0b1/docs/release_notes/release_notes.adoc).
72
+ - **Developer Guide** -- [setup, test selection and code navigation](https://github.com/StefanSchade/workflow-coordinator/blob/v0.1.0b1/docs/developer_guide/developer_guide.adoc).
73
+
74
+ The supported package requires Python 3.10 or newer. Once 0.1.0b1 is
75
+ published to PyPI, install the exact pre-release with
76
+ `python3 -m pip install 'workflow-coordinator==0.1.0b1'`; this paragraph
77
+ describes that installable state without claiming the package has been
78
+ published yet. From a source checkout, install with
79
+ `python3 -m pip install .` instead -- the form developers of this
80
+ repository use. Either way, inspect the operator with `wfc --help`. Real
81
+ provider execution always requires separate consumer authority and is never
82
+ implied by installation.
83
+
84
+ For detailed setup, test selection and code navigation, see the [Developer Guide](https://github.com/StefanSchade/workflow-coordinator/blob/v0.1.0b1/docs/developer_guide/developer_guide.adoc).
85
+ For development, install `python3 -m pip install '.[dev]'`. The small Makefile
86
+ provides `make test`, `make lint`, `make format-check`, `make check`,
87
+ `make coverage`, `make coverage-html`, and `make build`. Set `PYTHON` to the
88
+ development interpreter when needed, for example `make coverage PYTHON=.venv/bin/python`.
89
+ The coverage targets run the test suite with branch measurement; the terminal
90
+ report shows missing lines and the HTML report is written to `build/htmlcov/`. `make lint` runs repository-wide Ruff correctness checks;
91
+ `make format-check` covers the snapshot implementation and its architecture and
92
+ unit tests. Use `make snapshot` (or `make snapshot-multi`) to create compact,
93
+ line-numbered WFC-prefixed repository snapshots in `build/snapshots/`; the output
94
+ includes a table of contents and a repository tree.
95
+
96
+ Project Memory lives in [`project_memory/`](https://github.com/StefanSchade/workflow-coordinator/blob/v0.1.0b1/project_memory/README.adoc), whose
97
+ canonical JSON tables are authoritative. `make memory-export` renders them as an
98
+ ODS workbook; after editing it, `make memory-import` validates the converted
99
+ workbook and writes it back into the canonical JSON as ordinary working-tree
100
+ changes. Git is the review boundary: inspect the result with `git diff`, accept
101
+ it with a commit, reject it with `git restore`. There is no separate Project
102
+ Memory promotion protocol. `make memory-roundtrip-check` is the independent
103
+ transformation invariant and writes neither canonical JSON nor the workbook;
104
+ `make memory-setup` installs the pinned maintainer-only spreadsheet tooling.
105
+
106
+ The [standalone authority index](https://github.com/StefanSchade/workflow-coordinator/blob/v0.1.0b1/docs/README.adoc) is the authoritative
107
+ classification of current documentation, executable surfaces, provenance,
108
+ history, and planning evidence. Start there before maintaining or operating the
109
+ project. The compact [task router](https://github.com/StefanSchade/workflow-coordinator/blob/v0.1.0b1/docs/ai_info/_ai_info.adoc) provides the
110
+ normal current-reading path for a specific task.
111
+
112
+ The installed `wfc --version --json` reports the executing package version,
113
+ implementation tree SHA-256, reviewed resource SHA-256 digests and source commit
114
+ when established. A null `source_commit` means unknown: wheel and source archive
115
+ installs do not establish a Git commit merely from their contents. In a clean
116
+ checkout, the commit is reported only after the package files are verified
117
+ against it. The tree digest covers package files by relative path and bytes,
118
+ excluding Python bytecode and `__pycache__`; it does not depend on the current
119
+ working directory. Reviewed role texts and the operating contract are checked
120
+ before dispatch. Existing operator arguments continue through `wfc` unchanged.
@@ -0,0 +1,70 @@
1
+ # Workflow Coordinator
2
+
3
+ Workflow Coordinator is a Git-based coordinator for controlled agentic
4
+ execution: explicit authorization boundaries, independent review, trusted
5
+ commits and recorded run evidence. This first beta is qualified and
6
+ practically focused on software-development workflows, on one qualified
7
+ platform (CPython 3.13, Linux x86-64). Its core mechanics are designed to
8
+ stay domain-neutral for work on versioned artifacts more broadly -- an
9
+ enabling component of a longer-term "Agentic Anything Factory" direction, a
10
+ strategic target image rather than a feature this release delivers.
11
+
12
+ Workflow Coordinator is a bounded, repository-native engine for serial agent
13
+ workflows with explicit Git, evidence, authority, and human-stop boundaries.
14
+
15
+ ## Where to start
16
+
17
+ - **Install / Quickstart** -- [consumer quickstart](https://github.com/StefanSchade/workflow-coordinator/blob/v0.1.0b1/docs/operator_manual/ch09_consumer_quickstart/01_quickstart.adoc): prerequisites, installation and the plan/run/status walkthrough.
18
+ - **Run a small demo** -- [a first consumer example](https://github.com/StefanSchade/workflow-coordinator/blob/v0.1.0b1/docs/operator_manual/ch09_consumer_quickstart/02_first_run_example.adoc): one verified, copy-pasteable Run on a tiny demo repository.
19
+ - **Claude Code + WFC** -- [the Level-1 operating pattern](https://github.com/StefanSchade/workflow-coordinator/blob/v0.1.0b1/docs/operator_manual/ch10_level1_orchestration/_chapter.adoc): using an external Claude Code session to decompose a goal into bounded Commissions that WFC executes.
20
+ - **Operator Manual** -- [the full manual](https://github.com/StefanSchade/workflow-coordinator/blob/v0.1.0b1/docs/operator_manual/operator_manual.adoc): all ten chapters, including failure modes and recovery.
21
+ - **Limitations / Release Notes** -- this Beta's [honest limitations](https://github.com/StefanSchade/workflow-coordinator/blob/v0.1.0b1/docs/operator_manual/ch09_consumer_quickstart/01_quickstart.adoc#beta-limitations) and the [release notes](https://github.com/StefanSchade/workflow-coordinator/blob/v0.1.0b1/docs/release_notes/release_notes.adoc).
22
+ - **Developer Guide** -- [setup, test selection and code navigation](https://github.com/StefanSchade/workflow-coordinator/blob/v0.1.0b1/docs/developer_guide/developer_guide.adoc).
23
+
24
+ The supported package requires Python 3.10 or newer. Once 0.1.0b1 is
25
+ published to PyPI, install the exact pre-release with
26
+ `python3 -m pip install 'workflow-coordinator==0.1.0b1'`; this paragraph
27
+ describes that installable state without claiming the package has been
28
+ published yet. From a source checkout, install with
29
+ `python3 -m pip install .` instead -- the form developers of this
30
+ repository use. Either way, inspect the operator with `wfc --help`. Real
31
+ provider execution always requires separate consumer authority and is never
32
+ implied by installation.
33
+
34
+ For detailed setup, test selection and code navigation, see the [Developer Guide](https://github.com/StefanSchade/workflow-coordinator/blob/v0.1.0b1/docs/developer_guide/developer_guide.adoc).
35
+ For development, install `python3 -m pip install '.[dev]'`. The small Makefile
36
+ provides `make test`, `make lint`, `make format-check`, `make check`,
37
+ `make coverage`, `make coverage-html`, and `make build`. Set `PYTHON` to the
38
+ development interpreter when needed, for example `make coverage PYTHON=.venv/bin/python`.
39
+ The coverage targets run the test suite with branch measurement; the terminal
40
+ report shows missing lines and the HTML report is written to `build/htmlcov/`. `make lint` runs repository-wide Ruff correctness checks;
41
+ `make format-check` covers the snapshot implementation and its architecture and
42
+ unit tests. Use `make snapshot` (or `make snapshot-multi`) to create compact,
43
+ line-numbered WFC-prefixed repository snapshots in `build/snapshots/`; the output
44
+ includes a table of contents and a repository tree.
45
+
46
+ Project Memory lives in [`project_memory/`](https://github.com/StefanSchade/workflow-coordinator/blob/v0.1.0b1/project_memory/README.adoc), whose
47
+ canonical JSON tables are authoritative. `make memory-export` renders them as an
48
+ ODS workbook; after editing it, `make memory-import` validates the converted
49
+ workbook and writes it back into the canonical JSON as ordinary working-tree
50
+ changes. Git is the review boundary: inspect the result with `git diff`, accept
51
+ it with a commit, reject it with `git restore`. There is no separate Project
52
+ Memory promotion protocol. `make memory-roundtrip-check` is the independent
53
+ transformation invariant and writes neither canonical JSON nor the workbook;
54
+ `make memory-setup` installs the pinned maintainer-only spreadsheet tooling.
55
+
56
+ The [standalone authority index](https://github.com/StefanSchade/workflow-coordinator/blob/v0.1.0b1/docs/README.adoc) is the authoritative
57
+ classification of current documentation, executable surfaces, provenance,
58
+ history, and planning evidence. Start there before maintaining or operating the
59
+ project. The compact [task router](https://github.com/StefanSchade/workflow-coordinator/blob/v0.1.0b1/docs/ai_info/_ai_info.adoc) provides the
60
+ normal current-reading path for a specific task.
61
+
62
+ The installed `wfc --version --json` reports the executing package version,
63
+ implementation tree SHA-256, reviewed resource SHA-256 digests and source commit
64
+ when established. A null `source_commit` means unknown: wheel and source archive
65
+ installs do not establish a Git commit merely from their contents. In a clean
66
+ checkout, the commit is reported only after the package files are verified
67
+ against it. The tree digest covers package files by relative path and bytes,
68
+ excluding Python bytecode and `__pycache__`; it does not depend on the current
69
+ working directory. Reviewed role texts and the operating contract are checked
70
+ before dispatch. Existing operator arguments continue through `wfc` unchanged.
@@ -0,0 +1,75 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "workflow-coordinator"
7
+ version = "0.1.0b1"
8
+ description = "Bounded repository-native agent workflow coordination."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { file = "LICENSE" }
12
+ authors = [{ name = "Stefan Schade" }]
13
+ classifiers = [
14
+ "Development Status :: 4 - Beta",
15
+ "License :: OSI Approved :: MIT License",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.10",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Programming Language :: Python :: 3.12",
20
+ "Programming Language :: Python :: 3.13",
21
+ "Operating System :: POSIX :: Linux",
22
+ "Environment :: Console",
23
+ "Topic :: Software Development",
24
+ ]
25
+ dependencies = ["PyYAML>=6"]
26
+
27
+ [project.optional-dependencies]
28
+ dev = ["build>=1.2", "pytest>=8.2", "pytest-cov>=5", "ruff>=0.6"]
29
+
30
+ [project.scripts]
31
+ wfc = "workflow_coordinator.frontdoor.cli:main"
32
+
33
+ [project.urls]
34
+ Repository = "https://github.com/StefanSchade/workflow-coordinator"
35
+ Issues = "https://github.com/StefanSchade/workflow-coordinator/issues"
36
+
37
+ [tool.setuptools]
38
+ package-dir = { "" = "src" }
39
+ include-package-data = false
40
+
41
+ [tool.setuptools.packages.find]
42
+ where = ["src"]
43
+ include = ["workflow_coordinator*"]
44
+
45
+ [tool.setuptools.package-data]
46
+ workflow_coordinator = ["resources/*.txt", "resources/roles/*.txt"]
47
+
48
+ [tool.pytest.ini_options]
49
+ testpaths = ["tests"]
50
+ addopts = "-q"
51
+ pythonpath = ["src", "."]
52
+ markers = [
53
+ "ftr(id): associate an imported acceptance invariant with its historical feature ticket",
54
+ "guardrail: architecture, dependency, or semantic drift guard",
55
+ "historical_governance: requires historical self-development fixtures",
56
+ ]
57
+
58
+ [tool.coverage.run]
59
+ branch = true
60
+ source = ["src/workflow_coordinator"]
61
+ omit = ["*/__init__.py"]
62
+
63
+ [tool.coverage.report]
64
+ show_missing = true
65
+ skip_covered = true
66
+
67
+ [tool.ruff]
68
+ line-length = 100
69
+ target-version = "py310"
70
+
71
+ [tool.ruff.lint]
72
+ # Apply repository-wide correctness checks. Style cleanup is intentionally
73
+ # bounded to the developer-ergonomics implementation until the existing
74
+ # baseline is formatted in a dedicated change.
75
+ select = ["F"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ """Repository-local mechanics for the accepted workflow coordinator slices."""
@@ -0,0 +1,150 @@
1
+ """Provider-neutral execution port and deterministic local test adapters."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import subprocess
7
+ from dataclasses import dataclass
8
+ from pathlib import Path
9
+ from typing import Protocol
10
+
11
+ from .model import ResultContractKind, ResultValue, admits_result_contract_version
12
+ from .serialization import ValidationError, review_verdict_from_data, routing_result_from_data, work_result_from_data
13
+
14
+
15
+ class ResultValidationError(ValidationError):
16
+ """An adapter result is malformed, incomplete, or belongs to another invocation."""
17
+
18
+
19
+ class ExecutionResultValidationError(ResultValidationError):
20
+ """A semantic rejection paired with its completed transport outcome."""
21
+
22
+ def __init__(self, outcome: AgentExecutionOutcome, message: str):
23
+ super().__init__(message)
24
+ self.outcome = outcome
25
+
26
+
27
+ class ExecutionNotStartedError(ValueError):
28
+ """A local failure that proves the execution port was not entered."""
29
+
30
+
31
+ @dataclass(frozen=True)
32
+ class Invocation:
33
+ run_id: str
34
+ hop_id: str
35
+ invocation_id: str
36
+
37
+
38
+ @dataclass(frozen=True)
39
+ class AgentExecutionRequest:
40
+ """Facts the application supplies for one bounded agent invocation.
41
+
42
+ ``result_contract`` identifies the canonical semantic result envelope; its
43
+ provider transport projection is deliberately an adapter concern.
44
+ """
45
+
46
+ invocation: Invocation
47
+ prompt: str
48
+ repository: Path
49
+ result_contract: str
50
+ timeout_seconds: float
51
+ contract_version: int = 1
52
+ result_contract_kind: ResultContractKind = ResultContractKind.GENERIC_ROUTING_RESULT
53
+ # Current-phase route keys a strict-schema adapter may admit for
54
+ # ``requested_route``; empty is only meaningful to adapters that do not
55
+ # project such a schema (a strict-schema adapter must fail closed on empty,
56
+ # never treat it as unconstrained).
57
+ permitted_routes: tuple[str, ...] = ()
58
+ # The admitted phase's own permitted Finding operations, which a
59
+ # strict-schema adapter projects into the ``findings`` surface. ``None``
60
+ # states no authority at all, and keeps the unnarrowed surface; ``()`` is
61
+ # the truthful value for a phase that may author no authoritative
62
+ # disposition. The reducer re-derives and enforces the same authority.
63
+ finding_authority: tuple[str, ...] | None = None
64
+
65
+
66
+ @dataclass(frozen=True)
67
+ class AgentExecutionOutcome:
68
+ """Transport facts, before provider-neutral semantic acceptance.
69
+
70
+ A candidate result is intentionally not a ``RoutingResult``. The caller
71
+ must still parse, validate, and correlate it through ``validated_result``.
72
+ """
73
+
74
+ candidate_result: str | None
75
+ returncode: int | None
76
+ timed_out: bool
77
+ stdout: str
78
+ stderr: str
79
+ diagnostics: tuple[str, ...] = ()
80
+
81
+
82
+ ROUTING_RESULT_ENVELOPE_CONTRACT = "routing-result-envelope/v1"
83
+
84
+
85
+ class AgentExecutionPort(Protocol):
86
+ def execute(self, request: AgentExecutionRequest) -> AgentExecutionOutcome: ...
87
+
88
+
89
+ @dataclass(frozen=True)
90
+ class FakeAdapter:
91
+ output: str
92
+
93
+ def execute(self, request: AgentExecutionRequest) -> AgentExecutionOutcome:
94
+ return AgentExecutionOutcome(self.output, 0, False, "", "")
95
+
96
+
97
+ @dataclass(frozen=True)
98
+ class SubprocessAdapter:
99
+ """A disposable-fixture adapter, deliberately not a provider SDK."""
100
+
101
+ argv: tuple[str, ...]
102
+
103
+ def execute(self, request: AgentExecutionRequest) -> AgentExecutionOutcome:
104
+ completed = subprocess.run(self.argv, cwd=request.repository, input=request.prompt, text=True,
105
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False)
106
+ return AgentExecutionOutcome(
107
+ completed.stdout if completed.returncode == 0 else None,
108
+ completed.returncode,
109
+ False,
110
+ completed.stdout,
111
+ completed.stderr,
112
+ (f"subprocess adapter exited {completed.returncode}",) if completed.returncode else (),
113
+ )
114
+
115
+
116
+ def validated_result(
117
+ raw: str, expected: Invocation, contract_version: int = 1,
118
+ result_contract_kind: ResultContractKind = ResultContractKind.GENERIC_ROUTING_RESULT,
119
+ ) -> ResultValue:
120
+ if not admits_result_contract_version(result_contract_kind, contract_version):
121
+ raise ResultValidationError("unsupported structured result contract version")
122
+ try:
123
+ envelope = json.loads(raw)
124
+ except json.JSONDecodeError as error:
125
+ raise ResultValidationError("truncated or invalid structured result") from error
126
+ if not isinstance(envelope, dict) or set(envelope) != {"schema_version", "run_id", "hop_id", "invocation_id", "result"}:
127
+ raise ResultValidationError("structured result has missing or unknown envelope fields")
128
+ if envelope["schema_version"] != contract_version:
129
+ raise ResultValidationError("structured result has unsupported schema version")
130
+ actual = (envelope["run_id"], envelope["hop_id"], envelope["invocation_id"])
131
+ wanted = (expected.run_id, expected.hop_id, expected.invocation_id)
132
+ if actual != wanted:
133
+ raise ResultValidationError("structured result identity does not correlate to dispatch")
134
+ try:
135
+ parsers = {
136
+ ResultContractKind.GENERIC_ROUTING_RESULT: routing_result_from_data,
137
+ ResultContractKind.WORK_RESULT: work_result_from_data,
138
+ ResultContractKind.REVIEW_VERDICT: review_verdict_from_data,
139
+ }
140
+ parser = parsers.get(result_contract_kind)
141
+ if parser is None:
142
+ raise ResultValidationError("unsupported result contract kind")
143
+ result = parser(envelope["result"])
144
+ if result.schema_version != contract_version:
145
+ raise ResultValidationError(
146
+ "structured result version does not match the selected contract"
147
+ )
148
+ return result
149
+ except ValidationError as error:
150
+ raise ResultValidationError(str(error)) from error