terraproof 0.11.0 → 0.13.0

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.
package/README.md CHANGED
@@ -1,222 +1,280 @@
1
- # Terraproof
2
-
3
- > Evidence-graded skills, tools, and checks for mapping and remote-sensing AI agents. *By Geova.*
4
-
5
- [![npm](https://img.shields.io/npm/v/terraproof)](https://www.npmjs.com/package/terraproof) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
-
7
- Terraproof helps AI coding agents do geospatial work they can prove. It gives an agent three things:
8
-
9
- - **Skills.** 24 focused guides (GDAL, CRS and units, satellite preprocessing, SAR, spectral indices, time series, accuracy assessment, and more), split into sections an agent can load one at a time.
10
- - **A router.** It picks the smallest useful set of skills for a task, in English or Arabic, and explains why.
11
- - **Checks with an evidence grade.** They inspect the real datasets an agent produced (CRS, nodata, value ranges, geometry, COG layout, provenance) and grade the result as decision-grade (only against a declared verification contract), checks passed, review required, or advisory only. Every report lists the applicable checks that did not run.
12
-
13
- Everything runs locally and offline. No model API key is needed.
14
-
15
- **Status:** experimental (v0.11.0). See [Evaluation status](#evaluation-status) for what has and has not been measured.
16
-
17
- ---
18
-
19
- ## Quick start
20
-
21
- Route a task with the published CLI (Node.js 20+):
22
-
23
- ```bash
24
- npx terraproof route "Reproject a GeoTIFF to EPSG:3857 and build a COG with GDAL"
25
- npx terraproof route "Download Sentinel-2 from a STAC catalog, compute NDVI, and map the change with MapLibre" --format json
26
- ```
27
-
28
- Then check the data the work produced with the Python package (Python 3.10+). Since 0.8.0 it installs from PyPI with `pip`:
29
-
30
- ```bash
31
- pip install "terraproof[mcp]"
32
- ```
33
-
34
- Until then, install it from a clone:
35
-
36
- ```bash
37
- git clone https://github.com/esmailhussien/terraproof.git
38
- cd terraproof
39
- python -m venv .venv
40
- .venv/bin/python -m pip install -e ".[mcp]" # Windows: .venv\Scripts\python -m pip install -e ".[mcp]"
41
-
42
- python -m terraproof check ndvi.tif --expect index --format md
43
- python -m terraproof check outputs/clip.gpkg --compare-to data/parcels.gpkg --format md --lang ar --out report_ar.md
44
- ```
45
-
46
- The exit code is the grade: `0` decision-grade or checks passed, `2` review required, `3` advisory only, `1` usage error. Without a contract, a clean run is **checks passed**, not decision-grade: read the report's coverage section for what was not checked.
47
-
48
- ---
49
-
50
- ## Python checks
51
-
52
- `python -m terraproof` reads local vector, raster and STAC Item files and makes no network calls.
53
-
54
- | Command | What it does |
55
- |---|---|
56
- | `inspect PATH` | Profile one dataset: CRS and units, schema or bands, dtype, nodata, extent, counts. |
57
- | `check PATHS` | Run the applicable checks and write a JSON or Markdown evidence report (English or Arabic). |
58
- | `preflight PATHS --plan plan.json` | Check a declared processing plan against the real inputs before running it. |
59
- | `manifest write` / `manifest verify` | Record and verify a deterministic run manifest (inputs, outputs, parameters). |
60
- | `route "TASK" [--data PATH]` | Retrieve the skill sections worth reading, using the task text and inspected datasets. |
61
-
62
- Checks cover CRS and units, geometry validity and GeoJSON winding, record counts, raster nodata and valid support, vertical units, resampling, grid alignment and COG layout, reflectance and index ranges, scale/offset applied once, cloud masking, temporal scope, SAR domain, area-adjusted accuracy, and STAC provenance. A check that does not apply is left out; one that applies but cannot run is reported as `not-run`.
63
-
64
- | Grade | Arabic label | Meaning |
65
- |---|---|---|
66
- | Decision-grade | جاهز للقرار | A declared verification contract was fully verified, and every check that ran passed. |
67
- | Checks passed | الفحوصات نجحت (التغطية غير مُقيَّمة) | Every check that ran passed, but no contract was declared, so coverage was not assessed. The report lists applicable checks that did not run and what enables them. |
68
- | Review required | يحتاج مراجعة | At least one check warned; none failed or could not run. |
69
- | Advisory only | استرشادي فقط | At least one check failed or could not run, or no check ran. |
70
-
71
- The grade describes the data path and the checks that ran. It is not a certification of survey, engineering, legal, or safety fitness.
72
-
73
- For explicit task requirements, add `--contract contract.json` (MCP: `contract`).
74
- The contract's outcome becomes the report's grade: it is decision-grade only when every
75
- required check on every required output ran and passed with its declared sources and
76
- parameters, and any other failure or warning still counts. `propose --profile NAME`
77
- (MCP: `propose_contract`) drafts such a contract, filling bindings only from explicit
78
- file or STAC metadata and listing what you still need to declare. See
79
- [verification contracts, diagnostics and unsigned evidence bundles](docs/VERIFICATION_CONTRACTS.md).
80
-
81
- ### Verify a spectral index against its source bands
82
-
83
- ```bash
84
- python -m terraproof check outputs/ndvi.tif --index-formula ndvi --nir inputs/nir.tif --red inputs/red.tif
85
- ```
86
-
87
- This opt-in check compares every output cell with `(NIR-red)/(NIR+red)`, using each
88
- raster's own scale/offset metadata. Supply single-band rasters on the same grid;
89
- source-band roles and calibration must be declared correctly. Missing source data
90
- and a zero denominator cannot become valid output values. Extra output masking
91
- warns because its QA policy is not verified here. Source files are included in the
92
- evidence report and must be covered when a provenance manifest is supplied.
93
- See [the full contract and limits](docs/INDEX_FORMULA.md).
94
-
95
- The same check covers NBR, dNBR (pre minus post), McFeeters NDWI, MNDWI, Gao's NDMI, SAVI
96
- and EVI. Name each source band by its role; a multi-band source also needs its band number:
97
-
98
- ```bash
99
- python -m terraproof check outputs/evi.tif --index-formula evi --band blue=inputs/bands.tif --band-number blue=1 \
100
- --band red=inputs/bands.tif --band-number red=2 --band nir=inputs/bands.tif --band-number nir=3
101
- ```
102
-
103
- ### Verify a composite, an accumulation or a trend against its input stack
104
-
105
- ```bash
106
- python -m terraproof check outputs/storm_total.tif --stack-reduction weighted-sum \
107
- --stack inputs/rate1.tif --stack-weight 1 --stack inputs/rate2.tif --stack-weight 4.5
108
- ```
109
-
110
- `--stack-reduction` is `median`, `count`, `weighted-sum` (for example rate x hours),
111
- `mean-power-db` (dB averaged in linear power) or `ols-slope` (against `--stack-weight`
112
- times, with `--stack-min-count`). Every output cell is compared with that reduction of the
113
- ordered layers; a cell without enough valid inputs must be nodata. The check does not
114
- verify how the input layers were made, so pair it with the calibration and QA checks.
115
-
116
- ### Verify slope and lossless raster delivery
117
-
118
- ```bash
119
- python -m terraproof check outputs/result.tif --dem inputs/elevation.tif --slope-method central-difference
120
- python -m terraproof check outputs/delivery.tif --compare-to inputs/analysis.tif --raster-identity
121
- ```
122
-
123
- The explicit slope method checks all required values, flat cells, stencil masks
124
- and nodata edges. Raster identity checks every band's valid samples, complete
125
- validity masks and grid/band metadata against the declared source. Full COG
126
- conformance remains separate from this data comparison and the existing layout
127
- screen. See [supported contracts and limits](docs/RASTER_CONTRACTS.md).
128
- For final calibration/QA audits, `--processing-full-scan` checks every corresponding
129
- band and pixel in bounded windows; see [scope, examples and measured controls](docs/PROCESSING_FULL_SCAN.md).
130
-
131
-
132
- ---
133
-
134
- ## Use it from your agent
135
-
136
- ### MCP server
137
-
138
- ```bash
139
- python -m terraproof.mcp # stdio server; needs the `mcp` extra
140
- ```
141
-
142
- It is read-only and offline, with seven tools: `preflight`, `inspect_dataset`, `run_checks`, `propose_contract`, `list_skills`, `load_section`, and `find_guidance`. CLI and MCP return the same reports.
143
-
144
- ### Install into a project
145
-
146
- ```bash
147
- python -m terraproof.install --agent claude --task "NDVI change for 2020-2024" --target DIR --with-mcp
148
- python -m terraproof.install --agent cursor --skills gdal,crs-and-units --target DIR --dry-run
149
- ```
150
-
151
- | `--agent` | Skills are written to | MCP config (`--with-mcp`) |
152
- |---|---|---|
153
- | `antigravity` | `.agents/skills/<skill>/` and `AGENTS.md` | `.agents/mcp_config.json` |
154
- | `claude` | `.claude/skills/<skill>/` | `.mcp.json` |
155
- | `codex` | `.agents/skills/<skill>/` and `AGENTS.md` | `.codex/config.toml` |
156
- | `cursor` | `.cursor/rules/terraproof-<skill>.mdc` | `.cursor/mcp.json` |
157
- | `gemini` | `GEMINI.md` | `.gemini/settings.json` |
158
- | `copilot` | `.github/instructions/terraproof-<skill>.instructions.md` | `.vscode/mcp.json` |
159
- | `opencode` | `AGENTS.md` | `opencode.json` |
160
-
161
- The installer only writes inside `--target`, merges existing configs, and is idempotent. Some hosts need you to approve or trust the project before its MCP server connects (Claude Code shows it as "Pending approval"; Codex and Gemini load project config only in trusted folders). Writing the files does not prove the agent loaded or followed them.
162
-
163
- ### Route and export with the Node CLI
164
-
165
- ```bash
166
- npx terraproof route "Design a PostGIS schema for GPS tracks" --collection gis --dry-run
167
- npx terraproof bundle "TASK" --out context.md # one reviewable context file
168
- npx terraproof apply "TASK" --target ./demo/.agents/skills --dry-run # export skill folders
169
- npx terraproof validate
170
- ```
171
-
172
- `apply` and `bundle --out` overwrite files without asking, so start in a disposable folder. Routing is deterministic keyword and section scoring, not semantic understanding; review the selection before you use it. Details: [`router/README.md`](router/README.md) and [`routing/ROUTER_DESIGN.md`](routing/ROUTER_DESIGN.md).
173
-
174
- ---
175
-
176
- ## Skills
177
-
178
- | Area | Skills |
179
- |---|---|
180
- | Process | `brainstorming`, `writing-plans`, `systematic-debugging`, `verification` |
181
- | Mapping and GIS | `gdal`, `crs-and-units`, `raster-processing`, `vector-quality`, `geopandas`, `design-postgis-tables`, `geoparquet-validation`, `geospatial-frontend`, `networkx` |
182
- | Remote sensing | `satellite-preprocessing`, `spectral-indices`, `sar-basics`, `time-series-and-change`, `accuracy-assessment`, `geomaster`, `geozarr` |
183
- | Data access | `geospatial-data-discovery`, `stac-and-cloud-access` |
184
- | Analysis and figures | `statistical-analysis`, `scientific-visualization` |
185
-
186
- Skills are **unmeasured**: no study has separated their effect from the MCP checks, and in the Phase 5 Claude Code runs no skill file was read. Their content is frozen during Phase 6 (factual fixes only, no new skills) until the skills decision in the [Phase 6 plan](docs/plans/Terraproof_Phase6_PLAN.md).
187
-
188
- Each skill lives in `skills/<name>/` with a `SKILL.md`, references, and a `skill.json` routing manifest. Preset collections (`gis`, `remote-sensing`, `data-analysis`, `production`) are in [`routing/collections.json`](routing/collections.json).
189
-
190
- ---
191
-
192
- ## Evaluation status
193
-
194
- - **Checks:** 33 executable eval tasks with independent oracles pass with 0 false passes. The benchmark runs from a clone; the Python package does not include it. Of 50 seeded wrong outputs, production checks reject 25; the other 25 are caught only by the independent oracle (declared blind spots). Passing the benchmark does not mean the production checks catch every wrong output. See [`evals/README.md`](evals/README.md).
195
- - **Routing:** an independent, frozen 160-item set (v5) passed once in both languages: English recall 0.97 with 3.75 wrong picks per 100, Arabic recall 0.96 with 2.5. Earlier independent sets (v3, v4) failed and stay on record. The v5 set was written by an AI agent, not reviewed by an expert.
196
- - **Agent lift:** in a 54-run Claude Code comparison on 9 tasks, runs with Terraproof passed 27/27 and runs without it 21/27. The pre-specified test is **not significant** (p = 0.125), and five tasks passed either way, so no lift is claimed. The clearest single result is Landsat QA masking (3/3 with, 0/3 without). See [`docs/plans/Terraproof_Phase5_PLAN.md`](docs/plans/Terraproof_Phase5_PLAN.md).
197
- - **Harder cohort:** a one-repeat Claude Code screen passed all six tasks both with and without Terraproof. That small screen shows no observed benefit and is separate from the original nine-task study. API pilots are exploratory and do not establish lift.
198
- - **Real data (Phase 8):** on 34 sealed cases built from public Sentinel-2, Copernicus DEM, 3DEP and Natural Earth data, declared checks caught 7 of 7 covered wrong outputs with no false assurance and no false alarm. 20 of the 34 deliverables (validity masks, slope in percent, JSON reports) are forms no check covers yet. Contracts proposed from metadata alone did not meet acceptance. In a 10-run agent measurement, the agent rarely declared a goal, and the `s2-l2a` preset certified two wrong decodes; that preset now requires `--decode-offset`. See [`docs/plans/Terraproof_Phase8_PLAN.md`](docs/plans/Terraproof_Phase8_PLAN.md).
199
- - **Real deliverables (Phase 9):** validity masks, slopes in percent and JSON summaries are now checkable. On 36 fresh sealed real-data cases, 33 deliverables got a declared requirement, and declared checks caught 12 of 15 wrong outputs with no false assurance or false alarm. In a 10-run agent measurement, 8 runs declared their goal (every offered `next_step` was followed), all 10 deliverables were correct, and no wrong output was certified. There was no comparison run, so no lift is claimed.
200
- - **Real hosts:** tool use through MCP has been verified with Codex, Claude Code, Antigravity (Gemini) and OpenCode (Phase 8 P4, ten runs with real tool calls). Cursor and Copilot are unit-tested against their documented layouts only.
201
-
202
- ---
203
-
204
- ## Repository
205
-
206
- | Path | Contents |
207
- |---|---|
208
- | `skills/` | The 24 skills |
209
- | `routing/` | Generated skill registry, check catalog, rules, and collections |
210
- | `router/` | TypeScript router and CLI (the npm package) |
211
- | `src/terraproof/` | Python package: inspectors, checks, reports, router, MCP server, installers, evals |
212
- | `evals/` | Eval task specs and routing sets |
213
- | `tests/` | Router, Python, package, and release-validation tests |
214
- | `instructions/` | Universal engineering rules shipped with the skills |
215
- | `docs/` | [Release checklist](docs/RELEASE_CHECKLIST.md) and [design plans](docs/plans/) |
216
- | `sources/`, `third_party/` | Upstream attribution and licenses |
217
-
218
- To contribute, see [`CONTRIBUTING.md`](CONTRIBUTING.md). Changes are listed in [`CHANGELOG.md`](CHANGELOG.md).
219
-
220
- ## License
221
-
222
- [MIT](LICENSE). Vendored and adapted components keep their upstream licenses (MIT, Apache-2.0, 3-clause BSD), documented in `third_party/` and [`sources/SOURCES.md`](sources/SOURCES.md).
1
+ # Terraproof
2
+
3
+ > Evidence-graded skills, tools, and checks for mapping and remote-sensing AI agents. *By Geova.*
4
+
5
+ [![npm](https://img.shields.io/npm/v/terraproof)](https://www.npmjs.com/package/terraproof) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
+
7
+ Terraproof helps AI coding agents do geospatial work they can prove. It gives an agent three things:
8
+
9
+ - **Skills.** 24 focused guides (GDAL, CRS and units, satellite preprocessing, SAR, spectral indices, time series, accuracy assessment, and more), split into sections an agent can load one at a time.
10
+ - **A router.** It picks the smallest useful set of skills for a task, in English or Arabic, and explains why.
11
+ - **Checks with an evidence grade.** They inspect the real datasets an agent produced (CRS, nodata, value ranges, geometry, COG layout, provenance) and grade the result as decision-grade (only against a declared verification contract), checks passed, review required, or advisory only. Every report lists the applicable checks that did not run.
12
+
13
+ Routing, local inspection and checks run offline. No model API key is needed.
14
+
15
+ **Status:** experimental (v0.13.0). See [Evaluation status](#evaluation-status) for what has and has not been measured.
16
+
17
+ **Scientific workflow core (experimental):** [scientific workflows](docs/SCIENTIFIC_WORKFLOWS.md)
18
+ adds a Landsat surface-temperature route from reviewed intent through local processing,
19
+ verification, repair and map/report outputs, plus optional [public source discovery/acquisition](docs/SCIENTIFIC_SOURCE_RECOVERY.md)
20
+ that accesses the network only when invoked. [Separate-context acceptance](docs/SCIENTIFIC_WORKFLOW_INDEPENDENT_ACCEPTANCE_2026-11-03.md)
21
+ passed three prior targets across five fixed variants; human scientific suitability and absolute accuracy
22
+ remain unestablished.
23
+
24
+ ---
25
+
26
+ ## Quick start
27
+
28
+ Route a task with the published CLI (Node.js 20+):
29
+
30
+ ```bash
31
+ npx terraproof route "Reproject a GeoTIFF to EPSG:3857 and build a COG with GDAL"
32
+ npx terraproof route "Download Sentinel-2 from a STAC catalog, compute NDVI, and map the change with MapLibre" --format json
33
+ ```
34
+
35
+ Then check the data the work produced with the Python package (Python 3.10+). Since 0.8.0 it installs from PyPI with `pip`:
36
+
37
+ ```bash
38
+ pip install "terraproof[mcp]"
39
+ ```
40
+
41
+ Until then, install it from a clone:
42
+
43
+ ```bash
44
+ git clone https://github.com/esmailhussien/terraproof.git
45
+ cd terraproof
46
+ python -m venv .venv
47
+ .venv/bin/python -m pip install -e ".[mcp]" # Windows: .venv\Scripts\python -m pip install -e ".[mcp]"
48
+
49
+ python -m terraproof check ndvi.tif --expect index --format md
50
+ python -m terraproof check outputs/clip.gpkg --compare-to data/parcels.gpkg --format md --lang ar --out report_ar.md
51
+ ```
52
+
53
+ The exit code is the grade: `0` decision-grade or checks passed, `2` review required, `3` advisory only, `1` usage error. Without a contract, a clean run is **checks passed**, not decision-grade: read the report's coverage section for what was not checked.
54
+
55
+ ---
56
+
57
+ ## Python checks
58
+
59
+ `python -m terraproof` reads local vector, raster, STAC Item and Python files and makes no network calls.
60
+
61
+ | Command | What it does |
62
+ |---|---|
63
+ | `inspect PATH` | Profile one dataset: CRS and units, schema or bands, dtype, nodata, extent, counts (`--layer` for a GeoPackage layer). |
64
+ | `check PATHS` | Run the applicable checks and write a JSON, Markdown or offline HTML evidence report (English or Arabic). |
65
+ | `verify [terraproof.toml]` | Check every deliverable a project file declares, in one run with one exit code (`--plan` checks the declarations only). |
66
+ | `preflight PATHS --plan plan.json` | Check a declared processing plan against the real inputs before running it. |
67
+ | `manifest write` / `manifest verify` | Record and verify a deterministic run manifest (inputs, outputs, parameters). |
68
+ | `route "TASK" [--data PATH]` | Retrieve the skill sections worth reading, using the task text and inspected datasets. |
69
+ | `audit [PATHS]` | Find the datasets and Python scripts under PATHS and run the checks that need no declaration. |
70
+ | `lint PATHS` | Scan Python scripts statically (never run) for silent geospatial mistakes. |
71
+ | `demo` | Write a small workspace of deliberate mistakes, audit it, and save the reports. |
72
+
73
+ Checks cover CRS and units (Web Mercator fails metric operations), geometry validity and GeoJSON winding, record counts, raster nodata and valid support, vertical units, resampling, grid alignment and COG layout, reflectance and index ranges, scale/offset applied once, cloud masking, temporal scope, SAR domain, area-adjusted accuracy, and STAC provenance. A check that does not apply is left out; one that applies but cannot run is reported as `not-run`. Opt-in screens check bounds against the CRS area of use, vector topology, extensive-quantity totals, SAR orbits and Sentinel-2 processing baselines across STAC Items, and train/test spatial leakage; see [opt-in screens, `audit`, `lint` and HTML reports](docs/FRONTIER_CHECKS_AND_AUDIT.md).
74
+
75
+ | Grade | Arabic label | Meaning |
76
+ |---|---|---|
77
+ | Decision-grade | جاهز للقرار | A declared verification contract was fully verified, and every check that ran passed. |
78
+ | Checks passed | الفحوصات نجحت (التغطية غير مُقيَّمة) | Every check that ran passed, but no contract was declared, so coverage was not assessed. The report lists applicable checks that did not run and what enables them. |
79
+ | Review required | يحتاج مراجعة | At least one check warned; none failed or could not run. |
80
+ | Advisory only | استرشادي فقط | At least one check failed or could not run, or no check ran. |
81
+
82
+ The grade describes the data path and the checks that ran. It is not a certification of survey, engineering, legal, or safety fitness.
83
+
84
+ For explicit task requirements, add `--contract contract.json` (MCP: `contract`).
85
+ The contract's outcome becomes the report's grade: it is decision-grade only when every
86
+ required check on every required output ran and passed with its declared sources and
87
+ parameters, and any other failure or warning still counts. `propose --profile NAME`
88
+ (MCP: `propose_contract`) drafts such a contract, filling bindings only from explicit
89
+ file or STAC metadata and listing what you still need to declare. See
90
+ [verification contracts, diagnostics and unsigned evidence bundles](docs/VERIFICATION_CONTRACTS.md).
91
+
92
+ ### Verify a whole pipeline from one project file
93
+
94
+ Declare what each deliverable is meant to be once, in `terraproof.toml` next to your pipeline, and check
95
+ them all with one command, locally or in CI:
96
+
97
+ ```toml
98
+ schema = "terraproof.project/1"
99
+
100
+ [[deliverables]]
101
+ name = "usable-pixel mask"
102
+ outputs = ["out/mask.tif"]
103
+ goals = ["qa-masked"]
104
+ qa_path = "data/SCL_20m.tif"
105
+ qa_kind = "keep-codes"
106
+ qa_keep_codes = [4, 5, 6, 7, 11]
107
+ output_form = "validity-mask"
108
+
109
+ [[deliverables]]
110
+ name = "slope"
111
+ outputs = ["out/slope_utm.tif"]
112
+ goals = ["slope-from-dem"]
113
+ dem = "data/dem.tif"
114
+ dem_vertical_unit = "metre"
115
+ slope_unit = "percent"
116
+ ```
117
+
118
+ ```bash
119
+ python -m terraproof verify # every deliverable; exit 0, 2 or 3 as for check
120
+ python -m terraproof verify --plan # before outputs exist: what each declaration still lacks
121
+ ```
122
+
123
+ Each deliverable is graded on its declaration, so a correct one is decision-grade and a wrong one fails
124
+ with its finding. Bindings use the same names as `run_checks`, and paths are relative to the file. See
125
+ [project verification](docs/PROJECT_VERIFICATION.md) for every field and a GitHub Actions example.
126
+
127
+ ### Verify a spectral index against its source bands
128
+
129
+ ```bash
130
+ python -m terraproof check outputs/ndvi.tif --index-formula ndvi --nir inputs/nir.tif --red inputs/red.tif
131
+ ```
132
+
133
+ This opt-in check compares every output cell with `(NIR-red)/(NIR+red)`, using each
134
+ raster's own scale/offset metadata. Supply single-band rasters on the same grid;
135
+ source-band roles and calibration must be declared correctly. Missing source data
136
+ and a zero denominator cannot become valid output values. Extra output masking
137
+ warns because its QA policy is not verified here. Source files are included in the
138
+ evidence report and must be covered when a provenance manifest is supplied.
139
+ See [the full contract and limits](docs/INDEX_FORMULA.md).
140
+
141
+ The same check covers NBR, dNBR (pre minus post), McFeeters NDWI, MNDWI, Gao's NDMI, SAVI
142
+ and EVI. Name each source band by its role; a multi-band source also needs its band number:
143
+
144
+ ```bash
145
+ python -m terraproof check outputs/evi.tif --index-formula evi --band blue=inputs/bands.tif --band-number blue=1 \
146
+ --band red=inputs/bands.tif --band-number red=2 --band nir=inputs/bands.tif --band-number nir=3
147
+ ```
148
+
149
+ ### Verify a composite, an accumulation or a trend against its input stack
150
+
151
+ ```bash
152
+ python -m terraproof check outputs/storm_total.tif --stack-reduction weighted-sum \
153
+ --stack inputs/rate1.tif --stack-weight 1 --stack inputs/rate2.tif --stack-weight 4.5
154
+ ```
155
+
156
+ `--stack-reduction` is `median`, `count`, `weighted-sum` (for example rate x hours),
157
+ `mean-power-db` (dB averaged in linear power) or `ols-slope` (against `--stack-weight`
158
+ times, with `--stack-min-count`). Every output cell is compared with that reduction of the
159
+ ordered layers; a cell without enough valid inputs must be nodata. The check does not
160
+ verify how the input layers were made, so pair it with the calibration and QA checks.
161
+
162
+ ### Verify slope and lossless raster delivery
163
+
164
+ ```bash
165
+ python -m terraproof check outputs/result.tif --dem inputs/elevation.tif --slope-method central-difference
166
+ python -m terraproof check outputs/delivery.tif --compare-to inputs/analysis.tif --raster-identity
167
+ ```
168
+
169
+ The explicit slope method checks all required values, flat cells, stencil masks
170
+ and nodata edges. Raster identity checks every band's valid samples, complete
171
+ validity masks and grid/band metadata against the declared source. Full COG
172
+ conformance remains separate from this data comparison and the existing layout
173
+ screen. See [supported contracts and limits](docs/RASTER_CONTRACTS.md).
174
+ For final calibration/QA audits, `--processing-full-scan` checks every corresponding
175
+ band and pixel in bounded windows; see [scope, examples and measured controls](docs/PROCESSING_FULL_SCAN.md).
176
+
177
+ ### Verify bathymetry against reference depths
178
+
179
+ ```bash
180
+ python -m terraproof check outputs/depth.tif --bathymetry bathymetry.json --format md
181
+ ```
182
+
183
+ The audit checks declared vertical conventions, depth error and coverage by reference depth.
184
+ Optional operands check the shallow-water mask, training and holdout overlap, and repeat-run stability.
185
+ See the [configuration and evidence contract](docs/BATHYMETRY.md).
186
+
187
+
188
+ ---
189
+
190
+ ## Use it from your agent
191
+
192
+ ### MCP server
193
+
194
+ ```bash
195
+ python -m terraproof.mcp # stdio server; needs the `mcp` extra
196
+ ```
197
+
198
+ It is read-only and offline, with eight tools: `preflight`, `inspect_dataset`, `run_checks`, `propose_contract`, `verify_project`, `list_skills`, `load_section`, and `find_guidance`. CLI and MCP return the same reports.
199
+
200
+ ### Install into a project
201
+
202
+ ```bash
203
+ python -m terraproof.install --agent claude --task "NDVI change for 2020-2024" --target DIR --with-mcp
204
+ python -m terraproof.install --agent cursor --skills gdal,crs-and-units --target DIR --dry-run
205
+ ```
206
+
207
+ | `--agent` | Skills are written to | MCP config (`--with-mcp`) |
208
+ |---|---|---|
209
+ | `antigravity` | `.agents/skills/<skill>/` and `AGENTS.md` | `.agents/mcp_config.json` |
210
+ | `claude` | `.claude/skills/<skill>/` | `.mcp.json` |
211
+ | `codex` | `.agents/skills/<skill>/` and `AGENTS.md` | `.codex/config.toml` |
212
+ | `cursor` | `.cursor/rules/terraproof-<skill>.mdc` | `.cursor/mcp.json` |
213
+ | `gemini` | `GEMINI.md` | `.gemini/settings.json` |
214
+ | `copilot` | `.github/instructions/terraproof-<skill>.instructions.md` | `.vscode/mcp.json` |
215
+ | `opencode` | `AGENTS.md` | `opencode.json` |
216
+
217
+ `--with-hooks` also writes `.terraproof/verify_hook.py`, which runs `verify` on the project file in the target (for `claude`, as a Stop hook in `.claude/settings.json` that blocks stopping when a deliverable failed or is incomplete, or the file is invalid; review-required does not block). The installer only writes inside `--target`, merges existing configs, and is idempotent. Some hosts need you to approve or trust the project before its MCP server connects (Claude Code shows it as "Pending approval"; Codex and Gemini load project config only in trusted folders). Writing the files does not prove the agent loaded or followed them.
218
+
219
+ ### Route and export with the Node CLI
220
+
221
+ ```bash
222
+ npx terraproof route "Design a PostGIS schema for GPS tracks" --collection gis --dry-run
223
+ npx terraproof bundle "TASK" --out context.md # one reviewable context file
224
+ npx terraproof apply "TASK" --target ./demo/.agents/skills --dry-run # export skill folders
225
+ npx terraproof validate
226
+ ```
227
+
228
+ `apply` and `bundle --out` overwrite files without asking, so start in a disposable folder. Routing is deterministic keyword and section scoring, not semantic understanding; review the selection before you use it. Details: [`router/README.md`](router/README.md) and [`routing/ROUTER_DESIGN.md`](routing/ROUTER_DESIGN.md).
229
+
230
+ ---
231
+
232
+ ## Skills
233
+
234
+ | Area | Skills |
235
+ |---|---|
236
+ | Process | `brainstorming`, `writing-plans`, `systematic-debugging`, `verification` |
237
+ | Mapping and GIS | `gdal`, `crs-and-units`, `raster-processing`, `vector-quality`, `geopandas`, `design-postgis-tables`, `geoparquet-validation`, `geospatial-frontend`, `networkx` |
238
+ | Remote sensing | `satellite-preprocessing`, `spectral-indices`, `sar-basics`, `time-series-and-change`, `accuracy-assessment`, `geomaster`, `geozarr` |
239
+ | Data access | `geospatial-data-discovery`, `stac-and-cloud-access` |
240
+ | Analysis and figures | `statistical-analysis`, `scientific-visualization` |
241
+
242
+ Skills are **unmeasured**: no study has separated their effect from the MCP checks, and in the Phase 5 Claude Code runs no skill file was read. Their content is frozen during Phase 6 (factual fixes only, no new skills) until the skills decision in the [Phase 6 plan](docs/plans/Terraproof_Phase6_PLAN.md).
243
+
244
+ Each skill lives in `skills/<name>/` with a `SKILL.md`, references, and a `skill.json` routing manifest. Preset collections (`gis`, `remote-sensing`, `data-analysis`, `production`) are in [`routing/collections.json`](routing/collections.json).
245
+
246
+ ---
247
+
248
+ ## Evaluation status
249
+
250
+ - **Checks:** 33 executable eval tasks with independent oracles pass with 0 false passes. The benchmark runs from a clone; the Python package does not include it. Of 50 seeded wrong outputs, production checks reject 25; the other 25 are caught only by the independent oracle (declared blind spots). Passing the benchmark does not mean the production checks catch every wrong output. See [`evals/README.md`](evals/README.md).
251
+ - **Routing:** an independent, frozen 160-item set (v5) passed once in both languages: English recall 0.97 with 3.75 wrong picks per 100, Arabic recall 0.96 with 2.5. Earlier independent sets (v3, v4) failed and stay on record. The v5 set was written by an AI agent, not reviewed by an expert.
252
+ - **Agent lift:** in a 54-run Claude Code comparison on 9 tasks, runs with Terraproof passed 27/27 and runs without it 21/27. The pre-specified test is **not significant** (p = 0.125), and five tasks passed either way, so no lift is claimed. The clearest single result is Landsat QA masking (3/3 with, 0/3 without). See [`docs/plans/Terraproof_Phase5_PLAN.md`](docs/plans/Terraproof_Phase5_PLAN.md).
253
+ - **Harder cohort:** a one-repeat Claude Code screen passed all six tasks both with and without Terraproof. That small screen shows no observed benefit and is separate from the original nine-task study. API pilots are exploratory and do not establish lift.
254
+ - **Real data (Phase 8):** on 34 sealed cases built from public Sentinel-2, Copernicus DEM, 3DEP and Natural Earth data, declared checks caught 7 of 7 covered wrong outputs with no false assurance and no false alarm. 20 of the 34 deliverables (validity masks, slope in percent, JSON reports) are forms no check covers yet. Contracts proposed from metadata alone did not meet acceptance. In a 10-run agent measurement, the agent rarely declared a goal, and the `s2-l2a` preset certified two wrong decodes; that preset now requires `--decode-offset`. See [`docs/plans/Terraproof_Phase8_PLAN.md`](docs/plans/Terraproof_Phase8_PLAN.md).
255
+ - **Real deliverables (Phase 9):** validity masks, slopes in percent and JSON summaries are now checkable. On 36 fresh sealed real-data cases, 33 deliverables got a declared requirement, and declared checks caught 12 of 15 wrong outputs with no false assurance or false alarm. In a 10-run agent measurement, 8 runs declared their goal (every offered `next_step` was followed), all 10 deliverables were correct, and no wrong output was certified. There was no comparison run, so no lift is claimed.
256
+ - **QA masks and reprojected slopes (Phase 10):** a declared validity mask is checked against the QA layer's own no-data, a slope on another grid than its DEM is checked after resampling (in ground metres on projections such as Web Mercator), and every number of a JSON report can be declared. A first measurement certified one wrong Web Mercator slope, and that was fixed. On 45 fresh sealed real-data cases, declared checks then caught every wrong mask (5 of 5) and 5 of 6 wrong reprojected slopes, verified all 6 correct ones, and certified no wrong output. Multi-value reports did not meet their bar: 4 of 6 wrong reports failed, and the other two held only numbers the check cannot express (NDVI, joint band selections), so they were not certified either. No agent run was measured for this release.
257
+ - **New screens and bathymetry (Phase 12):** four sealed real-data sets from independent authors measured the checks added after 0.12.0, each set fixing what the previous one found. On the last (62 cases), no wrong output was certified, and CRS area of use, topology, spatial leakage, mass conservation, SAR orbit and Sentinel-2 baseline each caught every wrong case and accepted every correct one. Bathymetry caught every wrong map but rejected 5 of 6 correct ones, so it stays experimental. See [`docs/plans/Terraproof_Phase12_PLAN.md`](docs/plans/Terraproof_Phase12_PLAN.md).
258
+ - **Real hosts:** tool use through MCP has been verified with Codex, Claude Code, Antigravity (Gemini) and OpenCode (Phase 8 P4, ten runs with real tool calls). Cursor and Copilot are unit-tested against their documented layouts only.
259
+
260
+ ---
261
+
262
+ ## Repository
263
+
264
+ | Path | Contents |
265
+ |---|---|
266
+ | `skills/` | The 24 skills |
267
+ | `routing/` | Generated skill registry, check catalog, rules, and collections |
268
+ | `router/` | TypeScript router and CLI (the npm package) |
269
+ | `src/terraproof/` | Python package: inspectors, checks, reports, router, MCP server, installers, evals |
270
+ | `evals/` | Eval task specs and routing sets |
271
+ | `tests/` | Router, Python, package, and release-validation tests |
272
+ | `instructions/` | Universal engineering rules shipped with the skills |
273
+ | `docs/` | [Release checklist](docs/RELEASE_CHECKLIST.md) and [design plans](docs/plans/) |
274
+ | `sources/`, `third_party/` | Upstream attribution and licenses |
275
+
276
+ To contribute, see [`CONTRIBUTING.md`](CONTRIBUTING.md). Changes are listed in [`CHANGELOG.md`](CHANGELOG.md).
277
+
278
+ ## License
279
+
280
+ [MIT](LICENSE). Vendored and adapted components keep their upstream licenses (MIT, Apache-2.0, 3-clause BSD), documented in `third_party/` and [`sources/SOURCES.md`](sources/SOURCES.md).