atomicguard 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 (32) hide show
  1. atomicguard-0.1.0/LICENSE +21 -0
  2. atomicguard-0.1.0/PKG-INFO +137 -0
  3. atomicguard-0.1.0/README.md +96 -0
  4. atomicguard-0.1.0/pyproject.toml +186 -0
  5. atomicguard-0.1.0/setup.cfg +4 -0
  6. atomicguard-0.1.0/src/atomicguard/__init__.py +116 -0
  7. atomicguard-0.1.0/src/atomicguard/application/__init__.py +16 -0
  8. atomicguard-0.1.0/src/atomicguard/application/action_pair.py +65 -0
  9. atomicguard-0.1.0/src/atomicguard/application/agent.py +129 -0
  10. atomicguard-0.1.0/src/atomicguard/application/workflow.py +149 -0
  11. atomicguard-0.1.0/src/atomicguard/domain/__init__.py +51 -0
  12. atomicguard-0.1.0/src/atomicguard/domain/exceptions.py +28 -0
  13. atomicguard-0.1.0/src/atomicguard/domain/interfaces.py +119 -0
  14. atomicguard-0.1.0/src/atomicguard/domain/models.py +145 -0
  15. atomicguard-0.1.0/src/atomicguard/domain/prompts.py +85 -0
  16. atomicguard-0.1.0/src/atomicguard/guards/__init__.py +19 -0
  17. atomicguard-0.1.0/src/atomicguard/guards/base.py +41 -0
  18. atomicguard-0.1.0/src/atomicguard/guards/human.py +85 -0
  19. atomicguard-0.1.0/src/atomicguard/guards/syntax.py +33 -0
  20. atomicguard-0.1.0/src/atomicguard/guards/test_runner.py +176 -0
  21. atomicguard-0.1.0/src/atomicguard/infrastructure/__init__.py +23 -0
  22. atomicguard-0.1.0/src/atomicguard/infrastructure/llm/__init__.py +11 -0
  23. atomicguard-0.1.0/src/atomicguard/infrastructure/llm/mock.py +61 -0
  24. atomicguard-0.1.0/src/atomicguard/infrastructure/llm/ollama.py +132 -0
  25. atomicguard-0.1.0/src/atomicguard/infrastructure/persistence/__init__.py +11 -0
  26. atomicguard-0.1.0/src/atomicguard/infrastructure/persistence/filesystem.py +232 -0
  27. atomicguard-0.1.0/src/atomicguard/infrastructure/persistence/memory.py +39 -0
  28. atomicguard-0.1.0/src/atomicguard.egg-info/PKG-INFO +137 -0
  29. atomicguard-0.1.0/src/atomicguard.egg-info/SOURCES.txt +30 -0
  30. atomicguard-0.1.0/src/atomicguard.egg-info/dependency_links.txt +1 -0
  31. atomicguard-0.1.0/src/atomicguard.egg-info/requires.txt +13 -0
  32. atomicguard-0.1.0/src/atomicguard.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Matthew Thompson
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,137 @@
1
+ Metadata-Version: 2.4
2
+ Name: atomicguard
3
+ Version: 0.1.0
4
+ Summary: A Dual-State Agent Framework for reliable LLM code generation with guard-validated loops
5
+ Author-email: Matthew Thompson <thompsonson@gmail.com>
6
+ Maintainer-email: Matthew Thompson <thompsonson@gmail.com>
7
+ License: MIT
8
+ Project-URL: Homepage, https://github.com/thompsonson/atomicguard
9
+ Project-URL: Repository, https://github.com/thompsonson/atomicguard
10
+ Project-URL: Documentation, https://github.com/thompsonson/atomicguard#readme
11
+ Project-URL: Issues, https://github.com/thompsonson/atomicguard/issues
12
+ Project-URL: Changelog, https://github.com/thompsonson/atomicguard/blob/main/CHANGELOG.md
13
+ Keywords: llm,agents,code-generation,neuro-symbolic,guards,ai,validation
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
24
+ Classifier: Topic :: Software Development :: Code Generators
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.12
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: click>=8.3.1
30
+ Requires-Dist: matplotlib>=3.10.0
31
+ Requires-Dist: openai>=2.12.0
32
+ Requires-Dist: rich>=14.0.0
33
+ Provides-Extra: dev
34
+ Requires-Dist: mypy>=1.13.0; extra == "dev"
35
+ Requires-Dist: pre-commit>=4.5.0; extra == "dev"
36
+ Requires-Dist: ruff>=0.14.0; extra == "dev"
37
+ Provides-Extra: test
38
+ Requires-Dist: pytest>=8.0.0; extra == "test"
39
+ Requires-Dist: pytest-cov>=6.0.0; extra == "test"
40
+ Dynamic: license-file
41
+
42
+ # AtomicGuard
43
+
44
+ [![CI](https://github.com/thompsonson/atomicguard/actions/workflows/ci.yml/badge.svg)](https://github.com/thompsonson/atomicguard/actions/workflows/ci.yml)
45
+ [![codecov](https://codecov.io/gh/thompsonson/atomicguard/branch/main/graph/badge.svg)](https://codecov.io/gh/thompsonson/atomicguard)
46
+ [![PyPI version](https://badge.fury.io/py/atomicguard.svg)](https://badge.fury.io/py/atomicguard)
47
+ [![Python versions](https://img.shields.io/pypi/pyversions/atomicguard.svg)](https://pypi.org/project/atomicguard/)
48
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
49
+
50
+ A Dual-State Agent Framework for reliable LLM code generation.
51
+
52
+ > **New to AtomicGuard?** Start with the [Getting Started Guide](docs/getting-started.md).
53
+
54
+ **Paper:** *Managing the Stochastic: Foundations of Learning in Neuro-Symbolic Systems for Software Engineering* (Thompson, 2025)
55
+
56
+ ## Overview
57
+
58
+ AtomicGuard implements guard-validated generation loops that dramatically improve LLM reliability. The core abstraction is the **Atomic Action Pair** ⟨agen, G⟩ — coupling each generation action with a validation guard.
59
+
60
+ Key results (Yi-Coder 9B, n=50):
61
+
62
+ | Task | Baseline | Guarded | Improvement |
63
+ |------|----------|---------|-------------|
64
+ | Template | 35% | 90% | +55pp |
65
+ | Password | 82% | 98% | +16pp |
66
+ | LRU Cache | 94% | 100% | +6pp |
67
+
68
+ ## Installation
69
+
70
+ ```bash
71
+ # From PyPI
72
+ pip install atomicguard
73
+
74
+ # From source
75
+ git clone https://github.com/thompsonson/atomicguard.git
76
+ cd atomicguard
77
+ uv venv && source .venv/bin/activate
78
+ uv pip install -e ".[dev,test]"
79
+ ```
80
+
81
+ ## Quick Start
82
+
83
+ ```python
84
+ from atomicguard import (
85
+ OllamaGenerator, SyntaxGuard, TestGuard,
86
+ CompositeGuard, ActionPair, DualStateAgent,
87
+ InMemoryArtifactDAG
88
+ )
89
+
90
+ # Setup
91
+ generator = OllamaGenerator(model="qwen2.5-coder:7b")
92
+ guard = CompositeGuard([SyntaxGuard(), TestGuard("assert add(2, 3) == 5")])
93
+ action_pair = ActionPair(generator=generator, guard=guard)
94
+ agent = DualStateAgent(action_pair, InMemoryArtifactDAG(), rmax=3)
95
+
96
+ # Execute
97
+ artifact = agent.execute("Write a function that adds two numbers")
98
+ print(artifact.content)
99
+ ```
100
+
101
+ See [examples/](examples/) for more detailed usage, including a [mock example](examples/basic_mock.py) that works without an LLM.
102
+
103
+ ## Benchmarks
104
+
105
+ Run the simulation from the paper:
106
+
107
+ ```bash
108
+ python -m benchmarks.simulation --model yi-coder:9b --trials 50 --task all --output results/results.db --format sqlite
109
+
110
+ # Generate report
111
+ python -m benchmarks.simulation --visualize --output results/results.db --format sqlite
112
+ ```
113
+
114
+ ## Project Structure
115
+
116
+ ```
117
+ atomicguard/
118
+ ├── src/atomicguard/ # Core library
119
+ ├── benchmarks/ # Simulation code
120
+ ├── docs/design/ # Design documents
121
+ ├── examples/ # Usage examples
122
+ └── results/ # Generated reports & charts
123
+ ```
124
+
125
+ ## Citation
126
+
127
+ ```bibtex
128
+ @article{thompson2025managing,
129
+ title={Managing the Stochastic: Foundations of Learning in Neuro-Symbolic Systems for Software Engineering},
130
+ author={Thompson, Matthew},
131
+ year={2025}
132
+ }
133
+ ```
134
+
135
+ ## License
136
+
137
+ MIT
@@ -0,0 +1,96 @@
1
+ # AtomicGuard
2
+
3
+ [![CI](https://github.com/thompsonson/atomicguard/actions/workflows/ci.yml/badge.svg)](https://github.com/thompsonson/atomicguard/actions/workflows/ci.yml)
4
+ [![codecov](https://codecov.io/gh/thompsonson/atomicguard/branch/main/graph/badge.svg)](https://codecov.io/gh/thompsonson/atomicguard)
5
+ [![PyPI version](https://badge.fury.io/py/atomicguard.svg)](https://badge.fury.io/py/atomicguard)
6
+ [![Python versions](https://img.shields.io/pypi/pyversions/atomicguard.svg)](https://pypi.org/project/atomicguard/)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
+
9
+ A Dual-State Agent Framework for reliable LLM code generation.
10
+
11
+ > **New to AtomicGuard?** Start with the [Getting Started Guide](docs/getting-started.md).
12
+
13
+ **Paper:** *Managing the Stochastic: Foundations of Learning in Neuro-Symbolic Systems for Software Engineering* (Thompson, 2025)
14
+
15
+ ## Overview
16
+
17
+ AtomicGuard implements guard-validated generation loops that dramatically improve LLM reliability. The core abstraction is the **Atomic Action Pair** ⟨agen, G⟩ — coupling each generation action with a validation guard.
18
+
19
+ Key results (Yi-Coder 9B, n=50):
20
+
21
+ | Task | Baseline | Guarded | Improvement |
22
+ |------|----------|---------|-------------|
23
+ | Template | 35% | 90% | +55pp |
24
+ | Password | 82% | 98% | +16pp |
25
+ | LRU Cache | 94% | 100% | +6pp |
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ # From PyPI
31
+ pip install atomicguard
32
+
33
+ # From source
34
+ git clone https://github.com/thompsonson/atomicguard.git
35
+ cd atomicguard
36
+ uv venv && source .venv/bin/activate
37
+ uv pip install -e ".[dev,test]"
38
+ ```
39
+
40
+ ## Quick Start
41
+
42
+ ```python
43
+ from atomicguard import (
44
+ OllamaGenerator, SyntaxGuard, TestGuard,
45
+ CompositeGuard, ActionPair, DualStateAgent,
46
+ InMemoryArtifactDAG
47
+ )
48
+
49
+ # Setup
50
+ generator = OllamaGenerator(model="qwen2.5-coder:7b")
51
+ guard = CompositeGuard([SyntaxGuard(), TestGuard("assert add(2, 3) == 5")])
52
+ action_pair = ActionPair(generator=generator, guard=guard)
53
+ agent = DualStateAgent(action_pair, InMemoryArtifactDAG(), rmax=3)
54
+
55
+ # Execute
56
+ artifact = agent.execute("Write a function that adds two numbers")
57
+ print(artifact.content)
58
+ ```
59
+
60
+ See [examples/](examples/) for more detailed usage, including a [mock example](examples/basic_mock.py) that works without an LLM.
61
+
62
+ ## Benchmarks
63
+
64
+ Run the simulation from the paper:
65
+
66
+ ```bash
67
+ python -m benchmarks.simulation --model yi-coder:9b --trials 50 --task all --output results/results.db --format sqlite
68
+
69
+ # Generate report
70
+ python -m benchmarks.simulation --visualize --output results/results.db --format sqlite
71
+ ```
72
+
73
+ ## Project Structure
74
+
75
+ ```
76
+ atomicguard/
77
+ ├── src/atomicguard/ # Core library
78
+ ├── benchmarks/ # Simulation code
79
+ ├── docs/design/ # Design documents
80
+ ├── examples/ # Usage examples
81
+ └── results/ # Generated reports & charts
82
+ ```
83
+
84
+ ## Citation
85
+
86
+ ```bibtex
87
+ @article{thompson2025managing,
88
+ title={Managing the Stochastic: Foundations of Learning in Neuro-Symbolic Systems for Software Engineering},
89
+ author={Thompson, Matthew},
90
+ year={2025}
91
+ }
92
+ ```
93
+
94
+ ## License
95
+
96
+ MIT
@@ -0,0 +1,186 @@
1
+ [project]
2
+ name = "atomicguard"
3
+ version = "0.1.0"
4
+ description = "A Dual-State Agent Framework for reliable LLM code generation with guard-validated loops"
5
+ readme = "README.md"
6
+ license = { text = "MIT" }
7
+ authors = [
8
+ { name = "Matthew Thompson", email = "thompsonson@gmail.com" }
9
+ ]
10
+ maintainers = [
11
+ { name = "Matthew Thompson", email = "thompsonson@gmail.com" }
12
+ ]
13
+ requires-python = ">=3.12"
14
+ keywords = [
15
+ "llm",
16
+ "agents",
17
+ "code-generation",
18
+ "neuro-symbolic",
19
+ "guards",
20
+ "ai",
21
+ "validation",
22
+ ]
23
+ classifiers = [
24
+ "Development Status :: 3 - Alpha",
25
+ "Intended Audience :: Developers",
26
+ "Intended Audience :: Science/Research",
27
+ "License :: OSI Approved :: MIT License",
28
+ "Operating System :: OS Independent",
29
+ "Programming Language :: Python :: 3",
30
+ "Programming Language :: Python :: 3.12",
31
+ "Programming Language :: Python :: 3.13",
32
+ "Programming Language :: Python :: 3.14",
33
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
34
+ "Topic :: Software Development :: Code Generators",
35
+ "Typing :: Typed",
36
+ ]
37
+ dependencies = [
38
+ "click>=8.3.1",
39
+ "matplotlib>=3.10.0",
40
+ "openai>=2.12.0",
41
+ "rich>=14.0.0",
42
+ ]
43
+
44
+ [project.urls]
45
+ Homepage = "https://github.com/thompsonson/atomicguard"
46
+ Repository = "https://github.com/thompsonson/atomicguard"
47
+ Documentation = "https://github.com/thompsonson/atomicguard#readme"
48
+ Issues = "https://github.com/thompsonson/atomicguard/issues"
49
+ Changelog = "https://github.com/thompsonson/atomicguard/blob/main/CHANGELOG.md"
50
+
51
+ [project.optional-dependencies]
52
+ dev = [
53
+ "mypy>=1.13.0",
54
+ "pre-commit>=4.5.0",
55
+ "ruff>=0.14.0",
56
+ ]
57
+ test = [
58
+ "pytest>=8.0.0",
59
+ "pytest-cov>=6.0.0",
60
+ ]
61
+
62
+ [build-system]
63
+ requires = ["setuptools>=75.0.0", "wheel"]
64
+ build-backend = "setuptools.build_meta"
65
+
66
+ [tool.setuptools.packages.find]
67
+ where = ["src"]
68
+
69
+ # =============================================================================
70
+ # Semantic Release
71
+ # =============================================================================
72
+ [tool.semantic_release]
73
+ version_toml = ["pyproject.toml:project.version"]
74
+ version_variables = ["src/atomicguard/__init__.py:__version__"]
75
+ branch = "main"
76
+ commit_message = "chore(release): bump version to {version}"
77
+ build_command = "pip install build && python -m build"
78
+ upload_to_pypi = true
79
+ upload_to_release = true
80
+
81
+ [tool.semantic_release.changelog]
82
+ changelog_file = "CHANGELOG.md"
83
+ exclude_commit_patterns = [
84
+ "^chore\\(release\\):",
85
+ "^Merge",
86
+ ]
87
+
88
+ [tool.semantic_release.branches.main]
89
+ match = "main"
90
+ prerelease = false
91
+
92
+ [tool.semantic_release.remote]
93
+ type = "github"
94
+ token = { env = "GH_TOKEN" }
95
+
96
+ # =============================================================================
97
+ # Testing
98
+ # =============================================================================
99
+ [tool.pytest.ini_options]
100
+ testpaths = ["tests"]
101
+ python_files = ["test_*.py", "*_test.py"]
102
+ python_functions = ["test_*"]
103
+ addopts = [
104
+ "-ra",
105
+ "-q",
106
+ "--strict-markers",
107
+ "--strict-config",
108
+ ]
109
+ markers = [
110
+ "slow: marks tests as slow (deselect with '-m \"not slow\"')",
111
+ "integration: marks tests as integration tests",
112
+ ]
113
+ filterwarnings = [
114
+ "error",
115
+ "ignore::DeprecationWarning",
116
+ ]
117
+
118
+ [tool.coverage.run]
119
+ source = ["src/atomicguard"]
120
+ branch = true
121
+ omit = [
122
+ "*/__pycache__/*",
123
+ "*/tests/*",
124
+ ]
125
+
126
+ [tool.coverage.report]
127
+ exclude_lines = [
128
+ "pragma: no cover",
129
+ "def __repr__",
130
+ "raise NotImplementedError",
131
+ "if TYPE_CHECKING:",
132
+ "if __name__ == .__main__.:",
133
+ ]
134
+ fail_under = 70
135
+ show_missing = true
136
+
137
+ # =============================================================================
138
+ # Linting & Formatting
139
+ # =============================================================================
140
+ [tool.ruff]
141
+ target-version = "py312"
142
+ line-length = 88
143
+ src = ["src", "tests"]
144
+
145
+ [tool.ruff.lint]
146
+ select = [
147
+ "E", # pycodestyle errors
148
+ "W", # pycodestyle warnings
149
+ "F", # Pyflakes
150
+ "I", # isort
151
+ "B", # flake8-bugbear
152
+ "C4", # flake8-comprehensions
153
+ "UP", # pyupgrade
154
+ "ARG", # flake8-unused-arguments
155
+ "SIM", # flake8-simplify
156
+ ]
157
+ ignore = [
158
+ "E501", # line too long (handled by formatter)
159
+ "B008", # do not perform function calls in argument defaults
160
+ ]
161
+
162
+ [tool.ruff.lint.isort]
163
+ known-first-party = ["atomicguard"]
164
+
165
+ # =============================================================================
166
+ # Type Checking
167
+ # =============================================================================
168
+ [tool.mypy]
169
+ python_version = "3.12"
170
+ warn_return_any = true
171
+ warn_unused_configs = true
172
+ disallow_untyped_defs = true
173
+ disallow_incomplete_defs = true
174
+ check_untyped_defs = true
175
+ disallow_untyped_decorators = true
176
+ no_implicit_optional = true
177
+ warn_redundant_casts = true
178
+ warn_unused_ignores = true
179
+ warn_no_return = true
180
+ strict_equality = true
181
+ show_error_codes = true
182
+ mypy_path = "src"
183
+
184
+ [[tool.mypy.overrides]]
185
+ module = "tests.*"
186
+ disallow_untyped_defs = false
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,116 @@
1
+ """
2
+ AtomicGuard: Dual-State Framework for LLM Output Management.
3
+
4
+ A framework for managing stochastic LLM outputs through deterministic
5
+ control flow, implementing the formal model from Thompson (2025).
6
+
7
+ Example:
8
+ from atomicguard import Workflow, ActionPair
9
+ from atomicguard.guards import SyntaxGuard
10
+ from atomicguard.infrastructure import OllamaGenerator
11
+
12
+ generator = OllamaGenerator(model="qwen2.5-coder:7b")
13
+ guard = SyntaxGuard()
14
+ action_pair = ActionPair(generator=generator, guard=guard)
15
+
16
+ workflow = Workflow(rmax=3)
17
+ workflow.add_step('g_code', action_pair=action_pair)
18
+ result = workflow.execute("Write a function that adds two numbers")
19
+ """
20
+
21
+ # Domain models (most commonly used)
22
+ # Application layer (orchestration)
23
+ from atomicguard.application.action_pair import ActionPair
24
+ from atomicguard.application.agent import DualStateAgent
25
+ from atomicguard.application.workflow import Workflow, WorkflowStep
26
+
27
+ # Domain exceptions
28
+ from atomicguard.domain.exceptions import RmaxExhausted
29
+
30
+ # Domain interfaces (for type hints and custom implementations)
31
+ from atomicguard.domain.interfaces import (
32
+ ArtifactDAGInterface,
33
+ GeneratorInterface,
34
+ GuardInterface,
35
+ )
36
+ from atomicguard.domain.models import (
37
+ AmbientEnvironment,
38
+ Artifact,
39
+ ArtifactStatus,
40
+ Context,
41
+ ContextSnapshot,
42
+ FeedbackEntry,
43
+ GuardResult,
44
+ WorkflowResult,
45
+ WorkflowState,
46
+ )
47
+
48
+ # Prompts and tasks (structures only - content defined by calling applications)
49
+ from atomicguard.domain.prompts import (
50
+ PromptTemplate,
51
+ StepDefinition,
52
+ TaskDefinition,
53
+ )
54
+
55
+ # Guards (commonly composed)
56
+ from atomicguard.guards import (
57
+ CompositeGuard,
58
+ DynamicTestGuard,
59
+ HumanReviewGuard,
60
+ SyntaxGuard,
61
+ TestGuard,
62
+ )
63
+ from atomicguard.infrastructure.llm import (
64
+ MockGenerator,
65
+ OllamaGenerator,
66
+ )
67
+
68
+ # Infrastructure (explicit import encouraged for dependency injection)
69
+ from atomicguard.infrastructure.persistence import (
70
+ FilesystemArtifactDAG,
71
+ InMemoryArtifactDAG,
72
+ )
73
+
74
+ __version__ = "0.1.0"
75
+
76
+ __all__ = [
77
+ # Version
78
+ "__version__",
79
+ # Domain models
80
+ "Artifact",
81
+ "ArtifactStatus",
82
+ "ContextSnapshot",
83
+ "FeedbackEntry",
84
+ "Context",
85
+ "AmbientEnvironment",
86
+ "GuardResult",
87
+ "WorkflowState",
88
+ "WorkflowResult",
89
+ # Prompts and tasks (structures only)
90
+ "PromptTemplate",
91
+ "StepDefinition",
92
+ "TaskDefinition",
93
+ # Domain interfaces
94
+ "GeneratorInterface",
95
+ "GuardInterface",
96
+ "ArtifactDAGInterface",
97
+ # Domain exceptions
98
+ "RmaxExhausted",
99
+ # Application layer
100
+ "ActionPair",
101
+ "DualStateAgent",
102
+ "Workflow",
103
+ "WorkflowStep",
104
+ # Infrastructure - Persistence
105
+ "InMemoryArtifactDAG",
106
+ "FilesystemArtifactDAG",
107
+ # Infrastructure - LLM
108
+ "OllamaGenerator",
109
+ "MockGenerator",
110
+ # Guards
111
+ "CompositeGuard",
112
+ "SyntaxGuard",
113
+ "TestGuard",
114
+ "DynamicTestGuard",
115
+ "HumanReviewGuard",
116
+ ]
@@ -0,0 +1,16 @@
1
+ """
2
+ Application layer for the Dual-State Framework.
3
+
4
+ Contains use cases and orchestration logic that coordinates domain objects.
5
+ """
6
+
7
+ from atomicguard.application.action_pair import ActionPair
8
+ from atomicguard.application.agent import DualStateAgent
9
+ from atomicguard.application.workflow import Workflow, WorkflowStep
10
+
11
+ __all__ = [
12
+ "ActionPair",
13
+ "DualStateAgent",
14
+ "Workflow",
15
+ "WorkflowStep",
16
+ ]
@@ -0,0 +1,65 @@
1
+ """
2
+ ActionPair: Atomic generation-verification transaction.
3
+
4
+ Paper Definition 6: A = ⟨a_gen, G⟩
5
+ Precondition ρ is handled at the Workflow level.
6
+ """
7
+
8
+ from atomicguard.domain.interfaces import GeneratorInterface, GuardInterface
9
+ from atomicguard.domain.models import Artifact, Context, GuardResult
10
+ from atomicguard.domain.prompts import PromptTemplate
11
+
12
+
13
+ class ActionPair:
14
+ """
15
+ Atomic generation-verification transaction.
16
+
17
+ Couples a generator with a guard to form an indivisible unit.
18
+ The precondition ρ is handled at the Workflow level.
19
+ """
20
+
21
+ def __init__(
22
+ self,
23
+ generator: GeneratorInterface,
24
+ guard: GuardInterface,
25
+ prompt_template: PromptTemplate | None = None,
26
+ ):
27
+ """
28
+ Args:
29
+ generator: The artifact generator
30
+ guard: The validator for generated artifacts
31
+ prompt_template: Optional structured prompt template
32
+ """
33
+ self._generator = generator
34
+ self._guard = guard
35
+ self._prompt_template = prompt_template
36
+
37
+ @property
38
+ def generator(self) -> GeneratorInterface:
39
+ """Access the generator (read-only)."""
40
+ return self._generator
41
+
42
+ @property
43
+ def guard(self) -> GuardInterface:
44
+ """Access the guard (read-only)."""
45
+ return self._guard
46
+
47
+ def execute(
48
+ self,
49
+ context: Context,
50
+ dependencies: dict[str, Artifact] | None = None,
51
+ ) -> tuple[Artifact, GuardResult]:
52
+ """
53
+ Execute the atomic generate-then-validate transaction.
54
+
55
+ Args:
56
+ context: Generation context
57
+ dependencies: Artifacts from prior workflow steps
58
+
59
+ Returns:
60
+ Tuple of (generated artifact, guard result)
61
+ """
62
+ dependencies = dependencies or {}
63
+ artifact = self._generator.generate(context, self._prompt_template)
64
+ result = self._guard.validate(artifact, **dependencies)
65
+ return artifact, result