fix(contracts): declare profile rename history in roster results

This commit is contained in:
funky-xamarin
2026-09-21 07:43:57 +08:00
committed by Teknium
parent 10e7de79a9
commit 9a4a598bfc
4 changed files with 33 additions and 0 deletions

View File

@@ -1473,6 +1473,7 @@ export interface ProfileRow {
description?: string
display_name?: string
skill_count?: number
previous_names?: string[]
last_session?: ProfileSessionPreview | null
worker_session?: ProfileWorkerSession | null
canonical_session?: ProfileCanonicalSession | null

View File

@@ -19390,6 +19390,13 @@
"title": "Skill Count",
"type": "integer"
},
"previous_names": {
"items": {
"type": "string"
},
"title": "Previous Names",
"type": "array"
},
"last_session": {
"anyOf": [
{

View File

@@ -0,0 +1,24 @@
"""Regression for #117696: roster rename history belongs to the wire contract."""
import pytest
from pydantic import ValidationError
from tui_gateway.contracts.profiles_vault_complete_foreign_subagents import ProfilesListResult
from tui_gateway.contracts.registry import METHODS, check_result
def test_profile_rename_history_survives_result_validation():
for names in ([], ["old-bot", "older-bot"]):
payload = {"profiles": [{"name": "bot", "path": "/profiles/bot", "previous_names": names}]}
check_result(METHODS["profiles.list"], payload)
result = ProfilesListResult.model_validate(payload)
assert result.profiles[0].previous_names == names
assert ProfilesListResult.model_validate({"profiles": []}).profiles == []
legacy = ProfilesListResult.model_validate({"profiles": [{"name": "bot", "path": "/profiles/bot"}]})
assert legacy.profiles[0].previous_names == []
def test_profile_rename_history_keeps_strict_result_validation():
for extra in ({"previous_names": [None]}, {"previous_names": "old-bot"}, {"unknown_field": []}):
with pytest.raises(ValidationError):
ProfilesListResult.model_validate({"profiles": [{"name": "bot", "path": "/profiles/bot", **extra}]})

View File

@@ -155,6 +155,7 @@ class ProfileRow(Result):
description: str = ""
display_name: str = ""
skill_count: int = 0
previous_names: list[str] = Field(default_factory=list)
last_session: ProfileSessionPreview | None = None
worker_session: ProfileWorkerSession | None = None
canonical_session: ProfileCanonicalSession | None = None