Skip to content

About

Deterministic-first AI document automation workbench: Bun/TypeScript, Python parser, PostgreSQL, easy-template-x, pdf-lib, code-verified provenance

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Grounded Report Engine

Deterministic-first document automation and verification workbench built with TypeScript (Bun), Python (pypdf, pdfplumber, openpyxl, python-docx), PostgreSQL, easy-template-x, and pdf-lib.

Every filled number and report claim carries format-native source provenance verified by code:

  • PDF -> exact filename, 1-based page number, and verbatim quote
  • XLSX -> exact Sheet!Cell coordinate via openpyxl (handling Docling's charspan=(0, 0) and 0-based grid coordinates)
  • DOCX -> exact section heading and paragraph index (handling OOXML / Docling's lack of native Word page numbers)

Anything code cannot prove stays [MISSING: field]. An LLM runs only for the Engineering Discussion judgement section and a single AI review pass, with no tool access, on a compact verified evidence packet (~81.7% fewer input tokens than raw folder text), and every AI fix is re-checked by deterministic code before acceptance.

Architecture

  1. Python Parser Service (python-service/): Parses PDF, DOCX, XLSX, and CSV inputs deterministically, detects and converts metric (mm/s) to imperial (in/s) units while preserving raw source quotes, checks calibration expiry, and lints .docx templates for Word split-run {tag} XML fragments.
  2. Deterministic Core & Code Verifier (src/deterministic.ts, src/verifier.ts): Computes Table 1 values, limit comparisons, week-over-week deltas from the prior week's structured state, and builds the compact evidence packet. Rejects unknown evidence IDs, unverified decimals, dropped [MISSING: ...] markers, ungrounded cause speculation, prompt-injection compliance, and stale carry-forward text.
  3. LLM Writer + Single Review Pass (src/llm.ts): Compatible with Azure OpenAI (AZURE_OPENAI_ENDPOINT + AZURE_OPENAI_API_KEY) or OpenAI (OPENAI_API_KEY), strict Zod JSON Schema output, zero tools.
  4. Review Screen (src/server.ts, src/db.ts): Lightweight Bun + PostgreSQL web UI with report preview, source-on-hover popovers, missing-fields list, rerun, approval audit log, and DOCX / merged PDF downloads.
  5. Template Fill & Appendix Merge (src/docx_pdf.ts): Fills Word templates with easy-template-x (MIT), verifies zero stray {tags} in output XML, converts via Gotenberg v8 (MIT; avoids v9's AGPL-3.0 litho dependency) or LibreOffice, and merges Appendix A plus conditional Appendix B with pdf-lib (MIT).

Quick Start

# 1. Install TypeScript/Bun dependencies and run full CI (typecheck, lint, dead-code, license audit, tests)
bun install
bun run ci

# 2. Install Python parser dependencies and run pytest + ruff
cd python-service && uv sync && uv run pytest && uv run ruff check .

# 3. Start the Review Screen (after building sample corpus & eval snapshot)
bun run src/server.ts

License Hygiene

All runtime and dev dependencies in this repository are strictly permissive (MIT, Apache-2.0, BSD-2/3-Clause, ISC). Run bun run check:licenses to verify zero GPL/AGPL dependencies.

Public Demo Data Attribution

The weekly monitoring PDFs used in the benchmark are real public vibration reports published by the City of Cambridge, MA (221 Mt. Auburn Street / Riverview Demolition, Project 200609.05). Companion work orders, field memos, Excel limit sheets, and adversarial stress-test fixtures are clearly labeled synthetic test inputs.

About

Deterministic-first AI document automation workbench: Bun/TypeScript, Python parser, PostgreSQL, easy-template-x, pdf-lib, code-verified provenance

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages