This commit is contained in:
@@ -1696,6 +1696,8 @@ class SQLAlchemyCloudRepository:
|
||||
now: datetime,
|
||||
rationale: str | None = None,
|
||||
thinking: str | None = None,
|
||||
purpose: str | None = None,
|
||||
expected_outcome: str | None = None,
|
||||
) -> int:
|
||||
with self._sessions.begin() as session:
|
||||
current_max = session.scalars(
|
||||
@@ -1718,6 +1720,8 @@ class SQLAlchemyCloudRepository:
|
||||
created_at=_iso(now),
|
||||
rationale=rationale,
|
||||
thinking=thinking,
|
||||
purpose=purpose,
|
||||
expected_outcome=expected_outcome,
|
||||
)
|
||||
)
|
||||
session.flush()
|
||||
@@ -1772,6 +1776,8 @@ class SQLAlchemyCloudRepository:
|
||||
created_at=_parse_dt(row.created_at), # type: ignore[arg-type]
|
||||
rationale=row.rationale,
|
||||
thinking=row.thinking,
|
||||
purpose=row.purpose,
|
||||
expected_outcome=row.expected_outcome,
|
||||
)
|
||||
for row in rows
|
||||
]
|
||||
@@ -1894,9 +1900,7 @@ class SQLAlchemyCloudRepository:
|
||||
CloudSkillEntitlementRow.skill_id == skill_id
|
||||
)
|
||||
)
|
||||
session.execute(
|
||||
delete(CloudSkillRow).where(CloudSkillRow.id == skill_id)
|
||||
)
|
||||
session.execute(delete(CloudSkillRow).where(CloudSkillRow.id == skill_id))
|
||||
|
||||
def list_entitlements_for_skill(self, skill_id: str) -> list[str]:
|
||||
with self._sessions() as session:
|
||||
@@ -1922,13 +1926,9 @@ class SQLAlchemyCloudRepository:
|
||||
skills.sort(key=lambda s: s.name_normalized)
|
||||
return skills
|
||||
|
||||
def grant_entitlement(
|
||||
self, skill_id: str, host_id: str, *, now: datetime
|
||||
) -> None:
|
||||
def grant_entitlement(self, skill_id: str, host_id: str, *, now: datetime) -> None:
|
||||
with self._sessions.begin() as session:
|
||||
existing = session.get(
|
||||
CloudSkillEntitlementRow, (skill_id, host_id)
|
||||
)
|
||||
existing = session.get(CloudSkillEntitlementRow, (skill_id, host_id))
|
||||
if existing is not None:
|
||||
return # idempotent
|
||||
session.add(
|
||||
@@ -1940,21 +1940,15 @@ class SQLAlchemyCloudRepository:
|
||||
)
|
||||
self._bump_host(session, host_id, skill_id, "upsert", now)
|
||||
|
||||
def revoke_entitlement(
|
||||
self, skill_id: str, host_id: str, *, now: datetime
|
||||
) -> None:
|
||||
def revoke_entitlement(self, skill_id: str, host_id: str, *, now: datetime) -> None:
|
||||
with self._sessions.begin() as session:
|
||||
existing = session.get(
|
||||
CloudSkillEntitlementRow, (skill_id, host_id)
|
||||
)
|
||||
existing = session.get(CloudSkillEntitlementRow, (skill_id, host_id))
|
||||
if existing is None:
|
||||
return
|
||||
session.delete(existing)
|
||||
self._bump_host(session, host_id, skill_id, "remove", now)
|
||||
|
||||
def fetch_host_delta(
|
||||
self, host_id: str, since_version: int | None
|
||||
) -> Any:
|
||||
def fetch_host_delta(self, host_id: str, since_version: int | None) -> Any:
|
||||
from cloud.skills import HostSkillDelta
|
||||
|
||||
with self._sessions.begin() as session:
|
||||
|
||||
Reference in New Issue
Block a user