constraintloop 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.
- constraintloop-0.1.0/.gitignore +16 -0
- constraintloop-0.1.0/CHANGELOG.md +29 -0
- constraintloop-0.1.0/CONTRIBUTING.md +47 -0
- constraintloop-0.1.0/GOVERNANCE.md +13 -0
- constraintloop-0.1.0/LICENSE +21 -0
- constraintloop-0.1.0/PKG-INFO +371 -0
- constraintloop-0.1.0/README.md +328 -0
- constraintloop-0.1.0/RELEASE.md +80 -0
- constraintloop-0.1.0/SECURITY.md +26 -0
- constraintloop-0.1.0/SUPPORT.md +10 -0
- constraintloop-0.1.0/docs/configuration.md +55 -0
- constraintloop-0.1.0/docs/convergence-loops.md +219 -0
- constraintloop-0.1.0/docs/faq.md +189 -0
- constraintloop-0.1.0/docs/native-cli-evaluators.md +65 -0
- constraintloop-0.1.0/docs/openai-evaluation.md +49 -0
- constraintloop-0.1.0/docs/provider-privacy.md +42 -0
- constraintloop-0.1.0/docs/recipes.md +163 -0
- constraintloop-0.1.0/docs/release-readiness.md +271 -0
- constraintloop-0.1.0/docs/threat-model.md +60 -0
- constraintloop-0.1.0/pyproject.toml +109 -0
- constraintloop-0.1.0/scripts/check_anthropic_sdk.py +23 -0
- constraintloop-0.1.0/scripts/check_coverage.py +24 -0
- constraintloop-0.1.0/scripts/check_openai_sdk.py +30 -0
- constraintloop-0.1.0/scripts/check_sdist_contents.py +44 -0
- constraintloop-0.1.0/scripts/openai_eval_canary.py +83 -0
- constraintloop-0.1.0/scripts/wheel_failure_smoke.py +47 -0
- constraintloop-0.1.0/src/constraintloop/__init__.py +7 -0
- constraintloop-0.1.0/src/constraintloop/__main__.py +4 -0
- constraintloop-0.1.0/src/constraintloop/cli.py +485 -0
- constraintloop-0.1.0/src/constraintloop/config.py +53 -0
- constraintloop-0.1.0/src/constraintloop/digest.py +233 -0
- constraintloop-0.1.0/src/constraintloop/engine.py +466 -0
- constraintloop-0.1.0/src/constraintloop/environment.py +50 -0
- constraintloop-0.1.0/src/constraintloop/eval_corpus.py +46 -0
- constraintloop-0.1.0/src/constraintloop/evaluators.py +334 -0
- constraintloop-0.1.0/src/constraintloop/hooks.py +335 -0
- constraintloop-0.1.0/src/constraintloop/loops.py +334 -0
- constraintloop-0.1.0/src/constraintloop/models.py +397 -0
- constraintloop-0.1.0/src/constraintloop/native_cli_evaluator.py +464 -0
- constraintloop-0.1.0/src/constraintloop/py.typed +1 -0
- constraintloop-0.1.0/src/constraintloop/runners.py +290 -0
- constraintloop-0.1.0/src/constraintloop/scaffold.py +181 -0
- constraintloop-0.1.0/src/constraintloop/setup_hooks.py +191 -0
- constraintloop-0.1.0/src/constraintloop/state.py +225 -0
- constraintloop-0.1.0/tests/__init__.py +1 -0
- constraintloop-0.1.0/tests/failure_lab.py +27 -0
- constraintloop-0.1.0/tests/fixtures/openai_eval_corpus_v1.yml +67 -0
- constraintloop-0.1.0/tests/test_cli.py +65 -0
- constraintloop-0.1.0/tests/test_cli_commands.py +262 -0
- constraintloop-0.1.0/tests/test_digest.py +134 -0
- constraintloop-0.1.0/tests/test_engine.py +437 -0
- constraintloop-0.1.0/tests/test_environment.py +72 -0
- constraintloop-0.1.0/tests/test_eval_corpus.py +85 -0
- constraintloop-0.1.0/tests/test_evaluators.py +420 -0
- constraintloop-0.1.0/tests/test_failure_lab.py +185 -0
- constraintloop-0.1.0/tests/test_hooks.py +361 -0
- constraintloop-0.1.0/tests/test_loops.py +228 -0
- constraintloop-0.1.0/tests/test_models.py +238 -0
- constraintloop-0.1.0/tests/test_native_cli_evaluator.py +329 -0
- constraintloop-0.1.0/tests/test_release_metadata.py +97 -0
- constraintloop-0.1.0/tests/test_runners.py +128 -0
- constraintloop-0.1.0/tests/test_security.py +30 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes are documented here. The project follows Semantic
|
|
4
|
+
Versioning, with the usual initial-development flexibility for `0.y.z`.
|
|
5
|
+
|
|
6
|
+
## [Unreleased]
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2026-07-29
|
|
9
|
+
|
|
10
|
+
- Added the initial evidence engine, strict contract schema, provider adapters,
|
|
11
|
+
native agent hooks, contributor quality configuration, and CI baseline.
|
|
12
|
+
- Added deterministic OpenAI request-contract tests, refusal and incomplete
|
|
13
|
+
response handling, safe call metadata, SDK compatibility checks, and a
|
|
14
|
+
versioned opt-in semantic evaluation corpus.
|
|
15
|
+
- Added isolated native Codex and Claude Code command evaluators with
|
|
16
|
+
hook-aware same-agent preference and strict structured output.
|
|
17
|
+
- Added bounded convergence loops with pending evidence, strict budgets, atomic
|
|
18
|
+
journals, recoverable supervisor leases, stable cycle exit codes, native
|
|
19
|
+
prompts, and shared Stop-hook attempt accounting.
|
|
20
|
+
- Declared the v0.1 compatibility boundary around CLI and versioned protocols;
|
|
21
|
+
Python submodules remain internal during initial development.
|
|
22
|
+
- Added snapshot-bound advisory acknowledgments so Stop feedback must be
|
|
23
|
+
addressed or explicitly explained before completion can continue.
|
|
24
|
+
- Added canonical package metadata, a build-once PyPI Trusted Publishing
|
|
25
|
+
workflow, release invariants, CODEOWNERS, and dependency automation.
|
|
26
|
+
- Hardened project-bound and reversible hook setup, malformed hook/settings
|
|
27
|
+
handling, exact-result deterministic waivers, complete-bundle rubric caching,
|
|
28
|
+
rename disclosure, and evaluator-scoped secret loading and redaction.
|
|
29
|
+
- Added Contributor Covenant 2.1 with private conduct reporting instructions.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
By participating, you agree to follow the
|
|
4
|
+
[Code of Conduct](CODE_OF_CONDUCT.md). Report conduct concerns privately using
|
|
5
|
+
the contact method documented there.
|
|
6
|
+
|
|
7
|
+
ConstraintLoop accepts focused changes that strengthen evidence, state,
|
|
8
|
+
budgeting, locks, and stopping. It is not a general agent runtime and v0.1 must
|
|
9
|
+
not launch provider CLIs for repair turns or offer unbounded repair loops.
|
|
10
|
+
Opt-in native CLI evaluators are limited to isolated, tool-disabled reviews.
|
|
11
|
+
|
|
12
|
+
Use Python 3.11 or newer and install the development environment:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
uv sync --extra dev --extra openai
|
|
16
|
+
uv run ruff format --check .
|
|
17
|
+
uv run ruff check .
|
|
18
|
+
uv run mypy
|
|
19
|
+
uv run pytest --cov=constraintloop --cov-branch
|
|
20
|
+
uv build
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Tests must be deterministic and must not require provider credentials. Mock
|
|
24
|
+
provider success, refusal, malformed output, timeout, and retry exhaustion.
|
|
25
|
+
Live-provider checks are opt-in and never required for pull requests.
|
|
26
|
+
|
|
27
|
+
Hook installation must be reversible and preserve user configuration.
|
|
28
|
+
`constraintloop uninstall` removes only ConstraintLoop-owned entries; changes
|
|
29
|
+
to setup or uninstall behavior require merge, idempotency, and preservation
|
|
30
|
+
tests.
|
|
31
|
+
|
|
32
|
+
Failure behavior is tested with isolated temporary projects and fake evaluator
|
|
33
|
+
commands. Add scenarios through `tests/failure_lab.py`; do not add a public
|
|
34
|
+
failure-simulation flag or require a live provider merely to exercise an error
|
|
35
|
+
path.
|
|
36
|
+
|
|
37
|
+
Pull requests should explain the behavior and failure cases, add tests, update
|
|
38
|
+
user-facing documentation, and avoid unrelated formatting. Changes to the
|
|
39
|
+
contract schema, hooks, package metadata, or release workflows need especially
|
|
40
|
+
careful review. Do not commit local evidence, waivers, or secrets.
|
|
41
|
+
|
|
42
|
+
Releases are prepared through a focused release pull request and published only
|
|
43
|
+
through GitHub Trusted Publishing. See `RELEASE.md`. Contributors and agents
|
|
44
|
+
must not run local package upload commands or add long-lived registry tokens.
|
|
45
|
+
|
|
46
|
+
The supported v0.1 platforms are macOS and Linux. Windows is not supported
|
|
47
|
+
until hook command generation and clean-wheel tests are implemented there.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Governance
|
|
2
|
+
|
|
3
|
+
ConstraintLoop is currently maintainer-led. The maintainer decides scope,
|
|
4
|
+
merges, releases, compatibility policy, and security response after considering
|
|
5
|
+
documented technical evidence and community feedback.
|
|
6
|
+
|
|
7
|
+
Contract schema, public CLI behavior, hook protocols, release policy, and
|
|
8
|
+
security-boundary changes require an explicit rationale and migration impact.
|
|
9
|
+
Releases follow Semantic Versioning. During `0.y.z`, incompatible changes may
|
|
10
|
+
occur, but they must be recorded in the changelog with migration guidance.
|
|
11
|
+
|
|
12
|
+
Additional maintainers may be appointed after sustained, trusted
|
|
13
|
+
contributions. Governance changes are reviewed like code and recorded here.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mauhpr
|
|
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,371 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: constraintloop
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Evidence-based completion gates for AI coding agents
|
|
5
|
+
Project-URL: Homepage, https://github.com/mauhpr/constraintloop
|
|
6
|
+
Project-URL: Documentation, https://github.com/mauhpr/constraintloop/tree/main/docs
|
|
7
|
+
Project-URL: Repository, https://github.com/mauhpr/constraintloop
|
|
8
|
+
Project-URL: Issues, https://github.com/mauhpr/constraintloop/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/mauhpr/constraintloop/blob/main/CHANGELOG.md
|
|
10
|
+
Project-URL: Security, https://github.com/mauhpr/constraintloop/security/policy
|
|
11
|
+
Author: mauhpr
|
|
12
|
+
License-Expression: MIT
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Keywords: ai-agents,coding-agents,hooks,quality-gates,testing
|
|
15
|
+
Classifier: Development Status :: 3 - Alpha
|
|
16
|
+
Classifier: Environment :: Console
|
|
17
|
+
Classifier: Intended Audience :: Developers
|
|
18
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
19
|
+
Classifier: Operating System :: MacOS
|
|
20
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
25
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
26
|
+
Classifier: Typing :: Typed
|
|
27
|
+
Requires-Python: >=3.11
|
|
28
|
+
Requires-Dist: click>=8.1
|
|
29
|
+
Requires-Dist: pydantic>=2.7
|
|
30
|
+
Requires-Dist: pyyaml>=6.0
|
|
31
|
+
Provides-Extra: anthropic
|
|
32
|
+
Requires-Dist: anthropic<1,>=0.40; extra == 'anthropic'
|
|
33
|
+
Provides-Extra: dev
|
|
34
|
+
Requires-Dist: build>=1.2; extra == 'dev'
|
|
35
|
+
Requires-Dist: mypy>=1.11; extra == 'dev'
|
|
36
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
37
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
38
|
+
Requires-Dist: ruff>=0.9; extra == 'dev'
|
|
39
|
+
Requires-Dist: types-pyyaml>=6.0; extra == 'dev'
|
|
40
|
+
Provides-Extra: openai
|
|
41
|
+
Requires-Dist: openai<3,>=2.0; extra == 'openai'
|
|
42
|
+
Description-Content-Type: text/markdown
|
|
43
|
+
|
|
44
|
+
# ConstraintLoop
|
|
45
|
+
|
|
46
|
+
[](https://github.com/mauhpr/constraintloop/actions/workflows/ci.yml)
|
|
47
|
+
[](https://codecov.io/gh/mauhpr/constraintloop)
|
|
48
|
+
[](https://opensource.org/licenses/MIT)
|
|
49
|
+
|
|
50
|
+
ConstraintLoop is an evidence-based completion gate for AI coding agents. Instead
|
|
51
|
+
of relying on a human to inspect every generated line, it requires the agent's
|
|
52
|
+
work to pass an explicit, versioned contract of tests, static checks, metrics,
|
|
53
|
+
artifacts, and independent model rubrics.
|
|
54
|
+
|
|
55
|
+
The central distinction is deliberate:
|
|
56
|
+
|
|
57
|
+
- **Deterministic constraints** produce reproducible evidence: exit codes,
|
|
58
|
+
parsed metrics, and validated artifacts. Required deterministic failures
|
|
59
|
+
block autonomous completion. A human may explicitly waive an exact local
|
|
60
|
+
evidence snapshot with a non-empty reason; CI ignores every waiver and
|
|
61
|
+
remains blocking.
|
|
62
|
+
- **Non-deterministic constraints** apply a written rubric through OpenAI,
|
|
63
|
+
Anthropic, or any command that speaks ConstraintLoop's JSON protocol. They are
|
|
64
|
+
advisory by default. A required rubric must run at least twice and declare a
|
|
65
|
+
majority quorum.
|
|
66
|
+
|
|
67
|
+
ConstraintLoop supports Claude Code, Codex, and Gemini CLI through their hook
|
|
68
|
+
lifecycles. CI is the final authority: it ignores local caches and human waivers.
|
|
69
|
+
|
|
70
|
+
Bounded convergence loops are included in the v0.1 release scope. The design
|
|
71
|
+
keeps ConstraintLoop in control of evidence, budgets, and stopping while native
|
|
72
|
+
Claude or Codex loops perform at most one requested repair per transition. See
|
|
73
|
+
[docs/convergence-loops.md](docs/convergence-loops.md).
|
|
74
|
+
|
|
75
|
+
## At a glance
|
|
76
|
+
|
|
77
|
+
| Question | ConstraintLoop answer |
|
|
78
|
+
| --- | --- |
|
|
79
|
+
| What decides that work is complete? | Fresh evidence from a committed contract |
|
|
80
|
+
| What can block locally? | Required deterministic failures and undisposed advisory findings |
|
|
81
|
+
| What can block CI? | Every required CI constraint; local caches and waivers are ignored |
|
|
82
|
+
| Does it replace pytest, Ruff, or CI? | No. It turns their outputs into one completion decision |
|
|
83
|
+
| Does it run an autonomous agent? | No. It owns evidence and stopping; native agents own repairs |
|
|
84
|
+
| Can it review design? | Yes, through optional OpenAI, Anthropic, Codex, Claude Code, or command evaluators |
|
|
85
|
+
| Can it loop forever? | No. Every convergence loop has repair, unchanged-result, and time budgets |
|
|
86
|
+
|
|
87
|
+
```mermaid
|
|
88
|
+
flowchart LR
|
|
89
|
+
G[User goal] --> A[Coding agent]
|
|
90
|
+
A --> C[Versioned contract]
|
|
91
|
+
C --> D[Commands and metrics]
|
|
92
|
+
C --> R[Optional rubric review]
|
|
93
|
+
D --> E[Fresh evidence snapshot]
|
|
94
|
+
R --> E
|
|
95
|
+
E -->|pass| S[Completion allowed]
|
|
96
|
+
E -->|fail| F[One focused repair]
|
|
97
|
+
E -->|pending| W[Wait without repair]
|
|
98
|
+
F --> A
|
|
99
|
+
W --> E
|
|
100
|
+
E -->|budget reached| H[Human decision]
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Choose your path
|
|
104
|
+
|
|
105
|
+
| I want to… | Start here |
|
|
106
|
+
| --- | --- |
|
|
107
|
+
| Add tests, coverage, and lint gates | [Quick start](#quick-start) and [task-oriented recipes](docs/recipes.md) |
|
|
108
|
+
| Understand when each gate runs | [Lifecycle](#lifecycle) |
|
|
109
|
+
| Configure every schema field | [Configuration reference](docs/configuration.md) |
|
|
110
|
+
| Use Codex or Claude Code for design review | [Native CLI evaluators](docs/native-cli-evaluators.md) |
|
|
111
|
+
| Use OpenAI or Anthropic directly | [Provider privacy](docs/provider-privacy.md) |
|
|
112
|
+
| Add a bounded repair or monitoring loop | [Convergence loops](docs/convergence-loops.md) |
|
|
113
|
+
| Diagnose a failure or stale cache | [FAQ and troubleshooting](docs/faq.md) |
|
|
114
|
+
| Evaluate the security boundary | [Threat model](docs/threat-model.md) |
|
|
115
|
+
|
|
116
|
+
## Quick start
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
python -m venv .venv
|
|
120
|
+
. .venv/bin/activate
|
|
121
|
+
pip install constraintloop
|
|
122
|
+
|
|
123
|
+
constraintloop init
|
|
124
|
+
constraintloop setup --adapter all
|
|
125
|
+
constraintloop run
|
|
126
|
+
constraintloop ci
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
`constraintloop init` detects existing Python and Node tooling and writes a
|
|
130
|
+
plain `constraintloop.yml`. It does not install tools or silently invent gates.
|
|
131
|
+
Review and commit the contract.
|
|
132
|
+
|
|
133
|
+
The five commands above establish this flow:
|
|
134
|
+
|
|
135
|
+
```mermaid
|
|
136
|
+
sequenceDiagram
|
|
137
|
+
participant U as User
|
|
138
|
+
participant A as Agent
|
|
139
|
+
participant CL as ConstraintLoop
|
|
140
|
+
participant T as Project tools
|
|
141
|
+
U->>CL: init + review contract
|
|
142
|
+
U->>CL: setup hooks
|
|
143
|
+
A->>CL: run change/stop phase
|
|
144
|
+
CL->>T: execute ready constraints
|
|
145
|
+
T-->>CL: exit codes, metrics, artifacts
|
|
146
|
+
CL-->>A: pass, repair, wait, or escalate
|
|
147
|
+
CL->>T: ci reruns without cache/waivers
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Contract
|
|
151
|
+
|
|
152
|
+
```yaml
|
|
153
|
+
version: 1
|
|
154
|
+
settings:
|
|
155
|
+
max_auto_retries: 2
|
|
156
|
+
|
|
157
|
+
constraints:
|
|
158
|
+
tests:
|
|
159
|
+
kind: command
|
|
160
|
+
command: [python, -m, pytest, -q]
|
|
161
|
+
phases: [stop, ci]
|
|
162
|
+
watch: ["src/**/*.py", "tests/**/*.py", pyproject.toml]
|
|
163
|
+
|
|
164
|
+
coverage:
|
|
165
|
+
kind: metric
|
|
166
|
+
command: [python, -m, pytest, --cov, "--cov-report=json:coverage.json"]
|
|
167
|
+
parser:
|
|
168
|
+
type: json
|
|
169
|
+
source: file
|
|
170
|
+
file: coverage.json
|
|
171
|
+
path: totals.percent_covered
|
|
172
|
+
threshold: {operator: gte, value: 85}
|
|
173
|
+
needs: [tests]
|
|
174
|
+
phases: [stop, ci]
|
|
175
|
+
|
|
176
|
+
design_review:
|
|
177
|
+
kind: rubric
|
|
178
|
+
enforcement: advisory
|
|
179
|
+
evaluator: independent_review
|
|
180
|
+
rubric: >
|
|
181
|
+
Fail when the patch introduces an unjustified public API, crosses an
|
|
182
|
+
existing architectural boundary, or omits handling for a named failure
|
|
183
|
+
case. Cite concrete files in every finding.
|
|
184
|
+
include: ["src/**/*.py"]
|
|
185
|
+
phases: [stop, ci]
|
|
186
|
+
|
|
187
|
+
evaluators:
|
|
188
|
+
independent_review:
|
|
189
|
+
type: openai
|
|
190
|
+
model: YOUR_PINNED_MODEL
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
See [examples/constraintloop.full.yml](examples/constraintloop.full.yml) for all
|
|
194
|
+
constraint types.
|
|
195
|
+
|
|
196
|
+
The pre-release engineering and open-source checklist is tracked in
|
|
197
|
+
[docs/release-readiness.md](docs/release-readiness.md).
|
|
198
|
+
Participation is governed by the [Code of Conduct](CODE_OF_CONDUCT.md).
|
|
199
|
+
Maintainer release setup and Trusted Publishing invariants are documented in
|
|
200
|
+
[RELEASE.md](RELEASE.md).
|
|
201
|
+
The strict schema is documented in
|
|
202
|
+
[docs/configuration.md](docs/configuration.md), and remote evaluator disclosure
|
|
203
|
+
and cost controls are documented in
|
|
204
|
+
[docs/provider-privacy.md](docs/provider-privacy.md).
|
|
205
|
+
OpenAI request-shape, failure, SDK-compatibility, and semantic-corpus checks are
|
|
206
|
+
documented in [docs/openai-evaluation.md](docs/openai-evaluation.md).
|
|
207
|
+
Optional local Codex and Claude Code command evaluators are documented in
|
|
208
|
+
[docs/native-cli-evaluators.md](docs/native-cli-evaluators.md).
|
|
209
|
+
|
|
210
|
+
### OpenAI evaluator setup
|
|
211
|
+
|
|
212
|
+
Install the optional provider SDK:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
uv sync --extra dev --extra openai
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
For local development, paste the key into the gitignored
|
|
219
|
+
`.constraintloop/secrets.env` file:
|
|
220
|
+
|
|
221
|
+
```dotenv
|
|
222
|
+
OPENAI_API_KEY=your-key-here
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Process environment variables take precedence over the local file. In CI, use
|
|
226
|
+
the CI platform's secret store and expose `OPENAI_API_KEY`; do not create or
|
|
227
|
+
commit a credential file. ConstraintLoop parses the local file as plain
|
|
228
|
+
`KEY=VALUE` data and never evaluates it as shell code. Agent hook writes to this
|
|
229
|
+
file are denied.
|
|
230
|
+
|
|
231
|
+
This repository dogfoods an advisory native-agent design rubric. OpenAI and
|
|
232
|
+
Anthropic remain optional provider integrations. Keep probabilistic gates
|
|
233
|
+
advisory until their false-positive and false-negative rates are measured.
|
|
234
|
+
|
|
235
|
+
## Lifecycle
|
|
236
|
+
|
|
237
|
+
| Phase | Typical trigger | Intended work |
|
|
238
|
+
| --- | --- | --- |
|
|
239
|
+
| `change` | After a file-changing tool action | Fast syntax, formatting, or diff checks |
|
|
240
|
+
| `stop` | When the agent attempts to finish | Tests, build checks, and advisory review |
|
|
241
|
+
| `ci` | Protected hosted workflow | Authoritative uncached and waiver-free verification |
|
|
242
|
+
|
|
243
|
+
1. `SessionStart` tells the coding agent which required gates exist.
|
|
244
|
+
2. The prompt hook records the user's goal as review evidence.
|
|
245
|
+
3. Before tool execution, agent attempts to edit the contract or create a
|
|
246
|
+
waiver are denied.
|
|
247
|
+
4. After tool execution, `change` gates run and fresh results are injected.
|
|
248
|
+
5. Before compaction, the completion policy is restated.
|
|
249
|
+
6. At `Stop` / `AfterAgent`, required `stop` gates block completion. The agent
|
|
250
|
+
receives precise evidence and may repair the code a bounded number of times.
|
|
251
|
+
7. Advisory failures require either passing fresh evidence or an explicit
|
|
252
|
+
snapshot-bound explanation; delivery alone never counts as review.
|
|
253
|
+
8. Repeated required failure stops autonomous repair and requests a human
|
|
254
|
+
decision. A trusted human can record a reasoned, snapshot-bound local waiver;
|
|
255
|
+
hooks deny observed agent waiver commands, any relevant change invalidates
|
|
256
|
+
it, and CI ignores it. The local CLI cannot authenticate whether its caller
|
|
257
|
+
is human.
|
|
258
|
+
9. `constraintloop ci` reruns every CI gate without local evidence or waivers.
|
|
259
|
+
|
|
260
|
+
Evidence is keyed by the constraint definition and the bytes of every file
|
|
261
|
+
matched by `watch`. A source change therefore makes old evidence and waivers
|
|
262
|
+
stale without a mutable invalidation list. Local state lives under the
|
|
263
|
+
gitignored `.constraintloop/state` directory; set `CONSTRAINTLOOP_CACHE_DIR` to
|
|
264
|
+
override it.
|
|
265
|
+
|
|
266
|
+
### Verdicts and what they mean
|
|
267
|
+
|
|
268
|
+
| Verdict | Meaning | Can complete? |
|
|
269
|
+
| --- | --- | --- |
|
|
270
|
+
| `pass` | Fresh evidence satisfies the constraint | Yes |
|
|
271
|
+
| `fail` | The tool or rubric found a concrete violation | No when required |
|
|
272
|
+
| `pending` | External or delayed evidence is not ready | No |
|
|
273
|
+
| `uncertain` | An evaluator could not produce a reliable verdict | No when required |
|
|
274
|
+
| `error` | ConstraintLoop could not evaluate safely | No |
|
|
275
|
+
| `waived` | A human accepted one exact local deterministic snapshot | Locally only; never in CI |
|
|
276
|
+
| `skipped` | A dependency prevented execution | Only when no required result is missing |
|
|
277
|
+
|
|
278
|
+
## Commands
|
|
279
|
+
|
|
280
|
+
- `constraintloop init` — generate a reviewable initial contract.
|
|
281
|
+
- `constraintloop setup --adapter claude|codex|gemini|all` — merge hook entries
|
|
282
|
+
while preserving existing hooks.
|
|
283
|
+
- `constraintloop uninstall --adapter claude|codex|gemini|all` — remove only
|
|
284
|
+
ConstraintLoop hook entries while preserving unrelated settings.
|
|
285
|
+
- `constraintloop run --phase change|stop` — run local gates with fresh caching.
|
|
286
|
+
- `constraintloop ci` — authoritative, uncached, waiver-free run.
|
|
287
|
+
- `constraintloop cycle NAME --json` — execute one journaled loop transition.
|
|
288
|
+
- `constraintloop supervise NAME` — poll pending evidence under a recoverable
|
|
289
|
+
single-writer lease and exit whenever repair or termination is required.
|
|
290
|
+
- `constraintloop loop-prompt NAME --adapter claude|codex` — print the bounded
|
|
291
|
+
native-agent repair protocol without launching an agent.
|
|
292
|
+
- `constraintloop status` — inspect evidence without executing commands.
|
|
293
|
+
- `constraintloop debug ID` — explain evidence freshness, evaluator
|
|
294
|
+
configuration, executable resolution, and native CLI availability without
|
|
295
|
+
running an evaluator or consuming model quota.
|
|
296
|
+
- `constraintloop acknowledge ID --reason "..."` — record an explicit
|
|
297
|
+
snapshot-bound advisory disposition without changing its verdict.
|
|
298
|
+
- `constraintloop doctor` — validate and fingerprint the contract.
|
|
299
|
+
- `constraintloop waive ID --reason "..."` — human-local, snapshot-bound waiver
|
|
300
|
+
for fresh non-passing deterministic evidence. Rubrics cannot be waived.
|
|
301
|
+
- `constraintloop enhance` — write a review-only proposal for stronger tooling.
|
|
302
|
+
- `constraintloop author` — write a review-only QA/test-authoring proposal.
|
|
303
|
+
|
|
304
|
+
`enhance` and `author` intentionally do not install dependencies or modify the
|
|
305
|
+
active contract in v0.1. Their proposal files make the future self-improvement
|
|
306
|
+
path auditable.
|
|
307
|
+
|
|
308
|
+
## Documentation
|
|
309
|
+
|
|
310
|
+
| Guide | Contents |
|
|
311
|
+
| --- | --- |
|
|
312
|
+
| [Recipes](docs/recipes.md) | Copyable Python, native-review, CI, and bounded-loop setups |
|
|
313
|
+
| [FAQ](docs/faq.md) | Caching, failure modes, providers, hooks, security, and troubleshooting |
|
|
314
|
+
| [Configuration](docs/configuration.md) | Strict schema, defaults, constraints, evaluators, and loops |
|
|
315
|
+
| [Convergence loops](docs/convergence-loops.md) | State machine, budgets, leases, and native-agent protocol |
|
|
316
|
+
| [Native evaluators](docs/native-cli-evaluators.md) | Codex and Claude Code read-only rubric execution |
|
|
317
|
+
| [Provider privacy](docs/provider-privacy.md) | Data flow, disclosure, credentials, cost, and failure behavior |
|
|
318
|
+
| [Threat model](docs/threat-model.md) | Trusted inputs, controls, residual risks, and non-goals |
|
|
319
|
+
| [Release readiness](docs/release-readiness.md) | Compatibility, quality, security, and publishing gates |
|
|
320
|
+
|
|
321
|
+
## Evaluator command protocol
|
|
322
|
+
|
|
323
|
+
A command evaluator receives an `EvaluationBundle` JSON object on stdin and must
|
|
324
|
+
write exactly one object to stdout:
|
|
325
|
+
|
|
326
|
+
```json
|
|
327
|
+
{
|
|
328
|
+
"verdict": "pass",
|
|
329
|
+
"score": 0.91,
|
|
330
|
+
"rationale": "The patch satisfies the rubric.",
|
|
331
|
+
"findings": []
|
|
332
|
+
}
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
Valid verdicts are `pass`, `fail`, and `uncertain`. Provider errors and malformed
|
|
336
|
+
responses become `uncertain`; a required rubric therefore fails closed.
|
|
337
|
+
|
|
338
|
+
## Compatibility boundary
|
|
339
|
+
|
|
340
|
+
The supported v0.1 surfaces are the CLI and exit codes, configuration schema,
|
|
341
|
+
evaluator command protocol, native hook responses, and schema-versioned
|
|
342
|
+
evidence and cycle JSON. Python submodules are internal during initial
|
|
343
|
+
development and are not covered by semantic-versioning compatibility promises.
|
|
344
|
+
Migration notes will accompany changes to supported schemas and protocols.
|
|
345
|
+
|
|
346
|
+
## Security model
|
|
347
|
+
|
|
348
|
+
Hooks are policy automation, not a security sandbox. A sufficiently privileged
|
|
349
|
+
agent process can bypass local hooks or alter local files. The trusted boundary
|
|
350
|
+
is a protected, reviewed contract plus an independent CI run. See
|
|
351
|
+
[docs/threat-model.md](docs/threat-model.md).
|
|
352
|
+
|
|
353
|
+
## Frequently asked questions
|
|
354
|
+
|
|
355
|
+
**Why not just tell the agent to run tests?** Because a prompt is not durable
|
|
356
|
+
policy. ConstraintLoop records which contract ran, which inputs it covered, and
|
|
357
|
+
whether the evidence is still fresh.
|
|
358
|
+
|
|
359
|
+
**Why do some constraints run after every action?** Put only fast feedback in
|
|
360
|
+
the `change` phase. Expensive tests and reviews belong in `stop` and `ci`.
|
|
361
|
+
|
|
362
|
+
**Can I use Codex or Claude Code instead of an API evaluator?** Yes. The native
|
|
363
|
+
evaluator adapter prefers the active supported CLI and remains read-only.
|
|
364
|
+
|
|
365
|
+
**How do I test failure behavior?** Use deterministic commands or fixtures that
|
|
366
|
+
return known failure, pending, malformed, timeout, or corruption outcomes. Do
|
|
367
|
+
not spend provider quota merely to manufacture an error.
|
|
368
|
+
|
|
369
|
+
See the complete [FAQ and troubleshooting guide](docs/faq.md).
|
|
370
|
+
|
|
371
|
+
License: MIT.
|