math-scout 0.2.0a2__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.
Potentially problematic release.
This version of math-scout might be problematic. Click here for more details.
- math_scout-0.2.0a2/.github/dependabot.yml +10 -0
- math_scout-0.2.0a2/.github/workflows/ci.yml +41 -0
- math_scout-0.2.0a2/.github/workflows/release.yml +99 -0
- math_scout-0.2.0a2/.gitignore +20 -0
- math_scout-0.2.0a2/AGENTS.md +92 -0
- math_scout-0.2.0a2/CHANGELOG.md +261 -0
- math_scout-0.2.0a2/CLAUDE.md +1 -0
- math_scout-0.2.0a2/CONTRIBUTING.md +51 -0
- math_scout-0.2.0a2/LICENSE +21 -0
- math_scout-0.2.0a2/PKG-INFO +348 -0
- math_scout-0.2.0a2/README.md +324 -0
- math_scout-0.2.0a2/pyproject.toml +58 -0
- math_scout-0.2.0a2/src/math_scout/__init__.py +5 -0
- math_scout-0.2.0a2/src/math_scout/cli.py +196 -0
- math_scout-0.2.0a2/src/math_scout/prompts/adversarial_skeptic.md +54 -0
- math_scout-0.2.0a2/src/math_scout/prompts/claim_auditor.md +87 -0
- math_scout-0.2.0a2/src/math_scout/prompts/exposition_referee.md +55 -0
- math_scout-0.2.0a2/src/math_scout/prompts/final_referee.md +119 -0
- math_scout-0.2.0a2/src/math_scout/prompts/formal_verifier.md +64 -0
- math_scout-0.2.0a2/src/math_scout/prompts/notation_auditor.md +68 -0
- math_scout-0.2.0a2/src/math_scout/prompts/review_protocol.md +152 -0
- math_scout-0.2.0a2/src/math_scout/providers/__init__.py +61 -0
- math_scout-0.2.0a2/src/math_scout/providers/anthropic.py +233 -0
- math_scout-0.2.0a2/src/math_scout/providers/base.py +200 -0
- math_scout-0.2.0a2/src/math_scout/providers/openai.py +300 -0
- math_scout-0.2.0a2/src/math_scout/providers/registry.py +47 -0
- math_scout-0.2.0a2/src/math_scout/reviewer.py +1719 -0
- math_scout-0.2.0a2/tests/test_cli.py +234 -0
- math_scout-0.2.0a2/tests/test_providers.py +342 -0
- math_scout-0.2.0a2/tests/test_reviewer.py +1512 -0
- math_scout-0.2.0a2/uv.lock +525 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["main"]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
concurrency:
|
|
9
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
10
|
+
cancel-in-progress: true
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
test:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
strategy:
|
|
16
|
+
fail-fast: false
|
|
17
|
+
matrix:
|
|
18
|
+
python-version: ["3.11", "3.12"]
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v7
|
|
22
|
+
|
|
23
|
+
- name: Install uv
|
|
24
|
+
uses: astral-sh/setup-uv@v7
|
|
25
|
+
with:
|
|
26
|
+
enable-cache: true
|
|
27
|
+
|
|
28
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
29
|
+
run: uv python install ${{ matrix.python-version }}
|
|
30
|
+
|
|
31
|
+
- name: Install dependencies
|
|
32
|
+
run: uv sync --frozen --python ${{ matrix.python-version }}
|
|
33
|
+
|
|
34
|
+
- name: Lint
|
|
35
|
+
run: uv run ruff check
|
|
36
|
+
|
|
37
|
+
- name: Check formatting
|
|
38
|
+
run: uv run ruff format --check
|
|
39
|
+
|
|
40
|
+
- name: Test
|
|
41
|
+
run: uv run pytest
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types:
|
|
6
|
+
- published
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
concurrency:
|
|
12
|
+
group: pypi-${{ github.event.release.tag_name }}
|
|
13
|
+
cancel-in-progress: false
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
build:
|
|
17
|
+
name: Build and validate distributions
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- name: Checkout release
|
|
22
|
+
uses: actions/checkout@v7
|
|
23
|
+
|
|
24
|
+
- name: Set up Python
|
|
25
|
+
uses: actions/setup-python@v7
|
|
26
|
+
with:
|
|
27
|
+
python-version: "3.14"
|
|
28
|
+
|
|
29
|
+
- name: Install uv
|
|
30
|
+
uses: astral-sh/setup-uv@v7
|
|
31
|
+
with:
|
|
32
|
+
version: "0.12.5"
|
|
33
|
+
|
|
34
|
+
- name: Verify release tag matches package version
|
|
35
|
+
env:
|
|
36
|
+
RELEASE_TAG: ${{ github.event.release.tag_name }}
|
|
37
|
+
run: >-
|
|
38
|
+
python -c 'import os, sys, tomllib; version =
|
|
39
|
+
tomllib.load(open("pyproject.toml",
|
|
40
|
+
"rb"))["project"]["version"]; expected = f"v{version}"; actual
|
|
41
|
+
= os.environ["RELEASE_TAG"]; print(f"release tag: {actual};
|
|
42
|
+
package version: {version}"); sys.exit(0 if actual == expected
|
|
43
|
+
else f"expected release tag {expected}, got {actual}")'
|
|
44
|
+
|
|
45
|
+
- name: Build source and wheel distributions
|
|
46
|
+
run: uv build
|
|
47
|
+
|
|
48
|
+
- name: Validate distribution metadata
|
|
49
|
+
run: uvx twine check dist/*
|
|
50
|
+
|
|
51
|
+
- name: Upload distributions
|
|
52
|
+
uses: actions/upload-artifact@v7
|
|
53
|
+
with:
|
|
54
|
+
name: python-package-distributions
|
|
55
|
+
path: dist/
|
|
56
|
+
if-no-files-found: error
|
|
57
|
+
|
|
58
|
+
publish-testpypi:
|
|
59
|
+
name: Publish distributions to TestPyPI
|
|
60
|
+
needs: build
|
|
61
|
+
runs-on: ubuntu-latest
|
|
62
|
+
environment:
|
|
63
|
+
name: testpypi
|
|
64
|
+
url: https://test.pypi.org/p/math-scout
|
|
65
|
+
permissions:
|
|
66
|
+
id-token: write
|
|
67
|
+
|
|
68
|
+
steps:
|
|
69
|
+
- name: Download distributions
|
|
70
|
+
uses: actions/download-artifact@v8
|
|
71
|
+
with:
|
|
72
|
+
name: python-package-distributions
|
|
73
|
+
path: dist/
|
|
74
|
+
|
|
75
|
+
- name: Publish distributions to TestPyPI
|
|
76
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
77
|
+
with:
|
|
78
|
+
repository-url: https://test.pypi.org/legacy/
|
|
79
|
+
skip-existing: true
|
|
80
|
+
|
|
81
|
+
publish:
|
|
82
|
+
name: Publish distributions to PyPI
|
|
83
|
+
needs: publish-testpypi
|
|
84
|
+
runs-on: ubuntu-latest
|
|
85
|
+
environment:
|
|
86
|
+
name: pypi
|
|
87
|
+
url: https://pypi.org/p/math-scout
|
|
88
|
+
permissions:
|
|
89
|
+
id-token: write
|
|
90
|
+
|
|
91
|
+
steps:
|
|
92
|
+
- name: Download distributions
|
|
93
|
+
uses: actions/download-artifact@v8
|
|
94
|
+
with:
|
|
95
|
+
name: python-package-distributions
|
|
96
|
+
path: dist/
|
|
97
|
+
|
|
98
|
+
- name: Publish distributions to PyPI
|
|
99
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
__pycache__
|
|
2
|
+
*.py[cod]
|
|
3
|
+
|
|
4
|
+
# Environments
|
|
5
|
+
.venv/
|
|
6
|
+
.env
|
|
7
|
+
|
|
8
|
+
# Build artifacts
|
|
9
|
+
dist/
|
|
10
|
+
build/
|
|
11
|
+
*.egg-info/
|
|
12
|
+
|
|
13
|
+
# Tool caches
|
|
14
|
+
.pytest_cache/
|
|
15
|
+
.ruff_cache/
|
|
16
|
+
|
|
17
|
+
# Default output directory of the pipeline
|
|
18
|
+
review/
|
|
19
|
+
|
|
20
|
+
.DS_Store
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to AI agents when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## What this project does
|
|
6
|
+
|
|
7
|
+
`math-scout` is a multi-agent pipeline that reviews mathematical papers written in LaTeX. It splits a `.tex` file into sections, runs five specialized Claude-based reviewers in sequence — three over each section, two over the whole source — and synthesizes a final referee report in markdown.
|
|
8
|
+
|
|
9
|
+
## Running the pipeline
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
uv sync
|
|
13
|
+
uv run math-scout path/to/paper.tex [--output <dir>]
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Credentials come from the Anthropic SDK's own resolution: `ANTHROPIC_API_KEY` in the environment, or a profile stored by `ant auth login`. Never pass a key inline on the command line.
|
|
17
|
+
|
|
18
|
+
Outputs land in `<input_dir>/review/` by default (override with `--output`):
|
|
19
|
+
- `review/chunks/<NN>_<section>.tex` — the exact LaTeX each reviewer saw
|
|
20
|
+
- `review/reviews/<NN>_<section>_<reviewer>.json` — per-chunk reviewer output; the source of truth for issues
|
|
21
|
+
- `review/state.json` — resume bookkeeping: completed reviews keyed by chunk hash, plus the settings that produced them
|
|
22
|
+
- `review/all_issues.json` — the issues behind the current report, rebuilt from `reviews/` each run
|
|
23
|
+
- `review/issues.jsonl` — append-only log of every issue ever produced here; may contain superseded entries
|
|
24
|
+
- `review/final_report.md` — final synthesis in markdown
|
|
25
|
+
|
|
26
|
+
Use `--dry-run` to count tokens and estimate cost without sending generation requests, and `--yes` to skip the confirmation prompt in non-interactive contexts.
|
|
27
|
+
|
|
28
|
+
Exit codes: `0` clean (or declined at the prompt — declining is a choice, not an error), `1` finished with failed reviewer calls, `2` misconfigured (no credentials, unknown or unusable model, nothing to review, no terminal to confirm on without `--yes`).
|
|
29
|
+
|
|
30
|
+
## Layout
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
src/math_scout/reviewer.py # all pipeline logic
|
|
34
|
+
src/math_scout/cli.py # argparse, credential pre-flight, exit codes
|
|
35
|
+
src/math_scout/prompts/*.md # shared protocol, reviewer and final-referee prompts (package data)
|
|
36
|
+
tests/test_reviewer.py # pure-function tests; no network, no credentials
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Architecture
|
|
40
|
+
|
|
41
|
+
**Pipeline stages** (`run_pipeline`):
|
|
42
|
+
1. Load `.tex`, inlining `\input{}`/`\include{}` (`resolve_inputs`), then extract global context (title + abstract + preamble + up to 15 theorems via regex)
|
|
43
|
+
2. Split into `Chunk`s by `\section{}` boundaries; skip non-mathematical sections (References, Bibliography, Acknowledgments). Body text before the first `\section` becomes a "Front matter" chunk when it holds enough prose
|
|
44
|
+
3. For each chunk × each section-scoped reviewer: call Claude, save per-chunk JSON, append issues to `issues.jsonl`
|
|
45
|
+
4. Then once over the whole source (a `Chunk` named `WHOLE_PAPER_NAME`) for each paper-scoped reviewer, so they see every section finding
|
|
46
|
+
5. Run final referee over the full paper + all issues → `final_report.md`
|
|
47
|
+
|
|
48
|
+
`cli.py` calls `check_access` first: a free `count_tokens` probe per distinct model that validates credentials and model IDs before anything is written or any money is spent.
|
|
49
|
+
|
|
50
|
+
**Reviewers** (defined in `REVIEWER_SPECS` as `ReviewerSpec(prompt, tier, thinking, scope)`, resolved to `ReviewerConfig` by `load_prompts`):
|
|
51
|
+
|
|
52
|
+
| Name | Tier | Thinking | Scope | Focus |
|
|
53
|
+
|---|---|---|---|---|
|
|
54
|
+
| `FormalVerifier` | strong | adaptive | section | Proof gaps, invalid inferences, hidden assumptions, load-bearing computations |
|
|
55
|
+
| `AdversarialSkeptic` | strong | adaptive | section | Edge cases, brittle arguments, suspicious steps |
|
|
56
|
+
| `ExpositionReferee` | fast | disabled | section | Readability, missing intuition, proof strategy clarity |
|
|
57
|
+
| `NotationAuditor` | fast | adaptive | **paper** | Notation consistency, convention drift, undefined and broken references, circularity |
|
|
58
|
+
| `ClaimAuditor` | strong | adaptive | **paper** | Overclaiming: abstract and introduction against what the theorems prove |
|
|
59
|
+
|
|
60
|
+
Tiers map to concrete model IDs via `--strong-model` / `--fast-model`, defaulting to `DEFAULT_MODEL_STRONG` and `DEFAULT_MODEL_FAST`. Every reviewer returns the same JSON schema: `{ issues: [ { title, severity, type, location, quote, analysis, suggested_fix, confidence } ] }`.
|
|
61
|
+
|
|
62
|
+
Thinking is a property of the task, not the tier — and scope can move a reviewer across that line, as it did for `NotationAuditor`: whole-paper consistency means tracing the order results are established in and collapsing every occurrence of a symbol into one finding, which is not the lookup that per-section consistency was. `ReviewerConfig.thinking_config` turns the flag into the API parameter. The final referee always thinks. `--effort` applies uniformly to every call.
|
|
63
|
+
|
|
64
|
+
Scope is also a property of the task. Consistency and overclaiming are relations between two places in the document, so they are not decidable from one section; asking a section-scoped reviewer for them yields guesses that the final referee has to pay to discard. `LoadedPrompts.scoped()` partitions the reviewers, and `_format_review_target` labels the payload `SECTION UNDER REVIEW` or `FULL PAPER UNDER REVIEW` accordingly.
|
|
65
|
+
|
|
66
|
+
**Prompt composition.** Every reviewer call sends three system blocks: global context, `prompts/review_protocol.md`, then that reviewer's own prompt. The protocol holds the payload map, the single severity and confidence scales, and the field-by-field output contract; the individual prompts hold only a lane and its exclusions. The final referee passes `review_protocol=None` — it writes markdown, not the issue schema.
|
|
67
|
+
|
|
68
|
+
Each block is a cache breakpoint, and the first two are byte-identical across reviewers, so reviewers on one model share a prefix instead of writing their own. This also fixes a silent failure: the minimum cacheable prefix is model-dependent (512 tokens on Opus 5, 1024 on Sonnet 5), and a short global context did not reach it on its own; the protocol block is ~2k tokens, so the combined prefix always clears it. The saving is still **unmeasured** — check `usage.cache_read_input_tokens` before quoting a number, and consider a `ttl: "1h"` breakpoint if entries are expiring between calls.
|
|
69
|
+
|
|
70
|
+
The final referee (`prompts/final_referee.md`) receives global context + all issues + full paper and produces a structured markdown report with seven fixed sections. When reviewer calls have failed, `format_coverage_note` goes in as its own message block ahead of `DETECTED ISSUES` so the report states its own limits without the note reading as a finding.
|
|
71
|
+
|
|
72
|
+
## Invariants worth preserving
|
|
73
|
+
|
|
74
|
+
- **Resume hangs off `state.json`, not off filenames.** Chunks are identified by `chunk_key` (a hash of title + text), so an inserted section does not shift every identity, and an edited section is re-reviewed while its neighbours are not. Filenames carry an index prefix so output sorts in document order, and `retarget_reviews` moves a reused review whenever its chunk's position changes, so that ordering stays true across runs. `sweep` then deletes anything neither the current chunks nor `state.json` account for. `state.json` remains the authority on which file holds which chunk's review; the filenames are for humans. A settings change (models, effort, max tokens, or the prompt text itself via `prompts_digest`) is refused rather than silently reusing incomparable reviews. The whole-paper chunk's key must be passed to `state.prune` alongside the section keys, or its reviews are discarded on every resume.
|
|
75
|
+
- **Existing output is untrusted input.** A paper bundle can arrive with `review/state.json`
|
|
76
|
+
and a pre-populated output tree. Stored review names must remain validated direct
|
|
77
|
+
children of `reviews/`, and pipeline-managed directories and files must never follow
|
|
78
|
+
symbolic links; otherwise resume moves or ordinary writes can escape the output tree.
|
|
79
|
+
- **`reviews/*.json` is the source of truth for issues, not `issues.jsonl`.** `all_issues.json` is rebuilt from the stored reviews each run, so a crash between writing a review and appending to the log costs at most a repeated call. `issues.jsonl` is an append-only log and may hold superseded entries.
|
|
80
|
+
- **Section structure is matched against `mask_non_content(tex)`**, never the raw text, so a commented-out or verbatim-quoted `\section` neither invents a chunk nor truncates its neighbour. The mask preserves character offsets, so matches still index into the original.
|
|
81
|
+
- **`\input` targets are confined to the document's directory** (`_is_within`). Papers come from other people; without this, `\input{/etc/passwd}` would exfiltrate to the API.
|
|
82
|
+
- **Reviewer prompts keep their lanes.** Each prompt says what *not* to flag, naming the reviewer that covers it. Widening one produces duplicates, not coverage. Anything that should hold for every reviewer belongs in `review_protocol.md`, not copied into five files where it will drift.
|
|
83
|
+
- **Every schema field a reviewer fills is read downstream.** `_format_issue_full` carries `type`, `location`, `quote` and `confidence` into the final referee: the quote is how it checks a finding against the source, and the confidence is how it tells a demonstrated defect from a lead. A field the prompts calibrate but the report never sees is wasted tokens on every call.
|
|
84
|
+
- **No pass may assert prior art.** Nothing here can read a reference, so a claim that a result is already known would be a fabrication. The protocol, `claim_auditor.md` and `final_referee.md` each forbid it independently; keep all three.
|
|
85
|
+
- **Errors that would recur identically** (`FATAL_API_ERRORS`) stop the run; everything else is recorded as a per-reviewer failure and the run continues.
|
|
86
|
+
- **Every generation call streams** (`messages.stream`), which is what allows `max_tokens` above 21,333 — non-streaming requests estimated to run past ten minutes are refused by the SDK. `get_final_message()` returns a `ParsedMessage`, so `output_format` and `.parsed_output` work exactly as they did under `messages.parse`. `MAX_OUTPUT_TOKENS` (64000) is only a typo guard: every model in `MODEL_SUPPORT` allows at least 64K output tokens, and the Opus 5 and Sonnet 5 families allow 128K.
|
|
87
|
+
- **`max_tokens` is headroom, not a budget to spend.** Thinking and the response share it, and a call cut off mid-JSON is billed in full and yields nothing — so a cap set too low *causes* cost rather than limiting it. `DEFAULT_MAX_TOKENS` is 32000 for that reason. When a reviewer truncates anyway, `call_reviewer` retries once at one `--effort` level down (`lower_effort`) and `run_final_referee` does the same; a second truncation is a real failure. Note that a retried review was produced at lower effort than `state.json` records for the run.
|
|
88
|
+
- **Tests must not need the network or credentials.** Stub the client, as `FakeClient` does.
|
|
89
|
+
|
|
90
|
+
## Dependencies
|
|
91
|
+
|
|
92
|
+
`anthropic`, `pydantic`, `rich`; `pytest` and `ruff` for development. All declared in `pyproject.toml` and locked in `uv.lock` — install with `uv sync`.
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format is based on
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to
|
|
5
|
+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html) — with the caveat that before
|
|
6
|
+
1.0 anything may change between releases.
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.2.0a2] — 2026-08-26
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Renamed the project, package, and command from `llm-reviewer` to `math-scout`.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- Resume state can no longer name a review outside `reviews/`, and pipeline-managed
|
|
19
|
+
output paths refuse symbolic links. A crafted `review/state.json` in a paper bundle
|
|
20
|
+
could previously move an arbitrary file during resume bookkeeping; pre-positioned
|
|
21
|
+
output symlinks could likewise redirect chunk or report writes.
|
|
22
|
+
|
|
23
|
+
## [0.2.0a1] — 2026-08-17
|
|
24
|
+
|
|
25
|
+
**This invalidates existing output directories.** State now records qualified Anthropic
|
|
26
|
+
model IDs, so prior state containing bare IDs no longer matches. Delete `review/`, or pass
|
|
27
|
+
a different `--output`; existing paid reviews are not migrated.
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- Native OpenAI Responses API support alongside Anthropic. Explicit model flags require
|
|
32
|
+
`provider:model`, so strong and fast tiers can use different providers while the final
|
|
33
|
+
referee continues to follow the strong tier. Bare model IDs are rejected rather than
|
|
34
|
+
inferred as Anthropic.
|
|
35
|
+
- Provider-neutral generation, token-counting, capability, pricing, retry, and error
|
|
36
|
+
contracts, with credential-free adapter tests bound to both installed SDK signatures.
|
|
37
|
+
- `--preset opus-sonnet` and `--preset sol-luna` select the common Anthropic and OpenAI
|
|
38
|
+
strong/fast pairs; explicit tier flags can override either half of a preset.
|
|
39
|
+
|
|
40
|
+
### Changed
|
|
41
|
+
|
|
42
|
+
- Dry runs group exact token counts by provider-qualified model and keep working when
|
|
43
|
+
pricing metadata is unavailable. Every model in resume settings is stored with its
|
|
44
|
+
provider; historical bare Anthropic state is rejected by the settings-mismatch guard.
|
|
45
|
+
- Prompt caching is translated natively: Anthropic cache controls are preserved, while
|
|
46
|
+
OpenAI GPT-5.6 requests use developer `input_text` breakpoints and a deterministic
|
|
47
|
+
paper-specific cache key.
|
|
48
|
+
- OpenAI Luna dry-run estimates use its current $0.20 input and $1.20 output rates per
|
|
49
|
+
million tokens.
|
|
50
|
+
|
|
51
|
+
## [0.1.0a2] — 2026-08-16
|
|
52
|
+
|
|
53
|
+
**This invalidates existing output directories**, on two counts: the `--max-tokens`
|
|
54
|
+
default has changed, and the reviewer prompts have (see the prompt audit below). Both are
|
|
55
|
+
part of the settings a resume is keyed on. Delete `review/`, or pass a different
|
|
56
|
+
`--output`.
|
|
57
|
+
|
|
58
|
+
### Fixed
|
|
59
|
+
|
|
60
|
+
- Reviewers ran out of output budget mid-answer on ordinary sections and the whole run
|
|
61
|
+
degraded. On one 100k-character paper, 11 of 23 reviewer calls and the final referee
|
|
62
|
+
were cut off before finishing their JSON, and the report was synthesised from partial
|
|
63
|
+
coverage. Truncated calls are billed in full and return nothing usable, so roughly 60%
|
|
64
|
+
of that run's spend bought discarded tokens.
|
|
65
|
+
|
|
66
|
+
The cause was `max_tokens`, which thinking and the response share, pinned at 16000
|
|
67
|
+
because every call was non-streaming — the SDK refuses a non-streaming request
|
|
68
|
+
estimated to run past ten minutes, which capped the budget at 21333. Every generation
|
|
69
|
+
call now streams, so the cap is the model's own output limit instead. This is why
|
|
70
|
+
raising the default is not a cost increase: unused budget is never billed, so the old
|
|
71
|
+
cap was *causing* the spend rather than limiting it.
|
|
72
|
+
|
|
73
|
+
Only the reviewer with thinking disabled was unaffected, on every section size — which
|
|
74
|
+
is what identified thinking as what the budget was going to.
|
|
75
|
+
|
|
76
|
+
- `chunks/` and `reviews/` accumulated files from earlier runs. Nothing removed them, and
|
|
77
|
+
a reused review kept the filename it was first written under, so after inserting or
|
|
78
|
+
deleting a section the index prefixes no longer matched the document — `chunks/` could
|
|
79
|
+
hold both `00_Alpha.tex` and `01_Alpha.tex` with no way to tell which was current.
|
|
80
|
+
Reviews are now renamed into their new positions when a chunk moves, and anything
|
|
81
|
+
neither the current chunks nor `state.json` account for is deleted. Nothing is re-run:
|
|
82
|
+
the rename is bookkeeping, not a re-review.
|
|
83
|
+
- The chunk index is three digits, so the prefix still sorts past a hundred sections.
|
|
84
|
+
Existing output directories rename themselves on the next run.
|
|
85
|
+
|
|
86
|
+
### Changed
|
|
87
|
+
|
|
88
|
+
- `--max-tokens` defaults to 32000 (was 16000) and accepts up to 64000 (was 21333). Every
|
|
89
|
+
supported model allows at least 64K output tokens; the Opus 5 and Sonnet 5 families
|
|
90
|
+
allow 128K.
|
|
91
|
+
- A call that exhausts its budget is retried once at one `--effort` level down, trading
|
|
92
|
+
some depth on that section for producing a review at all. A second truncation is
|
|
93
|
+
reported as a failed call and the run continues, as before.
|
|
94
|
+
- `--dry-run` prints two output ceilings rather than one: assuming no call truncates, and
|
|
95
|
+
assuming every call truncates and is retried. The single figure it printed before stopped
|
|
96
|
+
being an upper bound once a call could bill two attempts.
|
|
97
|
+
|
|
98
|
+
Prompt audit: the reviewer set, the prompts, and the plumbing between them.
|
|
99
|
+
|
|
100
|
+
**This invalidates existing output directories.** `run_settings` now records a hash of
|
|
101
|
+
every prompt that shapes a stored review — the protocol and the five reviewer prompts, but
|
|
102
|
+
not `final_referee.md`, which shapes only the report and is regenerated on every run. A
|
|
103
|
+
`review/` produced before this change is refused rather than mixed with findings from the
|
|
104
|
+
new prompts. Delete it, or pass a different `--output`.
|
|
105
|
+
|
|
106
|
+
### Added
|
|
107
|
+
|
|
108
|
+
- `ClaimAuditor`, a fifth reviewer, reading the whole paper: it compares what the abstract
|
|
109
|
+
and introduction promise against what the theorems actually state and prove. Nothing
|
|
110
|
+
previously checked for overclaiming, and the recommendation was purely defect-driven —
|
|
111
|
+
a correct but unremarkable paper scored **Accept**.
|
|
112
|
+
- `prompts/review_protocol.md`, sent to every reviewer ahead of its own prompt. It holds
|
|
113
|
+
one severity scale, one confidence scale, and one field-by-field description of the
|
|
114
|
+
output schema. The four prompts previously carried their own copies, which had drifted,
|
|
115
|
+
and which fed a single filter in the final referee as though they were comparable.
|
|
116
|
+
- A reviewer `scope`: `NotationAuditor` now reads the whole paper in one pass instead of
|
|
117
|
+
each section separately. Consistency is a relation between two occurrences, and it could
|
|
118
|
+
previously see only one of them; its own prompt told it to hedge with "appears to", and
|
|
119
|
+
the final referee had a rule for discarding the false positives that produced. On a
|
|
120
|
+
multi-section paper this is also fewer calls than before.
|
|
121
|
+
- A `# Questions for the authors` section in the report, so a low-confidence finding has
|
|
122
|
+
somewhere to go other than being inflated into a main concern or dropped.
|
|
123
|
+
- Explicit instructions, in three separate prompts, never to assert prior art: nothing
|
|
124
|
+
here can read a reference, so a claim that a result is already known would be invented.
|
|
125
|
+
|
|
126
|
+
### Fixed
|
|
127
|
+
|
|
128
|
+
- Every reviewer prompt told the model to skip concerns already in a `KNOWN ISSUES` block.
|
|
129
|
+
No such block was ever sent — the pipeline sends `DETECTED ISSUES` — so the
|
|
130
|
+
de-duplication instruction had never once fired.
|
|
131
|
+
- `type`, `quote` and `confidence` were collected from every reviewer, written to
|
|
132
|
+
`reviews/*.json`, and then dropped before the final referee saw anything. Four prompts
|
|
133
|
+
were calibrating a confidence score that reached nothing. All three now reach the report,
|
|
134
|
+
and the referee is told how to use them: the quote to check a finding against the source,
|
|
135
|
+
the confidence to tell a demonstrated defect from a lead.
|
|
136
|
+
- The final referee prompt described its input as "deduplicated issues". They were never
|
|
137
|
+
deduplicated. It now says so, and deduplicating is stated as its job.
|
|
138
|
+
- The `COVERAGE GAPS` note about failed reviewer calls was concatenated onto the front of
|
|
139
|
+
the issue list, so it appeared under the `DETECTED ISSUES` heading as though it were a
|
|
140
|
+
finding. It is now its own message block.
|
|
141
|
+
- Nothing checked arithmetic: `FormalVerifier` was told not to look for algebraic mistakes
|
|
142
|
+
and no other reviewer covered them. It now works through computations the argument rests
|
|
143
|
+
on, while still leaving routine algebra alone.
|
|
144
|
+
- Reviewers are now told what they can and cannot see, including that the `## Theorem N`
|
|
145
|
+
headings in the global context are extraction indices rather than the paper's own
|
|
146
|
+
numbering — a reviewer citing "Theorem 3" could mean neither.
|
|
147
|
+
- `ExpositionReferee` findings are capped at `major` and routed to the report's exposition
|
|
148
|
+
section. A hard-to-follow proof was previously able to enter Main concerns beside a
|
|
149
|
+
theorem that does not hold.
|
|
150
|
+
|
|
151
|
+
### Changed
|
|
152
|
+
|
|
153
|
+
- `NotationAuditor` now runs with thinking enabled. Whole-paper scope turned its job into
|
|
154
|
+
tracing the order in which results are actually established and collapsing every
|
|
155
|
+
occurrence of a symbol into one finding — neither is the lookup that per-section
|
|
156
|
+
consistency checking was. It stays on the fast tier: the work is bookkeeping, not
|
|
157
|
+
mathematics.
|
|
158
|
+
- The shared severity scale now says how it applies to findings that are not about
|
|
159
|
+
correctness. Grading exposition and notation purely against the paper's claims left
|
|
160
|
+
them no rung above `minor`, since by construction they leave the claims alone.
|
|
161
|
+
- "A statement carries a hypothesis its proof never uses" and "a proof needs a hypothesis
|
|
162
|
+
its statement does not grant" were claimable by three reviewers under three type slugs,
|
|
163
|
+
and `notation_auditor.md` asserted and disclaimed the same defect twelve lines apart.
|
|
164
|
+
Each direction now has exactly one owner.
|
|
165
|
+
- The final referee's routing rules are ordered and disjoint, so a finding lands in one
|
|
166
|
+
section rather than matching two rules with no stated precedence.
|
|
167
|
+
- "Used but never defined anywhere in the paper" belonged to nobody: section reviewers
|
|
168
|
+
are told to presume such a symbol is defined elsewhere, and nothing picked it up
|
|
169
|
+
afterwards. It is `NotationAuditor`'s, which is the only pass that can see the whole
|
|
170
|
+
document.
|
|
171
|
+
|
|
172
|
+
## [0.1.0a1] — 2026-08-03
|
|
173
|
+
|
|
174
|
+
First public release. Everything before this lived only in the author's working tree.
|
|
175
|
+
|
|
176
|
+
### Added
|
|
177
|
+
|
|
178
|
+
- MIT license, packaging metadata, and a `math-scout` command installable with
|
|
179
|
+
`uvx --from git+https://github.com/nidrissi/math-scout`.
|
|
180
|
+
- Multi-file LaTeX support: `\input{}` and `\include{}` are resolved and inlined before
|
|
181
|
+
chunking, with commented-out references ignored, cycles broken, and missing targets
|
|
182
|
+
warned about rather than fatal.
|
|
183
|
+
- `--yes/-y` for non-interactive runs, plus a clear error instead of an `EOFError`
|
|
184
|
+
traceback when stdin is not a terminal and the flag is absent.
|
|
185
|
+
- `--strong-model`, `--fast-model`, `--max-tokens`, and `--effort` flags. Cost estimation
|
|
186
|
+
covers the current Opus, Sonnet, and Haiku models; unknown model IDs still run, and
|
|
187
|
+
`--dry-run` reports their token counts without a price.
|
|
188
|
+
- Per-reviewer extended thinking, chosen on the shape of each task: `FormalVerifier`,
|
|
189
|
+
`AdversarialSkeptic`, and the final referee think; `NotationAuditor` and
|
|
190
|
+
`ExpositionReferee` do not, because symbol and reference checking is scanning rather
|
|
191
|
+
than reasoning.
|
|
192
|
+
- Invalid invocations are refused before any request: `--max-tokens` above the
|
|
193
|
+
non-streaming ceiling of 21333, and a disabled-thinking reviewer on a model that
|
|
194
|
+
rejects that at `xhigh` or `max` effort.
|
|
195
|
+
- A free pre-flight check that verifies credentials and every model ID before the run
|
|
196
|
+
writes anything or asks for confirmation.
|
|
197
|
+
- Failure reporting: reviewer failures are collected, summarised, passed to the final
|
|
198
|
+
referee so the report states its own coverage gaps, and reflected in the exit code
|
|
199
|
+
(`0` clean, `1` incomplete, `2` misconfigured).
|
|
200
|
+
- Body text between `\begin{document}` and the first `\section` is now reviewed as a
|
|
201
|
+
"Front matter" chunk when it holds enough prose.
|
|
202
|
+
- Test suite, ruff configuration, and GitHub Actions CI on Python 3.11 and 3.12.
|
|
203
|
+
|
|
204
|
+
### Changed
|
|
205
|
+
|
|
206
|
+
- Default models are now `claude-opus-5` and `claude-sonnet-5`. Opus 5 costs the same as
|
|
207
|
+
Opus 4.7 and lowers the minimum cacheable prompt from 2048 to 512 tokens, so short
|
|
208
|
+
global contexts now benefit from prompt caching. Sonnet 5 uses a newer tokenizer that
|
|
209
|
+
produces roughly 30% more tokens for the same text, so the two fast reviewers cost
|
|
210
|
+
proportionally more per run at the same per-token rate.
|
|
211
|
+
- `--max-tokens` defaults to 16000, up from 8192, because it now covers extended thinking
|
|
212
|
+
and response text together. It is capped at 21333, above which the SDK requires
|
|
213
|
+
streaming.
|
|
214
|
+
- A reviewer that runs out of tokens mid-JSON now says so and names the fix, instead of
|
|
215
|
+
reporting a generic "no parsed output".
|
|
216
|
+
- Credentials resolve through the Anthropic SDK, so an `ant auth login` profile works in
|
|
217
|
+
addition to `ANTHROPIC_API_KEY`.
|
|
218
|
+
- Chunk output filenames are prefixed with the section index, so two sections whose titles
|
|
219
|
+
reduce to the same slug no longer overwrite each other.
|
|
220
|
+
- Errors that would recur identically on every call — rejected credentials, an unknown
|
|
221
|
+
model — now stop the run instead of repeating once per reviewer per section.
|
|
222
|
+
- A failure in the final referee pass no longer discards the run; collected issues stay on
|
|
223
|
+
disk and re-running resumes from them.
|
|
224
|
+
- `\title{}` containing braces (for example `\title{Cohomology of $\mathbb{Z}$}`) is now
|
|
225
|
+
extracted correctly.
|
|
226
|
+
|
|
227
|
+
### Fixed
|
|
228
|
+
|
|
229
|
+
- Resume is tracked in `review/state.json` against a hash of each section's text, not by
|
|
230
|
+
the existence of a review file. Previously, editing the paper and re-running silently
|
|
231
|
+
reused reviews of text that no longer existed and reported them as current, while
|
|
232
|
+
inserting a section shifted every filename and duplicated every prior issue in the
|
|
233
|
+
final report. Changing models, effort, or token limits between runs is now refused
|
|
234
|
+
rather than silently ignored.
|
|
235
|
+
- Issues are rebuilt from the stored reviews rather than from `issues.jsonl`, closing the
|
|
236
|
+
window where a crash between writing a review and appending to the log lost findings
|
|
237
|
+
that were sitting intact on disk.
|
|
238
|
+
- Section headings are matched against comment- and verbatim-masked text. A commented-out
|
|
239
|
+
`\section` no longer splits the section it sits in or invents one, and a `\section`
|
|
240
|
+
quoted inside `verbatim` no longer deletes the text that follows it from the review.
|
|
241
|
+
- `\input` and `\include` are confined to the document's own directory. An absolute path
|
|
242
|
+
or a `../` escape previously read the target and sent it to the API.
|
|
243
|
+
- A non-UTF-8 source produces a clear error naming the file instead of an uncaught
|
|
244
|
+
`UnicodeDecodeError`; Latin-1 is common in older LaTeX.
|
|
245
|
+
- The pre-flight reports rate limits and server errors instead of raising them as
|
|
246
|
+
tracebacks, and retries briefly first.
|
|
247
|
+
- `--fast-model anthropic:claude-haiku-4-5` is refused with an explanation: Haiku 4.5
|
|
248
|
+
rejects the effort and thinking settings every call carries, so it could not have
|
|
249
|
+
worked.
|
|
250
|
+
- A typo in the input path no longer leaves an empty output directory behind.
|
|
251
|
+
|
|
252
|
+
### Removed
|
|
253
|
+
|
|
254
|
+
- The unused `RapidFuzz` dependency, and `.github/requirements.txt` in favour of
|
|
255
|
+
`pyproject.toml`.
|
|
256
|
+
|
|
257
|
+
[Unreleased]: https://github.com/nidrissi/math-scout/compare/v0.2.0a2...HEAD
|
|
258
|
+
[0.2.0a2]: https://github.com/nidrissi/math-scout/releases/tag/v0.2.0a2
|
|
259
|
+
[0.2.0a1]: https://github.com/nidrissi/math-scout/releases/tag/v0.2.0a1
|
|
260
|
+
[0.1.0a2]: https://github.com/nidrissi/math-scout/releases/tag/v0.1.0a2
|
|
261
|
+
[0.1.0a1]: https://github.com/nidrissi/math-scout/releases/tag/v0.1.0a1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@AGENTS.md
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for looking. This is alpha software and the most useful contributions right now are
|
|
4
|
+
bug reports — especially papers whose structure breaks the chunker.
|
|
5
|
+
|
|
6
|
+
## Setup
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
git clone https://github.com/nidrissi/math-scout
|
|
10
|
+
cd math-scout
|
|
11
|
+
uv sync
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Before opening a PR
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
uv run ruff check
|
|
18
|
+
uv run ruff format
|
|
19
|
+
uv run pytest
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
CI runs the same checks on Python 3.11 and 3.12, except that it verifies formatting with
|
|
23
|
+
`ruff format --check` rather than rewriting files.
|
|
24
|
+
|
|
25
|
+
## Tests
|
|
26
|
+
|
|
27
|
+
Tests live in `tests/` and cover the pure, API-free parts of the pipeline plus native
|
|
28
|
+
provider request translation: chunking, `\input` resolution, resume behavior, prompt
|
|
29
|
+
composition, SDK request shapes, and issue handling. They never hit the network and need
|
|
30
|
+
no credentials — please keep it that way. Orchestration tests use a provider-neutral
|
|
31
|
+
fake; adapter tests use fake native clients and bind calls to installed SDK signatures.
|
|
32
|
+
|
|
33
|
+
## Changing prompts
|
|
34
|
+
|
|
35
|
+
Prompt edits in `src/math_scout/prompts/` are the highest-leverage and least testable
|
|
36
|
+
part of this project. There is no automated check that a prompt change is an improvement,
|
|
37
|
+
so please run the pipeline on a real paper before and after and say what changed in the
|
|
38
|
+
PR — which issues appeared, which disappeared, and whether the new ones are real.
|
|
39
|
+
|
|
40
|
+
Keep the lanes separate: each reviewer's prompt explicitly tells it what *not* to flag
|
|
41
|
+
because another reviewer handles it. Widening one reviewer's scope usually means
|
|
42
|
+
duplicate findings rather than better coverage.
|
|
43
|
+
|
|
44
|
+
## Reporting bugs
|
|
45
|
+
|
|
46
|
+
Useful reports include the command you ran, what you expected, and what happened. For
|
|
47
|
+
chunking or `\input` problems, a minimal `.tex` file that reproduces it is worth more than
|
|
48
|
+
anything else — those turn directly into test cases.
|
|
49
|
+
|
|
50
|
+
Please don't paste unpublished mathematics into a public issue. A reduced fixture with the
|
|
51
|
+
real content stripped out is enough.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Najib Idrissi-Kaïtouni
|
|
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.
|