Skip to content

fix(mcp): Censure the MCP surface's in-process durable writes - #5442

Merged
Sinity merged 1 commit into
masterfrom
work/wave-t
Sep 22, 2026
Merged

Sinity merged 1 commit into
masterfrom
work/wave-t

Conversation

@Sinity

@Sinity Sinity commented Sep 22, 2026

Copy link
Copy Markdown
Owner

Summary

polylogue/mcp had no mutation-authority rule at all, so an in-process durable write from that surface passed every gate. Beads: polylogue-gjwto, polylogue-r29bv (both advanced, neither closed).

Problem

The only layering rule for polylogue/mcp disallows storage|pipeline|sources. So mcp/server_cutover.py:2229 importing polylogue.annotations.importer — the module the CLI rule explicitly names as an executor driver, driving OperationExecutor against user.db in-process — passed cleanly.

That is the MCP twin of the CLI writer recorded in #5310: the same defect, one surface over from where it was fixed.

Premise corrections, by measurement

_execute_facade_mutation has 20 call sites, not 9. The figure I briefed this lane with was the first nine of twenty — a truncated scan reported as a complete population. A 2026-09-22 bead note saying "twenty… +1" is also wrong. AST census at eab6e8507: 20 call sites in 20 distinct methods, 1:1 —

3794, 6526, 6553, 6615, 6652, 6698, 6864, 6901, 6986, 7058,
7083, 7122, 7388, 7431, 7503, 7548, 7594, 7643, 7663, 7722

All 20 are MCP-reached; zero are CLI-reached. The three r29bv CLI writers (setting / note / annotations) landed before this base, and the layering baseline shrank 3 -> 2 accordingly. The remaining work is an MCP-side question, not a CLI one.

Solution

  1. docs/plans/layering.yaml — a third mutation-authority rule for polylogue/mcp. Proven to fire: before baselining, gate layering exited 1 with the exact violation.
  2. A baseline entry with its reviewed reason (D2 is genuinely blocked — _resolve_user_state_target is still on the facade at archive.py:6721 with 5 call sites; PR refactor(operations): Move ref resolution and anchor reads on every surface #5370 moved resolve_ref, not this).
  3. tests/unit/api/test_facade_mutation_census.py — pins the 20-method inventory shrink-only, plus surface reach. This covers the facade-routed spelling that an import rule structurally cannot see.

Verification

devtools verify --quick     ->  PASSED
gate layering               ->  exit 0, baselined_count: 215
devtools test tests/unit/api/test_facade_mutation_census.py  ->  PASSED
devtools render all --check ->  0 "out of sync"

Both mutations executed with real failures: a planted CLI caller failed test_no_cli_module_reaches_a_facade_mutation naming the file; dropping add_mark failed the inventory test naming it. The probe file was untracked and still caught, because the census walks with rglob rather than git ls-files — the exact failure mode that let a recent ui ratchet stay green with a live violating file on disk.

No production Python changed, so the derived identity cannot move.

Two AC-REWRITEs

1. "Growing the baseline is refused by the ratchet" is false (r29bv AC6, gjwto AC2). verify_layering.py:142-144 says so plainly: the count shrinks "without an explicit edit to this file (and that edit is the thing code review looks at)." It is a review convention, not a mechanical refusal — confirmed by history (2 -> 3 -> 2) and by this edit.

2. gjwto AC2 contradicts gjwto item 1. AC2 wants the baseline to shrink to zero; item 1 wants the rule extended so facade writes become visible. Making a previously-invisible write visible necessarily adds an entry — D1 itself grew the baseline 0 -> 2, and this change grows it 2 -> 3 for the same reason and by the same intent. Read as a prohibition on growth, AC2 forbids the rule extension its own bead demands. It should read: no entry may be added for a write that was already visible.

Residual

This covers the direct-import half at MCP. The 20 facade-routed writes remain, gated on D2 — an MCP-owner decision about requiring a running daemon — which both beads explicitly instruct a lane not to attempt.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy

The mutation-authority ratchet covered polylogue/cli and (since decision D1)
polylogue/api, but never polylogue/mcp. The writes finished moving there: at
eab6e85 all twenty surviving _execute_facade_mutation call sites in
polylogue/api/archive.py are reached from polylogue/mcp and none from
polylogue/cli, so the entire remaining in-process writer population sat behind
the one surface no rule watched. polylogue/mcp/server_cutover.py:2229 also
imports polylogue.annotations.importer directly -- the MCP twin of the CLI
writer #5310 recorded -- and passed every gate, because the existing
polylogue/mcp rule disallows only storage/pipeline/sources.

Adds the third mutation-authority rule and records that import in the
baseline with its reviewed reason (decision D2, still blocked:
_resolve_user_state_target remains on the facade at archive.py:6721; PR #5370
moved resolve_ref, not this).

An import rule cannot see the facade-routed spelling of the same write, so
tests/unit/api/test_facade_mutation_census.py pins the half it structurally
misses: the twenty caller methods, shrink-only, plus their surface reach. A
CLI command re-routed through Polylogue.add_tag goes red there while the
import ratchet stays green, since the CLI is allowed to import polylogue.api.

Verification:
  devtools gate layering -> exit 0, count:0, baselined_count:215
    (before the baseline entry: exit 1, violations:[polylogue/mcp/
     server_cutover.py -> polylogue.annotations.importer] -- the rule fires)
  devtools verify --quick -> PASSED
  devtools test tests/unit/api/test_facade_mutation_census.py
    tests/unit/devtools/test_layering_gates.py -> PASSED
  devtools render all --check -> 0 "out of sync"

Anti-vacuity, executed:
  planted polylogue/cli/commands/wave_t_probe.py calling poly.add_tag ->
    test_no_cli_module_reaches_a_facade_mutation FAILED naming the file.
    The probe was untracked and still detected (rglob, not git ls-files).
  dropped "add_mark" from _EXPECTED_FACADE_MUTATIONS ->
    test_the_facade_mutation_inventory_is_the_pinned_one FAILED naming it.

No production Python changed, so the derived schema identity cannot move.

Refs: polylogue-gjwto, polylogue-r29bv

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
@Sinity
Sinity enabled auto-merge (squash) September 22, 2026 22:34
@coderabbitai

coderabbitai Bot commented Sep 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 34 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: fc937a8f-4b73-4b8a-ba7e-4f603d88951f

📥 Commits

Reviewing files that changed from the base of the PR and between f380816 and 10482e4.

📒 Files selected for processing (3)
  • docs/plans/layering-cli-mutation-authority-baseline.json
  • docs/plans/layering.yaml
  • tests/unit/api/test_facade_mutation_census.py

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 commented Sep 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-22T22:39:28.514320Z 10482e4 PR opened
🔒 Security Review ✅ Completed 2026-09-22T22:39:18.866304Z 10482e4 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 10482e4dd9

ℹ️ 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".

@Sinity
Sinity merged commit 993cc38 into master Sep 22, 2026
3 checks passed
@Sinity
Sinity deleted the work/wave-t branch September 22, 2026 22:44
@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 5d56c3a):

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

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