Private
Public Access
0
0

feat(audit): MVP output - AUDIT_REPORT.md only, move stale to _stale/

MVP pipeline simplification:
- render_rollups() now produces ONLY summary.md + AUDIT_REPORT.md
- run_audit() now produces only per-aggregate .md (no .dsl/.tree)
- New src/code_path_audit_gen.py generates the single coherent report

Stale artifacts moved to _stale/ subdirectory (preserved for history):
- 13 per-aggregate .dsl files (redundant with .md)
- 13 per-aggregate .tree files (redundant with .md)
- 9 old top-level rollups (cross_audit_summary, decomposition_matrix,
  candidates, field_usage, call_graph, hot_paths, dead_fields,
  ssdl_analysis, organization_deductions - all superseded by sections
  inlined in AUDIT_REPORT.md)
- _stale/README.md explains what happened

Meta-audit updated to check .md files (14 required H2 sections per
aggregate) instead of .dsl files. 0 violations on 10 real profiles.

Tests: 131 passing. New MVP report: 5000+ lines.
This commit is contained in:
2026-06-22 13:34:29 -04:00
parent f7f616abb9
commit 0b79798eaf
51 changed files with 8111 additions and 10818 deletions
+32 -76
View File
@@ -1255,95 +1255,51 @@ def run_audit(
output_paths: dict[str, str] = {}
for profile in profiles:
agg_dir = output_dir_p / "aggregates"
dsl_path = agg_dir / f"{profile.name}.dsl"
md_path = agg_dir / f"{profile.name}.md"
tree_path = agg_dir / f"{profile.name}.tree"
dsl_path.write_text(to_dsl_v2(profile, generated_date=date), encoding="utf-8")
from src.code_path_audit_render import render_full_markdown
md_path.write_text(render_full_markdown(profile), encoding="utf-8")
tree_path.write_text(to_tree(profile), encoding="utf-8")
output_paths[profile.name] = str(dsl_path)
output_paths[profile.name] = str(md_path)
return Result(data=AuditSummary(aggregate_profiles=tuple(profiles), output_paths=output_paths))
def render_rollups(summary: AuditSummary, output_dir: Path) -> dict[str, str]:
"""Render the 4 top-level rollup files."""
"""Render the MVP audit output: AUDIT_REPORT.md (single comprehensive document).
This replaces the previous 10-rollup design. AUDIT_REPORT.md embeds
all the per-aggregate detail + SSDL analysis + organization deductions
+ cross-audit summary + decomposition matrix in one file.
Also writes a tiny summary.md as a TOC pointer to AUDIT_REPORT.md.
"""
output_dir.mkdir(parents=True, exist_ok=True)
summary_path = output_dir / "summary.md"
cross_audit_path = output_dir / "cross_audit_summary.md"
decomposition_matrix_path = output_dir / "decomposition_matrix.md"
candidates_path = output_dir / "candidates.md"
profiles = summary.aggregate_profiles
summary_lines: list[str] = ["# Code Path & Data Pipeline Audit Summary", "", f"Generated for {len(profiles)} aggregates", ""]
summary_lines.append("## 4-mem-dim rollup")
summary_lines.append("")
by_dim: dict[str, list[str]] = {}
summary_path = output_dir / "summary.md"
summary_lines: list[str] = [
"# Code Path Audit - TOC",
"",
f"Generated for {len(profiles)} aggregates on {date_mod.today().isoformat()}",
"",
"**Read [AUDIT_REPORT.md](AUDIT_REPORT.md) for the full audit.**",
"",
"## Per-aggregate profiles",
"",
]
for p in profiles:
by_dim.setdefault(p.memory_dim, []).append(p.name)
for dim, names in sorted(by_dim.items()):
summary_lines.append(f"- **{dim}** ({len(names)}): {', '.join(names)}")
summary_lines.append("")
summary_lines.append("## Cross-validation verdict")
summary_lines.append("")
for p in profiles:
rc = p.result_coverage
tac = p.type_alias_coverage
summary_lines.append(f"- **{p.name}**: result_coverage={rc.summary}; type_alias_coverage={tac.summary}")
summary_lines.append(f"- `{p.name}.md` - {p.aggregate_kind}, {p.memory_dim}-dim, {p.access_pattern}, {len(p.producers)} producers / {len(p.consumers)} consumers")
summary_path.write_text("\n".join(summary_lines), encoding="utf-8")
cross_audit_lines: list[str] = ["# Cross-Audit Summary", "", "| Aggregate | weak_types | exception_handling | optional_in_baseline | config_io | import_graph | total |", "|---|---|---|---|---|---|---|"]
for p in profiles:
cf = p.cross_audit_findings
total = len(cf.weak_types) + len(cf.exception_handling) + len(cf.optional_in_baseline) + len(cf.config_io_ownership) + len(cf.import_graph)
cross_audit_lines.append(f"| {p.name} | {len(cf.weak_types)} | {len(cf.exception_handling)} | {len(cf.optional_in_baseline)} | {len(cf.config_io_ownership)} | {len(cf.import_graph)} | {total} |")
cross_audit_path.write_text("\n".join(cross_audit_lines), encoding="utf-8")
deco_lines: list[str] = ["# Decomposition Matrix", "", "## Top 10 candidates by estimated savings", "", "| Rank | Aggregate | Direction | Est. savings (us) | Frequency | Effort | Priority |", "|---|---|---|---|---|---|---|"]
candidates_with_direction = [(p, p.decomposition_cost.componentize_savings + p.decomposition_cost.unify_savings, p.frequency, "n/a", "n/a") for p in profiles if p.decomposition_cost.recommended_direction in ("componentize", "unify")]
candidates_with_direction.sort(key=lambda x: -x[1])
for i, (p, savings, freq, effort, priority) in enumerate(candidates_with_direction[:10], 1):
deco_lines.append(f"| {i} | {p.name} | {p.decomposition_cost.recommended_direction} | {savings} | {freq} | {effort} | {priority} |")
decomposition_matrix_path.write_text("\n".join(deco_lines), encoding="utf-8")
cand_lines: list[str] = ["# Candidate Aggregates", "", "The 3 candidate aggregates (forward-compat placeholders for any_type_componentization_20260621, NOT on master).", ""]
for p in profiles:
if p.is_candidate:
cand_lines.append(f"- **{p.name}**: candidate; would be detected after any_type_componentization_20260621 merges")
candidates_path.write_text("\n".join(cand_lines), encoding="utf-8")
from src.code_path_audit_render import render_field_usage_rollup, render_call_graph_rollup
from src.code_path_audit_rollups import (
render_decomposition_matrix_rich,
render_summary_rich,
render_candidates_rich,
render_hot_path_rollup,
render_dead_field_rollup,
from src.code_path_audit_gen import generate_audit_report
audit_report_path = output_dir / "AUDIT_REPORT.md"
audit_report_text = generate_audit_report(
profiles=profiles,
output_dir=output_dir,
date=date_mod.today().isoformat(),
)
from src.code_path_audit_ssdl import (
render_ssdl_rollup,
render_organization_deductions,
)
field_usage_path = output_dir / "field_usage.md"
field_usage_path.write_text(render_field_usage_rollup(profiles), encoding="utf-8")
call_graph_path = output_dir / "call_graph.md"
call_graph_path.write_text(render_call_graph_rollup(profiles), encoding="utf-8")
hot_path_path = output_dir / "hot_paths.md"
hot_path_path.write_text(render_hot_path_rollup(profiles), encoding="utf-8")
dead_field_path = output_dir / "dead_fields.md"
dead_field_path.write_text(render_dead_field_rollup(profiles), encoding="utf-8")
summary_path.write_text(render_summary_rich(profiles), encoding="utf-8")
decomposition_matrix_path.write_text(render_decomposition_matrix_rich(profiles), encoding="utf-8")
candidates_path.write_text(render_candidates_rich(profiles), encoding="utf-8")
ssdl_path = output_dir / "ssdl_analysis.md"
ssdl_path.write_text(render_ssdl_rollup(profiles, "src"), encoding="utf-8")
org_path = output_dir / "organization_deductions.md"
org_path.write_text(render_organization_deductions(profiles, "src"), encoding="utf-8")
audit_report_path.write_text(audit_report_text, encoding="utf-8")
return {
"summary.md": str(summary_path),
"cross_audit_summary.md": str(cross_audit_path),
"decomposition_matrix.md": str(decomposition_matrix_path),
"candidates.md": str(candidates_path),
"field_usage.md": str(field_usage_path),
"call_graph.md": str(call_graph_path),
"hot_paths.md": str(hot_path_path),
"dead_fields.md": str(dead_field_path),
"ssdl_analysis.md": str(ssdl_path),
"organization_deductions.md": str(org_path),
"AUDIT_REPORT.md": str(audit_report_path),
}
def code_path_audit_v2(