untracked files on main: dceb101 feat(#63): IMP-34 R1 donor capacity measured bound (u1+u2)

This commit is contained in:
kmlee1 committed 2026-05-21 22:07:41 +09:00
commit 8f085a28d3
3220 files changed
+985495

No files matched your search

+1
View File
@@ -0,0 +1 @@
{"body": "[Claude #5] Stage 3 code-edit IMP-46 — u5 auto-cache CLI flag + 2^3 gate truth table\n\nExecuting unit: u5\n\n■ unit_executed\n- id: u5\n- summary: Wire IMP-46 u5 auto-cache opt-in across three layers — (1) add `ai_fallback_auto_cache: bool = False` to `src/config.py` Settings; (2) extend `src/phase_z2_ai_fallback/cache.py::save_proposal` with a keyword-only `auto_cache: bool = False` parameter that bypasses ONLY the `user_approved` gate (`visual_check_passed` remains mandatory and non-bypassable); (3) add `--auto-cache` CLI flag in `src/phase_z2_pipeline.py` that mutates `settings.ai_fallback_auto_cache=True` at parse time. The 2^3 gate truth table over `(visual_check_passed, user_approved, auto_cache)` is now exhaustively enumerated in `tests/phase_z2_ai_fallback/test_cache.py` with exactly three persisting rows: `(T,T,F)`, `(T,T,T)`, `(T,F,T)`. Every other row raises `AiFallbackCacheGateError` before any filesystem touch.\n\n■ files_changed\n- src/config.py (+8 lines — `ai_fallback_auto_cache: bool = False` Settings field + docstring)\n- src/phase_z2_ai_fallback/cache.py (+~30/-10 lines — `save_proposal(auto_cache=False)` keyword-only param, docstring expanded with u5 contract section, module docstring `u2 + u3` → `u2 + u3 + u5`)\n- src/phase_z2_pipeline.py (+~20 lines — `--auto-cache` argparse flag + in-process `settings.ai_fallback_auto_cache=True` mutation)\n- tests/phase_z2_ai_fallback/test_cache.py (+~110 lines — 8-row parametrised truth-table test + 5 targeted u5 cases)\n- tests/test_phase_z2_ai_fallback_config.py (+~12 lines — `test_ai_fallback_auto_cache_default_off`)\n\n■ diff_summary\n- `src/config.py`\n - New field `ai_fallback_auto_cache: bool = False` placed alongside the existing IMP-33 u1 ai_fallback_* block. Docstring explains the gate semantics (\"bypasses `user_approved` only; `visual_check_passed` never bypassable\") and locks the default OFF + CLI mutation contract.\n- `src/phase_z2_ai_fallback/cache.py`\n - Module docstring header: `IMP-46 u2 + u3` → `IMP-46 u2 + u3 + u5`. New \"u5 auto-cache contract\" section enumerates the truth table (3 cells succeed, 5 raise) and pins the keyword-only / default-False shape.\n - Guardrails block updated: \"Both write gates preserved — `visual_check_passed=False` always raises … `user_approved=False` also raises by default; the IMP-46 u5 `auto_cache=True` override bypasses ONLY the `user_approved` gate (`visual_check_passed` is never bypassed). Gate violation never silently no-ops.\"\n - `save_proposal` signature gains keyword-only `auto_cache: bool = False` at the end of the kwargs block (after `fingerprints`). Position-only callers cannot accidentally pass it.\n - New type-check: `if not isinstance(auto_cache, bool): raise TypeError(\"auto_cache must be a bool\")`. Symmetric with `slide_css` / `fingerprints` validation.\n - Gate logic change — single line:\n - Before: `if not user_approved: raise AiFallbackCacheGateError(...)`\n - After: `if not user_approved and not auto_cache: raise AiFallbackCacheGateError(...)`\n - The `visual_check_passed` gate is unchanged — `auto_cache` does NOT appear in that branch. Error messages updated to reflect the new bypass surface (\"auto_cache cannot bypass this gate\" on visual-check failure; \"Pass auto_cache=True (or --auto-cache on the CLI) to bypass\" on user-approved failure).\n - No new imports. No `src.config` import inside cache.py — the cache module remains a pure comparator/storage layer that takes the resolved boolean from the caller (preserves AI isolation contract `tests/phase_z2_ai_fallback/test_ast_isolation.py:48-69`).\n- `src/phase_z2_pipeline.py`\n - New `--auto-cache` flag added to the existing `if __name__ == \"__main__\"` argparse block (after `--override-section-assignment`, before `args = parser.parse_args()`). `action=\"store_true\"`, `default=False`. Help text states the gate semantics + setting wiring.\n - After `parse_args()`: a 3-line conditional imports `settings` from `src.config` and sets `ai_fallback_auto_cache=True` when the flag is present. The deferred import (inside `if args.auto_cache:`) keeps `src.config` off the unconditional pipeline import surface — only operators who opt in pull it in.\n - The mutation is in-process only — no .env write, no side effects between runs. A subsequent pipeline run without `--auto-cache` starts back at the Settings default (`False`).\n- `tests/phase_z2_ai_fallback/test_cache.py`\n - New section header \"IMP-46 u5: auto_cache gate (2^3 truth table)\".\n - `_GATE_TRUTH_TABLE` constant — 8 rows, exhaustive Cartesian product of `(V, U, A)` × `expect_persist`. Hand-locked, NOT generated from the implementation, so a regression in the gate logic surfaces as a row failure (3 persist + 5 raise).\n - `test_save_gate_truth_table` parametrised — for each row, either calls `save_proposal` and asserts the file exists (persist row), or asserts `AiFallbackCacheGateError` raises AND Line truncated