Closes a UX gap the user surfaced: W3.5-3.8 built 8 detectives, 4 new
URL endpoints (/jobs/[id], /h/[id], /c/[slug], /api/h/[id]/red-team)
and a chat tool, but the homepage was unchanged — the bureau was
invisible unless you knew the URL or asked the chat to invoke
request_investigation.
Homepage (web/app/page.tsx):
- Title `▍ war.gov/ufo — Investigative Wiki` → `▍ The Disclosure Bureau`
- Subtitle expanded from "Holmes · Poirot · Dupin · Locard" to all 8
detectives (Holmes · Locard · Dupin · Schneier · Poirot · Taleb ·
Tetlock · Case-Writer)
- New `🔎 bureau` topbar link (gold, between graph/stats and batch)
- BureauSnapshot inserted right after the header
BureauSnapshot (web/components/bureau-snapshot.tsx) — server component:
- 8 detective tiles with role labels (each in its tone color)
- 6 clickable counters (evidence / hypotheses / contradictions /
witnesses / outliers / case reports) — anchor to /bureau#section
- 6 "recent artefacts" columns surfacing the last 3-4 of each kind:
hypotheses with prior→posterior + band + ↳reviewed_by marker,
contradictions with topic + resolution_status, evidence with
Grade badge + verbatim quote, outliers with title + scope.kind,
witness analyses with canonical_name + credibility + verdict,
case reports with slug + link to /c/<slug>
- "Recent jobs" strip linking to /jobs/[id] color-coded by status
- Reports read from /data/ufo/case/reports/ via fs.readdir + stat,
sorted by mtime — no DB round-trip needed for that section
/bureau (web/app/bureau/page.tsx) — full hub:
- Header with full counts
- 7 sections (anchored to homepage counter links): Case reports,
Hypotheses, Evidence, Contradictions, Outliers, Witnesses,
Recent jobs table — each rendering up to 100 rows
- Reports section parses frontmatter from each .md to surface topic
+ n_hypotheses + n_evidence on the card
Runtime fixes batched in:
- Poirot: coerce entity_pk via Number() — node-postgres returns
BIGINT as string by default; writer's Number.isFinite() rejected
it as "person_entity_pk required" (j-edgar-hoover retry path)
- Tetlock: write_calibration rationale cap 600 → 1200 chars. Prompt
still asks ≤ 600 but a 2× slack beats failing the job on honest
analysis. Observed live: Tetlock emitted ~620 chars on H-0003 and
the writer rejected the entire calibration.
- Case-Writer: Promise.all of 5 queries × max_parallel=2 jobs
demanded up to 10 connections against the investigator role's
rolconnlimit=4 → "too many connections for role investigator".
Sequentialized — the LLM call is the hot path, not these queries.
Smoke results visible now on the homepage:
- 3 hypotheses (H-0001/2/3) about green fireballs origin
- 3 contradictions (R-0001/2/3) about color, geographic confinement,
exclusive-green vs multicolored
- 2 evidence cards (E-0002/3) Grade B
- 3 outliers (G-0001/2/3) — including Taleb's deliberate
meteor-shower-camouflage flag
- 1 case report at /c/green-fireballs-sandia (Watson 13.4 KB,
five-act narrative, fully cited)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|---|---|---|
| .claude/agents | ||
| .forgejo/workflows | ||
| .nirvana/outputs/disclosure-bureau | ||
| case/gaps | ||
| docs/adrs | ||
| infra | ||
| investigator-runtime | ||
| scripts | ||
| tests/rag | ||
| web | ||
| wiki/entities/events | ||
| .gitignore | ||
| CHANGELOG.md | ||
| CLAUDE-schema-full.md | ||
| CLAUDE.md | ||
| CORPUS-SNAPSHOT.md | ||
| README.md | ||
The Disclosure Bureau
Investigative wiki + agentic chat sobre o corpus declassificado do US Department of War em
war.gov/ufo(116 PDFs, 3.435 páginas, 34k+ entidades, 28 vídeos UAP).
Live: disclosure.top
O que é
Pipeline de IA que transforma documentos UAP/UFO declassificados em uma wiki investigativa navegável + chat agêntico com retrieval semântico bilíngue (EN + PT-BR) e citações com bbox crop no PDF original.
A premissa metodológica é o padrão Karpathy LLM Wiki: ler tudo, compilar conhecimento em markdown cross-referenciado, navegar via wiki-links — não por busca vetorial. Em cima dessa wiki rodamos uma camada de hybrid retrieval (BM25 + BGE-M3 dense + cross-encoder rerank) para perguntas livres no chat.
A camada investigativa segue protocolo Investigation Bureau (Holmes/Poirot/Dupin/Locard + Schneier/Tetlock/Taleb): chain-of-custody, hypothesis tournament, residual uncertainty.
Arquitetura
PDFs (raw/)
↓ pdftoppm 72 DPI + pdftotext
processing/ (png + ocr)
↓ Sonnet 4.6 subagents (page-rebuilder, image-analyst, table-stitcher)
raw/<doc>--subagent/ (chunks bilíngues + bbox + anomaly flags)
↓ scripts/30 (BGE-M3 embed) + 31 (entity_mentions)
Postgres + pgvector + tsvector
↓ hybrid_search RPC + reranker
chat agente (OpenRouter) cita [[doc/p007#c0042]] → frontend renderiza crop bbox
Stack
- Embedding: BGE-M3 self-hosted (1024-dim, multilíngue, $0)
- Reranker: BGE-Reranker-v2-M3 self-hosted ($0)
- Vetor + texto: Postgres 15 + pgvector + tsvector bilíngue (
pt_unaccent,en_unaccent) - LLM (chat): OpenRouter — DeepSeek v4 free como default
- Frontend: Next.js 15 + React 19 + Tailwind + assistant-ui (Pattern C streaming)
- Auth + persistência: Supabase self-hosted (GoTrue, PostgREST, Storage, Imgproxy)
- Reverse proxy: Traefik + Let's Encrypt
- Imagens: sharp via
/api/crop(bbox on-demand, cached 1ano)
Layout
/Users/guto/ufo/
├── CLAUDE.md # contrato vinculante (24 tipos de markdown)
├── CLAUDE-schema-full.md # schema detalhado
├── README.md # este arquivo
├── raw/ # 116 PDFs imutáveis + chunks v0.2.0 derivados
│ ├── <pdfs>
│ ├── <doc-id>--subagent/ # chunks rebuilt (chunks/c*.md + _index.json + document.md)
│ └── _batch-rebuild/ # logs do orchestrator
├── processing/ # intermediários (PNG, OCR, vision JSON)
├── wiki/ # markdown gerado (documents/, pages/, entities/, tables/, images/)
├── case/ # artefatos Investigation Bureau (case-report, hypotheses, gaps)
├── scripts/ # 33 scripts numerados (Phase 0 → manutenção)
├── infra/ # docker-compose, embed-service, migrations, deploy
└── web/ # Next.js frontend
Quick start
# 1. Converter PDFs em PNG + OCR (uma vez)
./scripts/01-convert-pdfs.sh
# 2. Rebuild chunks bilíngues (Sonnet 4.6 via Claude Code subagents)
python3 scripts/28-batch-rebuild-all.py --workers 2
# 3. (após batch) Indexar em Postgres + embeddings
python3 scripts/30-index-chunks-to-db.py --skip-existing
# 4. (opcional) Materializar entity_mentions p/ grafo
python3 scripts/31-populate-entity-mentions.py
# 5. Deploy
cd infra/disclosure-stack && ./scripts/deploy.sh
Detalhes completos em infra/DEPLOY-CHECKLIST.md.
Features do frontend
| URL | Função |
|---|---|
/ |
Lista de documentos com resumo de 3 linhas, filtros (collection, classification, sort), busca |
/d/<doc> |
Visão legado (page grid + frontmatter) |
/d/<doc>/v2 |
Render rico de chunks com lang toggle (PT/EN/both), paged vs flow |
/d/<doc>/v2/<page> |
Single page V2 com PNG side-by-side |
/d/<doc>/full |
Texto consolidado bilíngue |
/e/<class> |
Lista paginada de entidades por classe (people, locations, ...) |
/e/<class>/<id> |
Detalhe da entidade + co-mentions + chunks live |
/search?q=... |
Hybrid search URL-shareable |
/timeline |
Cronologia de eventos por década |
/graph |
Grafo força-direcionado de co-menções (Obsidian-style) |
/admin/stats |
Analytics do corpus (FS + DB) |
/admin/batch |
Monitor de progresso do rebuild |
/admin/indexer |
Estado da camada de retrieval |
Atalhos globais:
⌘K/Ctrl+Kem qualquer página → command palette com hybrid_search- Toggle 🌐 EN ↔ PT-BR fixo bottom-left (cookie 1ano)
- Chat 💬 botão flutuante bottom-right com 12 ferramentas
Os 12 tools do agente
🔍 Retrieval: hybrid_search, read_chunk, get_page_chunks, list_anomalies
🔗 Grafo: entity_neighbors, entity_path, co_mention_chunks
📄 Wiki: read_document, read_page, read_entity, search_corpus
🧭 UI: navigate_to
Citações tipo [[doc-id/p007#c0042]] viram cards interativos com crop bbox + texto bilíngue + link.
Custos
| Item | Custo |
|---|---|
| Rebuild chunks (Sonnet 4.6 via Claude Code Max 20x) | ~$200 one-shot p/ 116 docs |
| Embedding BGE-M3 self-host | $0/mês |
| Reranker BGE-Reranker-v2-M3 self-host | $0/mês |
| Postgres + pgvector | já incluso no VPS |
| Chat LLM (DeepSeek free via OpenRouter) | $0/req |
| VPS (16GB / 4 CPU) | ~€10/mês |
Documentação
CLAUDE.md— contrato vinculante para agentes (schema v0.2.0)CLAUDE-schema-full.md— schema dos 24 tiposinfra/RETRIEVAL.md— arquitetura da camada de retrievalinfra/DEPLOY-CHECKLIST.md— runbook end-to-endinfra/embed-service/README.md— microsserviço BGE-M3
Licença + procedência
- PDFs declassificados: domínio público (US Department of War / FBI / DOS / NASA)
- Código deste projeto: MIT
- Modelos: BGE-M3 (MIT), DeepSeek v4 (proprietary via OpenRouter free tier)
- Branding: The Disclosure Bureau / disclosure.top — pessoal
Wiki investigativa, não advocacy. Toda claim tem chain-of-custody até a página + bbox do PDF original.