Canon marker check: refuse repeated keys, read BOM files, fullmatch ids, loud bad base ref; untrack pyc (Soul)
Some checks failed
Canon marker / check (pull_request) Has been cancelled

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Weksa 2026-11-09 11:31:57 +00:00
commit ddf79e4373
3 changed files with 102 additions and 7 deletions

View file

@ -129,6 +129,74 @@ class CanonMarker(unittest.TestCase):
self.assertEqual(code, 1, out)
self.assertNotIn("Traceback", out)
def test_a_python_object_tag_is_refused_not_executed(self):
text = "---\nkind: !!python/object/apply:os.getcwd []\n---\nx\n"
code, out = self.run_pages({"Aetheria/A.md": text})
self.assertEqual(code, 1, out)
self.assertNotIn("Traceback", out)
def test_a_repeated_key_fails(self):
text = f"---\nkind: proposal\nkind: canon\nrulings:\n - {RULING}\n---\nx\n"
code, out = self.run_pages({"Aetheria/A.md": text})
self.assertEqual(code, 1, out)
self.assertIn("duplicate", out)
def test_a_bom_does_not_hide_the_marker(self):
code, out = self.run_pages({"Aetheria/Legacy.md": "\ufeff---\nkind: canon\n---\nx\n"})
self.assertEqual(code, 1, out)
def test_a_ruling_id_with_a_trailing_newline_is_malformed(self):
text = f'---\nkind: canon\nrulings:\n - "{RULING}\\n"\n---\nx\n'
code, out = self.run_pages({"Aetheria/A.md": text})
self.assertEqual(code, 1, out)
def test_empty_frontmatter_is_a_kindless_page_not_unterminated(self):
code, out = self.run_pages({"Aetheria/A.md": "---\n---\nx\n"})
self.assertEqual(code, 1, out)
self.assertNotIn("unterminated", out)
self.assertIn("needs `kind", out)
def test_a_lookalike_closing_marker_does_not_end_the_frontmatter(self):
text = "---\nkind: proposal\n----\nstill frontmatter?\n---\nx\n"
code, out = self.run_pages({"Aetheria/A.md": text})
self.assertEqual(code, 1, out)
def test_a_renamed_legacy_page_passes_with_a_notice(self):
def rename(r):
git(r.dir, "mv", "Aetheria/Legacy.md", "Aetheria/Moved.md")
code, out = self.run_pages({}, after=rename)
self.assertEqual(code, 0, out)
self.assertIn("notice", out)
def test_a_page_main_changed_after_the_branch_point_is_not_charged_to_the_pr(self):
# Old.md is a bad canon page that main already holds; the PR merges it in
# and does not touch it, then main edits it again. Two-dot diffing
# would see the PR's copy as modified and fail the PR for main's page.
r = Repo()
r.write("Aetheria/Mine.md", "---\nkind: proposal\n---\nx\n")
r.commit()
git(r.dir, "checkout", "main")
r.write("Aetheria/Old.md", "---\nkind: canon\n---\nv1\n")
git(r.dir, "add", "-A")
git(r.dir, "commit", "-m", "main adds Old")
git(r.dir, "checkout", "pr")
git(r.dir, "merge", "--no-edit", "main")
git(r.dir, "checkout", "main")
r.write("Aetheria/Old.md", "---\nkind: canon\n---\nv2\n")
git(r.dir, "add", "-A")
git(r.dir, "commit", "-m", "main edits Old")
git(r.dir, "checkout", "pr")
code, out = r.check()
self.assertEqual(code, 0, out)
def test_an_unknown_base_ref_fails_loudly_without_a_traceback(self):
r = Repo()
p = subprocess.run(["python3", SCRIPT, "no-such-ref"], cwd=r.dir,
capture_output=True, text=True)
self.assertEqual(p.returncode, 1)
self.assertNotIn("Traceback", p.stdout + p.stderr)
self.assertIn("no-such-ref", p.stdout + p.stderr)
def test_pages_outside_aetheria_are_not_checked(self):
code, out = self.run_pages({"README2.md": "---\nkind: canon\n---\nx\n"})
self.assertEqual(code, 0, out)