Skip to content

Publish events for agent personas and ACLs - #1372

Open
tomchop wants to merge 2 commits into
mainfrom
fix/agent-persona-events
Open

Publish events for agent personas and ACLs#1372
tomchop wants to merge 2 commits into
mainfrom
fix/agent-persona-events

Conversation

@tomchop

@tomchop tomchop commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Fixes #1371.

AgentPersona and RoleRelationship both threw union_tag_not_found while publishing their events, on every save and delete. The exception is caught and logged, so the write still landed — the only symptoms were log noise and events that never fired.

Two distinct causes

Investigating turned up more than the issue described:

  • AgentPersona never exposed root_type. Every other Yeti object has it as a computed_field; this one had only the private _root_type. The discriminator does getattr(v, "root_type", None), so it resolved to None — adding a union member alone would not have fixed it.
  • Neither agent_persona nor acl had a union member in YetiObjectTypes.

Why acl is included and the others aren't

The issue asked which of the five missing _root_types were deliberate. save() and delete() already answer it: both skip auditlog and timeline by collection name, so their absence from the union is correct and intentional — they never publish. package is a plain BaseModel, not Arango-backed, so it cannot publish either.

acls is in neither the skip-guard nor the union, so the code's expressed intent is that it publishes. It just threw instead. That is the evidence for fixing it rather than guarding it, but say the word if RBAC changes are meant to stay silent and I will guard the collection instead.

Tests

Two guards over the schema registry rather than a case per type, so a new schema cannot reintroduce either half:

  • every publishable object exposes root_type
  • every publishable root_type has a union member

Reverting the fix fails both, and the second names {'agent_persona', 'acl'} on its own. Plus end-to-end coverage that saving and deleting a persona each put an event on the queue.

Note

root_type is a computed_field, so it now appears in persona API responses, as it does for every other object. Additive, and requests are unaffected since computed fields are output-only — but the frontend's api-schema.d.ts will pick it up on its next regeneration.

Both failed to become events, silently. Publishing is wrapped in a
try/except that logs, so the write still landed and only the log said
anything.

AgentPersona failed twice over: it never exposed `root_type`, which the
discriminator reads off the instance, and it had no member in
YetiObjectTypes. RoleRelationship exposed `root_type` but had no union
member either. Neither is in the skip-guard that save() and delete()
apply to auditlog and timeline, so both were meant to publish all along.

Guarded by two tests over the schema registry rather than a case per
type: one that every publishable object exposes `root_type`, one that
every publishable root_type has a union member. Reverting either half of
the fix fails them, and the second names both gaps on its own.
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.

AgentPersona writes throw on event publishing (missing from YetiObjectTypes)

1 participant