Skip to content

fix(storage): settle FTS in its publication; delete dead parse caches - #5844

Merged
Sinity merged 6 commits into
masterfrom
feat/one-publication-path
Sep 29, 2026
Merged

Sinity merged 6 commits into
masterfrom
feat/one-publication-path

Conversation

@Sinity

@Sinity Sinity commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

Delete three predecessors of the one publication route and move message FTS settlement into the publication that writes it.

  • The daemon census parse stage is gone: CensusParseStage, the polylogue/daemon/parse_prefetch.py shim, RawParsePrefetchCache and every prefetch_cache parameter, the four daemon_parse_stage_* settings, their docs and baseline entries (polylogue-rykzt, reusing salvage commit bcfb374).
  • The live watcher's byte-keyed prefetch cache is gone: LiveParseStage.warm, LiveParsePrefetchCache, LiveParseCandidate, live_parse_worker, live_parse_and_shard_worker and batch._live_parse_stage_candidates.
  • Revision replay and membership replay repair the FTS rows of the session they write in the same transaction. Every ingest batch runs the FTS repair effect before its commit. The caller-side deferral and after-pass repairs are removed (6xcqj F07).

Problem

  • Nothing in polylogue/ or devtools/ constructed CensusParseStage or DaemonParseStage. Every RawObservationReplacement was built with payload=None, so the RawParsePrefetchCache plumbing never received a cache. The live warm()/LiveParsePrefetchCache path had no production caller either. The watcher prepares through warm_paths/prefetch_paths, and the writer consumes sealed carriers through pop_path. Only tests drove these paths, and one test (test_prefetch_cache_thread_safety.py) stress-tested a cache that production never filled.
  • The live batch passed defer_fts=True to apply_raw_revision_replay and apply_raw_membership_classification with manage_transaction=True. Each write therefore committed its blocks without FTS rows. The batch then repaired all session ids in a separate transaction after its loop. A kill between those points left sessions committed but unsearchable, with nothing recording the missing rows. The Codex state branch (archive.commit() mid-loop) committed earlier records in the same state.
  • The ingest batch took a repair_message_fts switch. parse_from_raw turned it off whenever there was no execution coordinator, then called repair_message_fts_bulk once after all batches. Each batch commit in between published sessions without FTS rows.
  • repair_message_fts_index_sync(record_exact_snapshot=...) and suspend_fts_triggers_sync(mark_stale=...) accepted parameters they discarded (del record_exact_snapshot, del mark_stale), "retained for caller compatibility".

Solution

  • Cherry-picked bcfb374 and resolved it against master. The salvage branch still carried daemon_parse_stage_warm_timeout_seconds and aar35's retired Drive/hook rows. Master's stall-report rename and aar35 deletions were kept. The remaining census-stage references in the legacy-prose-logging baseline and in docs/design/convergence-simplification-inventory.md were updated.
  • Deleted the live cache classes and functions, the stage's cache and shard_build_failure_count, and the tests that only drove them. The equivalence tests that asserted len(stage.cache) == 0 still run through the path route, which they already used.
  • revision_governance.apply_raw_revision_replay and apply_raw_membership_classification now always call repair_message_fts_index_sync for the written session (except under bulk_build, which rebuilds FTS archive-wide at readiness). assert_session_fts_exact_sync loses allow_pending. defer_fts is removed from both functions, the two ArchiveStore wrappers, publish_ingest_cohort (no caller passed it) and the live batch. The batch's after-loop repair is deleted.
  • repair_message_fts is removed from process_ingest_batch, _process_ingest_batch_sync, _commit_sync_ingest_side_effects, ParsingService.parse_from_raw and parsing_workflow.parse_from_raw. repair_message_fts_bulk, ParseResult.fts_repair_session_ids and the now-unused _ConnectionBackendLike protocol are deleted with them. The write-effect payload key stays for its one remaining user: session deletion, which clears FTS rows itself before the rows they index are gone.
  • The discarded record_exact_snapshot and mark_stale parameters are removed along with their callers.

Derived-identity closure (devtools schema closure). These changed production files are IN: polylogue/archive/write_effects.py, polylogue/config.py, polylogue/pipeline/parsed_tree_size.py, polylogue/pipeline/services/ingest_batch/_models.py, polylogue/sources/live/batch.py, polylogue/sources/live/parse_prefetch.py, polylogue/sources/live/watcher.py, polylogue/sources/revision_backfill.py, polylogue/storage/fts/fts_lifecycle.py, polylogue/storage/sqlite/archive_tiers/archive.py, polylogue/storage/sqlite/archive_tiers/revision_application.py and polylogue/storage/sqlite/archive_tiers/revision_governance.py. The deleted polylogue/sources/census_parse_stage.py and polylogue/daemon/parse_prefetch.py also leave it. This PR moves the candidate derived schema identity, so it must land before any rebuild starts.

Verification

Final head 0a9e1f1 (rebased onto 5ebcfe5):

  • agentctl job start --workspace /realm/worktrees/polylogue-publication-path polylogue verify_quick: job 3702, verify: PASSED exit=0 at head 0a9e1f1.
  • agentctl job start --workspace /realm/worktrees/polylogue-publication-path polylogue pytest_focused -- <45 files>: job 3703 at head 0a9e1f1. The full selection had 16 failures under a narrowed one-worker pool slot. devtools reran them alone: 11 failed, 5 passed. The files are every edited test file, plus each test module that names a changed symbol (apply_raw_revision_replay, apply_raw_membership_classification, publish_ingest_cohort, repair_message_fts_index_sync, suspend_fts_triggers_sync, assert_session_fts_exact_sync, parse_from_raw, LiveParseStage, write_effects, the parse-stage settings), plus test_config.py, test_config_inventory.py, test_live_ingest_kill_recovery.py, test_incremental_retained_cold_route_characterization.py and test_raw_observation_derivation.py.
  • All 11 remaining failures are inherited. The same 11 ids fail on master 87450e4 in baseline job 3478 (11 failed, 36 passed), with the same assertion lines: test_ingest_governance::test_membership_that_becomes_eligible_after_preparation_defers_publication, test_bulk_build_lifecycle::test_fresh_shard_build_finishes_equivalent_to_retained_indexes, test_config::test_flat_daemon_bind_keys_are_refused, test_hermes_raw_identity::test_identical_hermes_profiles_persist_and_reprocess_independently, test_revision_replay::test_chain_replay_supersedes_equal_frontier_quarantined_membership_head, test_profile_writer_retirement::test_profile_mutation_census_matches_the_declared_owners, the four test_raw_observation_derivation publish tests and test_raw_materialization_parse_stage_equivalence::test_two_accepted_revisions_survive_one_periodic_profile_pass. They belong to master-green.
  • Earlier heads timed out under pool load on other tests. In each case the test passed alone on the unchanged tree: for example test_accepted_marker_inputs::test_deferred_raw_does_not_publish_marker_witness_or_pending_carrier took 16.42 s in job 3547, against 14.49 s on master in job 3542.
  • The FTS postcondition is pinned on the production route. test_live_batch_support.py drives _ingest_full_paths_sync and asserts messages_fts rows exist with no caller repair. Removing the replay's inline repair zeroes indexed.

Self-review

Final pass: pass 3, against docs/review/codex-review-guide.md, the nested polylogue/sources/AGENTS.md and polylogue/storage/AGENTS.md, and the generic list in the orchestrate worker contract. Pass 1 found four problems, and all four were fixed. Resolving the salvage branch's conflict with "theirs" had restored live_watcher_parse_stage_warm_timeout_seconds into _FLOAT_CONFIG_KEYS; this was fixed in 176d9cf. A stall-field test still imported the deleted _completed_reporting_stalls, which mypy caught. A fake of _process_ingest_batch_sync still declared the removed repair_message_fts. The focused run failed collection because a benchmark conftest was registered twice, so the benchmark was taken out of the selection. Pass 2 found that the stall assertion moved onto warm_paths did not hold on that schedule, so it was reverted. Pass 3 found nothing new.

  • 1 Siblings and owners. The FTS rule is now "the replay repairs the session it wrote". It covers both governance publishers (revision_governance.py: git grep -c 'repair_message_fts_index_sync(store._conn, \[session_id\])' = 2) and the ingest-batch write effect. Every defer_fts= caller was found by grep (2 in live/batch.py, 0 elsewhere) and removed, along with the pass-through in publish_ingest_cohort, which no caller set. The session-delete path keeps repair_message_fts: False because it clears the FTS rows itself before the delete (archive.py, delete path). It is the only remaining user of the payload key.
  • 2 The fix itself. The inline repair runs inside the replay's own transaction, before store.commit() (manage_transaction=True) or the caller's batch commit. No new exception type was added. assert_session_fts_exact_sync now always runs its parity check outside bulk_build, so a missed repair raises there instead of passing as "pending".
  • 3 Memory and limits. No new buffer. The deleted LiveParsePrefetchCache and RawParsePrefetchCache were byte-budgeted in-memory caches of parsed trees. Nothing replaces them, because production never filled them.
  • 4 Cost per unit. FTS repair is per session in both the old and new code (replace_fts_partition_sync per id). The live batch paid one extra transaction per pass before and now pays none. A session written twice in one pass is repaired twice, which is the same cost as every non-deferring caller already had.
  • 5 Interruption. This is the point of the change. A kill after a replay commit used to leave blocks without FTS rows until an after-loop repair ran, and nothing recorded that. The rows now commit together. test_live_ingest_kill_recovery.py is in the selection.
  • 6 Ordering and races. N/A for the deletions. For FTS, the repair and the write share the writer connection and transaction, so no other writer can interleave between them.
  • 7 Failure classification. A repair failure now propagates out of the replay and rolls back the write through the existing except paths, instead of failing after the commit.
  • 8 Silent outcomes. ParseResult.fts_repair_session_ids and repair_message_fts_bulk are gone. No count or receipt reported them.
  • 9 Cleanup on failure. The shard and attempt cleanup in LiveParseStage._shutdown_locked is unchanged apart from the removed cache.discard_all(), whose cache no longer exists.
  • 10 Identity and keys. No hash or ID formula changed. The derived schema identity moves, because twelve closure-IN files change (listed above).
  • 11 Lossless transforms. N/A: no copy or replay path changes what it carries.
  • 12 Degenerate inputs. repair_message_fts_index_sync still returns early on an empty id list, and a replay always has exactly one session id at that point (it raises before then otherwise).
  • 13 Consumers. Grep across polylogue devtools tests finds 0 hits each for LiveParseCandidate|LiveParsePrefetchCache|live_parse_worker|DaemonParseStage|CensusParseStage|census_parse_stage|RawParsePrefetchCache|prefetch_cache=|repair_message_fts_bulk|defer_fts|allow_pending|record_exact_snapshot|mark_stale|repair_message_fts=|daemon_parse_stage_. Docs updated: configuration.md (keys and env rows), daemon.md (parse-parallelism section), the historical design inventory (dated note), the legacy-prose and layering baselines. docs/design/daemon-core.md §9 still names _live_parse_stage_candidates; it is a measurement record at pinned commit 0f1d1cb09, so it was left alone.
  • 14 Tests and stubs. Removed tests only drove deleted code: the daemon stage suite, the cache thread-safety test, the byte-keyed warm tests, the after-pass bulk-repair test, and the bulk-target merge test. Every monkeypatched fake of a changed signature was updated (repair_message_fts_index_sync fakes lost **kwargs, and the _process_ingest_batch_sync fake lost repair_message_fts). The FTS change is pinned on the production route by test_live_batch_support.py: removing the inline repair zeroes indexed.
  • 15 Trust boundaries. N/A: no secret, path or permission handling changed.
  • Worker 1: criteria met on the production path. rykzt's deletion and 6xcqj F07 are met on the production route. The unmet criteria are named with their blockers under Residuals.
  • Worker 2: every site of the class. See items 1 and 13, and the grep counts there.
  • Worker 3: predecessor deleted. Deleted: the census stage, its shim, its config keys, docs and tests; the live cache and its tests; the FTS deferral flags; the bulk repair; and the ignored parameters. No alias remains.
  • Worker 4: failure paths typed and visible. See item 7.
  • Worker 5: tests go red without the behavior. See item 14.
  • Worker 6: no secrets or private paths. Fixtures are unchanged synthetic data. The PR text cites only worktree paths and job ids.

Residuals

  • polylogue-9m93s INTAKE-PREP-1: prepare_jsonl_blob's collected branch (parse_payload(provider, list(records))) still holds every record of a non-stream JSONL file, and of any .json shape no streaming branch claims (including bundle providers when a prepare_sessions cohort callback is set). Deleting it needs a bounded branch per remaining shape; deleting it outright would refuse valid input.
  • polylogue-i07pw AC1: the writer still parses records inline when they have no path carrier (ZIP members, partial prefixes, browser captures, the Hermes and Codex SQLite branches).
  • polylogue-6xcqj: F33 (the positive-evidence rule is still applied per caller on the in-process parse routes) and the AC3 inline-parse remainder are still open.
  • RawObservationReplacement.payload stays typed None, because the kernel's ReplacementLike protocol requires the field.
  • The sinnix overlay patch flake/overlay/package/polylogue-status-document.patch still targets aar35's removed spool plumbing (another repository; recorded on polylogue-aar35).
  • The open PR fix: close 20 Codex P1 findings in sources, backup, browser, MCP #5835 touches seven of these files. A trial merge (git merge-tree) is clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

@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-29T19:12:25.870531Z 0087dad 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 enabled auto-merge (squash) September 29, 2026 20:00
Sinity and others added 6 commits September 29, 2026 22:10
CensusParseStage and its daemon/parse_prefetch.py shim have had no
production instance since the manual rebuild engine was deleted: nothing in
polylogue/ or devtools/ constructs or imports them, and every
RawObservationReplacement is built with payload=None, so the
RawParsePrefetchCache plumbing through revision_backfill never received a
cache. Remove the module, the shim, RawParsePrefetchCache and every
prefetch_cache parameter, the four daemon_parse_stage_* config keys, their
docs, the stale daemon.md section, baseline entries, and the tests that
only exercised the dead stage. The estimate_parsed_tree_bytes calibration
tests move to test_parsed_tree_size.py because revision_backfill still uses
the estimator.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
LiveParseStage.warm, LiveParsePrefetchCache, LiveParseCandidate,
live_parse_worker, live_parse_and_shard_worker and batch.py's
_live_parse_stage_candidates had no production caller: the watcher prepares
paths through warm_paths/prefetch_paths and the writer consumes sealed
carriers through pop_path. Remove them with the tests that only drove the
byte-keyed cache, and correct the comments that still described it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
Revision and membership replay skipped their per-session FTS repair when a
caller passed defer_fts, and the live batch then repaired after committing
the writes; the ingest batch let callers switch the repair effect off and
repaid it with an after-pass bulk repair. Committed state between those
points had blocks without search rows. The replay now always repairs the
session it wrote in the same transaction, and every ingest batch runs the
repair effect before its commit. Remove defer_fts, allow_pending, the
ingest repair_message_fts switch, repair_message_fts_bulk, the ParseResult
repair targets, and the ignored record_exact_snapshot and mark_stale
parameters.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
The stall-field test drove _completed_reporting_stalls, which went with the
deleted byte-keyed warm. The slow-preparation test now captures the same
event from warm_paths and checks its fields reach the log allowlist. Fakes
of repair_message_fts_index_sync drop the keyword catch-all it no longer
receives.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
Resolving the census-stage deletion against master took the salvage
branch's stale float-key entry, live_watcher_parse_stage_warm_timeout_seconds,
in place of live_watcher_parse_stage_stall_report_seconds. Restore it, and
rewrap the parsed-tree size docstrings the deletion shortened.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
The blob-store routing fake of _process_ingest_batch_sync still declared
the repair_message_fts keyword the batch no longer passes. The slow-JSON
preparation test goes back to its own claim; the stall fields it briefly
asserted are not reliably emitted on that schedule.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
@Sinity
Sinity force-pushed the feat/one-publication-path branch from 0087dad to 0a9e1f1 Compare September 29, 2026 21:30
@Sinity
Sinity merged commit e6e40b0 into master Sep 29, 2026
3 checks passed
@Sinity
Sinity deleted the feat/one-publication-path branch September 29, 2026 21:34
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