Skip to content

Commit bc30aa7

Browse files
committed
test all nouns
1 parent c21d525 commit bc30aa7

45 files changed

Lines changed: 1794 additions & 157 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎PROMPT_LOG.md‎

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,3 +2333,149 @@ secrets, credentials, private tokens, or unrelated transcript text.
23332333
scientifically declared cross-grid alignment. Each must satisfy source,
23342334
CRS, boundary, units, temporal-support, missingness, and QA contracts before
23352335
a dependency design is promoted to executable.
2336+
2337+
## 2026-08-26 - Lightweight semantic grammar and analysis coach
2338+
2339+
### User goal
2340+
2341+
- Make the existing `pipe(noun) | verb() | verb()` grammar semantically
2342+
inspectable and helpful to scientists and future agents without adding a DSL,
2343+
rewriting user order, or requiring new user-facing object classes.
2344+
- Add noun and verb metadata, state tracking, deterministic explanations and
2345+
suggestions, metadata-only validation, order knowledge, useful scientific
2346+
errors, diagrams, tests, and readable grammatical keywords.
2347+
2348+
### Design and implementation
2349+
2350+
- Audited the pipe, 62 callable names visible in `cubedynamics.verbs`, 38
2351+
explicit `verbs.__all__` exports, documented state/event/project verbs,
2352+
loaders, output metadata, dimensions, provenance, and information-changing
2353+
operations. Recorded the baseline in `docs/project/grammar_inventory.md`.
2354+
- Added `cubedynamics.grammar`, a lightweight registry and inference layer with
2355+
nine semantic states: observation, continuous field, categorical field,
2356+
condition, event, feature, relationship, summary, and network. Verb contracts
2357+
declare human descriptions, accepted/returned states, requirements,
2358+
preservation/removal effects, ownership categories, and examples.
2359+
- Registered every callable in `verbs.__all__` plus documented state, event,
2360+
synchrony, and biology verbs. Conceptual future verbs are present only in
2361+
order-rule metadata with `implemented=False`; they are never offered as
2362+
runnable suggestions.
2363+
- Extended `Pipe` with immutable `semantic_state` and `semantic_trace`, plus
2364+
deterministic `explain()`, `suggest()`, and `validate()` methods. Pipe still
2365+
calls each stage exactly once in written left-to-right order. Plain,
2366+
unregistered Python callables remain valid and need no subclass or registry
2367+
step.
2368+
- Added semantic preflight errors for incompatible kinds, missing temporal or
2369+
spatial support, removed time variation, unordered time, and obvious CRS or
2370+
dimension conflicts for aligned-state overlap. Underlying execution errors
2371+
remain unchanged outside known semantic incompatibilities.
2372+
- Added the four requested order categories and the complete starter response
2373+
set, including both directions for near/density, intersect/density,
2374+
intersect/summarize, clip/summarize, filter/change, subtract/divide,
2375+
normalize/threshold, and upstream/intersect. Rules are neutral,
2376+
deterministic, and do not mutate pipelines.
2377+
- Added semantic metadata to scientific nouns, state/event/overlap outputs, and
2378+
spatial block summary/comparison outputs so metadata survives unwrap and
2379+
re-pipe workflows. Added backward-compatible `over=` to `mean`, `variance`,
2380+
`anomaly`, and `zscore`; `dim=` remains supported and conflicts are explicit.
2381+
2382+
### Documentation and validation
2383+
2384+
- Added `docs/concepts/semantic_grammar.md` with state and architecture
2385+
diagrams, explain/suggest/validate examples, order categories, and a
2386+
near→density versus density→near interpretation table. Updated Pipe, grammar,
2387+
public API, README, and MkDocs navigation pages.
2388+
- Added `tests/test_grammar_semantics.py` for exact order/no rewriting, state
2389+
transitions, explanations, suggestions, reports, semantic errors, lost
2390+
information, all order rules, public verb registry coverage, CRS conflicts,
2391+
metadata propagation, and keyword compatibility. Expanded noun metadata
2392+
assertions and retained focused regression coverage for VirtualCube,
2393+
synchrony, spatial-block, plotting, and public APIs.
2394+
- Final focused affected-area run: 84 passed. An additional post-stall group
2395+
covering plotting, shape/statistical verbs, vignettes, and VirtualCube paths
2396+
passed 21 tests. `mkdocs build --strict`, Python compilation, and
2397+
`git diff --check` passed.
2398+
- The required offline suite reached 349 passed, 3 skipped, and 9 deselected
2399+
with no failures, then encountered the repository's pre-existing Matplotlib
2400+
backend stall and was interrupted after about 97 seconds. The six semantic
2401+
compatibility regressions found on the first broad run were corrected; their
2402+
complete affected suites subsequently passed.
2403+
2404+
### Known limitations and next work
2405+
2406+
- Runtime inference is strongest for xarray, VirtualCube, EventResult, and
2407+
metadata-bearing project outputs. Custom non-xarray objects fall back to an
2408+
observation state unless their project adds semantic attrs or registry
2409+
metadata.
2410+
- Some broad project/integration contracts are intentionally conservative and
2411+
should be refined alongside their owning workflows. Unit compatibility is
2412+
reported and preserved, but cross-object unit conversion/reconciliation
2413+
awaits verbs that actually combine numeric quantities.
2414+
- High-value next work is to let external verb packages contribute registry
2415+
entries through a documented registration hook, then implement vetted
2416+
feature/network nouns and verbs such as near, density, intersect, summarize,
2417+
and upstream against explicit CRS, boundary, unit, and provenance contracts.
2418+
2419+
## 2026-08-26 - Interrupted-work audit and Phase 1 source-QA completion
2420+
2421+
### User goal
2422+
2423+
- Re-read the interrupted publication, Decision Lab, and semantic-grammar
2424+
briefs and complete work left unfinished when earlier tasks hit usage limits.
2425+
- Keep examples observational, reproducible, validated, and suitable for the
2426+
publication website.
2427+
2428+
### Audit and decisions
2429+
2430+
- Re-audited the three pasted briefs and the resulting repository changes. The
2431+
semantic grammar is implemented and tested. The Decision Lab intentionally
2432+
contains one executable real-data vignette and four clearly labeled
2433+
dependency designs because the required feature/network nouns and verbs do
2434+
not yet exist; no speculative APIs or fake data were promoted as runnable.
2435+
- Identified the remaining Phase 1 publication gap: gridMET and Sentinel-2 had
2436+
no reviewed numerical/visual baseline, and their dataset pages referenced
2437+
text files masquerading as PNG previews. PRISM also retained an obsolete
2438+
placeholder despite already having reviewed QA evidence.
2439+
2440+
### Implementation
2441+
2442+
- Added small real-data gridMET and Sentinel-2 fixtures with checksums, source
2443+
requests, and provenance under `data/source_qa/`, plus a reproducibility
2444+
README and `scripts/build_phase1_qa_fixtures.py`.
2445+
- Expanded `scripts/run_source_qa.py` to validate PRISM, gridMET maximum
2446+
temperature, and Sentinel-2 B04/B08 plus derived NDVI. Checks cover checksum,
2447+
source, CRS, dates, finite data, coordinate order and resolution, bounds,
2448+
broad physical/scale limits, and source-specific invariants. It writes JSON,
2449+
figures, and a consolidated manifest.
2450+
- Replaced gridMET, Sentinel-2, and PRISM placeholder previews with reviewed
2451+
real-data QA figures and documented exact evidence and limitations.
2452+
- Removed older FIRED, Landsat, and fire-workflow text files masquerading as
2453+
PNGs. Their pages now state the missing QA evidence explicitly instead of
2454+
displaying or soliciting an unvalidated screenshot; the asset policy now
2455+
prohibits synthetic or text image placeholders.
2456+
- Found duplicate Sentinel-2 catalog records for identical acquisitions. The
2457+
loader now keeps the newest `s2:generation_time` record using STAC metadata
2458+
only, preserving lazy imagery, and records the selection in output attrs.
2459+
- Corrected the Sentinel-2 citation from a stale MODIS reference to the
2460+
Copernicus/ESA Level-2A product.
2461+
2462+
### Validation
2463+
2464+
- A bounded live Sentinel-2 request to the Planetary Computer passed and
2465+
confirmed unique, strictly ordered acquisition times after deduplication.
2466+
- Offline source QA passed for all three source adapters, and the gridMET and
2467+
Sentinel-2 figures were visually inspected for readable, plausible output.
2468+
- The combined affected-area suite passed 84 tests. A final focused
2469+
deduplication/live request passed 2 tests; its only warning is an upstream
2470+
Planetary Computer Pydantic deprecation.
2471+
- `scripts/run_decision_qa.py` passed. `scripts/run_vignettes.py` executed all
2472+
nine supported notebooks offline and confirmed their static plot outputs.
2473+
- `mkdocs build --strict`, Python compilation, and `git diff --check` passed.
2474+
2475+
### Limitations
2476+
2477+
- The baselines validate the named variables, places, and time windows, not
2478+
every product permutation. gridMET maximum temperature is representative of
2479+
the adapter; Sentinel-2 pixel-level cloud masking is not yet implemented.
2480+
- gridMET still downloads annual files before local AOI selection. Live tests
2481+
remain separate from deterministic offline fixture checks.

‎README.md‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,13 @@ cube = data.temperature(
7777

7878
result = (
7979
pipe(cube)
80-
| v.anomaly(dim="time")
81-
| v.variance(dim="time", keep_dim=False)
82-
).unwrap()
80+
| v.anomaly(over="time")
81+
| v.variance(over="time", keep_dim=False)
82+
)
83+
84+
print(result.explain())
85+
validated = result.validate()
86+
summary = result.unwrap()
8387
```
8488

8589
Loading names the scientific noun and source flavor. The pipe stays focused on
@@ -111,6 +115,7 @@ clipped = (pipe(cube) | clip_values(0, 1)).unwrap()
111115
Key entry points:
112116

113117
- [Core grammar versus project verbs](https://cu-esiil.github.io/cubedynamics/concepts/core_and_projects/)
118+
- [Semantic grammar and analysis coaching](https://cu-esiil.github.io/cubedynamics/concepts/semantic_grammar/)
114119
- [Narrative, executable vignettes](https://cu-esiil.github.io/cubedynamics/vignettes/)
115120
- [Write a custom verb project](https://cu-esiil.github.io/cubedynamics/extending/custom_verbs/)
116121
- [Public API and stability](https://cu-esiil.github.io/cubedynamics/project/public_api/)

‎data/source_qa/README.md‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Phase 1 real-data QA fixtures
2+
3+
These small NetCDF files are bounded extracts from observational products used
4+
to keep publication QA deterministic and offline-capable. They are not
5+
synthetic data and are not alternative production backends.
6+
7+
| Fixture | Product | Coverage | Purpose |
8+
| --- | --- | --- | --- |
9+
| `gridmet_badlands_july_2001.nc` | gridMET daily maximum temperature | Badlands, South Dakota; 10 days in July 2001 | Source, grid, time, units, range, and visual checks |
10+
| `sentinel2_badlands_june_2023.nc` | Sentinel-2 L2A B04/B08 reflectance | Badlands, South Dakota; bounded June 2023 scenes | Source, CRS, bands, acquisition identity, scale, NDVI, and visual checks |
11+
12+
Each fixture has a sibling provenance JSON containing its source request,
13+
creation method, and SHA-256 checksum. The QA runner refuses a fixture whose
14+
bytes no longer match that record.
15+
16+
PRISM uses the existing real-data fixture in `data/vignettes/`. To rebuild the
17+
two fixtures in this directory, run:
18+
19+
```bash
20+
python scripts/build_phase1_qa_fixtures.py
21+
```
22+
23+
That command uses public upstream services and therefore requires network
24+
access. Routine validation is fully offline:
25+
26+
```bash
27+
python scripts/run_source_qa.py
28+
```
29+
30+
The reviewed report is published at `docs/data/phase1_qa.md`. A passing
31+
fixture is evidence for the exact product, variable, place, and time window
32+
listed above; it is not a claim that every variable or geography has received
33+
scientific validation.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"created_at": "2026-08-26T12:55:49.518657+00:00",
3+
"fixture_sha256": "a36b2c4e1164d0a85429bc855fd94b32eb708a0f72e6be96f4959fc92bfe2721",
4+
"product": "gridMET daily maximum temperature",
5+
"provider": "University of Idaho",
6+
"query": {
7+
"bbox": [
8+
-102.5,
9+
43.6,
10+
-101.9,
11+
44.2
12+
],
13+
"end": "2001-07-10",
14+
"start": "2001-07-01",
15+
"variable": "tmmx"
16+
},
17+
"source_file_sha256": "a0e07daeb1aa8b58b66f01dcc99e776ab71a163aa80dbef448c972b74fed313a",
18+
"source_url": "https://www.northwestknowledge.net/metdata/data/tmmx_2001.nc",
19+
"transformation": "cropped and renamed dimensions/variable; values unchanged"
20+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"catalog": "Microsoft Planetary Computer STAC",
3+
"fixture_sha256": "eb7c02b01bc741483d28714f7081e08639282685705d5d7a15ff44bf7e97672a",
4+
"product": "Sentinel-2 Level-2A surface reflectance",
5+
"provider": "European Union Copernicus Programme / ESA",
6+
"query": {
7+
"bands": [
8+
"B04",
9+
"B08"
10+
],
11+
"cloud_lt": 80,
12+
"edge_size": 64,
13+
"end": "2023-06-10",
14+
"lat": 43.89,
15+
"lon": -102.18,
16+
"resolution": 10,
17+
"start": "2023-06-01"
18+
},
19+
"retrieved_at": "2026-08-26T12:55:51.112347+00:00",
20+
"scene_cloud_cover_percent": [
21+
72.819281,
22+
13.389252
23+
],
24+
"scene_ids": [
25+
"S2B_MSIL2A_20230602T173909_R098_T13TGJ_20240911T145543",
26+
"S2A_MSIL2A_20230607T173911_R098_T13TGJ_20240927T100945"
27+
],
28+
"transformation": "selected B04/B08, cropped to 640 m square, converted to float32; values unchanged"
29+
}

‎docs/api/pipe.md‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,18 @@ surface.
1212

1313
1. Wrap a value with :func:`cubedynamics.pipe` to opt into piping.
1414
2. Apply verbs or callables with ``|``; each stage receives the previous value.
15-
3. Finish with :meth:`Pipe.unwrap` (or rely on rich reprs in notebooks).
15+
3. Optionally inspect the semantic trace with ``explain()``, ``suggest()``, or
16+
``validate()``.
17+
4. Finish with :meth:`Pipe.unwrap` (or rely on rich reprs in notebooks).
1618

1719
```python
1820
import cubedynamics as cd
1921
from cubedynamics import pipe, verbs as v
2022

2123
cube = cd.gridmet(lat=40.0, lon=-105.2, start="2020-06-01", end="2020-07-01", variable="tmmx")
22-
result = (pipe(cube) | v.mean(dim="time") | v.zscore(dim="time")).unwrap()
24+
analysis = pipe(cube) | v.anomaly(over="time") | v.mean(over=("y", "x"))
25+
print(analysis.explain())
26+
result = analysis.unwrap()
2327
```
2428

2529
Rich repr example that keeps the viewer attached:
@@ -44,6 +48,15 @@ Container holding the wrapped value. Key methods:
4448
* ``__or__(func)`` – apply ``func`` to the wrapped value and return a new Pipe; respects passthrough verbs that attach viewers without replacing the object.
4549
* ``unwrap()`` – return the wrapped value.
4650
* ``v`` – property alias for the wrapped value.
51+
* ``semantic_state`` – metadata-only description of the current result.
52+
* ``semantic_trace`` – immutable record of executed pipe stages.
53+
* ``explain()`` – deterministic plain-language read-back of the analysis.
54+
* ``suggest()`` – a short list of compatible, implemented next verbs.
55+
* ``validate()`` – structured metadata, dimension, provenance, and order checks.
56+
57+
These inspection methods never reorder or execute pipeline stages. The result
58+
of each verb remains the object on which the next written verb acts. See
59+
[Semantic grammar and analysis coaching](../concepts/semantic_grammar.md).
4760

4861
### ``cubedynamics.piping.Verb``
4962
Lightweight wrapper for callables used in pipe chains. A verb can flag itself as

‎docs/assets/datasets/README.md‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Dataset preview assets
22

3-
Each dataset page in `docs/datasets/` references a static PNG preview at
4-
`docs/assets/datasets/<dataset-slug>-preview.png`.
3+
Dataset pages may reference reviewed static figures stored here or in
4+
`docs/assets/source_qa/`. Every image must be a genuine render from the named
5+
real dataset and accompanied by reproducible source/provenance and QA details.
56

6-
Codex does not add image binaries. After running the regeneration steps on a
7-
dataset page, save a 1200×700 px screenshot to the corresponding path so the
8-
placeholder link renders on the documentation site.
7+
Do not add text placeholders with image extensions. If reviewed visual
8+
evidence is not available, the dataset page should say so explicitly and omit
9+
the image until the source-specific QA is complete.

‎docs/assets/datasets/fired-preview.png‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎docs/assets/datasets/gridmet-preview.png‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎docs/assets/datasets/landsat8_mpc-preview.png‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)