Skip to content
apliko-xyzPublic
forked from Mr41022/veda

About

Provenance-aware vendor financial evidence agent — resolves a company, retrieves public SEC/USAspending evidence, and returns claims that always trace back to their source or an explicit statement that the evidence is insufficient.

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Provenance-Aware Vendor Financial Evidence Agent (Prototype)

A small, narrow demonstration of an evidence-first architecture for vendor financial assessment — built for the ArcellAI Open Source Engineering Fellowship project interview.

Problem

Given a vendor name and a fiscal period, can a system retrieve public evidence, extract structured claims, preserve provenance, reconcile conflicting information, and return either a defensible evidence packet or an explicit statement that the evidence is insufficient?

Design Philosophy

The system is evidence-first, not answer-first. A Claim may carry a normalized value, but that value is never treated as authoritative unless it references the Evidence object(s) it was derived from — the validator enforces this at every claim, moving anything without a live evidence_id to INSUFFICIENT_EVIDENCE regardless of how well-formed the claim looks. If two comparable sources disagree, both values are preserved — never averaged, never silently picked. If the evidence can't support a conclusion, the system says so explicitly instead of guessing.

Company + Fiscal Period
        │
        ▼
Entity Resolution          (deterministic — app/entity_resolver.py)
        │
        ▼
Evidence Retrieval          (app/providers/* — SEC Company Facts / Filings / USAspending)
        │
        ▼
Evidence Normalization      (deterministic — app/normalization.py + app/evidence_ids.py)
        │
        ▼
Typed Claim Extraction      (deterministic first; LLM only on unstructured text — app/claim_extraction.py)
        │
        ▼
Validation                  (deterministic — app/validator.py; enforces "no evidence, no claim")
        │
   ┌────┴────┐
   ▼         ▼
Conflict   Missing
Detection  Evidence
   └────┬────┘
        ▼
Assessment Engine (deterministic rules — app/assessment.py)
        │
   ┌────┴────┐
   ▼         ▼
Evidence    Abstention /
Packet      Human Review

Core Data Model (app/models.py)

  • ResolvedEntity — the resolved legal/reporting entity, or an explicit AMBIGUOUS / NOT_FOUND status. Identity is never guessed.
  • Evidence — a raw fact with full provenance: source, field/passage, reporting period, retrieval method, and an explicit is_fixture flag so demo data can never be confused with a live retrieval.
  • Claim — a typed statement that references evidence IDs; never contains detached values.
  • Conflict — only created when claims are genuinely comparable (same entity, claim type, period, unit, category) and materially disagree.
  • Assessment — the final packet, with one of SUPPORTED, SUPPORTED_WITH_LIMITATIONS, CONFLICTING_EVIDENCE, INSUFFICIENT_EVIDENCE, or REQUIRES_HUMAN_REVIEW.

Deterministic vs. LLM Components

Deterministic: entity resolution (app/entity_resolver.py), retrieval (app/providers/*.py), unit/field normalization (app/normalization.py), evidence-ID generation and deduplication (app/evidence_ids.py), claim validation, conflict detection, and the final assessment rules.

LLM-assisted (mocked in this offline demo, see app/claim_extraction.py for exactly where a real Claude API call would slot in): extracting a claim from an unstructured filing passage. Any LLM-produced claim must carry an evidence_id back to the source passage, or the validator marks it INSUFFICIENT_EVIDENCE regardless of how well-formed the output looks.

Running the Project

python -m venv .venv && source .venv/bin/activate   # optional
pip install -r requirements.txt

# Run all four demo scenarios end-to-end, no network required:
python demo.py

# Run the test suite:
pytest tests/ -v

# Run the API + visual dashboard:
uvicorn app.api:app --reload
# then open http://127.0.0.1:8000/ in a browser, or call the API directly:
curl -X POST http://127.0.0.1:8000/assess \
    -H "Content-Type: application/json" \
    -d '{"company_name": "Palantir Technologies", "fiscal_year": 2025}'
curl -X POST http://127.0.0.1:8000/assess/supported
curl -X POST http://127.0.0.1:8000/assess/conflict
curl -X POST http://127.0.0.1:8000/assess/insufficient
curl -X POST http://127.0.0.1:8000/assess/subsidiary

A .vscode/launch.json is included — open this folder in VS Code and use the Run/Debug panel to launch the demo, the API, or the test suite directly.

Visual dashboard

GET / serves a single-page dashboard (app/static/dashboard.html) for inspecting an evidence packet without reading raw JSON: it shows the resolved entity, a color-coded assessment status, each claim with clickable chips linking to the exact evidence item that supports it, the full evidence ledger (source, field/passage, URL, fixture flag), conflicts, missing evidence, and limitations — plus a raw-JSON toggle for the machine-readable packet underneath. It calls POST /assess and the four pinned /assess/<case> routes directly; no build step or extra dependency is required beyond FastAPI serving the static file.

POST /assess — the general-purpose endpoint

{"company_name": "Palantir Technologies", "fiscal_year": 2025}

runs the full pipeline for whatever company/year is given, rather than reproducing one pinned scenario. It only "knows about" the companies in app/entity_resolver.py's registry and the fixtures in app/fixtures.py, but the interface is the real one: swapping the fixture-backed classes in app/providers/ for live SEC/USAspending httpx clients would not require changing this endpoint, app/orchestrator.py's run_assessment(), or anything downstream of it.

Demo Cases

Case Scenario Result
examples/supported_case.json Single authoritative SEC revenue figure SUPPORTED
examples/conflict_case.json Two authoritative sources disagree on FY2025 revenue CONFLICTING_EVIDENCE
examples/insufficient_evidence_case.json USAspending procurement obligation exists, but no link to recognized revenue INSUFFICIENT_EVIDENCE
examples/subsidiary_case.json Named vendor is a subsidiary; SEC disclosures are made at the parent level; also covers the customer-concentration claim type SUPPORTED_WITH_LIMITATIONS

Trade-offs / What This Prototype Does Not Solve

  • Entity resolution is a small in-memory registry, not a live SEC lookup (the sandbox this was built in has no network access to sec.gov / usaspending.gov). app/providers/*.py implements the real provider interface — get_revenue_fact(cik), get_passage(cik, key), get_obligation(cik) — but each class currently reads from app/fixtures.py instead of issuing an httpx call. Swapping in httpx.get("https://data.sec.gov/...") inside each provider class is the only change a production build needs; app/normalization.py, app/orchestrator.py, and everything downstream stays the same.
  • LLM extraction is mocked with keyword matching rather than a real model call, for the same offline-reproducibility reason — the extraction contract (must return evidence-linked claims) is real.
  • Only two companies and a handful of claim types are supported. That's deliberate: a narrow, inspectable system beats a broad, unreliable one.

Future Work

Real SEC/USAspending httpx implementations behind the existing provider classes, broader entity resolution (aliases, subsidiaries), passage-level citation offsets, a richer evidence lineage graph, a labeled evaluation dataset, and a human-review workflow for REQUIRES_HUMAN_REVIEW cases.

About

Provenance-aware vendor financial evidence agent — resolves a company, retrieves public SEC/USAspending evidence, and returns claims that always trace back to their source or an explicit statement that the evidence is insufficient.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages