Private
Public Access
0
0
Files
manual_slop/scripts/tier2/artifacts/cruft_elimination_20260627/debug_regex.py
T
ed 2a76889341 conductor(cruft_elimination): Phase 0 setup + baseline + styleguide ack
TIER-2 READ all 11 mandatory pre-flight files before <cruft_elimination_20260627>:
  1. AGENTS.md
  2. conductor/workflow.md
  3. conductor/edit_workflow.md
  4. conductor/tier2/githooks/forbidden-files.txt
  5. conductor/tracks/tier2_leak_prevention_20260620/spec.md
  6. conductor/product-guidelines.md (Core Value section)
  7. conductor/code_styleguides/data_oriented_design.md (DOD + \u00a78.5)
  8. conductor/code_styleguides/python.md (\u00a717 Banned Patterns)
  9. conductor/code_styleguides/type_aliases.md
  10. conductor/code_styleguides/error_handling.md
  11. docs/guide_meta_boundary.md
Also read: agent_memory_dimensions.md, rag_integration_discipline.md,
cache_friendly_context.md, knowledge_artifacts.md, feature_flags.md,
workspace_paths.md, config_state_owner.md

Phase 0 baseline (measured 2026-06-27, master 88a1bdcb):
- Metadata: TypeAlias = dict[str, Any] at src/type_aliases.py:6 (Phase 1 target)
- hasattr(f, 'path') sites: 29 (gui_2.py:18, app_controller.py:10, aggregate.py:1)
- -> Optional[T] returns: 30 across 14 files
- Any params: 59
- dict[str, Any] params: 10
- Metadata params: 51
- All 7 audit gates pass --strict
- 17/18 per-aggregate dataclasses have from_dict() (NormalizedResponse is
  an output type, not wire-boundary; doesn't need from_dict)

Branch: tier2/cruft_elimination_20260627 (from origin/master @ 88a1bdcb)
2026-06-26 04:17:55 -04:00

38 lines
1.6 KiB
Python

"""Debug the optional returns regex - try multiple approaches."""
import subprocess
import os
from pathlib import Path
REPO = Path(r"C:\projects\manual_slop_tier2")
env = os.environ.copy()
env["GIT_PAGER"] = "cat"
# Approach A: use -e flag to separate pattern
cmd = ["git", "grep", "-nE", "-e", r"-> Optional\[", "--", "src/*.py"]
r = subprocess.run(cmd, cwd=str(REPO), capture_output=True, text=True, encoding="utf-8", env=env)
print(f"Approach A (-e flag): rc={r.returncode}")
print(f" stdout: {r.stdout[:300]!r}")
print(f" stderr: {r.stderr[:300]!r}")
# Approach B: write pattern to file
import tempfile
with tempfile.NamedTemporaryFile(mode="w", suffix=".txt", delete=False, encoding="utf-8") as f:
f.write(r"-> Optional\[")
pattern_file = f.name
cmd = ["git", "grep", "-nE", "-f", pattern_file, "--", "src/*.py"]
r = subprocess.run(cmd, cwd=str(REPO), capture_output=True, text=True, encoding="utf-8", env=env)
print(f"\nApproach B (-f file): rc={r.returncode}")
print(f" stdout: {r.stdout[:300]!r}")
# Approach C: use plain grep via PowerShell
import subprocess as sp
ps_cmd = 'git grep -nE "-> Optional\\[" -- src/*.py 2>&1'
r = sp.run(["powershell", "-Command", ps_cmd], cwd=str(REPO), capture_output=True, text=True, encoding="utf-8")
print(f"\nApproach C (powershell): rc={r.returncode}")
print(f" stdout: {r.stdout[:300]!r}")
# Approach D: use shell=True with the proper escaping
r = subprocess.run('git grep -nE "-> Optional\\[" -- src/*.py', cwd=str(REPO), shell=True, capture_output=True, text=True, encoding="utf-8", env=env)
print(f"\nApproach D (shell=True): rc={r.returncode}")
print(f" stdout: {r.stdout[:300]!r}")