Skip to content

fix: dedupe CreateThread initiator participants#36

Merged
rowan-stein merged 1 commit into
mainfrom
noa/issue-35
May 25, 2026
Merged

fix: dedupe CreateThread initiator participants#36
rowan-stein merged 1 commit into
mainfrom
noa/issue-35

Conversation

@casey-brooks
Copy link
Copy Markdown
Contributor

Summary

  • Fixes E2E mismatch: CreateThread rejects initiator in participants but initiator should be auto-included #35.
  • Allows CreateThread requests to include the initiator in participant_ids or participants without failing validation.
  • Dedupes the auto-included initiator so it is persisted exactly once and remains first in the participant list.
  • Adds migration 0004_enforce_thread_delete_cascades.sql to enforce ON DELETE CASCADE on thread-owned rows (thread_participants, messages, message_recipients) so hard-deleting a thread cleans child rows instead of tripping FK constraints.
  • Investigated agents E2E run 26379450519: the primary failure was CreateThread returning InvalidArgument for an initiator included in participant_ids; the cleanup log showed DeleteAgent returning FailedPrecondition because that failed flow left agent-related cleanup running after thread setup failed.

Validation

  • buf generate buf.build/agynio/api --path agynio/api/threads/v1 --path agynio/api/notifications/v1 --path agynio/api/identity/v1 --path agynio/api/metering/v1 --path agynio/api/agents/v1 --path agynio/api/authorization/v1
  • GOTOOLCHAIN=auto go test -json -count=1 ./...
  • GOTOOLCHAIN=auto go vet ./...
  • GOTOOLCHAIN=auto go build ./...
  • Applied all SQL migrations against a local Postgres 16 container and verified deleting a thread cascades to thread participants, messages, and message recipients.

Test & Lint Summary

  • Tests: 63 passed / 0 failed / 0 skipped.
  • Lint: go vet ./... passed with no errors.
  • Build: go build ./... passed.

@casey-brooks
Copy link
Copy Markdown
Contributor Author

Test & Lint Summary

  • buf generate buf.build/agynio/api --path agynio/api/threads/v1 --path agynio/api/notifications/v1 --path agynio/api/identity/v1 --path agynio/api/metering/v1 --path agynio/api/agents/v1 --path agynio/api/authorization/v1
  • GOTOOLCHAIN=auto go test -json -count=1 ./...
    • Tests: 63 passed / 0 failed / 0 skipped.
  • GOTOOLCHAIN=auto go vet ./...
    • Lint: passed with no errors.
  • GOTOOLCHAIN=auto go build ./...
    • Build: passed.
  • Applied all SQL migrations against a local Postgres 16 container and verified deleting a thread cascades to thread_participants, messages, and message_recipients.

Copy link
Copy Markdown

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review complete. The CreateThread change now dedupes the initiator while preserving the initiator-first ordering, and the added tests cover both participant_ids and participant identifiers. I did not find blocking issues.

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.

E2E mismatch: CreateThread rejects initiator in participants but initiator should be auto-included

3 participants