phase: 123_chat_image_questions
Build and Push Containers / build-and-push-app (push) Successful in 1m54s
Build and Push Containers / build-and-push-db (push) Failing after 13s

All gates green. Verification complete.

**Phase 123 — final verification pass (all 4 tasks already in `complete/`)**

- Verified the full implementation is in the working tree: `app/api/chat_images.py` (upload/serve pair), `ChatRequest.image`/`ChatMessage.image` (path-validated, omitted-when-None), toggle-off + stale-file hinted error frames, `build_user_content` multimodal build at both sites (chat.py deflected branch + `run_agent`), config-gated composer attach/preview/upload-then-send, restore + shared rendering, CSP `img-src 'self' data:` carve-out, mock-LLM capture buffer.
- `uv run pytest` → **2796 passed**, exit 0 (unit + integration).
- `uv run pytest --cov=app --cov-report=term-missing` → **TOTAL 99%** (29/4615 missed; phase-123 modules 99–100%).
- `uv run pytest tests/e2e/test_chat_image_questions.py -v --no-cov` → **5 passed** in isolation.
- `uv run ruff check . && uv run pyright` → clean (0 errors).

**Completion criteria:** (1) attach→send→multimodal text+image to the model, bubble/reload/shared all render it, saved chat stores the PATH with `"base64" not in json.dumps(stored)` — **verified** (E2E tests 1–4 + integration round-trip); (2) `BOR_IMAGES=false` — control hidden, exact hinted error frame, zero model calls / no query_log row — **verified** (E2E test 5 + integration); (3) text-only byte-identical (`content` stays a plain `str`) — **verified** (unit + integration); (4) all gates green — **verified**; (5) commit + phase move — left to the harness per pipeline rules (no `git add`/`commit` run).

No defects found; no live-infrastructure changes (repo + local dev DB only). **Next pending phase: none** — 123 is the last phase in `todo/`.
This commit is contained in:
2026-09-25 05:19:18 -04:00
parent a19d78d284
commit bef24e05e2
48 changed files with 3910 additions and 71 deletions
+33
View File
@@ -1083,6 +1083,16 @@ _HTTPS_PER_DEAD_ATTEMPT = 3
#: re-drives the failure sequence from zero.
_fail_posts: dict[str, int] = {}
#: Phase 123 (task 04 — question images): a small ring buffer of the
#: recent ``/v1/chat/completions`` request bodies, exposed on the
#: ``/v1/e2e/captured`` pair below. Purely OBSERVATIONAL (the buffer
#: never influences an answer — determinism is untouched): it lets a
#: story suite assert on the EXACT request the app built — e.g. that a
#: question-image turn delivered the multimodal user content list
#: (text part + ``image_url`` data URL) to the model.
_CAPTURED: list[dict[str, Any]] = []
_CAPTURE_MAX = 100
def _llm_500(why: str) -> JSONResponse:
"""A dead-proxy 500 with a JSON error body (phase 67 injection)."""
@@ -2416,6 +2426,23 @@ def compose_thinking_paragraphs(body: dict[str, Any]) -> str:
return "\n".join(out)
@app.get("/v1/e2e/captured")
def e2e_captured() -> list[dict[str, Any]]:
"""Phase 123 (task 04): the recent chat-completions request bodies
(oldest first, capped at ``_CAPTURED_MAX``) — the mock's capture
for request-shape assertions (see ``_CAPTURED``)."""
return _CAPTURED
@app.post("/v1/e2e/captured/reset")
def e2e_captured_reset() -> dict[str, int]:
"""Phase 123 (task 04): clear the capture so a suite can assert on
exactly the requests of the turn it is about to drive (e.g. the
toggle-off rejection proves ZERO chat calls — an empty capture)."""
_CAPTURED.clear()
return {"cleared": True}
@app.post("/__shutdown__")
def shutdown() -> dict[str, Any]:
"""Test hook (loading-feedback story): terminate this mock process to
@@ -2619,6 +2646,12 @@ def _tool_call_stream(name: str, arguments: dict[str, Any], call_id: str) -> Any
@app.post("/v1/chat/completions")
def chat_completions(body: dict[str, Any]) -> Any:
# Phase 123 (task 04): the OBSERVATIONAL capture (the ring buffer —
# recorded before any flow decision, so a 500-injected request is
# captured too; the buffer never touches the answer path).
_CAPTURED.append(body)
if len(_CAPTURED) > _CAPTURE_MAX:
del _CAPTURED[: len(_CAPTURED) - _CAPTURE_MAX]
user_lower = _user(body).lower()
# Phase 37 (agent document tools): the deterministic marker flow.
# The app's chat path is the only streaming consumer of this mock, so