Skip to content

refactor: split source acquisition into explicit components #324

Closed

Description

@Sinity

Context

The low-churn audit in #315 found that polylogue/sources/source_acquisition.py mixes source walking, ZIP entry handling, split-payload buffering, cursor recovery, provider hints, and observation reporting in a long orchestration flow.

This is a good candidate for whole-file renewal: the concern boundaries are visible, but the implementation still combines them procedurally.

Scope

Split source acquisition into explicit components while preserving provider detection and ingestion behavior.

Candidate boundaries:

  • archive/file walker
  • ZIP entry reader
  • split payload buffer/reassembler
  • provider hint and detection adapter
  • acquisition failure/observation recorder

Acceptance criteria

  • Acquisition components have typed boundaries and focused responsibilities.
  • ZIP, split JSON/JSONL, and normal file acquisition behavior remains compatible.
  • Cursor/failure diagnostics stay at least as actionable as today.
  • Source acquisition tests cover representative component boundaries.
  • devtools verify passes before PR merge.

Ref #315

Activity

  1. added
    type:refactor
    on Apr 21, 2026
  2. Sinity commented on Apr 22, 2026

    @Sinity
    OwnerAuthor

    Starting #324 on feature/refactor/source-acquisition-components.

    Initial boundary:

    • Keep polylogue.sources.source_acquisition.iter_source_raw_data() as the compatibility entrypoint.
    • Split local-file, ZIP-entry, split-payload, observation/status, and raw-record construction concerns behind typed helpers.
    • Preserve current source walking, provider detection, cursor diagnostics, blob-store semantics, and acquisition behavior for plain files, grouped ZIP entries, split JSON/JSONL entries, and zero-byte/read-failure cases.

    First implementation pass will focus on polylogue/sources/source_acquisition.py and representative tests in tests/unit/sources/test_source_laws.py.

  3. Sinity commented on Apr 22, 2026

    @Sinity
    OwnerAuthor

    Progress update for #324:

    • Added polylogue/sources/source_acquisition_components.py as the typed component layer for local acquisition.
    • Moved status heartbeats, observation payload creation, blob streaming, raw metadata construction, plain-file reads, ZIP preserved-entry reads, streamed JSON provider detection, and ZIP split-payload buffering/materialization out of the root iterator.
    • Kept polylogue.sources.source_acquisition.iter_source_raw_data() as the compatibility entrypoint; it now focuses on source walking, zero-byte cursor failures, top-level read exception handling, and summary logging.
    • Updated source-law monkeypatch targets from the old monolithic private helpers to the new component module.

    Focused verification so far:

    • ruff check polylogue/sources/source_acquisition.py polylogue/sources/source_acquisition_components.py tests/unit/sources/test_source_laws.py
    • mypy polylogue/sources/source_acquisition.py polylogue/sources/source_acquisition_components.py
    • pytest -q tests/unit/sources/test_source_laws.py -> 111 passed in 8.87s
    • pytest -q tests/unit/pipeline/test_run_sources.py tests/unit/sources/test_source_laws.py -> 159 passed in 9.55s

    Next: review/stage the diff, commit this slice, then run the full local gate before opening the PR.

  4. added a commit that references this issue on May 7, 2026
    8bd772a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:parserarea:pipelinetype:refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions