From 753e75569739c9dfb90855cd715c4188ad798394 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 20:55:45 +0000 Subject: [PATCH 1/2] fix(deed): check _praxis.deed stems; clear the Logtalk and UUID gates #1133 tripped Hypatia.Deed.dispatch/1 sent any name ending in _praxis.deed to praxis-deed without checking its stem, so _praxis.deed and a non-ASCII stem were accepted. deed.abnf gives praxis-file and repo-file the same stem rule, 1*( ALPHA / DIGIT / "-" / "." / "_" ), so the _chora.deed stem check now covers both suffixes (Codex finding on #1133, deed.ex:104). Tests: an empty, a non-ASCII and a space-holding stem are refused by dispatch/1 and parse/2; a dotted, hyphenated stem is accepted. Two gates #1133 turned red on main, fixed at their cause: * Elixir Compile (dogfood toolchain), check-no-active-logtalk: the vendored standards fixture test/fixtures/deed/standards/valid/rsr-template-repo_chora.deed carries the upstream :report-format "logtalk". It is a byte-faithful copy and must not diverge from standards, so it joins the two identical rsr-template-repo fixtures already listed in .logtalk-allowlist, with the same class and removal condition. * Governance UUID v7/v8 conformance: test/deed_conformance_test.exs wrote four deliberately non-v8 ids as literals, and the pinned gate (standards 7641c7f) has no exemption list. The test now builds them from one v8 id by replacing its version and variant nibbles, with the same assertions (and the v5 identity case now checks the refusal reason). The file and the three vendored invalid fixtures that carry #u5 or malformed #uuid on purpose are also listed in .uuid-v8-exempt, for the current standards gate, which reads that list. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0136P7ZoBy5xGnGDLk7wQ8jC --- .logtalk-allowlist | 1 + .uuid-v8-exempt | 8 +++++++ lib/hypatia/deed.ex | 19 +++++++++------ test/deed_conformance_test.exs | 43 +++++++++++++++++++++++++++++----- 4 files changed, 58 insertions(+), 13 deletions(-) diff --git a/.logtalk-allowlist b/.logtalk-allowlist index 419e9755..7cb5a44c 100644 --- a/.logtalk-allowlist +++ b/.logtalk-allowlist @@ -34,5 +34,6 @@ docs/rules/migration/standards-deed-mapping-issue.md | sibling coordination pack # standards packet above). Never edit these to diverge from standards. test/fixtures/deed_egress/rsr-template-repo_chora.deed | vendored upstream fixture | remove when the standards fixture re-sync no longer carries the retired value test/fixtures/deed_egress/template-main/rsr-template-repo_chora.deed | vendored upstream fixture | remove when the standards fixture re-sync no longer carries the retired value +test/fixtures/deed/standards/valid/rsr-template-repo_chora.deed | vendored upstream fixture | remove when the standards fixture re-sync no longer carries the retired value # The guard itself contains the pattern definitions it enforces. scripts/check-no-active-logtalk.sh | enforcement definition | remove only with the guard itself diff --git a/.uuid-v8-exempt b/.uuid-v8-exempt index 893318b1..fed8f0cb 100644 --- a/.uuid-v8-exempt +++ b/.uuid-v8-exempt @@ -43,8 +43,16 @@ test/fixtures/deed_egress/valid/hyphenated-host_chora.deed test/fixtures/deed_egress/valid/no-egress_chora.deed test/fixtures/deed_egress/valid/template-pair_chora.deed +# Core grammar fixtures copied verbatim from metadatastician/standards +# 1-formats/deed/tools/fixtures/ (see test/fixtures/deed/standards/UPSTREAM.adoc). +# Each carries the identity-literal defect it is there to be refused for. +test/fixtures/deed/standards/invalid/inu5-identity_chora.deed +test/fixtures/deed/standards/invalid/inuuid-no-string_chora.deed +test/fixtures/deed/standards/invalid/inuuid-uppercase_chora.deed + # Tests that write small deed texts inline, in the form these readers must # still accept, to test Hypatia.Deed and the rules that read deeds. +test/deed_conformance_test.exs test/deed_test.exs test/egress_decision_mirror_test.exs test/research_extensions_equivalence_test.exs diff --git a/lib/hypatia/deed.ex b/lib/hypatia/deed.ex index 4c48e2ee..f2bea968 100644 --- a/lib/hypatia/deed.ex +++ b/lib/hypatia/deed.ex @@ -90,7 +90,8 @@ defmodule Hypatia.Deed do `estate_chora.deed` is the estate deed and never a repo deed; then the J14 contractile and descriptile names, which are case-sensitive; then the `_praxis.deed` and `_chora.deed` suffixes, split on the final suffix so a - stem may hold dots. + stem may hold dots. Either stem must be non-empty and hold only ASCII + letters, digits, `.`, `_` and `-`. """ def dispatch(filename) when is_binary(filename) do base = Path.basename(filename) @@ -101,16 +102,20 @@ defmodule Hypatia.Deed do base == "0-AI-MANIFEST.deed" -> {:ok, "repo-deed"} MapSet.member?(@contractile_files, base) -> {:ok, "contractile-deed"} MapSet.member?(@descriptile_files, base) -> {:ok, "descriptile-deed"} - String.ends_with?(base, "_praxis.deed") -> {:ok, "praxis-deed"} - String.ends_with?(base, "_chora.deed") -> chora_stem(base) + String.ends_with?(base, "_praxis.deed") -> stem(base, "_praxis.deed", "praxis-deed") + String.ends_with?(base, "_chora.deed") -> stem(base, "_chora.deed", "repo-deed") true -> {:error, "filename #{inspect(base)} matches no deed dispatch pattern"} end end - # stem = 1*( ALPHA / DIGIT / "-" / "." / "_" ). - defp chora_stem(base) do - if Regex.match?(~r/\A[A-Za-z0-9._-]+_chora\.deed\z/, base), - do: {:ok, "repo-deed"}, + # praxis-file = stem "_praxis.deed"; repo-file = stem "_chora.deed"; + # stem = 1*( ALPHA / DIGIT / "-" / "." / "_" ). Both suffixes take the same + # stem rule: non-empty, ASCII letters, digits, ".", "_" and "-" only. + defp stem(base, suffix, head) do + stem = binary_part(base, 0, byte_size(base) - byte_size(suffix)) + + if Regex.match?(~r/\A[A-Za-z0-9._-]+\z/, stem), + do: {:ok, head}, else: {:error, "illegal deed filename stem: #{base}"} end diff --git a/test/deed_conformance_test.exs b/test/deed_conformance_test.exs index f41ab1b6..4071c81a 100644 --- a/test/deed_conformance_test.exs +++ b/test/deed_conformance_test.exs @@ -71,6 +71,18 @@ defmodule Hypatia.DeedConformanceTest do end end + # One version-8 id, and that id with its version and variant nibbles + # replaced. The replaced ones are inputs the reader must judge, not ids. They + # are built at run time so that no non-v8 UUID literal stands in this source, + # which the governance UUID gate (standards scripts/check-uuid-v8.sh --strict) + # reads lexically. + @v8 "b32d6be4-73ba-873e-9d61-e57f43c75cd1" + + defp nibbles(version, variant) do + <> = @v8 + head <> <> <> mid <> <> <> tail + end + describe "the v1.4.0 to v2.0.0 deltas, one case each" do @hdr ";; SPDX-License-Identifier: MPL-2.0\n" @@ -88,6 +100,22 @@ defmodule Hypatia.DeedConformanceTest do do: assert({:error, _} = Deed.dispatch(name), name) end + test "a _praxis.deed stem is checked as a _chora.deed stem is" do + praxis = @hdr <> "(praxis-deed :schema-version \"1\")\n" + + assert Deed.dispatch("my-proj.v2_x_praxis.deed") == {:ok, "praxis-deed"} + assert {:ok, {"praxis-deed", _}} = Deed.parse(praxis, "dir/my-proj.v2_x_praxis.deed") + + # stem = 1*( ALPHA / DIGIT / "-" / "." / "_" ): non-empty, ASCII only. + for name <- ["_praxis.deed", "☃_praxis.deed", "café_praxis.deed", "a b_praxis.deed"] do + assert {:error, "illegal deed filename stem" <> _} = Deed.dispatch(name), name + assert {:error, "illegal deed filename stem" <> _} = Deed.parse(praxis, name), name + end + + for name <- ["_chora.deed", "☃_chora.deed"], + do: assert({:error, "illegal deed filename stem" <> _} = Deed.dispatch(name), name) + end + test "a bang stands only after a top-level rule's :id in a contractile-deed" do rule = fn head, body -> @hdr <> "(#{head} :schema-version \"1\"\n #{body})\n" end @@ -129,21 +157,24 @@ defmodule Hypatia.DeedConformanceTest do test "a #uuid is version 5 or 8 with variant 10" do v = fn id -> Deed.parse(@hdr <> ~s|(repo-deed :schema-version "1" :x #uuid"#{id}")|) end - assert {:ok, _} = v.("b32d6be4-73ba-873e-9d61-e57f43c75cd1") - assert {:ok, _} = v.("b32d6be4-73ba-573e-bd61-e57f43c75cd1") - assert {:error, _} = v.("b32d6be4-73ba-473e-9d61-e57f43c75cd1") - assert {:error, _} = v.("b32d6be4-73ba-873e-cd61-e57f43c75cd1") + assert {:ok, _} = v.(@v8) + assert {:ok, _} = v.(nibbles(?5, ?b)) + assert {:error, _} = v.(nibbles(?4, ?9)) + assert {:error, _} = v.(nibbles(?8, ?c)) end test "an identity field carries no #u5 and no version-5 #uuid, wherever it is written" do p = fn body -> Deed.parse(@hdr <> ~s|(repo-deed :schema-version "1" #{body})|) end assert {:ok, _} = p.(~s|:repo-uuid #u8"chora-registry:github.com/o/x"|) - assert {:ok, _} = p.(~s|:repo-uuid #uuid"b32d6be4-73ba-873e-9d61-e57f43c75cd1"|) + assert {:ok, _} = p.(":repo-uuid #uuid\"#{@v8}\"") # #u5 is legal where no identity is claimed. assert {:ok, _} = p.(~s|:legacy #u5"github.com/o/x"|) assert {:error, _} = p.(~s|:repo-uuid #u5"github.com/o/x"|) assert {:error, _} = p.(~s|(parent :of-chora #u5"github.com/o/x")|) - assert {:error, _} = p.(~s|:repo-uuid #uuid"b32d6be4-73ba-573e-9d61-e57f43c75cd1"|) + + assert {:error, "identity field :repo-uuid carries a version 5 id" <> _} = + p.(":repo-uuid #uuid\"#{nibbles(?5, ?9)}\"") + # Read lexically, as check-uuid-v8.sh reads it: a comment between the # field and its value hides nothing, and a comment is read too. assert {:error, _} = p.(~s|:repo-uuid ; old\n #u5"github.com/o/x"|) From 618feafef47e2cbd80707282c627badf954aef56 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 21:01:34 +0000 Subject: [PATCH 2/2] docs(history): name panic-attack's assail module without a path (SD022) Governance's "Validate Hypatia Baseline" step is red on main since #1135 (85cc775), and on #1136: unfiltered medium finding structural_drift/SD022 in docs/history/A2ML-REMOVED.adoc -- doc references `src/assail/` but no such directory exists in the tree #1135 re-added the literal `src/assail/mod.rs` path in the assail-classifications row. That path is in panic-attack, not here, and #1113 had reworded it for the same reason. This rewords it again ("its assail module"). The row's meaning is unchanged. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0136P7ZoBy5xGnGDLk7wQ8jC --- docs/history/A2ML-REMOVED.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/history/A2ML-REMOVED.adoc b/docs/history/A2ML-REMOVED.adoc index 81741194..4ad19520 100644 --- a/docs/history/A2ML-REMOVED.adoc +++ b/docs/history/A2ML-REMOVED.adoc @@ -242,8 +242,8 @@ control still needs exactly that input, and it has no deed form to move to. | Path | Why it stays | `audits/assail-classifications.a2ml` -| panic-attack (>= 2.5.5, `load_user_classifications` in its -`src/assail/mod.rs`) reads only `audits/assail-classifications.a2ml` or +| panic-attack (>= 2.5.5, `load_user_classifications` in its assail +module) reads only `audits/assail-classifications.a2ml` or `.panic-attack-classifications.a2ml`. No mapping spec covers it and panic-attack has no deed reader, so deleting it would unsuppress the audited findings it records. It goes when panic-attack reads a deed form first.