Skip to content

chore: remove pre-snapshot Architecture fallback and fabricated line/complexity metrics (CQ-H1) #217

Description

@parthrohit22

Task

Remove the Architecture surface's pre-snapshot file_tree fallback and the fabricated line/complexity metrics, so Architecture behaves like every other consumer: it returns a sealed-snapshot payload or an explicit missing_snapshot state. No analytical number may be displayed without a snapshot fact or an explicit, named heuristic with truth class.

Rationale

The 2026-07-27 PARTHA audit (§7, CQ-H1) found the flagship Architecture surface violates the product's core "evidence before confidence" contract:

  • apps/backend/app/analysis/architecture.py:133 publishes estimated_lines = max(len(module.files) * 80, 20) — invented from file count, not measured code.
  • apps/backend/app/analysis/architecture.py:185 falls back to _persisted_file_paths(record.file_tree) when no snapshot exists, producing modules/nodes/layers from a parallel representation instead of the canonical ri.v1 engine.

This directly contradicts the roadmap's honesty doctrine and the merge gate (no fabricated/placeholder data on any surface). It also creates a canonical-source bypass flagged in the audit's Repository Intelligence reuse assessment (score 6/10). Fixing it is a P0 because it is the most reputationally damaging gap — it makes users trust numbers that do not exist.

References

Implementation Notes

  • Delete estimated_lines / file-count "complexity" computation in _nodes_for_modules (architecture.py:118-140); if the schema must retain the fields, set them to an explicit measurement_state (e.g. not_computed) — never a synthesized value.
  • Remove the record.file_tree fallback in _modules_from_facts (architecture.py:181-185); when no sealed snapshot is present, return the same missing_snapshot contract the dependencies/review/insights consumers use (see SnapshotQueryService absent-snapshot path).
  • Frontend ArchitecturePage already has not_assessed/PreviewBanner patterns (see bug: AI Workspace is inert without a provider and admits it reads legacy context, contradicting the sealed-snapshot model #177/bug: backend validation errors are collapsed to a generic "Request validation failed" in the UI #180 work) — reuse them for the missing-snapshot state instead of rendering a fallback graph.
  • Keep ArchNode schema fields but mark them not_computed when unsupported; do not drop fields that break the OpenAPI contract without a coordinated schema-version note.
  • Non-goal: do not add new metrics here. Real metrics come only from sealed snapshot facts or a later, explicitly-modeled heuristic with formula + truth class.

Acceptance Criteria

  • Architecture returns an explicit missing_snapshot (or equivalent 4xx/empty-with-state) when no sealed ri.v1 snapshot exists — no 200 fallback graph.
  • No Architecture payload can contain a numerical estimated_lines/complexity value not backed by a snapshot fact or a named heuristic with truth class.
  • A new contract test fails if any consumer reads RepositoryRecord.file_tree or repo_metadata for analytical output (extends audit §7 required guard).
  • Existing frontend tests (productSurfaces.test.tsx, accessibility.test.tsx) still pass; the missing-snapshot state renders via the established honest-limit UI pattern.
  • npm run build:frontend and backend pytest pass; test_openapi_contract.py unchanged or updated with a coordinated note.

Priority

P0 - Critical

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0Priority: criticalengineeringEngineering taskhonestyProduct honesty and truthful state

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions