From 2852785134c191a33c64605321e6331ad75a1b65 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Mon, 29 Jun 2026 18:33:50 -0400 Subject: [PATCH] artifacts --- .../phase4_audit.py | 40 +++++++++++++++++++ .../phase4_audit_patterns.py | 29 ++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 scripts/tier2/artifacts/default_layout_install_20260629/phase4_audit.py create mode 100644 scripts/tier2/artifacts/default_layout_install_20260629/phase4_audit_patterns.py diff --git a/scripts/tier2/artifacts/default_layout_install_20260629/phase4_audit.py b/scripts/tier2/artifacts/default_layout_install_20260629/phase4_audit.py new file mode 100644 index 00000000..fee4e75f --- /dev/null +++ b/scripts/tier2/artifacts/default_layout_install_20260629/phase4_audit.py @@ -0,0 +1,40 @@ +"""Refined Phase 4 VC checks per spec metadata.json.""" +import re +import sys +from pathlib import Path + +src_root = Path("src") +test_artifact_hits = [] +ini_file_hits = [] + +# VC_no_production_path_to_test_fixtures: the literal string "tests/artifacts" +# in source code (not in comments). The spec marks the prior false positive at +# src/commands.py:371 (the line we just removed). Allow comments. +def _is_comment(line: str) -> bool: + s = line.strip() + if s.startswith("#"): + return True + return False + +for py_file in src_root.rglob("*.py"): + try: + text = py_file.read_text(encoding="utf-8", errors="replace") + except OSError: + continue + for line_no, line in enumerate(text.splitlines(), 1): + if "tests/artifacts" in line and not _is_comment(line): + test_artifact_hits.append((py_file, line_no, line.strip())) + +# VC_no_configs_in_src: any file with .ini extension inside src/. +for ini_file in src_root.rglob("*.ini"): + ini_file_hits.append(ini_file) + +print(f"VC_no_production_path_to_test_fixtures:") +print(f" code-line hits: {len(test_artifact_hits)}") +for p, line_no, line in test_artifact_hits[:5]: + print(f" {p}:{line_no}: {line}") +print(f"VC_no_configs_in_src:") +print(f" .ini files in src/: {len(ini_file_hits)}") +for p in ini_file_hits[:5]: + print(f" {p}") +sys.exit(0 if (not test_artifact_hits and not ini_file_hits) else 1) diff --git a/scripts/tier2/artifacts/default_layout_install_20260629/phase4_audit_patterns.py b/scripts/tier2/artifacts/default_layout_install_20260629/phase4_audit_patterns.py new file mode 100644 index 00000000..339ec194 --- /dev/null +++ b/scripts/tier2/artifacts/default_layout_install_20260629/phase4_audit_patterns.py @@ -0,0 +1,29 @@ +"""Banned patterns audit on changed files.""" +import re +from pathlib import Path + +files = [ + "src/layouts.py", + "src/commands.py", + "src/gui_2.py", + "src/paths.py", + "tests/test_default_layout_install.py", + "tests/test_reset_layout.py", +] + +patterns = [ + ("dict[str, Any]", r'dict\[str, Any\]'), + ("bare Any param", r': Any[)\\, ]'), + ("Optional[T] ret", r'-> Optional'), + ("hasattr(x, str)", r"hasattr\(\w+, '\\x27"), + (".get('key', ..)", r"\.get\('\w"), +] + +for f in files: + try: + text = Path(f).read_text(encoding="utf-8", errors="replace") + except OSError as e: + print(f"{f}: open error {e}") + continue + counts = {label: len(re.findall(pat, text)) for label, pat in patterns} + print(f"{f}: " + ", ".join(f"{k}={v}" for k, v in counts.items()))