Skip to content

fix(live): follow active index authority in every route - #3952

Merged
Sinity merged 65 commits into
masterfrom
feature/fix/suite-live-ingest-authority
Aug 14, 2026
Merged

fix(live): follow active index authority in every route#3952
Sinity merged 65 commits into
masterfrom
feature/fix/suite-live-ingest-authority

Conversation

@Sinity

@Sinity Sinity commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Summary

Make live ingest, replay, repair, and degraded acquisition follow the selected archive and active-index authority while preserving durable raw evidence when parsing or derived writes are unavailable.

Problem

Retained replay and source-only acquisition had authority gaps: weakly classified JSONL could be discarded or scanned without a total bound; oversized records could lose valid provider evidence based on key order; ZIP members could lose acquisition coordinates; cursors could outrun quarantine; repair could consult a stale index generation; and daemon/watcher startup or any exceptional shutdown step could permit source writes without rebuild exclusion.

Solution

  • Stream bounded structural provider evidence across oversized JSONL records under a hard 64 KiB total envelope; evidence outside the envelope remains UNKNOWN.
  • Preserve ZIP coordinates and detected-provider authority through acquisition, replay, corpus validation, and blob replacement.
  • Bind append envelopes before parsing, preserve retry identity, and hold cursor acknowledgement while quarantined.
  • Route replay, repair, FTS closure, and raw-authority receipts through the exact active index generation.
  • Acquire archive-writer rebuild exclusion before every public daemon and standalone-watch route.
  • Retain exclusion until process exit whenever coordinator drain times out, raises, is cancelled, or is skipped by an earlier cleanup or watcher-stop exception.
  • Preserve frozen Codex-state, payload-budget, timestamp-authority, and late nested-root semantics.

Verification

  • Production-route suite: 32 passed in 338.32s at parent 58a687b26 (20260814T023634Z-focused-test-1506517-c5e0bced). It includes the sanitized 804-revision acquisition → crash → resume → inactive-candidate proof; bounded late-discriminator and outside-budget cases; daemon/watch refusal, cancellation, cleanup failure, and undrained retention; ZIP coordinates; raw replay; corpus validation; frozen state; and watcher rediscovery.
  • Exact-head standalone-watch delta: 4 passed in 1.65s at 7412c09f9b8516c07a51ce8464e6de3c174a9642 (20260814T025306Z-focused-test-1682868-43880690). It reproduces a throwing watcher.stop() with an undrained coordinator and proves rebuild exclusion remains held.
  • Exact-head direnv exec . devtools verify --quick: all 25 gates passed in 159.45s (20260814T025335Z-quick-1689690-74c1c4e5).
  • Exact-head devtools workspace pr-scope check --pr 3952: pr-scope OK @ 7412c09f.
  • Anti-vacuity: regressions execute production daemon, watcher, acquisition, replay, repair, cursor, generation-selection, corpus-validation, and candidate-build routes. Removing the repaired bindings permits a rebuild concurrently, mutates the archive after refusal, loses provider/raw evidence, advances authority incorrectly, or reads a stale generation.

Review disposition

All earlier inline findings were repaired before their threads were resolved. The final three independent P1 findings—cleanup failure releasing exclusion, key-order-sensitive oversized JSONL detection, and standalone watcher-stop failure skipping drain—are reproduced and repaired. CI and final exact-head review are not represented as complete until returned.

Risks and follow-ups

This changes live-ingest authority but does not mutate the production archive. Authenticated archive-root recovery, source migration, inactive-candidate construction, and the terminal current-master full-suite/testmon receipt remain separate operations.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The change routes archive operations through active-index generations, adds source-only live acquisition, classifies artifacts and decoded evidence, improves hook-spool retries, and updates retention, repair, and validation behavior.

Changes

Active index, live acquisition, and evidence handling

Layer / File(s) Summary
Active index routing and archive bootstrap
polylogue/config.py, polylogue/storage/..., polylogue/daemon/..., polylogue/browser_capture/...
Archive operations resolve the active index path. Explicit index overrides remain supported. Bootstrap calls are serialized.
Live acquisition and artifact admission
polylogue/sources/live/*, polylogue/sources/hooks.py, polylogue/archive/artifact_taxonomy/*, polylogue/sources/source_parsing.py
Source-only mode acquires source-tier data without a derived index. JSONL/NDJSON detection and artifact classification control session admission.
Watcher ownership and hook-spool retries
polylogue/sources/live/watcher.py, tests/unit/sources/test_hook_spool.py, tests/unit/sources/test_live_watcher*.py
The watcher resolves the deepest source owner, accepts relevant directories, drains existing files, retries hook shards, and cancels retry tasks.
Retention, repair, and validation lifecycle
polylogue/storage/raw_retention.py, polylogue/storage/repair.py, polylogue/storage/raw_authority.py, polylogue/storage/raw_reconciler.py, polylogue/schemas/sampling_db.py, polylogue/daemon/*
Terminal evidence receives scoped retention authority. Repair and replay propagate the active index path and writer leases. Parsed rows with historical validation failures remain eligible where applicable.

Estimated code review effort: 5 (Critical) | ~120 minutes

Mergeability Score: 🟠 High · up to da300

The change affects retained-source replay, archive routing, raw cleanup, ZIP identity, and repair batching. Unresolved paths can write to the wrong archive, merge distinct source coordinates, bypass safety handling, or commit partial repair state, so the PR is not merge-ready until these correctness and availability risks are fixed or explicitly accepted.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 47.20% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: routing live-ingest behavior through active-index authority.
Description check ✅ Passed The description covers the main template sections and provides detailed verification, risks, and a self-contained scope attestation.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/suite-live-ingest-authority

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 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: 79ee92aeec

ℹ️ 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.py Outdated
Comment thread polylogue/sources/live/watcher.py
@Sinity

Sinity commented Aug 11, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Please review exact head 45bcb3ad1bd8cf92859ced7409b10191a6c41f53, including the two repaired live delivery routes and their regressions.

@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: 45bcb3ad1b

ℹ️ 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/storage/raw_retention.py Outdated
Comment thread polylogue/storage/raw_retention.py Outdated
Comment thread polylogue/storage/repair.py Outdated
Comment thread polylogue/sources/live/batch.py
Comment thread tests/unit/sources/test_live_watcher_locking.py Outdated
@Sinity

Sinity commented Aug 11, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Please review exact head aa9624f45259714e5b532f7763a53f25a298fc1b, including the bounded re-drain for the added hook-shard atomic-publication race.

@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: aa9624f452

ℹ️ 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/storage/sqlite/archive_tiers/archive.py Outdated
Comment thread polylogue/sources/live/watcher.py Outdated
Comment thread polylogue/storage/raw_retention.py Outdated
@Sinity

Sinity commented Aug 11, 2026

Copy link
Copy Markdown
Owner Author

@codex Please review the final exact head dc568e3. Focus on the Provider.UNKNOWN strict-classification route and the added hook-spool day-shard retry lifecycle; the latter must tolerate a first envelope published after the former fixed grace period without relying on periodic catch-up.

@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: dc568e344c

ℹ️ 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/watcher.py Outdated
Comment thread polylogue/sources/live/batch.py

@coderabbitai coderabbitai 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.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@polylogue/sources/live/watcher.py`:
- Around line 430-463: Bound _retry_hook_spool_directory_until_populated with a
short deadline using a new _HOOK_SPOOL_DIRECTORY_RETRY_MAX_S constant defined
alongside _HOOK_SPOOL_DIRECTORY_RETRY_POLL_S. Stop polling once the deadline
expires, while preserving the existing shutdown, directory-removal, OSError, and
JSON-detected behaviors.

In `@polylogue/storage/raw_retention.py`:
- Around line 1409-1410: Update the logic around the semantic-only check so an
active semantic head is first validated for a corresponding source-tier row in
raw_sessions; raise the broken-head violation when that row is absent. Preserve
the existing byte-chain exemption, but do not let seed_raw_id in
semantic_only_raw_ids bypass the row is None validation or cursor handling.
- Around line 1678-1684: Update _terminal_artifact_raw_ids() to query ordered
terminal_paths in batches of 500, matching _terminal_artifact_paths(), and
aggregate raw_id results across all batches into the returned frozenset.
Preserve the existing empty-input behavior and query semantics while preventing
SQLite bind-variable-limit errors that bypass RawRetentionSafetyError handling.

In `@tests/unit/sources/test_hook_spool.py`:
- Around line 311-365: Mark
test_live_watcher_retries_added_hook_shard_until_atomic_publish with
pytest.mark.uses_real_clock, providing a reason that it relies on real asyncio
timing for the 0.10-second publish delay and 0.01-second polling against the
production retry interval.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8e2f986d-2825-4ea2-96ed-f6dfc62b0bb1

📥 Commits

Reviewing files that changed from the base of the PR and between c27af7d and dc568e3.

📒 Files selected for processing (12)
  • polylogue/sources/live/append_ingest.py
  • polylogue/sources/live/batch.py
  • polylogue/sources/live/watcher.py
  • polylogue/storage/raw_retention.py
  • polylogue/storage/repair.py
  • polylogue/storage/sqlite/archive_tiers/archive.py
  • polylogue/storage/sqlite/archive_tiers/bootstrap.py
  • tests/unit/sources/test_hook_spool.py
  • tests/unit/sources/test_live_watcher.py
  • tests/unit/sources/test_live_watcher_locking.py
  • tests/unit/storage/test_raw_retention.py
  • tests/unit/storage/test_repair.py

Comment thread polylogue/sources/live/watcher.py
Comment thread polylogue/storage/raw_retention.py Outdated
Comment thread polylogue/storage/raw_retention.py Outdated
Comment thread tests/unit/sources/test_hook_spool.py
@Sinity
Sinity force-pushed the feature/fix/suite-live-ingest-authority branch from dc568e3 to 6a2bed2 Compare August 12, 2026 21:58
@Sinity

Sinity commented Aug 12, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Please review exact head 6a2bed2bb28642acceccb3e97cd2dceb3ed78e79. Focus on the post-rebase synthetic fixture alignment: full archive bootstrap, fail-closed cursor authority, persisted census gating, and terminal raw-replay outcomes.

@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: 6a2bed2bb2

ℹ️ 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.py
@Sinity

Sinity commented Aug 12, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Please review exact head 01327dee69328b2ee0b907169f4a815a50b513bf. The P1 unknown weak-path JSON admission repair and its real-route regression are included in this head.

@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: 01327dee69

ℹ️ 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/storage/raw_retention.py Outdated
@Sinity

Sinity commented Aug 12, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@Sinity

Sinity commented Aug 12, 2026

Copy link
Copy Markdown
Owner Author

@codex review this exact pushed head only: 17435a4. The complete seven-file affected suite passed (446 tests), the three reproduced lifecycle regressions passed, and all 25 quick checks passed.

@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: 17435a4e5e

ℹ️ 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
Sinity added a commit that referenced this pull request Aug 12, 2026
Problem: large non-JSONL sidecars could reach generic streaming admission before definitive path classification.\n\nWhat changed: expose the existing strong path rules for live admission, preserve weak analysis-path payload and streaming handling, and cover both the full-ingest and preloaded-payload routes.\n\nCompatibility: the public path classifier preserves its output; the fingerprint manifest records the safe internal delegation.\n\nRef #3952
@Sinity

Sinity commented Aug 12, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Please review exact pushed head 694ca99ee46cc72184399d86fac86c3cd1b00567 only. Strong non-session path rules now precede non-JSONL large-file streaming; weak analysis/ paths retain bounded payload or streaming handling. Verification: focused regression passed, the 118-test live-batch support file passed, and all 25 quick stages passed.

@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: 694ca99ee4

ℹ️ 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.py
Comment thread polylogue/storage/raw_retention.py Outdated
Comment thread polylogue/sources/live/watcher.py Outdated
Sinity added a commit that referenced this pull request Aug 12, 2026
Problem: large non-JSONL sidecars could reach generic streaming admission before definitive path classification.\n\nWhat changed: expose the existing strong path rules for live admission, preserve weak analysis-path payload and streaming handling, and cover both the full-ingest and preloaded-payload routes.\n\nCompatibility: the public path classifier preserves its output; the fingerprint manifest records the safe internal delegation.\n\nRef #3952
@Sinity
Sinity force-pushed the feature/fix/suite-live-ingest-authority branch from 694ca99 to 62a276a Compare August 12, 2026 23:58
@Sinity

Sinity commented Aug 12, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Please review exact rebased head 62a276a3fb399f52d1616495b1e41329b0d5dafc only. The seven-file production-route suite passed 447 tests and all 25 quick checks passed after rebasing onto current master.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 62a276a3fb

ℹ️ 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 commented Aug 13, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Please review exact head 019f7c88e653dcb01445566714d127bfc3c8f716, including the three latest authority and containment repairs.

@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: 019f7c88e6

ℹ️ 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/storage/raw_retention.py Outdated
@Sinity

Sinity commented Aug 13, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Please review exact head 4ffd2d8, especially terminal-artifact authority after successful reparse.

@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: 4ffd2d876e

ℹ️ 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/storage/raw_retention.py Outdated
@Sinity

Sinity commented Aug 13, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Please review exact head 33cf85b, especially the validation-before-materialization ordering and stale terminal-carrier revocation.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 33cf85b88c

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

@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: 6bef347fbc

ℹ️ 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.py
Comment thread polylogue/storage/sqlite/raw_state_update.py
Comment thread polylogue/storage/blob_integrity.py
Comment thread polylogue/sources/live/batch.py
Sinity added 3 commits August 14, 2026 00:47
Bound retained document scalar tokens before structural provider detection and preserve whole-sequence detector tightness. Carry Codex state snapshots through frozen validation as non-session evidence, enforce replay budgets before state parsing, and refresh configured roots during periodic catch-up.
Unknown acquisition and parser classification had drifted across live ZIP replay, corpus verification, and blob reconstruction. Oversized NDJSON sampling could also allocate a complete physical record before streaming admission.

Keep acquisition provider separate from detected provider, persist independent ZIP entry and split coordinates in source v33, reuse those coordinates after blob replacement, and cap live JSONL record sampling. Inventory the new durable writer and cover the production routes with anti-vacuous regressions.
Return directly after a generation-lease refusal, bound unknown retained JSONL detection, and keep terminal Codex state snapshots out of frozen session parsing.

Ref #3952.
@Sinity

Sinity commented Aug 14, 2026

Copy link
Copy Markdown
Owner Author

@codex review exact head 118005d. Please review the combined final head, especially active-index authority, bounded retained replay, provider/ZIP identity, lease refusal, frozen Codex state, and watcher catch-up.

@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: 118005dbe1

ℹ️ 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/revision_backfill.py Outdated
Comment on lines +549 to +550
if not raw_line:
return Provider.UNKNOWN, "bounded JSONL provider scan exhausted; used fallback_provider"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Return detected providers before the scan cap

When an UNKNOWN JSONL starts with a provider-identifying record larger than 64 KiB, _detect_provider_from_bounded_prefix() can successfully identify Codex or Claude from the first 8 KiB, but this branch drains the record until the new total scan cap is exhausted and then replaces that positive result with Provider.UNKNOWN. Replay subsequently raises the unresolved-provider error instead of invoking the supported streaming parser. Fresh evidence at this exact head is the newly added total-cap return; preserve a provider already detected before attempting to drain the remainder.

AGENTS.md reference: AGENTS.md:L149-L158

Useful? React with 👍 / 👎.

Comment thread polylogue/daemon/cli.py
generation_pin_refused = False
with contextlib.ExitStack() as lease_stack:
try:
index_db = lease_stack.enter_context(raw_authority.materialization_generation_lease(config))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Acquire the generation lease before frontier recovery

When the default recover=True pass encounters a planned frontier census while an offline rebuild owns the lease, recover_interrupted_frontier() runs before this acquisition. Its _frontier_items() resolves and attaches the current active index and then recovery persists outcomes, so a promotion can race those reads/writes before the typed lease refusal is reached. Fresh evidence beyond the resolved post-repair fall-through issue is this pre-lease recovery path; acquire the generation lease before recovery and stale-plan processing.

Useful? React with 👍 / 👎.

@Sinity

Sinity commented Aug 14, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Please review exact pushed head ec151aab942ea2f3ee16538c9a14635ac7b690c0. The repair preserves positive provider evidence beyond the total scan cap and keeps interrupted-frontier recovery, stale-plan resolution, repair, FTS closure, and raw-authority convergence under one generation lease; lease refusal must mutate none of them.

@Sinity

Sinity commented Aug 14, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Please review exact pushed head 76533937a9890bcbe8e42c502679c6ef43a10aef. The latest repair moves direct blob-reference restoration behind the same generation lease and makes refusal prove that restoration, recovery, stale-plan resolution, repair, FTS closure, and frontier convergence all remain untouched.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 76533937a9

ℹ️ 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 commented Aug 14, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Please review exact pushed head 4984774bcc3df941c79578d4ac6f0122e02e7663. The daemon now acquires archive-writer rebuild exclusion for its complete lifetime before every source/index startup or periodic mutation; raw-materialization retains its nested exact-generation lease and fail-closed typed refusal.

@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: 4984774bcc

ℹ️ 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/daemon/cli.py Outdated

archive_root_path = Path(archive_root())
archive_root_path.mkdir(mode=0o700, parents=True, exist_ok=True)
with archive_writer_rebuild_exclusion(archive_root_path):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Permit daemon-coordinated rebuilds through the lifetime lease

Whenever automatic bulk rebuild routing or POST /api/maintenance/rebuild-index invokes rebuild_index_from_source_sync, the rebuild engine tries to acquire an exclusive RebuildLease while this wrapper still holds its shared ActiveWriterLease. Separate flock opens conflict even within the same process, so every daemon-owned rebuild is refused for the daemon's entire lifetime; bulk recovery repeatedly makes no progress and the HTTP maintenance route fails. The lifetime exclusion needs a handoff or a daemon-owned rebuild mode that preserves single-writer coordination without competing with its own lease.

AGENTS.md reference: AGENTS.md:L164-L167

Useful? React with 👍 / 👎.

Comment thread polylogue/daemon/cli.py Outdated

archive_root_path = Path(archive_root())
archive_root_path.mkdir(mode=0o700, parents=True, exist_ok=True)
with archive_writer_rebuild_exclusion(archive_root_path):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve live shared holders when reclaiming stale metadata

After a completed rebuild leaves its now-dead PID in .index-rebuild.lock, this daemon acquires the shared lease without replacing that metadata. A later external RebuildLease fails to lock the daemon-held inode, sees the recorded PID as dead, and _open_lock_fd() atomically replaces the lock file and acquires the new inode exclusively, allowing the rebuild to run concurrently with the still-writing daemon. The lifetime lease therefore needs a reclamation protocol that cannot discard a currently locked shared-holder inode merely because its contents describe an older exclusive owner.

AGENTS.md reference: AGENTS.md:L182-L184

Useful? React with 👍 / 👎.

@Sinity

Sinity commented Aug 14, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Please review exact pushed head 7e58dd94e0c5dae005ad6777ba9e3845af239464. Both public daemon and standalone watch now acquire rebuild exclusion before archive entry; drain timeouts retain the lease until process exit, and refusal compares the complete archive byte graph before/after.

@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: 7e58dd94e0

ℹ️ 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/daemon/cli.py Outdated
finally:
if watcher is not None:
watcher.stop()
writer_drained = await coordinator.shutdown(timeout=5.0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Retain exclusion before awaiting coordinator drain

If cancellation or another BaseException interrupts coordinator.shutdown() while a shielded admitted writer is still running, writer_drained is never returned and _retain_rebuild_exclusion_for_undrained_writer() is skipped; the surrounding context then calls release_if_safe(), which treats the unmarked state as safe and releases the shared lease. This can let an offline rebuild overlap the detached SQLite writer precisely on an interrupted shutdown, so the exclusion must fail closed until a completed drain explicitly proves it can be released.

AGENTS.md reference: AGENTS.md:L182-L184

Useful? React with 👍 / 👎.

Comment thread polylogue/daemon/cli.py Outdated
Comment on lines +2142 to +2144
finally:
if watcher is not None:
watcher.stop()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Stop watcher children before closing Polylogue

When watcher.run() raises KeyboardInterrupt while a failed-retry child is still scheduled, this finally executes only after Polylogue.__aexit__() has closed the repository/backend. watcher.stop() is what cancels that retry task, so it can resume during the asynchronous close and schedule work against already-closing services, producing shutdown failures or losing the pending ingestion. Stop and cancel the watcher children inside the Polylogue context, then drain the coordinator before closing those dependencies.

Useful? React with 👍 / 👎.

@Sinity

Sinity commented Aug 14, 2026

Copy link
Copy Markdown
Owner Author

@codex review exact head 8dbb635, including cancellation during coordinator drain.

@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: 8dbb6352ec

ℹ️ 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/daemon/cli.py
Comment on lines +2859 to +2863
writer_drained = await _shutdown_writer_coordinator_with_rebuild_exclusion(
write_coordinator,
rebuild_exclusion,
timeout=5.0,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Retain exclusion before all shutdown awaits

In _run_daemon_services_under_active_writer_lease, a second cancellation can arrive during any earlier cleanup await—such as server shutdown, _drain_tasks(), or the final lifecycle write—before this helper is reached. If an admitted sync writer is still detached, that cancellation exits the cleanup with writer_drained=False but without calling retain_until_process_exit(), so the outer context releases the shared rebuild lease and an offline rebuild can overlap the writer. Unlike the now-covered cancellation inside coordinator.shutdown(), the cleanup should fail closed from its start and release the exclusion only after a completed drain proves safety.

AGENTS.md reference: AGENTS.md:L182-L184

Useful? React with 👍 / 👎.

Sinity added 2 commits August 14, 2026 04:14
Problem: Provider detection stopped at the first 8192 bytes of an oversized JSONL record, so a valid discriminator after a large preceding field was treated as UNKNOWN.

What changed: Stream each retained JSONL record through the existing scalar-bounded structural probe in 4096-byte chunks, sharing the hard 64 KiB total scan envelope. Add a Codex late-session_meta regression and malformed huge-input budget coverage.

Alternatives rejected: Eager whole-record parsing and unbounded scanning would violate the retained-replay resource contract.

Compatibility: Positive evidence remains routed through the existing provider detectors. Evidence outside the envelope remains UNKNOWN.
@Sinity

Sinity commented Aug 14, 2026

Copy link
Copy Markdown
Owner Author

@codex review exact head 58a687b. The final two P1 reproductions are now in the exact-head 32-test production-route suite.

@Sinity

Sinity commented Aug 14, 2026

Copy link
Copy Markdown
Owner Author

@codex review exact head 7412c09. The standalone watcher-stop P1 now has an exact production-route regression.

@Sinity
Sinity merged commit 190f651 into master Aug 14, 2026
3 checks passed
@Sinity
Sinity deleted the feature/fix/suite-live-ingest-authority branch August 14, 2026 03:05

@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: 7412c09f9b

ℹ️ 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/daemon/cli.py
finally:
try:
if watcher is not None:
watcher.stop()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Stop watcher children before closing their services

On Ctrl-C while the real _drain_task is inside _flush_pending() or pre-parsing a live batch, LiveWatcher.run() does not cancel or await that child; control first exits async with Polylogue, closing its repository/backend, and only then reaches this stop() call and the coordinator drain. The child can therefore resume against closed services—or reach the coordinator only after admission has closed—causing shutdown failures and abandoning the pending batch. Fresh evidence at this exact head is the production _enqueue()_debounced_batch() route, while the new nested finally still preserves the close-before-stop ordering; stop/cancel and await watcher children, then drain the coordinator, before leaving the Polylogue context.

Useful? React with 👍 / 👎.

Comment thread polylogue/config.py
Comment on lines +145 to +146
if self._db_path_explicit:
return self.db_path

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Treat resolved runtime database paths as generation-aware

When a normal long-lived service obtains its config through resolve_runtime_config().as_config(), ResolvedRuntimeConfig.as_config() passes the already-resolved paths.index_db argument, so this flag is set even though the operator did not request an explicit database override. After an active-generation promotion, current_db_path() consequently keeps returning the startup generation; callers in raw repair and raw_reconciler can then read or mutate the inactive index while the rest of the archive serves the promoted one. Preserve whether the original runtime setting was truly explicit instead of inferring it solely from db_path is not None.

Useful? React with 👍 / 👎.

Sinity added a commit that referenced this pull request Aug 14, 2026
## Summary

Remove self-attesting campaign machinery while retaining executable
product behavior, durable authority, operational safety, and
independently valuable verification.

## Problem

The repository had accumulated generated mirrors, passive ledgers,
campaign packets, duplicate tracker projections, source-text scans,
one-shot reports, and tests that proved only their declarations. They
increased maintenance cost and made process artifacts look like runtime
authority. Review of the purge also exposed real defects in destructive
deletion, raw-authority proof binding, canary authority, benchmark
reporting, and continuity replay isolation.

## Solution

- Delete 324 retired files and roughly 79,000 lines of generated
reports, campaign wrappers, tracker/dashboard mirrors, prose-pattern
gates, stale planning packets, and duplicate authority registries.
- Retain runtime-consumed registries and executable evidence:
operation/action/query descriptors, origin specifications, SLO
benchmarks, durable migrations and audit records, parser fingerprints,
continuity replay, schema/layering checks, and behavior-level tests.
- Preserve one daemon-owned destructive-delete path with exact preview,
authorization, acknowledgement, cancellation, and batch binding.
- Bind raw-authority exceptions to the complete exact set of planted
terminal/deferred outcomes and seeded component/raw IDs; reject missing,
swapped, duplicate, unrelated, or falsely successful receipts.
- Keep canary semantic authority package-local and exact: a delta must
declare the reviewed operation, columns, table, and targeted
session/origin scope. Constraint-only, unscoped, unrelated, tracker, or
successor metadata cannot authorize candidate differences.
- Require continuity replay to name an exact catalog and run in a
completely hermetic environment: no inherited cwd/site config, daemon
URL/token, MCP capability, HOME/XDG, temp, or user-data authority.
Explicit offline mode suppresses per-call delivery and startup outbox
draining. A supplied archive is proven byte-identical before/after and
cannot emit an outbound daemon request.
- Replace the cancellation swarm/timing race with one deterministic
production-route proof per interruptible MCP tool. A disposable server
holds its real admission slot, one official MCP request queues, one
cancellation is confirmed, and a protocol ping proves healthy ordered
teardown. Equivalent scenarios reuse that tool-level proof.
- Keep structured Beads graph-cycle failure reporting, canonical canary
row identities, real benchmark metrics, and behavior-derived
command/document coverage.
- Retire the closed claim-vs-evidence campaign’s
private-report/calibration/publishing harness; reusable query semantics
remain on ordinary production routes.

## Verification

- Affected reindex-canary, daemon coordination, continuity, MCP
telemetry, CLI, and Beads graph suite: `167 passed in 154.70s`.
- Deterministic MCP cancellation regression: three fresh-process passes;
deduplicated run `1 passed in 18.92s` (previous redundant path was
roughly 26–30 seconds).
- Hermetic supplied-archive proof: zero outbound requests, unchanged
tier SHA-256 digests, and no archive-local runtime state.
- Focused deletion/raw-authority suites from the branch: 14 and 22
passed.
- Semantic schema wiring: 30 passed.
- Action/completion/workflow behavior: 192 passed.
- Documentation discovery/render coverage: 7 passed; `devtools render
all --check` passed.
- Exact-head review-repair suite: 98 focused tests covering canary
authority, raw-authority restart proof, hermetic continuity replay, MCP
telemetry, and server runtime.
- Exact post-rebase quick gate: all 10 checks passed in 59.29s
(`20260814T031542Z-quick-1912950-306d6f9e`).
- Final P1 repair restored the published source migration bytes exactly;
two durable-train hash/replay tests passed, followed by the 25.4s
exact-head quick gate (`20260814T033106Z-quick-2033174-5bd70dec`).

## Scope disposition

This is self-contained repository cleanup and correctness repair. It
assigns or mutates no Beads. #3952 merged first; this branch is now
rebased onto that exact master, with the 98-test production-route suite
and quick gate run at parent `e49a320d`, then the published-migration
repair verified at final head `13135b37`. The merge train still requires
its terminal complete-suite/testmon receipt.

<!-- polylogue-pr-scope:v2
{
  "assigned_beads": [],
  "dispositions": [],
  "mutated_beads": [],
"scope_digest":
"79a7984a9ec80a157c96dc8d28561159c642c15de3793837eff751fa7eac34a1",
  "scope_kind": "self_contained",
  "version": 2
}
-->
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