Aller au contenu
login
arrow_backRetour aux issues
Tracer-Cloud/opensre #5505

Move surfaces/shared/terminal/feedback/__init__.py into named modules

ecoDébutant good first issue refactor maintainability

descriptionDescription

## Goal `surfaces/shared/terminal/feedback/` is a package containing exactly one file: a 485-line `__init__.py`. It exposes one public function, `prompt_investigation_feedback`, behind about twenty private ones covering at least five unrelated jobs. A package whose `__init__.py` is the implementation gives a reader no way in except top to bottom. ## What is in it | Functions | Job | | --- | --- | | `_config_dir`, `_feedback_path`, `_prefs_path`, `_is_disabled`, `_set_disabled`, `_store` | where feedback is written and whether it is asked at all | | `_emit_analytics`, `_emit_miss_classified` | analytics events | | `_format_root_cause_lines`, `_root_cause_width`, `_print_context` | rendering the investigation context above the prompt | | `_write_raw`, `_run_select`, `_read_note`, `_pick_rating`, `_pick_taxonomy` | the raw-terminal select widget and prompts | | `_classify_miss` | classifying what the investigation missed | | `_collect`, `prompt_investigation_feedback` | the flow that calls the rest | The ANSI constants `_H`, `_D`, `_R` are single letters for highlight, dim and reset. Give them real names in whichever module they land in. ## Target `__init__.py` re-exports and nothing else; each job above becomes a named module. Only `prompt_investigation_feedback` is public, and both callers import it from `surfaces.shared.terminal.feedback` — that path must keep working. ## Watch out `tests/shared/terminal/test_feedback.py` reaches into the module twice in ways a move breaks silently: 1. It imports five private names directly — `_CHOICES`, `_format_root_cause_lines`, `_print_context`, `_root_cause_width`, `_run_select`. Update those imports to the new modules. 2. It monkeypatches by string path — `"surfaces.shared.terminal.feedback.read_key_unix"` and two siblings. Those names are imported *into* this module and used by `_run_select`. Once `_run_select` lives elsewhere, patching the old path patches a name nothing reads, and the test passes while exercising the real terminal. Repoint each patch at the module that now calls it, and confirm the test still fails if you break the function it covers. ## Acceptance - [ ] `surfaces/shared/terminal/feedback/__init__.py` contains imports and `__all__` only - [ ] `from surfaces.shared.terminal.feedback import prompt_investigation_feedback` still works — both call sites unchanged - [ ] Each new module states its one job in its docstring - [ ] `_H` / `_D` / `_R` renamed to something a reader can guess - [ ] `uv run python -m pytest tests/shared/terminal/test_feedback.py -q` passes, and each repointed monkeypatch was checked as described above - [ ] The prompt still works end to end: run an investigation in `uv run opensre`, reach the feedback prompt, pick a rating and confirm the record lands in the feedback file - [ ] `make lint format typecheck test` ## Out of scope Changing what feedback is collected, the choice list, or the analytics events. This is a move. ## Claiming this issue Ask in [OpenSRE Discord](https://discord.com/invite/opensre) before you start so a maintainer can assign it. Ask OpenSRE maintainers and write a commit under this issue.
codeOuvre sur GitHub