|
| 1 | +# P2-6 — Runtime namespace: `src` → `agentflow_runtime` |
| 2 | + |
| 3 | +> Plan only. **Do not implement** until a breaking release window is |
| 4 | +> scheduled. Source of the finding: `audit_gpt_11_07_26.md` §P2-6. |
| 5 | +
|
| 6 | +## Problem |
| 7 | + |
| 8 | +| Today | Risk | |
| 9 | +|-------|------| |
| 10 | +| Distribution name `agentflow-runtime` | Fine | |
| 11 | +| Wheel packages top-level **`src`** (`[tool.hatch.build.targets.wheel] packages = ["src"]`) | Namespace collision with any other project that also ships `src`; non-idiomatic public import (`from src.serving…`) | |
| 12 | +| Import surface used everywhere in-repo | `src.*` in app code, tests, Docker/helm command lines, Flink image layout, docs | |
| 13 | + |
| 14 | +## Target |
| 15 | + |
| 16 | +- Installable package name: **`agentflow_runtime`** (import path matches |
| 17 | + distribution intent; aligns with wheel evidence paths in |
| 18 | + `docs/runbooks/release-rollback.md`). |
| 19 | +- Deprecation window: keep a top-level **`src`** shim that re-exports or |
| 20 | + warns, then remove in N+1. |
| 21 | +- No change to distribution name `agentflow-runtime` unless a separate |
| 22 | + rename is decided. |
| 23 | + |
| 24 | +## Non-goals (this plan) |
| 25 | + |
| 26 | +- Renaming `sdk/agentflow` or `sdk-ts` packages. |
| 27 | +- Making `agentflow-integrations` publishable (separate P2-6 bullet — |
| 28 | + either first-class CI/publish or explicit “internal”). |
| 29 | +- Full monorepo re-layout. |
| 30 | + |
| 31 | +## Migration phases |
| 32 | + |
| 33 | +### Phase 0 — inventory (no code move) |
| 34 | + |
| 35 | +1. List all runtime entrypoints that hardcode `src.`: |
| 36 | + - process modules: `python -m src.processing.bridge_consumer`, |
| 37 | + `src.serving.api.main:app` (uvicorn / helm / staging Dockerfile) |
| 38 | + - tests / mypy `packages=["src"]` if any |
| 39 | + - docs and scripts |
| 40 | +2. Confirm hatch config: today only `packages = ["src"]` under |
| 41 | + `[tool.hatch.build.targets.wheel]`. |
| 42 | +3. Build a wheel and record `unzip -l dist/*.whl | head` so the before/after |
| 43 | + tree is evidence-backed. |
| 44 | + |
| 45 | +### Phase 1 — physical package + dual import (breaking-prep) |
| 46 | + |
| 47 | +1. Move or package-dir map `src/` content so imports are |
| 48 | + `agentflow_runtime.…` while **source tree stays reviewable** (prefer |
| 49 | + `src/agentflow_runtime/` layout *or* hatch `packages` map — pick one in |
| 50 | + implementation PR, not both ad hoc). |
| 51 | +2. Provide `src/__init__.py` shim: |
| 52 | + - re-export / path-hook / `import agentflow_runtime as …` pattern that |
| 53 | + keeps `import src.serving…` working for one minor line. |
| 54 | + - optional `DeprecationWarning` on first import of `src` (env-gated so |
| 55 | + tests stay quiet until the window starts). |
| 56 | +3. Update **first-party** entrypoints only when shim is green: |
| 57 | + - helm chart `command` / uvicorn module path |
| 58 | + - staging Dockerfile CMD |
| 59 | + - `scripts/k8s_staging_up.sh` inline Dockerfile |
| 60 | + - compose if any |
| 61 | +4. Gate: unit + contract + a wheel install smoke |
| 62 | + (`python -c "import agentflow_runtime; import src"`). |
| 63 | + |
| 64 | +### Phase 2 — first-party cutover |
| 65 | + |
| 66 | +1. Change in-repo imports `src.` → `agentflow_runtime.` (codemod + review). |
| 67 | +2. Keep shim for external consumers / old docs. |
| 68 | +3. mypy/ruff package paths, pytest `pythonpath`, coverage sources. |
| 69 | + |
| 70 | +### Phase 3 — remove shim (breaking release) |
| 71 | + |
| 72 | +1. Drop top-level `src` from the wheel. |
| 73 | +2. Changelog + migration note in `docs/migration/`. |
| 74 | +3. Tag as minor/major per semver policy for the release line. |
| 75 | + |
| 76 | +## Compatibility matrix (related P2-6 tail) |
| 77 | + |
| 78 | +| Artifact | Versioning today | Note | |
| 79 | +|----------|------------------|------| |
| 80 | +| `agentflow-runtime` | `2.0.0` in pyproject | This plan | |
| 81 | +| Python SDK `sdk/` | separate | Pin matrix in contract tests later | |
| 82 | +| TS SDK `sdk-ts/` | separate | Same | |
| 83 | +| `integrations/` | `1.0.1`, not in main publish workflow | Declare internal **or** promote | |
| 84 | + |
| 85 | +Do not block the namespace rename on integrations publish. |
| 86 | + |
| 87 | +## Verification checklist (when implementing) |
| 88 | + |
| 89 | +- [ ] `python -m build` wheel contains `agentflow_runtime/…` and (phase 1–2) `src/…` shim only |
| 90 | +- [ ] `pip install dist/*.whl` → both import styles work in phase 1–2 |
| 91 | +- [ ] helm/staging still boots API (`uvicorn …:app`) |
| 92 | +- [ ] bridge: `python -m agentflow_runtime.processing.bridge_consumer` (or shim module path) |
| 93 | +- [ ] CI unit + contract green; no accidental `packages = ["src"]` only |
| 94 | + |
| 95 | +## Decision needed before coding |
| 96 | + |
| 97 | +1. **Layout:** `src/agentflow_runtime/` (src-layout) vs rename tree root. |
| 98 | +2. **Shim lifetime:** one minor vs one major. |
| 99 | +3. **Warning default:** on vs off until phase 2 complete. |
| 100 | + |
| 101 | +Until those three are answered in a release ticket, leave code as-is. |
0 commit comments