Skip to content

analyze.py: dedup against existing ADRs belongs in the deterministic layer #41

Description

@hailcpy

Problem

SKILL.MD preflight says: "Note existing ADR slugs — skip any chunk whose diff is already covered by an existing ADR (match by commit hash in the Links section)." But analyze.py doesn't implement this — it only computes next_adr_number(). Dedup is left entirely to agent discipline, which is exactly the kind of step that gets skipped on re-runs, producing duplicate ADRs for the same decision with new numbers.

Re-running on a growing repo is the primary long-term usage pattern (generate once, re-run quarterly), so incremental behavior should be deterministic, not prose.

Fix

In analyze() preflight:

  1. Scan the scope-resolved output_dir for NNNN-*.md files.
  2. Extract linked SHAs from each (the template's ## Links → Commits: line; tolerate short SHAs via prefix match).
  3. Mark any candidate whose commit set is fully covered ⇒ classification: "already_covered" (with the covering ADR's filename in signals). Partially covered ⇒ keep, but add a partially_covered_by note so the agent can extend the existing ADR instead of writing a new one.
  4. Report covered_candidates count in preflight.

Acceptance

  • Fixture repo with an existing ADR linking commits A,B: re-running analyze marks the A+B candidate already_covered; a new candidate C is unaffected.
  • Short-SHA links (7 chars) match full SHAs.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions