Skip to content

[routing] Align ChoiceCard semantics with weaver-spec (1:N menu, not 1:1 item summary) #152

@dgenio

Description

@dgenio

Context

The weaver-spec defines ChoiceCard as a menu containing multiple SelectableItems — a bounded decision set presented to the LLM:

# Spec: ChoiceCard (1:N — menu of items)
@dataclass
class ChoiceCard:
    id: str
    items: list[SelectableItem]     # multiple items per card
    context_hint: Optional[str] = None
    metadata: Dict[str, Any] = {}

contextweaver's ChoiceCard is a compact view of a single item (1:1):

# Current: ChoiceCard (1:1 — compact view of one item)
@dataclass
class ChoiceCard:
    id: str
    name: str
    description: str
    tags: list[str] = []
    kind: str = "tool"
    namespace: str = ""
    has_schema: bool = False
    score: float | None = None
    cost_hint: float = 0.0
    side_effects: bool = False

These are semantically different types with the same name. The spec's ChoiceCard is a group/menu; contextweaver's is an item summary. This mismatch blocks spec-compliant RoutingDecision construction (#151), contract adapter round-trips (#143), and cross-repo interop.

Why it matters

Decision Required

There are two alignment strategies:

Option A: Rename + Restructure (recommended)

  • Rename current ChoiceCardItemSummary (or CompactItem) — it represents a single-item compact view.
  • Add a new ChoiceCard matching the spec: a group/menu containing multiple ItemSummary items.
  • make_choice_cards() now groups items into menus (the ChoiceGraph nodes already provide natural groupings).

Option B: Adapter-only

Acceptance Criteria

Implementation Notes

The ChoiceGraph DAG already provides natural groupings — each node's children are a bounded set of options. The TreeBuilder creates exactly these groups. The spec's ChoiceCard should map to one level of the graph traversal: "here are 5 groups of tools; pick a group, then pick within it."

Files likely touched:

  • src/contextweaver/envelope.py — type rename/restructure
  • src/contextweaver/routing/cards.py — rendering functions
  • src/contextweaver/context/manager.py — prompt building
  • src/contextweaver/__init__.py — exports
  • Multiple test files

Dependencies

References

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions