Compare commits

...

1 Commits

Author SHA1 Message Date
dadachann 41bc5e69f5 style: format workspace identity modules 2026-07-31 15:45:28 +00:00
3 changed files with 8 additions and 18 deletions
@@ -67,10 +67,7 @@ def _suspend_postgres_rls(
states: dict[str, tuple[bool, bool]] = {} states: dict[str, tuple[bool, bool]] = {}
for table_name in table_names: for table_name in table_names:
row = conn.execute( row = conn.execute(
sa.text( sa.text('SELECT relrowsecurity, relforcerowsecurity FROM pg_class WHERE oid = to_regclass(:table_name)'),
'SELECT relrowsecurity, relforcerowsecurity '
'FROM pg_class WHERE oid = to_regclass(:table_name)'
),
{'table_name': table_name}, {'table_name': table_name},
).one() ).one()
enabled, forced = bool(row.relrowsecurity), bool(row.relforcerowsecurity) enabled, forced = bool(row.relrowsecurity), bool(row.relforcerowsecurity)
@@ -141,18 +138,11 @@ def upgrade() -> None:
if table_name == 'workspaces': if table_name == 'workspaces':
continue continue
table = sa.Table(table_name, metadata, autoload_with=conn, extend_existing=True) table = sa.Table(table_name, metadata, autoload_with=conn, extend_existing=True)
conn.execute( conn.execute(table.update().where(table.c.workspace_uuid == old_uuid).values(workspace_uuid=canonical_uuid))
table.update()
.where(table.c.workspace_uuid == old_uuid)
.values(workspace_uuid=canonical_uuid)
)
if 'metadata' in table_names: if 'metadata' in table_names:
conn.execute( conn.execute(
sa.text( sa.text('UPDATE metadata SET value = :canonical_uuid WHERE key = :key AND value = :old_uuid'),
'UPDATE metadata SET value = :canonical_uuid '
'WHERE key = :key AND value = :old_uuid'
),
{ {
'canonical_uuid': canonical_uuid, 'canonical_uuid': canonical_uuid,
'key': _OSS_WORKSPACE_METADATA_KEY, 'key': _OSS_WORKSPACE_METADATA_KEY,
+2 -2
View File
@@ -12,5 +12,5 @@ def workspace_identity(execution_context: WorkspaceExecutionContext) -> dict[str
"""Build the canonical telemetry identity for one Workspace execution.""" """Build the canonical telemetry identity for one Workspace execution."""
workspace_uuid = execution_context.workspace_uuid.strip() workspace_uuid = execution_context.workspace_uuid.strip()
if not workspace_uuid: if not workspace_uuid:
raise ValueError("Telemetry execution Workspace UUID is empty") raise ValueError('Telemetry execution Workspace UUID is empty')
return {"workspace_uuid": workspace_uuid} return {'workspace_uuid': workspace_uuid}
+3 -3
View File
@@ -3,15 +3,15 @@ from __future__ import annotations
import uuid import uuid
_INSTANCE_PREFIX = "instance_" _INSTANCE_PREFIX = 'instance_'
_WORKSPACE_IDENTITY_NAMESPACE = uuid.UUID("8ea04f29-8528-4cc3-bb28-30a838c89d76") _WORKSPACE_IDENTITY_NAMESPACE = uuid.UUID('8ea04f29-8528-4cc3-bb28-30a838c89d76')
def workspace_uuid_from_instance_id(instance_id: str) -> str: def workspace_uuid_from_instance_id(instance_id: str) -> str:
"""Return the stable OSS Workspace UUID for a persisted instance identity.""" """Return the stable OSS Workspace UUID for a persisted instance identity."""
value = instance_id.strip() value = instance_id.strip()
if not value: if not value:
raise ValueError("LangBot instance identity is empty") raise ValueError('LangBot instance identity is empty')
candidate = value[len(_INSTANCE_PREFIX) :] if value.startswith(_INSTANCE_PREFIX) else value candidate = value[len(_INSTANCE_PREFIX) :] if value.startswith(_INSTANCE_PREFIX) else value
try: try: