Skip to content

Emit clean frontier from --codemod-plan-out and add script/layer guards to promote_hidden_imports - #642

Merged
trissim merged 2 commits into
mainfrom
feat/plan-out-frontier-and-hidden-import-guards
Nov 28, 2026
Merged

trissim merged 2 commits into
mainfrom
feat/plan-out-frontier-and-hidden-import-guards

Conversation

@trissim

@trissim trissim commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Two high-leverage codemod improvements from Toad bench feedback:

  1. Clean frontier emission for --codemod-plan-out (codemod_runtime.py, cli.py):
    • Added FindingRecipePlan.exportable_plan_document: returns the full document when unblocked, the unique clean trajectory frontier branch (len(branches) == 1 and non-empty), or the proved conflict-free candidate batch (document.has_recipes) when sibling findings have needs_input / needs_operation / conflicts.
    • CodemodSynthesisExecution.run() writes exportable_plan_document to --codemod-plan-out and returns 0 (while still reporting every needs_input / needs_operation sibling in stdout JSON), and still refuses --codemod-apply or empty/ambiguous exports.
  2. promote_hidden_imports script-guard & layer-boundary awareness (declared_root.py, hidden_imports.py):
    • Extended import_runtime_setup_change + _ModuleTopLevelSetupChanges to detect both sys.path and os.environ (os.environ[...] = ..., setdefault/update/pop/clear, os.putenv/unsetenv) at module top level (including inside if __name__ == "__main__":) and inside functions before the import. Live Toad verification: tools/qt_drive.py (25 hidden imports), tools/drive_sweep.py, and tools/physical_ui_remote.py all refuse cleanly naming the exact setup line.
    • Added [tool.nominal-refactor-advisor] forbidden-imports = [{ from = "...", to = "..." | [...] }] (ForbiddenImportEdge, DeclaredRoot.forbidden_imports_for) enforced in both HiddenImportPlan and CompactHiddenImportPlan across direct, transitive scanned, external (top_level_imported_modules), and reverse-importer edges (CrossesForbiddenImportEdge).

Verification

  • Focused tests (tests/test_hidden_imports.py, tests/test_hidden_import_cuts.py, tests/test_type_only_readers.py, tests/test_refactor_advisor.py -k "synthesized_plan or finding_backed_codemod_plan or blocks_unproved_finding_backed_plan or shared_typed_execution_lifecycle") + 72 test_repository_* guards + touched-line NRA self-scan on desktop.

@trissim
trissim merged commit 03b7a9a into main Nov 28, 2026
1 of 10 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