|
| 1 | +# Improvement Roadmap Execution Plan |
| 2 | + |
| 3 | +This document converts the roadmap checklist into a prioritized, dependency-aware |
| 4 | +execution plan based on the current repository state. |
| 5 | + |
| 6 | +## Current Technical Baseline |
| 7 | + |
| 8 | +The roadmap should build on the repository as it exists today rather than |
| 9 | +restart work that is already partially done. |
| 10 | + |
| 11 | +- **Package layout is already modular.** The main public library entry points are |
| 12 | + `py_moodle.MoodleSession`, `py_moodle.MoodleSessionError`, |
| 13 | + `py_moodle.Settings`, and `py_moodle.load_settings` |
| 14 | + (`src/py_moodle/__init__.py`). The largest and most central modules are |
| 15 | + `src/py_moodle/module.py`, `src/py_moodle/course.py`, `src/py_moodle/auth.py`, |
| 16 | + and `src/py_moodle/compat.py`. |
| 17 | +- **The CLI already has a clear command structure.** `src/py_moodle/cli/app.py` |
| 18 | + registers Typer sub-apps for courses, categories, sections, modules, users, |
| 19 | + admin, folders, pages, resources, URLs, and site info. |
| 20 | +- **Tests already have an initial layer split.** `tests/unit/` contains the fast |
| 21 | + smoke tests, while the rest of the suite is automatically marked as |
| 22 | + integration and skipped unless `--integration` is used (`tests/conftest.py`). |
| 23 | +- **CI already covers the supported Python versions.** The unit test matrix in |
| 24 | + `.github/workflows/ci.yml` runs on Python 3.8 through 3.13, and integration |
| 25 | + coverage spans Moodle 4.5.5 and 5.0.1. |
| 26 | +- **Version-sensitive parsing already has a foothold.** |
| 27 | + `src/py_moodle/compat.py` centralizes Moodle-version detection and selector |
| 28 | + strategies, and session bootstrap wires compatibility state into login flows. |
| 29 | +- **Documentation already has a contributor home.** MkDocs builds from `docs/`, |
| 30 | + with `docs/development.md` acting as the main contributor guide. |
| 31 | + |
| 32 | +### Priority Risk Areas |
| 33 | + |
| 34 | +The highest-value next changes are the ones that improve safety and |
| 35 | +maintainability without forcing broad refactors. |
| 36 | + |
| 37 | +1. **CLI output remains mostly human-first.** Commands generally expose a |
| 38 | + `--json` flag, but there is no unified `--output` contract, no YAML mode, and |
| 39 | + no field filtering for scripting workflows. |
| 40 | +2. **Timeouts are hardcoded and inconsistent.** HTTP operations use several |
| 41 | + different timeout values across modules instead of a centralized policy. |
| 42 | +3. **Retry behavior is effectively absent.** Transient network failures are |
| 43 | + mostly surfaced immediately. |
| 44 | +4. **Logging and debugging are still ad hoc.** There is no project-wide logging |
| 45 | + strategy, and the current debug behavior is not yet a redacted tracing |
| 46 | + system. |
| 47 | +5. **Dict-heavy boundaries are still concentrated in core flows.** |
| 48 | + `course.py`, `module.py`, `upload.py`, and `draftfile.py` still exchange |
| 49 | + large `dict[str, Any]` payloads and return values. |
| 50 | +6. **The module architecture still has extension cost.** The repository already |
| 51 | + supports several Moodle module types, but the registration and dispatch story |
| 52 | + is still implicit. |
| 53 | + |
| 54 | +## Prioritized Execution Plan |
| 55 | + |
| 56 | +The sequence below starts with the smallest changes that reduce risk and unlock |
| 57 | +later work. |
| 58 | + |
| 59 | +### Phase A: Lock in the baseline and smooth contributor workflows |
| 60 | + |
| 61 | +- **Subtask 1: Publish the technical baseline and roadmap plan.** |
| 62 | + - Deliverable: this document. |
| 63 | + - Why first: every later PR can reference shared assumptions instead of |
| 64 | + repeating the same audit. |
| 65 | +- **Subtask 2: Keep CI coverage aligned with the declared support policy.** |
| 66 | + - This is effectively complete in CI today and should now be maintained rather |
| 67 | + than redesigned. |
| 68 | +- **Subtask 3: Finish documenting the test layers.** |
| 69 | + - The unit vs. integration split is partially complete in the test layout and |
| 70 | + should be finished by documenting how to run each layer and by clearly |
| 71 | + identifying brittle HTML fixtures when they are introduced. |
| 72 | +- **Subtask 25: Add HTML fixture regression coverage for fragile parsing.** |
| 73 | + - This gives later compatibility and logging changes a safer landing zone. |
| 74 | +- **Subtask 10: Expand task-oriented documentation recipes.** |
| 75 | + - This can proceed in parallel with other foundation work once the baseline is |
| 76 | + published. |
| 77 | + |
| 78 | +### Phase B: Improve CLI ergonomics before deeper refactors |
| 79 | + |
| 80 | +- **Subtask 4: Add structured CLI output formats (`table`, `json`, `yaml`).** |
| 81 | + - This is a small, high-value improvement for automation users. |
| 82 | + - It also creates a stable output contract needed for later field filtering. |
| 83 | +- **Subtask 5: Add field filtering for machine-readable output.** |
| 84 | + - Build directly on the structured output work. |
| 85 | +- **Subtask 34: Improve CLI help text and option consistency.** |
| 86 | + - Best done after the output contract is settled so wording stays stable. |
| 87 | +- **Subtask 35: Standardize exit codes and batch summaries.** |
| 88 | + - Build on the CLI help cleanup. |
| 89 | +- **Subtask 36: Evaluate shell completion after the command surface is stable.** |
| 90 | + |
| 91 | +### Phase C: Improve reliability and observability |
| 92 | + |
| 93 | +- **Subtask 6: Improve exception wording and troubleshooting guidance.** |
| 94 | + - This is the safest first slice because it does not need architecture |
| 95 | + changes. |
| 96 | +- **Subtask 7: Add a redacted debug mode for HTTP and parsing flows.** |
| 97 | + - Build on the exception and wording cleanup so messages stay consistent. |
| 98 | +- **Subtask 8: Centralize timeout configuration.** |
| 99 | + - Introduce one config surface before adding retry behavior. |
| 100 | +- **Subtask 9: Add safe retry support with backoff for read paths.** |
| 101 | + - Limit the first pass to idempotent operations and clearly document scope. |
| 102 | + |
| 103 | +### Phase D: Improve API quality incrementally |
| 104 | + |
| 105 | +- **Subtask 11: Write the typed model migration note.** |
| 106 | + - Decide the public boundary between `TypedDict`, dataclasses, and backward |
| 107 | + compatibility adapters. |
| 108 | +- **Subtask 12: Introduce typed `Course` and `Section` models.** |
| 109 | + - These are the most central entities and touch both CLI and library usage. |
| 110 | +- **Subtask 13: Add typed `User`, `Module`, and `UploadResult` models.** |
| 111 | +- **Subtask 14: Ship `py.typed` only after the initial typed surface is real.** |
| 112 | +- **Subtask 17: Design the ensure-style API semantics.** |
| 113 | +- **Subtask 18: Implement `ensure_section`.** |
| 114 | +- **Subtask 19: Implement `ensure_label` and `ensure_resource`.** |
| 115 | +- **Subtask 20: Implement `ensure_folder` and `create_or_update_course`.** |
| 116 | + |
| 117 | +### Phase E: Continue compatibility and backend hardening |
| 118 | + |
| 119 | +- **Subtask 21: Keep the version-sensitive flow audit current.** |
| 120 | + - The compatibility layer already exists, so the next work should focus on |
| 121 | + documenting remaining fragile flows and filling test gaps. |
| 122 | +- **Subtask 22: Keep version detection centralized during session initialization.** |
| 123 | + - This is already partially implemented and should be extended, not |
| 124 | + restarted. |
| 125 | +- **Subtask 23: Document the compatibility-layer contribution model.** |
| 126 | +- **Subtask 24: Migrate one additional fragile scraping flow at a time.** |
| 127 | +- **Subtask 25: Expand HTML fixture-based regression tests alongside each migration.** |
| 128 | +- **Subtask 26: Audit current webservice usage and backend candidates.** |
| 129 | +- **Subtask 27: Design a hybrid backend selection strategy.** |
| 130 | +- **Subtask 28: Implement one high-value operation with transparent backend |
| 131 | + fallback.** |
| 132 | + |
| 133 | +### Phase F: Make extension and feature work cheaper |
| 134 | + |
| 135 | +- **Subtask 29: Audit the current module/resource architecture with concrete |
| 136 | + extension pain points.** |
| 137 | +- **Subtask 30: Design a minimal module registration system.** |
| 138 | +- **Subtask 31: Migrate one or two existing modules through the new registration |
| 139 | + path.** |
| 140 | +- **Subtask 32: Pick the next high-value feature slice only after the extension |
| 141 | + model is clearer.** |
| 142 | +- **Subtask 33: Implement that single feature slice cleanly.** |
| 143 | + |
| 144 | +### Phase G: Finish with low-risk polish |
| 145 | + |
| 146 | +- **Subtask 15: Add dry-run support to the highest-risk mutating commands.** |
| 147 | +- **Subtask 16: Add confirmations and `--yes` bypass for destructive |
| 148 | + operations.** |
| 149 | +- **Subtask 37: Review packaging and tooling coherence.** |
| 150 | +- **Subtask 38: Apply the minimal packaging/tooling cleanup plan.** |
| 151 | + |
| 152 | +## Dependency-Aware Subtask Tree |
| 153 | + |
| 154 | +The tree below groups the checklist into workstreams and shows the main blocking |
| 155 | +relationships. Items marked as **already landed** or **partially landed** should |
| 156 | +be extended instead of reimplemented. |
| 157 | + |
| 158 | +- **Baseline and contributor workflow** |
| 159 | + - **1. Technical baseline audit** → foundation for 3, 4, 6, 8, 10, 15, 21, 26, |
| 160 | + 29, 34, 37 |
| 161 | + - **2. CI Python matrix** (**already landed**) |
| 162 | + - **3. Test layering** (**partially landed**) → supports 25 |
| 163 | + - **10. Documentation recipes** |
| 164 | +- **CLI ergonomics** |
| 165 | + - **4. Structured output** → **5. Field filtering** |
| 166 | + - **34. CLI help consistency** → **35. Exit codes and summaries**, |
| 167 | + **36. Shell completion** |
| 168 | +- **Reliability and observability** |
| 169 | + - **6. Exception clarity** → **7. Debug mode** |
| 170 | + - **8. Configurable timeouts** → **9. Safe retry support** |
| 171 | +- **Typed API and idempotent operations** |
| 172 | + - **11. Typed model migration note** |
| 173 | + - **12. Course and Section models** |
| 174 | + - **13. User, Module, UploadResult models** |
| 175 | + - **14. `py.typed` packaging** |
| 176 | + - **17. Ensure API design** |
| 177 | + - **18. `ensure_section`** |
| 178 | + - **19. `ensure_label` and `ensure_resource`** |
| 179 | + - **20. `ensure_folder` and `create_or_update_course`** |
| 180 | +- **Compatibility and backend strategy** |
| 181 | + - **21. Moodle-version-sensitive audit** (**partially landed**) |
| 182 | + - **22. Version detection during session init** (**partially landed**) |
| 183 | + - **23. Compatibility-layer design** (**partially landed**) |
| 184 | + - **24. First migrated fragile flow** (**partially landed**) |
| 185 | + - **25. HTML fixture regression tests** |
| 186 | + - **26. Webservice usage audit** |
| 187 | + - **27. Backend selection strategy** |
| 188 | + - **28. First hybrid backend implementation** |
| 189 | +- **Module architecture and feature expansion** |
| 190 | + - **29. Module/resource architecture audit** |
| 191 | + - **30. Plugin-friendly registration system** |
| 192 | + - **31. Migrate one or two existing modules** |
| 193 | + - **32. Select next feature slice** |
| 194 | + - **33. Implement selected capability** |
| 195 | +- **Safety and polish** |
| 196 | + - **15. Dry-run support** |
| 197 | + - **16. Confirmation prompts and `--yes` bypass** |
| 198 | + - **34. CLI help consistency** |
| 199 | + - **35. Exit codes and summaries** |
| 200 | + - **36. Shell completion** |
| 201 | + - **37. Packaging/tooling coherence review** |
| 202 | + - **38. Packaging/tooling cleanup** |
| 203 | + - **10. Documentation recipes** |
| 204 | + |
| 205 | +## Proposed Sequence of Small PRs |
| 206 | + |
| 207 | +The PR sequence below favors narrow scope, clear validation, and reusable |
| 208 | +foundations. |
| 209 | + |
| 210 | +| PR | Scope | Why this order | |
| 211 | +| --- | --- | --- | |
| 212 | +| 1 | Publish the technical baseline and roadmap execution plan | Gives every later PR a shared reference point | |
| 213 | +| 2 | Finish documenting test layers and contributor test commands | Small change, reduces onboarding friction immediately | |
| 214 | +| 3 | Add HTML fixture scaffolding for brittle parsing tests | Strengthens safety before more compatibility work | |
| 215 | +| 4 | Introduce `--output table|json|yaml` for a first command family | High-value UX improvement with contained surface area | |
| 216 | +| 5 | Add `--fields` support for machine-readable output | Small follow-up once the output contract exists | |
| 217 | +| 6 | Standardize user-visible exception messages and troubleshooting docs | Improves day-to-day usability without architecture churn | |
| 218 | +| 7 | Add redacted debug tracing for HTTP/session flows | Builds on clearer errors and pays off during later refactors | |
| 219 | +| 8 | Centralize timeout configuration | Small reliability improvement with broad leverage | |
| 220 | +| 9 | Add safe retries with backoff for read-only operations | Depends on timeout config and should stay narrowly scoped | |
| 221 | +| 10 | Publish the typed model migration note | Design-first step before touching public return values | |
| 222 | +| 11 | Introduce typed `Course` and `Section` models | First incremental API improvement on central entities | |
| 223 | +| 12 | Add `py.typed` packaging after the typed surface is credible | Keeps typing support honest and low-risk | |
| 224 | +| 13 | Add dry-run to one mutating command family | Safety improvement with a small blast radius | |
| 225 | +| 14 | Add confirmation prompts and `--yes` bypass for destructive commands | Natural follow-up to dry-run | |
| 226 | +| 15 | Publish ensure-style API semantics and implement `ensure_section` | Smallest idempotent automation slice | |
| 227 | +| 16 | Extend ensure support to labels/resources, then folders/courses | Builds on the same result semantics incrementally | |
| 228 | +| 17 | Audit remaining version-sensitive flows and migrate one more fragile path | Reuses the compatibility layer already in the repo | |
| 229 | +| 18 | Audit webservice usage, then implement one hybrid backend path | Good medium-sized architecture proof point | |
| 230 | +| 19 | Audit module architecture and migrate one or two module handlers | Defers cost until lower-risk wins are complete | |
| 231 | +| 20 | Pick and implement one new feature slice | Best done after the extension and compatibility story improves | |
| 232 | +| 21 | Final CLI polish: help text, exit codes, completion | Keeps user-facing polish aligned with the final command surface | |
| 233 | +| 22 | Packaging/tooling coherence cleanup | Low-risk cleanup after product-facing changes settle | |
| 234 | +| 23 | Expand documentation recipes for the stabilized workflows | Best when new behavior is no longer moving quickly | |
| 235 | + |
| 236 | +## Recommended Next PRs |
| 237 | + |
| 238 | +If the roadmap is executed strictly for impact-per-line changed, the best next |
| 239 | +small PRs are: |
| 240 | + |
| 241 | +1. **Structured CLI output formats** |
| 242 | +2. **Field filtering for machine-readable output** |
| 243 | +3. **Exception clarity and troubleshooting** |
| 244 | +4. **Centralized timeout configuration** |
| 245 | +5. **Documentation recipes** |
| 246 | + |
| 247 | +That order keeps the early work mergeable, user-visible, and low-risk while |
| 248 | +setting up the more architectural phases for success. |
0 commit comments