Move core-specific types from shared types/ layer into core/types/ to follow Clean Architecture principles where domain types live in the domain layer.
Non-goals:
Changing the shared types that are correctly utils-level
Clean Architecture best practice: domain types live in domain layer
1---2name: 1496-2026-01-27-00-19-58-issue-311-core-types-layer-d09ca0f53description: Goal4---56## Goal78Move core-specific types from shared `types/` layer into `core/types/` to follow Clean Architecture principles where domain types live in the domain layer.910**Non-goals:**11- Changing the shared types that are correctly utils-level12- Adding re-export indirection layers13- Modifying any business logic1415## Scope & Assumptions1617**In scope:**18- Create `src/tunacode/core/types/` directory structure19- Move 9 core-specific types to `core/types/`20- Update 17 files in core to import from new location21- Delete 2 dead types (CommandContext, ProcessRequestCallback)22- Update DEPENDENCY_MAP.md2324**Out of scope:**25- Changes to UI layer26- Changes to tools layer27- New features or behavior changes2829**Assumptions:**30- The existing `core/types.py` re-export pattern can be expanded31- Tests pass after import path changes32- No circular import issues will arise3334## Deliverables (DoD)35361. `src/tunacode/core/types/` directory with moved types372. All 17 core files updated to import from `core/types/`383. Dead code deleted from `types/dataclasses.py` and `types/callbacks.py`394. `ruff check` passes405. `uv run pytest` passes416. DEPENDENCY_MAP.md updated4243## Readiness (DoR)4445- [x] Research document complete46- [x] Best practice verified (Clean Architecture standard)47- [x] File inventory complete (17 files, 26 imports)48- [x] Types categorized (9 to move, 2 to delete)4950## Milestones5152- **M1:** Create core/types/ structure and move types53- **M2:** Update all import statements54- **M3:** Delete dead code and verify5556## Work Breakdown (Tasks)5758### Task 1: Create core/types/ directory structure59**Summary:** Create the directory and initial `__init__.py`60**Files:** `src/tunacode/core/types/__init__.py`61**Acceptance:**62- Directory exists63- `__init__.py` exports nothing yet (placeholder)6465### Task 2: Move core-specific types to core/types/66**Summary:** Move 9 types from `types/` to `core/types/`67**Types to move:**68- `ResponseState` (from dataclasses.py)69- `AgentState` (from dataclasses.py)70- `StateManagerProtocol` (from state.py)71- `SessionStateProtocol` (from state.py)72- `ConversationState` (from state_structures.py)73- `TaskState` (from state_structures.py)74- `RuntimeState` (from state_structures.py)75- `UsageState` (from state_structures.py)76- `ToolCallRegistry` (from tool_registry.py)7778**Files touched:**79- Create: `src/tunacode/core/types/state.py`80- Create: `src/tunacode/core/types/protocols.py`81- Create: `src/tunacode/core/types/registry.py`82- Update: `src/tunacode/core/types/__init__.py`8384**Acceptance:**85- All 9 types defined in core/types/86- Exports work via `from tunacode.core.types import X`8788### Task 3: Update 17 core files to import from core/types/89**Summary:** Change import statements from `tunacode.types` to `tunacode.core.types` for moved types90**Files to update (17):**911. `core/state.py`922. `core/user_configuration.py`933. `core/lsp_status.py`944. `core/types.py` (the re-export file)955. `core/configuration.py`966. `core/logging/manager.py`977. `core/agents/main.py`988. `core/agents/agent_components/agent_config.py`999. `core/agents/agent_components/agent_helpers.py`10010. `core/agents/agent_components/response_state.py`10111. `core/agents/agent_components/state_transition.py`10212. `core/agents/agent_components/streaming.py`10313. `core/agents/agent_components/orchestrator/orchestrator.py`10414. `core/agents/agent_components/orchestrator/tool_dispatcher.py`10515. `core/agents/agent_components/orchestrator/usage_tracker.py`10616. `core/agents/resume/sanitize.py`10717. `core/agents/resume/sanitize_debug.py`108109**Acceptance:**110- All imports updated111- `ruff check` passes112- No import errors at runtime113114### Task 4: Delete dead code115**Summary:** Remove unused types from shared types layer116**Delete:**117- `CommandContext` from `types/dataclasses.py`118- `ProcessRequestCallback` from `types/callbacks.py`119120**Acceptance:**121- Dead code removed122- No references remain123- `ruff check` passes124125### Task 5: Verify and update documentation126**Summary:** Run tests, update DEPENDENCY_MAP.md127**Files:**128- `docs/architecture/DEPENDENCY_MAP.md`129130**Acceptance:**131- `uv run pytest` passes132- DEPENDENCY_MAP.md reflects new structure133- `core → types` import count reduced134135## Risks & Mitigations136137| Risk | Impact | Likelihood | Mitigation | Trigger |138|------|--------|------------|------------|---------|139| Circular imports | High | Medium | Careful ordering in __init__.py | Import error on startup |140| Missed import | Medium | Low | grep for old import paths | Test failure |141| Type checker errors | Medium | Medium | Run mypy, use `git commit -n` if blocked | mypy failure |142143## Test Strategy144145- Run existing test suite: `uv run pytest`146- Manual verification: `python -c "from tunacode.core.types import AgentState"`147- No new tests needed (structural change only)148149## Tickets Created150151| Ticket ID | Title | Priority | Status | Depends On |152|-----------|-------|----------|--------|------------|153| tun-3f92 | Create core/types/ directory structure | P1 | open | - |154| tun-979a | Move 9 core-specific types to core/types/ | P1 | open | tun-3f92 |155| tun-48fe | Update 17 core files to import from core/types/ | P1 | open | tun-979a |156| tun-f096 | Delete dead code (CommandContext, ProcessRequestCallback) | P2 | open | tun-48fe |157| tun-3cde | Verify tests and update DEPENDENCY_MAP.md | P2 | open | tun-48fe |158159## References160161- Research: `memory-bank/research/2026-01-27_00-10-38_issue-311-core-types-layer-violation.md`162- Issue: https://github.com/alchemiststudiosDOTai/tunacode/issues/311163- Clean Architecture best practice: domain types live in domain layer
Run npx skillmds@latest add tools-only/1496-2026-01-27-00-19-58-issue-311-core-types-layer-d09ca0f5 in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Goal It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
tools-only (@tools-only) published this skill. Their other Agent Skills are listed on their SkillMD profile.