Skip to content

comicbox.events ¶

Shared event types for read / write / online workflows.

One on_event callback shape across the three public bulk entry points (iter_process_files, bulk_write, OnlineSession.tag_many) so a caller — typically Codex — can wire a single handler.

Handlers run on the orchestrator thread that drains worker results. They must be thread-safe and should return quickly; expensive work belongs in a queue the handler dispatches to.

AutoWritten dataclass ¶

Bases: Event

Matcher accepted a candidate without prompting.

Source code in comicbox/events.py
143
144
145
146
147
148
149
@dataclass(frozen=True, slots=True, kw_only=True)
class AutoWritten(Event):
    """Matcher accepted a candidate without prompting."""

    source: str = ""
    candidate_summary: str = ""
    kind: Literal["auto_written"] = "auto_written"

BatchFinished dataclass ¶

Bases: Event

Fired once after every file has been delivered.

parsed / short_circuited / errored carry per-outcome counts so callers can render an end-of-batch summary without re-walking the result stream.

Source code in comicbox/events.py
79
80
81
82
83
84
85
86
87
88
89
90
91
92
@dataclass(frozen=True, slots=True, kw_only=True)
class BatchFinished(Event):
    """
    Fired once after every file has been delivered.

    ``parsed`` / ``short_circuited`` / ``errored`` carry per-outcome counts
    so callers can render an end-of-batch summary without re-walking the
    result stream.
    """

    parsed: int = 0
    short_circuited: int = 0
    errored: int = 0
    kind: Literal["batch_finished"] = "batch_finished"

BatchStarted dataclass ¶

Bases: Event

Fired once before the first file is submitted.

Source code in comicbox/events.py
43
44
45
46
47
@dataclass(frozen=True, slots=True, kw_only=True)
class BatchStarted(Event):
    """Fired once before the first file is submitted."""

    kind: Literal["batch_started"] = "batch_started"

Event dataclass ¶

Base for all workflow events.

Subclasses are concrete frozen dataclasses keyed by the kind literal on the subclass — callers can match on type or on kind.

Source code in comicbox/events.py
23
24
25
26
27
28
29
30
31
32
33
34
35
@dataclass(frozen=True, slots=True, kw_only=True)
class Event:
    """
    Base for all workflow events.

    Subclasses are concrete frozen dataclasses keyed by the ``kind`` literal
    on the subclass — callers can ``match`` on type or on ``kind``.
    """

    kind: str
    path: Path | None = None
    index: int | None = None
    total: int | None = None

FileError dataclass ¶

Bases: Event

Worker raised an exception. error is the str(exception).

Source code in comicbox/events.py
71
72
73
74
75
76
@dataclass(frozen=True, slots=True, kw_only=True)
class FileError(Event):
    """Worker raised an exception. ``error`` is the str(exception)."""

    error: str = ""
    kind: Literal["file_error"] = "file_error"

FileFinished dataclass ¶

Bases: Event

Per-file online tagging completed (success, skip, no-match, or error).

Source code in comicbox/events.py
272
273
274
275
276
277
@dataclass(frozen=True, slots=True, kw_only=True)
class FileFinished(Event):
    """Per-file online tagging completed (success, skip, no-match, or error)."""

    outcome: str = ""
    kind: Literal["file_finished"] = "file_finished"

FileParsed dataclass ¶

Bases: Event

Worker fully parsed embedded metadata.

Source code in comicbox/events.py
64
65
66
67
68
@dataclass(frozen=True, slots=True, kw_only=True)
class FileParsed(Event):
    """Worker fully parsed embedded metadata."""

    kind: Literal["file_parsed"] = "file_parsed"

FileShortCircuited dataclass ¶

Bases: Event

Worker decided the embedded metadata had not changed and skipped parse.

reason="mtime_unchanged" — embedded mtime <= caller’s old_mtime. reason="filtered" — caller passed full_metadata=False so the worker only collected envelope fields.

Source code in comicbox/events.py
50
51
52
53
54
55
56
57
58
59
60
61
@dataclass(frozen=True, slots=True, kw_only=True)
class FileShortCircuited(Event):
    """
    Worker decided the embedded metadata had not changed and skipped parse.

    ``reason="mtime_unchanged"`` — embedded mtime <= caller's ``old_mtime``.
    ``reason="filtered"``        — caller passed ``full_metadata=False`` so
                                   the worker only collected envelope fields.
    """

    reason: Literal["mtime_unchanged", "filtered", "dry_run"] = "mtime_unchanged"
    kind: Literal["file_short_circuited"] = "file_short_circuited"

NoMatch dataclass ¶

Bases: Event

No candidate cleared min_confidence.

Source code in comicbox/events.py
250
251
252
253
254
255
@dataclass(frozen=True, slots=True, kw_only=True)
class NoMatch(Event):
    """No candidate cleared min_confidence."""

    source: str = ""
    kind: Literal["no_match"] = "no_match"

PromptDeferred dataclass ¶

Bases: Event

OnlineSession is in defer_prompts mode and queued this prompt for later.

The batch continues; the deferred prompt is accessible via OnlineSession.deferred_prompts(). Codex’s intended flow: surface these in a “Review tagging” UI after the batch completes, collect the user’s decisions, seed them back into the session’s dedup cache via preload_resolution(), then re-run the affected files.

Source code in comicbox/events.py
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@dataclass(frozen=True, slots=True, kw_only=True)
class PromptDeferred(Event):
    """
    OnlineSession is in defer_prompts mode and queued this prompt for later.

    The batch continues; the deferred prompt is accessible via
    ``OnlineSession.deferred_prompts()``. Codex's intended flow: surface
    these in a "Review tagging" UI after the batch completes, collect the
    user's decisions, seed them back into the session's dedup cache via
    ``preload_resolution()``, then re-run the affected files.
    """

    source: str = ""
    prompt_id: str = ""
    fingerprint: str = ""
    n_candidates: int = 0
    kind: Literal["prompt_deferred"] = "prompt_deferred"

PromptQueued dataclass ¶

Bases: Event

Matcher needs human input; prompt dispatched to PromptHandler.

Source code in comicbox/events.py
168
169
170
171
172
173
174
175
@dataclass(frozen=True, slots=True, kw_only=True)
class PromptQueued(Event):
    """Matcher needs human input; prompt dispatched to PromptHandler."""

    source: str = ""
    prompt_id: str = ""
    n_candidates: int = 0
    kind: Literal["prompt_queued"] = "prompt_queued"

PromptResolved dataclass ¶

Bases: Event

PromptHandler returned a decision.

Source code in comicbox/events.py
178
179
180
181
182
183
184
185
@dataclass(frozen=True, slots=True, kw_only=True)
class PromptResolved(Event):
    """PromptHandler returned a decision."""

    source: str = ""
    prompt_id: str = ""
    action: str = ""
    kind: Literal["prompt_resolved"] = "prompt_resolved"

PromptResolvedFromCache dataclass ¶

Bases: Event

OnlineSession auto-applied a cached choice instead of re-prompting.

Fingerprint matched a previously-resolved prompt in the per-session dedup cache; the user’s handler was not invoked.

Source code in comicbox/events.py
207
208
209
210
211
212
213
214
215
216
217
218
219
220
@dataclass(frozen=True, slots=True, kw_only=True)
class PromptResolvedFromCache(Event):
    """
    OnlineSession auto-applied a cached choice instead of re-prompting.

    Fingerprint matched a previously-resolved prompt in the per-session
    dedup cache; the user's handler was not invoked.
    """

    source: str = ""
    prompt_id: str = ""
    action: str = ""
    fingerprint: str = ""
    kind: Literal["prompt_resolved_from_cache"] = "prompt_resolved_from_cache"

RateLimited dataclass ¶

Bases: Event

Source signaled a rate-limit hit.

retry_after_seconds is the server hint when available; otherwise the per-source retry-schedule’s next sleep.

Source code in comicbox/events.py
258
259
260
261
262
263
264
265
266
267
268
269
@dataclass(frozen=True, slots=True, kw_only=True)
class RateLimited(Event):
    """
    Source signaled a rate-limit hit.

    ``retry_after_seconds`` is the server hint when available; otherwise
    the per-source retry-schedule's next sleep.
    """

    source: str = ""
    retry_after_seconds: float | None = None
    kind: Literal["rate_limited"] = "rate_limited"

ReadingListFetchFinished dataclass ¶

Bases: Event

A reading-list fetch ended, whether it fetched anything or not.

Source code in comicbox/events.py
308
309
310
311
312
313
314
@dataclass(frozen=True, slots=True, kw_only=True)
class ReadingListFetchFinished(Event):
    """A reading-list fetch ended, whether it fetched anything or not."""

    source: str = ""
    key: str = ""
    kind: Literal["reading_list_fetch_finished"] = "reading_list_fetch_finished"

ReadingListFetchProgress dataclass ¶

Bases: Event

Part of a reading list arrived.

index counts the entries fetched so far and total is how many the source said there are, when it said.

Source code in comicbox/events.py
294
295
296
297
298
299
300
301
302
303
304
305
@dataclass(frozen=True, slots=True, kw_only=True)
class ReadingListFetchProgress(Event):
    """
    Part of a reading list arrived.

    ``index`` counts the entries fetched so far and ``total`` is how many
    the source said there are, when it said.
    """

    source: str = ""
    key: str = ""
    kind: Literal["reading_list_fetch_progress"] = "reading_list_fetch_progress"

ReadingListFetchStarted dataclass ¶

Bases: Event

A reading-list fetch began. source is where from, key what.

Source code in comicbox/events.py
285
286
287
288
289
290
291
@dataclass(frozen=True, slots=True, kw_only=True)
class ReadingListFetchStarted(Event):
    """A reading-list fetch began. ``source`` is where from, ``key`` what."""

    source: str = ""
    key: str = ""
    kind: Literal["reading_list_fetch_started"] = "reading_list_fetch_started"

SearchCompleted dataclass ¶

Bases: Event

Online source returned candidate list.

Source code in comicbox/events.py
133
134
135
136
137
138
139
140
@dataclass(frozen=True, slots=True, kw_only=True)
class SearchCompleted(Event):
    """Online source returned candidate list."""

    source: str = ""
    n_candidates: int = 0
    top_score: float | None = None
    kind: Literal["search_completed"] = "search_completed"

SearchStarted dataclass ¶

Bases: Event

Worker is about to query an online source for this file.

Source code in comicbox/events.py
125
126
127
128
129
130
@dataclass(frozen=True, slots=True, kw_only=True)
class SearchStarted(Event):
    """Worker is about to query an online source for this file."""

    source: str = ""
    kind: Literal["search_started"] = "search_started"

SeriesIdentified dataclass ¶

Bases: Event

A series was resolved and cached for series-first batching.

Fired when a cold-path search resolves a series and the session’s series_cache is populated for the first time. Subsequent issues of the same series skip the search via :meth:OnlineSource.lookup_issue.

Source code in comicbox/events.py
152
153
154
155
156
157
158
159
160
161
162
163
164
165
@dataclass(frozen=True, slots=True, kw_only=True)
class SeriesIdentified(Event):
    """
    A series was resolved and cached for series-first batching.

    Fired when a cold-path search resolves a series and the session's
    ``series_cache`` is populated for the first time. Subsequent issues
    of the same series skip the search via :meth:`OnlineSource.lookup_issue`.
    """

    source: str = ""
    series_fingerprint: str = ""
    volume_id: int = 0
    kind: Literal["series_identified"] = "series_identified"

Skipped dataclass ¶

Bases: Event

A source wrote no metadata for this file, and says why.

reason is one of the SKIP_* constants above.

Source code in comicbox/events.py
237
238
239
240
241
242
243
244
245
246
247
@dataclass(frozen=True, slots=True, kw_only=True)
class Skipped(Event):
    """
    A source wrote no metadata for this file, and says why.

    ``reason`` is one of the ``SKIP_*`` constants above.
    """

    source: str = ""
    reason: str = ""
    kind: Literal["skipped"] = "skipped"

SourceStarted dataclass ¶

Bases: Event

Worker is about to consult one online source for this file.

Fired once per source that actually runs, immediately before the source is consulted and after the first-wins skip — a source sat out because an earlier one already won never emits this. Unlike :class:SearchStarted, which only covers the cold-search path, this fires for every route a source can take: explicit-id fetch, stored-id refresh, series-cache issue lookup, and search. Callers rendering “which source is being consulted right now” want this one; SearchStarted stays the narrower “a full search is about to be issued” signal.

Source code in comicbox/events.py
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
@dataclass(frozen=True, slots=True, kw_only=True)
class SourceStarted(Event):
    """
    Worker is about to consult one online source for this file.

    Fired once per source that actually runs, immediately before the source
    is consulted and *after* the first-wins skip — a source sat out because
    an earlier one already won never emits this. Unlike
    :class:`SearchStarted`, which only covers the cold-search path, this
    fires for every route a source can take: explicit-id fetch, stored-id
    refresh, series-cache issue lookup, and search. Callers rendering "which
    source is being consulted right now" want this one; ``SearchStarted``
    stays the narrower "a full search is about to be issued" signal.
    """

    source: str = ""
    kind: Literal["source_started"] = "source_started"