Skip to content

feat: conversation fabric types, P0 CDP spike, and Grok provider discovery - #9

Open
MrJ55 wants to merge 6 commits into
hanzili:mainfrom
MrJ55:feat/fabric-types-p0-p2
Open

feat: conversation fabric types, P0 CDP spike, and Grok provider discovery#9
MrJ55 wants to merge 6 commits into
hanzili:mainfrom
MrJ55:feat/fabric-types-p0-p2

Conversation

@MrJ55

@MrJ55 MrJ55 commented Aug 6, 2026

Copy link
Copy Markdown

Summary

Adds the conversation-fabric type contracts, the P0 CDP-concurrency findings, and the P2 Grok provider discovery to comet-mcp — the first concrete steps toward the multi-provider backbone described in docs/build-plan.md and ADR 0001. No existing behavior changes; all new files.

What's included

P1 — Conversation fabric type contracts (ADR 0002, src/types/)

  • conversation.ts: ConversationEnvelope (distinct idempotency key / correlation ID), DeliveryReceipt with 7 statuses (queued|sent|accepted|completed|blocked|timed_out|unknownunknown is never silently resent, per ADR 0001 §5), append-only ConversationEvent log, Provenance (attribution is an audit control, explicitly not a safety claim), content persistence modes (full|redacted|none), conservative relay defaults (approval-required, unapproved).
  • provider.ts: normalized ProviderState union, PollResult (truthful hasStopButton; extraction-provenance flags preserve the Bug WSL Support: Add COMET_HOST and COMET_PORT environment variables #1/Bug Stop closing user's existing browser tabs on connect #2 fix lineage), TabSession (P3 reconnect/dedup anchors typed now), HealthReport (per-control hook-resolution source for P8 drift detection), ChatDriver adapter contract (open/ask/poll/stop/reset/health).

P1/P2 — Provider registry entries (src/providers/)

  • grok.ts: HIGH-confidence entry from live discovery (selectors, heuristics, state machine). Documents the verified finding that Grok's Fast model never renders a stop button — streaming state must use the "Working for Xs" indicator.
  • perplexity.ts: MEDIUM-confidence entry extracted from the existing comet-ai.ts contract + session-handoff verification (the P1 refactor seed).

P0 — CDP concurrency spike (test/integration/cdp-concurrency-spike.mjs, docs/p0-cdp-concurrency-findings.md)

  • Zero-dependency spike: 2→3→5 concurrent tabs, one CDP session per target, 60s per phase. Result: 0 failures, 0 disconnects, 0 cross-tab effects; all 5 sessions stable; latency flat (p50 ~2ms). Gate passed at the ADR 0001 target of 5 sessions. Recommended default cap: max_concurrent_tabs: 5, configurable.

P2 — Grok discovery workflow (test/integration/grok-discover.mjs, test/fixtures/grok/, docs/runbooks/grok-provider-discovery.md)

  • Offline/on-demand selector miner (not in the hot path) with live PONG validation, state fixtures (idle/typing/streaming/completed), and a --diff mode that re-runs discovery and diffs the provider entry against the previous run (workflow step 9).

Docs

  • docs/build-plan.md, ADR 0001 + 0002, design syntheses (00–02), reference docs, runbook.

Notes for reviewers

  • tsc --noEmit passes with both provider entries consuming the shared types.
  • The type layer is declarations only — the event-log store, concrete ChatDriver implementations, and the Perplexity refactor are next (P1 runtime work).
  • Fixture HTML files are sanitized snapshots (scripts/styles/svg stripped); they capture structure for synthetic tests.
  • test/integration/out/ run artifacts are gitignored as regenerable.
  • Verification: PONG round-trip against live grok.com in the authenticated Comet profile (Chrome/150.0.7871.230), three consecutive discovery runs with a clean diff.

Related

  • ADR 0001: Browser-tab transport and relay defaults
  • ADR 0002: Conversation fabric type contracts
  • Build plan: docs/build-plan.md

MrJ55 added 6 commits August 6, 2026 10:09
getAgentStatus truncated long answers to their final fragment and could get
stuck reporting WORKING after the answer finished streaming.

Fixes:
- Join ALL [class*="prose"] blocks with containment dedup instead of taking
  only the last element - long answers are returned in full, without
  duplicated nested content.
- Raise the response cap from 8000 to 30000 chars.
- Completion detection: "Ask a follow-up" + prose wins over the
  working-text heuristic, so answers whose text contains words like
  "Working"/"Searching"/"Analyzing" no longer leave comet_poll stuck on
  WORKING.
- Harden getAgentStatus against undefined CDP evaluate results (dead tab,
  navigate race, closed browser) so callers never crash on status.toUpperCase().

Verified end-to-end against live Perplexity threads (search mode) through the
MCP gateway: comet_poll returns the complete, deduplicated answer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant