Skip to content

[Database] Define Pydantic v2 models and initial relational schema (incidents, models, audits) #21

Open

Description

@saviornt

Description

Define strongly-typed Pydantic v2 models for validation/serialization and matching SQLAlchemy table definitions for the core entities: incidents, model registry, policy audits, and FAISS vector metadata.

Type

  • Task

Focus Area (pick one)

  • Shared Utils & Models

Priority

  • High

Acceptance Criteria

  • File: shared/src/database/schemas.py
    • Pydantic v2 models: IncidentBase, IncidentCreate, IncidentRead, IncidentInDB
    • Pydantic v2 models: ModelRegistryBase, ModelCreate, ModelInDB
    • Pydantic v2 models: PolicyAuditBase, PolicyAuditCreate, PolicyAuditInDB
    • Pydantic v2 model: FaissVectorMetadata
    • Use field_validator, ConfigDict(from_attributes=True), strict mode where appropriate
  • File: shared/src/database/models.py (or inside sqlite.py)
    • SQLAlchemy 2.0 declarative base classes matching above
    • Tables created: incidents, model_registry, policy_audits, faiss_vectors_metadata
    • Appropriate indexes: timestamp ranges, device_mac, incident_type, vector_id
    • Modern mapped_column syntax with typing
  • Google-style docstrings on every model and field
  • Alembic initial migration stub created (even if not applied yet)
  • mypy strict mode passes

Blocker / Dependencies

  • [Database] Implement robust async SQLite session factory + connection pooling

Notes / Links

  • Reference: tentative schema in docs/database_schema.md
  • Related files: shared/src/database/session.py

Activity

  1. self-assigned this
    on Mar 19, 2026
  2. added
    task
    needs-triage
    on Mar 19, 2026
  3. moved this from To Do to In Progress in Network-Chan Project Developmenton Mar 19, 2026
  4. moved this from In Progress to Manual QA Testing in Network-Chan Project Developmenton Mar 19, 2026
  5. Mardon-programm commented on Nov 28, 2026

    @Mardon-programm

    Hi,

    Saw your open issue on updating Pydantic models, validators, and schema fields while keeping runtime behavior intact.

    We built OmniMigrate — an AST/LibCST + LLM migration engine with an anti-shrinkage contract that prevents silent symbol drops, missing fields, or unintended logic shifts during rewrites (validated on 61k LOC of Zope with 100.4% symbol preservation and 0 ruff F821 errors).

    No demo or call needed — send me one Python model/schema file, and I’ll run a free contract check on it and send back the verified diff + audit report within 24 hours.

    Worth testing on a single file?

    Best,

    Mardonbek

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

Metadata

Metadata

Assignees

Labels

databaseneeds-triagetask

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions