Skip to content

Add evidence-backed Structure view to Review Tutor #62

Description

@ElbertePlinio

Goal

Add an evidence-backed Structure view to Review Tutor so a reviewer can understand how changed files connect and how dependency topology changes without reading every file sequentially.

Parent work: #59
Current UI PR: #61

Product contract

  • Diff remains the default and source of truth.
  • Diff | Structure switches views over the same immutable input snapshot.
  • Structure shows deterministic import/dependency topology, not inferred runtime architecture.
  • Changed files are the default scope; optional one-hop neighbors provide context.
  • Every shown connection has exact source or diff-line evidence.
  • Added connections use semantic green, removed connections use dashed rose, unchanged context is muted, and the selected item owns the single ember highlight.
  • Selecting a file or connection opens a compact evidence panel with Open in Diff; tutor integration comes only after the graph is trustworthy.
  • Mobile and high zoom default to an accessible Connections list rather than forcing a cramped graph.
  • Partial analysis is explicit: say no import data, never no dependencies.

Source fidelity

Source Honest comparison
Worktree index → working-tree patch
Staged HEAD → index
Commit first parent → commit; root/unsupported merge cases degrade explicitly
Range merge-base → target
Pull request base SHA → head SHA only when required Git objects are local
Pasted code unavailable; do not guess

Remote PR objects must not be fetched or checked out automatically. When unavailable locally, provide a clearly labeled patch-only partial result.

Acceptance criteria

  • Parse changed files, additions/deletions, and renames once in a DOM-free server module.
  • Produce deterministic, sorted Structure snapshots from a bounded local analyzer.
  • Support TypeScript/JavaScript import, re-export, require, and dynamic-import edges first.
  • Represent added, removed, unchanged, unresolved, partial, truncated, and unavailable states honestly.
  • Attach bounded exact evidence lines to every edge; no edge may exist only because a model inferred it.
  • Limit scope to changed files plus at most one-hop neighbors.
  • Expose one bearer-authenticated, Host/Origin-protected local endpoint.
  • Add an accessible Connections list with evidence and Diff jumps before the graph canvas.
  • Add a deterministic DOM/SVG Structure graph with stable positions and keyboard navigation.
  • Preserve the existing diff, tutor, configuration, learning-log, responsive, security, and persistence behavior.
  • Add Dart support next and Rust after TypeScript/JavaScript is proven.
  • Pass functional, security, resource-limit, keyboard, responsive, and rendered visual acceptance.
  • Stop at Ready for human review; Elberte alone authorizes merges.

Non-goals

  • No whole-repository hairball, transitive expansion, call graph, runtime tracing, architecture score, or health badge.
  • No LLM-generated edges or architecture verdicts.
  • No cloud analysis, daemon, telemetry, external assets, source writes, PR actions, or automatic Git fetch/checkout.
  • No force-directed physics, decorative animation, multicolor edge palette, or canvas-only inaccessible graph.
  • No speculative analyzer plugin system.

PR plan

  • PR 1 — comparison provenance and analysis core

    • Depends on: feat(review-tutor): redesign guided review interface #61 finished and human-approved.
    • Add DOM-free diff parsing with rename tracking.
    • Capture honest source comparison metadata.
    • Add deterministic TypeScript/JavaScript connection analysis and bounded evidence.
    • Add the authenticated Structure endpoint; no UI.
    • Validation: focused graph/protocol/security/resource tests plus bun run check.
    • Link: pending.
  • PR 2 — accessible Connections list

    • Depends on: PR 1.
    • Add Diff | Structure, partial-state disclosure, per-file changed connections, compact evidence rows, and Open in Diff.
    • Make List mode the keyboard, screen-reader, mobile, and high-zoom baseline.
    • Validation: executable page tests and browser proof at 1440, 860, 390, and 400% zoom.
    • Link: pending.
  • PR 3 — deterministic Structure graph

    • Depends on: PR 2.
    • Add stable layered DOM/SVG layout, directory clustering, node/edge selection, bounded filtering, and one-hop neighbor toggle.
    • Keep mobile/high zoom on List mode unless the user explicitly opens the graph.
    • Validation: small, partial, truncated, clustered, keyboard-only, and resize/zoom browser acceptance.
    • Link: pending.
  • PR 4 — mobile-language and tutor integration

    • Depends on: PR 3.
    • Add Dart, then Rust, using private language-table entries rather than a plugin system.
    • Add Ask about this file/connection using exact evidence as the existing tutor selection.
    • Complete final design-lead, local-review, CI, and human-review gates.
    • Link: pending.

Traceability

Acceptance area Slice Validation Status
Honest source provenance and deterministic edges PR 1 graph fixtures across worktree/staged/commit/range/PR/paste pending
Auth, limits, cancellation, and failure containment PR 1 server security and bounded-read tests pending
Evidence-first architectural review PR 2 runtime DOM tests and Diff-jump browser flow pending
Diagram comprehension and scale PR 3 rendered small/large/partial graph acceptance pending
Flutter/mobile relevance and tutor reuse PR 4 Dart/Rust fixtures and real tutor question flow pending

Resource and honesty limits

Start with conservative caps and return a valid partial snapshot when exceeded. The implementation plan must bound changed files, nodes, edges, analyzer output, evidence per edge, line length, runtime, and child processes. Binary, oversized, unsupported, aliased, or unresolved inputs are omitted with explicit reasons rather than guessed.

Feature flag decision

No flag while Review Tutor remains a private, unreleased prototype and each user-visible slice is independently complete. If packaging or release exposure lands before this work is complete, stop and add a default-off reviewTutorStructureView flag with the full enable-and-remove lifecycle before merging user-visible graph work.

Validation

bun run typecheck
bun run lint
bun run test
bun run test:coverage
bun run build
bun run check

Rendered proof must cover 1440px desktop, the 860px boundary, 390px mobile, and 400% zoom. Final aesthetic acceptance returns to the named Pickforge design lead.

Status

Current status: Deferred / planned

Do not start implementation until #61 is finished, manually approved, and its final disposition is recorded in #59.

Next action when resumed: run a read-only TypeScript/JavaScript analysis spike on several real PR snapshots and lock the analyzer payload before source edits.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions