Repository navigation
Description
Task
T-009· Milestone M1 — Foundation · Size XS · Priority P0 · Epic #1Implements NFR-EXT-002
Branch
chore/t-009-enforce-layered-architecture-with-import— one task = one branch = one PR (doc 32 §6)
Summary
Add the three import-linter contracts from doc 16 §2 so that layering violations fail make lint from the very first line of domain code.
Context / motivation
Modularity is a hard requirement (NFR-EXT-002). If the contracts exist before the code, AI agents working in parallel cannot accidentally couple the domain to infrastructure (e.g. selection importing sqlalchemy).
Scope
In scope
[tool.importlinter]section inbackend/pyproject.tomlwith: (1) layers contract, (2) independence/forbidden contract for domain packages vsroboprobe.store,roboprobe.backends,roboprobe.api,fastapi,sqlalchemy,rclpy, (3) onlyroboprobe.bootstrapmay import adapters together with application services.make lintrunslint-imports.- A short section in
CONTRIBUTING.mdexplaining how to read a contract failure.
Out of scope
- CI wiring (done in T-006a by calling
make lint)
Implementation guidance
- Layers (top → bottom):
roboprobe.api | roboprobe.cli→roboprobe.runner | roboprobe.experiments | roboprobe.reporting→roboprobe.selection | roboprobe.oracles | roboprobe.analysis | roboprobe.risk | roboprobe.metrics | roboprobe.scenario→roboprobe.core. - Use
type = "layers"withcontainers = ["roboprobe"]andtype = "forbidden"for the external libraries (setallow_indirect_imports = falsewhere supported). roboprobe.geometryandroboprobe.perturbationare kernel-level (L1) likecore.- Add a deliberately-violating test module under
tests/contract/_import_violation_example.py? No — instead document how to verify locally by temporarily adding an import. - Standards: respect the layering contracts (doc 16 §2) and conventions in doc 34; no hard-coded tunables — thresholds/defaults come from typed settings (doc 27); no magic numbers (ruff
PLR2004); public APIs typed (mypy strict) and documented.
Acceptance criteria
-
lint-importsruns inmake lintand passes on the skeleton. - Adding
import sqlalchemytoroboprobe/selection/__init__.pymakesmake lintfail (verified manually, noted in PR). - Contracts match doc 16 §2 exactly.
- Tests listed below added and green in CI; coverage of new code meets the gate in doc 18 §3.
- Docs, config reference and CHANGELOG
Unreleasedupdated where behaviour, keys or interfaces changed. - Definition of Done (doc 32 §3) satisfied.
Tests required
- CI lint job (T-006a) executes the contracts.
Dependencies
Blocked by: #12 (T-001)
Blocks: #28 (T-006a)
Parallelization notes
Files / paths owned by this task — avoid editing other paths; shared files (pyproject.toml entry points, cli/main.py, api/routers/__init__.py, router.tsx, docker/compose.yaml, ci.yml) are append-only:
- backend/pyproject.toml ([tool.importlinter] only)
- CONTRIBUTING.md (one section)
Tiny, touches one TOML section; merge early.
Definition of Done
Per doc 32 §3 and AGENTS.md §5: lint, format, mypy strict and import-linter green; tests added and passing; docs updated; PR template completed with Closes #<this issue>; Conventional Commit messages referencing T-009 (doc 16 §6); commits authored only by the repository owner identity (AGENTS.md §4); CI green; reviewer checklist (doc 32 §5.1) satisfied.
References
Design docs: doc 16 §2 · doc 34 §3 · ADR-0016 · doc 04 §2.1
Requirements: NFR-EXT-002 (traceability: doc 28)
External:
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Activity
ci.yml: lint, typecheck, backend unit/property/contract matrix, integration, web tests #28