agent-reliability-harness 0.2.1__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 (56) hide show
  1. agent_reliability_harness-0.2.1/CHANGELOG.md +122 -0
  2. agent_reliability_harness-0.2.1/LICENSE +21 -0
  3. agent_reliability_harness-0.2.1/MANIFEST.in +5 -0
  4. agent_reliability_harness-0.2.1/PKG-INFO +229 -0
  5. agent_reliability_harness-0.2.1/README.md +201 -0
  6. agent_reliability_harness-0.2.1/pyproject.toml +70 -0
  7. agent_reliability_harness-0.2.1/samples/policy.json +72 -0
  8. agent_reliability_harness-0.2.1/samples/policy_trajectory.json +48 -0
  9. agent_reliability_harness-0.2.1/samples/traces/lead_qualification_pass.json +61 -0
  10. agent_reliability_harness-0.2.1/samples/traces/refund_workflow_double_refund.json +42 -0
  11. agent_reliability_harness-0.2.1/samples/traces/refund_workflow_pass.json +51 -0
  12. agent_reliability_harness-0.2.1/samples/traces/renewal_workflow_budget_violation.json +58 -0
  13. agent_reliability_harness-0.2.1/samples/traces/support_escalation_unsafe.json +51 -0
  14. agent_reliability_harness-0.2.1/schemas/compare.schema.json +78 -0
  15. agent_reliability_harness-0.2.1/schemas/policy.schema.json +118 -0
  16. agent_reliability_harness-0.2.1/schemas/report.schema.json +61 -0
  17. agent_reliability_harness-0.2.1/schemas/trace.schema.json +65 -0
  18. agent_reliability_harness-0.2.1/setup.cfg +4 -0
  19. agent_reliability_harness-0.2.1/src/agent_reliability_harness/__init__.py +58 -0
  20. agent_reliability_harness-0.2.1/src/agent_reliability_harness/__main__.py +4 -0
  21. agent_reliability_harness-0.2.1/src/agent_reliability_harness/adapters/__init__.py +103 -0
  22. agent_reliability_harness-0.2.1/src/agent_reliability_harness/adapters/anthropic_messages.py +158 -0
  23. agent_reliability_harness-0.2.1/src/agent_reliability_harness/adapters/openai_chat.py +155 -0
  24. agent_reliability_harness-0.2.1/src/agent_reliability_harness/cli.py +388 -0
  25. agent_reliability_harness-0.2.1/src/agent_reliability_harness/models.py +649 -0
  26. agent_reliability_harness-0.2.1/src/agent_reliability_harness/py.typed +0 -0
  27. agent_reliability_harness-0.2.1/src/agent_reliability_harness/regression.py +551 -0
  28. agent_reliability_harness-0.2.1/src/agent_reliability_harness/report.py +301 -0
  29. agent_reliability_harness-0.2.1/src/agent_reliability_harness/rules.py +121 -0
  30. agent_reliability_harness-0.2.1/src/agent_reliability_harness/validator.py +1121 -0
  31. agent_reliability_harness-0.2.1/src/agent_reliability_harness.egg-info/PKG-INFO +229 -0
  32. agent_reliability_harness-0.2.1/src/agent_reliability_harness.egg-info/SOURCES.txt +54 -0
  33. agent_reliability_harness-0.2.1/src/agent_reliability_harness.egg-info/dependency_links.txt +1 -0
  34. agent_reliability_harness-0.2.1/src/agent_reliability_harness.egg-info/entry_points.txt +2 -0
  35. agent_reliability_harness-0.2.1/src/agent_reliability_harness.egg-info/requires.txt +6 -0
  36. agent_reliability_harness-0.2.1/src/agent_reliability_harness.egg-info/top_level.txt +1 -0
  37. agent_reliability_harness-0.2.1/tests/__init__.py +0 -0
  38. agent_reliability_harness-0.2.1/tests/fixtures/anthropic_messages_refund.json +39 -0
  39. agent_reliability_harness-0.2.1/tests/fixtures/anthropic_messages_tool_error.json +26 -0
  40. agent_reliability_harness-0.2.1/tests/fixtures/openai_chat_edge_cases.json +15 -0
  41. agent_reliability_harness-0.2.1/tests/fixtures/openai_chat_refund.json +34 -0
  42. agent_reliability_harness-0.2.1/tests/test_adapters.py +221 -0
  43. agent_reliability_harness-0.2.1/tests/test_adversarial.py +251 -0
  44. agent_reliability_harness-0.2.1/tests/test_argspec.py +206 -0
  45. agent_reliability_harness-0.2.1/tests/test_cli.py +81 -0
  46. agent_reliability_harness-0.2.1/tests/test_cli_compare.py +270 -0
  47. agent_reliability_harness-0.2.1/tests/test_compat_golden.py +75 -0
  48. agent_reliability_harness-0.2.1/tests/test_docs_examples.py +72 -0
  49. agent_reliability_harness-0.2.1/tests/test_models.py +85 -0
  50. agent_reliability_harness-0.2.1/tests/test_regression.py +193 -0
  51. agent_reliability_harness-0.2.1/tests/test_report.py +70 -0
  52. agent_reliability_harness-0.2.1/tests/test_report_formats.py +132 -0
  53. agent_reliability_harness-0.2.1/tests/test_review_fixes.py +366 -0
  54. agent_reliability_harness-0.2.1/tests/test_schemas.py +105 -0
  55. agent_reliability_harness-0.2.1/tests/test_trajectory_rules.py +332 -0
  56. agent_reliability_harness-0.2.1/tests/test_validator.py +351 -0
@@ -0,0 +1,122 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project
5
+ adheres to [Semantic Versioning](https://semver.org/).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.2.1] - 2026-07-14
10
+
11
+ ### Fixed
12
+
13
+ - Modernized packaging license metadata to the PEP 639/SPDX form
14
+ (`license = "MIT"`, `license-files = ["LICENSE"]`) and removed the
15
+ deprecated license classifier; builds no longer emit setuptools license
16
+ deprecation warnings.
17
+ - Converted README documentation links to absolute GitHub URLs so they work
18
+ from the PyPI long-description renderer.
19
+ - Corrected stale compatibility language that incorrectly claimed every
20
+ v0.1 score remained identical despite the documented nested-safety-scan
21
+ fix (70.0 -> 70.83 for one sample; verdict unchanged).
22
+
23
+
24
+ ## [0.2.0] - 2026-07-14
25
+
26
+ ### Added
27
+
28
+ - **Trajectory rules** (`sequence`): required tools, forbidden tools,
29
+ partial-order `call_order`, per-tool `min_calls`/`max_calls`
30
+ (`ARH-SEQ-001..005`).
31
+ - **Flow rules** (`error_handling`, `side_effect`): ignored tool errors,
32
+ retry storms, duplicate side-effect protection (`ARH-FLW-001..003`).
33
+ - **Completion rules** (`completion`): required final response, max step
34
+ count (`ARH-CMP-001..002`).
35
+ - **Argument value constraints**: `enum`, full-match `pattern`, numeric
36
+ `min`/`max` on tool arguments (`ARH-SCH-007..009`), alongside the legacy
37
+ bare type-name form.
38
+ - **Token budgets** (`budgets.max_total_tokens`, `ARH-BUD-004`) with an
39
+ explicit warning when the trace carries no token data (`ARH-BUD-005`)
40
+ instead of a silent pass.
41
+ - **Citation validity** (`grounding.require_valid_citation_urls`,
42
+ `ARH-GRD-003`) and step-level `status`/`error`, `input_tokens`/
43
+ `output_tokens`, and `metadata` trace fields.
44
+ - **Stable rule IDs** (`ARH-*`) on every finding, plus `expected`/`observed`/
45
+ `remediation` evidence fields and a generated rule reference
46
+ (`docs/rules.md`).
47
+ - **Regression engine**: `arh compare` diffs a candidate run against a
48
+ baseline report (new/resolved findings, pass/fail transitions,
49
+ score/latency/cost deltas) with gate modes `regressions` (default),
50
+ `failures`, `never`, and `--max-score-drop`.
51
+ - **Adapters**: `--format openai-chat` (Chat Completions `tool_calls`
52
+ transcripts) and `--format anthropic-messages` (`tool_use`/`tool_result`
53
+ conversations), with deterministic auto-detection and lossless handling of
54
+ unmappable input via `metadata.adapter.notes`.
55
+ - **Reports**: JUnit XML (`--junit-out`) and SARIF 2.1.0 (`--sarif-out`)
56
+ renderers; rule IDs shown in console and Markdown output; JSON reports
57
+ carry `schema_version`.
58
+ - **Schema versioning**: traces/policies accept `schema_version` (major `1`);
59
+ unknown major versions are rejected with a precise error.
60
+ - **JSON Schemas** for trace, policy, and report formats (`schemas/`).
61
+ - **Benchmark suite**: 34 seeded failure cases with a generator, a runner
62
+ enforcing thresholds (precision/recall 1.0, byte-identical determinism,
63
+ <50 ms/trace, metamorphic invariances, adapter equivalence, regression
64
+ scenarios), plus `BENCHMARK-METHODOLOGY.md` and generated
65
+ `BENCHMARK-RESULTS.md`.
66
+ - **GitHub Action** (`action.yml`): validate + optional baseline compare,
67
+ step-summary reports, SARIF/JUnit outputs, fork-safe, no secrets.
68
+ - **CI**: 3-OS × Python 3.11-3.13 matrix, ruff, strict mypy, benchmark
69
+ thresholds, packaging build with clean-environment install check.
70
+ - Documentation set (`docs/`), specs (`SPEC.md`, `TRACE-SPEC.md`,
71
+ `POLICY-SPEC.md`, `ARCHITECTURE.md`, and more), and community files.
72
+
73
+ ### Fixed
74
+
75
+ - **(review)** Regression loose-matching could silently cancel two findings
76
+ with *different* rule IDs on the same step whenever any legacy finding was
77
+ present, hiding real regressions from the CI gate. Loose matching now
78
+ applies only when at least one side of a pair lacks a `rule_id`.
79
+ - **(review)** Safety scanning now recurses into nested lists/dicts and the
80
+ step `error` string; unsafe content one level deep no longer evades
81
+ detection.
82
+ - **(review)** Warning-only traces can no longer fail: unverifiable budget
83
+ warnings (ARH-BUD-005, new ARH-BUD-006 latency, new ARH-BUD-007 cost) are
84
+ score-neutral.
85
+ - **(review)** Malformed telemetry (negative/non-finite/mistyped latency,
86
+ cost, tokens; non-string text/tool_name/error) is rejected at parse time.
87
+ - **(review)** `ArgSpec` patterns are compiled at policy load (precise error
88
+ instead of a traceback), `min > max` and non-finite bounds are rejected,
89
+ NaN values can no longer bypass range constraints, and unknown declared
90
+ types no longer disable enum/pattern/range checks.
91
+ - **(review)** JUnit output strips XML-1.0-illegal control characters so
92
+ strict CI consumers can always parse it; Markdown reports escape
93
+ trace-derived fields in table cells.
94
+ - **(review)** The GitHub Action passes all inputs via `env:` bindings
95
+ instead of interpolating `${{ inputs.* }}` into the script, closing a
96
+ shell-injection vector.
97
+ - **(review)** CLI: `--fail-under` is bounds-checked (usage error, exit 2);
98
+ pathologically nested JSON fails with a clean message instead of a
99
+ `RecursionError` traceback; the module docstring documents real exit
100
+ codes.
101
+
102
+ - v0.1.x reported type errors for **required** arguments twice (the argument
103
+ was checked in two loops). Each argument is now checked exactly once; the
104
+ duplicate finding is gone. Scores and verdicts are unchanged.
105
+
106
+ ### Compatibility
107
+
108
+ - v0.1.x trace and policy files remain accepted; verdicts and finding
109
+ messages are preserved. The documented nested-safety-scan fix changes one
110
+ sample score from 70.0 to 70.83 (verdict unchanged). New report fields are
111
+ additive.
112
+ `arh compare` accepts v0.1.x baselines via a rule-id-agnostic fallback
113
+ match. Exit codes and console markers are unchanged. See COMPATIBILITY.md.
114
+
115
+ ## [0.1.0] - 2026-07-13
116
+
117
+ ### Added
118
+
119
+ - Initial release: policy-driven trace validation (tool-call contracts,
120
+ latency/cost budgets, unsafe-pattern detection, citation coverage),
121
+ weighted 0-100 scoring, console/JSON/Markdown reports, `arh validate` CLI,
122
+ 35 unit/CLI tests, GitHub Actions CI (Python 3.11/3.12).
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Felmon Fekadu
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,5 @@
1
+ include LICENSE README.md CHANGELOG.md
2
+ recursive-include schemas *.json
3
+ recursive-include samples *.json
4
+ recursive-include tests *.py
5
+ recursive-include tests/fixtures *.json
@@ -0,0 +1,229 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-reliability-harness
3
+ Version: 0.2.1
4
+ Summary: Local-first policy and trajectory-regression harness for tool-using AI agents: deterministic trace validation, policy-as-code trajectory rules, baseline-vs-candidate regression gates, and CI-ready JSON/Markdown/JUnit/SARIF reports.
5
+ Author: Felmon Fekadu
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/felmonon/agent-reliability-harness
8
+ Project-URL: Documentation, https://github.com/felmonon/agent-reliability-harness/tree/main/docs
9
+ Project-URL: Changelog, https://github.com/felmonon/agent-reliability-harness/blob/main/CHANGELOG.md
10
+ Project-URL: Issues, https://github.com/felmonon/agent-reliability-harness/issues
11
+ Keywords: agents,llm,evaluation,reliability,regression-testing,grounding,tool-use,trajectory,policy-as-code,ci
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Software Development :: Testing
18
+ Classifier: Topic :: Software Development :: Quality Assurance
19
+ Requires-Python: >=3.11
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Provides-Extra: dev
23
+ Requires-Dist: mypy>=1.8; extra == "dev"
24
+ Requires-Dist: ruff>=0.5; extra == "dev"
25
+ Requires-Dist: jsonschema>=4.21; extra == "dev"
26
+ Requires-Dist: build>=1.0; extra == "dev"
27
+ Dynamic: license-file
28
+
29
+ # Agent Reliability Harness
30
+
31
+ A provider-neutral, local-first reliability and regression-testing harness for
32
+ tool-using AI agents. It validates recorded agent execution traces against
33
+ declarative policies (tool-call contracts, trajectory rules, budgets, unsafe
34
+ patterns, grounding), produces deterministic findings with stable rule IDs,
35
+ and compares candidate runs against a saved baseline so CI fails only on real
36
+ regressions.
37
+
38
+ The core has **zero runtime dependencies**, makes **no network calls**, sends
39
+ **no telemetry**, and produces **byte-identical reports** for identical input.
40
+
41
+ ## Why this exists
42
+
43
+ An agent can reach the correct final answer while still behaving unreliably.
44
+ It may:
45
+
46
+ - select the wrong tool, or skip a required one;
47
+ - use correct tools in the wrong order;
48
+ - pass invalid or out-of-range arguments;
49
+ - repeat an irreversible action (double refund, duplicate email);
50
+ - ignore a tool failure and answer anyway;
51
+ - get stuck in a retry storm;
52
+ - stop before finishing, or fail to terminate;
53
+ - return facts without citations;
54
+ - leak secrets or propagate prompt-injection text;
55
+ - blow past latency, cost, or token budgets;
56
+ - regress silently after a model, prompt, or tool change.
57
+
58
+ Final-answer evals miss all of this. This harness evaluates the **trajectory**,
59
+ and turns each of these concerns into a versioned policy rule with a stable ID.
60
+
61
+ ## 60-second example
62
+
63
+ ```bash
64
+ python -m pip install -e . # not yet on PyPI; install from a checkout
65
+
66
+ arh validate --policy samples/policy_trajectory.json \
67
+ samples/traces/refund_workflow_pass.json \
68
+ samples/traces/refund_workflow_double_refund.json
69
+ ```
70
+
71
+ The second trace ends with a perfectly plausible final answer — and still
72
+ fails, because the trajectory was unacceptable:
73
+
74
+ ```text
75
+ [FAIL] refund-workflow-1002 (agent=refund-copilot, workflow=refund)
76
+ score=84.5/100 policy=refund-workflow-v1 latency=1300ms cost=$0.0080
77
+ - [ERROR ] [flow ] ARH-FLW-003: duplicate side effect: tool 'issue_refund' was called again with identical arguments after already succeeding (step=s3)
78
+ - [ERROR ] [sequence ] ARH-SEQ-001: required tool 'check_refund_eligibility' was never called
79
+ - [ERROR ] [sequence ] ARH-SEQ-004: tool 'issue_refund' was called 2 times, above max_calls of 1
80
+ - [ERROR ] [sequence ] ARH-SEQ-003: call order violation: first call of 'lookup_order' must precede first call of 'issue_refund' (step=s1)
81
+ ```
82
+
83
+ Exit code `0` when everything passes, `1` on failure, `2` on usage errors —
84
+ usable as a CI gate as-is.
85
+
86
+ ## Regression gates
87
+
88
+ Save a baseline once, then gate future runs on *changes*, not absolutes:
89
+
90
+ ```bash
91
+ arh validate --policy samples/policy_trajectory.json \
92
+ samples/traces/refund_workflow_pass.json \
93
+ --json-out baseline.json --quiet
94
+
95
+ arh compare --baseline baseline.json \
96
+ --policy samples/policy_trajectory.json \
97
+ samples/traces/refund_workflow_pass.json \
98
+ samples/traces/refund_workflow_double_refund.json
99
+ ```
100
+
101
+ ```text
102
+ GATE: FAIL
103
+ - 4 new error finding(s): refund-workflow-1002:ARH-FLW-003, refund-workflow-1002:ARH-SEQ-001, refund-workflow-1002:ARH-SEQ-003, refund-workflow-1002:ARH-SEQ-004
104
+ - added trace 'refund-workflow-1002' fails
105
+ ```
106
+
107
+ The gate fails on new error findings, pass→fail transitions, and added failing
108
+ traces — resolved findings and unchanged failures don't re-alarm. Gate modes:
109
+ `--fail-on regressions` (default), `failures`, `never`; add `--max-score-drop`
110
+ for score-based gating. See [docs/regression-testing.md](https://github.com/felmonon/agent-reliability-harness/blob/main/docs/regression-testing.md).
111
+
112
+ ## What it checks
113
+
114
+ Seven deterministic categories; every finding carries a stable rule ID
115
+ (`ARH-<CATEGORY>-<NNN>`), an expected/observed pair, and remediation guidance:
116
+
117
+ | Category | Rules | Examples |
118
+ |---|---|---|
119
+ | schema | ARH-SCH-001..010 | unlisted tool, missing/mistyped args, enum/pattern/range violations |
120
+ | budget | ARH-BUD-001..007 | step/total latency, cost, and token budgets, plus unverifiable-budget warnings |
121
+ | safety | ARH-SAF-001 | prompt-injection phrases, secret-like strings (policy regexes) |
122
+ | grounding | ARH-GRD-001..003 | missing citations, low coverage, malformed citation URLs |
123
+ | sequence | ARH-SEQ-001..005 | required/forbidden tools, partial-order violations, call counts |
124
+ | flow | ARH-FLW-001..003 | ignored tool errors, retry storms, duplicate side effects |
125
+ | completion | ARH-CMP-001..002 | missing final response, failure to terminate |
126
+
127
+ Full reference: [docs/rules.md](https://github.com/felmonon/agent-reliability-harness/blob/main/docs/rules.md). Ordering rules are a
128
+ deliberate **partial order** (constraints), not an exact golden-trajectory
129
+ match — agents can legitimately reach a goal via different paths.
130
+
131
+ ## Trace formats
132
+
133
+ `arh validate` accepts (auto-detected, or forced with `--format`):
134
+
135
+ - **arh** — the canonical JSON trace format ([TRACE-SPEC.md](https://github.com/felmonon/agent-reliability-harness/blob/main/TRACE-SPEC.md));
136
+ - **openai-chat** — OpenAI Chat Completions message lists with `tool_calls`;
137
+ - **anthropic-messages** — Anthropic Messages conversations with
138
+ `tool_use`/`tool_result` blocks.
139
+
140
+ Adapters never guess: fields a transcript format cannot carry (latency, cost,
141
+ tokens) are left unset, which marks the dependent checks *not applicable*
142
+ instead of silently passing them. Unparseable input is recorded in the trace's
143
+ metadata, not dropped. See [docs/adapters.md](https://github.com/felmonon/agent-reliability-harness/blob/main/docs/adapters.md).
144
+
145
+ ## Reports
146
+
147
+ Console, JSON (doubles as the regression baseline), Markdown (PR-comment
148
+ ready), JUnit XML, and SARIF 2.1.0 (GitHub code-scanning annotations). All
149
+ renderers are deterministic: identical input produces byte-identical output —
150
+ no timestamps, no randomness, no clock reads.
151
+
152
+ ## CI
153
+
154
+ ```yaml
155
+ - uses: felmonon/agent-reliability-harness@main
156
+ with:
157
+ policy: policies/agent-policy.json
158
+ traces: traces/*.json
159
+ baseline: baselines/main.json # optional: gate on regressions
160
+ ```
161
+
162
+ The action writes JSON/Markdown/JUnit/SARIF reports, appends the Markdown
163
+ summary to the workflow step summary, and fails according to the gate. It uses
164
+ no secrets and is fork-safe. Full reference and SARIF/JUnit upload examples:
165
+ [docs/ci.md](https://github.com/felmonon/agent-reliability-harness/blob/main/docs/ci.md).
166
+
167
+ ## Design principles
168
+
169
+ - **Zero runtime dependencies.** `pip install` adds nothing to your
170
+ application's dependency graph.
171
+ - **Deterministic core.** No model calls, no network, no telemetry, no clock
172
+ reads. Semantic (model-graded) evaluation is a planned, clearly separated
173
+ optional extra — never hidden inside deterministic scores ([ROADMAP.md](https://github.com/felmonon/agent-reliability-harness/blob/main/ROADMAP.md)).
174
+ - **Additive schema evolution.** v0.1.x traces, policies, and baselines work
175
+ unchanged; unknown major schema versions are rejected loudly
176
+ ([COMPATIBILITY.md](https://github.com/felmonon/agent-reliability-harness/blob/main/COMPATIBILITY.md)).
177
+ - **Evidence over claims.** The benchmark suite contains 34 seeded cases
178
+ (28 expected-fail, 6 expected-pass controls) and measures detection:
179
+ currently 34/34 correct, precision 1.0, recall 1.0, 0 false
180
+ positives/negatives, byte-identical repeat runs, ~0.03 ms per trace. Those
181
+ numbers cover *seeded, deterministically detectable* failures only — scope
182
+ and limits are documented in [BENCHMARK-METHODOLOGY.md](https://github.com/felmonon/agent-reliability-harness/blob/main/BENCHMARK-METHODOLOGY.md),
183
+ results in [BENCHMARK-RESULTS.md](https://github.com/felmonon/agent-reliability-harness/blob/main/BENCHMARK-RESULTS.md).
184
+
185
+ ## Documentation
186
+
187
+ | Doc | What it covers |
188
+ |---|---|
189
+ | [docs/quickstart.md](https://github.com/felmonon/agent-reliability-harness/blob/main/docs/quickstart.md) | Five minutes from install to a regression gate |
190
+ | [docs/concepts.md](https://github.com/felmonon/agent-reliability-harness/blob/main/docs/concepts.md) | Traces, policies, findings, scores, baselines |
191
+ | [docs/policy-cookbook.md](https://github.com/felmonon/agent-reliability-harness/blob/main/docs/policy-cookbook.md) | Copy-paste recipes for every rule type |
192
+ | [docs/adapters.md](https://github.com/felmonon/agent-reliability-harness/blob/main/docs/adapters.md) | OpenAI/Anthropic transcript ingestion, field mapping |
193
+ | [docs/regression-testing.md](https://github.com/felmonon/agent-reliability-harness/blob/main/docs/regression-testing.md) | Baselines, fingerprints, gates |
194
+ | [docs/ci.md](https://github.com/felmonon/agent-reliability-harness/blob/main/docs/ci.md) | GitHub Action reference and workflows |
195
+ | [docs/rules.md](https://github.com/felmonon/agent-reliability-harness/blob/main/docs/rules.md) | Every rule ID with remediation |
196
+ | [docs/troubleshooting.md](https://github.com/felmonon/agent-reliability-harness/blob/main/docs/troubleshooting.md) | Error messages and fixes |
197
+ | [TRACE-SPEC.md](https://github.com/felmonon/agent-reliability-harness/blob/main/TRACE-SPEC.md) / [POLICY-SPEC.md](https://github.com/felmonon/agent-reliability-harness/blob/main/POLICY-SPEC.md) | Normative formats |
198
+ | [ARCHITECTURE.md](https://github.com/felmonon/agent-reliability-harness/blob/main/ARCHITECTURE.md) / [DECISIONS.md](https://github.com/felmonon/agent-reliability-harness/blob/main/DECISIONS.md) | Design and ADRs |
199
+
200
+ ## Compatibility
201
+
202
+ v0.1.x trace and policy files remain accepted and preserve verdicts and finding
203
+ messages. Two review-driven detection fixes are documented exceptions: nested safety
204
+ scanning changes one sample score from 70.0 to 70.83, and strict telemetry validation
205
+ rejects malformed values that v0.1 accepted. New report fields are additive.
206
+ Details: [COMPATIBILITY.md](https://github.com/felmonon/agent-reliability-harness/blob/main/COMPATIBILITY.md).
207
+
208
+ ## Development
209
+
210
+ ```bash
211
+ python -m venv .venv && source .venv/bin/activate
212
+ python -m pip install -e ".[dev]"
213
+ python -m unittest discover -s tests # full suite (194 tests as of 0.2.0)
214
+ ruff check src tests benchmarks
215
+ mypy src # strict
216
+ python benchmarks/run.py # thresholds enforced
217
+ ```
218
+
219
+ CI runs the suite on Linux/macOS/Windows across Python 3.11-3.13, plus
220
+ packaging checks. Contributions welcome — see [CONTRIBUTING.md](https://github.com/felmonon/agent-reliability-harness/blob/main/CONTRIBUTING.md).
221
+
222
+ ## Author
223
+
224
+ [Felmon Fekadu](https://felmon.tech/proof)
225
+ [GitHub](https://github.com/felmonon)
226
+
227
+ ## License
228
+
229
+ MIT
@@ -0,0 +1,201 @@
1
+ # Agent Reliability Harness
2
+
3
+ A provider-neutral, local-first reliability and regression-testing harness for
4
+ tool-using AI agents. It validates recorded agent execution traces against
5
+ declarative policies (tool-call contracts, trajectory rules, budgets, unsafe
6
+ patterns, grounding), produces deterministic findings with stable rule IDs,
7
+ and compares candidate runs against a saved baseline so CI fails only on real
8
+ regressions.
9
+
10
+ The core has **zero runtime dependencies**, makes **no network calls**, sends
11
+ **no telemetry**, and produces **byte-identical reports** for identical input.
12
+
13
+ ## Why this exists
14
+
15
+ An agent can reach the correct final answer while still behaving unreliably.
16
+ It may:
17
+
18
+ - select the wrong tool, or skip a required one;
19
+ - use correct tools in the wrong order;
20
+ - pass invalid or out-of-range arguments;
21
+ - repeat an irreversible action (double refund, duplicate email);
22
+ - ignore a tool failure and answer anyway;
23
+ - get stuck in a retry storm;
24
+ - stop before finishing, or fail to terminate;
25
+ - return facts without citations;
26
+ - leak secrets or propagate prompt-injection text;
27
+ - blow past latency, cost, or token budgets;
28
+ - regress silently after a model, prompt, or tool change.
29
+
30
+ Final-answer evals miss all of this. This harness evaluates the **trajectory**,
31
+ and turns each of these concerns into a versioned policy rule with a stable ID.
32
+
33
+ ## 60-second example
34
+
35
+ ```bash
36
+ python -m pip install -e . # not yet on PyPI; install from a checkout
37
+
38
+ arh validate --policy samples/policy_trajectory.json \
39
+ samples/traces/refund_workflow_pass.json \
40
+ samples/traces/refund_workflow_double_refund.json
41
+ ```
42
+
43
+ The second trace ends with a perfectly plausible final answer — and still
44
+ fails, because the trajectory was unacceptable:
45
+
46
+ ```text
47
+ [FAIL] refund-workflow-1002 (agent=refund-copilot, workflow=refund)
48
+ score=84.5/100 policy=refund-workflow-v1 latency=1300ms cost=$0.0080
49
+ - [ERROR ] [flow ] ARH-FLW-003: duplicate side effect: tool 'issue_refund' was called again with identical arguments after already succeeding (step=s3)
50
+ - [ERROR ] [sequence ] ARH-SEQ-001: required tool 'check_refund_eligibility' was never called
51
+ - [ERROR ] [sequence ] ARH-SEQ-004: tool 'issue_refund' was called 2 times, above max_calls of 1
52
+ - [ERROR ] [sequence ] ARH-SEQ-003: call order violation: first call of 'lookup_order' must precede first call of 'issue_refund' (step=s1)
53
+ ```
54
+
55
+ Exit code `0` when everything passes, `1` on failure, `2` on usage errors —
56
+ usable as a CI gate as-is.
57
+
58
+ ## Regression gates
59
+
60
+ Save a baseline once, then gate future runs on *changes*, not absolutes:
61
+
62
+ ```bash
63
+ arh validate --policy samples/policy_trajectory.json \
64
+ samples/traces/refund_workflow_pass.json \
65
+ --json-out baseline.json --quiet
66
+
67
+ arh compare --baseline baseline.json \
68
+ --policy samples/policy_trajectory.json \
69
+ samples/traces/refund_workflow_pass.json \
70
+ samples/traces/refund_workflow_double_refund.json
71
+ ```
72
+
73
+ ```text
74
+ GATE: FAIL
75
+ - 4 new error finding(s): refund-workflow-1002:ARH-FLW-003, refund-workflow-1002:ARH-SEQ-001, refund-workflow-1002:ARH-SEQ-003, refund-workflow-1002:ARH-SEQ-004
76
+ - added trace 'refund-workflow-1002' fails
77
+ ```
78
+
79
+ The gate fails on new error findings, pass→fail transitions, and added failing
80
+ traces — resolved findings and unchanged failures don't re-alarm. Gate modes:
81
+ `--fail-on regressions` (default), `failures`, `never`; add `--max-score-drop`
82
+ for score-based gating. See [docs/regression-testing.md](https://github.com/felmonon/agent-reliability-harness/blob/main/docs/regression-testing.md).
83
+
84
+ ## What it checks
85
+
86
+ Seven deterministic categories; every finding carries a stable rule ID
87
+ (`ARH-<CATEGORY>-<NNN>`), an expected/observed pair, and remediation guidance:
88
+
89
+ | Category | Rules | Examples |
90
+ |---|---|---|
91
+ | schema | ARH-SCH-001..010 | unlisted tool, missing/mistyped args, enum/pattern/range violations |
92
+ | budget | ARH-BUD-001..007 | step/total latency, cost, and token budgets, plus unverifiable-budget warnings |
93
+ | safety | ARH-SAF-001 | prompt-injection phrases, secret-like strings (policy regexes) |
94
+ | grounding | ARH-GRD-001..003 | missing citations, low coverage, malformed citation URLs |
95
+ | sequence | ARH-SEQ-001..005 | required/forbidden tools, partial-order violations, call counts |
96
+ | flow | ARH-FLW-001..003 | ignored tool errors, retry storms, duplicate side effects |
97
+ | completion | ARH-CMP-001..002 | missing final response, failure to terminate |
98
+
99
+ Full reference: [docs/rules.md](https://github.com/felmonon/agent-reliability-harness/blob/main/docs/rules.md). Ordering rules are a
100
+ deliberate **partial order** (constraints), not an exact golden-trajectory
101
+ match — agents can legitimately reach a goal via different paths.
102
+
103
+ ## Trace formats
104
+
105
+ `arh validate` accepts (auto-detected, or forced with `--format`):
106
+
107
+ - **arh** — the canonical JSON trace format ([TRACE-SPEC.md](https://github.com/felmonon/agent-reliability-harness/blob/main/TRACE-SPEC.md));
108
+ - **openai-chat** — OpenAI Chat Completions message lists with `tool_calls`;
109
+ - **anthropic-messages** — Anthropic Messages conversations with
110
+ `tool_use`/`tool_result` blocks.
111
+
112
+ Adapters never guess: fields a transcript format cannot carry (latency, cost,
113
+ tokens) are left unset, which marks the dependent checks *not applicable*
114
+ instead of silently passing them. Unparseable input is recorded in the trace's
115
+ metadata, not dropped. See [docs/adapters.md](https://github.com/felmonon/agent-reliability-harness/blob/main/docs/adapters.md).
116
+
117
+ ## Reports
118
+
119
+ Console, JSON (doubles as the regression baseline), Markdown (PR-comment
120
+ ready), JUnit XML, and SARIF 2.1.0 (GitHub code-scanning annotations). All
121
+ renderers are deterministic: identical input produces byte-identical output —
122
+ no timestamps, no randomness, no clock reads.
123
+
124
+ ## CI
125
+
126
+ ```yaml
127
+ - uses: felmonon/agent-reliability-harness@main
128
+ with:
129
+ policy: policies/agent-policy.json
130
+ traces: traces/*.json
131
+ baseline: baselines/main.json # optional: gate on regressions
132
+ ```
133
+
134
+ The action writes JSON/Markdown/JUnit/SARIF reports, appends the Markdown
135
+ summary to the workflow step summary, and fails according to the gate. It uses
136
+ no secrets and is fork-safe. Full reference and SARIF/JUnit upload examples:
137
+ [docs/ci.md](https://github.com/felmonon/agent-reliability-harness/blob/main/docs/ci.md).
138
+
139
+ ## Design principles
140
+
141
+ - **Zero runtime dependencies.** `pip install` adds nothing to your
142
+ application's dependency graph.
143
+ - **Deterministic core.** No model calls, no network, no telemetry, no clock
144
+ reads. Semantic (model-graded) evaluation is a planned, clearly separated
145
+ optional extra — never hidden inside deterministic scores ([ROADMAP.md](https://github.com/felmonon/agent-reliability-harness/blob/main/ROADMAP.md)).
146
+ - **Additive schema evolution.** v0.1.x traces, policies, and baselines work
147
+ unchanged; unknown major schema versions are rejected loudly
148
+ ([COMPATIBILITY.md](https://github.com/felmonon/agent-reliability-harness/blob/main/COMPATIBILITY.md)).
149
+ - **Evidence over claims.** The benchmark suite contains 34 seeded cases
150
+ (28 expected-fail, 6 expected-pass controls) and measures detection:
151
+ currently 34/34 correct, precision 1.0, recall 1.0, 0 false
152
+ positives/negatives, byte-identical repeat runs, ~0.03 ms per trace. Those
153
+ numbers cover *seeded, deterministically detectable* failures only — scope
154
+ and limits are documented in [BENCHMARK-METHODOLOGY.md](https://github.com/felmonon/agent-reliability-harness/blob/main/BENCHMARK-METHODOLOGY.md),
155
+ results in [BENCHMARK-RESULTS.md](https://github.com/felmonon/agent-reliability-harness/blob/main/BENCHMARK-RESULTS.md).
156
+
157
+ ## Documentation
158
+
159
+ | Doc | What it covers |
160
+ |---|---|
161
+ | [docs/quickstart.md](https://github.com/felmonon/agent-reliability-harness/blob/main/docs/quickstart.md) | Five minutes from install to a regression gate |
162
+ | [docs/concepts.md](https://github.com/felmonon/agent-reliability-harness/blob/main/docs/concepts.md) | Traces, policies, findings, scores, baselines |
163
+ | [docs/policy-cookbook.md](https://github.com/felmonon/agent-reliability-harness/blob/main/docs/policy-cookbook.md) | Copy-paste recipes for every rule type |
164
+ | [docs/adapters.md](https://github.com/felmonon/agent-reliability-harness/blob/main/docs/adapters.md) | OpenAI/Anthropic transcript ingestion, field mapping |
165
+ | [docs/regression-testing.md](https://github.com/felmonon/agent-reliability-harness/blob/main/docs/regression-testing.md) | Baselines, fingerprints, gates |
166
+ | [docs/ci.md](https://github.com/felmonon/agent-reliability-harness/blob/main/docs/ci.md) | GitHub Action reference and workflows |
167
+ | [docs/rules.md](https://github.com/felmonon/agent-reliability-harness/blob/main/docs/rules.md) | Every rule ID with remediation |
168
+ | [docs/troubleshooting.md](https://github.com/felmonon/agent-reliability-harness/blob/main/docs/troubleshooting.md) | Error messages and fixes |
169
+ | [TRACE-SPEC.md](https://github.com/felmonon/agent-reliability-harness/blob/main/TRACE-SPEC.md) / [POLICY-SPEC.md](https://github.com/felmonon/agent-reliability-harness/blob/main/POLICY-SPEC.md) | Normative formats |
170
+ | [ARCHITECTURE.md](https://github.com/felmonon/agent-reliability-harness/blob/main/ARCHITECTURE.md) / [DECISIONS.md](https://github.com/felmonon/agent-reliability-harness/blob/main/DECISIONS.md) | Design and ADRs |
171
+
172
+ ## Compatibility
173
+
174
+ v0.1.x trace and policy files remain accepted and preserve verdicts and finding
175
+ messages. Two review-driven detection fixes are documented exceptions: nested safety
176
+ scanning changes one sample score from 70.0 to 70.83, and strict telemetry validation
177
+ rejects malformed values that v0.1 accepted. New report fields are additive.
178
+ Details: [COMPATIBILITY.md](https://github.com/felmonon/agent-reliability-harness/blob/main/COMPATIBILITY.md).
179
+
180
+ ## Development
181
+
182
+ ```bash
183
+ python -m venv .venv && source .venv/bin/activate
184
+ python -m pip install -e ".[dev]"
185
+ python -m unittest discover -s tests # full suite (194 tests as of 0.2.0)
186
+ ruff check src tests benchmarks
187
+ mypy src # strict
188
+ python benchmarks/run.py # thresholds enforced
189
+ ```
190
+
191
+ CI runs the suite on Linux/macOS/Windows across Python 3.11-3.13, plus
192
+ packaging checks. Contributions welcome — see [CONTRIBUTING.md](https://github.com/felmonon/agent-reliability-harness/blob/main/CONTRIBUTING.md).
193
+
194
+ ## Author
195
+
196
+ [Felmon Fekadu](https://felmon.tech/proof)
197
+ [GitHub](https://github.com/felmonon)
198
+
199
+ ## License
200
+
201
+ MIT
@@ -0,0 +1,70 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "agent-reliability-harness"
7
+ version = "0.2.1"
8
+ description = "Local-first policy and trajectory-regression harness for tool-using AI agents: deterministic trace validation, policy-as-code trajectory rules, baseline-vs-candidate regression gates, and CI-ready JSON/Markdown/JUnit/SARIF reports."
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "Felmon Fekadu" }]
14
+ keywords = [
15
+ "agents",
16
+ "llm",
17
+ "evaluation",
18
+ "reliability",
19
+ "regression-testing",
20
+ "grounding",
21
+ "tool-use",
22
+ "trajectory",
23
+ "policy-as-code",
24
+ "ci",
25
+ ]
26
+ classifiers = [
27
+ "Development Status :: 4 - Beta",
28
+ "Intended Audience :: Developers",
29
+ "Programming Language :: Python :: 3.11",
30
+ "Programming Language :: Python :: 3.12",
31
+ "Programming Language :: Python :: 3.13",
32
+ "Topic :: Software Development :: Testing",
33
+ "Topic :: Software Development :: Quality Assurance",
34
+ ]
35
+ dependencies = []
36
+
37
+ [project.urls]
38
+ Homepage = "https://github.com/felmonon/agent-reliability-harness"
39
+ Documentation = "https://github.com/felmonon/agent-reliability-harness/tree/main/docs"
40
+ Changelog = "https://github.com/felmonon/agent-reliability-harness/blob/main/CHANGELOG.md"
41
+ Issues = "https://github.com/felmonon/agent-reliability-harness/issues"
42
+
43
+ [project.optional-dependencies]
44
+ dev = ["mypy>=1.8", "ruff>=0.5", "jsonschema>=4.21", "build>=1.0"]
45
+
46
+ [project.scripts]
47
+ arh = "agent_reliability_harness.cli:main"
48
+
49
+ [tool.setuptools.packages.find]
50
+ where = ["src"]
51
+
52
+ [tool.setuptools.package-data]
53
+ agent_reliability_harness = ["py.typed"]
54
+
55
+ [tool.ruff]
56
+ line-length = 100
57
+ target-version = "py311"
58
+
59
+ [tool.ruff.lint]
60
+ select = ["E", "F", "W", "I", "UP", "B"]
61
+ ignore = ["E501"] # long lines allowed in messages/docstrings; format stays readable
62
+
63
+ [tool.mypy]
64
+ python_version = "3.11"
65
+ strict = true
66
+ warn_unused_ignores = true
67
+
68
+ [[tool.mypy.overrides]]
69
+ module = "tests.*"
70
+ strict = false