conereplay 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.
- conereplay-0.1.0/LICENSE +15 -0
- conereplay-0.1.0/PKG-INFO +207 -0
- conereplay-0.1.0/README.md +151 -0
- conereplay-0.1.0/benchmarks/__init__.py +20 -0
- conereplay-0.1.0/benchmarks/__main__.py +5 -0
- conereplay-0.1.0/benchmarks/bench.py +171 -0
- conereplay-0.1.0/benchmarks/live_provider.py +190 -0
- conereplay-0.1.0/benchmarks/realistic_replay.py +144 -0
- conereplay-0.1.0/benchmarks/synth.py +75 -0
- conereplay-0.1.0/benchmarks/token_bench.py +181 -0
- conereplay-0.1.0/conereplay/__init__.py +79 -0
- conereplay-0.1.0/conereplay/audit.py +102 -0
- conereplay-0.1.0/conereplay/cli/__init__.py +0 -0
- conereplay-0.1.0/conereplay/cli/main.py +326 -0
- conereplay-0.1.0/conereplay/config.py +80 -0
- conereplay-0.1.0/conereplay/core/__init__.py +0 -0
- conereplay-0.1.0/conereplay/core/_hashing.py +25 -0
- conereplay-0.1.0/conereplay/core/_text.py +24 -0
- conereplay-0.1.0/conereplay/core/bisect.py +118 -0
- conereplay-0.1.0/conereplay/core/clock.py +60 -0
- conereplay-0.1.0/conereplay/core/cone.py +79 -0
- conereplay-0.1.0/conereplay/core/corpus.py +188 -0
- conereplay-0.1.0/conereplay/core/corpus_html.py +350 -0
- conereplay-0.1.0/conereplay/core/corpus_report.py +77 -0
- conereplay-0.1.0/conereplay/core/diagram.py +121 -0
- conereplay-0.1.0/conereplay/core/diff.py +46 -0
- conereplay-0.1.0/conereplay/core/graph.py +27 -0
- conereplay-0.1.0/conereplay/core/oracle.py +236 -0
- conereplay-0.1.0/conereplay/core/oracles/__init__.py +23 -0
- conereplay-0.1.0/conereplay/core/oracles/anthropic_backed.py +74 -0
- conereplay-0.1.0/conereplay/core/oracles/openai_backed.py +72 -0
- conereplay-0.1.0/conereplay/core/oracles/token_counter.py +16 -0
- conereplay-0.1.0/conereplay/core/replay.py +122 -0
- conereplay-0.1.0/conereplay/core/report.py +89 -0
- conereplay-0.1.0/conereplay/core/schemas.py +75 -0
- conereplay-0.1.0/conereplay/core/serialize.py +108 -0
- conereplay-0.1.0/conereplay/examples/__init__.py +7 -0
- conereplay-0.1.0/conereplay/examples/langgraph_refund_agent/README.md +82 -0
- conereplay-0.1.0/conereplay/examples/langgraph_refund_agent/__init__.py +22 -0
- conereplay-0.1.0/conereplay/examples/langgraph_refund_agent/demo.py +111 -0
- conereplay-0.1.0/conereplay/examples/langgraph_refund_agent/graph.py +175 -0
- conereplay-0.1.0/conereplay/examples/langgraph_refund_agent/llm.py +50 -0
- conereplay-0.1.0/conereplay/examples/langgraph_refund_agent/modifications/policy-5day.json +4 -0
- conereplay-0.1.0/conereplay/flags.py +43 -0
- conereplay-0.1.0/conereplay/logging_setup.py +99 -0
- conereplay-0.1.0/conereplay/otel.py +104 -0
- conereplay-0.1.0/conereplay/sdk/__init__.py +0 -0
- conereplay-0.1.0/conereplay/sdk/langgraph.py +314 -0
- conereplay-0.1.0/conereplay/sdk/provenance.py +51 -0
- conereplay-0.1.0/conereplay/sdk/recorder.py +82 -0
- conereplay-0.1.0/conereplay/server/__init__.py +16 -0
- conereplay-0.1.0/conereplay/server/app.py +282 -0
- conereplay-0.1.0/conereplay/server/auth.py +46 -0
- conereplay-0.1.0/conereplay/server/health.py +31 -0
- conereplay-0.1.0/conereplay/server/models.py +55 -0
- conereplay-0.1.0/conereplay/server/pagination.py +47 -0
- conereplay-0.1.0/conereplay/server/replays.py +38 -0
- conereplay-0.1.0/conereplay/server/stats.py +30 -0
- conereplay-0.1.0/conereplay.egg-info/PKG-INFO +207 -0
- conereplay-0.1.0/conereplay.egg-info/SOURCES.txt +102 -0
- conereplay-0.1.0/conereplay.egg-info/dependency_links.txt +1 -0
- conereplay-0.1.0/conereplay.egg-info/entry_points.txt +2 -0
- conereplay-0.1.0/conereplay.egg-info/requires.txt +44 -0
- conereplay-0.1.0/conereplay.egg-info/top_level.txt +2 -0
- conereplay-0.1.0/pyproject.toml +116 -0
- conereplay-0.1.0/setup.cfg +4 -0
- conereplay-0.1.0/tests/test_audit.py +111 -0
- conereplay-0.1.0/tests/test_audit_tail.py +41 -0
- conereplay-0.1.0/tests/test_auth.py +73 -0
- conereplay-0.1.0/tests/test_benchmarks.py +136 -0
- conereplay-0.1.0/tests/test_bisect.py +113 -0
- conereplay-0.1.0/tests/test_cli.py +535 -0
- conereplay-0.1.0/tests/test_clock.py +102 -0
- conereplay-0.1.0/tests/test_cone.py +145 -0
- conereplay-0.1.0/tests/test_config.py +104 -0
- conereplay-0.1.0/tests/test_corpus.py +187 -0
- conereplay-0.1.0/tests/test_corpus_html.py +244 -0
- conereplay-0.1.0/tests/test_corpus_report.py +108 -0
- conereplay-0.1.0/tests/test_diagram.py +132 -0
- conereplay-0.1.0/tests/test_diff.py +85 -0
- conereplay-0.1.0/tests/test_flags.py +47 -0
- conereplay-0.1.0/tests/test_graph.py +70 -0
- conereplay-0.1.0/tests/test_health.py +38 -0
- conereplay-0.1.0/tests/test_langgraph_capture.py +84 -0
- conereplay-0.1.0/tests/test_langgraph_demo.py +124 -0
- conereplay-0.1.0/tests/test_live_provider_ab.py +165 -0
- conereplay-0.1.0/tests/test_logging.py +96 -0
- conereplay-0.1.0/tests/test_oracle.py +129 -0
- conereplay-0.1.0/tests/test_oracles.py +109 -0
- conereplay-0.1.0/tests/test_otel.py +131 -0
- conereplay-0.1.0/tests/test_otel_traced.py +56 -0
- conereplay-0.1.0/tests/test_pagination.py +47 -0
- conereplay-0.1.0/tests/test_provider_oracle.py +135 -0
- conereplay-0.1.0/tests/test_replay.py +187 -0
- conereplay-0.1.0/tests/test_replays.py +37 -0
- conereplay-0.1.0/tests/test_report.py +90 -0
- conereplay-0.1.0/tests/test_sanitized_sample.py +28 -0
- conereplay-0.1.0/tests/test_schemas.py +120 -0
- conereplay-0.1.0/tests/test_sdk.py +218 -0
- conereplay-0.1.0/tests/test_serialize.py +91 -0
- conereplay-0.1.0/tests/test_server.py +357 -0
- conereplay-0.1.0/tests/test_server_auth.py +87 -0
- conereplay-0.1.0/tests/test_stats.py +30 -0
- conereplay-0.1.0/tests/test_token_bench.py +117 -0
conereplay-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Copyright (c) 2026 Naveen Singh Dhillon and Rajvir Singh Dhillon.
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Patent pending: U.S. Provisional Application CDRA-PROV-2026-001, filed with the
|
|
5
|
+
United States Patent and Trademark Office.
|
|
6
|
+
|
|
7
|
+
This source code and accompanying materials are proprietary and confidential.
|
|
8
|
+
No license or permission is granted, expressly or by implication, to any person
|
|
9
|
+
or entity to copy, modify, redistribute, sublicense, publicly perform, publicly
|
|
10
|
+
display, or create derivative works of any portion of this repository, except
|
|
11
|
+
as explicitly authorized in writing by the copyright holders.
|
|
12
|
+
|
|
13
|
+
Unauthorized use, reproduction, or distribution constitutes infringement of
|
|
14
|
+
copyright, trade secret, and/or pending patent rights and may be prosecuted to
|
|
15
|
+
the fullest extent permitted by law.
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: conereplay
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Pre-deploy regression harness for multi-agent AI: cone-bounded divergent replay with counterfactual oracle. Patent pending (US Provisional CDRA-PROV-2026-001).
|
|
5
|
+
Author: Naveen Singh Dhillon, Rajvir Singh Dhillon
|
|
6
|
+
License: Proprietary
|
|
7
|
+
Project-URL: Homepage, https://conereplay.com
|
|
8
|
+
Project-URL: Repository, https://github.com/gitdhillonai/conereplay
|
|
9
|
+
Keywords: llm,multi-agent,replay,counterfactual,observability,langgraph
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: License :: Other/Proprietary License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Requires-Python: >=3.11
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: networkx>=3.2
|
|
18
|
+
Requires-Dist: pydantic>=2.6
|
|
19
|
+
Requires-Dist: pydantic-settings>=2.0
|
|
20
|
+
Provides-Extra: langgraph
|
|
21
|
+
Requires-Dist: langgraph>=0.2; extra == "langgraph"
|
|
22
|
+
Requires-Dist: langchain-core>=0.3; extra == "langgraph"
|
|
23
|
+
Provides-Extra: providers
|
|
24
|
+
Requires-Dist: anthropic>=0.40; extra == "providers"
|
|
25
|
+
Requires-Dist: openai>=1.50; extra == "providers"
|
|
26
|
+
Provides-Extra: server
|
|
27
|
+
Requires-Dist: fastapi>=0.110; extra == "server"
|
|
28
|
+
Requires-Dist: uvicorn[standard]>=0.30; extra == "server"
|
|
29
|
+
Requires-Dist: sqlalchemy>=2.0; extra == "server"
|
|
30
|
+
Requires-Dist: psycopg2-binary>=2.9; extra == "server"
|
|
31
|
+
Requires-Dist: redis>=5.0; extra == "server"
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
34
|
+
Requires-Dist: pytest-cov>=5.0; extra == "dev"
|
|
35
|
+
Requires-Dist: ruff>=0.4; extra == "dev"
|
|
36
|
+
Requires-Dist: mypy>=1.10; extra == "dev"
|
|
37
|
+
Requires-Dist: pip-audit>=2.7; extra == "dev"
|
|
38
|
+
Requires-Dist: pre-commit>=3.7; extra == "dev"
|
|
39
|
+
Requires-Dist: httpx>=0.27; extra == "dev"
|
|
40
|
+
Requires-Dist: fastapi>=0.110; extra == "dev"
|
|
41
|
+
Requires-Dist: sqlalchemy>=2.0; extra == "dev"
|
|
42
|
+
Requires-Dist: langgraph>=0.2; extra == "dev"
|
|
43
|
+
Requires-Dist: langchain-core>=0.3; extra == "dev"
|
|
44
|
+
Requires-Dist: anthropic>=0.40; extra == "dev"
|
|
45
|
+
Requires-Dist: openai>=1.50; extra == "dev"
|
|
46
|
+
Requires-Dist: tiktoken>=0.7; extra == "dev"
|
|
47
|
+
Requires-Dist: opentelemetry-api>=1.20; extra == "dev"
|
|
48
|
+
Requires-Dist: opentelemetry-sdk>=1.20; extra == "dev"
|
|
49
|
+
Provides-Extra: otel
|
|
50
|
+
Requires-Dist: opentelemetry-api>=1.20; extra == "otel"
|
|
51
|
+
Requires-Dist: opentelemetry-sdk>=1.20; extra == "otel"
|
|
52
|
+
Provides-Extra: demo
|
|
53
|
+
Requires-Dist: langgraph>=0.2; extra == "demo"
|
|
54
|
+
Requires-Dist: langchain-core>=0.3; extra == "demo"
|
|
55
|
+
Dynamic: license-file
|
|
56
|
+
|
|
57
|
+
# ConeReplay
|
|
58
|
+
|
|
59
|
+
Pre-deploy regression testing for multi-agent AI. Record traces from your
|
|
60
|
+
production agent app, propose a change (new prompt, new tool response, new
|
|
61
|
+
model), and replay only the events causally affected — everything else is
|
|
62
|
+
served byte-identically from the recording.
|
|
63
|
+
|
|
64
|
+
Patent pending (U.S. Provisional Application **64/043,722**). See
|
|
65
|
+
[VERSIONING.md](VERSIONING.md) for SemVer commitments and
|
|
66
|
+
[docs/trace-format.md](docs/trace-format.md) for the on-disk contract.
|
|
67
|
+
|
|
68
|
+
## Install
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pip install conereplay # core + CLI
|
|
72
|
+
pip install conereplay[server] # hosted trace-store server
|
|
73
|
+
pip install conereplay[langgraph] # LangGraph recording adapter
|
|
74
|
+
pip install conereplay[providers] # anthropic / openai oracle backends
|
|
75
|
+
pip install conereplay[dev] # dev tooling (pytest, ruff, mypy, pip-audit)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Requires Python 3.11+. Core has only two runtime deps (`networkx`,
|
|
79
|
+
`pydantic`, `pydantic-settings`).
|
|
80
|
+
|
|
81
|
+
## CLI quickstart
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# Single-trace replay → Markdown report
|
|
85
|
+
conereplay replay \
|
|
86
|
+
--trace examples/trace.json \
|
|
87
|
+
--modify examples/modify.json \
|
|
88
|
+
--report report.md
|
|
89
|
+
|
|
90
|
+
# Corpus-mode regression harness → aggregate report (Markdown or HTML)
|
|
91
|
+
conereplay corpus \
|
|
92
|
+
--traces examples/traces \
|
|
93
|
+
--modify examples/corpus-modify.json \
|
|
94
|
+
--report corpus.html \
|
|
95
|
+
--format html
|
|
96
|
+
|
|
97
|
+
# Emit a Mermaid or Graphviz diagram of a trace's causal DAG
|
|
98
|
+
conereplay diagram \
|
|
99
|
+
--trace examples/trace.json \
|
|
100
|
+
--modify examples/modify.json \
|
|
101
|
+
--format mermaid --out cone.mmd
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
See [docs/cli.md](docs/cli.md) for the full reference.
|
|
105
|
+
|
|
106
|
+
## Library quickstart
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from conereplay import (
|
|
110
|
+
load_trace, ModificationSpec, selective_replay, compute_divergence,
|
|
111
|
+
render_markdown_report,
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
trace = load_trace("trace.json")
|
|
115
|
+
mod = ModificationSpec(target_event_id="e3", substituted_output=b"POLICY: 5 days")
|
|
116
|
+
divergent = selective_replay(trace, mod)
|
|
117
|
+
report = compute_divergence(trace, divergent)
|
|
118
|
+
print(render_markdown_report(trace, divergent, mod, report))
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Architecture
|
|
122
|
+
|
|
123
|
+
Four layers. See [ARCHITECTURE.md](ARCHITECTURE.md) for the full picture.
|
|
124
|
+
|
|
125
|
+
| Layer | Purpose | Modules |
|
|
126
|
+
|---|---|---|
|
|
127
|
+
| Core algorithms | Deterministic, pure-stdlib | `core/clock.py`, `core/cone.py`, `core/replay.py`, `core/diff.py` |
|
|
128
|
+
| SDK | Recording + provenance | `sdk/recorder.py`, `sdk/provenance.py`, `sdk/langgraph.py` |
|
|
129
|
+
| Presentation | Reports + diagrams | `core/report.py`, `core/corpus_report.py`, `core/corpus_html.py`, `core/diagram.py` |
|
|
130
|
+
| Server | Hosted trace store | `server/app.py`, `server/models.py` |
|
|
131
|
+
|
|
132
|
+
Supporting infrastructure:
|
|
133
|
+
|
|
134
|
+
- `config.py` — validated runtime config (pydantic-settings, `CONEREPLAY_*` env)
|
|
135
|
+
- `flags.py` — feature flags (`CONEREPLAY_FLAGS_*` env)
|
|
136
|
+
- `logging_setup.py` — structured text/JSON logging
|
|
137
|
+
- `audit.py` — append-only JSONL audit trail for compliance
|
|
138
|
+
- `core/schemas.py` — pydantic contract models for trace + modification JSON
|
|
139
|
+
|
|
140
|
+
## Configuration
|
|
141
|
+
|
|
142
|
+
All configuration is env-driven with the `CONEREPLAY_` prefix. Defaults
|
|
143
|
+
are safe for local use. Sample overrides:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
export CONEREPLAY_LOG_LEVEL=debug
|
|
147
|
+
export CONEREPLAY_LOG_FORMAT=json
|
|
148
|
+
export CONEREPLAY_DATA_DIR=/var/lib/conereplay
|
|
149
|
+
export CONEREPLAY_AUDIT_LOG_PATH=/var/log/conereplay/audit.jsonl
|
|
150
|
+
export CONEREPLAY_ENABLE_AUDIT=true
|
|
151
|
+
export CONEREPLAY_SERVER_DATABASE_URL=postgresql://...
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
See [docs/configuration.md](docs/configuration.md) (stub — coming soon) or
|
|
155
|
+
`conereplay/config.py` for the full list.
|
|
156
|
+
|
|
157
|
+
## Testing
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
make install-dev # install runtime + dev deps (pytest, ruff, mypy)
|
|
161
|
+
make test # run full pytest suite
|
|
162
|
+
make test-fast # fail-fast + failed-first
|
|
163
|
+
make test-cov # with coverage report (htmlcov/)
|
|
164
|
+
make lint # ruff
|
|
165
|
+
make typecheck # mypy
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
CI (see [.github/workflows/](.github/workflows/)) runs tests + lint +
|
|
169
|
+
typecheck on every push and PR against `main`. Integration tests that
|
|
170
|
+
hit real LLM providers are gated behind `CONEREPLAY_INTEGRATION=1`.
|
|
171
|
+
|
|
172
|
+
## Contributing
|
|
173
|
+
|
|
174
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
175
|
+
|
|
176
|
+
## Security
|
|
177
|
+
|
|
178
|
+
See [SECURITY.md](SECURITY.md) for supply-chain posture and vulnerability
|
|
179
|
+
disclosure. Patent-pending proprietary code; see [LICENSE](LICENSE).
|
|
180
|
+
|
|
181
|
+
## Runbooks
|
|
182
|
+
|
|
183
|
+
Operational procedures live in [runbooks/](runbooks/):
|
|
184
|
+
|
|
185
|
+
- [deployment.md](runbooks/deployment.md) — releases + migrations
|
|
186
|
+
- [on-call.md](runbooks/on-call.md) — incident triage
|
|
187
|
+
- [disaster-recovery.md](runbooks/disaster-recovery.md) — backups + restore
|
|
188
|
+
|
|
189
|
+
## Documentation
|
|
190
|
+
<!-- generated-by: workspace-admin/doc-standardize -->
|
|
191
|
+
- [Handoff](docs/HANDOFF.md)
|
|
192
|
+
- [Backlog](docs/BACKLOG.md)
|
|
193
|
+
- [Architecture](docs/ARCHITECTURE.md)
|
|
194
|
+
- [Local Development](docs/LOCAL_DEVELOPMENT.md)
|
|
195
|
+
- [Testing](docs/TESTING.md)
|
|
196
|
+
- [Infrastructure](docs/INFRASTRUCTURE.md)
|
|
197
|
+
- [Roadmap](docs/ROADMAP.md)
|
|
198
|
+
- [Architecture Decisions](docs/decisions/)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
## Evidence and sample
|
|
202
|
+
|
|
203
|
+
- [Sanitized end-to-end migration sample](examples/sanitized_migration/README.md)
|
|
204
|
+
- [Reproducible attribution configuration](examples/sanitized_migration/bisect.json)
|
|
205
|
+
- [Replay benchmark methodology](docs/BENCHMARKS.md)
|
|
206
|
+
|
|
207
|
+
The sample is synthetic and labels fixture measurements separately from live-provider evidence.
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# ConeReplay
|
|
2
|
+
|
|
3
|
+
Pre-deploy regression testing for multi-agent AI. Record traces from your
|
|
4
|
+
production agent app, propose a change (new prompt, new tool response, new
|
|
5
|
+
model), and replay only the events causally affected — everything else is
|
|
6
|
+
served byte-identically from the recording.
|
|
7
|
+
|
|
8
|
+
Patent pending (U.S. Provisional Application **64/043,722**). See
|
|
9
|
+
[VERSIONING.md](VERSIONING.md) for SemVer commitments and
|
|
10
|
+
[docs/trace-format.md](docs/trace-format.md) for the on-disk contract.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install conereplay # core + CLI
|
|
16
|
+
pip install conereplay[server] # hosted trace-store server
|
|
17
|
+
pip install conereplay[langgraph] # LangGraph recording adapter
|
|
18
|
+
pip install conereplay[providers] # anthropic / openai oracle backends
|
|
19
|
+
pip install conereplay[dev] # dev tooling (pytest, ruff, mypy, pip-audit)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Requires Python 3.11+. Core has only two runtime deps (`networkx`,
|
|
23
|
+
`pydantic`, `pydantic-settings`).
|
|
24
|
+
|
|
25
|
+
## CLI quickstart
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Single-trace replay → Markdown report
|
|
29
|
+
conereplay replay \
|
|
30
|
+
--trace examples/trace.json \
|
|
31
|
+
--modify examples/modify.json \
|
|
32
|
+
--report report.md
|
|
33
|
+
|
|
34
|
+
# Corpus-mode regression harness → aggregate report (Markdown or HTML)
|
|
35
|
+
conereplay corpus \
|
|
36
|
+
--traces examples/traces \
|
|
37
|
+
--modify examples/corpus-modify.json \
|
|
38
|
+
--report corpus.html \
|
|
39
|
+
--format html
|
|
40
|
+
|
|
41
|
+
# Emit a Mermaid or Graphviz diagram of a trace's causal DAG
|
|
42
|
+
conereplay diagram \
|
|
43
|
+
--trace examples/trace.json \
|
|
44
|
+
--modify examples/modify.json \
|
|
45
|
+
--format mermaid --out cone.mmd
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
See [docs/cli.md](docs/cli.md) for the full reference.
|
|
49
|
+
|
|
50
|
+
## Library quickstart
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from conereplay import (
|
|
54
|
+
load_trace, ModificationSpec, selective_replay, compute_divergence,
|
|
55
|
+
render_markdown_report,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
trace = load_trace("trace.json")
|
|
59
|
+
mod = ModificationSpec(target_event_id="e3", substituted_output=b"POLICY: 5 days")
|
|
60
|
+
divergent = selective_replay(trace, mod)
|
|
61
|
+
report = compute_divergence(trace, divergent)
|
|
62
|
+
print(render_markdown_report(trace, divergent, mod, report))
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Architecture
|
|
66
|
+
|
|
67
|
+
Four layers. See [ARCHITECTURE.md](ARCHITECTURE.md) for the full picture.
|
|
68
|
+
|
|
69
|
+
| Layer | Purpose | Modules |
|
|
70
|
+
|---|---|---|
|
|
71
|
+
| Core algorithms | Deterministic, pure-stdlib | `core/clock.py`, `core/cone.py`, `core/replay.py`, `core/diff.py` |
|
|
72
|
+
| SDK | Recording + provenance | `sdk/recorder.py`, `sdk/provenance.py`, `sdk/langgraph.py` |
|
|
73
|
+
| Presentation | Reports + diagrams | `core/report.py`, `core/corpus_report.py`, `core/corpus_html.py`, `core/diagram.py` |
|
|
74
|
+
| Server | Hosted trace store | `server/app.py`, `server/models.py` |
|
|
75
|
+
|
|
76
|
+
Supporting infrastructure:
|
|
77
|
+
|
|
78
|
+
- `config.py` — validated runtime config (pydantic-settings, `CONEREPLAY_*` env)
|
|
79
|
+
- `flags.py` — feature flags (`CONEREPLAY_FLAGS_*` env)
|
|
80
|
+
- `logging_setup.py` — structured text/JSON logging
|
|
81
|
+
- `audit.py` — append-only JSONL audit trail for compliance
|
|
82
|
+
- `core/schemas.py` — pydantic contract models for trace + modification JSON
|
|
83
|
+
|
|
84
|
+
## Configuration
|
|
85
|
+
|
|
86
|
+
All configuration is env-driven with the `CONEREPLAY_` prefix. Defaults
|
|
87
|
+
are safe for local use. Sample overrides:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
export CONEREPLAY_LOG_LEVEL=debug
|
|
91
|
+
export CONEREPLAY_LOG_FORMAT=json
|
|
92
|
+
export CONEREPLAY_DATA_DIR=/var/lib/conereplay
|
|
93
|
+
export CONEREPLAY_AUDIT_LOG_PATH=/var/log/conereplay/audit.jsonl
|
|
94
|
+
export CONEREPLAY_ENABLE_AUDIT=true
|
|
95
|
+
export CONEREPLAY_SERVER_DATABASE_URL=postgresql://...
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
See [docs/configuration.md](docs/configuration.md) (stub — coming soon) or
|
|
99
|
+
`conereplay/config.py` for the full list.
|
|
100
|
+
|
|
101
|
+
## Testing
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
make install-dev # install runtime + dev deps (pytest, ruff, mypy)
|
|
105
|
+
make test # run full pytest suite
|
|
106
|
+
make test-fast # fail-fast + failed-first
|
|
107
|
+
make test-cov # with coverage report (htmlcov/)
|
|
108
|
+
make lint # ruff
|
|
109
|
+
make typecheck # mypy
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
CI (see [.github/workflows/](.github/workflows/)) runs tests + lint +
|
|
113
|
+
typecheck on every push and PR against `main`. Integration tests that
|
|
114
|
+
hit real LLM providers are gated behind `CONEREPLAY_INTEGRATION=1`.
|
|
115
|
+
|
|
116
|
+
## Contributing
|
|
117
|
+
|
|
118
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
119
|
+
|
|
120
|
+
## Security
|
|
121
|
+
|
|
122
|
+
See [SECURITY.md](SECURITY.md) for supply-chain posture and vulnerability
|
|
123
|
+
disclosure. Patent-pending proprietary code; see [LICENSE](LICENSE).
|
|
124
|
+
|
|
125
|
+
## Runbooks
|
|
126
|
+
|
|
127
|
+
Operational procedures live in [runbooks/](runbooks/):
|
|
128
|
+
|
|
129
|
+
- [deployment.md](runbooks/deployment.md) — releases + migrations
|
|
130
|
+
- [on-call.md](runbooks/on-call.md) — incident triage
|
|
131
|
+
- [disaster-recovery.md](runbooks/disaster-recovery.md) — backups + restore
|
|
132
|
+
|
|
133
|
+
## Documentation
|
|
134
|
+
<!-- generated-by: workspace-admin/doc-standardize -->
|
|
135
|
+
- [Handoff](docs/HANDOFF.md)
|
|
136
|
+
- [Backlog](docs/BACKLOG.md)
|
|
137
|
+
- [Architecture](docs/ARCHITECTURE.md)
|
|
138
|
+
- [Local Development](docs/LOCAL_DEVELOPMENT.md)
|
|
139
|
+
- [Testing](docs/TESTING.md)
|
|
140
|
+
- [Infrastructure](docs/INFRASTRUCTURE.md)
|
|
141
|
+
- [Roadmap](docs/ROADMAP.md)
|
|
142
|
+
- [Architecture Decisions](docs/decisions/)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
## Evidence and sample
|
|
146
|
+
|
|
147
|
+
- [Sanitized end-to-end migration sample](examples/sanitized_migration/README.md)
|
|
148
|
+
- [Reproducible attribution configuration](examples/sanitized_migration/bisect.json)
|
|
149
|
+
- [Replay benchmark methodology](docs/BENCHMARKS.md)
|
|
150
|
+
|
|
151
|
+
The sample is synthetic and labels fixture measurements separately from live-provider evidence.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""ConeReplay performance benchmarks.
|
|
2
|
+
|
|
3
|
+
Reproduces the performance bound recited in Claim 14 of U.S. Provisional
|
|
4
|
+
Application 64/043,722 (see key_rotaton/supporting/claims.md):
|
|
5
|
+
|
|
6
|
+
Cone computation for a 100-agent-turn trace completes in < 1s on a
|
|
7
|
+
single modern CPU core; selective replay achieves >= 80% reduction in
|
|
8
|
+
events that must be re-executed vs naive full re-execution.
|
|
9
|
+
|
|
10
|
+
Run from repo root:
|
|
11
|
+
|
|
12
|
+
python -m benchmarks
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
__all__ = ["synthesize_trace", "run_benchmarks", "render_results_markdown"]
|
|
18
|
+
|
|
19
|
+
from .bench import render_results_markdown, run_benchmarks
|
|
20
|
+
from .synth import synthesize_trace
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"""Benchmark runner for cone computation + selective replay.
|
|
2
|
+
|
|
3
|
+
Runs a sweep of trace sizes, measures wall-clock time for
|
|
4
|
+
``compute_causal_cone`` and ``selective_replay``, and reports the event-
|
|
5
|
+
reduction ratio (events served byte-identically vs events re-executed) as
|
|
6
|
+
a proxy for the Claim 14 token-reduction metric.
|
|
7
|
+
|
|
8
|
+
Emits CSV to stdout and a human-readable Markdown summary if invoked as
|
|
9
|
+
``python -m benchmarks``.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import csv
|
|
15
|
+
import io
|
|
16
|
+
import sys
|
|
17
|
+
import time
|
|
18
|
+
from dataclasses import dataclass
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
|
|
21
|
+
from conereplay.core.cone import compute_causal_cone
|
|
22
|
+
from conereplay.core.replay import ModificationSpec, selective_replay
|
|
23
|
+
|
|
24
|
+
from .synth import synthesize_trace
|
|
25
|
+
|
|
26
|
+
# Sweep sizes: 50, 100 (Claim 14 target), 250, 500, 1000 total events over
|
|
27
|
+
# representative agent counts (4-8). Target selection: the event at 25% of
|
|
28
|
+
# the trace — far enough in that there are upstream ancestors, far enough
|
|
29
|
+
# from the end that many events remain out-of-cone.
|
|
30
|
+
DEFAULT_SWEEP = [(10, 5), (20, 5), (50, 5), (125, 4), (125, 8)]
|
|
31
|
+
TARGET_FRACTION = 0.25
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@dataclass(frozen=True)
|
|
35
|
+
class Row:
|
|
36
|
+
n_turns: int
|
|
37
|
+
n_agents: int
|
|
38
|
+
n_events: int
|
|
39
|
+
cone_size: int
|
|
40
|
+
event_reduction_pct: float
|
|
41
|
+
cone_time_ms: float
|
|
42
|
+
replay_time_ms: float
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def run_benchmarks(sweep: list[tuple[int, int]] | None = None) -> list[Row]:
|
|
46
|
+
"""Run the benchmark sweep and return per-size rows."""
|
|
47
|
+
sweep = sweep or DEFAULT_SWEEP
|
|
48
|
+
out: list[Row] = []
|
|
49
|
+
for n_turns, n_agents in sweep:
|
|
50
|
+
trace = synthesize_trace(n_turns, n_agents)
|
|
51
|
+
target_idx = max(0, int(len(trace) * TARGET_FRACTION))
|
|
52
|
+
target_id = trace[target_idx].event_id
|
|
53
|
+
modification = ModificationSpec(
|
|
54
|
+
target_event_id=target_id,
|
|
55
|
+
substituted_output=b"MODIFIED_OUTPUT_FOR_BENCH",
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
# Warm-up + measure (single-shot is adequate for pure-Python algorithms).
|
|
59
|
+
t0 = time.perf_counter()
|
|
60
|
+
cone = compute_causal_cone(target_id, trace)
|
|
61
|
+
t1 = time.perf_counter()
|
|
62
|
+
|
|
63
|
+
t2 = time.perf_counter()
|
|
64
|
+
selective_replay(trace, modification)
|
|
65
|
+
t3 = time.perf_counter()
|
|
66
|
+
|
|
67
|
+
reduction = (1.0 - (len(cone) / len(trace))) * 100.0 if trace else 0.0
|
|
68
|
+
out.append(
|
|
69
|
+
Row(
|
|
70
|
+
n_turns=n_turns,
|
|
71
|
+
n_agents=n_agents,
|
|
72
|
+
n_events=len(trace),
|
|
73
|
+
cone_size=len(cone),
|
|
74
|
+
event_reduction_pct=reduction,
|
|
75
|
+
cone_time_ms=(t1 - t0) * 1000.0,
|
|
76
|
+
replay_time_ms=(t3 - t2) * 1000.0,
|
|
77
|
+
)
|
|
78
|
+
)
|
|
79
|
+
return out
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def rows_to_csv(rows: list[Row]) -> str:
|
|
83
|
+
buf = io.StringIO()
|
|
84
|
+
w = csv.writer(buf)
|
|
85
|
+
w.writerow(
|
|
86
|
+
[
|
|
87
|
+
"n_turns",
|
|
88
|
+
"n_agents",
|
|
89
|
+
"n_events",
|
|
90
|
+
"cone_size",
|
|
91
|
+
"event_reduction_pct",
|
|
92
|
+
"cone_time_ms",
|
|
93
|
+
"replay_time_ms",
|
|
94
|
+
]
|
|
95
|
+
)
|
|
96
|
+
for r in rows:
|
|
97
|
+
w.writerow(
|
|
98
|
+
[
|
|
99
|
+
r.n_turns,
|
|
100
|
+
r.n_agents,
|
|
101
|
+
r.n_events,
|
|
102
|
+
r.cone_size,
|
|
103
|
+
f"{r.event_reduction_pct:.2f}",
|
|
104
|
+
f"{r.cone_time_ms:.3f}",
|
|
105
|
+
f"{r.replay_time_ms:.3f}",
|
|
106
|
+
]
|
|
107
|
+
)
|
|
108
|
+
return buf.getvalue()
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def render_results_markdown(rows: list[Row]) -> str:
|
|
112
|
+
lines: list[str] = [
|
|
113
|
+
"# ConeReplay Benchmark Results",
|
|
114
|
+
"",
|
|
115
|
+
"Auto-generated by `python -m benchmarks`. Timings are wall-clock",
|
|
116
|
+
"single-shot measurements on the machine that built the commit; use",
|
|
117
|
+
"them as ballparks, not guarantees.",
|
|
118
|
+
"",
|
|
119
|
+
"The Claim 14 performance bound recited in U.S. Provisional 64/043,722",
|
|
120
|
+
"is **cone computation in under 1 second on a single core for a 100-",
|
|
121
|
+
"agent-turn trace**. This suite measures that bound directly plus the",
|
|
122
|
+
"end-to-end selective-replay time and the event-reduction ratio (events",
|
|
123
|
+
"served byte-identically vs events re-executed).",
|
|
124
|
+
"",
|
|
125
|
+
"The patent's second bound — ~85% token-cost reduction vs naive full",
|
|
126
|
+
"re-execution — is oracle-dependent and requires a Bounded-LLM oracle",
|
|
127
|
+
"plus real trace data to quantify. The identity oracle shipped in the",
|
|
128
|
+
"package does not make LLM calls, so a synthetic token benchmark here",
|
|
129
|
+
"would be misleading; see `docs/trace-format.md` for the measurement",
|
|
130
|
+
"methodology to use with a live BoundedLLMOracle.",
|
|
131
|
+
"",
|
|
132
|
+
"| n_turns | n_agents | n_events | cone_size | out-of-cone | cone (ms) | replay (ms) |",
|
|
133
|
+
"|---:|---:|---:|---:|---:|---:|---:|",
|
|
134
|
+
]
|
|
135
|
+
for r in rows:
|
|
136
|
+
lines.append(
|
|
137
|
+
f"| {r.n_turns} | {r.n_agents} | {r.n_events} | {r.cone_size} | "
|
|
138
|
+
f"{r.event_reduction_pct:.1f}% | {r.cone_time_ms:.3f} | {r.replay_time_ms:.3f} |"
|
|
139
|
+
)
|
|
140
|
+
lines += [
|
|
141
|
+
"",
|
|
142
|
+
"## Claim 14 — cone-time gate",
|
|
143
|
+
"",
|
|
144
|
+
]
|
|
145
|
+
hit_100 = [r for r in rows if r.n_events >= 100]
|
|
146
|
+
if hit_100:
|
|
147
|
+
slowest = max(r.cone_time_ms for r in hit_100)
|
|
148
|
+
fastest = min(r.cone_time_ms for r in hit_100)
|
|
149
|
+
status = "PASS" if slowest < 1000.0 else "FAIL"
|
|
150
|
+
lines.append(
|
|
151
|
+
f"- Cone time for n_events >= 100: range **{fastest:.3f} ms – "
|
|
152
|
+
f"{slowest:.3f} ms** across {len(hit_100)} sweep sizes "
|
|
153
|
+
f"(target < 1000 ms). **{status}**."
|
|
154
|
+
)
|
|
155
|
+
else:
|
|
156
|
+
lines.append("- Sweep did not include n_events >= 100.")
|
|
157
|
+
lines.append("")
|
|
158
|
+
return "\n".join(lines)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def main() -> int:
|
|
162
|
+
rows = run_benchmarks()
|
|
163
|
+
sys.stdout.write(rows_to_csv(rows))
|
|
164
|
+
results_path = Path(__file__).parent / "RESULTS.md"
|
|
165
|
+
results_path.write_text(render_results_markdown(rows), encoding="utf-8")
|
|
166
|
+
sys.stderr.write(f"benchmarks: wrote {results_path}\n")
|
|
167
|
+
return 0
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
if __name__ == "__main__":
|
|
171
|
+
raise SystemExit(main())
|