Skip to content

Phase 2: Create Python package skeleton #4

Description

@tinkermonkey

Establish the full src/context_library/ package hierarchy with all sub-packages and placeholder module files, mirrored by a parallel tests/ directory structure.

Requirements

  • Create src/context_library/ as the root Python package with __init__.py
  • Create the following sub-packages, each with an __init__.py:
    • src/context_library/core/
    • src/context_library/domains/
    • src/context_library/adapters/
    • src/context_library/storage/
    • src/context_library/retrieval/
    • src/context_library/scheduler/
  • Create placeholder module files (each containing only a module docstring) in each sub-package:
    • core/: pipeline.py, differ.py, embedder.py, versioner.py, chunker.py
    • domains/: base.py, messages.py, notes.py, events.py, tasks.py
    • adapters/: base.py
    • storage/: document_store.py, vector_store.py, models.py
    • retrieval/: query.py, reranker.py, provenance.py
    • scheduler/: poller.py, watcher.py
  • Create a tests/ directory at the project root mirroring the sub-package structure:
    • tests/__init__.py
    • tests/core/__init__.py
    • tests/domains/__init__.py
    • tests/adapters/__init__.py
    • tests/storage/__init__.py
    • tests/retrieval/__init__.py
    • tests/scheduler/__init__.py

Design Guidance

  • The src/ layout (not flat) is required. It prevents accidental imports of the development package during testing.
  • __init__.py files are empty.
  • Each placeholder .py module contains only a docstring describing the component's role, derived from the architecture. Example docstrings:
    • core/pipeline.py: """Orchestrates the full ingestion pipeline: fetch → normalize → diff → chunk → embed → store."""
    • core/differ.py: """Computes diffs between normalized content versions to detect real changes."""
    • core/embedder.py: """Wraps the embedding model; converts chunk text to dense vectors."""
    • core/versioner.py: """Manages source version records and content-addressed chunk hashing."""
    • core/chunker.py: """Delegates domain-specific chunking; applies the recursive markdown chunking algorithm."""
    • domains/base.py: """Abstract base class defining the BaseDomain interface."""
    • domains/messages.py: """MessagesDomain: chunking and metadata for email, chat, and forum content."""
    • domains/notes.py: """NotesDomain: chunking and metadata for freeform notes."""
    • domains/events.py: """EventsDomain: time-windowed summaries for structured event records."""
    • domains/tasks.py: """TasksDomain: one-task-per-chunk strategy with lifecycle state tracking."""
    • adapters/base.py: """Abstract BaseAdapter defining the adapter contract."""
    • storage/document_store.py: """SQLite-backed document store; source of truth for versions, chunks, and lineage."""
    • storage/vector_store.py: """LanceDB-backed vector index; derived and fully rebuildable from the document store."""
    • storage/models.py: """Shared Pydantic data models: Chunk, LineageRecord, SourceVersion, VersionDiff."""
    • retrieval/query.py: """Semantic query interface combining vector search with optional metadata filters."""
    • retrieval/reranker.py: """Reranks vector search results using cross-encoder or lexical signals."""
    • retrieval/provenance.py: """Traces chunk provenance via SQLite: version diffs, source history, lineage chains."""
    • scheduler/poller.py: """Polling-based ingestion trigger; manages per-adapter poll intervals."""
    • scheduler/watcher.py: """Push/webhook-based ingestion trigger for real-time adapter events."""
  • Dependency direction (must not be violated in future implementation):
    • schedulercore
    • adapterscore (types only)
    • coredomains, storage
    • retrievalstorage
    • Nothing depends on adapters or scheduler

Acceptance Criteria

  • src/context_library/__init__.py exists
  • Each of core, domains, adapters, storage, retrieval, scheduler sub-packages exists with an __init__.py
  • All 22 placeholder module files listed in requirements exist
  • Each placeholder module file contains a module-level docstring and no other code
  • tests/ directory exists with __init__.py and one sub-directory per package, each containing __init__.py
  • No file in src/ or tests/ contains executable code (imports, class/function definitions)

Parent Issue

Part of #1

Discussion

This work is detailed in discussion 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions