Skip to content

feat: trust per point, facts, MCP, CLI, page for a municipality (0.4.0) - #8

Merged
gzileni merged 2 commits into
mainfrom
feat/standard-0.4
Nov 28, 2026
Merged

gzileni merged 2 commits into
mainfrom
feat/standard-0.4

Conversation

@gzileni

@gzileni gzileni commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Summary

ingv-shakemap reaches the standard of the other open-data libraries. Version 0.4.0.

  • How far to trust a value: trust_at gives the PGA with its 68 % range (from uncertainty.xml, where STDPGA is in ln g), the nearest station that recorded and the version and status of the map. No label, no default radius.
  • Facts and the check: shaking_facts, history_facts, revision_facts, the fetching Facts, describe (a sentence written by code) and check_text.
  • Versions kept: ShakeMapStore, fetch, version_key, is_newer. INGV serves only the current version of a map.
  • Municipalities: find_place, 7,896 with ISTAT codes (GeoNames, CC BY 4.0).
  • Command line and MCP server: ingv-shakemap, ingv-shakemap-mcp (extra mcp).
  • A page for a public body in app/, Dockerfile, compose.yaml (UI 3010, notebooks 8890, MCP 8774), a Makefile with help.
  • Benchmark in CI: five known earthquakes as windows of INGV's maps, four notebooks, 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_facts is 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 docs builds with --strict, with llms.txt and llms-full.txt.
  • The three Docker images build; the page, Jupyter and the MCP server answered on 3010, 8890 and 8774.
  • The four notebooks ran; the page was tried against live INGV data.

🤖 Generated with Claude Code

…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>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-28T15:27:20.276010Z 708fff5 PR opened
ℹ️ 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" or "@codex security review".

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>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +116 to +118
partial = path.with_name(path.name + ".part")
partial.write_bytes(content)
partial.replace(path)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +169 to +172
for name in PRODUCTS:
if name in contents:
await asyncio.to_thread(store.write, event_id, version, name, contents[name])
return version

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread app/static/app.js
Comment on lines +95 to +98
try { s = await load(id); } catch (error) { state(`INGV non risponde: ${error.message}`); return; }
state("");
$("felt").hidden = false;
mark(id);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread app/static/app.js
Comment on lines +115 to +117
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");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +120 to +121
if re.fullmatch(r"[-+]?\d{1,3}(?:,\d{3})+(?:\.\d+)?", t):
t = t.replace(",", "")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@gzileni
gzileni merged commit 13aceac into main Nov 28, 2026
8 checks passed
@gzileni
gzileni deleted the feat/standard-0.4 branch November 28, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant