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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ Continuous integration runs ruff and `pytest` (Ubuntu and Windows), a stale-`web
<details>
<summary><b>AI and third-party tools (disclosure)</b></summary>

- **Optional LLM triage.** NVIDIA-hosted `nvidia/nemotron-3.5-lightning-30b-a3b` (fallback `mistralai/mistral-large-4-1t-a52b`) labels *ambiguous* citation mentions on request. Its output must quote the snippet verbatim or it is discarded, people can override it, and an LLM-only link counts as uncertain evidence.
- **Optional LLM triage.** NVIDIA-hosted `nvidia/nemotron-3.5-lightning-30b-a3b` (fallback `mistralai/mistral-large-4-1t-a52b`) labels *ambiguous* citation mentions on request. Its output must quote the snippet verbatim or it is discarded. An LLM label is advisory: it is shown with its provenance but never changes the lineage or a verdict until a person confirms the citation.
- **Optional investigation agent.** NVIDIA-hosted `nvidia/nemotron-3-ultra-550b-a55b` (same fallback). It chooses tool calls and writes findings, but produces no verdicts or counts and cannot change lineage.
- Both need `NVIDIA_API_KEY` and `NVIDIA_BASE_URL` in `.env` (see [`.env.example`](.env.example)). Everything else works without them.
- **Libraries.** Relate (`relate-db`), FastAPI, Uvicorn, pypdf, httpx, React 18, Vite. Optional OCR refresh: RapidOCR and pypdfium2 ([`requirements-ocr.txt`](requirements-ocr.txt)).
Expand Down
41 changes: 36 additions & 5 deletions docs/EVIDENCE_QUALITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,39 @@ AI agent but labelled "curated human review", are kept with their notes under `a
applied: K092835 → K991646 stays out of the lineage through the audit (`error`), and the three K093416 links are
audit-`unresolved`, so they count, flagged as doubtful, until a person decides them.

Lineage rule (`graph.LINEAGE_EDGE`): a person confirmed it, OR (the extractor said predicate, or the LLM labelled a
mention predicate) and the audit did not mark it `error`/`not_predicate`, unless a person rejected it.
Lineage rule (`graph.LINEAGE_EDGE`, trusted lineage): the edge is still cited by the citing device's current summary
(not retired by a re-ingest), and a person confirmed it, OR the extractor said predicate and the audit did not mark it
`error`/`not_predicate`, unless a person rejected it. Automated sources never change trusted lineage on their own: an
LLM triage label, or a confirmation or rejection sent through the MCP client (reviewer `mcp-client`), is **advisory**
(`graph.ADVISORY_EDGE`) until a person decides. Advisory links are listed with their provenance (model, quote, time,
page, source hash) and the suggested device's recalls in the `ADVISORY_LINK_PENDING_REVIEW` signal; they are never
traversed, so they cannot raise or lower a verdict, recall reach or the watchlist. Inside the verdict window they make
the evidence `partial` (reason `advisory_links_pending_review`), so a clean result is shown as provisional rather than
fully supported. An MCP-client review never overwrites a person's review.

Re-ingest reconciliation (`ingest.write`, `graph.retire_citations`): re-ingesting a clearance compares its stored
citations with the refreshed summary inside the same write transaction. Edges the refreshed summary no longer supports
are **retired** (`retired_at`, `retired_reason`, `retired_by_sha256`), not deleted: reviews, LLM labels, audit fields
and the original quote, page and source hash stay on the edge, it leaves trusted and advisory lineage, and it is
restored if a later summary cites the device again. Reconciliation runs only when the refreshed summary text was read,
so an unreadable download never wipes lineage, and any write error rolls the whole ingest back. Retired edges appear in
the `CITATION_RETIRED_BY_REINGEST` signal; one that a person had confirmed makes the evidence `partial` (reason
`human_confirmed_citation_retired`).

Summary refresh (`summaries.refresh`, `POST /api/ingest {"refresh": true}`, MCP `ingest_clearance refresh=true`, the
"Re-download" option on *Add a clearance*): a plain re-ingest reuses the cached summary text, so only an explicit
refresh can see a changed FDA PDF. The refresh re-downloads the PDF and writes the new record to the gitignored
`data/live` cache, which then supersedes the committed `data/raw` record for the app; `data/raw` is never written by the
app (openFDA responses follow the same rule). The cached record is replaced only by readable evidence: a download
error, an HTTP 429/5xx, a missing PDF or an image-only PDF raises an error that changes neither the cache nor the graph.
An unchanged PDF (same SHA-256) is reported as unchanged.

Reviews are bound to the evidence version: a review records the summary SHA-256 it was made against
(`reviewed_source_sha256`) and counts only while the edge carries that SHA-256 (`graph.CURRENT_HUMAN_REVIEW`). When a
refresh changes the PDF, or a retired citation is restored from a different PDF, the review stays on the edge as history
but stops counting: the edge falls back to the extraction rules and is flagged `review_outdated`; an outdated
confirmation of a non-predicate becomes an advisory link (`outdated_human_confirmation`). A person's new review on the
current evidence makes it trusted again. A legacy review without a recorded hash counts only on an edge that has none.

### 5. Uncertainty in assessments (`forebear/lineage.py`, rules `forebear-rules-v3`)
A lineage hop is **doubtful** when it is audit-unresolved, its K-number was supplied by an audit correction rather than
Expand Down Expand Up @@ -266,9 +297,9 @@ Two issues found in review, investigated, fixed and re-reviewed by an independen
The three disputed K093416 links are audit-`unresolved`: they count in the lineage, flagged as doubtful, so the
Trilogy 200's recalls show instead of being dropped by a supposed human rejection. The re-review found one more path
to the same problem: the MCP `review_citation` tool wrote the same field as the app. Its writes are now recorded with
reviewer `mcp-client`; they still apply (a rejection removes the edge and is disclosed as an unresolved predicate
citation), but a client confirmation never clears an uncertain-evidence flag, and a mention promoted only by a client
confirmation counts as doubtful. Only a review made in the app (reviewer `user`) or a named human review does.
reviewer `mcp-client`; a client confirmation never clears an uncertain-evidence flag. (Superseded by rules
`forebear-rules-v5`: MCP-client reviews and LLM labels are now advisory and never change trusted lineage; see the
lineage rule above.) Only a review made in the app (reviewer `user`) or a named human review does.
2. **Completeness beyond the direct predicates.** Investigation on all 1,040 in-family devices: 7 clean results
requested at `depth=1` were reported `complete` although the full ancestry is REVIEW_LINEAGE (e.g. K251770), and among
the 101 `complete` clean results, 4 had removed or unresolved predicate citations and 23 had doubtful links at
Expand Down
2 changes: 1 addition & 1 deletion docs/UX_EXPERIENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ the favicon.

### The investigation page, top to bottom

- **Finding.** The device, the verdict, and an authority note: *Deterministic assessment · forebear-rules-v4.
- **Finding.** The device, the verdict, and an authority note: *Deterministic assessment · forebear-rules-v5.
Authoritative within its documented scope … A documentation signal, not a safety determination.* Below it, one
plain-language finding sentence, built only from the assessment payload. It names the page, the recall class, the root
cause, the start date, and how long before the clearance the recall began. Coverage chips show evidence completeness,
Expand Down
11 changes: 8 additions & 3 deletions forebear/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ def do(g: Graph):
# ---------------------------------------------------------------- writes
class IngestIn(BaseModel):
k: str
# Re-download the summary PDF instead of reusing the cached text, to detect a changed FDA document. A failed or
# unreadable download changes nothing (422).
refresh: bool = False


@app.post("/api/ingest")
Expand All @@ -241,7 +244,7 @@ async def ingest(body: IngestIn):
try:
# network phases run off the Relate thread, so the UI stays responsive during a PDF download
existing = await run(lambda g: g.device(k))
fetched = await loop.run_in_executor(None, ingest_mod.fetch_clearance, k)
fetched = await loop.run_in_executor(None, ingest_mod.fetch_clearance, k, True, body.refresh)
present = await run(lambda g: ingest_mod.present_devices(g, fetched.cited))
related = await loop.run_in_executor(None, ingest_mod.fetch_related, fetched, present)
return await run(lambda g: ingest_mod.write(g, fetched, related, existing))
Expand All @@ -254,7 +257,8 @@ class ReviewIn(BaseModel):
dst: str
status: str = Field(pattern="^(confirmed|rejected|)$")
note: str | None = None
# Who recorded it: "user" (the app) or "mcp-client" (the MCP tool, possibly an AI agent). Optional.
# Who recorded it: "user" (the app, a person) or "mcp-client" (the MCP tool, possibly an AI agent). An mcp-client
# review is advisory: it never changes trusted lineage and never overwrites a person's review. Optional.
via: str = Field("user", pattern="^(user|mcp-client)$")


Expand Down Expand Up @@ -503,7 +507,8 @@ async def decide_proposal(pid: str, body: DecisionIn):
except Exception as e: # IngestError or anything else: never leave the proposal 'deciding'
error = f"{type(e).__name__}: {str(e)[:300]}"
return await run(lambda g: inv_store.decide_proposal(g, pid, "failed", who, body.note, {"error": error}))
res = {k2: r[k2] for k2 in ("k", "summary_status", "summary_url", "new_devices", "recalls_linked")} | {
res = {k2: r[k2] for k2 in ("k", "summary_status", "summary_url", "new_devices", "recalls_linked",
"reconciliation")} | {
"citations_added": [{k2: c[k2] for k2 in ("dst", "kind", "page")} for c in r["citations_added"]]}
return await run(lambda g: inv_store.decide_proposal(g, pid, "executed", who, body.note, res))

Expand Down
Loading
Loading