diff --git a/.gitignore b/.gitignore index 7fb3976..ffb45ac 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,8 @@ venv/ .claude/* !.claude/commands/ !.claude/commands/** + +# Editor / IDE state — user-specific, not project config +.obsidian/ +.vscode/ +.idea/ diff --git a/DEV-LEDGER.md b/DEV-LEDGER.md index 3c099e5..885d361 100644 --- a/DEV-LEDGER.md +++ b/DEV-LEDGER.md @@ -143,7 +143,7 @@ One branch `codex/extractor-eval-loop` for Day 1-5, a second `codex/retrieval-ha | R11 | Codex | P2 | src/atocore/api/routes.py:773-845 | `POST /admin/extract-batch` still accepts `mode="llm"` inside the container and returns a successful 0-candidate result instead of surfacing that host-only LLM extraction is unavailable from this runtime. That is a misleading API contract for operators. | fixed | Claude | 2026-04-12 | (pending) | | R12 | Codex | P2 | scripts/batch_llm_extract_live.py:39-190 | The host-side extractor duplicates the LLM system prompt and JSON parsing logic from `src/atocore/memory/extractor_llm.py`. It works today, but this is now a prompt/parser drift risk across the container and host implementations. | fixed | Claude | 2026-04-12 | (pending) | | R13 | Codex | P2 | DEV-LEDGER.md:12 | The new `286 passing` test-count claim is not reproducibly auditable from the current audit environments: neither Dalidou nor the clean worktree has `pytest` available. The claim may be true in Claude's dev shell, but it remains unverified in this audit. | fixed | Claude | 2026-04-12 | (pending) | -| R14 | Codex | P2 | src/atocore/api/routes.py (POST /entities/{id}/promote) | The HTTP `POST /entities/{id}/promote` route does not translate the new service-layer `ValueError("source_refs required: cannot promote a candidate with no provenance...")` into a 400. A legacy no-provenance candidate promoted through the API currently surfaces as a 500. Does not block V1-0 acceptance; tidy in a follow-up. | open | Claude | 2026-04-22 | | +| R14 | Codex | P2 | src/atocore/api/routes.py (POST /entities/{id}/promote) | The HTTP `POST /entities/{id}/promote` route does not translate the new service-layer `ValueError("source_refs required: cannot promote a candidate with no provenance...")` into a 400. A legacy no-provenance candidate promoted through the API currently surfaces as a 500. Does not block V1-0 acceptance; tidy in a follow-up. | fixed | Claude | 2026-04-22 | (pending) | ## Recent Decisions diff --git a/src/atocore/api/routes.py b/src/atocore/api/routes.py index cd93786..dcfa42f 100644 --- a/src/atocore/api/routes.py +++ b/src/atocore/api/routes.py @@ -2187,12 +2187,17 @@ def api_promote_entity( from atocore.engineering.service import promote_entity target_project = req.target_project if req is not None else None note = req.note if req is not None else "" - success = promote_entity( - entity_id, - actor="api-http", - note=note, - target_project=target_project, - ) + try: + success = promote_entity( + entity_id, + actor="api-http", + note=note, + target_project=target_project, + ) + except ValueError as e: + # V1-0 F-8 re-check raises ValueError for no-provenance candidates + # (see service.promote_entity). Surface as 400, not 500. + raise HTTPException(status_code=400, detail=str(e)) if not success: raise HTTPException(status_code=404, detail=f"Entity not found or not a candidate: {entity_id}") result = {"status": "promoted", "id": entity_id} diff --git a/tests/test_v1_0_write_invariants.py b/tests/test_v1_0_write_invariants.py index d993c6d..e619382 100644 --- a/tests/test_v1_0_write_invariants.py +++ b/tests/test_v1_0_write_invariants.py @@ -160,6 +160,42 @@ def test_promote_rejects_legacy_candidate_without_provenance(tmp_data_dir): assert got.status == "candidate" +def test_api_promote_returns_400_on_legacy_no_provenance(tmp_data_dir): + """R14 (Codex, 2026-04-22): the HTTP promote route must translate + the V1-0 ValueError for no-provenance candidates into 400, not 500. + Previously the route didn't catch ValueError so legacy bad + candidates surfaced as a server error.""" + init_db() + init_engineering_schema() + + import uuid as _uuid + from fastapi.testclient import TestClient + from atocore.main import app + + entity_id = str(_uuid.uuid4()) + with get_connection() as conn: + conn.execute( + "INSERT INTO entities (id, entity_type, name, project, " + "description, properties, status, confidence, source_refs, " + "extractor_version, canonical_home, hand_authored, " + "created_at, updated_at) " + "VALUES (?, 'component', 'Legacy HTTP', 'p04-gigabit', " + "'', '{}', 'candidate', 1.0, '[]', '', 'entity', 0, " + "CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)", + (entity_id,), + ) + + client = TestClient(app) + r = client.post(f"/entities/{entity_id}/promote") + assert r.status_code == 400 + assert "source_refs required" in r.json().get("detail", "") + + # Row still candidate — the 400 didn't half-transition. + got = get_entity(entity_id) + assert got is not None + assert got.status == "candidate" + + def test_promote_accepts_candidate_flagged_hand_authored(tmp_data_dir): """The other side of the promote re-check: hand_authored=1 with empty source_refs still lets promote succeed, matching