Skip to content

feat: replay all continuity scenarios over real MCP stdio transport - #3060

Merged
Sinity merged 3 commits into
masterfrom
feature/gpt-pro/lin02-continuity
Jul 18, 2026
Merged

Sinity merged 3 commits into
masterfrom
feature/gpt-pro/lin02-continuity

Conversation

@Sinity

@Sinity Sinity commented Jul 17, 2026 •

Copy link
Copy Markdown
Owner

Summary

Revision r02 of the polylogue-t8t continuity replay slice (supersedes the r01 content previously on this branch). Replaces the surviving ContinuityScenarioSpec dataclass draft and the caller-supplied-observation-only devtools/continuity_replay.py with an executable declaration catalog that drives the real production MCP server over stdio JSON-RPC for all eight scenarios (the seven polylogue-t8t operator jobs plus the parallel-Claude incident), with exact-count pagination proofs, a six-case incident curriculum, and six executable mutation families.

Problem

r01 (the version previously on this branch) executed scenarios through the Polylogue API facade directly, not through MCP — it proved query/parser/storage behavior but not MCP discovery, transport, or response-budget behavior, and left AC items 3-5 (transcript/receipt classification, original-incident curriculum grading, and the full mutation-family set) partial. Separately, PR #3064 (test: replay MCP continuity transactions, merged) added one incremental MCP-stdio scenario (mcp-query-transaction) directly onto the still-live dataclass scaffold — narrower in scope (one scenario, not the full catalog) and architecturally incompatible with the ScenarioSpec-based rewrite both r01 and r02 make.

Solution

  • polylogue/product/continuity_scenarios.py: ContinuityScenarioSpec subclasses the existing scenarios.NamedScenarioSource seam. Eight declarations carry typed discovery requirements, coverage inventories, accepted plan signatures, exact item-identity paths, stop conditions, and call/page/aggregate/elapsed/cancellation-grace budgets.
  • devtools/continuity_replay.py: default replay path launches the production read-role MCP server as a child process via the official MCP SDK/stdio JSON-RPC, records discovery receipts (protocol version, tool/resource schemas) before running any scenario, and cross-checks a separate | count probe against enumerated item identities for every aggregate-capable terminal unit — rejecting page-local or wrapper-rewritten totals.
  • The parallel-incident scenario adds a six-case sanitized curriculum (candidate-list-oversized, wrong-corpus-assumption, weak-lexical-proxy, product-induced-hidden-grammar, and two correctly-formulated-but-execution-failed cases) planted separately from its expected grades, plus six executable mutation families (lost continuation state, capped pseudo-total, identical-call topology replay, hidden discovery, missing source coverage, unreasonable-query classification).
  • polylogue/mcp/server_prompts.py: fixes two shipped prompt recipes that advertised parser-invalid query_units expressions — unacknowledged_failures embedded since inside an action predicate instead of as the top-level argument; sessions_touching_file used a bare repo: file predicate instead of session-scoped session.repo:. New tests/unit/mcp/test_prompt_query_parity.py parses every shipped query_units recipe against the production parser and discovered tool schema so this can't regress silently.
  • tests/infra/continuity.py / continuity_mutations.py / tests/data/continuity/catalog.json: schema-v2 corpus/oracle separation. seed_continuity_archive() builds real archive tiers from planted corpus facts only; validate_continuity_population() does a direct SQLite census with no query/MCP/replay involvement; the independent oracle section is never derived from a production route.

Reconciliation performed by hand

Both r01 and r02 packets target base commit 536a53e (fix(repair): harden raw authority convergence #3046), pre-dating #3064. Applying r02's patch to current master (git apply --3way) applied continuity_scenarios.py "cleanly" by context-matching around #3064's inserted mcp-query-transaction scenario block — but that left the block behind as a dead call to the old 7-positional-argument _scenario() helper, incompatible with the rewritten 3-positional/keyword-only signature (TypeError: _scenario() takes 3 positional arguments but 7 were given at import time). Removed that stranded block: r02's all-scenario MCP-stdio replay, exact-count probes, and mutation matrix supersede what that single incremental scenario proved (an MCP transaction surviving one client-side pause/resume). devtools/continuity_replay.py and the two continuity test files conflicted directly against #3064's additions during the 3-way apply; resolved by taking r02's full replacement content in each case, since both revisions replace this architecture wholesale and #3064 built incrementally on the version being replaced.

tests/data/continuity/incident.json (the pre-existing, now fully unreferenced legacy fixture, including the row #3064 added to it) is left in place unchanged, matching both packets' own decision not to delete it without separate certification.

polylogue-t8t AC matrix (bead's own numbering)

# Criterion Status
1 Seven jobs + parallel-Claude variant Satisfied — eight declarations, all pass through MCP stdio JSON-RPC.
2 Wording, facts/coverage, independent target, discovery, refs, plan equivalence, paging/cancel/resource bounds, stops Satisfied as declaration/catalog contract.
3 Baseline transcripts/server receipts classify every failure layer Partial. Discovery/call/page receipts and mutations distinguish source-coverage, discovery, execution, projection, reasoning; no cold external-model transcript, no runner-issued MCP cancellation transcript.
4 Grade the original incident calls with the exposed curriculum Satisfied synthetically — six raw-feature cases planted separately from six expected grades; the prompt-parity fix preserves the product-induced sessions-only classification.
5 Mutation fixtures cover every named recovery/failure class Satisfied — all six execute and fail in the intended class.
6 z9gh.7 consumes this catalog as sole terminal gate Ready, not executed — corpus is parameterized and CLI documented; the authorized live-archive/cold-model/effect-evidence/SLO gate remains polylogue-z9gh.7 scope.

This PR does not close polylogue-t8t; item 6 remains polylogue-z9gh.7's scope.

Verification

  • devtools test tests/unit/product/test_continuity_scenarios.py tests/unit/mcp/test_prompt_query_parity.py tests/integration/test_continuity_replay.py → 20 passed.
  • devtools test tests/unit/mcp/test_server_surfaces.py → 83 passed (no MCP tool-surface regression from the prompt-recipe fix).
  • ruff format --check, ruff check, mypy --strict on all 9 changed/added files → clean.
  • devtools render all --check → exit 0 (no new polylogue/ module; no topology-projection regen needed).
  • Pre-push quick gate: 16/16 steps passed (format/lint/mypy/render-all/topology/layering/closure-matrix/schema/manifests/ci-workflows/doc-commands/docs-coverage/test-infra-currency/test-clock-hygiene/pytest-timeout-overrides/degrade-loudly).

Ref polylogue-t8t

@coderabbitai

coderabbitai Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 47 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9931ac04-c6bc-4775-bfcd-b8488619b479

📥 Commits

Reviewing files that changed from the base of the PR and between e3ed7ae and ca3a130.

📒 Files selected for processing (10)
  • devtools/continuity_replay.py
  • polylogue/mcp/server_prompts.py
  • polylogue/product/continuity_scenarios.py
  • tests/data/continuity/catalog.json
  • tests/infra/archive_scenarios.py
  • tests/infra/continuity.py
  • tests/infra/continuity_mutations.py
  • tests/integration/test_continuity_replay.py
  • tests/unit/mcp/test_prompt_query_parity.py
  • tests/unit/product/test_continuity_scenarios.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/gpt-pro/lin02-continuity

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 448cbb8f8b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread devtools/continuity_replay.py Resolved
Comment thread devtools/continuity_replay.py Outdated
Comment on lines +233 to +238
async def _provider_usage(self, step: ContinuityRouteStep) -> ContinuityRouteObservation:
report = await self._archive.provider_usage_report(
origin=step.origin,
limit=step.page_size,
detail=step.detail,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Scope the cost route to the target run

In any audited archive containing other token-bearing Claude Code sessions, this call aggregates their usage as well: Polylogue.provider_usage_report only accepts origin, limit, and detail, with no repository or session filter. The scenario nevertheless compares that aggregate with facts for one planted continuity run, so a healthy live archive will fail the cost scenario whenever it contains unrelated usage from the same origin. Execute this scenario against an isolated corpus or use a route that can scope usage to the target session.

Useful? React with 👍 / 👎.

Problem

polylogue-t8t needs a durable black-box spec for seven operator
continuity jobs plus the parallel-Claude incident replay, graded by an
independent oracle rather than a caller-supplied observation. PR #3060
(GPT-Pro lin-02 r01) rewrote the scaffold to run through the real
Polylogue API facade, but never proved the MCP transport, exact-count
completeness, or the original incident curriculum grading (AC 3-5
partial/remaining per the bead's own AC matrix). PR #3064 separately
added one MCP-stdio scenario ("mcp-query-transaction") on top of the
old dataclass scaffold, incrementally, without adopting the
ScenarioSpec-based rewrite.

Solution

Reconciles GPT-Pro lin-02 revision r02 (a full replacement package, not
a patch on r01) against current master, which had drifted from both
packages' common base commit via #3064's incremental scenario:

- polylogue/product/continuity_scenarios.py: ContinuityScenarioSpec now
  subclasses the existing scenarios.NamedScenarioSource seam. All eight
  jobs (seven operator jobs + parallel-Claude incident) declare typed
  discovery requirements, coverage inventories, accepted plan
  signatures, exact item-identity paths, stop conditions, and
  call/page/aggregate/elapsed/cancellation-grace budgets.
- devtools/continuity_replay.py: default replay path launches the
  production read-role MCP server as a child process and drives it
  over the official MCP SDK/stdio JSON-RPC, recording discovery
  receipts before executing any scenario. Every aggregate-capable
  terminal unit gets a separate `| count` probe cross-checked against
  enumerated identities, rejecting page-local/wrapper-rewritten totals.
- The parallel incident now carries a six-case sanitized curriculum
  (candidate-list, operator-phrase, lexical-proxy, hidden-grammar,
  and two correctly-formulated-but-failed-execution cases) planted
  separately from its expected grades, plus six executable mutation
  families (lost continuation state, capped pseudo-total, identical-
  call topology replay, hidden discovery, missing coverage,
  unreasonable-query classification).
- polylogue/mcp/server_prompts.py: fixes two shipped prompt recipes
  that advertised parser-invalid `query_units` expressions
  (`unacknowledged_failures` embedded `since` inside an action
  predicate; `sessions_touching_file` used a bare `repo:` file
  predicate instead of `session.repo:`). tests/unit/mcp/
  test_prompt_query_parity.py parses every shipped recipe against the
  production parser and discovered tool schema so this can't regress.
- tests/infra/continuity.py / continuity_mutations.py / tests/data/
  continuity/catalog.json: schema-v2 corpus/oracle separation —
  `seed_continuity_archive()` builds real archive tiers from planted
  corpus facts only; the oracle section is never derived from a
  production route.

Reconciliation performed by hand: r02's PATCH.diff (generated against
the same pre-#3064 base commit as r01) applied cleanly to
continuity_scenarios.py by context-matching around #3064's inserted
"mcp-query-transaction" scenario block, stranding it as a dead
old-signature `_scenario(...)` call incompatible with the new
constructor (7 positional args against a 3-positional/keyword-only
signature) — this is removed here since r02's all-scenario MCP-stdio
replay, exact-count probes, and mutation matrix supersede what that
single incremental scenario proved. devtools/continuity_replay.py and
the two continuity test files conflicted directly against #3064's
additions during a 3-way apply; resolved by taking r02's full
replacement content, since both r01 and r02 replace this architecture
wholesale and #3064 built incrementally on the version being replaced.

This does not close polylogue-t8t. AC 6 (z9gh.7 live-archive/cold-model
terminal gate) remains open; the catalog is corpus-parameterized and
ready for a live oracle but no live archive was accessed.

Verification

- devtools test tests/unit/product/test_continuity_scenarios.py
  tests/unit/mcp/test_prompt_query_parity.py
  tests/integration/test_continuity_replay.py -> 20 passed
- devtools test tests/unit/mcp/test_server_surfaces.py -> 83 passed
  (no MCP tool-surface regression from the prompt-recipe fix)
- ruff format --check / ruff check / mypy --strict on all 9
  changed/added files -> clean
- devtools render all --check -> exit 0, no modules added, no
  topology-projection regen needed

Ref polylogue-t8t
@Sinity
Sinity force-pushed the feature/gpt-pro/lin02-continuity branch from 448cbb8 to 1963ef8 Compare July 18, 2026 00:37
@Sinity Sinity changed the title feat: run continuity scenarios as real ScenarioSpec routes against oracle facts feat: replay all continuity scenarios over real MCP stdio transport Jul 18, 2026
Sinity and others added 2 commits July 18, 2026 03:59
Problem

A repeated logical query_units row on a later continuation page could
survive fact and evidence reducers even when the server advanced its
offset.

What changed

Preserve stable identities from returned unit rows across pages and report
the duplicate page and identity. Exercise the real registered FastMCP
query_units route for both a distinct six-page enumeration and a repeated
row with offsets advancing from 0 to 17 to 34.

Ref polylogue-t8t

Co-Authored-By: Codex <[email protected]>
@Sinity
Sinity merged commit b23c67b into master Jul 18, 2026
3 checks passed
@Sinity
Sinity deleted the feature/gpt-pro/lin02-continuity branch July 18, 2026 02:14
@Sinity

Sinity commented Sep 30, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 52.F044 / P1: fixed-already at the checked revision: Pagination records stable returned-unit identities across pages and raises duplicate_pagination_identity when a later page repeats one. The failure is raised before merged rows can be hidden by downstream evidence deduplication or first/value fact reducers. Current code: devtools/continuity_replay.py:1289; devtools/continuity_replay.py:1296.

Only the rows listed above are dispositioned. Held findings remain open.

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