Skip to content

fix: consolidate h2 spacing, drop invalid focus border-radius, dynamic versioning, uppercase strategy constants, strengthen cycle/key assertions#39

Draft
Nelson Spence (Fieldnote-Echo) with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-h2-spacing-issue
Draft

fix: consolidate h2 spacing, drop invalid focus border-radius, dynamic versioning, uppercase strategy constants, strengthen cycle/key assertions#39
Nelson Spence (Fieldnote-Echo) with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-h2-spacing-issue

Conversation

Copilot AI commented Apr 22, 2026

Copy link
Copy Markdown

Seven targeted fixes addressing CSS visual-hierarchy bugs, a hardcoded version string, mutable module-level test constants, and incomplete test assertions in walk().

CSS (docs/stylesheets/navi.css)

  • H2 spacing: padding-bottom was 0.75rem and ::after had margin-top: 0.75rem — 1.5rem total gap split across two properties. Consolidated to padding-bottom: 1.5rem + removed margin-top from ::after.
  • :focus-visible: Removed border-radius: 3px — CSS outline does not respect border-radius; the property was silently ignored.

Versioning (src/navi_sanitize/__init__.py)

  • Replaced hardcoded __version__ = "0.2.1" with importlib.metadata lookup; falls back to "0.0.0" on bare source checkouts where package metadata is absent.
try:
    __version__ = importlib_metadata.version("navi-sanitize")
except importlib_metadata.PackageNotFoundError:
    __version__ = "0.0.0"

Tests (tests/test_properties.py)

  • Renamed hostile_text / unicode_text / safe_textHOSTILE_TEXT / UNICODE_TEXT / SAFE_TEXT to signal immutable module-level constants.
  • test_handles_cycle: added full clean() invariant assertions on the leaf value (no null bytes, no invisible chars, no homoglyphs, NFKC-stable).

Tests (tests/test_walk.py)

  • Tuple pass-through: added assert result is not data — verifies walk() returns a new dict even when tuple values are not traversed.
  • Hostile keys: added negative-presence assertions confirming the original hostile keys ("n\u0430me", "\x00key", "inner\u200b") are absent from the result, not just that sanitized keys exist.
Original prompt
Please apply the following diffs and create a pull request.
Once the PR is ready, give it a title based on the messages of the fixes being applied.

[{"message":"The h2 styling creates both a border-bottom and an ::after pseudo-element with separate spacing (padding-bottom: 0.75rem and margin-top: 0.75rem). This creates 1.5rem of total spacing which may not be intentional. Consider consolidating the spacing or clarifying the visual hierarchy to avoid confusion during future modifications.","fixFiles":[{"filePath":"docs/stylesheets/navi.css","diff":"diff --git a/docs/stylesheets/navi.css b/docs/stylesheets/navi.css\n--- a/docs/stylesheets/navi.css\n+++ b/docs/stylesheets/navi.css\n@@ -46,7 +46,7 @@\n /* h2: 2rem + accent underline per brand guide */\n .md-typeset h2 {\n   font-size: 2rem;\n-  padding-bottom: 0.75rem;\n+  padding-bottom: 1.5rem;\n   border-bottom: 1px solid #2a2a2a;\n }\n \n@@ -56,7 +56,6 @@\n   width: 40px;\n   height: 2px;\n   background: #7eb8a8;\n-  margin-top: 0.75rem;\n   opacity: 0.6;\n }\n \n"}]},{"message":"The border-radius property on :focus-visible has no effect on the outline itself. The outline property doesn't respect border-radius in CSS. If rounded focus indicators are needed, consider using a box-shadow approach instead, or remove this property to avoid confusion.","fixFiles":[{"filePath":"docs/stylesheets/navi.css","diff":"diff --git a/docs/stylesheets/navi.css b/docs/stylesheets/navi.css\n--- a/docs/stylesheets/navi.css\n+++ b/docs/stylesheets/navi.css\n@@ -252,7 +252,6 @@\n :focus-visible {\n   outline: 3px solid #7eb8a8;\n   outline-offset: 2px;\n-  border-radius: 3px;\n }\n \n /* --- Footer muted --- */\n"}]},{"message":"The version string is hardcoded and must be manually kept in sync with CHANGELOG.md and pyproject.toml. Consider using a single source of truth for versioning, such as reading from pyproject.toml using importlib.metadata or a version file generated during the build process.","fixFiles":[{"filePath":"src/navi_sanitize/__init__.py","diff":"diff --git a/src/navi_sanitize/__init__.py b/src/navi_sanitize/__init__.py\n--- a/src/navi_sanitize/__init__.py\n+++ b/src/navi_sanitize/__init__.py\n@@ -5,6 +5,7 @@\n \n import logging\n from collections.abc import Callable\n+from importlib import metadata as importlib_metadata\n \n from navi_sanitize._decode import decode_evasion\n from navi_sanitize._pipeline import clean, walk\n@@ -13,7 +14,12 @@\n \n Escaper = Callable[[str], str]\n \n-__version__ = \"0.2.1\"\n+try:\n+    __version__ = importlib_metadata.version(\"navi-sanitize\")\n+except importlib_metadata.PackageNotFoundError:\n+    # Fallback for cases where package metadata is not available (e.g. source checkout)\n+    __version__ = \"0.0.0\"\n+\n __all__ = [\n     \"Escaper\",\n     \"clean\",\n"}]},{"message":"The strategy definitions are module-level variables that could be inadvertently modified. Consider making them constants by using uppercase naming (e.g., HOSTILE_TEXT, UNICODE_TEXT, SAFE_TEXT) or wrapping them in functions to prevent accidental mutation.","fixFiles":[{"filePath":"tests/test_properties.py","diff":"diff --git a/tests/test_properties.py b/tests/test_properties.py\n--- a/tests/test_properties.py\n+++ b/tests/test_properties.py\n@@ -55,9 +55,9 @@\n     \"../../\"\n )\n \n-hostile_text = st.text(alphabet=_HOSTILE_ALPHABET, min_size=0, max_size=200)\n-unicode_text = st.text(min_size=0, max_size=200)\n-safe_text = st.text(\n+HOSTILE_TEXT = st.text(alphabet=_HOSTILE_ALPHABET, min_size=0, max_size=200)\n+UNICODE_TEXT = st.text(min_size=0, max_size=200)\n+SAFE_TEXT = st.text(\n     alphabet=\"abcdefghijklmnopqrstuvwxyz0123456789 .-_\",\n     min_size=0,\n     max_size=100,\n@@ -86,7 +86,7 @@\n \n walk_structure = _nested_structure(\n     st.one_of(\n-        hostile_text,\n+        HOSTILE_TEXT,\n         st.integers(min_value=-1000, max_value=1000),\n         st.none(),\n         st.booleans(),\n"}]},{"message":"This test verifies that cycles are preserved in the output structure, but it doesn't verify that the leaf string 'hello' has been sanitized according to the clean() invariants (no null bytes, no invisible characters, NFKC normalization). Consider adding assertions to check that result['val'] satisfies these invariants.","fixFiles":[{"filePath":"tests/test_properties.py","diff":"diff --git a/tests/test_properties.py b/tests/test_properties.py\n--- a/tests/test_properties.py\n+++ b/tests/test_properties.py\n@@ -220,7 +220,14 @@\n         a: dict[str, object] = {\"val\": \"hello\"}\n         a[\"self\"] = a\n         result = walk(a)\n-        assert result[\"val\"] == \"hello\"\n+        leaf = result[\"val\"]\n+        assert leaf == \"hello\"\n+        # Leaf strings in cyclic structures should still satisfy clean() invariants.\n+        assert \"\\x00\" not in leaf\n+        assert not INVISIBLE_RE.search(leaf)\n+        remaining = set(leaf) & set(HOMOGLYPH_MAP)\n+        assert not remaining, f\"Homoglyph in walk outpu...

…importlib.metadata for version, uppercase strategy constants, and strengthen walk/cycle test assertions

Agent-Logs-Url: https://github.com/Project-Navi/navi-sanitize/sessions/04c15fd9-0f06-4339-8873-5d1581ce868d

Co-authored-by: Fieldnote-Echo <202828230+Fieldnote-Echo@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix h2 styling to consolidate spacing fix: consolidate h2 spacing, drop invalid focus border-radius, dynamic versioning, uppercase strategy constants, strengthen cycle/key assertions Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants