Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9bf80e7
fix(observers): report observer events a run could not record (ITL-1556)
eywalker Nov 28, 2026
9ef05a9
test(observers): a re-contextualized status observer keeps its run (I…
eywalker Nov 28, 2026
3f380c5
fix(observers): isolate event losses per job execution
eywalker Nov 28, 2026
02b3575
fix(observers): preserve lifecycle and report encoding losses (ITL-1556)
eywalker Nov 28, 2026
5bddfde
Merge remote-tracking branch 'origin/main' into eywalker/itl-1556-obs…
eywalker Nov 28, 2026
b761af4
Merge remote-tracking branch 'origin/main' into eywalker/itl-1556-obs…
eywalker Nov 28, 2026
3e3830b
fix(observers): preserve lifecycle and run metadata (ITL-1556)
eywalker Nov 28, 2026
af58840
fix(observers): preserve first loss and tolerate error formatting (IT…
eywalker Nov 28, 2026
2232f7f
Merge remote-tracking branch 'origin/main' into eywalker/itl-1556-obs…
eywalker Nov 28, 2026
1399afa
fix(observers): scope built-in observers by class identity (ITL-1556)
eywalker Nov 28, 2026
b587b51
fix(observers): preserve custom scoping and safely render loss warnings
eywalker Nov 28, 2026
5e6d8c4
fix(observers): keep loss reporting safe across warning renderers (IT…
eywalker Nov 28, 2026
e15df98
fix(observers): preserve row warnings and safe loss reporting
eywalker Nov 28, 2026
9b9605c
fix(observers): preserve tracebacks and completion interrupts
eywalker Nov 28, 2026
7155a47
fix(observers): preserve interrupts and stabilize compatibility checks
eywalker Nov 28, 2026
86f3e96
fix(observers): preserve interrupt precedence in completion warnings
eywalker Nov 28, 2026
7efdc2a
chore: merge origin/main into ITL-1556
eywalker Nov 28, 2026
cc1bb2d
chore: merge origin/main into ITL-1556
eywalker Nov 28, 2026
0ff5e0a
fix(observers): preserve loss reporting without caller frames
eywalker Nov 28, 2026
8f2b62d
fix(warnings): centralize observer warning fallback
eywalker Nov 28, 2026
3e351d0
chore: merge main after context hashing and source persistence
eywalker Nov 28, 2026
b38fe3c
chore: merge main into ITL-1556
eywalker Nov 29, 2026
d1fcf92
fix(observers): preserve completion warnings and cancellation
eywalker Nov 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions changelog.d/ITL-1556.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
### Added

- **A run reports the observer events it could not record** — `RunSummary` has a new
attribute, `lost_observer_events`: per observer kind (`"status"` for a `StatusObserver`,
`"logging"` for a `LoggingObserver`), a `LostObserverEvents` (exported from
`orcapod.pipeline`) with the number of events that were not written and the first error's
text; it is empty when every event was recorded. The summary's text and notebook display
show it as one line. A run with lost events issues one new warning,
`ObserverEventsLostWarning` (`orcapod.errors`), at the end of the run. It points to the
`run()` call or the line awaiting `run_async()`. For a separately scheduled coroutine,
it points to the event loop's resumption site. The summary display and warning escape
non-ASCII text and ASCII control characters. If the warning renderer raises, the totals
are logged. Interrupts still propagate, and an explicit warnings filter can still
promote the warning to an error.
(ITL-1556)

### Fixed

- **A failed observer write is no longer silent** — when a `StatusObserver` or a
`LoggingObserver` could not write an event to its database (a store that refuses the
rows, or one that fails partway through a run), the observer logged the error and the job
finished as if nothing had happened: nothing in the result or the summary said that the
status and log records were incomplete. The run still continues and its results, its
other summary counts and its exit are unchanged, and each failed write is still logged
with its traceback; the loss is now counted in `RunSummary.lost_observer_events` and
reported by one `ObserverEventsLostWarning` per run, on the sync and the async
orchestrator, for `job.run()`, `job.run_async()` and load-only runs, and for the
built-in observers inside a `CompositeObserver`. Event rows that cannot be encoded
are reported the same way. A job node's own `run()` takes no observer, so its summary
lists none. (ITL-1556)
2 changes: 2 additions & 0 deletions docs/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ These exceptions and warnings report problems running pipelines, processing rows

::: orcapod.errors.RowFailuresWarning

::: orcapod.errors.ObserverEventsLostWarning

::: orcapod.errors.RestrictedAggregationWarning

::: orcapod.errors.SemiJoinIgnoredColumnWarning
Expand Down
2 changes: 2 additions & 0 deletions docs/api/pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ blueprint; `PipelineJob` binds a pipeline to sources and a database and runs it.

::: orcapod.pipeline.NodeRunSummary

::: orcapod.pipeline.LostObserverEvents

::: orcapod.pipeline.SyncPipelineOrchestrator

::: orcapod.pipeline.AsyncPipelineOrchestrator
Expand Down
5 changes: 4 additions & 1 deletion docs/concepts/pipeline-job.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ Among `job.run()`'s optional arguments, the tutorial
default policy skips failed rows and continues) and `observer=` (`StatusObserver`,
`LoggingObserver`) to record what happened during the run. Both observers raise
`SpiralDBObserverNotSupportedError` at setup if given a SpiralDB store, so give them
another database such as Delta (ITL-1540). An observer only watches: one
another database such as Delta (ITL-1540). If a built-in observer cannot encode or write
an event, the failure is logged, the run continues, the summary counts the lost events
per observer kind in `lost_observer_events`, and one `ObserverEventsLostWarning` is
issued at the end of the run (ITL-1556). An observer only watches: one
that changes the job, its nodes or its bound sources during a run is unsupported, and what
the run then does is undefined (ITL-1369). `load_only=True` fills the nodes
from what is already stored and computes nothing; see
Expand Down
45 changes: 45 additions & 0 deletions docs/dev/design_issues/ITL-1556-OBS1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
## `src/orcapod/pipeline/status_observer.py`, `logging_observer.py` — failed event writes

### OBS1 — Observers swallowed every failure to write an event; the run said nothing
**Status:** resolved
**Severity:** high
**Issue:** ITL-1556

`StatusObserver` (both write variants, the root and the contextualized one) and the
`DataLogger` of `LoggingObserver` caught every exception of `add_record` and only logged it.
A job whose observer database refused its rows, or failed partway through a run, finished
successfully with its status and log records missing or incomplete, and nothing in the
`RunSummary` or in a warning said so. ITL-1540 refuses a SpiralDB store at setup; that is
one case only (a SQLite-backed store is accepted at setup and refuses every event row).

**Fix:** Developer decision (November 28, 2026): the observers continue, and the loss is
reported. A job creates a counter for its execution (`pipeline/observer_losses.py`,
`RunLosses`). Node-scoped built-in observers and their data loggers carry that counter,
so overlapping executions count their own losses even when they share an observer or
a run ID. The job selects concrete built-in observers that use the original scope
factory. Custom scope hooks keep control of the observers they return. A failed event
encoding or write is counted and logged. Lifecycle hooks run on the caller's original
observers, and the built-ins derive event metadata as before.

The run puts the count and first reported error for each observer kind in
`RunSummary.lost_observer_events`. The observer logs the original exception before
rendering it for the summary. If the error's message cannot be rendered,
the summary shows its type name. An interrupt while formatting the error propagates.
The summary display and warning escape non-ASCII
text and ASCII control characters within the first LF- or CRLF-delimited line.
If warning delivery raises, the totals are logged.
A filter that promotes `ObserverEventsLostWarning` to an error still raises it.
The run issues one `ObserverEventsLostWarning` after
keeping the completed summary. The warning points to the `run()` call, the
`run_async()` await, or the event loop's resumption site for a separately scheduled
coroutine. If caller frame access is denied, the run issues the observer warning
from Orcapod. A completed run reports observer losses even when preparing or
issuing the row-failure warning raises. When both warnings raise ordinary
exceptions, the row-warning error propagates. An interrupt or cancellation during
delivery of the observer warning logs the totals and propagates, with an earlier
ordinary row-warning error as its cause.

A run that raises before keeping a summary reports the losses in the logs. A job
node's own `run()` takes no observer. Observers passed directly to an orchestrator or
`node.execute` report failed writes in the logs. Which stores support observer event
rows remains open on the issue.
14 changes: 14 additions & 0 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,20 @@ same (`Run of job '...': 1 row failed.`).
`orcapod.pipeline`) so that the first failure stops the run and raises. See the tutorial
[Handling errors](tutorial/handling-errors.md).

### `ObserverEventsLostWarning: Observer events were not recorded in this run: ...`

**Cause.** A `StatusObserver` or `LoggingObserver` could not encode an event row or write
it to its database. The run continues with its usual results and incomplete status or
log records. The warning is issued once, at the end of the run, and gives, per observer
kind, how many events were lost and the first error.

**Fix.** Check the first error in the message and the traceback in the
`orcapod.pipeline` logs. The counts are in `job.last_run.lost_observer_events`. For a
write error, use a database that accepts the observer's rows, such as in-memory or Delta.
For an encoding error, correct the reported value before it is used in another event.
These changes apply to future writes. A later `job.run()` can reuse work from the
completed run and may never emit replacement events for the missing records.

### `TypeError: ...() got an unexpected keyword argument 'ctx'` from a `sink_pod`

**Cause.** A function decorated with `@sink_pod`, `@tap_pod` or `@side_effect_pod` must
Expand Down
14 changes: 14 additions & 0 deletions src/orcapod/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,20 @@ class RowFailuresWarning(UserWarning):
"""


class ObserverEventsLostWarning(UserWarning):
"""Issued once at the end of a job run whose observers lost events (ITL-1556).

A ``StatusObserver`` and a ``LoggingObserver`` record run events as rows in a
database. A write that fails does not stop the run, whose results do not depend on
those rows: the failure is logged with its traceback when it happens, and the run
goes on. At the end of the run (``job.run()``, ``job.run_async()``) this warning
says how many events of each observer kind were not recorded and gives each kind's
first error. The run's ``RunSummary`` (returned by the run, kept as
``job.last_run``) holds the same counts in ``lost_observer_events``. The run's
result and summary are complete and kept before the warning is issued.
"""


class SourceCheckFailedWarning(UserWarning):
"""A source could not be checked for new data at the start of a run (ITL-1102).

Expand Down
2 changes: 2 additions & 0 deletions src/orcapod/pipeline/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from .graph import Pipeline
from .job import PipelineJob
from .logging_observer import LoggingObserver, DataLogger
from .observer_losses import LostObserverEvents
from .run_summary import NodeRunSummary, RunSummary
from .serialization import (
LoadStatus,
Expand All @@ -22,6 +23,7 @@
"GraphProtocol",
"LoadStatus",
"LoggingObserver",
"LostObserverEvents",
"NodeRunSummary",
"DataLogger",
"OrcaDAG",
Expand Down
75 changes: 71 additions & 4 deletions src/orcapod/pipeline/composite_observer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,25 @@

from __future__ import annotations

from typing import Any, cast
from types import MethodType
from typing import TYPE_CHECKING, Any, cast

from orcapod.pipeline.logging_observer import (
LoggingObserver,
_ContextualizedLoggingObserver, # pyright: ignore[reportPrivateUsage]
)
from orcapod.pipeline.observer import NoOpLogger
from orcapod.pipeline.status_observer import (
StatusObserver,
_ContextualizedStatusObserver, # pyright: ignore[reportPrivateUsage]
)
from orcapod.protocols.core_protocols import DataProtocol, TagProtocol
from orcapod.types import SchemaLike

if TYPE_CHECKING:
from orcapod.pipeline.observer_losses import RunLosses
from orcapod.protocols.observability_protocols import ExecutionObserverProtocol

_NOOP_LOGGER = NoOpLogger()


Expand All @@ -39,18 +52,62 @@ class CompositeObserver:
``ExecutionObserverProtocol``.
"""

__run_losses: RunLosses | None = None

def __init__(self, *observers: Any) -> None:
self._observers = list(observers)

def contextualize(self, *identity_path: str) -> "CompositeObserver":
"""Return a new CompositeObserver wrapping each child's contextualized version."""
return self.__contextualize(identity_path, self.__run_losses)

@classmethod
def _for_run(
cls,
observer: ExecutionObserverProtocol,
counter: ExecutionObserverProtocol,
losses: RunLosses,
) -> CompositeObserver:
"""Keep the original observers for lifecycle calls and count node event losses."""
composite = cls(observer, counter)
composite.__run_losses = losses
return composite

def __contextualize(
self, identity_path: tuple[str, ...], losses: RunLosses | None
) -> CompositeObserver:
"""Scope the children and attach the job's counter to the built-in results."""
if not identity_path:
raise ValueError(
"CompositeObserver.contextualize() requires a non-empty identity_path."
)
return CompositeObserver(
*[o.contextualize(*identity_path) for o in self._observers]
)
if losses is None:
return CompositeObserver(
*[o.contextualize(*identity_path) for o in self._observers]
)

children: list[Any] = []
for child in self._observers:
contextualize = child.contextualize
child_type = type(child)
# Custom hooks can return a shared or delegated observer. Only
# the default factories on concrete built-ins give us owned scopes.
uses_default_scope = (
type(contextualize) is MethodType
and contextualize.__self__ is child
and any(
child_type is kind and contextualize.__func__ is factory
for kind, factory in _BUILT_IN_SCOPES
)
)
if uses_default_scope and child_type is CompositeObserver:
scoped = child.__contextualize(identity_path, losses)
else:
scoped = contextualize(*identity_path)
if uses_default_scope:
scoped._run_losses = losses
children.append(scoped)
return CompositeObserver(*children)

def on_run_start(self, run_id: str, **kwargs: Any) -> None:
for o in self._observers:
Expand Down Expand Up @@ -150,3 +207,13 @@ def from_config(
cast("dict[str, object] | None", db_registry),
)
return cls(*(build() for build in children))


# Keep the original functions so hooks replaced on a class are custom too.
_BUILT_IN_SCOPES = (
(CompositeObserver, CompositeObserver.contextualize),
(LoggingObserver, LoggingObserver.contextualize),
(StatusObserver, StatusObserver.contextualize),
(_ContextualizedLoggingObserver, _ContextualizedLoggingObserver.contextualize),
(_ContextualizedStatusObserver, _ContextualizedStatusObserver.contextualize),
)
Loading
Loading