feat: Implement Study Interview Mode as default study creation method

Study Interview Mode is now the DEFAULT for all study creation requests.
This intelligent Q&A system guides users through optimization setup with:

- 7-phase interview flow: introspection → objectives → constraints → design_variables → validation → review → complete
- Material-aware validation with 12 materials and fuzzy name matching
- Anti-pattern detection for 12 common mistakes (mass-no-constraint, stress-over-yield, etc.)
- Auto extractor mapping E1-E24 based on goal keywords
- State persistence with JSON serialization and backup rotation
- StudyBlueprint generation with full validation

Triggers: "create a study", "new study", "optimize this", any study creation intent
Skip with: "skip interview", "quick setup", "manual config"

Components:
- StudyInterviewEngine: Main orchestrator
- QuestionEngine: Conditional logic evaluation
- EngineeringValidator: MaterialsDatabase + AntiPatternDetector
- InterviewPresenter: Markdown formatting for Claude
- StudyBlueprint: Validated configuration output
- InterviewState: Persistent state management

All 129 tests passing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-03 11:06:07 -05:00
parent b1ffc64407
commit 32caa5d05c
27 changed files with 9737 additions and 11 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,297 @@
# Study Interview Mode - Implementation TODO
**Created**: 2026-01-02
**Source**: [ATOMIZER_STUDY_INTERVIEW_MODE_IMPLEMENTATION_PLAN.md](ATOMIZER_STUDY_INTERVIEW_MODE_IMPLEMENTATION_PLAN.md)
**Status**: COMPLETE - All Tasks Done
---
## Overview
This document tracks the Interview Mode implementation. **All core components have been implemented and tests pass (129/129).**
---
## Phase 1: Foundation - COMPLETE
### 1.1 Directory Structure Setup
**Status**: `[x]` COMPLETE
**Files Created**:
```
optimization_engine/interview/
├── __init__.py
├── study_interview.py
├── question_engine.py
├── interview_state.py
├── interview_presenter.py
├── interview_intelligence.py
├── engineering_validator.py
├── study_blueprint.py
└── schemas/
├── interview_questions.json
├── materials_database.json
└── anti_patterns.json
tests/interview/
├── __init__.py
├── test_interview_state.py
├── test_question_engine.py
├── test_interview_presenter.py
├── test_engineering_validator.py
├── test_study_blueprint.py
└── test_study_interview.py
```
---
### 1.2 InterviewState Dataclass
**Status**: `[x]` COMPLETE
Implemented in `interview_state.py`:
- InterviewState dataclass with all fields
- JSON serialization (to_json(), from_json())
- InterviewPhase enum with transitions
- Helper methods: is_complete(), progress_percentage(), add_warning(), etc.
- AnsweredQuestion and LogEntry dataclasses
---
### 1.3 InterviewStateManager
**Status**: `[x]` COMPLETE
Implemented in `interview_state.py`:
- Directory creation (.interview/, .interview/backups/)
- Atomic save with backup rotation
- Lock file mechanism
- Log file appending (INTERVIEW_LOG.md)
- History tracking
---
## Phase 2: Question Engine - COMPLETE
### 2.1 Question Schema
**Status**: `[x]` COMPLETE
Created `schemas/interview_questions.json`:
- 17 questions across 7 categories
- Conditional logic definitions
- Dynamic option population support
- Engineering guidance per question
---
### 2.2 QuestionEngine
**Status**: `[x]` COMPLETE
Implemented in `question_engine.py`:
- Schema loading and parsing
- Conditional evaluation (and/or/not/equals/contains/introspection_has)
- Dynamic option population from introspection
- Answer validation
- Category ordering
---
### 2.3 Interview Presenters
**Status**: `[x]` COMPLETE
Implemented in `interview_presenter.py`:
- InterviewPresenter abstract base class
- ClaudePresenter (markdown formatting)
- DashboardPresenter (JSON events)
- CLIPresenter (plain text)
- Response parsing for all question types
---
## Phase 3: Intelligence Layer - COMPLETE
### 3.1 ExtractorMapper
**Status**: `[x]` COMPLETE
Implemented in `interview_intelligence.py`:
- GOAL_MAP for goal-to-extractor mapping
- Support for all extractors E1-E10
- Auto-assignment based on optimization goal
---
### 3.2 Materials Database
**Status**: `[x]` COMPLETE
Created `schemas/materials_database.json`:
- 12 common engineering materials
- Properties: yield stress, ultimate stress, density, modulus
- Safety factors by application
- Fuzzy name matching implemented
---
### 3.3 Anti-Pattern Detector
**Status**: `[x]` COMPLETE
Created `schemas/anti_patterns.json` and implemented in `engineering_validator.py`:
- 12 anti-pattern definitions
- Severity levels (error, warning, info)
- Fix suggestions
- Pattern detection logic
---
### 3.4 Engineering Validator
**Status**: `[x]` COMPLETE
Implemented in `engineering_validator.py`:
- MaterialsDatabase class with fuzzy matching
- AntiPatternDetector class
- EngineeringValidator combining both
- Constraint validation (stress, displacement, frequency)
- Bounds suggestion
---
### 3.5 Interview Intelligence
**Status**: `[x]` COMPLETE
Implemented in `interview_intelligence.py`:
- Complexity determination (simple/moderate/complex)
- Question estimation
- Recommended settings generation
---
## Phase 4: Blueprint & Generation - COMPLETE
### 4.1 StudyBlueprint
**Status**: `[x]` COMPLETE
Implemented in `study_blueprint.py`:
- DesignVariable, Objective, Constraint dataclasses
- StudyBlueprint with all configuration
- to_config_json() for optimization_config.json format
- to_markdown() for summary display
- Validation methods
---
### 4.2 BlueprintBuilder
**Status**: `[x]` COMPLETE
Implemented in `study_blueprint.py`:
- from_interview_state() method
- Automatic extractor assignment
- Trial count calculation
- Sampler selection
---
### 4.3 StudyInterviewEngine
**Status**: `[x]` COMPLETE
Implemented in `study_interview.py`:
- Main orchestrator class
- start_interview() with resume support
- get_first_question() / process_answer() flow
- Warning acknowledgment
- Blueprint generation and modification
- State persistence
---
## Phase 5: Integration - COMPLETE
### 5.1 Skill File
**Status**: `[x]` COMPLETE
Created `.claude/skills/modules/study-interview-mode.md`:
- Usage documentation
- Example conversation
- Integration guide
---
### 5.2 Protocol Updates
**Status**: `[x]` COMPLETE
Completed:
- [x] Update OP_01_CREATE_STUDY.md with interview phase
- [x] Update 00_BOOTSTRAP.md task routing
- [x] Update CLAUDE.md with interview instructions
---
## Phase 6: Testing - COMPLETE
### 6.1 Unit Tests
**Status**: `[x]` COMPLETE
All tests pass: **129/129**
Test files created:
- test_interview_state.py (23 tests)
- test_question_engine.py (20 tests)
- test_interview_presenter.py (16 tests)
- test_engineering_validator.py (32 tests)
- test_study_blueprint.py (22 tests)
- test_study_interview.py (16 tests)
---
### 6.2 Integration Tests
**Status**: `[x]` COMPLETE
Integration tests in test_study_interview.py:
- Full interview flow
- Resume functionality
- Blueprint generation
- Warning handling
---
## Summary
| Phase | Status | Completion |
|-------|--------|------------|
| 1. Foundation | COMPLETE | 100% |
| 2. Question Engine | COMPLETE | 100% |
| 3. Intelligence | COMPLETE | 100% |
| 4. Blueprint | COMPLETE | 100% |
| 5. Integration | COMPLETE | 100% |
| 6. Testing | COMPLETE | 100% |
**Overall**: 100% Complete
**All Tasks Done**:
- [x] All 129 tests passing
- [x] All protocol updates complete
- [x] Skill file created
---
## Quick Start
```python
from optimization_engine.interview import StudyInterviewEngine
# Create engine
engine = StudyInterviewEngine(study_path)
# Start interview
session = engine.start_interview("my_study", introspection=introspection_data)
# Get first question
action = engine.get_first_question()
print(action.message)
# Process answers in loop
while action.action_type == "ask_question":
user_response = input()
action = engine.process_answer(user_response)
# When complete
if action.action_type == "show_summary":
blueprint = action.blueprint
config = blueprint.to_config_json()
```