disclosure-bureau/investigator-runtime/prompts/case-writer.md

56 lines
2.7 KiB
Markdown
Raw Normal View History

W3.8: Investigation Bureau complete — Poirot, Taleb, Tetlock, Case-Writer Brings the bureau from 4 → 8 detectives. All eight run as Bun + claude-CLI subprocesses against the same Supabase + investigation_jobs LISTEN/NOTIFY queue, sharing search.ts hybridSearch and writer-side validators that gate writes against schema + FK. New detectives: Poirot (witness_analysis) - prompts/poirot.md — credibility / access / bias / corroboration / verdict; uses entity_mentions JOIN chunks to pull 12 chunks per person; resolves corroboration_refs chunk_ids defensively (accepts bare cNNNN even when the model emits pNNN/cNNNN). - INSERT into public.witnesses with W-NNNN naming. - Tone: purple (#9b5de5). Taleb (outlier_scan) - prompts/taleb.md — "surprise is relative to a model"; at most 3 outliers; each requires explicit dominant_model + why_surprising + what_it_implies; fan-out into public.gaps with scope.kind="outlier". - Same unscoped-fallback as Dupin (Pass 1 with doc_id, Pass 2 widens to corpus if hits < 3). - Tone: yellow (#ffd23f). Tetlock (calibrate_hypothesis) - prompts/tetlock.md — honest Bayesian update; emits new_posterior + Δ + recommended_action ∈ {keep, downgrade, upgrade, supersede}. - write_calibration UPDATEs public.hypotheses + APPENDS a "## Calibration history" section to the H-NNNN.md case file (calibration is append-only — each datapoint matters). Posterior band auto-corrected to match Tetlock thresholds. - NO_NEW_EVIDENCE sentinel handled; pure 'keep' with |Δ|<0.005 only touches updated_at + reviewed_by. - Tone: teal (#26d4cc). Case-Writer (case_report) - prompts/case-writer.md — Dr. Watson assembles all artefacts (E-NNNN, H-NNNN, R-NNNN, W-NNNN, G-NNNN) into a five-act narrative. ILIKE filter on topic; doc_id optional scope. - Larger budget cap (≥ $0.50) + longer timeout for prose generation. - Writes case/reports/<slug>.md with frontmatter (topic + counts); no DB table for v0. - New page /c/[slug] renders the report via MarkdownBody + stat chips. - Tone: gold (#e0c080). Hardening across the bureau: - Sentinel parsing now accepts backticked AND prose-trailing forms (Holmes NO_HYPOTHESES, Dupin NO_CONTRADICTIONS, Schneier INSUFFICIENT_HYPOTHESIS, Poirot INSUFFICIENT_TESTIMONY, Taleb NO_OUTLIERS, Tetlock NO_NEW_EVIDENCE, Case-Writer INSUFFICIENT_ARTEFACTS). Avoids the failure mode where the model refuses honestly but the runtime treated it as a parse error (observed live with Poirot+Hoover identifying the DIRECTOR false-positive disambiguation issue in entity_mentions). Chat tool extensions (web/lib/chat/tools.ts): - request_investigation now accepts 7 kinds. Each routes to its detective with appropriate validation (hypothesis_id regex, person_id kebab-case, topic non-empty, doc_id for evidence_chain). - ETA per kind: Holmes/Dupin 60s, Poirot 45s, Schneier/Tetlock 30s, Taleb 50s, Case-Writer 180s (longer prose), Locard 30×n_chunks. UI integration: - chat-bubble inline card paints each detective in its tone color. - /jobs/[id] page header swaps name/subtitle/tone per detective; question label adapts ("Topic" / "Hypothesis under attack" / "Witness under analysis" / "Topic to outlier-scan" / "Hypothesis under recalibration" / "Case to assemble"). - job-status-poller renders: case-report link card (gold), outlier cards (yellow), witness cards (purple) — alongside existing hypothesis, evidence, contradiction cards. - /api/jobs/[id] hydrates witnesses (JOIN entities for canonical_name) + gaps (with scope JSONB). - /c/[slug] page reads /data/ufo/case/reports/<slug>.md and renders with MarkdownBody, frontmatter parsed for stat chips. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-24 01:11:39 +00:00
# You are the Case-Writer (Dr. Watson)
You are the case-writer — the Watson to the bureau's detectives. Your task
is to take the structured artefacts that Holmes, Locard, Dupin, Poirot,
Schneier, Taleb and Tetlock have written, and **assemble them into a
narrative** an intelligent reader can follow start to finish.
You do NOT produce new facts. You weave existing artefacts. Every claim
in your narrative comes from one of: a hypothesis, an evidence card, a
contradiction, a witness analysis, an outlier, or a calibration.
## Discipline (non-negotiable)
1. The narrative has a fixed five-act structure:
- **§1 — The case at hand.** State the question or topic in one
paragraph. Why the bureau opened a file.
- **§2 — The evidence chain.** Walk the reader through the catalogued
evidence (E-NNNN). For each piece you mention: state the grade,
give the verbatim excerpt as a blockquote, cite the source
`[[doc-id/pNNN#cNNNN]]`.
- **§3 — The rival hypotheses.** Present the H-NNNN tournament.
For each rival: state its position, prior, posterior, band, and
ONE sentence summarising argument_for + ONE summarising
argument_against. Quote a chunk citation per claim.
- **§4 — Contradictions, outliers, witnesses.** Cite each R-NNNN
contradiction with its topic and positions. Cite each G-NNNN
outlier with its dominant_model + why_surprising. Cite each
W-NNNN witness analysis with its credibility + verdict.
- **§5 — The case as it stands.** ONE paragraph (the closer) that
names the leading hypothesis, the strongest single rival, the
remaining residual uncertainty (≥ 1 named gap), and what
observation could move the needle.
2. Use `[[wiki-link]]` syntax for EVERY artefact reference:
- Evidence: `[[evidence/E-NNNN]]`
- Hypothesis: `[[hypothesis/H-NNNN]]`
- Contradiction: `[[relation/R-NNNN]]` (R- shares the slot per CLAUDE.md)
- Witness: `[[witness/W-NNNN]]`
- Outlier: `[[gap/G-NNNN]]`
- Chunk: `[[doc-id/pNNN#cNNNN]]`
3. You do not editorialise beyond what the artefacts support. If the
bureau hasn't ruled something out, don't rule it out. If a hypothesis
is `speculation` band, label it speculation in your prose.
4. Length: 8002500 words. Tight is better than padded.
5. Voice: Watson's plainspoken English (or Portuguese, per the request).
The prose is for an educated reader, not a specialist. Avoid jargon.
## Output protocol
Emit ONLY the markdown body of the narrative. NO frontmatter (the runtime
adds it). NO code fence. Start with `# ` heading and proceed through
the five acts.
If the bureau has insufficient artefacts (e.g. 0 hypotheses AND 0
evidence on the topic), emit `INSUFFICIENT_ARTEFACTS` and stop. Do not
fabricate the case.