Skip to content

Commit 384edde

Browse files
copyleftdevclaude
andauthored
docs: cover all four examples in README + mdbook (#68)
The README Examples section only listed stock_anomalies.py, and the mdbook had no examples coverage. Expand the README to all four examples (stock, journal, polymarket, synergy) and add a "Worked examples" page to the book (new docs/src/examples.md + SUMMARY entry) framing them as consuming the tq1 contract — with the agent-calc synergy as the "contracts composing" showcase. Docs-only; the book's changelog is already an {{#include}} of CHANGELOG.md. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 9130a57 commit 384edde

3 files changed

Lines changed: 59 additions & 4 deletions

File tree

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,20 @@ Install: `cargo install anomalyx`.
116116

117117
## Examples
118118

119-
[`examples/stock_anomalies.py`](examples/README.md) fetches a stock's history
120-
from Yahoo Finance and finds its anomalous trading days — or its distributional
121-
drift against another ticker — as a worked example of consuming the `tq1`
122-
envelope (handles mapped back to dates).
119+
Worked examples of *consuming the `tq1` contract* on real data — they parse the
120+
dense JSON envelope and map handles back to time, never scrape pretty text. See
121+
[`examples/`](examples/README.md) for details and how to run each.
122+
123+
- [`stock_anomalies.py`](examples/README.md#stock_anomaliespy) — anomalous
124+
trading days (and distributional drift vs. another ticker) from Yahoo Finance.
125+
- [`journal_anomalies.py`](examples/README.md#journal_anomaliespy) — anomalies in
126+
the systemd journal, piped from `journalctl -o json`.
127+
- [`polymarket_anomalies.py`](examples/README.md#polymarket_anomaliespy)
128+
information shocks and odds regime shifts in a Polymarket prediction market.
129+
- [`synergy_market.py`](examples/README.md#synergy_marketpy) — anomalyx paired
130+
with [`agent-calc`](https://github.com/copyleftdev/agent-calc): anomalyx
131+
*finds* the anomalies, the exact-math kernel *proves* what they mean (tail
132+
probability, a t-test across the regime break, exact correlations).
123133

124134
## Anomaly taxonomy
125135

docs/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- [Validation against NIST](./validation.md)
1313
- [Architecture](./architecture.md)
1414
- [Quality gates](./gates.md)
15+
- [Worked examples](./examples.md)
1516

1617
---
1718

docs/src/examples.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Worked examples
2+
3+
The repository's [`examples/`](https://github.com/copyleftdev/anomalyx/tree/main/examples)
4+
directory holds small, runnable programs that use anomalyx on **real data**. They
5+
exist to demonstrate one thing the contract makes possible: an agent (or a
6+
30-line script) can *consume the `tq1` envelope directly* — parse the dense
7+
finding rows and the dict-pinned string table, then map each
8+
[handle](./envelope.md) back to a row, cell, or timestamp — rather than scraping
9+
human-readable text.
10+
11+
They live outside the Cargo workspace and shell out to the installed `anomalyx`
12+
binary, so they have no effect on the build or the [quality gates](./gates.md).
13+
Each mirrors anomalyx's exit code (`0` clean, `1` anomalies, `2` error).
14+
15+
## The examples
16+
17+
| Example | Data | What it surfaces |
18+
|---|---|---|
19+
| `stock_anomalies.py` | Yahoo Finance daily history | anomalous trading days; distributional drift vs. another ticker |
20+
| `journal_anomalies.py` | `journalctl -o json` (systemd) | rare priorities, bursts, per-unit content spikes; drift between two windows |
21+
| `polymarket_anomalies.py` | Polymarket public APIs | information shocks (`point`/`mv`) and odds regime shifts (`coll.cusum`) |
22+
| `synergy_market.py` | Yahoo Finance + `agent-calc` | anomalyx *finds*; the exact-math kernel *proves* (tail probability, a t-test across the regime break, exact correlations) |
23+
24+
Each maps the handle in every finding back to a calendar date / timestamp,
25+
so the output reads as *"this day, this column, this kind of deviation"*.
26+
27+
## Contracts composing with contracts
28+
29+
`synergy_market.py` is the clearest illustration of why a machine-readable
30+
contract matters. anomalyx is **descriptive and assumption-free** — it reports
31+
*which* days and regimes broke the pattern (`point.modz`, `mv.mahalanobis`,
32+
`coll.cusum`), never assuming a distribution. Its findings then flow, as typed
33+
JSON, straight into [`agent-calc`](https://github.com/copyleftdev/agent-calc)
34+
a sibling contract-first CLI that does **exact** statistics: the return
35+
distribution's fat-tailed kurtosis, the worst day's tail probability under a
36+
fitted Gaussian (routinely *one-in-millions* — i.e. the naive risk model is what
37+
is broken), a two-sample *t*-test across the detected regime break (a real shift
38+
in the *mean*, or only the trajectory?), and exact correlations across a basket.
39+
40+
Two executables, two contracts, no prose and no float drift in between — which is
41+
the whole thesis: *the executable is the contract.*
42+
43+
See [`examples/README.md`](https://github.com/copyleftdev/anomalyx/blob/main/examples/README.md)
44+
for the exact commands and prerequisites.

0 commit comments

Comments
 (0)