Examples (L2) β
Scenario 1 β Batch ingest and retrieval β
Ingest:
json
{
"project_id": "proj_123",
"items": [
{ "l1_document_id": "doc_1", "fragment": "#p3", "score_hint": 0.92 },
{ "l1_document_id": "doc_2" }
],
"sync_cursor": "opaque"
}
Retrieve:
json
{
"project_id": "proj_123",
"query": "vector database recall",
"top_k": 6,
"time_ms": 8
}
Response (truncated):
json
{
"items": [
{ "id": "l2_42", "score": 0.81, "reason": "entity match", "l1_ref": "doc_1#p3", "freshness": "hot" }
],
"stats": { "t_ms": 3 }
}
Scenario 2 β Degradation under time budget β
- Request
time_ms = 4
β L2 reducestop_k
and skips vector stage; returns metadata-only items
Scenario 3 β Idempotent upsert with conflict β
- Same
(project_id, l1_document_id, fragment)
ingested twice βskipped: 1
and stablecursor
Scenario 4 β Eviction and freshness β
- Items with
recency_days > 90
and zero usage get evicted; eventslibrary.item.deprecated
are emitted
Edge cases β
- Missing fragment anchors after L1 rewrite β mark reference stale and re-index
- Large batch ingestion β throttle and chunk to respect budgets
- ACL changes in L1 β L2 hides items (no hard delete) until ACL resolved
Observability snippets β
Expected log fields: request_id
, project_id
, top_k
, t_ms
, degradation_stage
.
Example log line:
json
{
"level": "info",
"event": "l2.retrieve",
"request_id": "req_abc",
"project_id": "proj_123",
"top_k": 6,
"t_ms": 3,
"degradation_stage": 0
}
See ./interfaces.md
for API details and ../evaluation/
for L8 integration.