Documentation
¶
Overview ¶
Package models - hooks.go contains GORM lifecycle hooks for validation. These hooks replace PostgreSQL CHECK constraints and triggers to enable consistent validation across all supported databases.
Package models defines GORM models for the TMI database schema.
Package models defines GORM models for the TMI database schema. These models support both PostgreSQL and Oracle databases through GORM's dialect abstraction.
Package models defines GORM models for the TMI database schema. This file contains models for the Survey API feature.
Package models defines GORM models for the TMI database schema.
Package models defines GORM models for the TMI database schema. This file contains models for the Teams and Projects feature.
Index ¶
- Constants
- Variables
- func AllModels() []any
- type Addon
- type AddonInvocationQuota
- type AliasCounter
- type Asset
- type AuditEntry
- type CVSSArray
- type CVSSScore
- type ClientCredential
- type CollaborationSession
- type ContentFeedback
- type DBBool
- type DBBytes
- type DBText
- type DBVarchar
- type Diagram
- type Document
- type ExtractionJob
- type Group
- type GroupMember
- type JSONMap
- type JSONRaw
- type LinkedIdentity
- type Metadata
- type Note
- type NullableDBText
- func (NullableDBText) GormDBDataType(db *gorm.DB, _ *schema.Field) string
- func (t NullableDBText) MarshalJSON() ([]byte, error)
- func (t NullableDBText) Ptr() *string
- func (t *NullableDBText) Scan(value any) error
- func (t *NullableDBText) UnmarshalJSON(data []byte) error
- func (t NullableDBText) Value() (driver.Value, error)
- type NullableDBVarchar
- func (NullableDBVarchar) GormDBDataType(db *gorm.DB, field *schema.Field) string
- func (v NullableDBVarchar) MarshalJSON() ([]byte, error)
- func (v NullableDBVarchar) Ptr() *string
- func (v *NullableDBVarchar) Scan(value any) error
- func (v *NullableDBVarchar) UnmarshalJSON(data []byte) error
- func (v NullableDBVarchar) Value() (driver.Value, error)
- type NullableSSVC
- type OracleBooldeprecated
- type ProjectNoteRecord
- type ProjectRecord
- type ProjectRelationshipRecord
- type ProjectResponsiblePartyRecord
- type RefreshTokenRecord
- type Repository
- type SSVCScore
- type SessionParticipant
- type StringArray
- type SurveyAnswer
- type SurveyResponse
- type SurveyResponseAccess
- type SurveyTemplate
- type SurveyTemplateVersion
- type SystemAuditEntry
- type SystemSetting
- type TeamMemberRecord
- type TeamNoteRecord
- type TeamRecord
- type TeamRelationshipRecord
- type TeamResponsiblePartyRecord
- type Threat
- type ThreatModel
- type ThreatModelAccess
- type TimmyEmbedding
- type TimmyMessage
- type TimmySession
- type TimmyUsage
- type TriageNote
- type UsabilityFeedback
- type User
- type UserAPIQuota
- type UserContentToken
- type UserPreference
- type VersionSnapshot
- type WebhookQuota
- type WebhookSubscription
- type WebhookURLDenyList
Constants ¶
const ( ChangeTypeCreated = "created" ChangeTypeUpdated = "updated" ChangeTypePatched = "patched" ChangeTypeDeleted = "deleted" ChangeTypeRestored = "restored" ChangeTypeRolledBack = "rolled_back" )
Audit change type constants
const ( ObjectTypeThreatModel = "threat_model" ObjectTypeDiagram = "diagram" ObjectTypeThreat = "threat" ObjectTypeAsset = "asset" ObjectTypeDocument = "document" ObjectTypeNote = "note" ObjectTypeRepository = "repository" )
Audit object type constants
const ( SnapshotTypeCheckpoint = "checkpoint" SnapshotTypeDiff = "diff" )
Snapshot type constants
const ( ExtractionStatusQueued = "queued" ExtractionStatusExtracting = "extracting" ExtractionStatusChunkEmbedding = "chunk_embedding" ExtractionStatusCompleted = "completed" ExtractionStatusFailed = "failed" )
Extraction job status values. The monolith actively writes only StatusQueued (at publish time) and the terminal StatusCompleted / StatusFailed (when a result lands). The intermediate values exist for forward-compatibility and are not written in Plan 3.
const ( SystemSettingTypeString = "string" SystemSettingTypeInt = "int" SystemSettingTypeBool = "bool" SystemSettingTypeJSON = "json" )
SystemSettingType constants for the Type field
const CheckpointInterval = 10
CheckpointInterval defines how often a full checkpoint is stored (every Nth version)
Variables ¶
var ErrBuiltInGroupProtected = errors.New("built-in group is protected")
ErrBuiltInGroupProtected is returned by GORM hooks and repositories when an operation would modify or delete a built-in group (everyone, security-reviewers, administrators). Handlers use errors.Is(err, ErrBuiltInGroupProtected) to map these conditions to HTTP 403 responses.
var UseUppercaseTableNames = false
UseUppercaseTableNames controls whether table names should be uppercase. Set to true for Oracle databases where unquoted identifiers are folded to uppercase. This must be set before any GORM operations occur.
Functions ¶
Types ¶
type Addon ¶
type Addon struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
Name DBVarchar `gorm:"size:256;not null"`
WebhookID DBVarchar `gorm:"size:36;not null;index"`
Description NullableDBText `gorm:""`
Icon NullableDBVarchar `gorm:"size:60"`
Objects StringArray `gorm:""`
ThreatModelID NullableDBVarchar `gorm:"size:36;index"`
Parameters JSONRaw `gorm:""`
// Relationships
Webhook WebhookSubscription `gorm:"foreignKey:WebhookID"`
ThreatModel *ThreatModel `gorm:"foreignKey:ThreatModelID"`
}
Addon represents an addon configuration Note: Explicit column tags removed for Oracle compatibility SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: DB model for an addon configuration bound to a webhook and optional threat model
func (*Addon) BeforeCreate ¶
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign a UUID to Addon if unset before DB insert (mutates shared state)
type AddonInvocationQuota ¶
type AddonInvocationQuota struct {
OwnerInternalUUID DBVarchar `gorm:"primaryKey;not null;size:36"`
MaxActiveInvocations int `gorm:"default:1"`
MaxInvocationsPerHour int `gorm:"default:10"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
// Relationships
Owner User `gorm:"foreignKey:OwnerInternalUUID;references:InternalUUID"`
}
AddonInvocationQuota represents per-user addon invocation quotas Note: Explicit column tags removed for Oracle compatibility SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: DB model for per-user addon concurrency and hourly invocation limits
func (AddonInvocationQuota) TableName ¶
func (AddonInvocationQuota) TableName() string
TableName specifies the table name for AddonInvocationQuota SEM@7d6e24510cb080b00d72322263caafc04d1d57dc: return the dialect-aware DB table name for AddonInvocationQuota (pure)
type AliasCounter ¶
type AliasCounter struct {
ParentID DBVarchar `gorm:"primaryKey;not null;size:36;column:parent_id"`
ObjectType DBVarchar `gorm:"primaryKey;not null;size:16;column:object_type"`
NextAlias int32 `gorm:"not null;default:1;column:next_alias"`
}
AliasCounter holds the next-alias value for a given (parent_id, object_type) scope. ThreatModel global counter uses parent_id="__global__"; sub-object counters use the parent threat-model UUID. Allocation is done via SELECT ... FOR UPDATE inside the calling repository's transaction. SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: DB model for the next sequential alias value scoped to a parent and object type
func (AliasCounter) TableName ¶
func (AliasCounter) TableName() string
TableName returns the dialect-aware table name. SEM@7d6e24510cb080b00d72322263caafc04d1d57dc: return the dialect-aware DB table name for AliasCounter (pure)
type Asset ¶
type Asset struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
ThreatModelID DBVarchar `` /* 166-byte string literal not displayed */
Name DBVarchar `gorm:"size:256;not null;index:idx_assets_name"`
Description NullableDBText `gorm:""`
Type DBVarchar `gorm:"size:64;not null;index:idx_assets_type"`
Criticality NullableDBVarchar `gorm:"size:128"`
Classification StringArray `gorm:""`
Sensitivity NullableDBVarchar `gorm:"size:128"`
IncludeInReport DBBool `gorm:"default:1"`
TimmyEnabled DBBool `gorm:"default:1"`
Alias int32 `gorm:"column:alias;not null;default:0;<-:create;uniqueIndex:uniq_assets_tm_alias,priority:2"` // Server-assigned per-(threat_model_id, type) alias
CreatedAt time.Time `gorm:"not null;autoCreateTime;index:idx_assets_created;index:idx_assets_tm_created,priority:2"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime;index:idx_assets_modified;index:idx_assets_tm_modified,priority:2"`
DeletedAt *time.Time `gorm:"index:idx_assets_deleted_at"`
// Version is incremented on every successful update (T14 / #385).
Version int `gorm:"not null;default:1"`
// Relationships
ThreatModel ThreatModel `gorm:"foreignKey:ThreatModelID"`
}
Asset represents an asset within a threat model Note: Explicit column tags removed for Oracle compatibility SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model for an asset within a threat model with type, criticality, and classification
func (*Asset) BeforeCreate ¶
BeforeCreate generates a UUID if not set and validates required fields. Validation is in BeforeCreate (not BeforeSave) because GORM map-based updates trigger BeforeSave on the empty model struct, causing false validation errors. SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: generate a UUID, validate name and type for Asset before insert
type AuditEntry ¶
type AuditEntry struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36;index:idx_audit_created_id,priority:2"`
ThreatModelID DBVarchar `gorm:"size:36;not null;index:idx_audit_tm;index:idx_audit_tm_created,priority:1"`
ObjectType DBVarchar `gorm:"size:50;not null;index:idx_audit_object,priority:1;index:idx_audit_object_version,priority:1"`
ObjectID DBVarchar `gorm:"size:36;not null;index:idx_audit_object,priority:2;index:idx_audit_object_version,priority:2"`
Version *int `gorm:"index:idx_audit_object_version,priority:3"` // nullable: NULL means version snapshot has been pruned
ChangeType DBVarchar `gorm:"size:20;not null;index:idx_audit_change_type"`
ActorEmail DBVarchar `gorm:"size:320;not null;index:idx_audit_actor,priority:1"`
ActorProvider DBVarchar `gorm:"size:100;not null"`
ActorProviderID DBVarchar `gorm:"size:500;not null"`
ActorDisplayName DBVarchar `gorm:"size:256;not null"`
ChangeSummary NullableDBText `gorm:""`
// Composite (created_at, id) index serves the unfiltered admin audit keyset
// scans and full-table export in both directions (#473). idx_audit_tm_created
// already covers the filtered-by-threat-model path.
CreatedAt time.Time `` /* 139-byte string literal not displayed */
}
AuditEntry represents an entry in the audit trail. The audit trail tracks who changed what and when for all entity mutations. Actor fields are denormalized (not FKs) so audit entries persist after user deletion. threat_model_id is not a FK so the "threat model deleted" entry persists after TM deletion. SEM@b7ad72016d91424b5dd7e6ed69ba846a4170f7b5: persistent audit record of who changed which object in a threat model and when (reads DB)
func (*AuditEntry) BeforeCreate ¶
func (a *AuditEntry) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: auto-assign a UUID to an AuditEntry before it is inserted into the DB (pure)
func (AuditEntry) TableName ¶
func (AuditEntry) TableName() string
TableName specifies the table name for AuditEntry SEM@626c102e7b7f7ceffb64d01a6c51f618862c5f31: return the database table name for AuditEntry (pure)
type CVSSArray ¶
type CVSSArray []CVSSScore
CVSSArray is a custom type that stores CVSS score arrays as JSON This outputs JSON array format [{"vector":"...","score":9.8}] which works for both PostgreSQL JSONB columns and Oracle JSON columns SEM@dafcb0b707b3aec36d55d6377ccb7a5a04b9dff7: database-compatible slice of CVSS scores serialized as a JSON array for cross-dialect storage (pure)
func (CVSSArray) GormDBDataType ¶
GormDBDataType implements the GormDBDataTypeInterface to return dialect-specific column types for cross-database compatibility SEM@9745b416c50726fc3ca5d4637364ba55d6ba0699: return the dialect-specific column type for CVSSArray storage (pure)
func (*CVSSArray) Scan ¶
Scan implements the sql.Scanner interface for database reads SEM@3d0d5a8cf02fa74fad102f0f99c2b936a164bbea: deserialize a CVSSArray from a JSON array database value (pure)
type CVSSScore ¶
CVSSScore represents a CVSS vector and score pair for threat assessment SEM@dafcb0b707b3aec36d55d6377ccb7a5a04b9dff7: CVSS vector string and numeric score pair for threat severity assessment (pure)
type ClientCredential ¶
type ClientCredential struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
OwnerUUID DBVarchar `gorm:"size:36;not null;index"`
ClientID DBVarchar `gorm:"size:1000;not null;uniqueIndex"`
ClientSecretHash DBText `gorm:"not null"`
Name DBVarchar `gorm:"size:256;not null"`
Description NullableDBText `gorm:""`
IsActive DBBool `gorm:"default:1"`
LastUsedAt *time.Time
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
ExpiresAt *time.Time
// Relationships
Owner User `gorm:"foreignKey:OwnerUUID;references:InternalUUID"`
}
ClientCredential represents OAuth 2.0 client credentials for machine-to-machine auth Note: Explicit column tags removed for Oracle compatibility SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model for an OAuth 2.0 client credential used in machine-to-machine auth
func (*ClientCredential) BeforeCreate ¶
func (c *ClientCredential) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: generate a UUID primary key for ClientCredential before insert if not already set
func (ClientCredential) TableName ¶
func (ClientCredential) TableName() string
TableName specifies the table name for ClientCredential SEM@7d6e24510cb080b00d72322263caafc04d1d57dc: return the dialect-aware table name for ClientCredential (pure)
type CollaborationSession ¶
type CollaborationSession struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
ThreatModelID DBVarchar `gorm:"size:36;not null;index"`
DiagramID DBVarchar `gorm:"size:36;not null;index"`
WebsocketURL DBText `gorm:"not null"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
ExpiresAt *time.Time
// Relationships
ThreatModel ThreatModel `gorm:"foreignKey:ThreatModelID"`
Diagram Diagram `gorm:"foreignKey:DiagramID"`
Participants []SessionParticipant `gorm:"foreignKey:SessionID"`
}
CollaborationSession represents a real-time collaboration session Note: Explicit column tags removed for Oracle compatibility SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: DB model for a real-time WebSocket collaboration session on a diagram
func (*CollaborationSession) BeforeCreate ¶
func (c *CollaborationSession) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign a UUID to CollaborationSession if unset before DB insert (mutates shared state)
func (*CollaborationSession) BeforeSave ¶
func (c *CollaborationSession) BeforeSave(tx *gorm.DB) error
BeforeSave validates CollaborationSession before create or update SEM@d48970168f241f7cb359d0cfdb00f3e26abb59da: validate collaboration session WebSocket URL before DB write (pure)
func (CollaborationSession) TableName ¶
func (CollaborationSession) TableName() string
TableName specifies the table name for CollaborationSession SEM@7d6e24510cb080b00d72322263caafc04d1d57dc: return the dialect-aware DB table name for CollaborationSession (pure)
type ContentFeedback ¶
type ContentFeedback struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
ThreatModelID DBVarchar `gorm:"size:36;not null;index:idx_content_feedback_target,priority:1"`
TargetType DBVarchar `gorm:"size:24;not null;index:idx_content_feedback_target,priority:2"`
TargetID DBVarchar `gorm:"size:36;not null;index:idx_content_feedback_target,priority:3"`
TargetField NullableDBVarchar `gorm:"size:64"`
Sentiment DBVarchar `gorm:"size:8;not null;index:idx_content_feedback_sentiment"`
Verbatim NullableDBText `gorm:""`
FalsePositiveReason NullableDBVarchar `gorm:"column:false_positive_reason;size:32;index:idx_content_feedback_fp_reason"`
FalsePositiveSubreason NullableDBVarchar `gorm:"column:false_positive_subreason;size:40"`
ClientID DBVarchar `gorm:"column:client_id;size:32;not null"`
ClientVersion NullableDBVarchar `gorm:"column:client_version;size:32"`
Screenshot NullableDBText `gorm:"column:screenshot"`
CreatedByUUID DBVarchar `gorm:"column:created_by;size:36;not null"`
// Note: autoCreateTime tag removed for Oracle compatibility (#380). The
// repository sets CreatedAt explicitly in Create / CreateWithTargetCheck
// before INSERT, matching the Threat model pattern.
CreatedAt time.Time `gorm:"not null;index:idx_content_feedback_created_at"`
// Relationships. ContentFeedback rows are cleaned up explicitly by
// deleteThreatModelChildren (issue #378), matching every other TM child.
// The CreatedBy FK is suppressed (constraint:-) so a user with outstanding
// feedback can still be deleted; application-layer integrity is sufficient.
ThreatModel ThreatModel `gorm:"foreignKey:ThreatModelID"`
CreatedBy User `gorm:"foreignKey:CreatedByUUID;references:InternalUUID;constraint:-"`
}
ContentFeedback represents user feedback on AI/automation-generated artifacts (notes, diagrams, threats, threat-classification fields) within a threat model. Issued via POST /threat_models/{id}/feedback by reader+ on the parent TM. SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: DB model for user feedback on AI-generated threat-model content artifacts
func (*ContentFeedback) BeforeCreate ¶
func (c *ContentFeedback) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set. SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign a UUID to ContentFeedback if unset before DB insert (mutates shared state)
func (ContentFeedback) TableName ¶
func (ContentFeedback) TableName() string
TableName returns the dialect-aware table name. SEM@7d6e24510cb080b00d72322263caafc04d1d57dc: return the dialect-aware DB table name for ContentFeedback (pure)
type DBBool ¶
type DBBool bool
DBBool is a cross-database boolean type that handles different database representations of booleans. Oracle uses NUMBER(1), MySQL uses TINYINT(1), SQL Server uses BIT, while PostgreSQL and SQLite have native boolean support. This type implements sql.Scanner and driver.Valuer to handle the conversion for all supported databases. SEM@55d98405ac043c7929d10873466d6f6f3ebc53e8: cross-database boolean type handling NUMBER(1), TINYINT, BIT, and native bool per dialect (pure)
func (DBBool) Bool ¶
Bool returns the underlying bool value. SEM@55d98405ac043c7929d10873466d6f6f3ebc53e8: return the underlying bool value of DBBool (pure)
func (DBBool) GormDBDataType ¶
GormDBDataType implements the GormDBDataTypeInterface to return dialect-specific column types for cross-database compatibility SEM@9745b416c50726fc3ca5d4637364ba55d6ba0699: return the dialect-specific boolean column type for DBBool (pure)
func (*DBBool) Scan ¶
Scan implements the sql.Scanner interface for DBBool. It handles: - bool (PostgreSQL native boolean) - int64/int/int32 (numeric representation) - godror.Number (Oracle's numeric type, implements fmt.Stringer) - nil (NULL values) SEM@3d0d5a8cf02fa74fad102f0f99c2b936a164bbea: deserialize a DB value into DBBool, handling numeric, native bool, and Oracle godror.Number (pure)
func (DBBool) Value ¶
Value implements the driver.Valuer interface for DBBool. It returns the boolean as a native Go bool for cross-database compatibility. PostgreSQL expects bool for boolean columns, and Oracle's godror driver can handle Go bool and convert it to NUMBER(1) appropriately. SEM@55d98405ac043c7929d10873466d6f6f3ebc53e8: serialize DBBool to a native Go bool for cross-database driver compatibility (pure)
type DBBytes ¶
type DBBytes []byte
DBBytes is a cross-database binary data type. Uses BYTEA on PostgreSQL, BLOB on Oracle, LONGBLOB on MySQL, VARBINARY(MAX) on SQL Server, and BLOB on SQLite. SEM@d60ddcf3f407dda0e558c55c1c597317e13eece1: cross-database binary data type mapping to BYTEA, BLOB, or dialect equivalent (pure)
func (DBBytes) GormDBDataType ¶
GormDBDataType implements the GormDBDataTypeInterface to return dialect-specific column types for cross-database compatibility SEM@9745b416c50726fc3ca5d4637364ba55d6ba0699: return the dialect-specific binary column type for DBBytes (pure)
type DBText ¶
type DBText string
DBText is a cross-database large text type. Uses TEXT on PostgreSQL, CLOB on Oracle, LONGTEXT on MySQL, NVARCHAR(MAX) on SQL Server, and TEXT on SQLite. SEM@ae4222674aa836756d4e53ad513582d70f862bae: cross-database large text type mapping to TEXT, CLOB, or dialect equivalent (pure)
func (DBText) GormDBDataType ¶
GormDBDataType implements the GormDBDataTypeInterface to return dialect-specific column types for cross-database compatibility SEM@9745b416c50726fc3ca5d4637364ba55d6ba0699: return the dialect-specific large text column type for DBText (pure)
func (*DBText) Scan ¶
Scan implements the sql.Scanner interface for database reads SEM@3d0d5a8cf02fa74fad102f0f99c2b936a164bbea: deserialize a DB value into DBText, accepting bytes or string (pure)
type DBVarchar ¶
type DBVarchar string
DBVarchar is a cross-database length-bounded text type with CHAR semantics. Uses varchar(N) on PostgreSQL (already char-counted), varchar2(N CHAR) on Oracle (avoiding default BYTE semantics under AL32UTF8), varchar(N) on MySQL (utf8mb4 is char-counted), nvarchar(N) on SQL Server, varchar(N) on SQLite. The length N is carried by the GORM `size:` tag, not by the Go type. SEM@ae4222674aa836756d4e53ad513582d70f862bae: cross-database length-bounded text type with CHAR semantics per dialect (pure)
func (DBVarchar) GormDBDataType ¶
GormDBDataType implements the GormDBDataTypeInterface to return dialect-specific column types for cross-database compatibility The column size is read from field.Size (populated from the `size:` GORM tag). A field.Size of 0 falls back to 255 as a safety default; every usage site should set size: explicitly. SEM@9745b416c50726fc3ca5d4637364ba55d6ba0699: return the dialect-specific bounded varchar column type using the GORM size tag (pure)
func (*DBVarchar) Scan ¶
Scan implements the sql.Scanner interface for database reads SEM@3d0d5a8cf02fa74fad102f0f99c2b936a164bbea: deserialize a DB value into DBVarchar, accepting bytes or string (pure)
type Diagram ¶
type Diagram struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
ThreatModelID DBVarchar `` /* 129-byte string literal not displayed */
Name DBVarchar `gorm:"size:256;not null"`
Description NullableDBText `gorm:""`
Type NullableDBVarchar `gorm:"size:64;index:idx_diagrams_type;index:idx_diagrams_tm_type,priority:2"`
Content NullableDBText `gorm:""`
Cells JSONRaw `gorm:""`
ColorPalette JSONRaw `gorm:""`
SVGImage NullableDBText `gorm:""`
ImageUpdateVector *int64
UpdateVector int64 `gorm:"default:0"`
IncludeInReport DBBool `gorm:"default:1"`
TimmyEnabled DBBool `gorm:"default:1"`
AutoGenerated DBBool `gorm:"default:0;<-:create" json:"auto_generated"`
Alias int32 `gorm:"column:alias;not null;default:0;<-:create;uniqueIndex:uniq_diagrams_tm_alias,priority:2"` // Server-assigned per-(threat_model_id, type) alias
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
DeletedAt *time.Time `gorm:"index:idx_diagrams_deleted_at"`
// Version is incremented on every successful update (T14 / #385).
Version int `gorm:"not null;default:1"`
// Relationships
ThreatModel ThreatModel `gorm:"foreignKey:ThreatModelID"`
}
Diagram represents a diagram within a threat model Note: Explicit column tags removed for Oracle compatibility SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model for a diagram within a threat model, storing cells, SVG, and version state
func (*Diagram) BeforeCreate ¶
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: generate a UUID primary key for Diagram before insert if not already set
func (*Diagram) BeforeUpdate ¶
BeforeUpdate validates Diagram before update SEM@ebf201816c3638ec74fc8483a2a649af3ccddfc9: validate Diagram type before a GORM update (pure)
type Document ¶
type Document struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
ThreatModelID DBVarchar `` /* 163-byte string literal not displayed */
Name DBVarchar `gorm:"size:256;not null;index:idx_docs_name"`
URI DBText `gorm:"not null"`
Description NullableDBText `gorm:""`
IncludeInReport DBBool `gorm:"default:1"`
TimmyEnabled DBBool `gorm:"default:1"`
AccessStatus NullableDBVarchar `gorm:"size:32;default:unknown"`
ContentSource NullableDBVarchar `gorm:"size:64"`
// Picker registration (all three set together or all null — enforced by application code).
PickerProviderID NullableDBVarchar `gorm:"size:64;index:idx_docs_picker,priority:1"`
PickerFileID NullableDBVarchar `gorm:"size:255;index:idx_docs_picker,priority:2"`
PickerMimeType NullableDBVarchar `gorm:"size:128"`
// Access diagnostics (populated when access_status != accessible/unknown).
AccessReasonCode NullableDBVarchar `gorm:"size:64"`
AccessReasonDetail NullableDBText
AccessStatusUpdatedAt *time.Time
Alias int32 `gorm:"column:alias;not null;default:0;<-:create;uniqueIndex:uniq_documents_tm_alias,priority:2"` // Server-assigned per-(threat_model_id, type) alias
CreatedAt time.Time `gorm:"not null;autoCreateTime;index:idx_docs_created;index:idx_docs_tm_created,priority:2"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime;index:idx_docs_modified;index:idx_docs_tm_modified,priority:2"`
DeletedAt *time.Time `gorm:"index:idx_docs_deleted_at"`
// Version is incremented on every successful update (T14 / #385).
Version int `gorm:"not null;default:1"`
// Relationships
ThreatModel ThreatModel `gorm:"foreignKey:ThreatModelID"`
}
Document represents a document attached to a threat model Note: Explicit column tags removed for Oracle compatibility SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: DB model for a document attached to a threat model, with picker and access diagnostics
func (*Document) BeforeCreate ¶
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign a UUID to Document if unset before DB insert (mutates shared state)
func (*Document) BeforeSave ¶
BeforeSave validates Document before create or update SEM@d48970168f241f7cb359d0cfdb00f3e26abb59da: validate document name and URI are non-empty before DB write (pure)
type ExtractionJob ¶
type ExtractionJob struct {
JobID DBVarchar `gorm:"column:job_id;primaryKey;not null;size:36"`
// DocumentRef is the document being extracted. NOT NULL with no DB-level FK.
// On the bare-upsert-insert path (a terminal result arriving with no prior
// queued row) the real ref is unknown and the non-empty sentinel
// "__unknown__" (unknownDocumentRef in api/extraction_job_store.go) is
// written instead — an empty string is indistinguishable from NULL on
// Oracle and would violate NOT NULL (ORA-01400). Any query that filters on
// document_ref must exclude the sentinel.
DocumentRef DBVarchar `gorm:"column:document_ref;size:36;not null;index:idx_extraction_jobs_doc"`
Status DBVarchar `gorm:"column:status;size:32;not null;default:queued"`
ReasonCode NullableDBVarchar `gorm:"column:reason_code;size:64"`
Stage NullableDBVarchar `gorm:"column:stage;size:32"`
Attempts int32 `gorm:"column:attempts;not null;default:0"`
CreatedAt time.Time `gorm:"column:created_at;not null;autoCreateTime"`
UpdatedAt time.Time `gorm:"column:updated_at;not null;autoUpdateTime"`
CompletedAt *time.Time `gorm:"column:completed_at"`
}
ExtractionJob is the monolith's internal record of one async extraction job. The result-consumer is the sole writer of terminal states; the publish-side callers only insert the initial queued row (idempotently). Components (workers) never touch this table. document_ref is indexed but has no database-level foreign key, so a document deleted mid-job does not cause a constraint violation; the result-consumer tolerates the missing row. SEM@d8b4a7f6b4c480a8020df9e796e1deabb7f0fdb7: GORM model tracking the status lifecycle of one async extraction job (pure)
func (*ExtractionJob) BeforeCreate ¶
func (j *ExtractionJob) BeforeCreate(_ *gorm.DB) error
BeforeCreate is a gorm hook required to satisfy the gorm.DB interface. JobID is always supplied by the caller (it is the envelope job_id) so it is never generated here. SEM@d8b4a7f6b4c480a8020df9e796e1deabb7f0fdb7: GORM hook that no-ops before insert since job ID is always caller-supplied (pure)
func (ExtractionJob) TableName ¶
func (ExtractionJob) TableName() string
TableName returns the prefixed table name. SEM@d8b4a7f6b4c480a8020df9e796e1deabb7f0fdb7: return the prefixed database table name for extraction jobs (pure)
type Group ¶
type Group struct {
InternalUUID DBVarchar `gorm:"primaryKey;not null;size:36"`
Provider DBVarchar `gorm:"size:100;not null;index:idx_groups_provider"`
GroupName DBVarchar `gorm:"size:500;not null;index:idx_groups_group_name"`
Name NullableDBVarchar `gorm:"size:256"`
Description NullableDBText `gorm:""`
FirstUsed time.Time `gorm:"not null;autoCreateTime"`
LastUsed time.Time `gorm:"not null;autoUpdateTime;index:idx_groups_last_used"`
UsageCount int `gorm:"default:1"`
}
Group represents an identity provider group Note: Explicit column tags removed for Oracle compatibility SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: DB model for an identity-provider group with usage tracking
func (*Group) BeforeCreate ¶
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign a UUID to Group if unset before DB insert (mutates shared state)
func (*Group) BeforeDelete ¶
BeforeDelete prevents deletion of built-in groups (everyone, security-reviewers, administrators) SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: prevent deletion of built-in system groups (pure)
func (*Group) BeforeUpdate ¶
BeforeUpdate prevents renaming or changing the description of built-in groups SEM@ebf201816c3638ec74fc8483a2a649af3ccddfc9: prevent renaming or redescribing built-in groups; allow other field updates (reads DB)
type GroupMember ¶
type GroupMember struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
GroupInternalUUID DBVarchar `gorm:"size:36;not null;index;uniqueIndex:idx_gm_group_user_type,priority:1"`
UserInternalUUID NullableDBVarchar `gorm:"size:36;index;uniqueIndex:idx_gm_group_user_type,priority:2"`
MemberGroupInternalUUID NullableDBVarchar `gorm:"size:36;index"`
SubjectType DBVarchar `gorm:"size:10;not null;default:user;uniqueIndex:idx_gm_group_user_type,priority:3"`
AddedByInternalUUID NullableDBVarchar `gorm:"size:36"`
AddedAt time.Time `gorm:"not null;autoCreateTime"`
Notes NullableDBText `gorm:""`
// Relationships
Group Group `gorm:"foreignKey:GroupInternalUUID;references:InternalUUID"`
User *User `gorm:"foreignKey:UserInternalUUID;references:InternalUUID"`
MemberGroup *Group `gorm:"foreignKey:MemberGroupInternalUUID;references:InternalUUID"`
AddedBy *User `gorm:"foreignKey:AddedByInternalUUID;references:InternalUUID;constraint:-"`
}
GroupMember represents a user's or group's membership in a group. Supports one level of group-in-group nesting: an external IdP group can be a member of a built-in group (e.g., Administrators), enabling all members of the external group to inherit the built-in group's privileges. Note: Explicit column tags removed for Oracle compatibility SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: DB model for a user or nested group membership within a group
func (*GroupMember) BeforeCreate ¶
func (g *GroupMember) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign a UUID to GroupMember if unset before DB insert (mutates shared state)
func (*GroupMember) BeforeSave ¶
func (gm *GroupMember) BeforeSave(tx *gorm.DB) error
BeforeSave validates GroupMember and prevents adding to "everyone" group SEM@d48970168f241f7cb359d0cfdb00f3e26abb59da: validate group membership subject type, exclusivity, and block direct adds to the everyone group (pure)
func (GroupMember) TableName ¶
func (GroupMember) TableName() string
TableName specifies the table name for GroupMember SEM@7d6e24510cb080b00d72322263caafc04d1d57dc: return the dialect-aware DB table name for GroupMember (pure)
type JSONMap ¶
JSONMap is a custom type that stores JSON objects This works across both PostgreSQL JSONB and Oracle JSON SEM@3d0d5a8cf02fa74fad102f0f99c2b936a164bbea: database-compatible map for JSON objects stored as JSONB or CLOB across dialects (pure)
func (JSONMap) GormDBDataType ¶
GormDBDataType implements the GormDBDataTypeInterface to return dialect-specific column types for cross-database compatibility SEM@9745b416c50726fc3ca5d4637364ba55d6ba0699: return the dialect-specific column type for JSONMap storage (pure)
func (*JSONMap) Scan ¶
Scan implements the sql.Scanner interface for database reads SEM@3d0d5a8cf02fa74fad102f0f99c2b936a164bbea: deserialize a JSONMap from a JSON string database value (pure)
type JSONRaw ¶
type JSONRaw json.RawMessage
JSONRaw is a custom type for storing raw JSON (like cells in diagrams) SEM@a251f60c11fe9831021be2539ff7d746fbd65b2c: database-compatible raw JSON value stored as JSONB or CLOB across dialects (pure)
func (JSONRaw) GormDBDataType ¶
GormDBDataType implements the GormDBDataTypeInterface to return dialect-specific column types for cross-database compatibility SEM@9745b416c50726fc3ca5d4637364ba55d6ba0699: return the dialect-specific column type for JSONRaw storage (pure)
func (JSONRaw) MarshalJSON ¶
MarshalJSON implements json.Marshaler SEM@7e4b34fec28c8e0d5c235301e7a132b24212d3a9: serialize JSONRaw to JSON, emitting null for nil (pure)
func (*JSONRaw) Scan ¶
Scan implements the sql.Scanner interface for database reads SEM@3d0d5a8cf02fa74fad102f0f99c2b936a164bbea: deserialize a DB value into JSONRaw, decoding Oracle hex-encoded CLOB when needed (pure)
func (*JSONRaw) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler SEM@7e4b34fec28c8e0d5c235301e7a132b24212d3a9: deserialize JSON bytes into JSONRaw (pure)
func (JSONRaw) Value ¶
Value implements the driver.Valuer interface for database writes Returns string (not []byte) for Oracle CLOB compatibility. A zero-length non-nil slice is normalized to nil so that behavior is consistent across PostgreSQL JSONB (which would reject "" as 22P02) and Oracle CLOB (which silently coerces "" to NULL). SEM@55d98405ac043c7929d10873466d6f6f3ebc53e8: serialize JSONRaw to a driver string, normalizing empty to NULL (pure)
type LinkedIdentity ¶
type LinkedIdentity struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
UserInternalUUID DBVarchar `gorm:"size:36;not null;index:idx_linked_user"`
Provider DBVarchar `gorm:"size:100;not null;uniqueIndex:uniq_linked_provider_sub,priority:1"`
ProviderUserID DBVarchar `gorm:"size:500;not null;uniqueIndex:uniq_linked_provider_sub,priority:2"`
Email DBVarchar `gorm:"size:320"`
Name DBVarchar `gorm:"size:256"`
LinkedAt time.Time `gorm:"not null;autoCreateTime"`
LastUsedAt *time.Time
}
LinkedIdentity records an external identity provider credential linked to a TMI user account. Each (provider, provider_user_id) pair is globally unique — a provider sub cannot be linked to more than one TMI user.
Referential integrity to the users table is enforced by application code; no DB-level FK is declared so that users can be deleted without a cascade constraint ordering concern. SEM@211793c39ea528b3d2da244f3504963c40584df7: GORM model representing an external identity provider credential linked to a user account
func (*LinkedIdentity) BeforeCreate ¶
func (l *LinkedIdentity) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if ID is empty. SEM@211793c39ea528b3d2da244f3504963c40584df7: generate a UUID for a linked identity record if none is set before insert
func (LinkedIdentity) TableName ¶
func (LinkedIdentity) TableName() string
TableName returns the dialect-aware table name. SEM@211793c39ea528b3d2da244f3504963c40584df7: return the dialect-aware database table name for linked identities (pure)
type Metadata ¶
type Metadata struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
EntityType DBVarchar `` /* 203-byte string literal not displayed */
EntityID DBVarchar `` /* 174-byte string literal not displayed */
Key DBVarchar `gorm:"size:256;not null;index:idx_metadata_key;index:idx_metadata_unique,priority:3;index:idx_metadata_key_value,priority:2"`
Value DBVarchar `gorm:"size:1024;not null;index:idx_metadata_key_value,priority:3"`
CreatedAt time.Time `gorm:"not null;autoCreateTime;index:idx_metadata_created;index:idx_metadata_entity_created,priority:2"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime;index:idx_metadata_modified;index:idx_metadata_entity_modified,priority:2"`
}
Metadata represents key-value metadata for entities Note: Explicit column tags removed for Oracle compatibility SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: DB model for arbitrary key-value metadata on any entity
func (*Metadata) BeforeCreate ¶
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign a UUID to Metadata if unset before DB insert (mutates shared state)
func (*Metadata) BeforeSave ¶
BeforeSave validates Metadata before create or update SEM@d48970168f241f7cb359d0cfdb00f3e26abb59da: validate metadata entity type, key, and value fields before DB write (pure)
type Note ¶
type Note struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
ThreatModelID DBVarchar `` /* 162-byte string literal not displayed */
Name DBVarchar `gorm:"size:256;not null;index:idx_notes_name"`
Content DBText `gorm:"not null"`
Description NullableDBText `gorm:""`
IncludeInReport DBBool `gorm:"default:1"`
TimmyEnabled DBBool `gorm:"default:1"`
AutoGenerated DBBool `gorm:"default:0;<-:create" json:"auto_generated"`
Alias int32 `gorm:"column:alias;not null;default:0;<-:create;uniqueIndex:uniq_notes_tm_alias,priority:2"` // Server-assigned per-(threat_model_id, type) alias
CreatedAt time.Time `gorm:"not null;autoCreateTime;index:idx_notes_created;index:idx_notes_tm_created,priority:2"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime;index:idx_notes_modified;index:idx_notes_tm_modified,priority:2"`
DeletedAt *time.Time `gorm:"index:idx_notes_deleted_at"`
// Relationships
ThreatModel ThreatModel `gorm:"foreignKey:ThreatModelID"`
}
Note represents a note attached to a threat model Note: Explicit column tags removed for Oracle compatibility SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: DB model for a text note attached to a threat model
func (*Note) BeforeCreate ¶
BeforeCreate generates a UUID if not set and validates required fields. Note: Required field validation is intentionally in BeforeCreate (not BeforeSave) because the Update path uses map-based GORM Updates() on an empty model struct. BeforeSave would validate the empty struct's zero-value fields, causing false "cannot be empty" errors. Update-time validation is handled by the API layer. SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign a UUID to Note and validate required fields before DB insert (mutates shared state)
type NullableDBText ¶
NullableDBText is a nullable cross-database large text type. Wraps a string with a Valid flag for NULL handling. Uses TEXT on PostgreSQL, CLOB on Oracle, LONGTEXT on MySQL, NVARCHAR(MAX) on SQL Server, and TEXT on SQLite. SEM@ae4222674aa836756d4e53ad513582d70f862bae: nullable cross-database large text type with Valid flag for NULL handling (pure)
func NewNullableDBText ¶
func NewNullableDBText(s *string) NullableDBText
NewNullableDBText creates a NullableDBText from a string pointer SEM@ae4222674aa836756d4e53ad513582d70f862bae: build a NullableDBText from a string pointer, setting Valid false for nil (pure)
func (NullableDBText) GormDBDataType ¶
GormDBDataType implements the GormDBDataTypeInterface to return dialect-specific column types for cross-database compatibility SEM@9745b416c50726fc3ca5d4637364ba55d6ba0699: return the dialect-specific large text column type for NullableDBText (pure)
func (NullableDBText) MarshalJSON ¶
func (t NullableDBText) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface. A valid NullableDBText marshals as a JSON string; an invalid one marshals as null. SEM@7e4b34fec28c8e0d5c235301e7a132b24212d3a9: serialize NullableDBText to a JSON string or null (pure)
func (NullableDBText) Ptr ¶
func (t NullableDBText) Ptr() *string
Ptr returns a pointer to the string, or nil if not valid SEM@ae4222674aa836756d4e53ad513582d70f862bae: return a string pointer from NullableDBText, or nil if not valid (pure)
func (*NullableDBText) Scan ¶
func (t *NullableDBText) Scan(value any) error
Scan implements the sql.Scanner interface for database reads SEM@3d0d5a8cf02fa74fad102f0f99c2b936a164bbea: deserialize a DB value into NullableDBText, setting Valid false for NULL (pure)
func (*NullableDBText) UnmarshalJSON ¶
func (t *NullableDBText) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface. A JSON null sets Valid to false; a JSON string sets Valid to true and String to the value. SEM@7e4b34fec28c8e0d5c235301e7a132b24212d3a9: deserialize JSON string or null into NullableDBText (pure)
type NullableDBVarchar ¶
NullableDBVarchar is a nullable cross-database length-bounded text type with CHAR semantics. Wraps a string with a Valid flag for NULL handling. Maps to the same column types as DBVarchar per dialect. SEM@ae4222674aa836756d4e53ad513582d70f862bae: nullable cross-database bounded varchar type with Valid flag for NULL handling (pure)
func NewNullableDBVarchar ¶
func NewNullableDBVarchar(s *string) NullableDBVarchar
NewNullableDBVarchar creates a NullableDBVarchar from a string pointer SEM@10f24b09b53917610ab8bdc25c0c5f8621dcc0ee: build a NullableDBVarchar from a string pointer, setting Valid false for nil (pure)
func (NullableDBVarchar) GormDBDataType ¶
GormDBDataType implements the GormDBDataTypeInterface to return dialect-specific column types for cross-database compatibility SEM@9745b416c50726fc3ca5d4637364ba55d6ba0699: return the dialect-specific bounded varchar column type for NullableDBVarchar (pure)
func (NullableDBVarchar) MarshalJSON ¶
func (v NullableDBVarchar) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface. A valid NullableDBVarchar marshals as a JSON string; an invalid one marshals as null. SEM@7e4b34fec28c8e0d5c235301e7a132b24212d3a9: serialize NullableDBVarchar to a JSON string or null (pure)
func (NullableDBVarchar) Ptr ¶
func (v NullableDBVarchar) Ptr() *string
Ptr returns a pointer to the string, or nil if not valid SEM@ae4222674aa836756d4e53ad513582d70f862bae: return a string pointer from NullableDBVarchar, or nil if not valid (pure)
func (*NullableDBVarchar) Scan ¶
func (v *NullableDBVarchar) Scan(value any) error
Scan implements the sql.Scanner interface for database reads SEM@3d0d5a8cf02fa74fad102f0f99c2b936a164bbea: deserialize a DB value into NullableDBVarchar, setting Valid false for NULL (pure)
func (*NullableDBVarchar) UnmarshalJSON ¶
func (v *NullableDBVarchar) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface. A JSON null sets Valid to false; a JSON string sets Valid to true and String to the value. SEM@7e4b34fec28c8e0d5c235301e7a132b24212d3a9: deserialize JSON string or null into NullableDBVarchar (pure)
type NullableSSVC ¶
NullableSSVC is a custom type that stores an optional SSVC score as JSON SEM@41c4d4fee1a1b990b10999bf34a8957796b3a0ce: nullable wrapper for an SSVCScore that distinguishes SQL NULL from a zero value (pure)
func (NullableSSVC) GormDBDataType ¶
GormDBDataType implements the GormDBDataTypeInterface SEM@9745b416c50726fc3ca5d4637364ba55d6ba0699: return the dialect-specific column type for NullableSSVC storage (pure)
func (NullableSSVC) MarshalJSON ¶
func (s NullableSSVC) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface. A valid NullableSSVC marshals as the inner SSVCScore JSON object; an invalid one marshals as null. This mirrors the Value/Scan database representation so JSON round-trips (e.g. through a Redis cache) match the on-disk encoding. SEM@7e4b34fec28c8e0d5c235301e7a132b24212d3a9: serialize a NullableSSVC as a JSON object or null, mirroring its database encoding (pure)
func (*NullableSSVC) Scan ¶
func (s *NullableSSVC) Scan(value any) error
Scan implements the sql.Scanner interface for database reads SEM@3d0d5a8cf02fa74fad102f0f99c2b936a164bbea: deserialize a NullableSSVC from a JSON database value, setting Valid=false for NULL (pure)
func (*NullableSSVC) UnmarshalJSON ¶
func (s *NullableSSVC) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface. A JSON null sets Valid to false; any other value is unmarshaled into the inner SSVCScore and sets Valid to true. SEM@7e4b34fec28c8e0d5c235301e7a132b24212d3a9: deserialize a NullableSSVC from JSON null or an SSVCScore object (pure)
type OracleBool
deprecated
type OracleBool = DBBool
OracleBool is an alias for DBBool for backward compatibility.
Deprecated: Use DBBool instead.
type ProjectNoteRecord ¶
type ProjectNoteRecord struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
ProjectID DBVarchar `gorm:"size:36;not null;index:idx_pnote_project;index:idx_pnote_project_name,priority:1"`
Name DBVarchar `gorm:"size:256;not null;index:idx_pnote_name;index:idx_pnote_project_name,priority:2"`
Content DBText `gorm:"not null"`
Description NullableDBText `gorm:""`
TimmyEnabled DBBool `gorm:"default:1"`
Sharable DBBool `gorm:"not null"`
CreatedAt time.Time `gorm:"not null;autoCreateTime;index:idx_pnote_created"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
// Relationships
Project ProjectRecord `gorm:"foreignKey:ProjectID;constraint:OnDelete:CASCADE"`
}
ProjectNoteRecord represents a note attached to a project SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model for a note attached to a project, with cascade delete on project removal
func (*ProjectNoteRecord) BeforeCreate ¶
func (n *ProjectNoteRecord) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set and validates required fields. SEM@2dccb03396c9b3e288e2242edb54c418635c3e08: assign a UUID and validate required fields before inserting a project note (pure)
func (ProjectNoteRecord) TableName ¶
func (ProjectNoteRecord) TableName() string
TableName specifies the table name for ProjectNoteRecord SEM@14963ec2acf3a735a933d7f1e724e4c7d224cbe6: return the database table name for ProjectNoteRecord (pure)
type ProjectRecord ¶
type ProjectRecord struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
Name DBVarchar `gorm:"size:256;not null;index:idx_proj_name"`
Description NullableDBText `gorm:""`
TeamID DBVarchar `gorm:"size:36;not null;index:idx_proj_team"`
URI NullableDBText `gorm:""`
Status NullableDBVarchar `gorm:"size:128;index:idx_proj_status"`
CreatedByInternalUUID DBVarchar `gorm:"size:36;not null"`
ModifiedByInternalUUID NullableDBVarchar `gorm:"size:36"`
ReviewedByInternalUUID NullableDBVarchar `gorm:"size:36"`
ReviewedAt *time.Time `gorm:"index:idx_proj_reviewed_at"`
CreatedAt time.Time `gorm:"not null;autoCreateTime;index:idx_proj_created_at"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
// Version is incremented on every successful update (T14 / #385).
Version int `gorm:"not null;default:1"`
// Relationships
Team TeamRecord `gorm:"foreignKey:TeamID"`
CreatedBy User `gorm:"foreignKey:CreatedByInternalUUID;references:InternalUUID;constraint:-"`
ModifiedBy *User `gorm:"foreignKey:ModifiedByInternalUUID;references:InternalUUID;constraint:-"`
ReviewedBy *User `gorm:"foreignKey:ReviewedByInternalUUID;references:InternalUUID;constraint:-"`
}
ProjectRecord represents a project in the system SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model for a project with ownership, status, review, and versioning metadata
func (*ProjectRecord) BeforeCreate ¶
func (p *ProjectRecord) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: generate and assign a UUID to the project record if absent (mutates shared state)
func (ProjectRecord) TableName ¶
func (ProjectRecord) TableName() string
TableName specifies the table name for ProjectRecord SEM@8c7929da791c778ff88713684c47aa2a10911bba: return the DB table name for the project entity (pure)
type ProjectRelationshipRecord ¶
type ProjectRelationshipRecord struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
ProjectID DBVarchar `gorm:"size:36;not null;index:idx_prel_project;uniqueIndex:idx_prel_project_related,priority:1"`
RelatedProjectID DBVarchar `gorm:"size:36;not null;index:idx_prel_related;uniqueIndex:idx_prel_project_related,priority:2"`
Relationship DBVarchar `gorm:"size:64;not null"`
CustomRelationship NullableDBVarchar `gorm:"size:128"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
// Relationships
Project ProjectRecord `gorm:"foreignKey:ProjectID"`
RelatedProject ProjectRecord `gorm:"foreignKey:RelatedProjectID"`
}
ProjectRelationshipRecord represents a relationship between two projects SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model representing a typed directional relationship between two projects
func (*ProjectRelationshipRecord) BeforeCreate ¶
func (p *ProjectRelationshipRecord) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: generate and assign a UUID to the project relationship record if absent (mutates shared state)
func (ProjectRelationshipRecord) TableName ¶
func (ProjectRelationshipRecord) TableName() string
TableName specifies the table name for ProjectRelationshipRecord SEM@8c7929da791c778ff88713684c47aa2a10911bba: return the DB table name for the project relationship entity (pure)
type ProjectResponsiblePartyRecord ¶
type ProjectResponsiblePartyRecord struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
ProjectID DBVarchar `gorm:"size:36;not null;index:idx_prp_project;uniqueIndex:idx_prp_project_user,priority:1"`
UserInternalUUID DBVarchar `gorm:"size:36;not null;index:idx_prp_user;uniqueIndex:idx_prp_project_user,priority:2"`
Role DBVarchar `gorm:"size:64;not null"`
CustomRole NullableDBVarchar `gorm:"size:128"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
// Relationships
Project ProjectRecord `gorm:"foreignKey:ProjectID"`
User User `gorm:"foreignKey:UserInternalUUID;references:InternalUUID"`
}
ProjectResponsiblePartyRecord represents a responsible party for a project SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model mapping a responsible party user to a project with role
func (*ProjectResponsiblePartyRecord) BeforeCreate ¶
func (p *ProjectResponsiblePartyRecord) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: generate and assign a UUID to the project responsible party record if absent (mutates shared state)
func (ProjectResponsiblePartyRecord) TableName ¶
func (ProjectResponsiblePartyRecord) TableName() string
TableName specifies the table name for ProjectResponsiblePartyRecord SEM@8c7929da791c778ff88713684c47aa2a10911bba: return the DB table name for the project responsible party entity (pure)
type RefreshTokenRecord ¶
type RefreshTokenRecord struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
UserInternalUUID DBVarchar `gorm:"size:36;not null;index"`
Token DBVarchar `gorm:"size:4000;not null;uniqueIndex"` // DBVarchar size:4000 for Oracle compatibility (CLOB cannot have unique index)
ExpiresAt time.Time `gorm:"not null"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
// Relationships
User User `gorm:"foreignKey:UserInternalUUID;references:InternalUUID"`
}
RefreshTokenRecord represents a refresh token for a user Note: Explicit column tags removed for Oracle compatibility SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model for a persisted OAuth refresh token linked to a user
func (*RefreshTokenRecord) BeforeCreate ¶
func (r *RefreshTokenRecord) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: generate a UUID primary key for RefreshTokenRecord before insert if not already set
func (RefreshTokenRecord) TableName ¶
func (RefreshTokenRecord) TableName() string
TableName specifies the table name for RefreshTokenRecord SEM@7d6e24510cb080b00d72322263caafc04d1d57dc: return the dialect-aware table name for RefreshTokenRecord (pure)
type Repository ¶
type Repository struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
ThreatModelID DBVarchar `` /* 169-byte string literal not displayed */
Name NullableDBVarchar `gorm:"size:256;index:idx_repos_name"`
URI DBText `gorm:"not null"`
Description NullableDBText `gorm:""`
Type NullableDBVarchar `gorm:"size:64;index:idx_repos_type"`
Parameters JSONMap `gorm:""`
IncludeInReport DBBool `gorm:"default:1"`
TimmyEnabled DBBool `gorm:"default:1"`
Alias int32 `gorm:"column:alias;not null;default:0;<-:create;uniqueIndex:uniq_repositories_tm_alias,priority:2"` // Server-assigned per-(threat_model_id, type) alias
CreatedAt time.Time `gorm:"not null;autoCreateTime;index:idx_repos_created;index:idx_repos_tm_created,priority:2"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime;index:idx_repos_modified;index:idx_repos_tm_modified,priority:2"`
DeletedAt *time.Time `gorm:"index:idx_repos_deleted_at"`
// Relationships
ThreatModel ThreatModel `gorm:"foreignKey:ThreatModelID"`
}
Repository represents a repository attached to a threat model Note: Explicit column tags removed for Oracle compatibility SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: DB model for a source-code repository attached to a threat model
func (*Repository) BeforeCreate ¶
func (r *Repository) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign a UUID to Repository if unset before DB insert (mutates shared state)
func (*Repository) BeforeSave ¶
func (r *Repository) BeforeSave(tx *gorm.DB) error
BeforeSave validates Repository before create or update SEM@d48970168f241f7cb359d0cfdb00f3e26abb59da: validate repository URI and optional type enum before DB write (pure)
func (Repository) TableName ¶
func (Repository) TableName() string
TableName specifies the table name for Repository SEM@7d6e24510cb080b00d72322263caafc04d1d57dc: return the dialect-aware DB table name for Repository (pure)
type SSVCScore ¶
type SSVCScore struct {
Vector string `json:"vector"`
Decision string `json:"decision"`
Methodology string `json:"methodology"`
}
SSVCScore represents an SSVC (Stakeholder-Specific Vulnerability Categorization) assessment result SEM@41c4d4fee1a1b990b10999bf34a8957796b3a0ce: SSVC stakeholder vulnerability categorization result with vector, decision, and methodology (pure)
type SessionParticipant ¶
type SessionParticipant struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
SessionID DBVarchar `gorm:"size:36;not null;index"`
UserInternalUUID DBVarchar `gorm:"size:36;not null;index"`
JoinedAt time.Time `gorm:"not null;autoCreateTime"`
LeftAt *time.Time
// Relationships
Session CollaborationSession `gorm:"foreignKey:SessionID"`
User User `gorm:"foreignKey:UserInternalUUID;references:InternalUUID"`
}
SessionParticipant represents a participant in a collaboration session Note: Explicit column tags removed for Oracle compatibility SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: DB model for a user participating in a collaboration session
func (*SessionParticipant) BeforeCreate ¶
func (s *SessionParticipant) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign a UUID to SessionParticipant if unset before DB insert (mutates shared state)
func (SessionParticipant) TableName ¶
func (SessionParticipant) TableName() string
TableName specifies the table name for SessionParticipant SEM@7d6e24510cb080b00d72322263caafc04d1d57dc: return the dialect-aware DB table name for SessionParticipant (pure)
type StringArray ¶
type StringArray []string
StringArray is a custom type that stores string arrays as JSON This outputs JSON array format ["val1","val2"] which works for both PostgreSQL JSONB columns and Oracle JSON columns SEM@a251f60c11fe9831021be2539ff7d746fbd65b2c: database-compatible string slice that serializes as a JSON array for cross-dialect storage (pure)
func (StringArray) GormDBDataType ¶
GormDBDataType implements the GormDBDataTypeInterface to return dialect-specific column types for cross-database compatibility SEM@9745b416c50726fc3ca5d4637364ba55d6ba0699: return the dialect-specific column type for StringArray storage (pure)
func (*StringArray) Scan ¶
func (a *StringArray) Scan(value any) error
Scan implements the sql.Scanner interface for database reads SEM@3d0d5a8cf02fa74fad102f0f99c2b936a164bbea: deserialize a StringArray from a JSON or PostgreSQL array format database value (pure)
func (StringArray) Value ¶
func (a StringArray) Value() (driver.Value, error)
Value implements the driver.Valuer interface for database writes Outputs JSON array format: ["val1","val2","val3"] SEM@55d98405ac043c7929d10873466d6f6f3ebc53e8: serialize a StringArray to a JSON array string for database writes (pure)
type SurveyAnswer ¶
type SurveyAnswer struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
ResponseID DBVarchar `gorm:"size:36;not null;index:idx_sa_response_id;index:idx_sa_response_mapping"`
QuestionName DBVarchar `gorm:"size:256;not null"`
QuestionType DBVarchar `gorm:"size:64;not null"`
QuestionTitle NullableDBText `gorm:""`
MapsToTmField NullableDBVarchar `gorm:"size:128;index:idx_sa_response_mapping"`
AnswerValue JSONRaw `gorm:""`
ResponseStatus DBVarchar `gorm:"size:30;not null"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
// Relationships
SurveyResponse SurveyResponse `gorm:"foreignKey:ResponseID"`
}
SurveyAnswer represents an extracted answer from a survey response. Rows are fully replaced on every response save for consistency. SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model for a single extracted answer from a survey response keyed by question (pure)
func (*SurveyAnswer) BeforeCreate ¶
func (s *SurveyAnswer) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign a UUID to a survey answer if not already set before DB insert (pure)
func (SurveyAnswer) TableName ¶
func (SurveyAnswer) TableName() string
TableName specifies the table name for SurveyAnswer SEM@5998227fb120ee0575a994ea2c0ecb24f0e67109: return the DB table name for the survey answer entity (pure)
type SurveyResponse ¶
type SurveyResponse struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
TemplateID DBVarchar `gorm:"size:36;not null;index:idx_sr_template;index:idx_sr_template_status,priority:1"`
TemplateVersion DBVarchar `gorm:"size:64;not null"` // Captured at creation, immutable
Status DBVarchar `gorm:"size:30;not null;default:draft;index:idx_sr_status;index:idx_sr_template_status,priority:2"`
IsConfidential DBBool `gorm:"default:0"` // If true, Security Reviewers group not auto-added
Answers JSONRaw `gorm:""` // Question answers keyed by question name
UIState JSONRaw `gorm:"column:ui_state"` // Client-managed UI state for draft resumption
SurveyJSON JSONRaw `gorm:"column:survey_json"` // Snapshot of template survey_json at creation
LinkedThreatModelID NullableDBVarchar `gorm:"size:36;index:idx_sr_linked_tm"`
CreatedThreatModelID NullableDBVarchar `gorm:"size:36;index:idx_sr_created_tm"`
RevisionNotes NullableDBText `gorm:""`
OwnerInternalUUID NullableDBVarchar `gorm:"size:36;index:idx_sr_owner"`
CreatedAt time.Time `gorm:"not null;autoCreateTime;index:idx_sr_created_at"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
SubmittedAt *time.Time `gorm:"index:idx_sr_submitted_at"`
ReviewedAt *time.Time
ReviewedByInternalUUID NullableDBVarchar `gorm:"size:36"`
ProjectID NullableDBVarchar `gorm:"size:36;index:idx_sr_project"`
// Version is incremented on every successful update (T14 / #385).
Version int `gorm:"not null;default:1"`
// Relationships
Template SurveyTemplate `gorm:"foreignKey:TemplateID"`
Owner *User `gorm:"foreignKey:OwnerInternalUUID;references:InternalUUID"`
ReviewedBy *User `gorm:"foreignKey:ReviewedByInternalUUID;references:InternalUUID;constraint:-"`
LinkedThreatModel *ThreatModel `gorm:"foreignKey:LinkedThreatModelID"`
CreatedThreatModel *ThreatModel `gorm:"foreignKey:CreatedThreatModelID"`
Project *ProjectRecord `gorm:"foreignKey:ProjectID"`
}
SurveyResponse represents a user's response to a survey template SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model representing a user's submitted answers to a survey template with lifecycle state (pure)
func (*SurveyResponse) BeforeCreate ¶
func (s *SurveyResponse) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign a UUID to a survey response if not already set before DB insert (pure)
func (SurveyResponse) TableName ¶
func (SurveyResponse) TableName() string
TableName specifies the table name for SurveyResponse SEM@5998227fb120ee0575a994ea2c0ecb24f0e67109: return the DB table name for the survey response entity (pure)
type SurveyResponseAccess ¶
type SurveyResponseAccess struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
SurveyResponseID DBVarchar `gorm:"size:36;not null;index:idx_sra_sr;index:idx_sra_perf,priority:1"`
UserInternalUUID NullableDBVarchar `gorm:"size:36;index:idx_sra_user;index:idx_sra_perf,priority:3"`
GroupInternalUUID NullableDBVarchar `gorm:"size:36;index:idx_sra_group;index:idx_sra_perf,priority:4"`
SubjectType DBVarchar `gorm:"size:10;not null;index:idx_sra_subject_type;index:idx_sra_perf,priority:2"`
Role DBVarchar `gorm:"size:6;not null;index:idx_sra_role"`
GrantedByInternalUUID NullableDBVarchar `gorm:"size:36"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
// Relationships
SurveyResponse SurveyResponse `gorm:"foreignKey:SurveyResponseID"`
User *User `gorm:"foreignKey:UserInternalUUID;references:InternalUUID"`
Group *Group `gorm:"foreignKey:GroupInternalUUID;references:InternalUUID"`
GrantedBy *User `gorm:"foreignKey:GrantedByInternalUUID;references:InternalUUID"`
}
SurveyResponseAccess represents access control for a survey response Mirrors the ThreatModelAccess pattern for consistency SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model for role-based access control grants on a survey response (pure)
func (*SurveyResponseAccess) BeforeCreate ¶
func (s *SurveyResponseAccess) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign a UUID to a survey response access record if not already set before DB insert (pure)
func (SurveyResponseAccess) TableName ¶
func (SurveyResponseAccess) TableName() string
TableName specifies the table name for SurveyResponseAccess SEM@5998227fb120ee0575a994ea2c0ecb24f0e67109: return the DB table name for the survey response access entity (pure)
type SurveyTemplate ¶
type SurveyTemplate struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
Name DBVarchar `gorm:"size:256;not null;index:idx_st_name;uniqueIndex:idx_st_name_version,priority:1"`
Description NullableDBText `gorm:""`
Version DBVarchar `gorm:"size:64;not null;index:idx_st_version;uniqueIndex:idx_st_name_version,priority:2"`
Status DBVarchar `gorm:"size:20;not null;default:inactive;index:idx_st_status"`
SurveyJSON JSONRaw `gorm:"column:survey_json"` // Complete SurveyJS JSON definition (opaque blob)
Settings JSONRaw `gorm:""` // Template settings (allow_threat_model_linking, etc.)
CreatedByInternalUUID DBVarchar `gorm:"size:36;not null;index:idx_st_created_by"`
CreatedAt time.Time `gorm:"not null;autoCreateTime;index:idx_st_created_at"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
}
SurveyTemplate represents a survey template for security review intake SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model representing a versioned security review intake survey template (pure)
func (*SurveyTemplate) BeforeCreate ¶
func (s *SurveyTemplate) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign a UUID to a survey template if not already set before DB insert (pure)
func (SurveyTemplate) TableName ¶
func (SurveyTemplate) TableName() string
TableName specifies the table name for SurveyTemplate SEM@5998227fb120ee0575a994ea2c0ecb24f0e67109: return the DB table name for the survey template entity (pure)
type SurveyTemplateVersion ¶
type SurveyTemplateVersion struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
TemplateID DBVarchar `gorm:"size:36;not null;index:idx_stv_template;uniqueIndex:idx_stv_template_version,priority:1"`
Version DBVarchar `gorm:"size:64;not null;uniqueIndex:idx_stv_template_version,priority:2"`
SurveyJSON JSONRaw `gorm:"column:survey_json"`
CreatedByInternalUUID DBVarchar `gorm:"size:36;not null"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
// Relationships
Template SurveyTemplate `gorm:"foreignKey:TemplateID"`
}
SurveyTemplateVersion represents a versioned snapshot of a survey template definition SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model representing a frozen snapshot of a survey template definition (pure)
func (*SurveyTemplateVersion) BeforeCreate ¶
func (s *SurveyTemplateVersion) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign a UUID to a survey template version if not already set before DB insert (pure)
func (SurveyTemplateVersion) TableName ¶
func (SurveyTemplateVersion) TableName() string
TableName specifies the table name for SurveyTemplateVersion SEM@5998227fb120ee0575a994ea2c0ecb24f0e67109: return the DB table name for the survey template version entity (pure)
type SystemAuditEntry ¶
type SystemAuditEntry struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36;index:idx_sysaudit_created_id,priority:2"`
// Actor identity (denormalized)
ActorEmail DBVarchar `gorm:"size:320;not null;index:idx_sysaudit_actor,priority:1"`
ActorProvider DBVarchar `gorm:"size:100;not null"`
ActorProviderID DBVarchar `gorm:"size:500;not null"`
ActorDisplayName DBVarchar `gorm:"size:256;not null"`
// Request shape
HTTPMethod DBVarchar `gorm:"size:10;not null"`
HTTPPath DBText `gorm:"not null"`
// Change description
FieldPath DBVarchar `gorm:"size:1024;not null;index:idx_sysaudit_field"`
OldValueRedacted NullableDBText `gorm:""`
NewValueRedacted NullableDBText `gorm:""`
ChangeSummary NullableDBText `gorm:""`
// Composite (created_at, id) index serves the bidirectional keyset scans and
// the unfiltered full-table export in both ASC and DESC directions (#473). It
// also covers single-column created_at lookups by prefix, so the former
// single-column idx_sysaudit_created has been dropped from fresh schemas.
CreatedAt time.Time `gorm:"not null;autoCreateTime;index:idx_sysaudit_actor,priority:2;index:idx_sysaudit_created_id,priority:1"`
}
SystemAuditEntry is a system-level audit row recording a single /admin/* write. Distinct from AuditEntry (which is threat-model-scoped). Append-only; writes only happen on 2xx responses; redaction policy is applied at write time per the deny-list in api/admin_audit_redaction.go (see #355).
Actor fields are denormalized (matches AuditEntry pattern) so audit rows persist after user deletion. No FKs by design — investigators rely on the row content, not on join integrity. SEM@b7ad72016d91424b5dd7e6ed69ba846a4170f7b5: append-only DB record of a single admin write operation with denormalized actor identity
func (*SystemAuditEntry) BeforeCreate ¶
func (s *SystemAuditEntry) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set. SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: generate a UUID for the system audit entry if none is set before DB insert (mutates shared state)
func (SystemAuditEntry) TableName ¶
func (SystemAuditEntry) TableName() string
TableName returns the table name, casing-aware for Oracle compatibility. SEM@40a00bf3590eabf19003103d38311ef4c284f3aa: return the DB table name for system audit entries with Oracle-compatible casing (pure)
type SystemSetting ¶
type SystemSetting struct {
// SettingKey is the unique identifier for this setting (e.g., "rate_limit.requests_per_minute")
// Named SettingKey instead of Key to avoid Oracle reserved word conflict
SettingKey DBVarchar `gorm:"column:setting_key;primaryKey;not null;size:256" json:"key"`
Value DBText `gorm:"not null" json:"value"`
// SettingType stores the value type: "string", "int", "bool", "json"
// Note: default tag removed for Oracle compatibility (unquoted string defaults cause syntax errors)
SettingType DBVarchar `gorm:"column:setting_type;size:50;not null" json:"type"`
Description NullableDBText `gorm:"" json:"description,omitempty"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime" json:"modified_at"`
ModifiedBy NullableDBVarchar `gorm:"size:36" json:"modified_by,omitempty"` // User InternalUUID
// Source indicates where the effective value comes from: "database", "config", "environment", "vault"
// Computed at response time, not stored in the database.
Source string `gorm:"-" json:"source"`
// ReadOnly indicates whether this setting can be modified via the API.
// True when source is not "database". Computed at response time.
ReadOnly bool `gorm:"-" json:"read_only"`
}
SystemSetting represents a system-wide configuration setting stored in the database. These settings can be modified at runtime without requiring server restart. Settings are cached with short TTL for performance. SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model for a runtime-configurable system setting with key, typed value, and audit fields (reads DB)
func DefaultSystemSettings ¶
func DefaultSystemSettings() []SystemSetting
DefaultSystemSettings returns the default system settings that should be seeded when the database is initialized. These provide sensible defaults that can be overridden by administrators. SEM@8f7b5125fd7a1b5bb10210ba480278708de918b0: build the seed list of default system settings for database initialization (pure)
func (SystemSetting) TableName ¶
func (SystemSetting) TableName() string
TableName specifies the table name for SystemSetting SEM@fe6575f1c15d84b67ee9853a0e59055c1ebe44b6: return the database table name for the SystemSetting model (pure)
type TeamMemberRecord ¶
type TeamMemberRecord struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
TeamID DBVarchar `gorm:"size:36;not null;index:idx_tmem_team;uniqueIndex:idx_tmem_team_user,priority:1"`
UserInternalUUID DBVarchar `gorm:"size:36;not null;index:idx_tmem_user;uniqueIndex:idx_tmem_team_user,priority:2"`
Role DBVarchar `gorm:"size:64;not null;default:engineer"`
CustomRole NullableDBVarchar `gorm:"size:128"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
// Relationships
Team TeamRecord `gorm:"foreignKey:TeamID"`
User User `gorm:"foreignKey:UserInternalUUID;references:InternalUUID"`
}
TeamMemberRecord represents a user's membership in a team SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model representing a user's role membership in a team (reads DB)
func (*TeamMemberRecord) BeforeCreate ¶
func (t *TeamMemberRecord) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: generate and assign a UUID to the team member record if absent (mutates shared state)
func (TeamMemberRecord) TableName ¶
func (TeamMemberRecord) TableName() string
TableName specifies the table name for TeamMemberRecord SEM@8c7929da791c778ff88713684c47aa2a10911bba: return the DB table name for the team member entity (pure)
type TeamNoteRecord ¶
type TeamNoteRecord struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
TeamID DBVarchar `gorm:"size:36;not null;index:idx_tnote_team;index:idx_tnote_team_name,priority:1"`
Name DBVarchar `gorm:"size:256;not null;index:idx_tnote_name;index:idx_tnote_team_name,priority:2"`
Content DBText `gorm:"not null"`
Description NullableDBText `gorm:""`
TimmyEnabled DBBool `gorm:"default:1"`
Sharable DBBool `gorm:"not null"`
CreatedAt time.Time `gorm:"not null;autoCreateTime;index:idx_tnote_created"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
// Relationships
Team TeamRecord `gorm:"foreignKey:TeamID;constraint:OnDelete:CASCADE"`
}
TeamNoteRecord represents a note attached to a team SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model for a note attached to a team, with cascade delete on team removal
func (*TeamNoteRecord) BeforeCreate ¶
func (n *TeamNoteRecord) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set and validates required fields. SEM@2dccb03396c9b3e288e2242edb54c418635c3e08: assign a UUID and validate required fields before inserting a team note (pure)
func (TeamNoteRecord) TableName ¶
func (TeamNoteRecord) TableName() string
TableName specifies the table name for TeamNoteRecord SEM@14963ec2acf3a735a933d7f1e724e4c7d224cbe6: return the database table name for TeamNoteRecord (pure)
type TeamRecord ¶
type TeamRecord struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
Name DBVarchar `gorm:"size:256;not null;index:idx_team_name"`
Description NullableDBText `gorm:""`
URI NullableDBText `gorm:""`
EmailAddress NullableDBVarchar `gorm:"size:320"`
Status NullableDBVarchar `gorm:"size:128;index:idx_team_status"`
CreatedByInternalUUID DBVarchar `gorm:"size:36;not null"`
ModifiedByInternalUUID NullableDBVarchar `gorm:"size:36"`
ReviewedByInternalUUID NullableDBVarchar `gorm:"size:36"`
ReviewedAt *time.Time `gorm:"index:idx_team_reviewed_at"`
CreatedAt time.Time `gorm:"not null;autoCreateTime;index:idx_team_created_at"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
// Version is incremented on every successful update (T14 / #385).
Version int `gorm:"not null;default:1"`
// Relationships
CreatedBy User `gorm:"foreignKey:CreatedByInternalUUID;references:InternalUUID;constraint:-"`
ModifiedBy *User `gorm:"foreignKey:ModifiedByInternalUUID;references:InternalUUID;constraint:-"`
ReviewedBy *User `gorm:"foreignKey:ReviewedByInternalUUID;references:InternalUUID;constraint:-"`
}
TeamRecord represents a team in the system SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model for a team with membership, audit timestamps, and versioning (reads DB)
func (*TeamRecord) BeforeCreate ¶
func (t *TeamRecord) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: generate a UUID for a TeamRecord if none is set before insert (mutates shared state)
func (TeamRecord) TableName ¶
func (TeamRecord) TableName() string
TableName specifies the table name for TeamRecord SEM@8c7929da791c778ff88713684c47aa2a10911bba: return the database table name for TeamRecord (pure)
type TeamRelationshipRecord ¶
type TeamRelationshipRecord struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
TeamID DBVarchar `gorm:"size:36;not null;index:idx_trel_team;uniqueIndex:idx_trel_team_related,priority:1"`
RelatedTeamID DBVarchar `gorm:"size:36;not null;index:idx_trel_related;uniqueIndex:idx_trel_team_related,priority:2"`
Relationship DBVarchar `gorm:"size:64;not null"`
CustomRelationship NullableDBVarchar `gorm:"size:128"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
// Relationships
Team TeamRecord `gorm:"foreignKey:TeamID"`
RelatedTeam TeamRecord `gorm:"foreignKey:RelatedTeamID"`
}
TeamRelationshipRecord represents a relationship between two teams SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model representing a typed directional relationship between two teams
func (*TeamRelationshipRecord) BeforeCreate ¶
func (t *TeamRelationshipRecord) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: generate and assign a UUID to the team relationship record if absent (mutates shared state)
func (TeamRelationshipRecord) TableName ¶
func (TeamRelationshipRecord) TableName() string
TableName specifies the table name for TeamRelationshipRecord SEM@8c7929da791c778ff88713684c47aa2a10911bba: return the DB table name for the team relationship entity (pure)
type TeamResponsiblePartyRecord ¶
type TeamResponsiblePartyRecord struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
TeamID DBVarchar `gorm:"size:36;not null;index:idx_trp_team;uniqueIndex:idx_trp_team_user,priority:1"`
UserInternalUUID DBVarchar `gorm:"size:36;not null;index:idx_trp_user;uniqueIndex:idx_trp_team_user,priority:2"`
Role DBVarchar `gorm:"size:64;not null"`
CustomRole NullableDBVarchar `gorm:"size:128"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
// Relationships
Team TeamRecord `gorm:"foreignKey:TeamID"`
User User `gorm:"foreignKey:UserInternalUUID;references:InternalUUID"`
}
TeamResponsiblePartyRecord represents a responsible party for a team SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model mapping a responsible party user to a team with role
func (*TeamResponsiblePartyRecord) BeforeCreate ¶
func (t *TeamResponsiblePartyRecord) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: generate and assign a UUID to the team responsible party record if absent (mutates shared state)
func (TeamResponsiblePartyRecord) TableName ¶
func (TeamResponsiblePartyRecord) TableName() string
TableName specifies the table name for TeamResponsiblePartyRecord SEM@8c7929da791c778ff88713684c47aa2a10911bba: return the DB table name for the team responsible party entity (pure)
type Threat ¶
type Threat struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
ThreatModelID DBVarchar `` /* 170-byte string literal not displayed */
DiagramID NullableDBVarchar `gorm:"size:36;index:idx_threats_diagram"`
CellID NullableDBVarchar `gorm:"size:36;index:idx_threats_cell"`
AssetID NullableDBVarchar `gorm:"size:36;index:idx_threats_asset"`
Name DBVarchar `gorm:"size:256;not null;index:idx_threats_name"`
Description NullableDBText `gorm:""`
Severity NullableDBVarchar `gorm:"size:50;index:idx_threats_severity"`
Likelihood NullableDBVarchar `gorm:"size:50"`
RiskLevel NullableDBVarchar `gorm:"size:50;index:idx_threats_risk_level"`
Score *float64 `gorm:"type:decimal(3,1);index:idx_threats_score"`
Priority NullableDBVarchar `gorm:"size:256;index:idx_threats_priority"`
Mitigated DBBool `gorm:"index:idx_threats_mitigated"`
IncludeInReport DBBool `gorm:"default:1"`
TimmyEnabled DBBool `gorm:"default:1"`
AutoGenerated DBBool `gorm:"default:0;<-:create" json:"auto_generated"`
Status NullableDBVarchar `gorm:"size:128;index:idx_threats_status"`
ThreatType StringArray `gorm:"not null"`
CweID StringArray `gorm:"column:cwe_id"` // CWE identifiers (e.g., CWE-89)
Cvss CVSSArray `gorm:"column:cvss"` // CVSS vector and score pairs
Ssvc NullableSSVC `gorm:"column:ssvc"` // SSVC assessment result
Mitigation NullableDBText `gorm:""`
IssueURI NullableDBText `gorm:""`
Alias int32 `gorm:"column:alias;not null;default:0;<-:create;uniqueIndex:uniq_threats_tm_alias,priority:2"` // Server-assigned per-(threat_model_id, type) alias
// Note: autoCreateTime/autoUpdateTime tags removed for Oracle compatibility.
// Timestamps are set explicitly in the store layer (toGormModelForCreate).
CreatedAt time.Time `gorm:"not null;index:idx_threats_tm_created,priority:2"`
ModifiedAt time.Time `gorm:"not null;index:idx_threats_modified;index:idx_threats_tm_modified,priority:2"`
DeletedAt *time.Time `gorm:"index:idx_threats_deleted_at"`
// Version is incremented on every successful update (T14 / #385).
Version int `gorm:"not null;default:1"`
// Relationships
ThreatModel ThreatModel `gorm:"foreignKey:ThreatModelID"`
Diagram *Diagram `gorm:"foreignKey:DiagramID"`
Asset *Asset `gorm:"foreignKey:AssetID"`
}
Threat represents a threat within a threat model Note: Explicit column tags removed for Oracle compatibility SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model for a threat entry with severity, CVSS, SSVC, mitigation, and status fields
func (*Threat) BeforeCreate ¶
BeforeCreate ensures the ID is set before insert This is required for Oracle compatibility where the driver may not properly handle IDs set after struct initialization SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign a UUID to Threat if unset before DB insert (mutates shared state)
func (*Threat) BeforeSave ¶
BeforeSave validates Threat before create or update SEM@d48970168f241f7cb359d0cfdb00f3e26abb59da: validate Threat score before a GORM create or update (pure)
type ThreatModel ¶
type ThreatModel struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
OwnerInternalUUID DBVarchar `gorm:"size:36;not null;index:idx_tm_owner;index:idx_tm_owner_created,priority:1"`
Name DBVarchar `gorm:"size:256;not null"`
Description NullableDBText `gorm:""`
CreatedByInternalUUID DBVarchar `gorm:"size:36;not null;index:idx_tm_created_by"`
ThreatModelFramework DBVarchar `gorm:"size:30;default:STRIDE;index:idx_tm_framework"`
IssueURI NullableDBText `gorm:""`
Status DBVarchar `gorm:"size:128;not null;default:'not_started';index:idx_tm_status"`
StatusUpdated time.Time `gorm:"not null;default:CURRENT_TIMESTAMP;index:idx_tm_status_updated"`
Alias int32 `gorm:"column:alias;not null;default:0;<-:create;uniqueIndex:uniq_threat_models_alias"` // Server-assigned globally-unique integer alias
IsConfidential DBBool `gorm:"default:0"` // Immutable after creation
SecurityReviewerInternalUUID NullableDBVarchar `gorm:"size:36;index:idx_tm_security_reviewer"`
ProjectID NullableDBVarchar `gorm:"size:36;index:idx_tm_project"`
// Timestamp columns map to precision-6 TIMESTAMP WITH TIME ZONE on both
// PostgreSQL and Oracle (the gorm-oracle dialector emits bare TIMESTAMP WITH
// TIME ZONE = microsecond). The application truncates created_at/modified_at
// to microseconds at generation (see api/store.go UpdateTimestamps and the
// threat-model handlers) so in-memory values match what the DB persists and
// conform to the OpenAPI timestamp schema (max 6 fractional digits). If these
// columns are ever pinned to a different precision, revisit that truncation.
CreatedAt time.Time `gorm:"not null;autoCreateTime;index:idx_tm_owner_created,priority:2"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
DeletedAt *time.Time `gorm:"index:idx_tm_deleted_at"`
LastAccessedAt *time.Time `gorm:"index:idx_tm_last_accessed_at"`
// Version is incremented on every successful update (T14 / #385).
// Clients pass the expected value via If-Match (or version body field) on
// PUT/PATCH; mismatches return 409 Conflict.
Version int `gorm:"not null;default:1"`
// Relationships
Project *ProjectRecord `gorm:"foreignKey:ProjectID"`
Owner User `gorm:"foreignKey:OwnerInternalUUID;references:InternalUUID"`
CreatedBy User `gorm:"foreignKey:CreatedByInternalUUID;references:InternalUUID;constraint:-"`
SecurityReviewer *User `gorm:"foreignKey:SecurityReviewerInternalUUID;references:InternalUUID"`
Diagrams []Diagram `gorm:"foreignKey:ThreatModelID"`
Threats []Threat `gorm:"foreignKey:ThreatModelID"`
Assets []Asset `gorm:"foreignKey:ThreatModelID"`
}
ThreatModel represents a threat model in the system Note: Explicit column tags removed for Oracle compatibility (Oracle stores column names as UPPERCASE, and the Oracle GORM driver doesn't handle case-insensitive matching with explicit column tags) SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model for a threat model with ownership, status, versioning, and sub-resource relationships
func (*ThreatModel) BeforeCreate ¶
func (t *ThreatModel) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: generate a UUID primary key for ThreatModel before insert if not already set
func (*ThreatModel) BeforeUpdate ¶
func (t *ThreatModel) BeforeUpdate(tx *gorm.DB) error
BeforeUpdate validates ThreatModel before update SEM@ebf201816c3638ec74fc8483a2a649af3ccddfc9: validate ThreatModel framework and status before a GORM update (pure)
func (ThreatModel) TableName ¶
func (ThreatModel) TableName() string
TableName specifies the table name for ThreatModel SEM@7d6e24510cb080b00d72322263caafc04d1d57dc: return the dialect-aware table name for ThreatModel (pure)
type ThreatModelAccess ¶
type ThreatModelAccess struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
ThreatModelID DBVarchar `gorm:"size:36;not null;index:idx_tma_tm;index:idx_tma_perf,priority:1"`
UserInternalUUID NullableDBVarchar `gorm:"size:36;index:idx_tma_user;index:idx_tma_perf,priority:3"`
GroupInternalUUID NullableDBVarchar `gorm:"size:36;index:idx_tma_group;index:idx_tma_perf,priority:4"`
SubjectType DBVarchar `gorm:"size:10;not null;index:idx_tma_subject_type;index:idx_tma_perf,priority:2"`
Role DBVarchar `gorm:"size:6;not null;index:idx_tma_role"`
GrantedByInternalUUID NullableDBVarchar `gorm:"size:36"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
// Relationships
ThreatModel ThreatModel `gorm:"foreignKey:ThreatModelID"`
User *User `gorm:"foreignKey:UserInternalUUID;references:InternalUUID"`
Group *Group `gorm:"foreignKey:GroupInternalUUID;references:InternalUUID"`
GrantedBy *User `gorm:"foreignKey:GrantedByInternalUUID;references:InternalUUID;constraint:-"`
}
ThreatModelAccess represents access control for threat models Note: Explicit column tags removed for Oracle compatibility (Oracle stores column names as UPPERCASE, and the Oracle GORM driver doesn't handle case-insensitive matching with explicit column tags) SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: DB model for a role-based access-control entry on a threat model
func (*ThreatModelAccess) BeforeCreate ¶
func (t *ThreatModelAccess) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign a UUID to ThreatModelAccess if unset before DB insert (mutates shared state)
func (*ThreatModelAccess) BeforeSave ¶
func (t *ThreatModelAccess) BeforeSave(tx *gorm.DB) error
BeforeSave validates ThreatModelAccess before create or update SEM@d48970168f241f7cb359d0cfdb00f3e26abb59da: validate access control entry subject type, role, and user/group exclusivity before DB write (pure)
func (ThreatModelAccess) TableName ¶
func (ThreatModelAccess) TableName() string
TableName specifies the table name for ThreatModelAccess SEM@7d6e24510cb080b00d72322263caafc04d1d57dc: return the dialect-aware DB table name for ThreatModelAccess (pure)
type TimmyEmbedding ¶
type TimmyEmbedding struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
ThreatModelID DBVarchar `gorm:"size:36;not null;index:idx_timmy_embeddings_tm;index:idx_timmy_embeddings_entity,priority:1"`
EntityType DBVarchar `gorm:"size:30;not null;index:idx_timmy_embeddings_entity,priority:2"`
EntityID DBVarchar `gorm:"size:36;not null;index:idx_timmy_embeddings_entity,priority:3"`
ChunkIndex int `gorm:"not null;index:idx_timmy_embeddings_entity,priority:4"`
IndexType DBVarchar `gorm:"size:10;not null;default:text;index:idx_timmy_embeddings_entity,priority:5"`
ContentHash DBVarchar `gorm:"size:64;not null"`
EmbeddingModel DBVarchar `gorm:"size:100;not null"`
EmbeddingDim int `gorm:"not null"`
VectorData DBBytes `gorm:""`
ChunkText DBText `gorm:"not null"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
// Relationships
ThreatModel ThreatModel `gorm:"foreignKey:ThreatModelID"`
}
TimmyEmbedding represents a vector embedding for a chunk of threat model content SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model for a vector embedding chunk derived from threat model content (reads DB)
func (*TimmyEmbedding) BeforeCreate ¶
func (e *TimmyEmbedding) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign a new UUID to TimmyEmbedding if none is set before insert (mutates shared state)
func (TimmyEmbedding) TableName ¶
func (TimmyEmbedding) TableName() string
TableName specifies the table name for TimmyEmbedding SEM@38c9cd78ea6f81a7cfa5891e34a980915566378b: return the database table name for TimmyEmbedding records (pure)
type TimmyMessage ¶
type TimmyMessage struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
SessionID DBVarchar `gorm:"size:36;not null;index:idx_timmy_messages_session;uniqueIndex:idx_timmy_messages_session_seq,priority:1"`
Role DBVarchar `gorm:"size:20;not null"`
Content DBText `gorm:"not null"`
TokenCount int `gorm:"default:0"`
Sequence int `gorm:"not null;uniqueIndex:idx_timmy_messages_session_seq,priority:2"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
// Relationships
Session TimmySession `gorm:"foreignKey:SessionID"`
}
TimmyMessage represents a single message in a Timmy chat session SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model for a single ordered message in a Timmy chat session (reads DB)
func (*TimmyMessage) BeforeCreate ¶
func (m *TimmyMessage) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign a UUID to a TimmyMessage before insert (pure)
func (TimmyMessage) TableName ¶
func (TimmyMessage) TableName() string
TableName specifies the table name for TimmyMessage SEM@38c9cd78ea6f81a7cfa5891e34a980915566378b: return the DB table name for TimmyMessage (pure)
type TimmySession ¶
type TimmySession struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
ThreatModelID DBVarchar `gorm:"size:36;not null;index:idx_timmy_sessions_tm;index:idx_timmy_sessions_tm_user,priority:1"`
UserID DBVarchar `gorm:"size:36;not null;index:idx_timmy_sessions_user;index:idx_timmy_sessions_tm_user,priority:2"`
Title DBVarchar `gorm:"size:256"`
SourceSnapshot JSONRaw `gorm:""`
SystemPromptHash NullableDBVarchar `gorm:"size:64"`
Status DBVarchar `gorm:"size:20;not null;default:active;index:idx_timmy_sessions_status"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
DeletedAt *time.Time `gorm:"index:idx_timmy_sessions_deleted_at"`
// Relationships
ThreatModel ThreatModel `gorm:"foreignKey:ThreatModelID"`
User User `gorm:"foreignKey:UserID;references:InternalUUID"`
}
TimmySession represents a chat session between a user and Timmy for a threat model SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model for a Timmy AI chat session scoped to a threat model and user (reads DB)
func (*TimmySession) BeforeCreate ¶
func (s *TimmySession) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID and sets default status if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign a UUID and default status to a TimmySession before insert (pure)
func (TimmySession) TableName ¶
func (TimmySession) TableName() string
TableName specifies the table name for TimmySession SEM@38c9cd78ea6f81a7cfa5891e34a980915566378b: return the DB table name for TimmySession (pure)
type TimmyUsage ¶
type TimmyUsage struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
UserID DBVarchar `gorm:"size:36;not null;index:idx_timmy_usage_user"`
SessionID DBVarchar `gorm:"size:36;not null;index:idx_timmy_usage_session"`
ThreatModelID DBVarchar `gorm:"size:36;not null;index:idx_timmy_usage_tm"`
MessageCount int `gorm:"default:0"`
PromptTokens int `gorm:"default:0"`
CompletionTokens int `gorm:"default:0"`
EmbeddingTokens int `gorm:"default:0"`
PeriodStart time.Time `gorm:"not null;index:idx_timmy_usage_period"`
PeriodEnd time.Time `gorm:"not null"`
// Relationships
ThreatModel ThreatModel `gorm:"foreignKey:ThreatModelID"`
User User `gorm:"foreignKey:UserID;references:InternalUUID"`
Session TimmySession `gorm:"foreignKey:SessionID"`
}
TimmyUsage tracks LLM token usage for billing and monitoring SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: store LLM token usage metrics per user, session, and threat model for billing (reads DB)
func (*TimmyUsage) BeforeCreate ¶
func (u *TimmyUsage) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign a new UUID to TimmyUsage if none is set before insert (mutates shared state)
func (TimmyUsage) TableName ¶
func (TimmyUsage) TableName() string
TableName specifies the table name for TimmyUsage SEM@38c9cd78ea6f81a7cfa5891e34a980915566378b: return the database table name for TimmyUsage records (pure)
type TriageNote ¶
type TriageNote struct {
SurveyResponseID DBVarchar `gorm:"primaryKey;not null;size:36;index:idx_tn_sr"`
ID int `gorm:"primaryKey;not null;autoIncrement:false"`
Name DBVarchar `gorm:"size:256;not null"`
Content DBText `gorm:"not null"`
CreatedByInternalUUID NullableDBVarchar `gorm:"size:36"`
ModifiedByInternalUUID NullableDBVarchar `gorm:"size:36"`
CreatedAt time.Time `gorm:"not null;autoCreateTime;index:idx_tn_created"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
// Relationships
SurveyResponse SurveyResponse `gorm:"foreignKey:SurveyResponseID"`
CreatedBy *User `gorm:"foreignKey:CreatedByInternalUUID;references:InternalUUID;constraint:-"`
ModifiedBy *User `gorm:"foreignKey:ModifiedByInternalUUID;references:InternalUUID;constraint:-"`
}
TriageNote represents a triage note attached to a survey response Uses a composite primary key (SurveyResponseID, ID) where ID is a per-response monotonically increasing integer. SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model for an append-only reviewer note attached to a survey response with per-response sequential ID (pure)
func (*TriageNote) BeforeCreate ¶
func (t *TriageNote) BeforeCreate(tx *gorm.DB) error
BeforeCreate assigns the next sequential ID for the survey response SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign the next sequential per-response ID to a triage note before DB insert (reads DB)
func (TriageNote) TableName ¶
func (TriageNote) TableName() string
TableName specifies the table name for TriageNote SEM@5998227fb120ee0575a994ea2c0ecb24f0e67109: return the DB table name for the triage note entity (pure)
type UsabilityFeedback ¶
type UsabilityFeedback struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
Sentiment DBVarchar `gorm:"size:8;not null;index:idx_usability_feedback_sentiment"`
Verbatim NullableDBText `gorm:""`
Surface DBVarchar `gorm:"size:32;not null;index:idx_usability_feedback_surface"`
ClientID DBVarchar `gorm:"column:client_id;size:32;not null"`
ClientVersion NullableDBVarchar `gorm:"column:client_version;size:32"`
ClientBuild NullableDBVarchar `gorm:"column:client_build;size:12"`
UserAgent NullableDBVarchar `gorm:"column:user_agent;size:512"`
UserAgentData JSONRaw `gorm:"column:user_agent_data"`
Viewport NullableDBVarchar `gorm:"size:11"`
Screenshot NullableDBText `gorm:"column:screenshot"`
CreatedByUUID DBVarchar `gorm:"column:created_by;size:36;not null;index:idx_usability_feedback_created_by"`
// Note: autoCreateTime tag removed for Oracle compatibility (#380). The
// repository sets CreatedAt explicitly in Create before INSERT, matching
// the Threat model pattern (see api/models/models.go Threat.CreatedAt).
CreatedAt time.Time `gorm:"not null;index:idx_usability_feedback_created_at"`
// Relationships. constraint:- suppresses the DB-level FK so a user with
// outstanding feedback rows can still be deleted without an integrity-
// constraint error. Application-layer integrity (CreatedByUUID is always
// set from the authenticated user) is sufficient.
CreatedBy User `gorm:"foreignKey:CreatedByUUID;references:InternalUUID;constraint:-"`
}
UsabilityFeedback represents user feedback about UI usability. Issued via POST /usability_feedback by any authenticated user. Listed via GET /usability_feedback (admin only). SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: DB model for user-submitted UI usability feedback with client context
func (*UsabilityFeedback) BeforeCreate ¶
func (u *UsabilityFeedback) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set. SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign a UUID to UsabilityFeedback if unset before DB insert (mutates shared state)
func (UsabilityFeedback) TableName ¶
func (UsabilityFeedback) TableName() string
TableName returns the dialect-aware table name. SEM@7d6e24510cb080b00d72322263caafc04d1d57dc: return the dialect-aware DB table name for UsabilityFeedback (pure)
type User ¶
type User struct {
InternalUUID DBVarchar `gorm:"primaryKey;not null;size:36"`
Provider DBVarchar `gorm:"size:100;not null;index:idx_users_provider;index:idx_users_provider_lookup,priority:1"`
ProviderUserID NullableDBVarchar `gorm:"size:500;index:idx_users_provider_lookup,priority:2"`
Email DBVarchar `gorm:"size:320;not null;index:idx_users_email"`
Name DBVarchar `gorm:"size:256;not null"`
EmailVerified DBBool `gorm:"default:0"`
AccessToken NullableDBText `gorm:""`
RefreshToken NullableDBText `gorm:""`
TokenExpiry *time.Time
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
LastLogin *time.Time `gorm:"index:idx_users_last_login"`
Automation *bool `gorm:"default:null"`
// ExtractionConcurrencyOverride lets a trusted machine account run more
// concurrent OOXML extractions than the operator default. NULL = use
// default. Hard-capped at maxPerUserConcurrency (16) regardless of value.
ExtractionConcurrencyOverride *int `gorm:""`
}
User represents an authenticated user in the system Note: Column names are intentionally not specified to allow GORM's NamingStrategy to handle database-specific casing (lowercase for PostgreSQL, UPPERCASE for Oracle) SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: GORM model for an authenticated user with OAuth identity and token fields
func (*User) BeforeCreate ¶
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: generate a UUID primary key for User before insert if not already set
type UserAPIQuota ¶
type UserAPIQuota struct {
UserInternalUUID DBVarchar `gorm:"primaryKey;not null;size:36"`
MaxRequestsPerMinute int `gorm:"default:100"`
MaxRequestsPerHour *int
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
// Relationships
User User `gorm:"foreignKey:UserInternalUUID;references:InternalUUID"`
}
UserAPIQuota represents per-user API rate limits Note: Explicit column tags removed for Oracle compatibility SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: DB model for per-user API request rate limits
func (UserAPIQuota) TableName ¶
func (UserAPIQuota) TableName() string
TableName specifies the table name for UserAPIQuota SEM@7d6e24510cb080b00d72322263caafc04d1d57dc: return the dialect-aware DB table name for UserAPIQuota (pure)
type UserContentToken ¶
type UserContentToken struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
UserID DBVarchar `gorm:"size:36;not null;index:idx_uct_user;uniqueIndex:uq_uct_user_provider,priority:1"`
ProviderID DBVarchar `gorm:"size:64;not null;uniqueIndex:uq_uct_user_provider,priority:2"`
AccessToken DBBytes `gorm:"not null"`
RefreshToken DBBytes
Scopes DBText
ExpiresAt *time.Time
Status NullableDBVarchar `gorm:"size:16;default:active;index:idx_uct_status_expires,priority:1"`
LastRefreshAt *time.Time `gorm:"index:idx_uct_status_expires,priority:2"`
LastError DBText
ProviderAccountID NullableDBVarchar `gorm:"size:255"`
ProviderAccountLabel NullableDBVarchar `gorm:"size:255"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
// Owner is the user who owns this token; ON DELETE CASCADE removes the token when the user is deleted.
Owner User `gorm:"foreignKey:UserID;references:InternalUUID;constraint:OnDelete:CASCADE"`
}
UserContentToken is a per-user OAuth token used by delegated content providers. access_token and refresh_token are AES-256-GCM ciphertexts (nonce prepended). DBBytes maps to BYTEA on PostgreSQL and BLOB on Oracle / SQLite (#404). SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: DB model for a per-user OAuth token used by delegated content providers, with encrypted token fields (pure)
func (*UserContentToken) BeforeCreate ¶
func (u *UserContentToken) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set. SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: generate and assign a UUID primary key before inserting a UserContentToken (pure)
func (UserContentToken) TableName ¶
func (UserContentToken) TableName() string
TableName specifies the table name for UserContentToken. SEM@fa58c5122fea64e4d8baa4116b86a3f00053b0c3: return the DB table name for UserContentToken (pure)
type UserPreference ¶
type UserPreference struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
UserInternalUUID DBVarchar `gorm:"size:36;not null;uniqueIndex"`
Preferences JSONRaw `gorm:"not null"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
// Relationships
User User `gorm:"foreignKey:UserInternalUUID;references:InternalUUID"`
}
UserPreference stores user preferences as JSON Preferences are keyed by client application identifier (e.g., "tmi-ux", "tmi-cli") Maximum total size: 1KB, maximum 20 client entries SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: DB model for per-user, per-client JSON preferences
func (*UserPreference) BeforeCreate ¶
func (u *UserPreference) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign a UUID to UserPreference if unset before DB insert (mutates shared state)
func (UserPreference) TableName ¶
func (UserPreference) TableName() string
TableName specifies the table name for UserPreference SEM@7d6e24510cb080b00d72322263caafc04d1d57dc: return the dialect-aware DB table name for UserPreference (pure)
type VersionSnapshot ¶
type VersionSnapshot struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
AuditEntryID DBVarchar `gorm:"size:36;not null;index:idx_vs_audit_entry"`
ObjectType DBVarchar `gorm:"size:50;not null;index:idx_vs_object,priority:1;index:idx_vs_object_snapshot,priority:1"`
ObjectID DBVarchar `gorm:"size:36;not null;index:idx_vs_object,priority:2;index:idx_vs_object_snapshot,priority:2"`
Version int `gorm:"not null;index:idx_vs_object,priority:3"`
SnapshotType DBVarchar `gorm:"size:20;not null;index:idx_vs_object_snapshot,priority:3"` // "checkpoint" or "diff"
Data NullableDBText `gorm:""` // full JSON snapshot or reverse JSON Patch
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
}
VersionSnapshot stores the data needed for rollback. Each snapshot is either a full JSON checkpoint or a reverse JSON Patch diff (RFC 6902). Checkpoints are stored every 10th version; all others are diffs. Snapshots have their own retention policy and can be pruned independently of audit entries. SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: persisted checkpoint or reverse-diff snapshot used to roll back an object to a prior version
func (*VersionSnapshot) BeforeCreate ¶
func (v *VersionSnapshot) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: auto-assign a UUID to a VersionSnapshot before it is inserted into the DB (pure)
func (VersionSnapshot) TableName ¶
func (VersionSnapshot) TableName() string
TableName specifies the table name for VersionSnapshot SEM@626c102e7b7f7ceffb64d01a6c51f618862c5f31: return the database table name for VersionSnapshot (pure)
type WebhookQuota ¶
type WebhookQuota struct {
OwnerID DBVarchar `gorm:"primaryKey;not null;size:36"`
MaxSubscriptions int `gorm:"default:10"`
MaxEventsPerMinute int `gorm:"default:12"`
MaxSubscriptionRequestsPerMinute int `gorm:"default:10"`
MaxSubscriptionRequestsPerDay int `gorm:"default:20"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
// Relationships
Owner User `gorm:"foreignKey:OwnerID;references:InternalUUID"`
}
WebhookQuota represents per-user webhook quotas Note: Explicit column tags removed for Oracle compatibility SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: DB model for per-user webhook subscription and delivery rate limits
func (WebhookQuota) TableName ¶
func (WebhookQuota) TableName() string
TableName specifies the table name for WebhookQuota SEM@7d6e24510cb080b00d72322263caafc04d1d57dc: return the dialect-aware DB table name for WebhookQuota (pure)
type WebhookSubscription ¶
type WebhookSubscription struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
OwnerInternalUUID DBVarchar `gorm:"size:36;not null;index"`
ThreatModelID NullableDBVarchar `gorm:"size:36;index"`
Name DBVarchar `gorm:"size:256;not null"`
URL DBText `gorm:"not null"`
Events StringArray `gorm:"not null"`
Secret NullableDBVarchar `gorm:"size:128"`
Status DBVarchar `gorm:"size:128;default:pending_verification"`
Challenge NullableDBVarchar `gorm:"size:1000"`
ChallengesSent int `gorm:"default:0"`
TimeoutCount int `gorm:"default:0"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
LastSuccessfulUse *time.Time
PublicationFailures int `gorm:"default:0"`
// OperatorPinned marks the subscription as materialized from operator
// config (alerting block, #395). Pinned rows cannot be modified or
// deleted through /admin/webhooks and their URL is redacted in reads.
// DBBool is required for Oracle compatibility (NUMBER(1) column).
OperatorPinned DBBool `gorm:"not null;default:false" json:"operator_pinned"`
// Relationships
Owner User `gorm:"foreignKey:OwnerInternalUUID;references:InternalUUID"`
ThreatModel *ThreatModel `gorm:"foreignKey:ThreatModelID"`
}
WebhookSubscription represents a webhook subscription Note: Explicit column tags removed for Oracle compatibility SEM@c0d6404284f25e45cfa9076be2c6375c2f93913e: DB model for a webhook subscription with delivery tracking and operator-pin support
func (*WebhookSubscription) BeforeCreate ¶
func (w *WebhookSubscription) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign a UUID to WebhookSubscription if unset before DB insert (mutates shared state)
func (*WebhookSubscription) BeforeSave ¶
func (w *WebhookSubscription) BeforeSave(tx *gorm.DB) error
BeforeSave validates WebhookSubscription before create or update SEM@d48970168f241f7cb359d0cfdb00f3e26abb59da: validate webhook subscription status enum when non-empty before DB write (pure)
func (WebhookSubscription) TableName ¶
func (WebhookSubscription) TableName() string
TableName specifies the table name for WebhookSubscription SEM@7d6e24510cb080b00d72322263caafc04d1d57dc: return the dialect-aware DB table name for WebhookSubscription (pure)
type WebhookURLDenyList ¶
type WebhookURLDenyList struct {
ID DBVarchar `gorm:"primaryKey;not null;size:36"`
Pattern DBVarchar `gorm:"size:256;not null;uniqueIndex:idx_webhook_deny_pattern"`
PatternType DBVarchar `gorm:"size:64;not null"`
Description NullableDBText `gorm:""`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
}
WebhookURLDenyList represents URL patterns blocked for webhooks Note: Explicit column tags removed for Oracle compatibility SEM@db6c3b75a42a48dd122e5984e9efdf0e6e15ca9d: DB model for URL patterns that are blocked from webhook delivery targets
func (*WebhookURLDenyList) BeforeCreate ¶
func (w *WebhookURLDenyList) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set SEM@e530c9655ae71e6bf78a13b97320afcbd9b1e7b5: assign a UUID to WebhookURLDenyList entry if unset before DB insert (mutates shared state)
func (*WebhookURLDenyList) BeforeSave ¶
func (w *WebhookURLDenyList) BeforeSave(tx *gorm.DB) error
BeforeSave validates WebhookURLDenyList before create or update SEM@d48970168f241f7cb359d0cfdb00f3e26abb59da: validate webhook deny-list entry pattern type before DB write (pure)
func (WebhookURLDenyList) TableName ¶
func (WebhookURLDenyList) TableName() string
TableName specifies the table name for WebhookURLDenyList SEM@7d6e24510cb080b00d72322263caafc04d1d57dc: return the dialect-aware DB table name for WebhookURLDenyList (pure)