fix(mosaic): preserve v1 agent name semantics
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful

This commit is contained in:
Jarvis
2026-07-16 07:01:51 -05:00
parent fce489269a
commit 355571182f
2 changed files with 33 additions and 3 deletions

View File

@@ -386,7 +386,7 @@ export async function previewV1ToV2Migration(
for (let index = 0; index < rawAgents.length; index += 1) {
const rawAgent = record(rawAgents[index]);
const name = stringValue(rawAgent.name);
const name = exactStringValue(rawAgent.name);
const path = `agents[${index}]`;
if (!name) {
blockers.push(blocker('invalid-agent-name', `${path}.name`, 'Agent name is required.'));
@@ -538,7 +538,7 @@ export async function previewV1ToV2Migration(
rawAgents
.map((candidate) => record(candidate))
.filter((candidate) => classifyAgentLocality(candidate, decisions.fleetHost) !== 'remote')
.map((candidate) => stringValue(candidate.name))
.map((candidate) => exactStringValue(candidate.name))
.filter((name): name is string => name !== undefined),
);
for (const decisionName of Object.keys(decisions.agents)) {
@@ -936,7 +936,7 @@ function validateV1FieldCatalog(raw: Record<string, unknown>, blockers: Migratio
path,
blockers,
);
const name = stringValue(agent.name);
const name = exactStringValue(agent.name);
if (!name || !AGENT_NAME_PATTERN.test(name)) {
blockers.push(
blocker('invalid-v1-field-type', `${path}.name`, 'A valid agent name is required.'),
@@ -1420,6 +1420,10 @@ function record(value: unknown): Record<string, unknown> {
: {};
}
function exactStringValue(value: unknown): string | undefined {
return typeof value === 'string' ? value : undefined;
}
function trimmedString(value: unknown): string | undefined {
return typeof value === 'string' ? value.trim() : undefined;
}