fix(contracts): declare profile rename history in roster results
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -19390,6 +19390,13 @@
|
||||
"title": "Skill Count",
|
||||
"type": "integer"
|
||||
},
|
||||
"previous_names": {
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"title": "Previous Names",
|
||||
"type": "array"
|
||||
},
|
||||
"last_session": {
|
||||
"anyOf": [
|
||||
{
|
||||
|
||||
24
tests/tui_gateway/contracts/test_profile_rename_history.py
Normal file
24
tests/tui_gateway/contracts/test_profile_rename_history.py
Normal 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}]})
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user