Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /ashita-ai_tessera /src /tessera /models /proposal.py
| """Proposal models.""" | |
| from datetime import datetime | |
| from typing import Any | |
| from uuid import UUID | |
| from pydantic import BaseModel, ConfigDict, Field, field_validator | |
| from tessera.models.enums import ChangeType, ProposalStatus | |
| class ProposalBreakingChangeDict(BaseModel): | |
| """A breaking change as stored in the proposal JSON column. | |
| Matches the output of ``schema_diff.BreakingChange.to_dict()``. | |
| """ | |
| type: str = Field(..., description="Change kind (e.g., 'property_removed', 'type_changed')") | |
| path: str = Field(default="", description="JSON path to the affected element") | |
| message: str = Field(default="", description="Human-readable description") | |
| old_value: Any = None | |
| new_value: Any = None | |
| class AffectedAsset(BaseModel): | |
| """An asset affected by a proposal via lineage.""" | |
| asset_id: str = Field(..., description="ID of the affected downstream asset") | |
| asset_fqn: str = Field(..., description="FQN of the affected downstream asset") | |
| owner_team_id: str = Field(..., description="Team ID that owns this asset") | |
| owner_team_name: str | None = Field(None, description="Team name that owns this asset") | |
| owner_user_id: str | None = Field(None, description="Individual user ID that owns this asset") | |
| owner_user_name: str | None = Field( | |
| None, description="Individual user name that owns this asset" | |
| ) | |
| class AffectedTeam(BaseModel): | |
| """A team affected by a proposal via lineage (owning downstream assets).""" | |
| team_id: str = Field(..., description="ID of the affected team") | |
| team_name: str = Field(..., description="Name of the affected team") | |
| assets: list[str] = Field( | |
| default_factory=list, description="Asset IDs owned by this team that are affected" | |
| ) | |
| class Objection(BaseModel): | |
| """An objection filed by an affected team.""" | |
| team_id: str = Field(..., description="ID of the team that objected") | |
| team_name: str = Field(..., description="Name of the team that objected") | |
| reason: str = Field(..., description="Reason for the objection") | |
| objected_at: datetime = Field(..., description="When the objection was filed") | |
| objected_by_user_id: str | None = Field(None, description="User ID who filed the objection") | |
| objected_by_user_name: str | None = Field(None, description="User name who filed the objection") | |
| class ObjectionCreate(BaseModel): | |
| """Request body for filing an objection to a proposal.""" | |
| reason: str = Field( | |
| ..., | |
| min_length=1, | |
| max_length=1000, | |
| description="Reason for objecting to this proposal", | |
| ) | |
| def validate_reason(cls, v: str) -> str: | |
| """Strip whitespace and validate reason.""" | |
| v = v.strip() | |
| if not v: | |
| raise ValueError("Reason cannot be empty or whitespace only") | |
| return v | |
| class PendingProposalSummary(BaseModel): | |
| """A proposal awaiting acknowledgment from a specific team.""" | |
| proposal_id: str = Field(..., description="Proposal UUID") | |
| asset_id: str = Field(..., description="Asset UUID this proposal targets") | |
| asset_fqn: str = Field(..., description="Fully-qualified name of the asset") | |
| proposed_by_team: str = Field(..., description="Name of the team that proposed the change") | |
| proposed_at: datetime = Field(..., description="When the proposal was created") | |
| expires_at: datetime | None = Field(None, description="When the proposal expires") | |
| breaking_changes_summary: list[str] = Field( | |
| default_factory=list, | |
| description="Human-readable summary of each breaking change", | |
| ) | |
| total_consumers: int = Field(..., description="Total registered consumers for this contract") | |
| acknowledged_count: int = Field(..., description="How many consumers have acknowledged") | |
| your_team_status: str = Field( | |
| ..., description="This team's acknowledgment status (e.g., AWAITING_RESPONSE)" | |
| ) | |
| class PendingProposalsResponse(BaseModel): | |
| """Response for the pending proposals endpoint.""" | |
| pending_proposals: list[PendingProposalSummary] | |
| total: int | |
| limit: int | |
| offset: int | |
| class ProposalBase(BaseModel): | |
| """Base proposal fields.""" | |
| proposed_schema: dict[str, object] = Field(..., description="Proposed JSON Schema") | |
| class ProposalCreate(ProposalBase): | |
| """Fields for creating a proposal.""" | |
| pass | |
| class Proposal(ProposalBase): | |
| """Proposal entity.""" | |
| model_config = ConfigDict(from_attributes=True) | |
| id: UUID | |
| asset_id: UUID | |
| change_type: ChangeType | |
| breaking_changes: list[ProposalBreakingChangeDict] = Field(default_factory=list) | |
| status: ProposalStatus = ProposalStatus.PENDING | |
| proposed_by: UUID | |
| proposed_by_user_id: UUID | None = None | |
| proposed_at: datetime | |
| resolved_at: datetime | None = None | |
| expires_at: datetime | None = None | |
| auto_expire: bool = False | |
| updated_at: datetime | None = None | |
| # Affected parties discovered via lineage (not registered consumers) | |
| affected_teams: list[AffectedTeam] = Field( | |
| default_factory=list, | |
| description="Teams owning downstream assets affected by this change", | |
| ) | |
| affected_assets: list[AffectedAsset] = Field( | |
| default_factory=list, | |
| description="Downstream assets that depend on this asset", | |
| ) | |
| objections: list[Objection] = Field( | |
| default_factory=list, | |
| description="Objections filed by affected teams (non-blocking)", | |
| ) | |
| has_objections: bool = Field( | |
| default=False, | |
| description="True if any affected teams have objected", | |
| ) | |
| def model_post_init(self, __context: object) -> None: | |
| """Compute has_objections from objections list.""" | |
| object.__setattr__(self, "has_objections", len(self.objections) > 0) | |
| # --------------------------------------------------------------------------- | |
| # Proposal status (enriched) response models | |
| # --------------------------------------------------------------------------- | |
| class ProposalStatusProposer(BaseModel): | |
| """Team/user that proposed the change.""" | |
| team_id: str | |
| team_name: str | |
| user_id: str | None = None | |
| user_name: str | None = None | |
| class ProposalStatusConsumers(BaseModel): | |
| """Aggregated consumer acknowledgment counts.""" | |
| total: int | |
| acknowledged: int | |
| pending: int | |
| blocked: int | |
| class ProposalStatusAcknowledgment(BaseModel): | |
| """A single consumer acknowledgment in the status response.""" | |
| consumer_team_id: str | |
| consumer_team_name: str | |
| acknowledged_by_user_id: str | None = None | |
| acknowledged_by_user_name: str | None = None | |
| response: str | |
| responded_at: str | |
| notes: str | None = None | |
| class ProposalStatusPendingConsumer(BaseModel): | |
| """A consumer that has not yet acknowledged.""" | |
| team_id: str | |
| team_name: str | |
| registered_at: str | |
| class ProposalStatusResponse(BaseModel): | |
| """Full proposal status including acknowledgment progress and audit info.""" | |
| proposal_id: str | |
| status: str | |
| asset_id: str | |
| asset_fqn: str | None = None | |
| change_type: str | |
| breaking_changes: list[ProposalBreakingChangeDict] = Field(default_factory=list) | |
| proposed_by: ProposalStatusProposer | |
| proposed_at: str | |
| resolved_at: str | None = None | |
| expires_at: str | None = None | |
| auto_expire: bool = False | |
| proposed_schema: dict[str, object] = Field(default_factory=dict) | |
| affected_teams: list[AffectedTeam] = Field(default_factory=list) | |
| affected_assets: list[AffectedAsset] = Field(default_factory=list) | |
| objections: list[Objection] = Field(default_factory=list) | |
| has_objections: bool = False | |
| consumers: ProposalStatusConsumers | |
| acknowledgments: list[ProposalStatusAcknowledgment] = Field(default_factory=list) | |
| pending_consumers: list[ProposalStatusPendingConsumer] = Field(default_factory=list) | |
| audit_status: dict[str, Any] | None = None | |
| warnings: list[str] = Field(default_factory=list) | |
Xet Storage Details
- Size:
- 7.95 kB
- Xet hash:
- 0518bc81e18b5e81de1dd7584c3e140f09789a6bf33e996a87a3b7c4606c217f
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.