Skip to content

fix(pipeline): four critical silent-failure sites - #453

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/silent-failure-sites
Apr 26, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/fix/silent-failure-sites

Conversation

@Sinity

@Sinity Sinity commented Apr 26, 2026 •

Copy link
Copy Markdown
Owner

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

🤖 Generated with Claude Code

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

coderabbitai Bot commented Apr 26, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 53 minutes and 55 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 60bf6877-852d-4565-a104-595a09af15eb

📥 Commits

Reviewing files that changed from the base of the PR and between 5bb0c25 and 900e640.

📒 Files selected for processing (4)
  • polylogue/pipeline/run_execution.py
  • polylogue/pipeline/services/ingest_worker.py
  • polylogue/sources/dispatch.py
  • polylogue/storage/backends/schema_bootstrap.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/silent-failure-sites

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 and usage tips.

@Sinity
Sinity merged commit 8fdcb10 into master Apr 26, 2026
13 of 14 checks passed
@Sinity
Sinity deleted the feature/fix/silent-failure-sites branch April 26, 2026 12:08
Sinity added a commit that referenced this pull request Apr 26, 2026
## 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 -->
@Sinity

Sinity commented May 1, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

ℹ️ 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 requested a review from Copilot May 1, 2026 01:54

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sinity added a commit that referenced this pull request May 7, 2026
## 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]>
Sinity added a commit that referenced this pull request May 7, 2026
## 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 -->
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.

fix(pipeline): four critical silent-failure sites

2 participants