Skip to content

Commit 345b94c

Browse files
committed
ingest
1 parent 35b2cbe commit 345b94c

2 files changed

Lines changed: 13 additions & 19 deletions

File tree

docs/plans/2026-05-11-pivot-cleanup-tier1-tier2.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,11 +486,11 @@ git commit -m "cleanup: drop _set_corpus alias"
486486
**Pros:** Removes ceremony. `_SourceSpec` adds zero over `type[Source]`.
487487
**Cons:** If a second field (`enable_flag`, `default_kwargs`) is coming, the dataclass becomes useful — but per CLAUDE.md, design for today, not hypothetical futures.
488488

489-
- [ ] **Step 1: Find all `_SourceSpec` / `source_class` references**
489+
- [x] **Step 1: Find all `_SourceSpec` / `source_class` references**
490490

491491
Run: `git grep -n '_SourceSpec\|source_class' slopmortem/cli/_ingest_cmd.py`
492492

493-
- [ ] **Step 2: Replace the dataclass with a bare type alias**
493+
- [x] **Step 2: Replace the dataclass with a bare type alias**
494494

495495
In `slopmortem/cli/_ingest_cmd.py:455-465`, delete the `_SourceSpec` dataclass definition and change:
496496

@@ -516,12 +516,12 @@ _SOURCE_REGISTRY: dict[str, type[Source]] = {
516516

517517
Replace every `spec.source_class` lookup elsewhere in the file with the registry value directly (e.g. `_SOURCE_REGISTRY[name]` instead of `_SOURCE_REGISTRY[name].source_class`).
518518

519-
- [ ] **Step 3: Verify**
519+
- [x] **Step 3: Verify**
520520

521521
Run: `just test && just typecheck && just lint`
522522
Expected: all pass.
523523

524-
- [ ] **Step 4: Commit**
524+
- [x] **Step 4: Commit**
525525

526526
```bash
527527
git add slopmortem/cli/_ingest_cmd.py

slopmortem/cli/_ingest_cmd.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import functools
1313
import os
14-
from dataclasses import dataclass
1514
from pathlib import Path
1615
from typing import TYPE_CHECKING, Annotated, cast
1716

@@ -308,14 +307,14 @@ async def _run_ingest( # noqa: PLR0913, PLR0912, PLR0915, C901 - the ingest CLI
308307
valid = ", ".join(sorted(_SOURCE_REGISTRY))
309308
msg = f"--only-source: unknown source {only_source!r}. Valid: {valid}."
310309
raise typer.BadParameter(msg)
311-
spec = _SOURCE_REGISTRY[only_source]
310+
source_class = _SOURCE_REGISTRY[only_source]
312311
# Each opt-in source's --enable-* flag needs an explicit branch here —
313312
# Python's keyword-only parameter binding can't be table-driven without
314313
# ``locals()`` tricks. Add one when introducing a new opt-in source.
315-
if spec.source_class is TavilyNewsSource:
314+
if source_class is TavilyNewsSource:
316315
enable_tavily_news = True
317316
# crunchbase_csv is gated by a path argument, not a boolean — require it explicitly.
318-
if spec.source_class is CrunchbaseCsvSource and crunchbase_csv is None:
317+
if source_class is CrunchbaseCsvSource and crunchbase_csv is None:
319318
msg = "--only-source crunchbase_csv requires --crunchbase-csv PATH."
320319
raise typer.BadParameter(msg)
321320

@@ -351,7 +350,7 @@ async def _run_ingest( # noqa: PLR0913, PLR0912, PLR0915, C901 - the ingest CLI
351350
)
352351

353352
if only_source is not None:
354-
wanted_class = _SOURCE_REGISTRY[only_source].source_class
353+
wanted_class = _SOURCE_REGISTRY[only_source]
355354
sources = [s for s in sources if isinstance(s, wanted_class)]
356355
if not sources:
357356
msg = (
@@ -452,16 +451,11 @@ async def _run_ingest( # noqa: PLR0913, PLR0912, PLR0915, C901 - the ingest CLI
452451
typer.echo(f"slopmortem ingest result: {result} cost=${budget.spent_usd:.4f}")
453452

454453

455-
@dataclass(frozen=True)
456-
class _SourceSpec:
457-
source_class: type[Source]
458-
459-
460-
_SOURCE_REGISTRY: dict[str, _SourceSpec] = {
461-
"curated": _SourceSpec(source_class=CuratedSource),
462-
"hn_algolia": _SourceSpec(source_class=HNAlgoliaSource),
463-
"crunchbase_csv": _SourceSpec(source_class=CrunchbaseCsvSource),
464-
"tavily_news": _SourceSpec(source_class=TavilyNewsSource),
454+
_SOURCE_REGISTRY: dict[str, type[Source]] = {
455+
"curated": CuratedSource,
456+
"hn_algolia": HNAlgoliaSource,
457+
"crunchbase_csv": CrunchbaseCsvSource,
458+
"tavily_news": TavilyNewsSource,
465459
}
466460

467461

0 commit comments

Comments
 (0)