Repository navigation
feat: trust per point, facts, MCP, CLI, page for a municipality (0.4.0) - #8
Conversation
…y (0.4.0) The library reaches the standard of the other open-data libraries. - trust_at: the value with its 68 % range (STDPGA is in ln g), the nearest station that recorded, the version and status of the map. - shaking_facts, history_facts, revision_facts, Facts, describe: the answers as data with units in the keys; check_text finds numbers invented, in the wrong unit or wrongly rounded. - ShakeMapStore, fetch, version_key, is_newer: every version of a map kept, since INGV serves only the current one. - find_place: the 7,896 Italian municipalities (GeoNames, CC BY 4.0). - The ingv-shakemap command line and the ingv-shakemap-mcp server. - app/: a page for a public body. Dockerfile, compose.yaml (UI 3010, notebooks 8890, MCP 8774), a Makefile with help. - benchmarks/: five known earthquakes against 119 stations, and a faithfulness set, in CI. Four notebooks, llms.txt, the agent skill, publiccode.yml. revision_facts is tested on pairs of grids built by code: no real pair of versions was at hand. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 708fff5bfa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| partial = path.with_name(path.name + ".part") | ||
| partial.write_bytes(content) | ||
| partial.replace(path) |
There was a problem hiding this comment.
Use unique temporary files for concurrent store writes
When two requests fetch the same uncached event concurrently, both can pass the version-exists check and write to the same .part path. Once one writer renames that path, the other writer's replace() raises FileNotFoundError; this is reproducible with two simultaneous write() calls. The HTTP UI and MCP server allow concurrent requests, and compose.yaml also shares the store between services. Use a unique temporary file per writer and coordinate publication of a complete version.
Useful? React with 👍 / 👎.
| for name in PRODUCTS: | ||
| if name in contents: | ||
| await asyncio.to_thread(store.write, event_id, version, name, contents[name]) | ||
| return version |
There was a problem hiding this comment.
Verify product versions before publishing a downloaded bundle
If INGV updates an event's /current/ products after the initial info.json request, the remaining downloads can belong to a newer version but are permanently stored under the earlier version number. For example, version-4 metadata followed by a version-5 grid produces v004/grid.xml whose declared version is 5. This also allows uncertainty and station data from different revisions to be combined, undermining both trust ranges and revision comparisons. Validate the downloaded products against the selected version and retry if the current version changes during the download.
Useful? React with 👍 / 👎.
| try { s = await load(id); } catch (error) { state(`INGV non risponde: ${error.message}`); return; } | ||
| state(""); | ||
| $("felt").hidden = false; | ||
| mark(id); |
There was a problem hiding this comment.
Discard stale shaking responses after the selection changes
If a user selects another earthquake while the first map is downloading, both show() calls remain active. When the earlier request finishes last, it reaches mark(id) and replaces the displayed facts, reverting the user's newer selection. A municipality change also leaves earlier requests running against shared page state. Track a selection generation or cancel superseded requests, and check that the response still belongs to the active municipality and earthquake before updating the DOM.
Useful? React with 👍 / 👎.
| const near = s.nearest_station; | ||
| fill("nearest", near ? `${near.name || near.id}, a ${near.distance_km} km: ha registrato ${g(near.recorded_pga_g)}` | ||
| : "nessuna: la mappa è il solo modello"); |
There was a problem hiding this comment.
Preserve the unknown state when station data is unavailable
When stationlist.json is unavailable, fetch() deliberately accepts the other products, and shaking_facts() returns both nearest_station: null and stations_recording: null, with a note that station proximity is unknown. This fallback instead tells users that no station recorded and the map is the model alone, which is not established by missing data. Distinguish stations_recording === 0 from null, as describe() already does, and display an unknown-data message for the latter.
Useful? React with 👍 / 👎.
| if re.fullmatch(r"[-+]?\d{1,3}(?:,\d{3})+(?:\.\d+)?", t): | ||
| t = t.replace(",", "") |
There was a problem hiding this comment.
Recognize leading-zero decimal commas before thousands separators
For Italian text using three decimal places, this pattern treats 0,486 as a thousands-grouped integer and converts it to 486. Consequently, check_text("0,486 g", {"pga_g": 0.4858}) reports an invented number, although the equivalent 0.486 g correctly passes. Since the checker explicitly supports decimal commas and Italian units, exclude leading-zero decimal forms from the thousands-separator branch so ordinary Italian PGA quotations are checked at their actual value and precision.
Useful? React with 👍 / 👎.
Summary
ingv-shakemap reaches the standard of the other open-data libraries. Version 0.4.0.
trust_atgives the PGA with its 68 % range (fromuncertainty.xml, whereSTDPGAis in ln g), the nearest station that recorded and the version and status of the map. No label, no default radius.shaking_facts,history_facts,revision_facts, the fetchingFacts,describe(a sentence written by code) andcheck_text.ShakeMapStore,fetch,version_key,is_newer. INGV serves only the current version of a map.find_place, 7,896 with ISTAT codes (GeoNames, CC BY 4.0).ingv-shakemap,ingv-shakemap-mcp(extramcp).app/,Dockerfile,compose.yaml(UI 3010, notebooks 8890, MCP 8774), a Makefile withhelp.llms.txt, the agent skill,publiccode.yml.Limits, stated in the docs: the benchmark compares the map with the stations it was built on, so it checks the reading, not the map between stations;
revision_factsis tested on pairs built by code, since no real pair of versions exists; no model answered the faithfulness set; a municipality is one point.Epic
Part of agent-engineering-studio/limen#712 (landslide)
Verification
make check: ruff, mypy strict, 198 tests at 100 % coverage,benchmarks.run --check,benchmarks.faithful --check.make docsbuilds with--strict, withllms.txtandllms-full.txt.🤖 Generated with Claude Code