Skip to content

fix(agent): validate creation DTOs against issue requirements - #362

Merged
Cjay-Cyber-2 merged 3 commits into
ASTROIDX556:mainfrom
Tech-Cryptic:fix/215-agent-input-validation
Sep 30, 2026
Merged

Cjay-Cyber-2 merged 3 commits into
ASTROIDX556:mainfrom
Tech-Cryptic:fix/215-agent-input-validation

Conversation

@Tech-Cryptic

Copy link
Copy Markdown
Contributor

What changed\n- Added strict runtime validation schemas and exported agent creation/update guards in @astroid/types and @astroid/agent.\n- Enforced the issue's required 52-character G-prefixed address format and rejected negative initial budget caps with descriptive field errors.\n- Added unit coverage for valid payloads, malformed inputs, and address length boundaries.\n\n## Why\nCatch agent configuration errors in the SDK before requests reach the Astroid API.\n\n## Testing\n- @astroid/agent tests and typecheck pass (113 tests).\n- @astroid/types tests pass (124 tests); types typecheck passes.\n- Workspace test has 3 unrelated @astroid/auth session failures.\n- Workspace typecheck is blocked by unrelated @astroid/analytics missing exports/API errors.\n\nCloses #215

…DTOs (ASTROIDX556#215)

Add zod schemas to @astroid/types that validate CreateAgentDto and
UpdateAgentDto at runtime without duplicating the DTO types:

- StellarPublicKeySchema (StrKey G..., 56 chars, base32 + checksum)
- DecimalAmountStringSchema (no exponent/NaN/Infinity, >= 0)
- AgentMetadataSchema (all values scalar, max 16 keys)
- AgentInitialBudgetSchema (amount + optional assetId)
- CreateAgentDtoSchema / UpdateAgentDtoSchema
- isValid*/validate* helpers returning ValidationResult

Wire the @astroid/agent create/update validators to the same rules via
public assertion guards (assertValidStellarPublicKey,
assertValidAmountString, validateAgentMetadata) so both layers reject
identical payloads with AstroidValidationError {field, received, expected}.

Tests: +32 in @astroid/types, +14 in @astroid/agent, including a
45-payload cross-layer agreement fixture table.
@Cjay-Cyber-2
Cjay-Cyber-2 merged commit 395fb97 into ASTROIDX556:main Sep 30, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants