Skip to content

Add relational schema design plan and Rust hello binding fallback - #13

Draft
leynos wants to merge 1 commit into
mainfrom
design-relational-schema-v2-2-1-7oobm9
Draft

Add relational schema design plan and Rust hello binding fallback#13
leynos wants to merge 1 commit into
mainfrom
design-relational-schema-v2-2-1-7oobm9

Conversation

@leynos

@leynos leynos commented Feb 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • Introduces the Relational Schema Design ExecPlan (2.2.1) to guide SQLAlchemy/PostgreSQL schema work for canonical content, ingestion, provenance, and approval workflows.
  • Adds robust optional Rust bindings wiring for the public hello function with a Python fallback to ensure compatibility in environments without Rust extensions.

Changes

  • New: docs/execplans/2-2-1-relational-schema-design.md
    • Contains the living exec plan outlining purpose, progress, decisions, plan of work, and validation criteria for the relational schema design.
  • Code:
    • Updated episodic/init.py to import hello from episodic._hello to support the optional Rust binding path.
    • Added episodic/_hello.py to resolve the Rust binding for the public hello function, with a Python fallback if the Rust module is not available.

Design rationale

  • The ExecPlan documents the scope for modeling TEI headers, canonical episodes, ingestion jobs, source documents, series profiles, and approval state tracking within a hexagonal architecture.
  • The Rust binding goal is to provide optional acceleration while preserving a pure-Python fallback to ensure broad compatibility across environments (CI, dev, and users).
  • The changes are intentionally non-breaking: existing Python-only usage continues to work when the Rust binding is unavailable.

How to test locally

  • Import and call the hello entrypoint (works with or without Rust extension):
    • python -c "from episodic import hello; print(hello())"
  • Validate import paths:
    • Without the Rust module installed: ensure the Python fallback path is taken (no ImportError).
    • With the Rust binding available (if built/installed): ensure the Rust-accelerated path is used.

Validation plan

  • Ensure the new docs file is present and readable: docs/execplans/2-2-1-relational-schema-design.md
  • Ensure episodic.hello() resolves via _hello.py in both scenarios (Rust present vs. absent).
  • (Future) Extend tests to cover Alembic migrations, SQLAlchemy models, and ingestion/approval workflows as per the ExecPlan.

Documentation updates

  • The Relational Schema Design ExecPlan serves as the guiding doc for the upcoming schema work and will be expanded with concrete models, migrations, and tests.
  • This PR lays the groundwork for plan visibility and traceability of design decisions.

Artifacts and notes

  • Branch: design-relational-schema-v2-2-1-7oobm9
  • No database migrations are added yet; this is a planning and wiring change plus new planning doc.
  • If any quality gates fail due to missing Rust bindings in certain environments, the Python fallback path guarantees continued operability.

◳ Generated by DevBoxer


ℹ️ Tag @devboxerhub to ask questions and address PR feedback

📎 Task: https://www.devboxer.com/task/d3154e2f-0f5f-41f6-a32f-76f3fe7830ad

Summary by Sourcery

Introduce a relational schema design exec plan document and centralize resolution of the optional Rust-backed hello binding behind a dedicated helper module.

Enhancements:

  • Refactor hello export to use a dedicated helper module that transparently selects the Rust implementation when available and falls back to the Python version otherwise.

Documentation:

  • Add an ExecPlan document outlining the relational schema design work for canonical content, ingestion, provenance, and approval workflows.

- Introduce a comprehensive ExecPlan for relational schema design covering TEI headers, canonical episodes, ingestion jobs, source documents, series profiles, and approval states.
- Document design decisions, context, concrete steps, validation criteria, and interfaces for schema development.
- Provide a roadmap to implement SQLAlchemy models, Alembic migrations, tests, and documentation updates.
- Aim to support auditable ingestion, approval workflows, and stable downstream service interfaces.

This new document guides the development, testing, and documentation of the canonical content foundation schema.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch design-relational-schema-v2-2-1-7oobm9

Comment @coderabbitai help to get the list of available commands and usage tips.

@sourcery-ai

sourcery-ai Bot commented Feb 2, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds a living ExecPlan document for upcoming relational schema design work and refactors the public episodic.hello entrypoint to resolve an optional Rust implementation via a new helper module with a Python fallback.

Sequence diagram for episodic.hello resolution with optional Rust binding

sequenceDiagram
    actor User
    participant PythonRuntime
    participant episodic as episodic_package
    participant _hello as episodic__hello_module
    participant RustExt as _episodic_rs_extension
    participant Pure as episodic_pure_module

    User->>PythonRuntime: from episodic import hello
    PythonRuntime->>episodic: import episodic
    episodic->>_hello: from ._hello import hello

    _hello->>PythonRuntime: __import(_episodic_rs)
    alt Rust extension available
        PythonRuntime-->>_hello: returns RustExt
        _hello->>RustExt: access hello
        RustExt-->>_hello: function hello
        _hello-->>episodic: bind hello to RustExt.hello
    else Rust extension missing
        PythonRuntime-->>_hello: raises ModuleNotFoundError
        _hello->>Pure: from .pure import hello
        Pure-->>_hello: Python hello function
        _hello-->>episodic: bind hello to Pure.hello
    end

    episodic-->>PythonRuntime: export hello in __all__
    PythonRuntime-->>User: hello bound to chosen implementation

    User->>PythonRuntime: print(hello())
    PythonRuntime->>episodic: call hello()
    episodic->>_hello: delegate to bound hello
Loading

Class diagram for modules involved in episodic.hello resolution

classDiagram
    class episodic {
        +hello()
    }

    class episodic__hello {
        +PACKAGE_NAME : str
        +hello()
    }

    class episodic_pure {
        +hello()
    }

    class _episodic_rs {
        +hello()
    }

    episodic --> episodic__hello : imports hello from
    episodic__hello --> _episodic_rs : optionally imports
    episodic__hello --> episodic_pure : falls back to
Loading

Flow diagram for hello implementation selection in episodic._hello

flowchart TD
    A[Start import of episodic._hello] --> B[Set PACKAGE_NAME = episodic]
    B --> C[Attempt to import module _episodic_rs]
    C -->|Import succeeds| D[Bind hello = rust.hello]
    C -->|ModuleNotFoundError| E[Import hello from episodic.pure]
    D --> F[hello refers to Rust implementation]
    E --> F[hello refers to Python implementation]
    F --> G[episodic.__init__ does from ._hello import hello]
    G --> H[episodic.hello is available to callers]
Loading

File-Level Changes

Change Details Files
Refactor hello entrypoint to route through a dedicated resolver that prefers an optional Rust binding with a Python fallback.
  • Remove inline Rust import / Python fallback logic from the package init and replace it with a simple import of hello from a helper module.
  • Introduce a _hello helper module that attempts to import the Rust extension module and, on failure, falls back to importing hello from the pure-Python implementation.
  • Ensure the public episodic.hello symbol continues to resolve correctly via all while keeping behaviour non-breaking when Rust is absent.
episodic/__init__.py
episodic/_hello.py
Introduce an ExecPlan document that defines the scope, steps, and acceptance criteria for relational schema design using SQLAlchemy and Postgres.
  • Add a Markdown ExecPlan describing purpose, context, and terminology for the canonical content relational schema.
  • Document a concrete plan of work, validation criteria, and tooling commands for implementing models, migrations, and tests.
  • Capture progress tracking, future decision log, and outcomes sections to be updated as schema work proceeds.
docs/execplans/2-2-1-relational-schema-design.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant