Skip to content

Automated documentation validation pipeline to detect drift from implementation #3

Description

@oomokaro1

What

Build a CI pipeline that automatically validates documentation against the actual codebase, detecting when docs describe features that don't exist or when code changes aren't reflected in docs.

Why

The documentation currently describes phantom endpoints, tables, and contract functions that were never implemented or have since been removed:

  • openapi.yaml documents /merchants/me/anchor, /v1/escrow/claimable, /v1/escrow/claimable/:id/claim — none of these controllers exist in the backend
  • architecture/backend.md references claimable_escrows and anchors tables — not in the Drizzle schema
  • contract/spec.md documents create_claimable_escrow, claim_escrow, get_claimable_escrow — not in the Soroban contract
  • architecture/frontend.md references useDexPrices hook and lib/dex — don't exist in the frontend

This creates a bad developer experience: contributors read the docs, try to use documented features, and find they don't work.

Scope

In scope

  1. API route validator — parse NestJS controllers to extract route definitions (method, path, auth), diff against openapi.yaml, flag phantom endpoints and missing docs
  2. Schema validator — parse src/db/schema.ts to extract table/column names, diff against architecture/backend.md, flag phantom tables/columns
  3. Contract validator — parse orbitstream_contracts/src/lib.rs for #[contractimpl] functions, diff against contract/spec.md, flag phantom/missing functions
  4. Link validator — parse all markdown files for internal links, verify targets exist, flag broken links
  5. CI integration — run all validators in GitHub Actions, warn on PRs that add code without updating docs or vice versa
  6. Drift reportnpm run docs:drift-report generates a markdown summary of all phantom claims

Out of scope

  • Auto-fixing docs (validators only report, don't modify)
  • Content quality review (only checks existence, not accuracy of descriptions)
  • External link checking (only internal file references)

Acceptance criteria

  • npm run docs:validate:api detects endpoints in openapi.yaml not backed by actual controllers
  • npm run docs:validate:schema detects tables/columns in docs not in schema.ts
  • npm run docs:validate:contract detects functions in spec.md not in lib.rs
  • npm run docs:validate:links detects broken internal markdown links
  • npm run docs:drift-report generates a summary report
  • GitHub Actions workflow runs validators on PRs touching orbitstream_docs/, OrbitStream_backend/src/, or orbitstream_contracts/src/
  • All validators pass for the current codebase (after cleaning phantom references)
  • Validators output machine-readable (JSON) for CI consumption

Technical context

  • NestJS controllers are at OrbitStream_backend/src/*/ — route decorators are @Get(), @Post(), @Patch(), @Delete() with path strings
  • Drizzle schema is at OrbitStream_backend/src/db/schema.ts — tables defined with pgTable(), columns with type helpers
  • Soroban contract is at orbitstream_contracts/src/lib.rs — functions marked with #[contractimpl]
  • OpenAPI spec is at orbitstream_docs/api/openapi.yaml
  • Architecture docs are at orbitstream_docs/architecture/*.md
  • Contract spec is at orbitstream_docs/contract/spec.md
  • Consider ts-morph for TypeScript AST parsing, regex for Rust function extraction
  • The orbitstream_docs repo has no package.json — the validators could live in the backend repo's scripts or as standalone Node scripts in the docs repo

Severity

medium — docs drift doesn't break functionality but misleads contributors and slows development.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions