Files

80 lines
2.6 KiB
Go

package bell_connector
import (
"encoding/json"
"time"
)
const OutboxType = "bell_event_v1"
type eventIdentity struct {
SchemaVersion string `json:"schema_version"`
ProducerID string `json:"producer_id"`
SourceEventID string `json:"source_event_id"`
}
type IngestResult struct {
EventID string `json:"event_id"`
ProducerID string `json:"producer_id"`
SourceEventID string `json:"source_event_id"`
Disposition string `json:"disposition"`
PayloadSHA256 string `json:"payload_sha256"`
}
type Problem struct {
Code string `json:"code"`
Message string `json:"message"`
ExistingEventID string `json:"existing_event_id,omitempty"`
}
type DeliveryError struct {
Code string
Detail string
Terminal bool
RetryAfter time.Duration
}
func (e *DeliveryError) Error() string { return e.Code + ": " + e.Detail }
// ReplayToken is Sense-owned verification state for authenticated evidence
// requests. It is never shared with Bell's replay table or business receipts.
type ReplayToken struct {
Principal string `gorm:"size:128;primaryKey"`
TokenID string `gorm:"size:64;primaryKey"`
ExpiresAt time.Time `gorm:"not null;index"`
CreatedAt time.Time `gorm:"not null"`
}
func (ReplayToken) TableName() string { return "sense_machine_token_replays" }
// InboundEvent is the Sense-owned local fact for an event received from Brain.
// The immutable payload and Bell Outbox row are created in one transaction.
type InboundEvent struct {
ID string `gorm:"size:36;primaryKey"`
ProducerID string `gorm:"size:128;not null;uniqueIndex:sense_inbound_event_key"`
SourceEventID string `gorm:"size:128;not null;uniqueIndex:sense_inbound_event_key"`
Payload json.RawMessage `gorm:"column:payload;type:jsonb;not null"`
PayloadSHA256 string `gorm:"type:char(64);not null"`
ReceivedAt time.Time `gorm:"not null"`
}
func (InboundEvent) TableName() string { return "sense_inbound_events" }
type EvidenceRecord struct {
EvidenceID string `gorm:"size:128;primaryKey"`
OwnerID string `gorm:"size:128;not null;index"`
Status string `gorm:"size:16;not null;index"`
Payload json.RawMessage `gorm:"column:payload;type:jsonb;not null"`
ExpiresAt *time.Time `gorm:"index"`
UpdatedAt time.Time `gorm:"not null"`
}
func (EvidenceRecord) TableName() string { return "sense_evidence_metadata" }
type AcceptResult struct {
ProducerID string `json:"producer_id"`
SourceEventID string `json:"source_event_id"`
Disposition string `json:"disposition"`
PayloadSHA256 string `json:"payload_sha256"`
}