fix(benchmark): close 5 should-address residuals from CE review on PR #3 - #4
Merged
HugoSkylight merged 1 commit intoApr 25, 2026
Merged
Conversation
Addresses the should-address tail from the prior PR's CE review (run 20260425-093102-b5a311de) — see docs/residual-review-findings/feat-benchmark-offline-conv-ingest.md. REL-02 — Recomposition failure now propagates created directory URIs to the caller's tracker. Introduces ``RecompositionError`` carrying ``created_uris`` so the benchmark layer's run-scoped cleanup can drain them and let its compensate() path do the deletion. Production callers (``raise_on_error=False``) keep the legacy inline best-effort cleanup unchanged. REL-04 — Adapter cross-conversation gather no longer cascades cancel. Both LoCoMo and conversation adapters use ``return_exceptions=True`` and treat per-task ``CancelledError`` as a structured error so one crashed or cancelled item cannot abort sibling work. F4 / api-contract-005 — Idempotent-hit response now preserves summary_uri when the prior run wrote one. Looks up the deterministic session_summary URI and returns it; previously always returned None, which was a contract asymmetry vs the cold-ingest path. api-contract-007 — Public ``MemoryOrchestrator.benchmark_conversation_ingest`` facade now requires admin role by default (defense-in-depth). ``enforce_admin=True`` is the default; in-process callers (benchmarks, maintenance scripts, tests pre-seeding role) can opt out via ``enforce_admin=False`` — the kwarg is verbose so any bypass shows up in code review. The HTTP layer's _require_admin() is still the primary gate; this catches future internal callers that might skip the route. F5 / ADV-007 — Source records gain a ``run_complete`` marker written only on successful ingest completion. The idempotent-hit path now checks both ``transcript_hash`` AND ``run_complete``: a hash-match WITHOUT the marker is treated as a torn prior run and triggers ``_purge_torn_benchmark_run`` to drop stale leaves, directories, and summary before re-ingesting. Implements the R2-17 pre-ingest purge that was deferred from U5. New regression test ``test_torn_prior_run_is_not_treated_as_idempotent``. 96/96 tests pass.
This was referenced Apr 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to PR #3 closing the should-address tail from the CE code review. PR #3 already shipped the must-address residuals (F1 sibling-task race, ADV-002 anchorless seed split, PERF-001 semaphore hoist). This PR closes the next 5:
RecompositionError. Inner best-effort suppress cleanup remains for production callers that don't maintain a tracker.gatherno longer cascades cancel: switched toreturn_exceptions=Trueand explicit per-taskCancelledErrorhandling.summary_uriwhen the prior run wrote one. Closes the contract asymmetry vs cold-ingest.MemoryOrchestrator.benchmark_conversation_ingestfacade requires admin role by default (defense-in-depth). HTTP layer's_require_admin()is still the primary gate; this catches future internal callers.run_completemarker written only on successful ingest completion. Idempotent-hit path now checks bothtranscript_hashANDrun_complete; a hash-match without the marker triggers_purge_torn_benchmark_runto drop stale leaves/directories/summary before re-ingesting. Implements the R2-17 pre-ingest purge deferred from U5.Source:
docs/residual-review-findings/feat-benchmark-offline-conv-ingest.md(run artifact at.context/compound-engineering/ce-code-review/20260425-093102-b5a311de/).Test plan
tests.test_http_server,tests.test_locomo_bench,tests.test_e2e_phase1,tests.test_benchmark_ingest_lifecycle.tests.test_benchmark_ingest_lifecycle.test_torn_prior_run_is_not_treated_as_idempotentlocks F5 behavior — stripsrun_completemarker, verifies the next replay calls_purge_torn_benchmark_runand re-ingests instead of returning the partial set.context_commit/context_end) regression suite passes — important because theRecompositionErrorchange touches_run_full_session_recompositionwhich is shared, butraise_on_error=False(production default) preserves the legacy inline cleanup path exactly.Risk notes
RecompositionErroris a new public-ish exception class. Production callers (raise_on_error=False) never see it. The benchmark caller catches and re-raisesexc.original, so the outerexcept (Exception, asyncio.CancelledError)handler's compensate flow is preserved — no change in observable failure semantics.enforce_admin=Truedefault on the orchestrator facade could break in-process callers that don't pre-seed the role contextvar. Audited: onlyadmin_routes.py(HTTP — admin role set) and tests via httpx (admin role set in fixture) call the facade today. The CLI benchmark adapter goes viaOCClientwhich is HTTP. If something breaks, passenforce_admin=Falseexplicitly.run_completemarker is opt-in: only the benchmark path writes it. Existing source records without the marker (legacy / production-conversation source records) are NOT affected because the production lifecycle never enters the benchmark idempotent-hit path. Backward-compat preserved._purge_torn_benchmark_runuses_delete_immediate_familieswhich iscontextlib.suppress(Exception)per-URI. Failure to purge a stale record is logged and the re-ingest proceeds; this matches existing benchmark cleanup posture.Deferred (still on the residual sheet)
The remaining items in
docs/residual-review-findings/feat-benchmark-offline-conv-ingest.mdare nice-to-haves (api-contract-001 CHANGELOG, api-contract-004 error envelope shape consistency, ADV-006 hash list-ordering, F3/ADV-003 cross-conv shared state non-determinism, KP-* Pythonic style) plus the testing gaps (TEST-001/002/005/008). None are merge-blocking — they can ride along with Phase 2 cleanup or land as standalone polish.🤖 Generated with Claude Code