Derive frontmatter and task-block depends_on edges from the pinned commit and reconcile workplan_dependencies under an explicit ownership contract: only forge:<repo> rows are created or removed, external relations are preserved, missing/ambiguous/self targets are recorded and hold owned edges, failures roll back, and repeat receipts are noop. Additive migration b3c4d5e6f7a8. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Assistant: claude-code Assistant-Model: opus Assistant-Process: 671493@bnt-lap001 Assistant-Session: 60d7b11f-78f9-4731-9367-918511b2762d
71 lines
No EOL
2.2 KiB
Python
71 lines
No EOL
2.2 KiB
Python
import uuid
|
|
from datetime import datetime
|
|
|
|
from pydantic import AliasChoices, BaseModel, ConfigDict, Field, computed_field
|
|
|
|
|
|
class WorkplanDependencyCreate(BaseModel):
|
|
to_workplan_id: uuid.UUID | None = Field(
|
|
default=None,
|
|
validation_alias=AliasChoices("to_workplan_id", "to_workstream_id"),
|
|
)
|
|
to_task_id: uuid.UUID | None = None
|
|
from_task_id: uuid.UUID | None = None
|
|
relationship_type: str = "blocks"
|
|
description: str | None = None
|
|
|
|
|
|
class WorkplanDependencyRead(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
id: uuid.UUID
|
|
from_workplan_id: uuid.UUID
|
|
from_task_id: uuid.UUID | None = None
|
|
to_workplan_id: uuid.UUID | None = None
|
|
to_task_id: uuid.UUID | None = None
|
|
relationship_type: str
|
|
description: str | None = None
|
|
source_owner: str | None = None
|
|
source_commit: str | None = None
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
|
|
class WorkplanDepStub(BaseModel):
|
|
"""Minimal projection of the other end of a dependency edge."""
|
|
dep_id: uuid.UUID
|
|
target_type: str = "workplan"
|
|
relationship_type: str = "blocks"
|
|
workplan_id: uuid.UUID | None = Field(
|
|
default=None,
|
|
validation_alias=AliasChoices("workplan_id", "workstream_id"),
|
|
)
|
|
workplan_slug: str | None = Field(
|
|
default=None,
|
|
validation_alias=AliasChoices("workplan_slug", "workstream_slug"),
|
|
)
|
|
workplan_title: str | None = Field(
|
|
default=None,
|
|
validation_alias=AliasChoices("workplan_title", "workstream_title"),
|
|
)
|
|
task_id: uuid.UUID | None = None
|
|
task_title: str | None = None
|
|
# The waiting task on a task-scoped edge (workplan_dependencies.from_task_id);
|
|
# None on frontmatter edges.
|
|
from_task_id: uuid.UUID | None = None
|
|
from_task_title: str | None = None
|
|
description: str | None = None
|
|
|
|
@computed_field # type: ignore[prop-decorator]
|
|
@property
|
|
def workstream_id(self) -> uuid.UUID | None:
|
|
return self.workplan_id
|
|
|
|
@computed_field # type: ignore[prop-decorator]
|
|
@property
|
|
def workstream_slug(self) -> str | None:
|
|
return self.workplan_slug
|
|
|
|
@computed_field # type: ignore[prop-decorator]
|
|
@property
|
|
def workstream_title(self) -> str | None:
|
|
return self.workplan_title |