gabriel / muse public
test_identity_plugin_invariant_docs.py python
55 lines 2.4 KB
Raw
sha256:e6186c2a5be8e7a1361b66ad64d74d3ed1865f3e713c55e7931b4c983e3c9df6 fix: get_signing_identity's MUSE_AGENT_KEY_FD path derived … Sonnet 5 patch 6 hours ago
1 """muse#227 (companion musehub#227) — the identity plugin's own docs must
2 describe I3 accurately: per-edge signature authorization (enforced at push
3 time, hub-side, in musehub/graph/push_validator.py), not "quorum soundness"
4 (a different, unrelated, never-invoked mechanism in musehub/graph/quorum.py).
5
6 Before this fix, muse/plugins/identity/plugin.py's module docstring and its
7 schema() description both labeled I3 "quorum soundness" — pointing readers
8 at the wrong one of the two non-reconciled "I3" definitions that existed in
9 the musehub codebase (musehub#227's own audit). Fixed on both sides: this
10 repo's docs now say "authorization", and musehub/graph/quorum.py no longer
11 claims the "I3" label at all.
12 """
13 from __future__ import annotations
14
15 import re
16
17 from muse.plugins.identity import plugin as identity_plugin
18
19
20 def _claims_label(doc: str, label: str) -> bool:
21 """True if *doc* uses *label* as an invariant-naming claim (a line
22 starting with the label followed eventually by a separator), not just
23 mentioning it in passing prose."""
24 pattern = re.compile(rf"^\s*{re.escape(label)}\b.*[—:]", re.MULTILINE)
25 return bool(pattern.search(doc))
26
27
28 def test_module_docstring_i3_is_authorization_not_quorum_soundness() -> None:
29 doc = identity_plugin.__doc__ or ""
30 assert _claims_label(doc, "I3")
31 # Find just the I3 line for a precise check.
32 i3_line = next(
33 line for line in doc.splitlines() if re.match(r"^\s*I3\b", line)
34 )
35 assert "Authorization" in i3_line or "authorization" in i3_line, (
36 f"I3 line must describe authorization (the real, enforced "
37 f"mechanism), not quorum soundness: {i3_line!r}"
38 )
39 assert "quorum soundness" not in i3_line.lower(), (
40 f"I3 line still says 'quorum soundness' — that's the OTHER, "
41 f"never-invoked mechanism (musehub/graph/quorum.py), not what "
42 f"push_validator.py actually enforces for I3: {i3_line!r}"
43 )
44
45
46 def test_schema_description_i3_is_authorization_not_quorum_soundness() -> None:
47 schema = identity_plugin.IdentityPlugin().schema()
48 description = schema["description"]
49 assert "(I3)" in description
50 assert "quorum soundness" not in description.lower(), (
51 f"schema() description still calls I3 'quorum soundness': {description!r}"
52 )
53 assert "authoriz" in description.lower(), (
54 f"schema() description should describe I3 as authorization: {description!r}"
55 )
File History 1 commit
sha256:e6186c2a5be8e7a1361b66ad64d74d3ed1865f3e713c55e7931b4c983e3c9df6 fix: get_signing_identity's MUSE_AGENT_KEY_FD path derived … Sonnet 5 patch 6 hours ago