Skip to content

Investigate derived semantic retrieval for bounded context packets #5

Description

@greygoody

Problem

CodeCtx currently exposes explicit, inspectable task context such as the task goal, allowed scope, Git/worktree state, runtime metadata, required evidence, and explained net moves.

Exact links, identifiers, and structured state should remain authoritative. However, agents may also need to recover conceptually related prior constraints, decisions, failures, or closure evidence when terminology has changed and no direct link exists.

The question is whether a derived semantic retrieval capability can improve bounded context packets without turning similarity into domain truth or expanding CodeCtx into a general memory platform.

Current hypothesis

A semantic layer may be useful as a disposable projection over explicit CodeCtx records.

Possible shape:

  • export selected context records with stable source references and epistemic/status metadata;
  • generate embeddings through a provider-neutral interface;
  • support hybrid retrieval: hard metadata filters, explicit graph/direct links, exact keyword matching, then semantic similarity;
  • return attributed results with source, score, status, and selection reason;
  • keep all vectors and indexes rebuildable and non-canonical;
  • expose retrieval through a narrow CLI or tool-facing contract only after evaluation proves value.

This is a hypothesis, not accepted architecture.

Questions to answer

  1. Which CodeCtx records are legitimate semantic inputs: task intent, constraints, decisions, evidence, unknowns, rejected moves, failures, or closure summaries?
  2. Can semantic retrieval materially outperform direct links plus keyword search on realistic CodeCtx tasks?
  3. How should results preserve distinctions between accepted state, proposal, unknown, rejected material, and stale context?
  4. Should this capability live in CodeCtx core, an optional adapter, or a separate private projection service?
  5. What provider and model identity must be recorded so incompatible vectors are never silently compared?
  6. What bounded packet contract would let an agent inspect why each result was selected?

Required experiment

Build or simulate a small representative corpus from completed and active tasks, then hand-label realistic queries and compare:

  • keyword-only retrieval;
  • embedding-only retrieval;
  • hybrid retrieval;
  • explicit graph/direct-link retrieval plus hybrid fallback.

Measure at minimum:

  • relevant-record recall within a small result budget;
  • stale or superseded context retrieval rate;
  • contradictory/rejected-context coverage;
  • provenance completeness;
  • relevant tokens added per packet;
  • whether retrieved context changes or improves an actual task decision.

Constraints

  • Explicit CodeCtx state, Git evidence, tests, and human decisions remain authoritative.
  • Similarity must never promote, accept, or mutate state.
  • Retrieval must preserve source references and epistemic/status metadata.
  • The semantic index must be disposable and reproducible from canonical records.
  • No required hosted vector database or embedding provider in CodeCtx core.
  • No silent partial context packet when the declared retrieval contract requires complete coverage.

Non-goals

  • exposing model hidden states, activations, attention data, reasoning tokens, or KV caches;
  • building a universal personal-memory system;
  • replacing branch/task links, Git traversal, or exact identifiers;
  • introducing a general ontology, relation graph, or event framework;
  • selecting pgvector, a hosted vector store, or OpenAI embeddings before the experiment earns that dependency;
  • adding semantic retrieval to the public product before a concrete consumer proves it useful.

Acceptance criteria

This issue may close with one of three valid outcomes:

  1. Promote a minimal contract: evidence shows a bounded semantic fallback materially improves context retrieval, and a follow-up implementation issue defines the smallest public boundary.
  2. Keep it external/private: the mechanism is useful but belongs in Orb/private workflow infrastructure rather than CodeCtx core.
  3. Reject or defer: direct links, graph traversal, and keyword search are sufficient, or semantic retrieval adds too much stale/noisy context for its cost.

Any promoted result must include an inspectable evaluation corpus, retrieval witnesses, provider/model identity handling, and explicit kill or demotion conditions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions