Each retry attempt now records llm_prompt_tail, llm_raw_output,
llm_caller, patches_count, patch_apply_ok/error, modified_lines,
tests_passed/total, test_output_tail, and error_type. This enables
precise post-hoc diagnosis without re-running benchmarks.
Also fixes test_audit_model.py to use correct module-level constants
(LOGS_SUCCESS/LOGS_FAILED/LOGS_LEGACY instead of removed LOGS_DIR).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Audit log (audit/logger.py):
- Persists task execution trace as human-readable JSON
- Storage: ~/.kaiwu/logs/, max 100, auto-cleanup
- Records: task, gate, experts, files, tests, retries (no code content)
- orchestrator._emit() now instance method, auto-logs to audit
- CLI: kwcode log / log show <id> / log clear
Model commands (cli/commands/model_cmd.py):
- kwcode model: show current config + tier
- kwcode model set <name>: switch model (writes config.yaml)
- kwcode model probe: detect family/params/quant/reasoning via Ollama API
Indent alignment fix (Generator._align_indentation):
- Fixes systematic bug: LLM returns class methods at 0-indent,
apply_patch replaces 4-indent original → method escapes class
- Aligns modified base indent to match original before apply_patch
Tests: 10 new (audit 4 + indent 5 + hashline prompt 1), 50 total green
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
P0 Hashline (tools/hashline.py):
- Content-hash anchored editing: 6-char MD5 per line
- Model outputs EDIT/DELETE/INSERT_AFTER instructions, not full functions
- Hash mismatch → reject entire edit batch (stale file protection)
- Generator tries hashline first, falls back to full-function on failure
P1 AdaptThink (core/think_config.py):
- Gate-driven think budget per expert_type × difficulty
- easy=off, medium=512, hard=2048-4096, chat=always off
- Generator adjusts max_tokens based on think_config
P2 Fast/Slow (orchestrator retry loop):
- First attempt: fast (think=off, low tokens)
- First failure: escalate to slow (think=on, budget=2048)
- Second failure: max budget (4096)
- Orthogonal to retry_strategy (0→1→2)
Tests: 21 new (12 hashline + 8 think + 1 fast/slow), 40 total green
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>