Skip to content

feat(shared-contact-notes): input safety and perf guards#1220

Open
michaelvic123 wants to merge 2 commits into
Stellar-Mail:mainfrom
michaelvic123:feat/shared-contact-notes-safety
Open

feat(shared-contact-notes): input safety and perf guards#1220
michaelvic123 wants to merge 2 commits into
Stellar-Mail:mainfrom
michaelvic123:feat/shared-contact-notes-safety

Conversation

@michaelvic123

@michaelvic123 michaelvic123 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

closes #657

What

Adds safety and performance constraints to the shared-contact-notes V2 tool before any future integration. All changes stay inside tools/v2/team/shared-contact-notes/.

Changes

types.ts

  • Added LIMITS constant — CONTENT_MAX: 10_000, ID_MAX: 256. Centralises the hard limits so validators and tests stay in sync.
  • Added maxNotesPerContact to ServiceConfig — performance cap for getByContact.

validation.ts

  • validateCreateNote / validateUpdateNote now reject inputs exceeding LIMITS.
  • New validateId() helper — rejects empty or oversized ID strings. Replaces inline guard duplication across service methods.

service.ts

  • All ID-bearing methods (update, delete, archive, getByContact) use validateId() consistently.
  • getByContact breaks early when maxNotesPerContact is reached — avoids iterating the full map on contacts with large note histories. Default cap is 500.

tests/service.test.ts

  • Length-limit rejection for content, contactId, authorId, and update content.
  • validateId edge cases.
  • maxNotesPerContact cap verified against a 20-note fixture.

Checks

  • TypeScript noEmit ✅
  • 56/56 tool tests pass ✅
  • 581/581 unit tests pass ✅

michaelvic123 and others added 2 commits June 23, 2026 08:14
Safety:
- Added LIMITS constant (CONTENT_MAX: 10_000, ID_MAX: 256) to types.ts
- validateCreateNote/validateUpdateNote now reject oversized content
- New validateId() helper rejects empty or oversized ID strings
- service.ts uses validateId() consistently across all ID-bearing methods

Performance:
- Added maxNotesPerContact to ServiceConfig (default 500)
- getByContact breaks early once the cap is reached, avoiding full map
  iteration on contacts with large note histories

Tests:
- Length limit rejection for content, contactId, authorId, update content
- validateId edge cases (empty, oversized, custom field name)
- maxNotesPerContact cap behaviour with 20-note fixture
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.

[V2][team] Shared Contact Notes - Security and performance hardening

1 participant