Documentation
¶
Overview ¶
Package events provides domain event types and parsing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectorSyncCompletedEvent ¶
type ConnectorSyncCompletedEvent struct {
// EventMetadata contains the common event fields.
EventMetadata
// ConnectorID is the identifier of the connector that completed syncing.
ConnectorID string `json:"connector_id"`
// WorkspaceID is the workspace the connector synced into.
WorkspaceID string `json:"workspace_id"`
// DocumentsNew is the count of newly created documents.
DocumentsNew int `json:"documents_new"`
// DocumentsUpd is the count of updated documents.
DocumentsUpd int `json:"documents_updated"`
// DocumentsDel is the count of deleted documents.
DocumentsDel int `json:"documents_deleted"`
// Errors is the count of errors encountered during the sync.
Errors int `json:"errors"`
}
ConnectorSyncCompletedEvent is emitted when a connector sync finishes.
func (*ConnectorSyncCompletedEvent) Metadata ¶
func (e *ConnectorSyncCompletedEvent) Metadata() EventMetadata
Metadata returns the embedded common event metadata.
func (*ConnectorSyncCompletedEvent) Type ¶
func (e *ConnectorSyncCompletedEvent) Type() EventType
Type returns the connector-sync-completed event type.
type DocumentDeletedEvent ¶
type DocumentDeletedEvent struct {
// EventMetadata contains the common event fields.
EventMetadata
// DocumentID is the identifier of the deleted document.
DocumentID string `json:"document_id"`
// WorkspaceID is the workspace the document belonged to.
WorkspaceID string `json:"workspace_id"`
// Title is the deleted document's name (its value in the "name" list-query field).
// It is carried on the event so the value-suggestion facet's refcount DEC
// recovers the value without re-reading the soft-deleted row.
Title string `json:"title,omitempty"`
// Classification is the deleted document's sensitivity — the facet partition key the
// DEC decrements, carried alongside Title so the delete needs no second read.
Classification string `json:"classification,omitempty"`
}
DocumentDeletedEvent is emitted when a document is deleted.
func (*DocumentDeletedEvent) Metadata ¶
func (e *DocumentDeletedEvent) Metadata() EventMetadata
Metadata returns the embedded common event metadata.
func (*DocumentDeletedEvent) Type ¶
func (e *DocumentDeletedEvent) Type() EventType
Type returns the document-deleted event type.
type DocumentReclassifiedEvent ¶
type DocumentReclassifiedEvent struct {
// EventMetadata contains the common event fields.
EventMetadata
// DocumentID is the identifier of the reclassified document.
DocumentID string `json:"document_id"`
// WorkspaceID is the workspace the document belongs to (the KB tenant-isolation filter).
WorkspaceID string `json:"workspace_id"`
// StorageKey is the document's object-store key; the sidecar lives at
// <storage_key>.metadata.json, so the consumer needs it to re-stamp the metadata.
StorageKey string `json:"storage_key"`
// TrustLevel is the document's NEW provenance trust to write into the sidecar.
TrustLevel string `json:"trust_level"`
// Classification is the document's NEW sensitivity to write into the sidecar (the
// value retrieval's clearance filter compares against).
Classification string `json:"classification"`
}
DocumentReclassifiedEvent is emitted when an admin changes a document's classification and/or trust level. It is a re-sync TRIGGER: the ingestion worker re-stamps the Bedrock KB metadata sidecar(s) with the new Classification + TrustLevel and re-queues the document for indexing, so retrieval's clearance filter (which reads the KB metadata) stops seeing the stale classification. The from→to history is persisted in the document_reclassifications audit table, not carried here — the event needs only the new values plus the ids/key to locate and re-stamp the sidecar. The JSON tags are a subset of DocumentUploadedEvent's, so the Python ingestion consumer reuses the same sidecar path; keep the two in sync.
func (*DocumentReclassifiedEvent) Metadata ¶
func (e *DocumentReclassifiedEvent) Metadata() EventMetadata
Metadata returns the embedded common event metadata.
func (*DocumentReclassifiedEvent) Type ¶
func (e *DocumentReclassifiedEvent) Type() EventType
Type returns the document-reclassified event type.
type DocumentStatusChangedEvent ¶
type DocumentStatusChangedEvent struct {
// EventMetadata contains the common event fields.
EventMetadata
// DocumentID is the identifier of the document whose status changed.
DocumentID string `json:"document_id"`
// WorkspaceID is the workspace the document belongs to.
WorkspaceID string `json:"workspace_id"`
// OldStatus is the previous status of the document.
OldStatus string `json:"old_status"`
// NewStatus is the new status of the document.
NewStatus string `json:"new_status"`
}
DocumentStatusChangedEvent is emitted when a document's status changes.
func (*DocumentStatusChangedEvent) Metadata ¶
func (e *DocumentStatusChangedEvent) Metadata() EventMetadata
Metadata returns the embedded common event metadata.
func (*DocumentStatusChangedEvent) Type ¶
func (e *DocumentStatusChangedEvent) Type() EventType
Type returns the document-status-changed event type.
type DocumentUploadedEvent ¶
type DocumentUploadedEvent struct {
// EventMetadata contains the common event fields.
EventMetadata
// DocumentID is the identifier of the uploaded document.
DocumentID string `json:"document_id"`
// WorkspaceID is the workspace the document was uploaded to.
WorkspaceID string `json:"workspace_id"`
// FileName is the original name of the uploaded file.
FileName string `json:"file_name"`
// ContentType is the MIME type of the uploaded file.
ContentType string `json:"content_type"`
// StorageKey is the object storage key where the file is stored.
StorageKey string `json:"storage_key"`
// TrustLevel is the document's provenance trust; ingestion writes it into the
// Bedrock KB sidecar for retrieval weighting.
TrustLevel string `json:"trust_level"`
// Classification is the document's sensitivity; ingestion writes it into the
// Bedrock KB sidecar for clearance-based retrieval filtering.
Classification string `json:"classification"`
// SizeBytes is the size of the uploaded file in bytes.
SizeBytes int64 `json:"size_bytes"`
}
DocumentUploadedEvent is emitted when a document is uploaded.
Field order is chosen for struct alignment (all strings, then the int64 last); each field carries a doc comment per the documentation standard. The JSON tags are the wire contract the Python ingestion consumer (core/domain/events.py) parses — keep the two in sync.
func (*DocumentUploadedEvent) Metadata ¶
func (e *DocumentUploadedEvent) Metadata() EventMetadata
Metadata returns the embedded common event metadata.
func (*DocumentUploadedEvent) Type ¶
func (e *DocumentUploadedEvent) Type() EventType
Type returns the document-uploaded event type.
type Event ¶
type Event interface {
// Type returns the event's type discriminator.
Type() EventType
// Metadata returns the common metadata shared by all events.
Metadata() EventMetadata
}
Event is the interface all events implement.
func ParseEvent ¶
ParseEvent parses a JSON event payload and returns the appropriate Event type. It unmarshals the payload exactly once (into eventEnvelope) and dispatches on event_type, rather than parsing the same bytes twice (#9).
type EventMetadata ¶
type EventMetadata struct {
// EventID is the unique identifier of the event.
EventID string `json:"event_id"`
// EventType is the type discriminator for the event.
EventType EventType `json:"event_type"`
// OccurredAt is the timestamp when the event occurred.
OccurredAt time.Time `json:"occurred_at"`
// OrgID is the organization that the event belongs to.
OrgID string `json:"org_id"`
// UserID is the user who triggered the event, if applicable.
UserID string `json:"user_id,omitempty"`
// CorrelationID links related events across services.
CorrelationID string `json:"correlation_id,omitempty"`
// TraceParent carries the W3C trace context (traceparent header) captured when
// the event was produced, so a consumer can continue the originating trace —
// e.g. HTTP upload → outbox → relay publish → ingestion — as one distributed
// trace. Empty when no active trace context was present.
TraceParent string `json:"traceparent,omitempty"`
}
EventMetadata holds common fields for all events.
type EventType ¶
type EventType string
EventType represents the type of a domain event.
const ( // EventDocumentUploaded is emitted when a document is uploaded. EventDocumentUploaded EventType = "document.uploaded" // EventDocumentStatusChanged is emitted when a document's status transitions. EventDocumentStatusChanged EventType = "document.status_changed" // EventDocumentDeleted is emitted when a document is deleted. EventDocumentDeleted EventType = "document.deleted" // EventDocumentReclassified is emitted when an admin changes a document's // classification and/or trust level. The ingestion worker consumes it // to re-stamp the Bedrock KB metadata sidecar(s) and re-sync the document so // retrieval's clearance filter sees the new classification. EventDocumentReclassified EventType = "document.reclassified" // EventNotificationRequested is emitted by a producer to REQUEST a notification (the single, // reusable notification-emission seam). Its outbox payload is a notification event carrying the // recipient's user_id (NOT their email — the notification worker resolves the address from identity, // so no producer needs users-table access; service-to-table isolation). The document-events relay // routes it verbatim to the notification queue for the notification worker to dispatch. EventNotificationRequested EventType = "notification.requested" // EventTeamCreated is emitted when a team is created. EventTeamCreated EventType = "team.created" // EventConnectorSyncCompleted is emitted when a connector sync finishes. EventConnectorSyncCompleted EventType = "connector.sync_completed" )
Event types.
type TeamCreatedEvent ¶
type TeamCreatedEvent struct {
// EventMetadata contains the common event fields.
EventMetadata
// TeamID is the identifier of the newly created team.
TeamID string `json:"team_id"`
// TeamName is the display name of the newly created team.
TeamName string `json:"team_name"`
}
TeamCreatedEvent is emitted when a team is created.
func (*TeamCreatedEvent) Metadata ¶
func (e *TeamCreatedEvent) Metadata() EventMetadata
Metadata returns the embedded common event metadata.
func (*TeamCreatedEvent) Type ¶
func (e *TeamCreatedEvent) Type() EventType
Type returns the team-created event type.