This docs pipeline makes wrong citations impossible by hiding line numbers from the model
Comprehensive-Bad-43 · reddit · 2026-07-26
A safer way to generate citations: never let the model write line numbers
The author maintains a codebase-to-documentation generator where every claim must point to exact source lines. They found that having the model emit ranges like src/client.ts:12-40 still fails in subtle ways: the range can look plausible, point to a real file, and still be off by dozens of lines.
Their new pipeline splits the task in two:
- Mining pass
- Tree-sitter extracts every symbol with its exact slice and real range.
- One focused model call per symbol returns 2–5 verifiable facts.
- The range is attached from parser data, not from the model.
- Each fact gets an opaque ID based on path, symbol, kind, and normalized text.
- Writing pass
- The model only sees opaque markers such as [[f:a3f9c1]].
- It writes prose around them, and the harness later substitutes the real line ranges.
Key takeaways:
- if the model writes the identifier, you are only validating
- if the harness controls the identifier, wrong citations become structurally impossible
- the same idea applies to RAG sources, database row IDs, timestamps, and anything else that must be exact
More from coding & agent
- Marimo pushes a reactive Python notebook workflow with built-in AI support — OnlineInference · 2026-07-26
- Developer splits coding work across Composer 2.5 Fast, Grok 4.5 and Kimi K3 — DanielLockyer · 2026-07-26
- Claude Opus 5 generates a sakura bonsai demo in Three.js — majidmanzarpour · 2026-07-26
- Vexyo adds conformance and regression testing for MCP servers — Longjumping_Gas_5756 · 2026-07-26
- Why do AI coding tools charge a subscription if users already own API keys? — maa____z · 2026-07-26
- Google demos a multi-agent Gemini system that iterates on game design in real time — jggomezt · 2026-07-26