Skip to content

feat(refs): resolve public object and evidence refs across CLI, API, MCP, and daemon #2181

Closed

Description

@Sinity

Metadata

Parent: #1807
Related cleanup umbrella: #2177
Related substrate: polylogue/core/refs.py, recovery/context compiler, work-packet evidence refs, assertion evidence refs.
Cross-pollination source: /tmp/ideas.md ref-resolution UX section and Sinex ObjectRef cross-pollination notes.
Status: proposed feature; parse/normalize exists, resolution does not.

Purpose

Make public refs actionable.

Polylogue can now parse and normalize ObjectRef / EvidenceRef strings for sessions, messages, blocks, runs, context snapshots, observed events, assertions, commits, GitHub refs, tool calls, subagent reports, and more. Many payloads carry those refs. But users and agents cannot consistently say “show me this ref” through CLI/API/MCP/daemon and get the appropriate payload/view.

This issue adds a resolver service and surfaces so refs become a real navigation substrate rather than just typed strings embedded in payloads.

Current code reality

Current ref substrate:

polylogue/core/refs.py
  ObjectRefKind includes session, message, block, attachment, paste_span, work_event, phase, thread, file, branch, commit, check-run, workspace, agent, user, repo, insight, run, context-snapshot, observed-event, assertion, saved_view, recall_pack, transform, tool-call, subagent-report, github-issue, github-pr, github-review
  EvidenceRefKind includes session/message/block
  parse_public_ref(), normalize_object_ref_text(), normalize_public_ref_text()

polylogue/context/compiler.py
  RecoveryContextCompilation carries evidence_refs and object_refs

polylogue/surfaces/payloads.py
  assertions, runs, observed events, context snapshots, recovery/work-packet payloads carry refs

Missing owner:

resolve_public_ref(ref) -> finite payload/view or typed unsupported error

Proposed resolver

Add a service such as:

class PublicRefResolutionPayload(SurfacePayloadModel):
    mode: Literal["ref-resolution"]
    ref: str
    kind: str
    resolved: bool
    payload_kind: str | None
    payload: object | None
    title: str | None
    summary: str | None
    evidence_refs: tuple[str, ...]
    object_refs: tuple[str, ...]
    caveats: tuple[str, ...]
    actions: tuple[RefResolutionActionPayload, ...]

resolve_public_ref(archive, ref: str, *, view: str | None = None) -> PublicRefResolutionPayload

Resolution should prefer existing read/query/recovery/assertion APIs rather than direct SQL everywhere.

Initial resolvable kinds should include:

session:<id>       -> session summary/read profile payload
message:<id>       -> message terminal-query row or session/message snippet
block:<id>[:idx]   -> block terminal-query row or block snippet
assertion:<id>     -> assertion row/claim payload
run:<id>           -> run query-unit row / recovery projection row when available
context-snapshot:<id> -> context snapshot query-unit row when available
observed-event:<id>   -> observed event query-unit row when available
EvidenceRef session_id[::message_id[::block_index]] -> nearest session/message/block payload

External refs such as github-pr, github-review, commit, and file may resolve to structured local metadata/caveat rows first; they do not need network lookup in v0.

Surfaces

CLI:

polylogue read REF --format json
polylogue read REF --view transcript
polylogue find ref:REF then read

Python API:

await archive.resolve_ref("session:codex-session:abc")

MCP:

resolve_ref(ref, view?)

Daemon/web API:

GET /api/refs/resolve?ref=...

The web workbench should use the daemon route to make evidence refs clickable in recovery/work-packet/assertion views.

Design constraints

  • Do not create a database registry just to resolve refs. Use existing storage/query/read-model owners first.
  • Do not churn the colon ref format until resolution works.
  • Unsupported kinds must return typed unsupported errors/caveats, not silently perform broad search.
  • Ref resolution must preserve privacy boundaries: raw bytes and absolute local paths are not exposed by default.
  • The resolver should be finite and bounded; no “resolve every related thing recursively” by default.

Acceptance criteria

  • Shared resolver service exists and is consumed by at least CLI and one machine surface (MCP, Python API, or daemon).
  • Session, message, block, assertion, and at least one runtime-transform ref kind (run, observed-event, or context-snapshot) resolve against fixture archives.
  • EvidenceRef forms resolve to the nearest object payload and preserve the original evidence ref in the response.
  • Web/workbench evidence refs can link to the resolver route or payload without inventing a separate resolver.
  • Unsupported ref kinds fail typed with the parsed kind and a clear caveat/action.
  • Docs list supported ref forms, unsupported forms, and examples.

Tests

  • Core parse/resolve tests for session/message/block/assertion refs.
  • Runtime-transform resolve test for one projected run/event/snapshot row.
  • CLI JSON smoke for polylogue read REF --format json or equivalent final syntax.
  • MCP/API/daemon route test for the shared payload if implemented.
  • Privacy test for file/path refs or raw evidence refs.

Non-goals

  • Do not add live GitHub/network lookup in v0.
  • Do not create a separate task/project model around refs.
  • Do not implement unbounded graph expansion.
  • Do not add tests that merely assert old ref spellings are absent.

Identity-map dependency

Ref resolution must distinguish archive refs, provider-native provenance, logical session refs, run/context/event refs, and material-source refs. Do not make provider-native ids a substitute for archive object identity. See #2184 for the coordinate map.

Forensic audit reinforcement

The 2026-06-19 static audit reached the same conclusion as this issue: #1845 made refs useful as payload strings, but the missing product capability is resolution. Future ref work should prioritize resolve_public_ref(...) and user-visible navigation over adding more ref kinds.

Do not build a global ref database first. Resolve through existing owners where possible: session/message/block repositories, assertion reads, terminal query-unit rows, recovery/work-packet projections, and daemon/API/MCP wrappers. Unsupported external refs should return typed caveats/actions, not broad search.

Activity

  1. added
    type:feat
    theme:evidence-trust
    area:core
    area:daemon
    theme:analysis
    on Jun 19, 2026
  2. Sinity commented on Jun 19, 2026

    @Sinity
    OwnerAuthor

    Closing as implemented on current master.

    Acceptance matrix:

    • Shared resolver service exists: satisfied by Polylogue.resolve_ref(...) in polylogue/api/archive.py, returning PublicRefResolutionPayload from polylogue/surfaces/payloads.py.
    • CLI surface exists: satisfied by direct polylogue read REF --format json handling in polylogue/cli/query_verbs.py.
    • Machine surfaces exist: satisfied by MCP resolve_ref in polylogue/mcp/server_tools.py and daemon GET /api/refs/resolve?ref=... in polylogue/daemon/http.py; route contract is recorded in polylogue/daemon/route_contracts.py.
    • Supported kinds: session, message, block, assertion, and runtime-transform refs are covered. The focused API test resolves session/message/block, evidence refs, assertion, and context-snapshot:<id>:session_start.
    • EvidenceRef behavior: tested through session_id::message_id and session_id::message_id::0, preserving the original evidence ref in the response.
    • Unsupported refs: commit:abc123 returns a bounded unresolved payload with kind/caveat rather than broad search.
    • Docs: docs/search.md documents PublicRefResolutionPayload, Polylogue.resolve_ref(), MCP resolve_ref, and /api/refs/resolve.

    Verification run from a fresh worktree on current master:

    devtools test tests/unit/api/test_facade_contracts.py -k resolve_ref -q
    # 3 passed, 214 deselected
    
    devtools test tests/unit/cli/test_query_verbs_runtime.py -k direct_ref -q
    # 1 passed, 33 deselected
    
    devtools test tests/unit/daemon/test_web_reader.py -k ref_resolve -q
    # 1 passed, 121 deselected
    
    devtools test tests/unit/mcp/test_server_surfaces.py -k resolve_ref -q
    # 1 passed, 72 deselected

    Residuals such as richer external GitHub/file/commit lookup or recursive graph expansion remain explicit non-goals for this issue and should be opened separately only if product pressure appears.

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

    area:cliarea:corearea:daemonarea:mcptheme:analysistheme:evidence-trusttype:feat

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions