Skip to content

feat(types,agent): strict runtime validation for agent DTOs - #361

Merged
Cjay-Cyber-2 merged 4 commits into
ASTROIDX556:mainfrom
Tech-Cryptic:feat/215-agent-dto-validation-upstream
Oct 1, 2026
Merged

Cjay-Cyber-2 merged 4 commits into
ASTROIDX556:mainfrom
Tech-Cryptic:feat/215-agent-dto-validation-upstream

Conversation

@Tech-Cryptic

Copy link
Copy Markdown
Contributor

What changed

  • Add strict runtime schemas and validation helpers for agent creation and update DTOs in @astroid/types and export the agent validation utilities from @astroid/agent.
  • Validate required metadata, Stellar public key shape, capabilities, and non-negative decimal budget amounts before requests are sent.
  • Restore the DTO schema test block that was omitted during the previous branch merge, so the schema imports are exercised and validation behavior is covered.

Why

Catch malformed agent payloads on the client with field-specific validation errors instead of waiting for API rejection.

Testing

  • @astroid/types: 124 tests passed; package typecheck passed.
  • @astroid/agent: 113 tests passed; package typecheck passed.
  • ESLint passed for all changed source and test files.

Closes #215

Tech-Cryptic and others added 4 commits September 30, 2026 21:52
…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 899044c into ASTROIDX556:main Oct 1, 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.

Add strict input validation schemas for agent creation DTOs in @astroid/types and @astroid/agent

2 participants