From 650c3fcda038d973985dd611088d741dec2ca261 Mon Sep 17 00:00:00 2001 From: "Jonathan D.A. Jewell" <6759885+hyperpolymath@users.noreply.github.com> Date: Wed, 12 Aug 2026 01:20:30 +0100 Subject: [PATCH] fix(rules): update SD004 to accept canonical .machine_readable/ layout Fixes for issue #426: SD004 rule was enforcing the retired .machine_readable/6a2/ layout while the current standards specify .machine_readable/ as the canonical location. Changes: 1. Added ANCHOR.a2ml to @a2ml_state_files (completes the seven canonical files) 2. Updated docstring to reflect new canonical location 3. Changed wrong_locations: now flags .machine_readable/6a2/ as wrong (not .machine_readable/) 4. Updated reason and target path to point to .machine_readable/ directly This eliminates false positives for repos using the current canonical layout. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe --- lib/rules/structural_drift.ex | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/rules/structural_drift.ex b/lib/rules/structural_drift.ex index 59c984cb..f6c54016 100644 --- a/lib/rules/structural_drift.ex +++ b/lib/rules/structural_drift.ex @@ -131,21 +131,23 @@ defmodule Hypatia.Rules.StructuralDrift do "ECOSYSTEM.a2ml", "AGENTIC.a2ml", "NEUROSYM.a2ml", - "PLAYBOOK.a2ml" + "PLAYBOOK.a2ml", + "ANCHOR.a2ml" ] @doc """ - SD004: Detect 6a2ml files outside of .machine_readable/6a2/. - These MUST be in .machine_readable/6a2/ and nowhere else. + SD004: Detect 6a2ml files in retired locations. + Canonical location is .machine_readable/.a2ml. + Retired location .machine_readable/6a2/.a2ml is no longer accepted. Severity: critical. - Action: move to .machine_readable/6a2/. + Action: move to .machine_readable/. """ def sd004_misplaced_a2ml(repo_path) do @a2ml_state_files |> Enum.flat_map(fn a2ml_file -> wrong_locations = [ Path.join(repo_path, a2ml_file), - Path.join([repo_path, ".machine_readable", a2ml_file]) + Path.join([repo_path, ".machine_readable", "6a2", a2ml_file]) ] wrong_locations @@ -155,9 +157,9 @@ defmodule Hypatia.Rules.StructuralDrift do rule: "SD004", file: Path.relative_to(path, repo_path), severity: :critical, - reason: "6a2ml file outside canonical location -- must be in .machine_readable/6a2/", + reason: "6a2ml file in retired location -- must be in .machine_readable/ directly", action: :move, - target: ".machine_readable/6a2/#{a2ml_file}" + target: ".machine_readable/#{a2ml_file}" } end) end)