Every mapped table resolves a retention policy; a report-only job runs over all of them and logs "N records to purge". ARCH §6.4; NIST AU-11, SI-12; source RFP C.5.7.42. - framework/retention.py: RetentionPolicy (data class, disposal, period, anchor column, cadence, approved, authority), run_retention(), and a `python -m ypms.framework.retention` entrypoint. Phase 0 never mutates data: interim-period rows are counted (interim_eligible), approved-period rows are counted (to_purge), nothing is purged. One retention_run audit row per run. - retention_classes.py: PIA §9 data classes at their interim periods, all approved=False pending YPMS-POAM-054. Classes without a PIA basis (hosts, operational logs, accounts, consent-derived) are unset and logged by name with their governing POA&M item. Vendored framework tables are mapped by table name so vendored files stay unchanged. - stub_models.py + migration 0004: id + mixin models for the 26 stub entities so each can carry a policy. Migration uses a literal table list. - ypms/models.py: single import-all module used by Alembic env, the job, and the test fixtures. - Drift guard: test upgrades a scratch SQLite DB to head and compares to Base.metadata. Found pre-existing drift in 0002 (named unique constraints duplicating the unique indexes on roles.code, users.username, users.email); allow-listed, follow-up noted in PHASE0_STATUS. 156 tests passing; ruff + mypy clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
"""Test-only entity used to exercise the framework without pulling in a real
|
|
domain entity. Milestone 0.5 introduces the Registrant entity for the vertical
|
|
slice; until then, this Thing model is enough to prove CRUD + audit + versioning.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import ClassVar
|
|
|
|
from pydantic import BaseModel
|
|
from sqlalchemy import String
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from ypms.db import Base
|
|
from ypms.framework.base import SoftDeleteMixin, TimestampMixin, VersionedMixin
|
|
from ypms.framework.retention import Disposal, RetentionPolicy
|
|
|
|
|
|
class Thing(Base, TimestampMixin, SoftDeleteMixin, VersionedMixin):
|
|
__tablename__ = "things"
|
|
# Every mapped table needs a policy, test-only ones included (milestone 0.7).
|
|
retention_policy: ClassVar[RetentionPolicy] = RetentionPolicy(
|
|
"test_fixture", Disposal.RETAIN, None, authority="test-only model"
|
|
)
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
name: Mapped[str] = mapped_column(String(64), nullable=False)
|
|
color: Mapped[str | None] = mapped_column(String(32), nullable=True)
|
|
|
|
|
|
class ThingCreate(BaseModel):
|
|
name: str
|
|
color: str | None = None
|
|
|
|
|
|
class ThingUpdate(BaseModel):
|
|
name: str | None = None
|
|
color: str | None = None
|
|
|
|
|
|
class ThingRead(BaseModel):
|
|
id: int
|
|
name: str
|
|
color: str | None = None
|
|
version: int
|