Skip to content

Phase 5: answers as data, check_text, faithfulness benchmark, MCP facts tools - #39

Merged
gzileni merged 1 commit into
mainfrom
feat/fase-5-facts
Nov 26, 2026
Merged

gzileni merged 1 commit into
mainfrom
feat/fase-5-facts

Conversation

@gzileni

@gzileni gzileni commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Phase 5 of #26: the AI layer. Closes #19.

What

  • firms_client.facts: area, place, event, seen return answers as JSON-ready dicts. Every number sits next to its window, product, sources, licence (the NASA FIRMS acknowledgement, plus the ESA WorldCover CC BY 4.0 credit when the land was read) and notes (not measured, not an alert, presence-only). Nothing read (rows=None, a place with no mask and no land) is measured: false with null numbers, never 0. Pure, no network.
  • check_text (firms_client.check): the numbers of a text, English or Italian, that no figure of the facts gives, to the decimals written; percentages as shares, dates as parts, numbers of the question allowed.
  • MCP: fires_in_area, event_facts (bulletin facts for the largest event, with your places), trust_at, detection_odds, check_answer, and area_digest(..., land_cover=True) (MCP: expose land cover and bulletin facts as tools #19). The guide tells the agent to say "not measured" for nulls and to pass its text to check_answer.
  • benchmarks/faithful.json: nine questions (five English, four Italian) on the benchmark crops: trust at the Taranto steelworks and on cropland at Aragona, the empty Tyrrhenian, Palermo 2023, Montiferru 2021, San Luca and Irsina events with WorldCover, detection odds, and a year not published. Each has a faithful and a faulty hand answer, with every number labelled. score --check runs in CI (make faithful) and fails if a hand answer does not score as expected or the facts change.
  • llms.txt section, llms-full.txt built by make docs, skills/firms-client/SKILL.md with ten traps, README section, CHANGELOG.

Measured

Author Answers Numbers faithful question unmeasured rounded swapped invented
hand 9 79 72 7 0 0 0 0
hand-faulty 9 36 12 3 3 2 8 8

Every fault in the faulty answers is caught by the scorer. check_text alone, with no labels, catches 13 of the 21; the 8 it misses are numbers that exist in the facts but are said of the wrong one (318 fires when 318 are the detections). That is why the guide tells the agent to reread them.

Not in this PR

Checks

make check (200 passed, coverage 99%), make test-core, make bench (34 of 41, no change), make faithful, make docs.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VFEUmXwmaxtB7PF8sSP1d4

…tools (phase 5)

- firms_client.facts: area, place, event, seen as JSON-ready dicts with
  window, product, sources, licence (NASA FIRMS; ESA WorldCover CC BY 4.0
  when the land was read) and notes. Nothing read is measured: false with
  null counts, never 0.
- firms_client.check: check_text (English and Italian numbers, percentages
  as shares, dates as parts), numbers, figures, at.
- MCP: fires_in_area, event_facts, trust_at, detection_odds, check_answer,
  area_digest(land_cover=True) (#19).
- benchmarks/faithful.json: nine questions on the benchmark crops, a
  faithful and a faulty hand answer each; score --check in CI and make
  faithful. check_text alone catches 13 of the 21 faults.
- llms-full.txt on the site, skills/firms-client/SKILL.md with the traps.

Part of #26. Closes #19.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VFEUmXwmaxtB7PF8sSP1d4
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 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-25T20:07:39.568720Z cb06a18 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.

@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: cb06a18037

ℹ️ 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 +423 to +424
with _land(land_cover) as land:
return facts.event(events[0], places=gazetteer, land=land, source=product)

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 Move blocking WorldCover reads off the MCP event loop

When land_cover=True (the default here) and tiles are read from the public bucket, facts.event() synchronously opens raster datasets and reads a window for each detection through classify_burning(). Calling it directly from this async handler blocks the MCP event loop throughout those network reads, preventing other requests and cancellations from being processed during a large event. WorldCover explicitly documents that its reads are blocking, and the existing CLI offloads equivalent work with asyncio.to_thread. Offload the land-cover context and computation together; the new land-cover paths in fires_in_area, trust_at, and area_digest need the same treatment.

Useful? React with 👍 / 👎.

Comment thread src/firms_client/check.py
Comment on lines +26 to +27
_EN = re.compile(r"(?<![\w.,])(\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?)(?:st|nd|rd|th)?(?!\w)")
_IT = re.compile(r"(?<![\w.,])(\d{1,3}(?:\.\d{3})+(?:,\d+)?|\d+(?:,\d+)?)(?:°|ª|º)?(?!\w)")

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 fractional numbers without a leading zero

When an answer writes a score or share as .95, the English pattern silently skips the entire number: it requires a digit before the decimal point and prevents a match immediately after a period. Consequently, check_text('Reliability is .95', {}) returns [], and the MCP check_answer tool reports the unsupported number as faithful. The Italian pattern similarly skips ,95. Recognize these fractional forms as complete numeric tokens so they are checked against the facts rather than omitted.

Useful? React with 👍 / 👎.

@gzileni
gzileni merged commit 10f6640 into main Nov 26, 2026
6 checks passed
@gzileni
gzileni deleted the feat/fase-5-facts branch November 26, 2026 07:52
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.

MCP: expose land cover and bulletin facts as tools

1 participant