Repository navigation
fix(pipeline): four critical silent-failure sites - #453
Conversation
Closes #443. Per the silent-failure audit (.agent/scratch/swarm-2026-04-26/silent-failure-audit.md), four sites swallowed exceptions in ways that risk data corruption or silent wrong-answer behavior. The codebase has zero bare ``except:`` clauses, but each of these ``except Exception:`` blocks combined with the archive's content-hash idempotency to make bugs sticky: once a record is misclassified, subsequent re-imports won't retry. Each fix adds explicit ``logger.exception(...)`` so operators see degraded state in logs rather than discovering it later via stale results. The four sites cluster at stage boundaries (acquire->parse, parse->materialize, materialize->index) — the meta-pattern is implicit contracts at stage boundaries, tracked separately in #447. ### Site 1: polylogue/sources/dispatch.py:144 Provider detection by JSON-stream parsing was demoted to fallback_provider on any exception with no log. Now logs the exception with stream name and fallback target, so misclassified streams are visible in logs. ### Site 2: polylogue/pipeline/run_execution.py:317 FTS-trigger restoration was wrapped in ``except Exception: pass`` with a comment claiming "index rebuild handles FTS". Failure left search returning stale results until manual rebuild. Now logs the exception with explicit guidance ("rebuild via 'polylogue run index'"). ### Site 3: polylogue/pipeline/services/ingest_worker.py:401 JSONL sample probe failure quietly returned None, which the caller treated as "not stream-shaped" and rerouted through a different parser, breaking content-hash stability. Adds a logger and ``logger.exception`` documenting the rerouting and its content-hash implication. Deeper fix (preserving content-hash stability under helper failure) is follow-up work tracked in #447. ### Site 4: polylogue/storage/backends/schema_bootstrap.py:602 ``with suppress(Exception)`` hid both "vec0 not loaded" (common, intentional) and "vec0 present but DDL failed" (corruption-shaped, must surface). Now splits into a probe (silent if probe fails) followed by the DDL (logs exception if DDL fails after probe succeeded). The clean three-tier exception pattern in source_acquisition.py and source_parsing.py (cited in audit as exemplars) remains the canonical model. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 53 minutes and 55 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
## Summary Closes #447. Adds declarative input/output contracts to `PipelineStageSpec` and a runtime validator that fires at every stage boundary. ## Problem The `pipeline-stage-audit` (swarm 2026-04-26) identified the implicit-contract pattern as the meta-cause behind the four silent-failure sites fixed in #453: stages depend on prior-stage outputs through bare `RunExecutionState` attributes, with no runtime check verifying the contract is intact. ## Solution - ``StageInput`` dataclass: named state slot a stage requires. - ``PipelineStageSpec`` extended with ``inputs: tuple[StageInput, ...]`` and ``outputs: tuple[str, ...]``. - All eight stages declare their producer/consumer relations. - ``StageContractError`` raised on violation, naming stage and missing inputs. - ``validate_stage_contract`` invoked from ``run_execution._run_stage_spec`` before the stage body runs. - Single-stage runs skip validation (durable archive state can satisfy inputs). ## Verification - 11 new tests in ``tests/unit/pipeline/test_stage_contract.py`` cover full / reprocess / publish sequences, missing-producer cases, optional inputs, message format, and a sanity check that every declared input has a producer somewhere in ``PIPELINE_STAGE_SPECS``. - ``devtools verify`` (full, with pytest): all checks pass. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Pipeline stages now validate contracts, automatically checking that all required inputs are available from previously executed stages. * Enhanced error reporting when stage validation fails, clearly identifying which inputs are missing. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
## Summary Closes #443. Four sites that swallowed exceptions and risked data-corruption or silent wrong-answer behavior, per the silent-failure audit (swarm 2026-04-26). Each fix adds explicit `logger.exception(...)` so operators see degraded state. ## Problem Polylogue's archive uses content-hash idempotency: once a record is processed, subsequent ingests skip it. This is an asset for performance but a hazard when paired with silent failures — a misclassified or partially-processed record stays misclassified until manual recovery. The silent-failure audit identified four critical sites where `except Exception:` paths swallowed failures with no log, surfacing in user-visible behavior only as "search returns stale results" / "duplicate conversations" / "vector search empty": - `polylogue/sources/dispatch.py:144` — provider detection demoted on any exception, no log. - `polylogue/pipeline/run_execution.py:317` — FTS-trigger restoration suppressed. - `polylogue/pipeline/services/ingest_worker.py:401` — JSONL sample probe failure rerouted; broke content-hash stability. - `polylogue/storage/backends/schema_bootstrap.py:602` — `with suppress(Exception)` hid both "vec0 not loaded" (intentional) and "vec0 DDL failed" (corruption). ## Solution ### Site 1 — `polylogue/sources/dispatch.py:144` `logger.exception` with stream name and fallback target. Misclassified streams are now visible in logs. ### Site 2 — `polylogue/pipeline/run_execution.py:317` `logger.exception` with explicit guidance to rebuild via `polylogue run index`. Replaces silent `pass` with operator-actionable diagnostic. ### Site 3 — `polylogue/pipeline/services/ingest_worker.py:401` `logger.exception` documenting the rerouting and its hash-stability implication. Deeper fix (preserving content-hash stability under helper failure) is follow-up work tracked in #447. ### Site 4 — `polylogue/storage/backends/schema_bootstrap.py:602` Split into a silent probe (vec0 not loaded → return) followed by the DDL with `logger.exception` on DDL failure after the probe succeeded. Distinguishes intentional skip from corruption-shaped failure. The clean three-tier exception pattern in `polylogue/sources/source_acquisition.py` and `polylogue/sources/source_parsing.py` (cited in audit as exemplars) remains the canonical model. ## Verification ``` $ devtools verify --quick verify: all checks passed (incl. all 8 lints) $ ruff check polylogue/sources/dispatch.py polylogue/pipeline/run_execution.py polylogue/pipeline/services/ingest_worker.py polylogue/storage/backends/schema_bootstrap.py All checks passed! $ mypy <four files> Success: no issues found in 4 source files ``` Behavior unchanged — only adds logging. Pytest already covers the recovery paths; no new test surface needed at this layer (deeper contract validation is #447's scope). ## Related - #447 — pipeline runtime stage contract validation (the systemic fix; this PR is the localized one). - #421 — proof obligations for these failure modes. - #401 — post-renewal consolidation umbrella. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
## Summary Closes #447. Adds declarative input/output contracts to `PipelineStageSpec` and a runtime validator that fires at every stage boundary. ## Problem The `pipeline-stage-audit` (swarm 2026-04-26) identified the implicit-contract pattern as the meta-cause behind the four silent-failure sites fixed in #453: stages depend on prior-stage outputs through bare `RunExecutionState` attributes, with no runtime check verifying the contract is intact. ## Solution - ``StageInput`` dataclass: named state slot a stage requires. - ``PipelineStageSpec`` extended with ``inputs: tuple[StageInput, ...]`` and ``outputs: tuple[str, ...]``. - All eight stages declare their producer/consumer relations. - ``StageContractError`` raised on violation, naming stage and missing inputs. - ``validate_stage_contract`` invoked from ``run_execution._run_stage_spec`` before the stage body runs. - Single-stage runs skip validation (durable archive state can satisfy inputs). ## Verification - 11 new tests in ``tests/unit/pipeline/test_stage_contract.py`` cover full / reprocess / publish sequences, missing-producer cases, optional inputs, message format, and a sanity check that every declared input has a producer somewhere in ``PIPELINE_STAGE_SPECS``. - ``devtools verify`` (full, with pytest): all checks pass. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Pipeline stages now validate contracts, automatically checking that all required inputs are available from previously executed stages. * Enhanced error reporting when stage validation fails, clearly identifying which inputs are missing. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary
Closes #443. Four sites that swallowed exceptions and risked data-corruption or silent wrong-answer behavior, per the silent-failure audit (swarm 2026-04-26). Each fix adds explicit
logger.exception(...)so operators see degraded state.Problem
Polylogue's archive uses content-hash idempotency: once a record is processed, subsequent ingests skip it. This is an asset for performance but a hazard when paired with silent failures — a misclassified or partially-processed record stays misclassified until manual recovery.
The silent-failure audit identified four critical sites where
except Exception:paths swallowed failures with no log, surfacing in user-visible behavior only as "search returns stale results" / "duplicate conversations" / "vector search empty":polylogue/sources/dispatch.py:144— provider detection demoted on any exception, no log.polylogue/pipeline/run_execution.py:317— FTS-trigger restoration suppressed.polylogue/pipeline/services/ingest_worker.py:401— JSONL sample probe failure rerouted; broke content-hash stability.polylogue/storage/backends/schema_bootstrap.py:602—with suppress(Exception)hid both "vec0 not loaded" (intentional) and "vec0 DDL failed" (corruption).Solution
Site 1 —
polylogue/sources/dispatch.py:144logger.exceptionwith stream name and fallback target. Misclassified streams are now visible in logs.Site 2 —
polylogue/pipeline/run_execution.py:317logger.exceptionwith explicit guidance to rebuild viapolylogue run index. Replaces silentpasswith operator-actionable diagnostic.Site 3 —
polylogue/pipeline/services/ingest_worker.py:401logger.exceptiondocumenting the rerouting and its hash-stability implication. Deeper fix (preserving content-hash stability under helper failure) is follow-up work tracked in #447.Site 4 —
polylogue/storage/backends/schema_bootstrap.py:602Split into a silent probe (vec0 not loaded → return) followed by the DDL with
logger.exceptionon DDL failure after the probe succeeded. Distinguishes intentional skip from corruption-shaped failure.The clean three-tier exception pattern in
polylogue/sources/source_acquisition.pyandpolylogue/sources/source_parsing.py(cited in audit as exemplars) remains the canonical model.Verification
Behavior unchanged — only adds logging. Pytest already covers the recovery paths; no new test surface needed at this layer (deeper contract validation is #447's scope).
Related
🤖 Generated with Claude Code