Skip to content

fix(mcp): relay daemon rejections; realign stale daemon tests - #5705

Merged
Sinity merged 3 commits into
masterfrom
claude/master-fixes-2
Sep 28, 2026
Merged

Sinity merged 3 commits into
masterfrom
claude/master-fixes-2

Conversation

@Sinity

@Sinity Sinity commented Sep 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes one product defect and realigns daemon and MCP tests that fail on master because they encode superseded contracts.

Problem

A per-directory run of tests/unit/daemon and tests/unit/mcp on clean master (03c543dfe) failed 28 and 11 tests. This PR covers the clusters below. Other failures belong to named owners or need a decision; see Residuals.

Solution

  • _exception_to_error_json relays DaemonOperationRejectedError with the daemon's code and detail, as the CLI does.
  • New tests/infra/mcp.py::daemon_served_runtime_services runs the real operation stack on the archive's socket for MCP write tests. The load-evidence test seeds its deliveries under the daemon and measures reads without it.
  • Each stale expectation is realigned; the chunk-cost test converges one warm-up chunk and measures a steady-state chunk.

Verification

devtools test over the affected daemon and MCP tests plus the MCP error-translation tests: 165 passed, 1 failed (receipt 20260928T000820Z-focused-test-736375-35660df1, pre-rebase). The one failure is test_working_dir_demand_withholds_profile_readiness, tracked in polylogue-6remh. The rebase kept master's own fix to test_convergence_debt_alert.py and dropped this branch's change to that file. No other conflicts.

Review follow-up (f189af7): WatchDefinitionError declares invalid_watch_definition. MCP reports an undeclared (prose) rejection code as rejected. DaemonClient keeps a pre-dispatch refusal's public detail. devtools test tests/unit/mcp/test_tool_error_isolation.py …::test_skewed_write_refusal_is_pre_dispatch_not_an_indeterminate_mutation tests/unit/daemon/test_standing_queries_default_evaluator.py passed (receipt 20260928T003051Z-focused-test-966381-9c978486). devtools schema closure: archive/query/watch_definition.py is IN, so this lands before a rebuild.

Residuals

🤖 Generated with Claude Code

https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4

Sinity and others added 2 commits September 28, 2026 02:19
A daemon rejection reached MCP callers as 'internal error
(DaemonOperationRejectedError)', dropping the typed code and detail the
daemon returned, for example why a saved view cannot be watched. MCP now
relays both, as the CLI does.

Public archive writes are daemon-owned since #5550, so MCP tests that
write now run against the real operation stack through a shared
tests/infra/mcp.py helper.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
- expect an unavailable snapshot when no rich observation exists (#5621);
- let the converger test double accept derivation_barrier (#5664);
- expect the request model's normalized mark payload;
- measure a steady-state chunk: the first chunk after seeding also
  prunes the seeding's raw-existence journal, one trigger per row (#5657);
- inject the thread-insight failure at the ArchiveStore the route reads.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 28, 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-28T00:35:01.016301Z f189af7 New commits
ℹ️ 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: 208519ee4c

ℹ️ 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/server_support.py Resolved
Comment thread polylogue/mcp/server_support.py Resolved
WatchDefinitionError declares invalid_watch_definition, so the daemon
rejects an unwatchable view under a stable token instead of its prose. A
rejection that declares no code is reported to MCP as 'rejected'. The
client keeps the public detail of a pre-dispatch refusal instead of
repeating its code.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
@Sinity
Sinity enabled auto-merge (squash) September 28, 2026 00:36
@Sinity
Sinity merged commit 2c6d36b into master Sep 28, 2026
3 checks passed
@Sinity
Sinity deleted the claude/master-fixes-2 branch September 28, 2026 00:36
Sinity added a commit that referenced this pull request Sep 28, 2026
## Summary

A degraded live batch now returns before it touches the archive, and
five stale daemon test expectations match current contracts.

## Problem

These failures are from a clean-master run of `tests/unit/daemon` (base
`03c543dfe`), outside the clusters that PR #5705 and the master-fix
owner cover.

- **Product: degraded ingest still hit the archive.** `_ingest_files`
ran `require_cursor_authority()` before its `is_fully_degraded()`
short-circuit. That gate reads the archive's existence journals on every
call. Under an event burst, a degraded daemon therefore did the per-file
archive access the short-circuit exists to prevent (#1003). On
unreadable tiers it raised `CursorAuthorityBlockedError` instead of
skipping
(`test_ingest_files_short_circuits_under_burst_after_degraded`).
- **Stale tests:**
- The evidence-summary test patched `http.archive_read_context`, but the
route (moved in #5550) imports it from `archive.query.transaction` at
call time, so the injected lineage failure never fired.
- The structural-error preflight test placed a stub `index.db` in the
archive root without a source tier. The #5657 source-selection gate
correctly blocks that archive before the full parse the test drives.
- The "healthy" raw-materialization fixture had zero raw artifacts,
which #5491 classifies as unmeasured, never ready.
- The component-metadata test predates the `completed_at` and
`collection_duration_s` fields.

## Solution

- The degraded check now runs first. The authority gate and refused-path
filtering follow in their original order, so a non-degraded batch
behaves as before.
- Each stale test is realigned as described in the commit messages.

## Verification

- `devtools test tests/unit/daemon/test_status_unmeasured.py
tests/unit/daemon/test_status_observations.py
tests/unit/daemon/test_schema_preflight.py
tests/unit/daemon/test_daemon_http.py`: `64 passed, 1 failed` (receipt
`20260928T002626Z-focused-test-923898-aafe19be`). The one failure,
`test_daemon_status_names_every_halted_unit_and_is_not_ok`, is left as
it is on master; see Residuals.
- `devtools schema closure polylogue/sources/live/batch.py`: IN, so this
must land before a rebuild.

## Residuals

Still red on master, and not addressed here:
- `test_daemon_status_names_every_halted_unit_and_is_not_ok`: an
initialized empty archive has never had a green `ok` baseline since
#5491. Pinning collectors healthy was not enough, so this needs its own
diagnosis.
- `test_drive_phased_matches_ordinary_document_growth`: no
asserted-authority revision with a predecessor.
- `test_daemon_watcher_hints_wake_fair_intake_and_canonical_derivation`:
intake discovers no source carrier.
- polylogue-6remh: periodic profile ticks starve demand.

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

https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Sinity added a commit that referenced this pull request Sep 28, 2026
Both fail on origin/master 5312edb as well. The relayed 401 keeps its
code as the rejection outcome while the message is the ingress detail
(#5705), and startup recovery now re-applies a dead operation's plan
convergently (#5688), so the no-replay check counts only the client's
resend.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
Sinity added a commit that referenced this pull request Sep 28, 2026
…5729)

## Summary

Fixes six tests that fail on master and one intake bug. Five tests
encoded contracts that earlier PRs changed on purpose, and are
realigned. The intake bug: a SQLite database that could not be read at
probe time was excluded for good.

## Problem

A focused run on `7e5b96e15d` failed six tests:

| Test | Broken by | Cause |
| --- | --- | --- |
| `test_live_full_ingest_offloads_sync_work_to_keep_loop_responsive` |
#5557 | `_ingest_full_paths` now passes `prepared_json_paths`; the test
stub rejected the keyword. |
|
`test_source_only_full_ingest_streams_admitted_zip_members_without_decoding`
| #5557 | #5557 removed `_detect_provider_from_raw_bytes` from
`live.batch`, and `monkeypatch.setattr` failed on the missing name. |
| `test_every_planned_path_is_accounted_for`,
`test_offered_bytes_split_puts_a_refused_file_in_the_refused_bucket` |
#5557 | #5557 retains a JSON document of any shape and lets the parser
record unsupported-shape evidence. The `notes.json` fixture meant to be
refused therefore succeeds. |
| `test_authentication_refusal_is_not_an_indeterminate_mutation` | #5705
| The exception text is now the daemon's detail (`machine authentication
required`), not the code. |
| `test_restart_recovers_indeterminate_mutation_without_replaying_it` |
#5688 | Startup recovery now resolves an `unknown` run by convergent
replay, so the restarted daemon applies once more. |

Intake bug: the Codex, Hermes and Antigravity recognizers catch
`sqlite3.Error`/`OSError` and answer "not ours".
`classify_pre_acquisition` turns that answer into an exclusion, and
`_mark_excluded_cursor` records `excluded=True`. A database that is
locked or unreadable during the probe (EACCES, SQLITE_BUSY/CANTOPEN) was
never retried while its observation stayed unchanged. #5724 had guarded
only the cold-build baseline against this.

## Solution

- Tests: accept `prepared_json_paths` in the stub. Point the ZIP
no-decode guard at `detect_provider_from_path_sample_evidence`. Refuse a
JSONL record stream that no origin claims instead of a JSON document.
Assert `rejected.value.outcome == "unauthorized"`. In the restart test,
count the one startup replay and check that the retried request id does
not dispatch again.
- Intake: `classify_pre_acquisition` probes a SQLite path before
excluding it and raises a retryable read fault. The batch records that
fault as an ordinary retryable failure. Bytes that are not a database
stay excluded. The baseline's own probe and `_retryable_read_fault` move
into `batch_support`, so intake and the baseline apply the same rule.
The baseline branch those helpers made dead is removed.

`batch.py`, `batch_support.py` and `production_baseline.py` are in the
derived schema-identity closure (`devtools schema closure`), so this
must land before a rebuild starts.

## Verification

- `devtools test tests/unit/sources/test_live_watcher.py
tests/unit/sources/test_raw_admission_settlement.py
tests/unit/sources/test_live_batch_support.py
tests/unit/sources/test_production_baseline.py
tests/unit/sources/test_cold_build_generation.py
tests/unit/daemon/test_daemon_operation_route.py`: `418 passed`, 1
flaky. The flaky test was
`test_cancelled_long_delete_retains_writer_until_blocked_apply_releases`:
a 25 ms deadline returned `completed` under load, and the test passed
when rerun alone.
- After the final baseline cleanup: `devtools test
tests/unit/sources/test_production_baseline.py
tests/unit/sources/test_cold_build_generation.py`: `64 passed`.
- `devtools verify --quick`: `PASSED` (includes mypy, patterns,
schema-closure).
- The new
`test_unreadable_state_database_stays_retryable_instead_of_excluded`
drives a mode-0 `state_5.sqlite` through `_ingest_full_paths_sync`.
Without the probe, the file is not failed and gets an excluded cursor.

## Residuals

- If a lock clears between the recognizer's failed read and the probe,
the file is still excluded. That window was already accepted for the
baseline in #5724. Closing it needs the recognizers to propagate read
faults.
- The unbounded JSONL session scan is filed separately and is not
changed here.

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

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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