Skip to content

feat(answer): add single-pass cortex answer with citation integrity + injection guards #247

Closed

Description

@hurttlocker

Summary

Add cortex answer "question" as a v1.1 feature for single-pass retrieval + synthesis with citations.

Scope

  • New package: internal/answer/
  • New CLI command: cortex answer
  • New MCP tool: cortex_answer

Functional constraints

  1. Single-pass only: search -> top results -> synthesize -> cite -> done
  2. No recursion, no memory writes
  3. LLM call used when available (--model override, sensible config-resolved default)
  4. Output: 4-8 sentence answer + numbered citations [n]
  5. --json output machine-parseable
  6. Graceful degrade if no LLM configured: return top search results (no hard fail)

Security / quality guards

  • Citation integrity gate: citations must map to retrieved result IDs or degrade fallback
  • Prompt-injection stripping on retrieved chunks before synthesis
  • In verbose mode, log stripped content to stderr for auditability
  • Context budget controls (maxContextChars, per-result truncation)

MCP parameters

  • query, mode, limit, project, agent_id, source, source_boosts
  • plus model, maxSentences, maxContextChars

Acceptance

  • go test ./... passes
  • Command and MCP tool both available
  • Degrade mode works offline without failure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions