Skip to content

PR B: remove patch-safe audit dead code - #168

Merged
ohjonathan merged 1 commit into
mainfrom
codex/audit-tail-dead-code
Jul 14, 2026
Merged

ohjonathan merged 1 commit into
mainfrom
codex/audit-tail-dead-code

Conversation

@ohjonathan

Copy link
Copy Markdown
Owner

Summary

Implements the nine patch-safe PR B findings from #149 on fresh main@d6eca479d5c5d71b2335e3ee2abad4f8d2651e3e. The governing gate was applied to every target: zero package call sites was accepted only after checking package initializers, __all__, re-exports, supported docs, and whole-tree consumers.

The breaking D5b-dead-code-3 removal is not included. This PR retains the 11-name legacy compatibility surface for Ontos 5.x, adds callable DeprecationWarning guidance naming v6.0.0, and keeps PROJECT_ROOT warning-free at import. The audit's original 12-name count included live, supported resolve_config.

Finding-by-finding public-surface checks

  • D5b-dead-code-2: _templates had no initializer/__all__ re-export, supported-doc import, or live consumer; removed the private package and package data.
  • D5b-dead-code-6: ontos.io did not export obsidian; its only live import was the orphan test; removed it and moved BOM/leading-whitespace coverage to canonical load_document.
  • D5b-dead-code-8: the three zero-call wrappers had no initializer/__all__/doc exposure; the two command shims were undocumented internal aliases covered by the maintainer assumption; removed them and repointed tests to canonical core imports.
  • D5b-dead-code-9: _create_directories was private, unexported, undocumented, and uncalled; removed it while retaining the rollback-aware initializer.
  • D5b-dead-code-10: all six helpers were absent from package exports and supported docs; scanner's alias was explicitly outside __all__; removed all six after whole-tree consumer checks.
  • D3b-structure-7: _cmd_export was private and absent from parser/registry dispatch; removed it and added a regression proving bare ontos export still selects _cmd_export_deprecated and creates CLAUDE.md.
  • D7-cli-consistency-9: message-only, no import surface; removed the expired v3.4 promise and replaced ontos_init.py remediation with current CLI/Path guidance.
  • D5a-repo-redundancy-3: _hooks was private, unexported, and unused; live installed hooks are generated shims that call ontos hook; removed the private package and package data.
  • D5a-repo-redundancy-6: repository backups are not package API; deleted exactly 11 tracked .bak files.
  • D5b-dead-code-3 (deprecation only, still open): ten functions are re-exported from both ontos and ontos.core, and PROJECT_ROOT remains a direct compatibility import. All 11 stay importable/working; removal remains v6.0.0.

Verification

  • 219 focused regressions passed.
  • Full suite: 1,585 passed; the approved WAL/SHM flake did not reproduce.
  • Exact doctor exit-code regression passed.
  • Ontos map and activation: zero errors/warnings; link-check clean; doctor has only the two pre-existing environment warnings (non-Ontos repository hooks and stale PATH ontos), with no new warning and agents freshness green.
  • Wheel and sdist built and inspected; neither ships _templates, _hooks, io/obsidian.py, or backups.
  • Fresh non-editable wheel install with declared dependencies passed imports, version, removed-module, export, and hook CLI smoke tests outside the checkout.
  • llm-dev manifest, schema, review-seat, scope, cardinality, branch, and staging checks passed.
  • Whole-tree orphan-import/dead-definition scans, compileall, git diff --check, commit hooks, and clean-worktree checks passed.

Bookkeeping and release hold

The O4 ledger records PR A #167 merged at d6eca47: current main is 15/33 addressed with 18 remaining. This PR implements B=9 for review but does not count them landed before merge. After a verified merge, 9 remain (C=4, D=4, E=1).

Package metadata remains 5.0.0 on this branch. Versioning, merge, tags, PyPI, releases, and issue closure remain maintainer-owned. Do not start PR C until this PR merges and is independently verified.

Refs #149.

Copy link
Copy Markdown
Owner Author

Final Codex verification receipt for head feb65a418e7a30771617ded50b4ddb074a2d5143:

  • GitHub CI: 6/6 green — Python 3.9, 3.10, 3.11, 3.12, v5-release-gates, and test-non-editable.
  • Local full suite: 1,585 passed; approved WAL/SHM flake did not reproduce.
  • Focused PR B suite: 219 passed.
  • Wheel/sdist inspection and fresh non-editable wheel install passed; retired private packages/module/backups are absent.
  • Ontos map/activate: zero errors or warnings; link-check clean. Doctor has only the two baseline environment warnings and reports activation/agents health clean.
  • llm-dev manifest/schema/review-seat/scope/cardinality/branch/staging checks passed.
  • Whole-tree orphan-import/dead-definition scans, compileall, git diff --check, and commit/push hooks passed.

No release action was performed. D5b-dead-code-3 remains open and import-compatible pending v6.0.0 removal. Awaiting maintainer/Claude independent review and merge; PR C has not started.

@ohjonathan

Copy link
Copy Markdown
Owner Author

PR B review — Claude — approve to merge (no blockers, no majors)

Verified independently in a worktree at the PR head (feb65a4) with a real venv + wheel build. A dead-code sweep is where breaking changes hide, so I re-derived every per-finding public-surface claim rather than trust the report.

The load-bearing check — nothing breaking snuck into a patch

  • No public API was removed. Diffed paths.py's public names base (d6eca47) vs head: every symbol present at base is still importable at head — the change is purely additive (deprecation wrappers + private helpers). Deprecate-only, correct for a patch.
  • Every removed helper/module is genuinely unreachable. For all 11 removed names (_cmd_export, the six D5b-dead-code-10 helpers, the command wrappers) I ran an exact-token grep across the whole head tree — zero references, static or string/dynamic dispatch. The live _cmd_export_deprecated/_data/_claude handlers that merely share a prefix all remain.
  • The paths.py deprecation is real and correctly isolated. External callers get a DeprecationWarning naming v6.0.0 (verified get_logs_dir() fires); PROJECT_ROOT, resolve_project_root, resolve_config stay warning-free; and import ontos + ontos map/activate/doctor all run clean under -W error::DeprecationWarning — no internal caller trips a warning, thanks to the private _get_logs_dir worker that internal code uses instead of the public warn-path.

Everything else held up

  • ontos export claude still writes CLAUDE.md; export data dispatches (D3b-structure-7 clean).
  • Built the wheel and inspected it: no _templates/_hooks/obsidian entries — packaging correctly updated; test-non-editable green.
  • The obsidian BOM coverage genuinely moved to the canonical loader (io.files.load_document, the wired-in scanning path) — a real improvement, not a hollow "moved."
  • Activation tripwire (test_doctor_phase4 … passed == 12) green; 159 focused + the new test_paths_v2_deprecation.py pass; full suite 1,585 green (no WAL flake this run); CI 6/6 including 3.12.
  • Ledger + [P1-containing] v5.0.1 patch-safe sweep + v6.0.0 path compatibility removal #149 reconciled honestly — PR A's 7 findings + D5a-repo-redundancy-7 checked off (attributed to PR A: align v5 docs and generated instructions #167/d6eca47), PR B's 9 marked implemented with candid "merge/verification pending" notes, and D5b-dead-code-3 explicitly held unchecked for v6.0.0.

One judgment call, surfaced not buried

The four removed command wrappers (export_claude_command, migrate_convenience_command, migration_report_command, verify_document) are the only non-underscore module-level functions deleted — technically importable from ontos.commands.* by a determined external user. They're not re-exported, not documented, and have zero references, so the audit's "unsupported internal aliases" classification holds and removal-in-patch is defensible. Noting it as the single non-underscore-private removal; not a blocker.

Verdict: the cleanest sweep PR yet — no blockers, no majors, ready to merge as a v5.0.1-track patch. Release actions remain maintainer-deferred.

@ohjonathan
ohjonathan marked this pull request as ready for review July 14, 2026 05:34
@ohjonathan
ohjonathan merged commit f2ed48d into main Jul 14, 2026
6 checks passed
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.

1 participant