Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

All notable changes to the learning modules. Versions are per module (`manifest.json` and the manifest embedded in `module.html` carry the same number).

## 2026-11-30 — Contributor path tested end to end

A new standalone lesson was written as an outside contributor would, by following CONTRIBUTING.md literally in a scratch copy (the test lesson is not in the repository). What that found, and what changed. No lesson content changed; module versions are unchanged.
- **A standalone lesson could not pass the tests.** `tests/test_wave2_repo.py` required every module to appear on the flagship course page. It now requires the course's own members there; every module is still required in the README table.
- **The API check failed on a correctly built new lesson.** `createdAt` fell back to a git date, which is empty before the first commit and differs between the contributor's commit, the merge commit and `main`. `createdAt` (YYYY-MM-DD) is now a required manifest field (`scripts/validate_manifests.py`; all 11 lessons already had it) and a test pins that the API copies it.
- **`scripts/new_module.py`** (new, with `scripts/templates/module.html.tmpl`): writes the skeleton of a standalone lesson that has the structure the checks expect and prints the next commands in the order that works. Its `TODO(new_module)` placeholders fail `validate_manifests.py` until they are written. `tests/test_new_module.py` takes a skeleton through render, build, validation, the CSP check and the checkpoint shape in a scratch directory.
- **CONTRIBUTING.md:** a "Start here" section (what to install, the scaffold, how to look at the page); the generated-files order corrected (render the cells before `build_modules.py`); the markup of an executable cell; what the citation gate is and that its tool is not in this repository; `createdAt`; what the usual failing checks mean.
- **Failure messages** of the checks a new lesson usually trips now say what to do (CHANGELOG heading, theme-ratchet baseline, checkpoint shape, typed numeric answer). No check was loosened: unique ids, `downloadUrl`, per-file hashes, CSP and the 250,000-byte page cap are unchanged.

## 2026-11-30 — Author link corrected

Owner request (2026-11-30): "fix the author link". No lesson content changed; module versions are unchanged.

### Course intro-to-hydrology 0.4.2 → 0.4.3
- The author's GitHub handle and links in `course.json` (`authors[0].github`, `authors[0].profileUrl`, `authorUrl`) pointed to an unrelated account; they now point to `galib9690` (`https://github.com/galib9690`). `api/courses.json` regenerated (the `course.json` sha256 and the course `content_sha256` change).
- `tests/test_repo.py`: fails if a link or handle of the wrong account reappears in any tracked file, and if a course author's `profileUrl` or the course `authorUrl` disagrees with the `github` handle.

## 2026-11-30 — Contribution-ready (licences, standalone lessons, credit)

No lesson content changed; module versions are unchanged. Owner approval: "go ahead with the fixes" (2026-11-30), covering CC BY 4.0 for lesson content and MIT for code.
Expand Down
49 changes: 40 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Contributing a Learning Module

## Start here

You need Python with `pytest numpy matplotlib pillow`, and Node (CI uses Python 3.12 and Node 22) for the JavaScript tests and for rendering cells; there is nothing else to install. Run every command from the repository root.

```bash
python -m pip install pytest numpy matplotlib pillow
python scripts/new_module.py my-lesson-id --title "My Lesson Title" --author "Your Name, Your Institution"
```

`scripts/new_module.py` writes `modules/my-lesson-id/` with a `module.html`, `manifest.json` and `README.md` that already have the structure the checks expect (shared theme, accessibility and quiz code behind their markers, one Python cell with its static-output marker, a checkpoint of the required shape, Sources, footer) and prints the commands to run next, in order. The lesson it writes is standalone. Every place you must write is marked `TODO(new_module)`; `validate_manifests.py` fails while one is left. You can also copy an existing lesson instead; the checklist below is the same either way.

To look at the lesson, open `modules/my-lesson-id/module.html` in a browser after `build_modules.py` has run: it renders with no server and no AI-Hydro (the Run buttons are disabled there and the pre-rendered outputs are shown).

## Quick checklist

A lesson can stand alone or belong to a course. **Course membership is not required**: a standalone lesson has no `courseId` or `courseOrder`, and no `course.json` lists it. Items with a bracket are enforced by CI (`.github/workflows/checks.yml`) through the named check; items marked **human review** are not machine-checked and are what the reviewer reads for.
Expand All @@ -12,7 +25,7 @@ Files
- [ ] `modules/<your-id>/data/` and `static/` if the lesson bundles data or pre-rendered outputs (see below)
- [ ] An entry in `CHANGELOG.md`, with a heading of the form `### <your-id> … → <version>` (for example `### <your-id> new → 0.1.0`; the id, an arrow and the manifest version are matched) [`tests/test_repo.py::test_changelog_records_each_version`]
- [ ] A baseline entry for the theme ratchet: run `python tests/test_theme_ratchet.py --write` once the page is final; it records your count of hard-coded colours in `tests/theme_hex_baseline.json`, and the count may only go down afterwards [`tests/test_theme_ratchet.py::test_every_module_has_a_baseline_and_none_is_over_it`]
- [ ] Every DOI the lesson cites passes the cite-verify gate and has a `| <doi> | PASS |` row in `CITATIONS.verified.md` [`tests/test_repo.py::test_every_doi_in_the_modules_passed_the_gate`]
- [ ] Every DOI the lesson cites has a `| <doi> | PASS |` row in `CITATIONS.verified.md` [`tests/test_repo.py::test_every_doi_in_the_modules_passed_the_gate`]. The test only finds the row; see "Data and citations" for what the row asserts and who runs the gate

Lesson
- [ ] Renders in a plain browser with no AI-Hydro bridge (standalone rule below); every executable cell has a pre-rendered output, with alt text for each figure [`test_wave2_repo`]
Expand All @@ -22,9 +35,9 @@ Lesson
- [ ] **Human review:** data sources and citations in a Sources & Further Reading section; real data come from `scripts/extract_camels.py` with `data/PROVENANCE.json`; anything else is labelled SYNTHETIC (see "Data and citations"). Only the existing lessons' SYNTHETIC labels are tested; a new lesson's label is read by the reviewer
- [ ] **Human review:** Python cells have been read for risky calls: `python scripts/lint_cell_risk.py` (see "Security review")

Generated files (regenerate, do not edit)
Generated files (regenerate, do not edit; run them in this order)
- [ ] `python scripts/render_static_outputs.py --only <your-id>` first: it runs each cell and stores the output in `static/`. `build_modules.py` stops with "no static output for cell" if a cell has none yet
- [ ] `python scripts/build_modules.py` (inlines shared code, data, manifest and static outputs)
- [ ] `python scripts/render_static_outputs.py`
- [ ] `python scripts/gen_docs.py` (README module table; course page)
- [ ] `python scripts/gen_contributors.py` (CONTRIBUTORS.md)
- [ ] `python scripts/build_api.py` (api/*.json with the per-file sha256)
Expand Down Expand Up @@ -63,14 +76,15 @@ Attribution expected from reuse of a lesson: the author(s) named in its `manifes
"executable": true,
"python": ["numpy"]
},
"citation": { "text": "Author (Year). Title. Venue.", "doi": "10.xxxx/xxxx" }
"citation": { "text": "Author (Year). Title. Venue.", "doi": "10.xxxx/xxxx" },
"createdAt": "2026-11-30"
}
```

Optional: `"contributors": ["Name, Institution"]`, `createdAt`. `courseId` and `courseOrder` are set only by a lesson that a `courses/<dir>/course.json` lists, and must then match it; a standalone lesson has neither. `moduleId` equals the directory name, `version` is `major.minor.patch` and the page footer shows `v<version>`.
`citation.doi` is optional (a book may have none); `citation.text` is needed for `certification.metadata_complete`. Optional: `"contributors": ["Name, Institution"]`. `courseId` and `courseOrder` are set only by a lesson that a `courses/<dir>/course.json` lists, and must then match it; a standalone lesson has neither. `moduleId` equals the directory name, `version` is `major.minor.patch` and the page footer shows `v<version>`.

**Valid levels:** `intro`, `intermediate`, `advanced`. **Suggested topics:** `terrain-analysis`, `streamflow`, `hydrograph`, `water-quality`, `modelling`, `remote-sensing`, `data-access`.
`updatedAt` is not kept in the manifest: the API takes it from the last git commit that touched the module. `createdAt` is optional (otherwise the first commit date is used).
`updatedAt` is not kept in the manifest: the API takes it from the last git commit that touched the module, and `build_api.py --check` ignores it. `createdAt` is required, written `YYYY-MM-DD`: the day the lesson is first proposed. It is not taken from git, because a git date differs between your commit, the pull-request merge commit and `main`, and the API check would then fail on a file you built correctly.

## One manifest, two naming schemes

Expand Down Expand Up @@ -102,6 +116,20 @@ Every module must follow the [AI-Hydro brand guide](https://github.com/AI-Hydro/
Without the `window.aihydro` bridge (a plain browser tab) a module must still be meaningful:

- **Code panes update.** Controls that rewrite a cell's source must do it themselves, then ask the bridge to mirror it (`aihydro.rewriteCell`) only if it is present.
- **An executable cell has this structure** (the checks and the bridge look for these class names and attributes; the cell id is unique on the page):

```html
<div class="aihydro-cell" data-aihydro-cell-id="my-cell" data-language="python">
<div class="aihydro-cell-header">
<span class="aihydro-cell-lang">Python</span>
<span class="aihydro-cell-desc">What the cell does</span>
<button class="run-btn aihydro-run" type="button">Run ▶</button>
</div>
<pre class="aihydro-source">print("the code the learner sees")</pre>
<div class="aihydro-output" aria-live="polite"><!--@@BEGIN static:my-cell@@--><!--@@END static:my-cell@@--></div>
</div>
```

- **Every executable cell shows a pre-rendered output.** Put `<!--@@BEGIN static:<cell-id>@@--><!--@@END static:<cell-id>@@-->` inside the cell's `.aihydro-output`, then run `python scripts/render_static_outputs.py` (it runs each cell headless with `python -s -E` and stores text plus a PNG in `modules/<id>/static/`; add alt text for each figure to `static/alt.json`). The bridge replaces the static block when the learner runs the cell. A cell that cannot run headless (network, a long render) gets an authored note saying so, never made-up output.
- **Interactive widgets work in plain JavaScript.** Where a map or 3-D view needs the bridge, draw a plain fallback in a *separate* element, only when `window.parent === window` and there is no bridge (`shared/cmap.js` has a shaded-relief renderer, `shared/geosketch.js` a longitude/latitude sketch). Never invent geometry.
- **Run buttons** show "Open in AI-Hydro to run" outside the preview.
Expand Down Expand Up @@ -152,7 +180,8 @@ Every control that works by dragging also works from the keyboard (`HydroA11y.sl
## Data and citations

- Real-data slices come from CAMELS-US via `scripts/extract_camels.py` and ship with `data/PROVENANCE.json` (source member, sha256, period, units, QC flags, citations). Label anything else SYNTHETIC; do not give synthetic series real gauge ids.
- Every number a lesson states must come from a cell or from a cited, verified source; run each citation through the cite-verify gate and record it in `CITATIONS.verified.md`.
- Every number a lesson states must come from a cell or from a cited, verified source, recorded in `CITATIONS.verified.md`.
- **The citation gate.** A reference with a DOI is kept only if two or more of Crossref, OpenAlex and Semantic Scholar resolve that DOI to the same work (title, authors, year). The tool the maintainers use for this (`cite-verify`) is not in this repository, so as a contributor: look the DOI up yourself (for example at `https://doi.org/<doi>` and in Crossref), check that title, authors and year match what you cite, and add the row to `CITATIONS.verified.md` with the indexes you checked. **Human review:** the automated test only finds the row; the reviewer re-runs the gate before merging and removes a reference that fails. A book or handbook with no DOI goes in the "Books and handbooks without a DOI" table and is cited without chapter or page numbers you have not checked.

## Checks

Expand All @@ -167,11 +196,13 @@ python scripts/validate_manifests.py # manifests valid; embedded blo
python scripts/check_csp.py # no external hosts except Google Fonts, no eval/fetch/WebSocket
python scripts/build_api.py --check # api/*.json are current (including the per-file sha256)
python scripts/lint_cell_risk.py # reviewer aid: risky calls in cell code (warnings; not a sandbox)
python -m pytest tests -q # use /opt/miniconda3/bin/python -s -E locally in the AI-Hydro workspace
python -m pytest tests -q # maintainers, in the AI-Hydro workspace: /opt/miniconda3/bin/python -s -E
node --test tests/js/*.test.js
```

Regenerate instead of editing by hand: `build_modules.py`, `render_static_outputs.py` (after a cell changes), `gen_docs.py`, `build_api.py`.
Regenerate instead of editing by hand: `render_static_outputs.py` (after a cell changes), `build_modules.py`, `gen_docs.py`, `gen_contributors.py`, `build_api.py`. `build_api.py --check` compares everything except `updatedAt`, so the API you build before committing stays valid after you commit.

A failing check names the lesson and what to do. The usual ones for a new lesson: "CHANGELOG.md needs a heading" (add `### <your-id> new → <version>`), "modules without a baseline" (run `python tests/test_theme_ratchet.py --write`), "static output missing or stale" (run `render_static_outputs.py --only <your-id>`, then `build_modules.py`), "stale: api/modules.json" (run `build_api.py` again after the last edit).

## PR review

Expand Down
6 changes: 6 additions & 0 deletions DECISIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,9 @@ Owner approved the pilot ("go ahead with the three.js feasibility check") and ru
- **Page budget.** watershed-runoff is at 246,682 B of the 250,000 B cap. The added-bytes budget was raised 130,000 → 140,000 for the shared theme code; the cap was not raised. Any further growth in that lesson needs a trim first.
- **Ratchet, not a zero target.** `tests/theme_hex_baseline.json` stores the allowed colour literals per lesson (outside generated regions); it may only go down. Counts before and after are in the file (`main_before` and `max`).

## 2026-11-30 — `createdAt` is a required manifest field; a scaffold instead of a longer checklist

- **`createdAt` comes from the manifest, never from git.** `build_api.py` used the first commit date when a manifest had none. For a new lesson that date is empty before the first commit (the API was built with `null`), then changes when the contributor commits, and again on a squash merge, while `build_api.py --check` compared it; a contributor who followed CONTRIBUTING exactly got "stale: api/modules.json" in CI (reproduced in a scratch clone). Ignoring the field in `--check`, as the Skills repository does for its dates, would have published `null`. Requiring it in the manifest is deterministic and tightens validation; the 11 existing lessons already carried it. `updatedAt` stays git-derived and ignored by `--check`.
- **A scaffold (`scripts/new_module.py`) rather than more prose.** The undocumented part of a lesson was its structure (which shared markers a page needs, the cell markup the static-output test expects, a checkpoint of the required shape). A generated skeleton states that once, in code a test exercises, and cannot drift from the checks unnoticed. Its placeholders fail validation, so a skeleton cannot be merged as a lesson.
- **The standalone promise is tested by doing it.** The one remaining test that assumed every module is in the flagship course was found only by adding a lesson; `tests/test_new_module.py` keeps a skeleton passing the per-lesson checks.
- **Citation gate.** The gate tool is not in this repository, so the test can only find a PASS row a contributor wrote. CONTRIBUTING now says so and makes the reviewer's re-run of the gate the control. Bringing the tool into the repository is left to the owner.
6 changes: 6 additions & 0 deletions PROGRESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@ Implemented the pre-AGU contribution fixes of `docs/vision-2040/findings/skills-
Verification: the commands of CONTRIBUTING.md "Checks" plus `gen_contributors.py --check`; real counts in the hand-off report.
Not done: the Skills-repo and extension-side authoring-skill fixes of the same scout report; a branch-protection setting for `main`; a DOI for CITATION.cff.

## 2026-11-30 — Author link, and the contributor path tested as an outside contributor

Owner request: fix the author link; test and improve the contribution path. Course `intro-to-hydrology` 0.4.3 points to `galib9690` (regression test in `tests/test_repo.py`).
A standalone "Rational Method peak discharge" lesson was written twice in a scratch clone by following CONTRIBUTING.md literally (once by hand, once from the new scaffold) and removed; findings and fixes are in CHANGELOG.md ("Contributor path tested end to end") and DECISIONS.md.
Verification: the commands of CONTRIBUTING.md "Checks" on this branch, and on the scratch clone with the test lesson committed; real counts in the hand-off report.
Not done: the page was not opened in a browser or in Studio (the node smoke and standalone tests ran on it); the citation-gate tool is still not in this repository (documented, owner decision); `build_api.py` keeps its now-unused git fallback for `createdAt`.
2 changes: 1 addition & 1 deletion api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ An array, one entry per `modules/<id>/manifest.json`, sorted by module id. Every
|---|---|
| `moduleId`, `title`, `description`, `version`, `license`, `author`, `topic`, `level`, `estimatedMinutes`, `tags`, `requires`, `citation`, `isFeatured`, `courseId`, `courseOrder` | `manifest.json` |
| `downloadUrl`, `githubUrl` | manifest value, else derived from `moduleId` |
| `createdAt` | manifest value, else the date of the first git commit touching `modules/<id>/` |
| `createdAt` | the manifest's `createdAt` (required, `YYYY-MM-DD`) |
| `updatedAt` | **author date of the last git commit that touched `modules/<id>/`** (not the build date; without history it keeps the previous value) |
| `downloadCount`, `githubReactions`, `discussionUrl` | kept from the previous file; **not refreshed**: Discussions are disabled on this repository, so `githubReactions` stays 0 and `discussionUrl` empty (the extension still reads `githubReactions`, so the field stays) |
| `certification` | see below |
Expand Down
Loading
Loading