Skip to content

ADR-0003: Deterministic AST Extraction and Incremental Generation Manifests

  • Status: Accepted
  • Date: 2026-11-27

Context

Relying purely on an LLM to discover Python module signatures, config schemas, metric formulas, or changed files risks hallucination, silent approximations, and excessive regeneration cost across releases. Moreover, scanned source repositories must be treated as untrusted data (comments or READMEs could contain prompt-injection attempts).

Decision

  1. Static Deterministic Extraction First: Use Python's ast.parse and tomllib to extract modules, classes, type-annotated function signatures, docstrings, Pydantic configuration fields, and metric definitions without executing any target repository code.
  2. Untrusted Data Isolation: Wrap all scanned source snippets in untrusted-context fences before passing them to any AI provider, and enforce secret/PII scanning prior to extraction and after generation.
  3. Explicit Provenance & Unverified Markers: Every metric field defaults to "unverified" unless verified directly from source/tests. Technical pages record source repository, application version, pinned commit SHA (never mutable branch links), and generation timestamp.
  4. Incremental Manifests (manifests/<product>.json): Track source file SHA-256 hashes, prompt/template hashes, knowledge model hash, and per-page source_dependencies + content_hash. Unchanged pages are skipped; manually edited pages whose disk hash differs from the manifest are preserved and flagged as conflicts rather than silently overwritten.

Consequences

  • API references, config tables, and source line links remain grounded in actual code.
  • Incremental runs regenerate only affected pages when source files, prompts, or templates change.