Skip to content

P1-E: Implement dialectical retrieval pipeline (Metroid + subgraph + coherence) #91

@devlux76

Description

@devlux76

Parent issue: Part of #89

Problem

The current query pipeline in cortex/Query.ts performs a simple hotpath→warm/cold flat ranking and does not implement the dialectical retrieval described in the design docs:

  • It does not build or use a Metroid { m1, m2, c } probe for dialectical reasoning.
  • It does not explore thesis/antithesis/synthesis zones.
  • It does not perform bounded semantic neighbor subgraph expansion with Williams-derived limits.
  • It does not compute a coherent ordering (TSP) of the returned pages.

Goal

Implement the full dialectical retrieval pipeline as described in docs/wiki/Retrieval.md:

  1. Use MetroidBuilder to compute m1, m2, and frozen centroid c.
  2. Use the metroid to guide retrieval through thesis/antithesis/synthesis zones.
  3. Expand the result set via the semantic neighbor graph with Williams-derived bounds.
  4. Compute a coherent path ordering of returned nodes (Open TSP or heuristic) for narrative coherence.

Acceptance Criteria

  • Query results include a coherencePath and metroid in QueryResult.
  • Subgraph expansion obeys HotpathPolicy.computeSubgraphBounds(...) and does not scan the full corpus unnecessarily.
  • A unit test verifies that a query returns a metroid with m1 and m2 (when enough data exists) and that the returned path is ordered.
  • No regression in existing hotpath ranking behavior.

Notes

This issue is a prerequisite for Knowledge Gap detection, curiosity probes, and a reliable retrieval experience.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1: highHigh priority — targets v0.5layer: cortexRetrieval orchestration (rank → expand → order)layer: storageOPFS vector store and IndexedDB metadata storelayer: testingTest coverage and integration tests

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions