From df970a9379641f65e01d057133fead3cb78d0d72 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 20:04:04 +0000 Subject: [PATCH] fix(rsr): restore the deed-first 3.1.1 and 3.2.1 that #1117 described main has not compiled since #1117: descriptiles_parse/1 calls deed_state/1, which nothing defines; a duplicate `record_files == []` branch can never run; and descriptile_carrier/0 is defined but never used, so 3.1.1 still read only the directory. - deed_state/1: the chora deed is :absent, :ok (parses as a repo-deed) or :broken. deed_parses?/1 is folded into it. - 3.1.1 uses descriptile_carrier/0: the deed first, then the directory. - 3.2.1: a broken chora deed fails even when the .a2ml files parse. #1117's own tests ("3.1.1: a chora deed with a top-level descriptile clause is the substrate", "3.2.1 needs every carrier to parse, the deed first") fail on the code before #1117 and pass with this change. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0136P7ZkGCWGEyedTtdEHAPT --- lib/rules/rsr_conformance.ex | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/lib/rules/rsr_conformance.ex b/lib/rules/rsr_conformance.ex index 23b93751..6151b4f5 100644 --- a/lib/rules/rsr_conformance.ex +++ b/lib/rules/rsr_conformance.ex @@ -460,7 +460,7 @@ defmodule Hypatia.Rules.RsrConformance do ".well-known/humans.txt" ]), "2.3.1" => any_of(["0-AI-MANIFEST.a2ml", "0-AI-MANIFEST.deed"]), - "3.1.1" => present_mr("descriptiles"), + "3.1.1" => descriptile_carrier(), "3.1.2" => descriptile("STATE", "status"), "3.1.3" => descriptile("META", "meta"), "3.1.4" => descriptile("ECOSYSTEM", "ecosystem"), @@ -610,13 +610,24 @@ defmodule Hypatia.Rules.RsrConformance do end end - defp deed_parses?(repo) do - with {:ok, path} <- Hypatia.Deed.repo_deed_path(repo), - {:ok, text} <- File.read(path), - {:ok, {"repo-deed", _items}} <- Hypatia.Deed.parse(text) do - true - else - _ -> false + # The chora deed's state: :absent (no deed file), :ok (it parses as a + # repo-deed) or :broken (present but unreadable, unparsable, misnamed or + # ambiguous). + defp deed_state(repo) do + case Hypatia.Deed.repo_deed_path(repo) do + {:ok, path} -> + with {:ok, text} <- File.read(path), + {:ok, {"repo-deed", _items}} <- Hypatia.Deed.parse(text) do + :ok + else + _ -> :broken + end + + :none -> + :absent + + _ -> + :broken end end @@ -652,8 +663,10 @@ defmodule Hypatia.Rules.RsrConformance do deed = deed_state(repo) cond do - record_files == [] -> - if deed_parses?(repo), do: :pass, else: :fail + # The deed first: a broken chora deed fails 3.2.1 even when the + # remaining .a2ml files parse (#1117). + deed == :broken -> + :fail record_files == [] -> if deed == :ok, do: :pass, else: :fail