terraproof 0.4.0 → 0.5.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,357 +1,150 @@
1
1
  # Terraproof
2
2
 
3
- > evidence-graded skills, tools, and checks for mapping and remote-sensing AI agents. *By Geova.*
3
+ > Evidence-graded skills, tools, and checks for mapping and remote-sensing AI agents. *By Geova.*
4
4
 
5
- > **Status:** Experimental — refocusing from AgentLayer v0.1
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
6
 
7
- Terraproof is a focused collection of mapping and remote-sensing skills for AI coding agents, plus a deterministic router that selects the smallest useful set of them for a task. The direction is to make geospatial agents prove their work: inspect real datasets, apply section-level expert guidance, run executable checks, and attach an evidence grade to each result. Read the full plan in [`Terraproof_v1_PLAN.md`](Terraproof_v1_PLAN.md).
7
+ Terraproof helps AI coding agents do geospatial work they can prove. It gives an agent three things:
8
8
 
9
- **Today:** 24 skills, a TypeScript router with 73 test scenarios, and a Python package with dataset inspection, checks, evidence grades, a skill router, a read-only MCP server, executable evals, and agent installers (see [Python core](#python-core-phase-1-experimental), [Skill router (Python)](#skill-router-python), [MCP server](#mcp-server), and [Install into your agent](#install-into-your-agent)).
10
- **Planned, not implemented yet:** verification of the installers in real agent hosts (only Claude Code has been exercised end to end) and a fresh, independently written held-out routing set.
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, review required, or advisory only.
11
12
 
12
- ---
13
-
14
- ## Quick Start: Route a Real Task
15
-
16
- Use a source checkout for this walkthrough; it does not depend on an npm release being available.
17
-
18
- **Requirements:** Git and Node.js. Source checkout commands (`node router/index.ts ...`) need **Node.js 22.18+ or 24+** for native TypeScript support (see [Node.js TypeScript support](https://nodejs.org/api/typescript.html)). The built package (`npm run build`, `node bin/terraproof.js ...`) needs Node.js 20+. No model API key is needed for routing. A coding agent is needed separately to implement the task.
19
-
20
- ```bash
21
- git clone https://github.com/esmailhussien/terraproof.git
22
- cd terraproof
23
- node router/index.ts --version
24
- node router/index.ts validate
25
- node router/index.ts route "Download Sentinel-2 imagery from a STAC catalog, compute NDVI, and map the change with MapLibre" --dry-run
26
- ```
27
-
28
- **Expected result:** `--version` prints `terraproof v0.4.0`, and `validate` reports the current generated registry and collections. The route prints the task, selected skills grouped by layer, and rationale. Exact scores and selections are input- and registry-dependent; dry-run output also lists dropped candidates. It does not create files or call a model.
29
-
30
- The walkthrough is illustrative, not a recorded execution. Exact selections and scores depend on the prompt, overrides, and registry revision. The commands that run offline were checked against this checkout. The download, NDVI, and MapLibre steps need network access and data, so they are illustrative only.
31
-
32
- ### Practical example: Sentinel-2 NDVI change map
13
+ Everything runs locally and offline. No model API key is needed.
33
14
 
34
- The task needs satellite imagery, a spectral index, and a web map. First inspect the route above. If the recommendation misses a requirement, revise the prompt or use overrides.
35
-
36
- Bundle the selected skills into one reviewable context file. The `--include` flags force four skills; the router also selects `spectral-indices` for the NDVI step, so the bundle holds five:
37
-
38
- ```bash
39
- node router/index.ts bundle "Download Sentinel-2 imagery from a STAC catalog, compute NDVI, and map the change with MapLibre" --include geospatial-data-discovery --include geomaster --include geospatial-frontend --include verification --out ndvi-context.md
40
- ```
41
-
42
- **Expected artifact:** `ndvi-context.md` in the current directory. The CLI prints `✓ Composed bundle written to: ndvi-context.md (5 skills, <N> bytes)`; the size in this checkout was 40130 bytes. The file starts with a header listing the task, the five skills, and their layers, then the universal engineering instructions and the skill text grouped by layer. Review it, then give it to your coding agent together with your project requirements. The file is instructions, not generated application code.
43
-
44
- For agents that support project skill directories, export to a separate demo folder first. The `--dry-run` form prints the same recommendation with `Mode: DRY RUN (No changes made)` and writes nothing:
45
-
46
- ```bash
47
- node router/index.ts apply "Download Sentinel-2 imagery from a STAC catalog, compute NDVI, and map the change with MapLibre" --include geospatial-data-discovery --include geomaster --include geospatial-frontend --include verification --target ../terraproof-demo/.agents/skills --dry-run
48
-
49
- # After reviewing the recommendation, remove --dry-run to write files:
50
- node router/index.ts apply "Download Sentinel-2 imagery from a STAC catalog, compute NDVI, and map the change with MapLibre" --include geospatial-data-discovery --include geomaster --include geospatial-frontend --include verification --target ../terraproof-demo/.agents/skills
51
- ```
52
-
53
- **Expected files after a successful export** (the target is resolved from the directory you run the command in, so this folder appears next to the clone):
54
-
55
- ```text
56
- terraproof-demo/
57
- └── .agents/
58
- ├── AGENTS.md # Generated manifest with installed skills and rationales
59
- ├── instructions/ # engineering.md, security.md, simplicity.md; copied only if this folder does not exist yet
60
- └── skills/ # One folder per selected skill; UPSTREAM.md is excluded
61
- ├── geomaster/
62
- ├── geospatial-data-discovery/
63
- ├── geospatial-frontend/
64
- ├── spectral-indices/
65
- └── verification/
66
- ```
67
-
68
- Check the CLI output for copy errors and inspect the files. The CLI reminds you that nothing loads these skills automatically, so reference `.agents/skills` from your agent's instruction file (for example, a root `AGENTS.md`). Then ask the agent to read the manifest and the relevant skills before it implements anything. Verify the resulting work yourself, including the map rendering and the error states in the app.
69
-
70
- ### Check the result with the Python core
71
-
72
- After the work produces a raster, run the Python checks on it. Setup (Python 3.10 or newer) and the full list of checks are in [Python core](#python-core-phase-1-experimental).
73
-
74
- ```bash
75
- python -m terraproof check ndvi.tif --expect index --format md --lang ar --out ndvi_report_ar.md
76
- ```
77
-
78
- `--expect index` checks that the sampled values fall within [-1, 1]. `--lang` only applies to the Markdown format, so `--format md --lang ar` writes an Arabic report. The exit code is `0` Decision-grade, `2` Review required, `3` Advisory only, or `1` for a usage error.
79
-
80
- **Expected result (illustrative for `ndvi.tif`):** the grade and messages depend on your file. This command was run on a synthetic 64×64 NDVI GeoTIFF (EPSG:32636, striped, no overviews), not on a Sentinel-2 product. It produced the grade **يحتاج مراجعة** (Review required) and exit code `2`: `raster.cog_layout` warned that the file is not a tiled COG, while `crs.defined`, `raster.nodata_declared`, and `rs.index_range` passed.
81
-
82
- ### Experimental limits and safe use
83
-
84
- - Routing is deterministic keyword/scoring logic, not semantic understanding. Confidence is a routing signal, not a probability that the implementation will succeed.
85
- - Inspect recommendations before use. Prompt wording, conflicts, collection presets, and manual overrides can change the selected skills.
86
- - The CLI is strict. Unknown options, options missing a value, `--include` or `--exclude` names that are not registered skills, unknown `--collection` names, and `--format` values other than `json` or `table` exit with status `1` and a message. `--help` lists the options.
87
- - `apply` writes without an interactive confirmation; there is no `--yes` flag. It overwrites files that have the same names in the target and the manifest next to it (`<target>/../AGENTS.md`). Start in a disposable folder, or commit or back up existing files first.
88
- - The generated manifest tells you to reference the skills from your agent's instruction file, because nothing loads `.agents/skills/` automatically.
89
- - Use `route --dry-run` or `apply --dry-run` to inspect without exporting. `bundle --out` writes its file even when `--dry-run` is supplied, and it overwrites an existing output file.
90
- - Routing uses local files. Cloning, dependency installation, and any tools that individual skills describe may need network access or their own dependencies.
91
- - Exporting skills does not install GDAL, Python packages, browser tooling, or other domain dependencies, and it does not prove that an agent loaded or followed the instructions.
92
-
93
- For development checks, see [Verify your change](CONTRIBUTING.md#verify-your-change) in `CONTRIBUTING.md`.
15
+ **Status:** experimental (v0.5.0). See [Evaluation status](#evaluation-status) for what has and has not been measured.
94
16
 
95
17
  ---
96
18
 
97
- ## Install & Usage
19
+ ## Quick start
98
20
 
99
- The npm package name `terraproof` is not published yet, so `npx terraproof` does not work from the registry. From a clone:
21
+ Route a task with the published CLI (Node.js 20+):
100
22
 
101
23
  ```bash
102
- npm install # dev dependencies (TypeScript)
103
- npm run build # compile router/ to dist/router/
104
- node bin/terraproof.js route "Reproject a GeoTIFF to EPSG:3857 and build a COG with GDAL"
105
- node bin/terraproof.js --version
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
106
26
  ```
107
27
 
108
- Requirements:
109
- - **Installed package (`dist/`):** Node.js 20 or newer.
110
- - **Development and tests from source** (`node router/index.ts`, `npm run test:router`, `npm run typecheck`): Node.js 22.18 or newer, which strips TypeScript types natively.
111
- - `npm run test:package` packs the repository, installs the tarball into a temporary project, and runs the installed CLI.
112
-
113
- ## Smart Skill Router
114
-
115
- The router is deterministic and offline. It maps a task description to a short list of skills, each with a reason:
116
-
117
- ```bash
118
- # Calculate the recommended skill composition
119
- node router/index.ts route "Reproject GeoTIFF elevation tiles to EPSG:4326 and build COGs"
120
-
121
- # Seed the selection from a preset collection
122
- node router/index.ts route "Design a PostGIS schema for GPS tracks" --collection gis
123
-
124
- # Inspect the result without changes, or print JSON for tooling
125
- node router/index.ts route "Compute NDVI change for 2020-2024" --dry-run --format json
126
-
127
- # Check registry integrity
128
- node router/index.ts validate
129
- ```
130
-
131
- For scoring weights, layers, and heuristics, see [`routing/ROUTER_DESIGN.md`](routing/ROUTER_DESIGN.md) and [`router/README.md`](router/README.md).
132
-
133
- ---
134
-
135
- ## Python core (Phase 1, experimental)
136
-
137
- The Python package `terraproof` inspects geospatial datasets, runs deterministic checks, and writes an evidence report as JSON or Markdown (English or Arabic). It reads local files only and makes no network calls. `inspect` and `check` are not a port of the TypeScript router; the same package also provides the separate Python skill router, the MCP server, and the agent installers described in the next three sections. The `terraproof` npm command above is still the TypeScript router; the Python core runs as `python -m terraproof`.
138
-
139
- Setup, from the repository root (Python 3.10 or newer):
28
+ Then check the data the work produced with the Python package (Python 3.10+, from a clone):
140
29
 
141
30
  ```bash
31
+ git clone https://github.com/esmailhussien/terraproof.git
32
+ cd terraproof
142
33
  python -m venv .venv
143
- .venv/bin/python -m pip install -e ".[dev]" # Windows: .venv\Scripts\python -m pip install -e ".[dev]"
144
- .venv/bin/python -m pytest -q tests/python
145
- ```
146
-
147
- Examples (replace the paths with your own datasets):
34
+ .venv/bin/python -m pip install -e ".[mcp]" # Windows: .venv\Scripts\python -m pip install -e ".[mcp]"
148
35
 
149
- ```bash
150
- # Print the inspection of one dataset as JSON
151
- python -m terraproof inspect data/parcels.gpkg
152
-
153
- # Run the checks and print a JSON evidence report
154
- python -m terraproof check data/parcels.gpkg --operation area
155
-
156
- # Compare record counts with the input and write a Markdown report in Arabic
36
+ python -m terraproof check ndvi.tif --expect index --format md
157
37
  python -m terraproof check outputs/clip.gpkg --compare-to data/parcels.gpkg --format md --lang ar --out report_ar.md
158
-
159
- # Categorical raster: nearest or mode resampling passes, bilinear fails
160
- python -m terraproof check landcover.tif --categorical --resampling nearest --format md
161
38
  ```
162
39
 
163
- Inputs: vector (`.gpkg`, `.geojson`, `.json`, `.shp`, `.fgb`, `.parquet` where GDAL can read it), raster (`.tif`, `.tiff`, `.vrt`, `.jp2`), and local STAC Item JSON.
164
-
165
- Checks cover CRS and units (`crs.defined`, `crs.consistent`, `crs.metric_operation`), geometry (`geometry.valid`, `geometry.non_empty`, `geometry.type_consistent`), record counts (`scope.record_count`), raster integrity (`raster.nodata_declared`, `raster.resampling`, `raster.grid_alignment`, `raster.cog_layout`), remote-sensing value ranges (`rs.reflectance_range`, `rs.index_range`), and STAC provenance (`stac.provenance`), with Phase4 processing, preflight, and reproducibility checks documented below. A check that does not apply to an input is left out; a check that applies but cannot run is reported as `not-run`.
40
+ The exit code is the grade: `0` decision-grade, `2` review required, `3` advisory only, `1` usage error.
166
41
 
167
- ### Phase 4 preflight, processing, and provenance
42
+ ---
168
43
 
169
- Preflight validates a declared JSON plan before processing. Supported fields include `operation`, `target_crs`, explicit `reproject`, `resampling`, `categorical`, `combine`, declared `alignment`, `decode`, product `encoding`, `time_range`, `expect`, `measurement_units`, and explicit `unit_conversion`. `target_crs` alone never implies reprojection; `alignment:true` and unit conversion must be declared, and malformed or reversed STAC intervals do not pass.
44
+ ## Python checks
170
45
 
171
- ```bash
172
- python -m terraproof preflight input.tif --plan plan.json
173
- python -m terraproof check output.tif --reference-input input_dn.tif --encoding s2-l2a --manifest run.manifest.json
174
- python -m terraproof manifest write --inputs input.tif --outputs output.tif --params plan.json --out run.manifest.json
175
- python -m terraproof manifest verify run.manifest.json
176
- ```
46
+ `python -m terraproof` reads local vector, raster and STAC Item files and makes no network calls.
177
47
 
178
- Manifest verification covers every contributing path: primary, compare, reference, QA, samples, and class-area files. `--require-provenance` makes an absent or failed manifest advisory; CLI and MCP use the same coverage and malformed-manifest behavior. Processing checks include exact-once scale application, cloud masking, temporal scope, SAR domain/geocoding, and area-adjusted accuracy. Optional router semantic retrieval is offline-only and falls back to lexical retrieval when its dependency/model is unavailable; candidate mode defaults to eight deterministic candidates for optional host-side selection.
48
+ | Command | What it does |
49
+ |---|---|
50
+ | `inspect PATH` | Profile one dataset: CRS and units, schema or bands, dtype, nodata, extent, counts. |
51
+ | `check PATHS` | Run the applicable checks and write a JSON or Markdown evidence report (English or Arabic). |
52
+ | `preflight PATHS --plan plan.json` | Check a declared processing plan against the real inputs before running it. |
53
+ | `manifest write` / `manifest verify` | Record and verify a deterministic run manifest (inputs, outputs, parameters). |
54
+ | `route "TASK" [--data PATH]` | Retrieve the skill sections worth reading, using the task text and inspected datasets. |
179
55
 
180
- ### Evidence grades
56
+ Checks cover CRS and units, geometry validity and GeoJSON winding, record counts, raster nodata, 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`.
181
57
 
182
58
  | Grade | Arabic label | Meaning |
183
59
  |---|---|---|
184
- | Decision-grade | جاهز للقرار | Every check in the run passed. |
185
- | Review required | يحتاج مراجعة | At least one check warned; none failed and none could not run. |
186
- | Advisory only | استرشادي فقط | At least one check failed or could not run (`not-run`). A run with no checks is also Advisory only. |
187
-
188
- Exit codes: `0` Decision-grade, `2` Review required, `3` Advisory only, `1` usage error or unreadable input.
60
+ | Decision-grade | جاهز للقرار | Every check that ran passed. |
61
+ | Review required | يحتاج مراجعة | At least one check warned; none failed or could not run. |
62
+ | Advisory only | استرشادي فقط | At least one check failed or could not run, or no check ran. |
189
63
 
190
64
  The grade describes the data path and the checks that ran. It is not a certification of survey, engineering, legal, or safety fitness.
191
65
 
192
- Arabic Markdown reports translate the labels, headings, status words, and the limitation sentence. Check messages, file paths, check ids, and numbers stay as produced (messages are in English).
193
-
194
66
  ---
195
67
 
196
- ## Skill router (Python)
197
-
198
- `python -m terraproof route` is the Python skill router (Phase 3). Given a task description, it returns the few skill sections worth reading, each with the reasons for its score. It is offline, deterministic, and lexical; there is no model call. Setup is the same as [Python core](#python-core-phase-1-experimental); text-only routing is dependency-light, because the inspectors load only when you pass `--data`.
199
-
200
- How it ranks:
201
-
202
- - **BM25 over skill sections.** Every section of `SKILL.md` and the reference files is indexed. A skill's score is its best-matching section plus a quarter of its second best, so a skill ranks on the passage that matches, not on its length.
203
- - **Exact triggers.** The technology and capability phrases in each `skill.json` add deterministic boosts when they occur as whole phrases. A bare `map` is deliberately weak.
204
- - **Explained data-aware rules.** With `--data`, each local dataset is inspected first: CRS, bands, dtype, scale/offset, geometry types, feature counts, STAC collection. The profile then adds or subtracts score, and the reason is printed. A geographic CRS under metric wording (area, buffer, distance, metres) promotes `crs-and-units`; an integer band with a non-identity scale/offset promotes `satellite-preprocessing`; several rasters promote `raster-processing`; a raster-only input penalises vector skills, and a vector-only input penalises raster skills; a print-figure request penalises the web-map skill; a STAC item already in hand for processing penalises the catalog-search skill.
205
- - **Arabic and Egyptian dialect.** Text is normalized before matching: diacritics and tatweel are dropped, NFKC is applied, and `أ/إ/آ/ٱ → ا`, `ى → ي`, `ة → ه`. Attached conjunctions, prepositions, and articles are tried (`ال`, `وال`, `بال`, `لل`, `ف`, `ب`, `ل`, `و`), and a curated lexicon maps Arabic phrases, including Egyptian forms such as `نزل` (download) and `دور على` (look for), to English retrieval terms. Latin technical tokens (`Sentinel-2`, `SCL`, `NDVI`) are matched as written, which is how these prompts are usually typed.
206
- - **Process skills are separate.** `brainstorming`, `writing-plans`, `systematic-debugging`, and `verification` are never mixed into the ranked domain skills. The `process` field lists the ones whose wording appears in the task, followed by `verification`.
207
-
208
- CLI usage:
209
-
210
- ```bash
211
- python -m terraproof route "TASK" [--data PATH ...] [--top-k N] [--mode ranked|candidates] [--semantic] [--format json|md]
212
- ```
213
-
214
- `--data` takes one or more local datasets and can be repeated; `--top-k` defaults to 5 and `--format` to `json`. `--format md` prints a readable digest of the same result, and JSON stays the stable machine-readable form. The command exits `0` and writes nothing.
68
+ ## Use it from your agent
215
69
 
216
- English example:
70
+ ### MCP server
217
71
 
218
72
  ```bash
219
- python -m terraproof route "Mask clouds in Sentinel-2 L2A with the SCL band, then compute NDVI" --format json
73
+ python -m terraproof.mcp # stdio server; needs the `mcp` extra
220
74
  ```
221
75
 
222
- The result is deterministic for a fixed registry and input. Each reason names the matched section, lexical contributions, and any exact triggers that fired.
76
+ It is read-only and offline, with six tools: `preflight`, `inspect_dataset`, `run_checks`, `list_skills`, `load_section`, and `find_guidance`. CLI and MCP return the same reports.
223
77
 
224
- Arabic example:
78
+ ### Install into a project
225
79
 
226
80
  ```bash
227
- python -m terraproof route "اضبط scale و offset لصور Sentinel-2 L2A قبل حساب NDVI" --format md
81
+ python -m terraproof.install --agent claude --task "NDVI change for 2020-2024" --target DIR --with-mcp
82
+ python -m terraproof.install --agent cursor --skills gdal,crs-and-units --target DIR --dry-run
228
83
  ```
229
84
 
230
- It reports `Language: ar` and shows the normalized Arabic expansion and selected sections. Only your task line and matched Arabic terms are Arabic: reasons and section excerpts remain the English skill text, and JSON keeps your prompt verbatim.
231
-
232
- Evaluate a routing set with the bundled evaluator:
233
-
234
- It prints JSON with `items`, `top_k`, recall, per-language recall, `must_not` violations, and every failing item, and exits `1` when mean recall is below `--min-recall` or a forbidden skill is ranked. `evals/routing/dev.jsonl` is the permitted tuning/regression set; independent held-out sets are not part of routine development or this acceptance run. The evaluator measures retrieval only, not agent performance.
235
-
236
- Limits: this is lexical retrieval with hand-written rules, not semantic understanding. Candidate mode returns a deterministic recall-oriented list (default cap 8) for optional host-side selection; ranked mode retains its existing cap and thresholds. Dataset rules fire once per request and only from the keys the inspectors report, so a misleading or missing profile leads to a misleading boost.
237
-
238
- ---
85
+ | `--agent` | Skills are written to | MCP config (`--with-mcp`) |
86
+ |---|---|---|
87
+ | `claude` | `.claude/skills/<skill>/` | `.mcp.json` |
88
+ | `codex` | `.agents/skills/<skill>/` and `AGENTS.md` | `.codex/config.toml` |
89
+ | `cursor` | `.cursor/rules/terraproof-<skill>.mdc` | `.cursor/mcp.json` |
90
+ | `gemini` | `GEMINI.md` | `.gemini/settings.json` |
91
+ | `copilot` | `.github/instructions/terraproof-<skill>.instructions.md` | `.vscode/mcp.json` |
92
+ | `opencode` | `AGENTS.md` | `opencode.json` |
239
93
 
240
- ## MCP server
94
+ 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.
241
95
 
242
- The MCP server exposes the same inspectors, checks, skill sections, and router to any Model Context Protocol client, so an agent gets identical results whether it calls the CLI or a tool. It is read-only: it never writes files and never uses the network.
96
+ ### Route and export with the Node CLI
243
97
 
244
98
  ```bash
245
- python -m pip install -e ".[mcp]" # Windows: .venv\Scripts\python -m pip install -e ".[mcp]"
246
- python -m terraproof.mcp # serve over stdio
99
+ npx terraproof route "Design a PostGIS schema for GPS tracks" --collection gis --dry-run
100
+ npx terraproof bundle "TASK" --out context.md # one reviewable context file
101
+ npx terraproof apply "TASK" --target ./demo/.agents/skills --dry-run # export skill folders
102
+ npx terraproof validate
247
103
  ```
248
104
 
249
- The `mcp` extra installs the official MCP Python SDK 2.x (`mcp>=2.3,<3`); the base install stays dependency-light, and `inspect`, `check`, and `route` keep working without it. Register the server in your client with a stdio entry whose command is the interpreter that has the package installed and whose arguments are `-m terraproof.mcp`, or let [`python -m terraproof.install --with-mcp`](#install-into-your-agent) write that entry for you.
250
-
251
- Six tools:
252
-
253
- - `preflight(paths, plan, lang?)` — validate a declared plan (a JSON object or local JSON file path) against inspected inputs and return the evidence report without running processing.
254
- - `inspect_dataset(path)` — profile one local vector, raster, or STAC Item file: CRS and units, schema or bands, dtype, nodata, extent, resolution, and feature or pixel counts.
255
- - `run_checks(paths, operation?, compare_to?, resampling?, categorical?, expect?, lang?, ...)` — run checks and return the grade, exit code, JSON report, and Markdown in `en` or `ar`. Phase 4 parameters are `reference_input`, `encoding`, `qa_path`, `qa_kind`, `time_range`, `sar_expect`, `accuracy_samples`, `class_areas`, `min_per_class`, `estimates_requested`, `manifest`, and `require_provenance`; CLI flags use hyphens, with `--qa` for `qa_path`. Samples accept CSV/JSON file paths (or records through MCP); class areas accept a JSON file path (or a mapping through MCP).
256
- - `list_skills()` — list the registered skills with their layer, one-sentence explanation, section ids and titles, and the check ids they bear on.
257
- - `load_section(skill, section_id)` — return one section's Markdown text, without reading the whole `SKILL.md`.
258
- - `find_guidance(task, data_paths?, top_k?, mode?, semantic?)` — retrieve skill sections and inspect the given datasets; `mode="candidates"` provides host-selectable candidates and `semantic=true` enables the optional cached local model. This is the retrieval `python -m terraproof route` performs.
105
+ `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).
259
106
 
260
107
  ---
261
108
 
262
- ## Install into your agent
263
-
264
- The installer writes Terraproof into one project in that agent's own format, instead of a shared `.agents/` folder:
265
-
266
- ```bash
267
- python -m terraproof.install --agent {claude,cursor,codex,gemini,copilot,opencode} --skills a,b --target DIR [--with-mcp] [--dry-run]
268
- python -m terraproof.install --agent cursor --task "NDVI change for 2020-2024" --target DIR
269
- ```
109
+ ## Skills
270
110
 
271
- Give either `--skills` (comma-separated names from `routing/registry.json`) or `--task` (routed by the Python router), never both. `--target` must already exist. `--with-mcp` also registers the Terraproof MCP server, and `--dry-run` prints the planned writes and changes nothing. The command exits `0` on success and `1` for a usage error such as an unknown skill name or a missing target.
111
+ | Area | Skills |
112
+ |---|---|
113
+ | Process | `brainstorming`, `writing-plans`, `systematic-debugging`, `verification` |
114
+ | Mapping and GIS | `gdal`, `crs-and-units`, `raster-processing`, `vector-quality`, `geopandas`, `design-postgis-tables`, `geoparquet-validation`, `geospatial-frontend`, `networkx` |
115
+ | Remote sensing | `satellite-preprocessing`, `spectral-indices`, `sar-basics`, `time-series-and-change`, `accuracy-assessment`, `geomaster`, `geozarr` |
116
+ | Data access | `geospatial-data-discovery`, `stac-and-cloud-access` |
117
+ | Analysis and figures | `statistical-analysis`, `scientific-visualization` |
272
118
 
273
- What each agent gets (`<skill>` stands for one selected skill):
274
-
275
- | `--agent` | Skill files | MCP config with `--with-mcp` |
276
- |---|---|---|
277
- | `claude` | `.claude/skills/<skill>/` — the full skill folder | `.mcp.json` (`mcpServers`) |
278
- | `cursor` | `.cursor/rules/terraproof-<skill>.mdc` — one rule per skill | `.cursor/mcp.json` (`mcpServers`) |
279
- | `codex` | `.agents/skills/<skill>/` plus a block in `AGENTS.md` | `.codex/config.toml` (`[mcp_servers.terraproof]`) |
280
- | `gemini` | a block in `GEMINI.md` with the skill text inline | `.gemini/settings.json` (`mcpServers`) |
281
- | `copilot` | `.github/instructions/terraproof-<skill>.instructions.md` | `.vscode/mcp.json` (`servers`) |
282
- | `opencode` | a block in `AGENTS.md` with the skill text inline | `opencode.json` (`mcp`) |
283
-
284
- Every format above was checked against that agent's own documentation; the source URL is cited next to the writer in `src/terraproof/install/agents.py`.
285
-
286
- Merge and idempotency: nothing is written outside `--target`. An existing JSON or TOML config is parsed and merged, so other servers, keys, and tables survive, and only the `terraproof` server entry is replaced. Markdown goes between agent-scoped markers (`<!-- terraproof:<agent>:begin -->` and `<!-- terraproof:<agent>:end -->`); a rerun replaces only that agent's block and leaves the rest of the file alone. If a legacy unscoped `<!-- terraproof:begin -->` / `<!-- terraproof:end -->` block exists, the installer migrates it to the current agent's scoped marker and prints a note. A rerun with the same inputs produces identical bytes, unchanged files are reported as `unchanged` and not rewritten, and the recorded MCP command is the interpreter that ran the installer. Skill copies skip `UPSTREAM.md` and `skill.json`.
287
-
288
- Known limits:
289
-
290
- - **Claude Code** (2.1.292) reads the generated `.mcp.json` and lists `terraproof`, but project MCP servers start as "Pending approval"; an interactive `claude` session is required to approve the server before it connects.
291
- - **Codex CLI** (0.160.1) parses the generated `.codex/config.toml`, but only loads project-scoped config for trusted projects. Verified by copying the same TOML into an isolated `CODEX_HOME`: `codex mcp list` / `codex mcp get terraproof` show the stdio server correctly.
292
- - **Gemini CLI** (0.62.0) reads the generated `.gemini/settings.json` and reports `terraproof` as a configured stdio server, but `gemini mcp list` suppresses all servers (project and user-level) in an untrusted folder. Trusting the workspace is required to list, enable, or connect to the server.
293
- - The other three agents (`cursor`, `copilot`, `opencode`) are unit-tested against their documented file layouts (`tests/python/test_install.py`); they have not been loaded by those agents here.
294
- - Writing the files does not prove the host loaded them or that the agent followed the guidance. Verify an installed setup in the agent itself, as you would verify any agent-generated work.
119
+ 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).
295
120
 
296
121
  ---
297
122
 
298
- ## Skills (v0.2.0)
299
-
300
- ### Process & Verification
301
- - `brainstorming` — Explore intent, requirements, and design options before implementation.
302
- - `writing-plans` — Produce detailed, executable task-by-task engineering plans.
303
- - `systematic-debugging` — Structured root-cause investigation for bugs and errors.
304
- - `verification` — Validate completeness and truthfulness before declaring work done.
305
-
306
- ### Mapping & GIS
307
- - `gdal` — Raster and vector CLI recipes: reprojection, clipping, mosaics, and COGs.
308
- - `design-postgis-tables` — PostGIS table design, geometry vs geography, spatial indexing.
309
- - `geoparquet-validation` — GeoParquet metadata validation and cloud-native vector distribution.
310
- - `geospatial-frontend` — MapLibre GL and geospatial visualization interfaces.
311
- - `crs-and-units` — Coordinate reference systems, axis order, datum transformations, and measurement units.
312
- - `raster-processing` — Raster reading, grid alignment, resampling, nodata and masks, and COG delivery checks.
313
-
314
- ### Remote Sensing & Earth Observation
315
- - `geomaster` — Earth observation, satellite processing, spectral indices, terrain, and spatial ML.
316
- - `geospatial-data-discovery` — Open geospatial data acquisition (STAC, OSM, Overture, Sentinel, Landsat, DEMs).
317
- - `geozarr` — Multidimensional geospatial raster and cube arrays.
318
- - `satellite-preprocessing` — Sentinel-2 L2A and Landsat Collection 2 surface reflectance decoding, QA masks, and composites.
319
- - `spectral-indices` — NDVI, NDWI/MNDWI, NBR/dNBR, EVI, and SAVI from calibrated, masked reflectance.
320
-
321
- ### Spatial Analysis & Visualization
322
- - `geopandas` — Vector operations, spatial joins, geometric overlays, and CRS transforms.
323
- - `vector-quality` — Geometry validity and repair, duplicate and coverage audits, and join cardinality checks.
324
- - `scientific-visualization` — Publication-ready figures with colorblind-safe palettes and multi-panel layouts.
325
- - `statistical-analysis` — Hypothesis testing, assumption diagnostics, effect sizes, and power analysis.
326
- - `networkx` — Graph structures, centrality, community detection, and shortest paths.
123
+ ## Evaluation status
327
124
 
328
- ---
329
-
330
- ## Preset Collections
331
-
332
- | Collection | Description | Included Skills |
333
- |---|---|---|
334
- | `gis` | Geospatial engineering and mapping | `geomaster`, `geopandas`, `gdal`, `geospatial-data-discovery`, `verification` |
335
- | `data-analysis` | Statistical modeling and scientific figures | `statistical-analysis`, `scientific-visualization`, `verification` |
336
- | `production` | Core engineering discipline and debugging | `brainstorming`, `writing-plans`, `systematic-debugging`, `verification` |
337
- | `remote-sensing` | Optical satellite preprocessing, spectral indices, raster processing, and verification | `geospatial-data-discovery`, `satellite-preprocessing`, `spectral-indices`, `raster-processing`, `verification` |
125
+ - **Checks:** 27 executable eval tasks with independent oracles pass with 0 false passes. 15 seeded wrong outputs are still caught only by the oracle, not by the checks (declared blind spots). See [`evals/README.md`](evals/README.md).
126
+ - **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.
127
+ - **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).
128
+ - **Real hosts:** tool use through MCP has been verified with Codex and Claude Code. Cursor, Copilot and OpenCode are unit-tested against their documented layouts only.
338
129
 
339
130
  ---
340
131
 
341
- ## Repository Overview
132
+ ## Repository
342
133
 
343
- - **`skills/`** — Task-specific instructions, scripts, and references (24 skills, each with a `skill.json` routing manifest).
344
- - **`routing/`** — Skill registry generated from `skills/*/skill.json`, check catalog, scoring rules, and preset collections.
345
- - **`router/`** — Deterministic TypeScript routing engine with CLI and programmatic API.
346
- - **`evals/`** — 27 executable benchmark task specifications plus the deterministic harness and permitted routing regression set `evals/routing/dev.jsonl`, scored by `python -m terraproof.router.evaluate`.
347
- - **`src/terraproof/`** — Python package: dataset inspectors, checks, evidence reports, the skill router and its evaluator, the read-only MCP server, and the native agent installers (`pyproject.toml`).
348
- - **`instructions/`** — Universal engineering rules (engineering discipline, simplicity, security).
349
- - **`tests/`** — Router test suites (73 scenarios), Python tests for the checks, router, MCP server, evals, and installers (`tests/python/`), and upstream fixtures.
350
- - **`third_party/`** — Upstream licenses and notices for vendored material.
351
- - **`sources/`** — Attribution log mapping each skill to its upstream source, commit SHA, and license.
134
+ | Path | Contents |
135
+ |---|---|
136
+ | `skills/` | The 24 skills |
137
+ | `routing/` | Generated skill registry, check catalog, rules, and collections |
138
+ | `router/` | TypeScript router and CLI (the npm package) |
139
+ | `src/terraproof/` | Python package: inspectors, checks, reports, router, MCP server, installers, evals |
140
+ | `evals/` | Eval task specs and routing sets |
141
+ | `tests/` | Router, Python, package, and release-validation tests |
142
+ | `instructions/` | Universal engineering rules shipped with the skills |
143
+ | `docs/` | [Release checklist](docs/RELEASE_CHECKLIST.md) and [design plans](docs/plans/) |
144
+ | `sources/`, `third_party/` | Upstream attribution and licenses |
352
145
 
353
- ---
146
+ To contribute, see [`CONTRIBUTING.md`](CONTRIBUTING.md). Changes are listed in [`CHANGELOG.md`](CHANGELOG.md).
354
147
 
355
148
  ## License
356
149
 
357
- This project is licensed under the [MIT License](LICENSE). Vendored and adapted components keep their upstream licenses (MIT, Apache-2.0, 3-clause BSD) as documented in `third_party/` and `sources/SOURCES.md`.
150
+ [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).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "terraproof",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "evidence-graded skills, tools, and checks for mapping and remote-sensing AI agents. By Geova.",
5
5
  "type": "module",
6
6
  "main": "./dist/router/index.js",
@@ -25,6 +25,10 @@
25
25
  "family": "geometry",
26
26
  "description": "The layer holds one geometry family; single and multi-part types count together."
27
27
  },
28
+ "geometry.winding": {
29
+ "family": "geometry",
30
+ "description": "GeoJSON polygon rings follow the RFC 7946 right-hand rule: counterclockwise exteriors, clockwise holes."
31
+ },
28
32
  "scope.record_count": {
29
33
  "family": "scope",
30
34
  "description": "The output feature count is compared with a reference dataset's count."
@@ -43,7 +47,7 @@
43
47
  },
44
48
  "raster.cog_layout": {
45
49
  "family": "raster",
46
- "description": "Heuristic layout screen for GeoTIFFs: tiled, with internal overviews unless the raster fits in one block; not COG validation."
50
+ "description": "Heuristic layout screen for GeoTIFFs: tiled, with internal overviews unless the raster fits in one block, and not lossy JPEG; not COG validation."
47
51
  },
48
52
  "rs.reflectance_range": {
49
53
  "family": "rs",