Skip to content

fix: realign stale master tests and keep unreadable SQLite retryable - #5729

Merged
Sinity merged 2 commits into
masterfrom
fix/inherited-master-failures
Sep 28, 2026
Merged

Sinity merged 2 commits into
masterfrom
fix/inherited-master-failures

Conversation

@Sinity

@Sinity Sinity commented Sep 28, 2026

Copy link
Copy Markdown
Owner

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

🤖 Generated with Claude Code

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

Sinity and others added 2 commits September 28, 2026 18:36
- #5557 passes prepared_json_paths to _ingest_full_paths_sync; the
  responsiveness stub did not accept it.
- #5557 retains a JSON document at every shape, so an unrelated JSON file
  now succeeds; the admission-accounting tests refuse a JSONL record
  stream no origin claims instead.
- #5705 carries the daemon's rejection detail in the exception text; the
  auth test asserts the typed outcome code.
- #5688 resolves an unknown run at startup by convergent replay; the
  restart test counts that one replay and asserts the retried request
  does not dispatch again.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
The structural SQLite recognizers read a locked or unreadable database as
"not ours", and full intake turned that into a cursor exclusion that no
later pass revisits while the file is unchanged. classify_pre_acquisition
now probes a database before excluding it and raises a retryable read
fault, which the batch records as an ordinary retryable failure. The
cold-build baseline shared the same decision, so its own probe moves
into classify_pre_acquisition and the read-fault classifier moves beside
it.

Also retarget the ZIP no-decode guard at the detector the batch module
imports since #5557.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
@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-28T16:43:25.641412Z 47b9e4a 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: 47b9e4a72e

ℹ️ 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/sources/live/batch_support.py Resolved
@Sinity
Sinity enabled auto-merge (squash) September 28, 2026 16:44
@Sinity
Sinity merged commit 02e5d48 into master Sep 28, 2026
3 checks passed
@Sinity
Sinity deleted the fix/inherited-master-failures branch September 28, 2026 16:45
Sinity added a commit that referenced this pull request Sep 28, 2026
#5729 moved one sqlite handler in production_baseline.py and added the
retryable read-fault handler in live/batch.py. Both are classified by
retryable_read_fault on purpose, so the layering baseline is re-anchored
to them. #5722 removed the query_verbs.py site the cli-nonzero-click-exit
pattern baseline still named, so that stale anchor is pruned.

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
Sinity added a commit that referenced this pull request Sep 28, 2026
…ter merge

Master commits #5721/#5729 (already merged, unrelated to this batch)
shifted two sqlite-degradation anchor digests in
polylogue/sources/live/batch.py and
polylogue/sources/live/production_baseline.py. Pruned the one stale
anchor and declared the two new ones via
`devtools.verify_layering --prune-baselines` plus a direct baseline
edit, matching the same reconciliation already done for the first
master merge in 39f6f02.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
Sinity added a commit that referenced this pull request Sep 28, 2026
## Summary

Integrates orphaned branch `w10/s2` and cleans up an inherited red on
master. Three separate changes:

1. Adds a test that the embedded-facade writers refuse an archive whose
daemon is resident. Deletes the unused
`_require_archive_write_authority` wrapper in `api/archive.py`.
2. The OpenAPI renderer keeps security that an operation documents
explicitly, instead of special-casing one route.
3. Pre-acquisition intake reports a retryable read as a typed
`RetryableSourceReadError`, so the batch no longer adds an `except
sqlite3` degradation site. The `batch.py` anchor that #5727 admitted is
removed from the degradation baseline.

It also adds the missing `otel-genai` row (tightness 95) to the detector
table in `docs/atlas/sources-parsers.md`.

## Problem

- `w10/s2` (70ee4e97c4) added lease checks to seven API mutation routes.
Master already runs the equivalent `require_archive_write_authority`
check in each of those writers, now in `operations/facade_writers.py`.
No test drives that refusal, and the old wrapper in `api/archive.py` has
no callers.
- `test_openapi_publishes_typed_first_party_credential_contract` broke
at #5550 (da5346d). The renderer began overwriting every
declaration's `security` with the auth-policy default, which cleared the
explicit `webCredentialCookie` requirement on `DELETE
/api/web-auth/session`. #5720 (960d0ec) fixed it by hard-coding that
one method and path.
- #5729 added an `except (OSError, sqlite3.Error)` handler that degrades
to retry in `batch.py`, and #5727 admitted it to the degradation
baseline.

## Solution

- `tests/unit/operations/test_facade_writer_authority.py` holds the
daemon's `flock` on `daemon.pid` from a separate process, which is the
same token `polylogued run` holds. It then drives the
manual-continuation, context-ledger and comparative-judgment writers.
Each writer must raise `ArchiveWriterOwnershipError` naming the PID, and
must leave no `*.db` in the archive root.
- `render_openapi` uses `operation.setdefault("security", ...)`. I
compared every operation's security before and after, and the rendered
document is identical.
- `classify_pre_acquisition` converts a retryable OS or SQLite read
fault, including one from the readability probe, into
`RetryableSourceReadError(path, cause)`. Non-retryable errors propagate
unchanged, and a probe failure on bytes that are not a database leaves
the exclusion standing. `batch.py` catches the typed error, and
`production_baseline.py` records it as `revision_io_unavailable`. New
test:
`test_pre_acquisition_reports_a_retryable_read_as_its_typed_fault`.
- `batch.py`, `batch_support.py` and `production_baseline.py` are in the
derived schema closure. No rebuild has started
(`polylogue-reindex-2026.1` is open).

## Verification

- `devtools test 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/operations/test_facade_writer_authority.py
tests/unit/devtools/test_render_openapi.py`: `PASSED exit=0`
- Hosted `ci/circleci: quick-gate` on the head.

## Residuals

- The facade test covers three of the eight writers. The others need a
seeded `user.db` to reach their check.

🤖 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]>
Sinity added a commit that referenced this pull request Sep 29, 2026
Resolve conflicts in devtools/patterns/baselines/cli-nonzero-click-exit.txt
and docs/plans/sqlite-degradation-baseline.json: both are generated
content-anchored baselines master rewrote to the file:digest:context
format in the same window this PR pruned/re-anchored entries in. Take
master's rewritten baseline verbatim for the cli-nonzero-click-exit
pattern (this PR's own removal of the query_verbs.py anchor was already
independently reflected there); keep this PR's own new batch.py anchor
in the sqlite-degradation baseline (added deliberately in #5729/this
branch's prior commit for the classifier-scope change to
retryable_read_fault) and drop the stale duplicate production_baseline.py
entry master already relocated.

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 29, 2026
The merge with origin/master carried the merge branch's own added anchor
for polylogue/sources/live/batch.py (digest 5b632e9d..., added earlier
in this PR's own #5729/re-anchor commit) forward unchanged, but master's
independent edits to batch.py in the same window changed that handler's
normalized text so the anchor no longer reproduces. `devtools gate
layering` on the merged head reports it stale
(sqlite_degradation_shrunk); pruned per its own suggested fix.

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 29, 2026
## Summary
`polylogue facets` now sends every typed operation-kernel failure
through `exit_for_read_failure`, the path every other read route already
uses.

## Problem
`_fetch_daemon_facets` caught only `OperationUnavailableError`. Any
other `OperationKernelError` escaped the Click command as a raw
exception: a dropped daemon connection (`daemon_transport_error`), a
deadline, a cancellation, or an invalid request. The operator got no
exit status for the failure class, no call id and no remedy. This
residual came from the salvage ref `work/luna-x1`. Its other hunks are
already on master.

## Solution
The existing `OperationUnavailableError` → `DaemonRequiredError`
conversion stays. A second `except OperationKernelError` hands every
other typed failure to `exit_for_read_failure`.

## Verification
- `devtools test tests/unit/cli/test_read_failure_exit_codes.py
tests/unit/cli/test_machine_main.py` result: `33 passed`, `PASSED
exit=0`.
- The new test
`test_the_facets_route_leaves_through_the_read_failure_terminal` drives
the real `facets` CLI route for the transport, deadline, cancelled and
invalid-request cases. It fails if the new branch is removed.
- Master's quick gate was red on two stale baselines, and this PR fixes
them forward in a second commit. First, the layering sqlite-degradation
baseline is re-anchored to two handlers from #5729: the one it moved in
`production_baseline.py` and the retryable read-fault handler it added
in `live/batch.py`. Both are deliberately classified by
`retryable_read_fault`. Second, the `query_verbs.py` anchor that #5722
made stale is pruned from `cli-nonzero-click-exit`.
- `devtools verify --quick` result: `PASSED exit=0`, with all 12 gates
ok.

## Residuals
None known.

🤖 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