Phase 3.5 extraction & assembly

ContextAssemblyService gRPC AssembleContext orchestrator with L0–L2 degradation (logs + response shape), IBEX_CONTEXT_DEADLINE_MS 40ms retrieval wall, and L3 DEADLINE_EXCEEDED for proxy fail-open (ADR-0071).

Milestone 3.5.C.6 — gRPC Service Skeleton and Degradation Contract

Status: Completed Goal: Track C — Context Assembly Engine
Phase: 3.5 — Extraction & Context Assembly
Estimated effort: 3 days
Track: Track C — Context Assembly Engine
Depends on: 3.5.C.5 (context formatter)
ADR: ADR-0071


Why This Milestone Exists

Wraps Track C’s budget/retrieval/scorer/packer/formatter into ContextAssemblyService.AssembleContext and locks operational degradation (L0–L2 in-service; L3 as proxy fail-open on DEADLINE_EXCEEDED).


Non-Goals

  • Proto message field adds (fallback, was_truncated, …)
  • Go proxy client / X-IBEX-Context-Fallback — 3.5.D.1
  • Changing packages/proto/** / buf.gen.yaml

File layout (as shipped)

services/context/app/assemble.py              # ContextAssembler, L0–L2 classification
services/context/app/server.py                # grpc.aio AssembleContext + UNIMPLEMENTED stubs
services/context/app/__main__.py              # python -m app
services/context/app/config.py                # IBEX_CONTEXT_DEADLINE_MS, IBEX_CONTEXT_GRPC_ADDR
services/context/tests/test_assemble.py
services/context/tests/test_server.py
benchmarks/context/assemble_load.py           # stub + live gRPC load harness
infra/scripts/context-proto-gen.sh            # buf generate for context_pb2 in CI

Settings / env:

  • IBEX_CONTEXT_DEADLINE_MS (default 40) — retrieval wall; effective wait min(timeout_ms, deadline_ms)
  • IBEX_CONTEXT_GRPC_ADDR (default 127.0.0.1:9092) — bind address

Degradation Ladder (as shipped)

LevelTriggerBehaviorSignal
L0 — FullHot + cold usable (or intentional skips)Full pack/formatdegradation_level=L0 (debug); memories from both
L1 — Cold degradedCold timeout/errorHot (+ directive) onlyINFO log; hot-only candidates_evaluated
L2 — Memory degradedHot and cold both failDirective + history onlyINFO log; memories_included==0
L3 — Full degradedCaller cancel / deadlineNo partial inventgRPC DEADLINE_EXCEEDED → proxy fail-open (3.5.D.1)

No new proto response fields — observability via AssemblyMetrics + structured logs (ADR-0071).


Success signals

  • Dedicated unit tests for L0 / L1 / L2 / L3 (DEADLINE_EXCEEDED) with stubbed dependencies
  • AssemblyMetrics populated at every level (stage timings + candidates_evaluated)
  • Server enforces IBEX_CONTEXT_DEADLINE_MS (40) independently of the proxy’s 45ms client timeout
  • Stub load harness: 500 RPS AssembleContext, p99 < 50ms (benchmarks/context/assemble_load.py); live 100K procedure documented
  • ADR-0071 accepted; context-test CI green
Edit on GitHub

Last updated on