[claude] Split thinking.py into focused sub-modules (#1279) #1306

Merged
claude merged 1 commits from claude/issue-1279 into main 2026-03-24 01:57:05 +00:00
Collaborator

Fixes #1279

What changed

Converted src/timmy/thinking.py (1383 lines) into a package with 8 focused modules, all under 500 lines:

Module Lines Responsibility
_db.py 50 Thought dataclass and SQLite access layer
seeds.py 129 Seed constants and _THINKING_PROMPT template
_distillation.py 215 _DistillationMixin: fact extraction + memory checks
_issue_filing.py 170 _IssueFilingMixin: Gitea issue creation from thoughts
_snapshot.py 173 _SnapshotMixin: system snapshot + memory context
_seeds_mixin.py 191 _SeedsMixin: seed-type selection and context gathering
engine.py 430 ThinkingEngine class (inherits all mixins)
__init__.py 142 Public facade + search_thoughts + singleton

Acceptance criteria

  • No module exceeds 500 lines (largest is engine.py at 430)
  • All 500 unit tests pass (tox -e unit)
  • Public API unchanged — from timmy.thinking import thinking_engine, ThinkingEngine, search_thoughts, Thought, SEED_TYPES, _THINKING_PROMPT all work as before

Test changes

Updated patch targets in test_thinking.py to reference correct sub-modules:

  • timmy.thinking.settingstimmy.thinking.engine.settings (for think_once tests)
  • timmy.thinking._distillation.settings (for _maybe_check_memory tests)
  • timmy.thinking.HOT_MEMORY_PATHtimmy.thinking._snapshot.HOT_MEMORY_PATH
  • timmy.thinking.SOUL_PATHtimmy.thinking._snapshot.SOUL_PATH
Fixes #1279 ## What changed Converted `src/timmy/thinking.py` (1383 lines) into a package with 8 focused modules, all under 500 lines: | Module | Lines | Responsibility | |---|---|---| | `_db.py` | 50 | `Thought` dataclass and SQLite access layer | | `seeds.py` | 129 | Seed constants and `_THINKING_PROMPT` template | | `_distillation.py` | 215 | `_DistillationMixin`: fact extraction + memory checks | | `_issue_filing.py` | 170 | `_IssueFilingMixin`: Gitea issue creation from thoughts | | `_snapshot.py` | 173 | `_SnapshotMixin`: system snapshot + memory context | | `_seeds_mixin.py` | 191 | `_SeedsMixin`: seed-type selection and context gathering | | `engine.py` | 430 | `ThinkingEngine` class (inherits all mixins) | | `__init__.py` | 142 | Public facade + `search_thoughts` + singleton | ## Acceptance criteria - [x] No module exceeds 500 lines (largest is `engine.py` at 430) - [x] All 500 unit tests pass (`tox -e unit`) - [x] Public API unchanged — `from timmy.thinking import thinking_engine`, `ThinkingEngine`, `search_thoughts`, `Thought`, `SEED_TYPES`, `_THINKING_PROMPT` all work as before ## Test changes Updated patch targets in `test_thinking.py` to reference correct sub-modules: - `timmy.thinking.settings` → `timmy.thinking.engine.settings` (for `think_once` tests) - `timmy.thinking._distillation.settings` (for `_maybe_check_memory` tests) - `timmy.thinking.HOT_MEMORY_PATH` → `timmy.thinking._snapshot.HOT_MEMORY_PATH` - `timmy.thinking.SOUL_PATH` → `timmy.thinking._snapshot.SOUL_PATH`
claude added 1 commit 2026-03-24 01:56:45 +00:00
refactor: split thinking.py (1383 lines) into focused sub-modules
Some checks failed
Tests / lint (pull_request) Failing after 37s
Tests / test (pull_request) Has been skipped
a23850b7fd
Convert src/timmy/thinking.py into a package with 8 modules, each under
500 lines. Public API (ThinkingEngine, thinking_engine, search_thoughts,
Thought, SEED_TYPES, _THINKING_PROMPT) is unchanged via __init__.py re-exports.

Modules:
- _db.py         — Thought dataclass and SQLite access layer (50 lines)
- seeds.py       — Seed constants and _THINKING_PROMPT template (129 lines)
- _distillation.py — _DistillationMixin: fact extraction + memory checks (215 lines)
- _issue_filing.py — _IssueFilingMixin: Gitea issue creation from thoughts (170 lines)
- _snapshot.py   — _SnapshotMixin: system snapshot + memory context (173 lines)
- _seeds_mixin.py  — _SeedsMixin: seed-type selection and context gathering (191 lines)
- engine.py      — ThinkingEngine class (inherits all mixins) (430 lines)
- __init__.py    — Public facade with search_thoughts and singleton (142 lines)

Update test patches to reference correct sub-module paths
(timmy.thinking.engine.settings, timmy.thinking._snapshot.HOT_MEMORY_PATH, etc.)

Fixes #1279

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
claude merged commit e44db42c1a into main 2026-03-24 01:57:05 +00:00
claude deleted branch claude/issue-1279 2026-03-24 01:57:05 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#1306