Skip to content

About

Evidence-first invoice reconciliation that challenges its own findings.

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Countercheck

An overcharge is a hypothesis. Try to disprove it first.

Countercheck is an evidence-first invoice review workbench for small operators. It separates exact arithmetic from model interpretation, checks the excuses an apparent overcharge might have, and asks for missing evidence before creating a supplier-review draft.

Status: working local prototype, published on GitHub at https://github.com/Bembaby/countercheck. The deterministic workbench and API are tested. A real Nebius Token Factory adapter is implemented, but no live model call, public deployment, or final competition submission has been completed in this build environment. Do not present mocked tests as live inference.

Countercheck workbench

Publish this project with Codex

Start with START_HERE.md, then ask Codex to execute CODEX_PROMPT.md. The handoff targets a new public Bembaby/countercheck repository on main, with account checks, tests, and remote-commit verification. This package does not itself create a repository or perform a push.

Run in 30 seconds

Requires Node.js 22 or newer. No runtime packages or API key are needed for the deterministic demo.

npm start
# Open http://127.0.0.1:4173
npm test
npm run benchmark
npm run build

For an offline demonstration, open artifacts/countercheck-demo.html in a modern desktop browser. Downloaded HTML may need to be opened in a browser rather than a file preview. Receipt hashing requires WebCrypto in a secure context; localhost works, while an embedded insecure preview may not. The server and tests also support receipt generation and verification.

The 90-second demo

The six fictional invoice lines total $996, with a $62 allocated credit. An intentionally naive raw-count baseline suggests $195 in differences. Countercheck retains $52 for review and withholds up to $288 pending evidence.

  1. Open House-blend coffee: the missing case already has a credit. Do not claim it twice.
  2. Open Grade A eggs: 10 dozen is 120 eggs, not a 110-egg shortage.
  3. Inspect Bread flour: delivery is unfinished, so a shortage claim is premature.
  4. Click Confirm 4 tubs / case: new fictional pack evidence clears the cheese uncertainty.
  5. Click Mark delivery final: a final flour receipt changes the supported total to $100.
  6. Review source quotes, check the human-review box, and download a draft or replay receipt. Nothing is sent.

These amounts are controlled synthetic examples—not recovered money, model accuracy, or a comparison against a commercial product.

Real NVIDIA / Nebius review

The model is a skeptical source-consistency reviewer. It returns a cited verdict for each line. It cannot create amounts, approve a claim, execute a tool, or send a supplier message. A needs_review verdict on a supported line blocks the interface's draft export until the case is revised.

cp .env.example .env
# Add your key locally; never commit or paste it into public content.
# Choose an available NVIDIA model with structured-output support from your Nebius console.
npm run models
# Set NEBIUS_MODEL to that exact current model ID.
npm start

Click Run skeptical review. The app asks before sending the case to Nebius; provider usage may incur charges. Only use synthetic or explicitly authorized, redacted documents. All errors are surfaced, never replaced with simulated AI output. This adapter is based on the official quickstart and structured-output documentation, checked September 9, 2026. Model availability and individual structured-output support must be verified in the live account.

What is built

  • Exact BigInt rational quantities; decimal-string prices; per-line half-up cent rounding.
  • Unit normalization, allocated-credit deduction, final-delivery gating, and explicit abstention.
  • Literal source-quote validation, evidence replay, and prioritized unanswered questions.
  • Editable/importable evidence-linked JSON, responsive workbench, local draft export.
  • SHA-256 replay receipts with deterministic re-execution. A checksum is not a signature or proof that a source is authentic.
  • Optional server-side Nebius/NVIDIA structured review with provenance validation and a veto-only user-interface gate.
  • 55 automated tests, including 500 seeded arithmetic invariant cases; standalone-browser interaction checks.

Deliberate boundaries

This prototype takes structured JSON, not PDFs or automatic OCR. facts_confirmed is an operator-supplied flag, not authentication. Matching a quote only proves the string is present, not that a quantity or interpretation is right. The model can still miss contradictions. Tax, freight, rebates, global invoice discounts, cross-invoice credit allocation, duplicate whole invoices, mixed currencies, accounting integrations, persistent user accounts, and production authentication are out of scope. Credits must already be allocated to individual lines; the importer does not perform or verify that allocation.

There is no evidence yet from real customers and no independent model-quality benchmark. Never describe a supported difference as a legal entitlement or money actually recovered.

Source map

src/engine.mjs        Exact reconciliation, validation, drafts, replay receipts
src/fixture.mjs       Entirely fictional source documents and demo scenarios
src/provider.mjs      Optional real Nebius adapter and strict result validation
public/               Responsive browser workbench
server.mjs            Local HTTP API; static allowlist; basic resource guards
scripts/              Offline build, evaluation, browser QA, publication helper
artifacts/            Standalone demo, test evidence, sample results, screenshots
docs/                 Architecture, draft submission, video script, live-test plan

Before public hosting

Read SECURITY.md. Keep inference disabled on a public demo unless you add authentication and enforced cost controls. Bind to loopback by default. Do not host real invoices. This project is not production hardened.

Competition direction

Target: Nebius x NVIDIA Global AI Hackathon, Best apps and agents. The formal rules require real Nebius runtime use with an NVIDIA open-source model, a public licensed repository, working demo, genuine feedback, and a public YouTube demonstration under three minutes. The current artifact does not yet meet all those requirements. See docs/submission-draft.md and docs/live-validation.md.

Built September 9, 2026 with AI assistance. See AI_ASSISTANCE.md. MIT licensed.

About

Evidence-first invoice reconciliation that challenges its own findings.

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages