Build opaque bounded external context runtime (#6) #25

Merged
lost-rob0t merged 10 commits from feature/issue-6-context-store into main 2026-08-12 02:13:49 +00:00
lost-rob0t commented 2026-08-12 02:11:50 +00:00 (Migrated from github.com)

Closes #6.

Context runtime

  • add rlm_context as the backend-neutral external-context API
  • keep payloads outside model-facing references behind versioned opaque context_handle(Id, Version) terms
  • initial in-memory backend accepts only explicit text(Text) and terms(List) sources
  • backend declares filesystem:false and network:false; file(...), URL-like terms, streams, sockets, and arbitrary callable terms are not dereferenced
  • retain tombstones so deleted/stale handles fail structurally

Bounded operations

  • metadata
  • peek: head/tail, term item, metadata
  • slice
  • search over text lines or stable term representation
  • partition: fixed chunks and text-line chunks
  • allow-listed map: identity/lowercase/uppercase/length
  • allow-listed reduce: count/byte_count

Every projection supports explicit max_results, global max_bytes, and wall-time budgets. Count/byte limits are enforced across the whole returned projection rather than independently per chunk.

Traceability

Each successful operation records structured trace data including:

  • operation + handle
  • bytes/items inspected
  • bytes returned
  • truncation state
  • elapsed milliseconds
  • timestamp
  • per-handle monotonic sequence

Deterministic coverage

Tests cover large opaque text, bounded search, global partition byte limits, term peek/slice/map/reduce, malformed/unknown/deleted handles, arbitrary callable denial, unsupported filesystem sources, invalid limits/partition sizes, trace metrics, and declared backend capabilities.

The branch has been merged forward to the current main provider behavior, including reasoning-only OpenRouter normalization, so this PR does not revert or duplicate provider changes.

CI/security

  • deterministic branch CI is green
  • the PR must additionally pass the trusted same-repository REAL OpenRouter integration job before merge
  • no Python runtime
  • no provider fakes in the live path
  • no credential-bearing context behavior or traces
  • final PR diff/security scan required before merge
Closes #6. ## Context runtime - add `rlm_context` as the backend-neutral external-context API - keep payloads outside model-facing references behind versioned opaque `context_handle(Id, Version)` terms - initial in-memory backend accepts only explicit `text(Text)` and `terms(List)` sources - backend declares `filesystem:false` and `network:false`; `file(...)`, URL-like terms, streams, sockets, and arbitrary callable terms are not dereferenced - retain tombstones so deleted/stale handles fail structurally ## Bounded operations - metadata - peek: head/tail, term item, metadata - slice - search over text lines or stable term representation - partition: fixed chunks and text-line chunks - allow-listed map: identity/lowercase/uppercase/length - allow-listed reduce: count/byte_count Every projection supports explicit `max_results`, global `max_bytes`, and wall-time budgets. Count/byte limits are enforced across the whole returned projection rather than independently per chunk. ## Traceability Each successful operation records structured trace data including: - operation + handle - bytes/items inspected - bytes returned - truncation state - elapsed milliseconds - timestamp - per-handle monotonic sequence ## Deterministic coverage Tests cover large opaque text, bounded search, global partition byte limits, term peek/slice/map/reduce, malformed/unknown/deleted handles, arbitrary callable denial, unsupported filesystem sources, invalid limits/partition sizes, trace metrics, and declared backend capabilities. The branch has been merged forward to the current `main` provider behavior, including reasoning-only OpenRouter normalization, so this PR does not revert or duplicate provider changes. ## CI/security - deterministic branch CI is green - the PR must additionally pass the trusted same-repository REAL OpenRouter integration job before merge - no Python runtime - no provider fakes in the live path - no credential-bearing context behavior or traces - final PR diff/security scan required before merge
Sign in to join this conversation.
No description provided.