Skip to content

fix(reset): confirm databases, not their transient WAL sidecars - #5810

Merged
Sinity merged 1 commit into
masterfrom
fix/reset-sidecar-confirmation
Sep 29, 2026
Merged

Sinity merged 1 commit into
masterfrom
fix/reset-sidecar-confirmation

Conversation

@Sinity

@Sinity Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner

Summary

polylogue reset refused every reset of an open database tier. The confirmed target identity now names databases, not their transient WAL sidecars. Separately, the test daemon stack stops failing under host load.

Problem

At master, 11 tests/unit/cli/test_reset.py cases (all TestReset* daemon-route cases) failed with reset targets changed since confirmation; preview the targets again (baseline agentctl job 2441; bead polylogue-6bhuy).

The CLI previews the reset targets, then submits them as expected_targets. The daemon re-resolves them in _reset_targets and compares the two sets. Both lists include -wal/-shm sidecars that exist at the moment of listing. A sidecar exists exactly while some connection has its database open. The daemon's own pinned operation read opens index.db between the CLI preview and the daemon's resolution, so the daemon's set gained index.db-wal/-shm and the comparison refused. An operator hits the same refusal whenever anything has the tier open.

Solution

  • reset_confirmation_paths in polylogue/operations/daemon_mutations.py owns the confirmed identity for both sides. It includes a sidecar only when its database is not itself a target. The CLI submits that set, and the daemon compares against it. Sidecars are still resolved and deleted with their database; they are only left out of what the operator confirmed.
  • tests/infra/daemon_operations.py: the coordinator loop now sets readiness from inside the running loop (loop.call_soon), as the production writer loop does. Before, a bridge admitted before run_forever could see is_running() false and refuse the startup write. The fixed 2-5 s startup and shutdown waits are replaced with waits on the thread or loop itself, bounded by pytest-timeout. The startup bridge uses the production bound. These waits failed on a loaded host (load average ~27 during these runs).

Verification

  • agentctl job start polylogue pytest_focused --workspace <wt> -- tests/unit/cli/test_reset.py tests/unit/cli/test_daemon_client.py tests/unit/api/test_writer_boundary.py tests/unit/cli/test_archive_maintenance_cli.py: job 2599, devtools test: PASSED exit=0, 130 passed.
  • agentctl job start polylogue verify_quick --workspace <wt>: job 2598, succeeded.
  • New test_confirmation_names_databases_not_their_transient_sidecars: a preview taken before index.db-wal exists is accepted after the sidecar appears. A preview that omits an added cache directory is still refused. Anti-vacuity: comparing sidecars as part of the identity refuses the first request.

Self-review

  • Sibling sites. The CLI's _archive_database_targets and the daemon's _reset_targets both list sidecars. Both now reduce through the one helper, so they cannot disagree about identity. The duplicated target listing itself predates this PR and is unchanged.
  • Destructive scope. Deletion is unchanged: the daemon deletes exactly the targets it resolves, including sidecars, as before. A sidecar whose database is absent stays in the identity, so an unexpected orphan still refuses.
  • Interruption. No new multi-step state. Confirmation is still checked before the audited actuator runs.
  • Test harness. The removed wall-clock waits were not assertions; each was a startup or shutdown bound that pytest-timeout already covers. Shutdown still raises if the writer does not drain.
  • Derived identity. Neither production file is in the derived-identity closure.

Residuals

Other daemon-stack tests that were load-sensitive may have causes beyond these waits. They are tracked in the sibling master-health PRs.

🤖 Generated with Claude Code

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

A SQLite -wal/-shm sidecar exists while any connection has its database
open. The daemon's own pinned read opens the index between the CLI
preview and the daemon's target resolution, so the resolved set gained
sidecars the preview never listed and every reset of an open tier was
refused as "reset targets changed since confirmation".

reset_confirmation_paths now owns the confirmed identity for both the
CLI and the daemon: a sidecar whose database is also a target is deleted
with it but is not part of what the operator confirmed.

The test daemon's coordinator loop now signals readiness from inside the
running loop, as the production writer loop does, and waits on thread
events rather than fixed 2-5 s wall clocks that fail under host load.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
@Sinity
Sinity enabled auto-merge (squash) September 29, 2026 08:36
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 29, 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
🔒 Security Review ✅ Completed 2026-09-29T08:39:52.101900Z a6cc65c 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.

@Sinity
Sinity merged commit a0f51df into master Sep 29, 2026
2 of 3 checks passed
@Sinity
Sinity deleted the fix/reset-sidecar-confirmation branch September 29, 2026 08:40
Sinity added a commit that referenced this pull request Sep 29, 2026
## Summary

Realigns 11 tests that fail on master. Each encodes a contract that a
merged PR changed on purpose. Production code is unchanged.

## Problem

These tests failed at master 1beb2e5 (baseline agentctl job 2441,
`devtools test --on-default-branch`). Beads: polylogue-cp3z5 (lineage
validation) and polylogue-bn8gg (facade `record_context_ledger`). The
other items are in polylogue-6bhuy, which also lists items owned by
sibling PRs.

| Test | Contract change |
| --- | --- |
| `tests/unit/devtools/test_lineage_validation.py` (all 21) | The
hand-built index lacks `messages.fields_digest` and the derived schema
identity stamp. Every reader refuses an unstamped derived tier as
`SchemaSkew` ("expected <digest>, found None"). |
| `test_facade_contracts.py::test_no_undiscovered_async_methods` |
`record_context_ledger` (#5722) and `get_session_summaries` are in no
contract set. |
|
`test_facade_contracts.py::test_archive_facet_buckets_count_unique_sessions_for_duplicate_hits`
| #5703 moved deduplication into the search-scope walk. The unscoped
path yields each session once by construction, so the duplicate case is
a search hit. |
|
`test_preamble.py::test_precompact_uses_scheduler_and_records_real_boundary_context`
| The precompact path awaits `record_context_ledger` (#5722). The mock
was a plain `MagicMock` attribute, and the other test in the file set it
twice. |
|
`test_manual_contract.py::test_published_examples_use_live_operation_vocabularies_and_preconditions`
| `read`'s `view` is now `Literal[...] \| None`. `typing.get_args` on
the union yields the Literal and `NoneType`, not the members. |
|
`test_write_effects.py::test_deferred_insight_invalidation_follows_a_repointed_index`
| #5727 moved profile invalidation into the admitted transaction, so no
deferred reopen by path is left to follow. |
|
`test_mutation_actuators.py::...::test_production_tag_and_metadata_writes_use_user_overlay_policy`
| #5727 made tag writes that change a row invalidate the search cache. |
|
`tests/unit/cli/test_status.py::...::test_sinex_status_reads_the_active_archive_file_set`
| #5722: publication mode comes from the loaded config, and the file set
from `resolve_runtime_config()`. |
|
`tests/unit/cli/commands/test_status.py::...::test_configured_override_url_is_not_refused`
| #5722: a non-built-in daemon URL is read over HTTP `GET /api/status`.
|

## Solution

Each test now exercises the current contract and keeps its anti-vacuity
condition:

- **Lineage validation.** The fixture declares `fields_digest` and
stamps the current identity with the production
`stamp_derived_schema_identity`.
- **Facade.** Both methods are classified. `get_session_summaries` gains
coverage in `test_archive_tiers_api_reads_native_sessions`: requested
ids key the result, and an unresolved id is omitted. The facet test
drives two hits for one session through the search scope.
- **Manual contract.** The vocabulary is read through unions, and the
test asserts `"messages"` is in it, so an empty read cannot pass.
- **Write effects.** The test now proves the invalidation commits and
rolls back with the caller's transaction. An effect that opened its own
connection would survive the rollback.
- **Tag overlay.** Expects exactly one invalidation per changed tag
write, and none for metadata writes or the no-op re-add.
- **Status.** The URL-override test runs a real local HTTP server and
asserts only `/api/status` was requested.

## Verification

- `agentctl job start polylogue pytest_focused --workspace <wt> --
tests/unit/devtools/test_lineage_validation.py
tests/unit/api/test_facade_contracts.py
tests/unit/context/test_preamble.py
tests/unit/agent_integration/test_manual_contract.py
tests/unit/archive/test_write_effects.py
tests/unit/operations/test_mutation_actuators.py
tests/unit/cli/test_status.py tests/unit/cli/commands/test_status.py`:
job 2632, `devtools test: PASSED exit=0`, 582 passed. Five tests passed
only on rerun. Each failed first with `DaemonWriterOwnerLoopStopped ...
daemon.operation_journals.startup` or a 5 s bridge `TimeoutError` in the
test daemon stack; that race is fixed in #5810.
- `agentctl job start polylogue verify_quick --workspace <wt>`: job
2633, succeeded.

## Self-review

- **Production route.** Each rewritten test calls the production
function (`stamp_derived_schema_identity`, `_invalidate_insights_effect`
on a real connection, `_status_operation_result` against a real HTTP
listener, `ArchiveStore` tag writes). None asserts a mock's own
behaviour.
- **Loosening.** No assertion was dropped. The facet and write-effects
tests change input shape to match the current route, and each keeps a
condition that fails if the named behaviour regresses.
- **Scope.** Test-only; no derived-identity closure file changes.

## Residuals

None known for these tests. The daemon-stack startup race behind the
five reruns is addressed in #5810.

🤖 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