Skip to content

fix: align CLI surface corpus contracts - #4226

Merged
Sinity merged 1 commit into
masterfrom
fix/corpus5-surface
Aug 26, 2026
Merged

Sinity merged 1 commit into
masterfrom
fix/corpus5-surface

Conversation

@Sinity

@Sinity Sinity commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Summary

Round-2 corpus-fix lane (surface cluster): fixes the MCP structured-filter regression and updates genuinely stale CLI expectations from the corpus run 2b00a953 failure set.

Problem

devtools verify --all (corpus run 2b00a953) failed 9 surface-cluster tests. One was a real regression: build_query_spec passed descriptor-internal parameter names through normalize_query_params into SessionQuerySpec.from_params, which consumes the public query vocabulary — every structured MCP filter was silently discarded (caught by test_query_cases_agree_across_public_adapters). The rest were stale expectations (unified row fields, basename display, relative time, priced/exact cost status precedence, embed activation fixture hashes, plain-snapshot merged fields).

Solution

  • polylogue/mcp/query_contracts.py: stop converting public names to internal names before from_params; validation still runs on the public vocabulary.
  • Updated stale expectations in test_select, test_insights, test_embed_activation, and the plain CLI snapshot.

Deliberately excluded from the lane's original output: a migration_runner.py change that removed _checkpoint_live_tier and rewrote test_backup_verify_then_migrate_tier_cli_applies_user_migration_with_receipt to assert the migration fails. That corpus failure is a real regression from #4200 (user v11 train declares runtime consumers with no durable probe adapter) and is being fixed properly in a follow-up, not enshrined.

Verification

  • devtools test tests/unit/cli/test_select.py tests/unit/cli/test_insights.py tests/unit/cli/test_embed_activation.py tests/unit/test_cross_surface_agreement.py tests/unit/mcp/test_query_request_contracts.py → 110 passed, 1 failed — the failure is test_mcp_query_boundary_rejects_unknown_and_allows_only_declared_paste_alias, a pre-existing corpus failure assigned to the rest-cluster lane (untouched by this diff).
  • devtools verify --quick green in-lane.

Residuals

🤖 Generated with Claude Code

https://claude.ai/code/session_014BQsaB1NBY8mTR6yZByfMA

@Sinity
Sinity merged commit fe19586 into master Aug 26, 2026
1 of 2 checks passed
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 0e2ca9a9-1a92-43ca-a961-6482b5e54e91


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.

@Sinity
Sinity deleted the fix/corpus5-surface branch August 26, 2026 07:26

@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: df1e0fecf0

ℹ️ 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 polylogue/mcp/query_contracts.py Resolved
Comment thread tests/unit/cli/test_select.py Resolved
Comment thread tests/unit/cli/test_select.py Resolved
Sinity added a commit that referenced this pull request Aug 26, 2026
#4227)

## Summary
Fixes the corpus-red durable-migration route: archives below a tier's
adoption floor could never apply the new numbered trains (user v11 from
#4200, source v37 from #4185) through the production migrate-tier route.

## Problem (evidence)
Two defects, both introduced with recently landed trains:
1. **Stale-manifest authorization**: with an archive below the adoption
floor (e.g. user v3), `execute_durable_change_train` runs the legacy
climb to the floor — mutating the live tier — then hands the *same*
backup manifest to train backup authorization, which re-fingerprints the
live tier and dies with the misleading `migration backup receipt live
tier size mismatch` (corpus failure
`test_backup_verify_then_migrate_tier_cli_applies_user_migration_with_receipt`).
2. **Missing probe adapters**: the v11 user train declares runtime
consumers `promote_query` / `apply_query_excision`, and the v37 source
train declares `publish_source_generation` / `source_generation_census`
— none had a durable probe adapter, so even with a fresh backup the
trains failed at the proof stage with `no durable probe adapter` (also
red:
`test_continuity_migrations_have_a_deployable_cross_tier_compatibility_window[order0|order1]`).

A dispatched fix lane originally "fixed" this by deleting
`_checkpoint_live_tier` from `migrate_archive_tier` and rewriting the
CLI test to assert the migration *fails*; that was rejected at harvest
(see #4226's exclusion note).

## Solution
- The executor now stops with a typed, actionable error after the legacy
climb when a next train exists: the climb is committed and safe, and the
operator is told to take a fresh verified backup of the migrated tier
and rerun. This keeps backup authorization's exact-live-bytes binding
strong instead of weakening recovery to restore-and-replay.
- Added four probe adapters following the existing in-memory
projected-tier idiom: query promotion under a complete privacy contract,
query excision into the non-resurrection ledger, source-generation
publication of every manifest coordinate, and reconciliation census
(pending manifests report unsealable).
- Rewrote the CLI test as the honest two-step route: v3 → climb to floor
+ typed instruction (tier intact at v10) → fresh backup → train applies
v11, `query_excision_ledger` present.

## Verification
- `devtools test tests/unit/cli/test_archive_maintenance_cli.py
tests/unit/storage/test_query_objects.py
tests/unit/storage/test_durable_migrations.py` → 197 passed.
- `devtools test tests/unit/storage/test_durable_change_train.py
tests/unit/storage/test_source_items.py` → 107 passed (both
continuity-window params were red before the source probes).
- `devtools verify --quick` → all 15 gates ok.

## Residuals
- The below-floor route is deliberately two invocations (climb, then
train with a fresh backup). Single-invocation UX would need a new
authorization mode binding pre-climb evidence; not taken here to keep
the recovery contract byte-exact.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_014BQsaB1NBY8mTR6yZByfMA
Sinity added a commit that referenced this pull request Aug 26, 2026
## Summary
Round-2 corpus-fix lane (rest cluster): closes out the remaining corpus
run `2b00a953` failures — lineage/MCP/storage/daemon — and repairs the
MCP alias regression that #4226 introduced.

## Problem (evidence)
31 corpus failures across the rest cluster, classified per-failure:
- **Real regressions**: the daemon's `/api/operation` route had no
`RouteContract` entry (contract census red); MCP query alias lowering
(`_mcp_aliases` mapping every declared name to its dataclass
`spec_attr`) broke list pagination, provider/tag filters, cross-adapter
query parity, and retrieval readiness; the startup recovery read path
opened SQLite outside the controlled interruptible reader.
- **Stale expectations**: lineage validation (index v73), model runtime
(#4173), blob-GC v33 (schema evolution through v37 — test now pins
`target_version=35`, the version its DDL snapshot proves), hook carrier
identity (#4171), continuity capability catalogue (#4190), dev-loop
worker count (#4222), and others per the lane report.
- Additionally, #4226's `normalized = dict(params)` skipped
normalization entirely, silently dropping the three genuine MCP-only
alias spellings (`has_tool_use`, `has_thinking`, `has_paste_evidence`) —
`SessionQuerySpec.from_params` only reads the `filter_has_*` names.
Restored `normalize_query_params` with the alias map narrowed to exactly
those three.

## Verification
- All 40 nodeids from the corpus failure set
(`/realm/tmp/work/corpus5-failed.txt`) → **40 passed** on this branch
(rebased on master with #4226 + #4227 in).
- `devtools test tests/unit/mcp/test_query_request_contracts.py
tests/unit/test_cross_surface_agreement.py
tests/unit/storage/test_retrieval_readiness_laws.py
tests/integration/test_mcp.py` → 26 passed.
- `devtools verify --quick` → all 15 gates ok.

## Residuals
- One listed failure
(`test_submit_failure_cleans_every_admitted_future_and_reservation`) was
not reproducible in-lane and is unchanged; if it reappears in the corpus
rerun it needs its own investigation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_014BQsaB1NBY8mTR6yZByfMA
@Sinity

Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

Closing out open Codex review threads on this PR (evidence checked against master at ef10e59):

Resolving the fixed, stale and refuted threads; tracked threads stay open.

@Sinity

Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

Closing out open Codex review threads on this PR (evidence checked against master at bf68918):

Resolving every thread listed; confirmed defects are fixed under the named bead.

@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.

  • 78.F029 / P1: fixed-already at the checked revision: tests/unit/cli/test_select.py:63 targets polylogue.surfaces.query_rows with the frozen-clock fixture, and line 66 fixes its time to 2026-08-22. The asserted 16w age is now independent of the execution date.

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