The Disclosure Bureau — declassified UAP/UFO wiki
Find a file
Luiz Gustavo 2ac42b99a7
Some checks failed
CI / Web — typecheck + lint + build (push) Failing after 33s
CI / Scripts — Python smoke (push) Failing after 5s
CI / Web — npm audit (push) Failing after 24s
CI / Retrieval — golden set (Recall@5 + MRR) (push) Failing after 3s
W5.5 (Phase 3C): Sun-Tzu strategist feeder + entity hero illustrations
Sun-Tzu (silent backend) — builds the strongest pro-anomaly brief the
corpus supports for any topic. Bilingual JSON: thesis + 2-4 pillars
(each with claim + citation-backed support) + honest residual
unexplained clause. NEVER surfaced reader-facing.

  Migration 0009 (apply as supabase_admin):
    public.pro_anomaly_briefs  brief_pk BIGSERIAL PK
                               brief_id B-NNNN unique
                               topic + topic_pt_br
                               thesis + thesis_pt_br
                               pillars JSONB
                               unexplained + unexplained_pt_br
                               doc_id, job_id, created_by, created_at
    + brief_id_seq sequence
    + GIN trigram indexes on topic + topic_pt_br
    + RLS policies (investigator INSERT, public SELECT)
    + GRANTs on seq + table to investigator

  prompts/sun-tzu.md
    "Adversarial strategist who plays the pro-disclosure side with the
    same rigour a red-team plays skeptic" — single thesis, 2-4 pillars,
    honest residual. Every claim cites a chunk. No fabrication from
    training-time knowledge. Output INTERNAL — case-writer pulls it.
    Bilingual mandatory. NO_STRONG_CASE sentinel when corpus is thin.

  detectives/sun_tzu.ts
    Grounds with hybridSearch top 18 chunks, calls Sonnet, parses
    JSON strict, calls writeProAnomalyBrief.

  tools/write_pro_anomaly_brief.ts
    Validates 2-4 pillars with bilingual claim+support, requires at
    least one [[wiki-link]] citation per pillar, INSERTs.

  orchestrator: new kind "anomaly_brief" dispatches Sun-Tzu.

Case-writer integration (detectives/case_writer.ts):
  - Pulls most recent matching brief via ILIKE on topic or doc_id.
  - Renders brief as a separate prompt section labelled
    "Strategic brief (internal — do NOT cite or attribute)".
  - Instructs the narrator to weave the thesis as a quiet through-
    line, use pillar facts in scenes, let the unexplained clause
    inform the closing paragraph. Forbidden to name "the analyst",
    say "a brief argues", or use the words "thesis"/"pillar"
    explicitly. Translate it into prose.

Entity hero illustrations:
  - 3 painterly editorial illustrations generated via Nano Banana
    Pro at 2K, stored under /data/disclosure/processing/case-art/:
    * EV-1947-06-24-kenneth-arnold-sighting.png — cockpit POV of
      Arnold in a CallAir A-2 over Mount Rainier, 9 chevron disc
      objects in formation, 1947 Life-magazine register.
    * EV-1947-07-08-roswell-incident.png — debris field in NM
      desert, USAAF officer in 1947 uniform examining foil
      fragments, period staff car.
    * EV-1947-06-21-maury-island-incident.png — wooden patrol
      boat on Puget Sound, 6 doughnut craft hovering, one
      shedding glowing slag, Harold Dahl + son + dog watching.
  - app/e/[cls]/[id]/page.tsx: full-bleed editorial hero replaces
    the old gradient header card when an illustration exists for
    that entity_id. Title sits over the painting with gradient
    overlay. "Ilustração editorial" chip in the top-right.

Quota note: Claude OAuth still rate-limited as of this commit, so
Sun-Tzu hasn't been smoke-tested in production. Code is shipped and
ready; first brief will land when the weekly quota refreshes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-24 16:41:20 -03:00
.claude/agents rebuild entity layer from Sonnet-vision reextract pipeline 2026-05-21 12:20:24 -03:00
.forgejo/workflows W2: rerank opt-in, analyze_image_region tool, RAG eval, graph cleanup, ADRs 2026-05-23 19:20:09 -03:00
.nirvana/outputs/disclosure-bureau phase-0: kill stubs, ship 20 curated anchor events, configure SMTP 2026-05-18 00:44:17 -03:00
case/gaps rebuild entity layer from Sonnet-vision reextract pipeline 2026-05-21 12:20:24 -03:00
docs/adrs W2: rerank opt-in, analyze_image_region tool, RAG eval, graph cleanup, ADRs 2026-05-23 19:20:09 -03:00
infra W5.5 (Phase 3C): Sun-Tzu strategist feeder + entity hero illustrations 2026-05-24 16:41:20 -03:00
investigator-runtime W5.5 (Phase 3C): Sun-Tzu strategist feeder + entity hero illustrations 2026-05-24 16:41:20 -03:00
scripts W0+W1+W1.2: security hardening, observability, autocomplete, glitchtip, forgejo CI 2026-05-23 18:18:42 -03:00
tests/rag W2: rerank opt-in, analyze_image_region tool, RAG eval, graph cleanup, ADRs 2026-05-23 19:20:09 -03:00
web W5.5 (Phase 3C): Sun-Tzu strategist feeder + entity hero illustrations 2026-05-24 16:41:20 -03:00
wiki/entities/events phase-0: kill stubs, ship 20 curated anchor events, configure SMTP 2026-05-18 00:44:17 -03:00
.gitignore W3.1-W3.4: Investigation Bureau foundation — migrations, runtime, Locard 2026-05-23 19:49:33 -03:00
CHANGELOG.md W3.1-W3.4: Investigation Bureau foundation — migrations, runtime, Locard 2026-05-23 19:49:33 -03:00
CLAUDE-schema-full.md phase-0: kill stubs, ship 20 curated anchor events, configure SMTP 2026-05-18 00:44:17 -03:00
CLAUDE.md baseline: Disclosure Bureau pipeline + Next.js UI + Supabase stack 2026-05-17 22:44:36 -03:00
CORPUS-SNAPSHOT.md baseline: Disclosure Bureau pipeline + Next.js UI + Supabase stack 2026-05-17 22:44:36 -03:00
README.md baseline: Disclosure Bureau pipeline + Next.js UI + Supabase stack 2026-05-17 22:44:36 -03:00

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+K em 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

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.