sqlite

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AttributionStatusAvailable               = "available"
	AttributionStatusParticipantTitleMissing = "participant_matched_title_missing"
	AttributionStatusSpeakerUnmatched        = "speaker_unmatched"
	AttributionStatusSpeakerAmbiguous        = "speaker_ambiguous"
	AttributionSourceCallParties             = "call_parties"
	AttributionSourceGongParty               = "gong_party"
	AttributionSourceUnmatched               = "unmatched"
	AttributionConfidenceExactSpeakerID      = "exact_speaker_id"
	AttributionConfidenceAmbiguous           = "ambiguous"
	AttributionConfidenceUnmatched           = "unmatched"
	// SpeakerRole values are the safe, low-cardinality buyer-vs-rep
	// signal the gap-followup slice surfaces alongside speaker
	// attribution. Roles are derived from the cached Gong party
	// `affiliation` field (Internal / External). When the party data
	// does not give us an answer we emit `unknown` plus a status that
	// names the reason so callers preserve the uncertainty.
	SpeakerRoleInternal                 = "internal"
	SpeakerRoleExternal                 = "external"
	SpeakerRoleUnknown                  = "unknown"
	SpeakerRoleStatusAvailable          = "available"
	SpeakerRoleStatusAffiliationMissing = "affiliation_missing"
	SpeakerRoleStatusSpeakerUnmatched   = "speaker_unmatched"
	SpeakerRoleStatusSpeakerAmbiguous   = "speaker_ambiguous"
)

Phase B-1 read-time speaker attribution status/source/confidence values. These constants are part of the documented MCP contract for evidence.call_drilldown; downstream callers compare on the literal strings, so do not rename without updating the facade contract.

View Source
const (
	LifecycleSourceAuto    = "auto"
	LifecycleSourceBuiltin = "builtin"
	LifecycleSourceProfile = "profile"
)

Variables

View Source
var LossReasonFieldNames = []string{
	"LossReason",
	"Loss_Reason__c",
	"Closed_Lost_Reason__c",
	"Closed_Lost_Reason_Detail__c",
	"Lost_Reason__c",
	"Reason_Lost__c",
	"OpportunityLossReason",
	"lossReason",
	"loss_reason",
}

LossReasonFieldNames is the deterministic list of Opportunity field names that may carry a free-text loss reason for the call's primary opportunity. The ordering reflects priority when multiple are populated. The list is the single source of truth shared by the SQLite dimension SQL, the Postgres gongmcp_business_analysis_loss_reason_bucket function, and the Postgres read-model has_loss_reason flag — extending this slice automatically extends loss-reason source coverage on both backends.

Functions

func LossReasonBucketWhenClauses added in v0.4.0

func LossReasonBucketWhenClauses(normAlias string) string

LossReasonBucketWhenClauses returns the WHEN/THEN lines that map a normalized (lower-cased, punctuation-collapsed, leading/trailing space-padded) loss-reason text aliased as `normAlias` to the deterministic loss-reason buckets in priority order. The clauses are emitted in the same priority order as NormalizeLossReasonBucket so the SQL CASE result and the Go normalization remain in lockstep.

The caller is responsible for the surrounding `CASE` and the empty/raw branches; this helper only emits the bucket WHEN clauses so it can be reused by both the SQLite scalar-subquery shape and the Postgres CREATE FUNCTION shape.

func NormalizeCallFactsGroupBy

func NormalizeCallFactsGroupBy(groupBy string) (string, error)

func NormalizeLossReasonBucket added in v0.4.0

func NormalizeLossReasonBucket(raw string) string

NormalizeLossReasonBucket maps a raw CRM loss-reason string to one of the deterministic normalized buckets surfaced by the loss_reason dimension. Blank input returns an empty string so the dimension's existing <blank> coverage row is preserved. Non-empty input that does not match any bucket rule returns "unknown_other" so MCP callers can distinguish "no loss reason recorded" from "loss reason recorded but unrecognized phrasing".

func NormalizeScorecardActivityGroupBy added in v0.3.3

func NormalizeScorecardActivityGroupBy(groupBy string) (string, error)

func NormalizeStableCallRef added in v0.4.0

func NormalizeStableCallRef(ref string) (string, error)

func StableCallRef added in v0.4.0

func StableCallRef(callID string) string

func StableCallRefMatchesCallID added in v0.4.0

func StableCallRefMatchesCallID(normalizedRef, callID string) bool

Types

type AIHighlightListParams added in v0.4.0

type AIHighlightListParams struct {
	CallIDs []string
	Limit   int
}

AIHighlightListParams is the bounded input contract for listing typed Gong AI highlights. CallIDs contains already-resolved raw call IDs and is capped by the caller; Limit is honored as an upper bound on returned rows.

type AIHighlightRow added in v0.4.0

type AIHighlightRow struct {
	CallID         string `json:"call_id"`
	CallRef        string `json:"call_ref,omitempty"`
	HighlightIndex int    `json:"highlight_index"`
	HighlightType  string `json:"highlight_type"`
	HighlightText  string `json:"highlight_text"`
	SourcePath     string `json:"source_path,omitempty"`
	UpdatedAt      string `json:"updated_at,omitempty"`
}

AIHighlightRow is one redacted, typed Gong AI highlight row. The Postgres call_ai_highlights read model writes only these typed columns; raw highlight JSON is intentionally not exposed.

type AttributionCoverage

type AttributionCoverage struct {
	CallsWithTitles       int64  `json:"calls_with_titles"`
	CallsWithParties      int64  `json:"calls_with_parties"`
	CallsWithPartyTitles  int64  `json:"calls_with_party_titles"`
	UsersWithTitles       int64  `json:"users_with_titles"`
	AccountNameCalls      int64  `json:"account_name_calls"`
	AccountIndustryCalls  int64  `json:"account_industry_calls"`
	OpportunityStageCalls int64  `json:"opportunity_stage_calls"`
	ContactObjectCalls    int64  `json:"contact_object_calls"`
	LeadObjectCalls       int64  `json:"lead_object_calls"`
	ObjectsWithNames      int64  `json:"objects_with_names"`
	ParticipantStatus     string `json:"participant_status"`
	PersonTitleStatus     string `json:"person_title_status"`
	RecommendedNextAction string `json:"recommended_next_action,omitempty"`
}

type BusinessAnalysisCallRow added in v0.3.2

type BusinessAnalysisCallRow struct {
	CallID               string `json:"call_id,omitempty"`
	Title                string `json:"title,omitempty"`
	StartedAt            string `json:"started_at,omitempty"`
	CallDate             string `json:"call_date,omitempty"`
	CallMonth            string `json:"call_month,omitempty"`
	DurationSeconds      int64  `json:"duration_seconds,omitempty"`
	LifecycleBucket      string `json:"lifecycle_bucket,omitempty"`
	LikelyVoicemailOrIVR bool   `json:"likely_voicemail_or_ivr,omitempty"`
	Scope                string `json:"scope,omitempty"`
	System               string `json:"system,omitempty"`
	Direction            string `json:"direction,omitempty"`
	TranscriptStatus     string `json:"transcript_status,omitempty"`
	AccountIndustry      string `json:"account_industry,omitempty"`
	OpportunityStage     string `json:"opportunity_stage,omitempty"`
	OpportunityType      string `json:"opportunity_type,omitempty"`
	ForecastCategory     string `json:"forecast_category,omitempty"`
	OpportunityCount     int64  `json:"opportunity_count,omitempty"`
	AccountCount         int64  `json:"account_count,omitempty"`
	ParticipantStatus    string `json:"participant_status,omitempty"`
	PersonTitleStatus    string `json:"person_title_status,omitempty"`
	PersonTitleSource    string `json:"person_title_source,omitempty"`
}

type BusinessAnalysisCallSearchParams added in v0.3.2

type BusinessAnalysisCallSearchParams struct {
	Filter BusinessAnalysisFilter
	Limit  int
}

type BusinessAnalysisCallSearchResult added in v0.3.2

type BusinessAnalysisCallSearchResult struct {
	Filter  BusinessAnalysisFilter        `json:"filter"`
	Summary BusinessAnalysisCohortSummary `json:"summary"`
	Rows    []BusinessAnalysisCallRow     `json:"rows"`
}

type BusinessAnalysisCohortSummary added in v0.3.2

type BusinessAnalysisCohortSummary struct {
	CallCount                 int64   `json:"call_count"`
	TranscriptCount           int64   `json:"transcript_count"`
	MissingTranscriptCount    int64   `json:"missing_transcript_count"`
	TranscriptCoverageRate    float64 `json:"transcript_coverage_rate"`
	AccountIndustryCount      int64   `json:"account_industry_count"`
	OpportunityStageCount     int64   `json:"opportunity_stage_count"`
	OpportunityCallCount      int64   `json:"opportunity_call_count"`
	AccountCallCount          int64   `json:"account_call_count"`
	ExternalCallCount         int64   `json:"external_call_count"`
	ParticipantCallCount      int64   `json:"participant_call_count"`
	ParticipantTitleCallCount int64   `json:"participant_title_call_count"`
	ParticipantTitleRate      float64 `json:"participant_title_rate"`
	EarliestCallAt            string  `json:"earliest_call_at,omitempty"`
	LatestCallAt              string  `json:"latest_call_at,omitempty"`
	TotalDurationSeconds      int64   `json:"total_duration_seconds"`
	AverageDurationSeconds    float64 `json:"average_duration_seconds"`
	CRMOutcomeCoverageHint    string  `json:"crm_outcome_coverage_hint,omitempty"`
	ParticipantCoverageHint   string  `json:"participant_coverage_hint,omitempty"`
	IndustryCoverageHint      string  `json:"industry_coverage_hint,omitempty"`
	CacheDerivedNotLLMClaims  bool    `json:"cache_derived_not_llm_claims"`
}

type BusinessAnalysisDimensionRow added in v0.3.2

type BusinessAnalysisDimensionRow struct {
	Dimension              string  `json:"dimension"`
	Value                  string  `json:"value"`
	CallCount              int64   `json:"call_count"`
	TranscriptCount        int64   `json:"transcript_count"`
	MissingTranscriptCount int64   `json:"missing_transcript_count"`
	TranscriptCoverageRate float64 `json:"transcript_coverage_rate"`
	OpportunityCallCount   int64   `json:"opportunity_call_count"`
	AccountCallCount       int64   `json:"account_call_count"`
	ExternalCallCount      int64   `json:"external_call_count"`
	LatestCallAt           string  `json:"latest_call_at,omitempty"`
}

type BusinessAnalysisDimensionSummaryParams added in v0.3.2

type BusinessAnalysisDimensionSummaryParams struct {
	Filter     BusinessAnalysisFilter
	Dimension  string
	ThemeQuery string
	Limit      int
}

type BusinessAnalysisEvidenceRow added in v0.3.2

type BusinessAnalysisEvidenceRow struct {
	CallID                 string `json:"call_id,omitempty"`
	Title                  string `json:"title,omitempty"`
	StartedAt              string `json:"started_at,omitempty"`
	CallDate               string `json:"call_date,omitempty"`
	CallMonth              string `json:"call_month,omitempty"`
	LifecycleBucket        string `json:"lifecycle_bucket,omitempty"`
	LikelyVoicemailOrIVR   bool   `json:"likely_voicemail_or_ivr,omitempty"`
	AccountIndustry        string `json:"account_industry,omitempty"`
	AccountName            string `json:"account_name,omitempty"`
	OpportunityName        string `json:"opportunity_name,omitempty"`
	OpportunityStage       string `json:"opportunity_stage,omitempty"`
	OpportunityType        string `json:"opportunity_type,omitempty"`
	OpportunityProbability string `json:"opportunity_probability,omitempty"`
	OpportunityCloseDate   string `json:"opportunity_close_date,omitempty"`
	ParticipantStatus      string `json:"participant_status,omitempty"`
	PersonTitleStatus      string `json:"person_title_status,omitempty"`
	PersonTitleSource      string `json:"person_title_source,omitempty"`
	SegmentIndex           int    `json:"segment_index,omitempty"`
	StartMS                int64  `json:"start_ms,omitempty"`
	EndMS                  int64  `json:"end_ms,omitempty"`
	Snippet                string `json:"snippet,omitempty"`
	ContextExcerpt         string `json:"context_excerpt,omitempty"`
	// SpeakerID is the cached transcript-segment speaker key. The SQLite
	// quote-search path populates it from `transcript_segments.speaker_id`
	// so the MCP layer can match the segment against cached Gong party
	// affiliation and emit SpeakerRole/SpeakerRoleStatus on the
	// quote/business-workbench facade. Postgres SECURITY DEFINER functions
	// resolve the safe role/status values in SQL and intentionally do not
	// expose this hidden speaker key through MCP responses.
	SpeakerID         string `json:"-"`
	SpeakerRole       string `json:"-"`
	SpeakerRoleStatus string `json:"-"`
}

type BusinessAnalysisEvidenceSearchParams added in v0.3.2

type BusinessAnalysisEvidenceSearchParams struct {
	Filter BusinessAnalysisFilter
	Query  string
	Limit  int
	// BroadDiscovery enables a seedless evidence sample for broad theme
	// discovery: when true and Query/Filter.Query are blank, the store
	// returns a deterministic, bounded transcript-segment sample within
	// the cohort filter instead of requiring a full-text query. Only
	// discover_themes_in_cohort should set this; all other evidence and
	// quote searches must keep query-required semantics.
	BroadDiscovery bool
}

type BusinessAnalysisFilter added in v0.3.2

type BusinessAnalysisFilter struct {
	TitleQuery              string   `json:"title_query,omitempty"`
	Query                   string   `json:"query,omitempty"`
	FromDate                string   `json:"from_date,omitempty"`
	ToDate                  string   `json:"to_date,omitempty"`
	Quarter                 string   `json:"quarter,omitempty"`
	LifecycleBucket         string   `json:"lifecycle_bucket,omitempty"`
	ExcludeLifecycleBuckets []string `json:"exclude_lifecycle_buckets,omitempty"`
	ExcludeLikelyVoicemail  bool     `json:"exclude_likely_voicemail,omitempty"`
	Scope                   string   `json:"scope,omitempty"`
	System                  string   `json:"system,omitempty"`
	Direction               string   `json:"direction,omitempty"`
	TranscriptStatus        string   `json:"transcript_status,omitempty"`
	Industry                string   `json:"industry,omitempty"`
	AccountQuery            string   `json:"account_query,omitempty"`
	OpportunityStage        string   `json:"opportunity_stage,omitempty"`
	CRMObjectType           string   `json:"crm_object_type,omitempty"`
	CRMObjectID             string   `json:"crm_object_id,omitempty"`
	ParticipantTitleQuery   string   `json:"participant_title_query,omitempty"`
	Limit                   int      `json:"limit,omitempty"`
}

type BusinessConcept

type BusinessConcept struct {
	Kind        string   `json:"kind"`
	Name        string   `json:"name"`
	Label       string   `json:"label,omitempty"`
	Description string   `json:"description,omitempty"`
	Object      string   `json:"object,omitempty"`
	ObjectTypes []string `json:"object_types,omitempty"`
	FieldNames  []string `json:"field_names,omitempty"`
	Aliases     []string `json:"aliases,omitempty"`
}

type BusinessProfile

type BusinessProfile struct {
	ProfileID           int64                `json:"profile_id"`
	Name                string               `json:"name,omitempty"`
	Version             int                  `json:"version"`
	SourcePath          string               `json:"source_path"`
	SourceSHA256        string               `json:"source_sha256"`
	CanonicalSHA256     string               `json:"canonical_sha256"`
	ImportedAt          string               `json:"imported_at"`
	ImportedBy          string               `json:"imported_by"`
	IsActive            bool                 `json:"is_active"`
	LifecycleCore       []string             `json:"lifecycle_core"`
	ObjectConcepts      []BusinessConcept    `json:"object_concepts"`
	FieldConcepts       []BusinessConcept    `json:"field_concepts"`
	LifecycleBuckets    []BusinessConcept    `json:"lifecycle_buckets"`
	MethodologyConcepts []BusinessConcept    `json:"methodology_concepts"`
	Warnings            []profilepkg.Finding `json:"warnings,omitempty"`
	UnavailableConcepts []string             `json:"unavailable_concepts,omitempty"`
}

type CRMFieldPopulationCell

type CRMFieldPopulationCell struct {
	GroupValue     string  `json:"group_value"`
	FieldName      string  `json:"field_name"`
	FieldLabel     string  `json:"field_label"`
	ObjectCount    int64   `json:"object_count"`
	CallCount      int64   `json:"call_count"`
	PopulatedCount int64   `json:"populated_count"`
	PopulationRate float64 `json:"population_rate"`
}

type CRMFieldPopulationMatrix

type CRMFieldPopulationMatrix struct {
	ObjectType   string                   `json:"object_type"`
	GroupByField string                   `json:"group_by_field"`
	Cells        []CRMFieldPopulationCell `json:"cells"`
}

type CRMFieldPopulationMatrixParams

type CRMFieldPopulationMatrixParams struct {
	ObjectType   string
	GroupByField string
	Limit        int
}

type CRMFieldSummary

type CRMFieldSummary struct {
	ObjectType         string   `json:"object_type"`
	FieldName          string   `json:"field_name"`
	FieldLabel         string   `json:"field_label"`
	RowCount           int64    `json:"row_count"`
	CallCount          int64    `json:"call_count"`
	PopulatedCount     int64    `json:"populated_count"`
	DistinctValueCount int64    `json:"distinct_value_count"`
	ExampleValues      []string `json:"example_values,omitempty"`
}

type CRMFieldValueMatch

type CRMFieldValueMatch struct {
	CallID       string `json:"call_id"`
	Title        string `json:"title"`
	StartedAt    string `json:"started_at"`
	ObjectType   string `json:"object_type"`
	ObjectID     string `json:"object_id,omitempty"`
	ObjectName   string `json:"object_name,omitempty"`
	FieldName    string `json:"field_name"`
	FieldLabel   string `json:"field_label"`
	ValueSnippet string `json:"value_snippet,omitempty"`
}

type CRMFieldValueSearchParams

type CRMFieldValueSearchParams struct {
	ObjectType          string
	FieldName           string
	ValueQuery          string
	Limit               int
	IncludeValueSnippet bool
	IncludeCallIDs      bool
}

type CRMIntegrationRecord

type CRMIntegrationRecord struct {
	IntegrationID string `json:"integration_id"`
	Name          string `json:"name,omitempty"`
	Provider      string `json:"provider,omitempty"`
	UpdatedAt     string `json:"updated_at,omitempty"`
}

type CRMObjectTypeSummary

type CRMObjectTypeSummary struct {
	ObjectType            string `json:"object_type"`
	ObjectCount           int64  `json:"object_count"`
	CallCount             int64  `json:"call_count"`
	FieldCount            int64  `json:"field_count"`
	PopulatedFieldCount   int64  `json:"populated_field_count"`
	DistinctObjectIDCount int64  `json:"distinct_object_id_count"`
}

type CRMSchemaFieldListParams

type CRMSchemaFieldListParams struct {
	IntegrationID string
	ObjectType    string
	Limit         int
}

type CRMSchemaFieldRecord

type CRMSchemaFieldRecord struct {
	IntegrationID string `json:"integration_id"`
	ObjectType    string `json:"object_type"`
	FieldName     string `json:"field_name"`
	FieldLabel    string `json:"field_label,omitempty"`
	FieldType     string `json:"field_type,omitempty"`
	UpdatedAt     string `json:"updated_at,omitempty"`
}

type CRMSchemaObjectRecord

type CRMSchemaObjectRecord struct {
	IntegrationID string `json:"integration_id"`
	ObjectType    string `json:"object_type"`
	DisplayName   string `json:"display_name,omitempty"`
	FieldCount    int64  `json:"field_count"`
	UpdatedAt     string `json:"updated_at,omitempty"`
}

type CacheInventory

type CacheInventory struct {
	TableCounts         []CacheTableCount  `json:"table_counts"`
	OldestCallStartedAt string             `json:"oldest_call_started_at,omitempty"`
	NewestCallStartedAt string             `json:"newest_call_started_at,omitempty"`
	Summary             *SyncStatusSummary `json:"summary"`
}

type CachePurgePlan

type CachePurgePlan struct {
	StartedBefore                 string `json:"started_before"`
	CallCount                     int64  `json:"call_count"`
	TranscriptCount               int64  `json:"transcript_count"`
	TranscriptSegmentCount        int64  `json:"transcript_segment_count"`
	ContextObjectCount            int64  `json:"context_object_count"`
	ContextFieldCount             int64  `json:"context_field_count"`
	CallFactCount                 int64  `json:"call_fact_count,omitempty"`
	ReadModelDiagnosticCount      int64  `json:"read_model_diagnostic_count,omitempty"`
	ProfileCallFactCount          int64  `json:"profile_call_fact_count"`
	ScorecardActivityCount        int64  `json:"scorecard_activity_count,omitempty"`
	GovernanceSuppressedCallCount int64  `json:"governance_suppressed_call_count,omitempty"`
}

type CacheTableCount

type CacheTableCount struct {
	Table string `json:"table"`
	Rows  int64  `json:"rows"`
}

type CallDetail

type CallDetail struct {
	CallID              string                `json:"call_id"`
	CallRef             string                `json:"call_ref,omitempty"`
	Title               string                `json:"title"`
	StartedAt           string                `json:"started_at"`
	DurationSeconds     int64                 `json:"duration_seconds"`
	PartiesCount        int64                 `json:"parties_count"`
	CRMObjects          []CallDetailCRMObject `json:"crm_objects,omitempty"`
	CRMObjectsTruncated bool                  `json:"crm_objects_truncated,omitempty"`
}

type CallDetailCRMObject

type CallDetailCRMObject struct {
	ObjectType          string   `json:"object_type"`
	ObjectID            string   `json:"object_id"`
	ObjectName          string   `json:"object_name,omitempty"`
	FieldCount          int64    `json:"field_count"`
	PopulatedFieldCount int64    `json:"populated_field_count"`
	FieldNames          []string `json:"field_names,omitempty"`
	FieldNamesTruncated bool     `json:"field_names_truncated,omitempty"`
}

type CallDrilldownEvidenceParams added in v0.4.0

type CallDrilldownEvidenceParams struct {
	CallID string
	Query  string
	Limit  int
}

CallDrilldownEvidenceParams is the bounded input contract for the exact call-scoped transcript evidence path used by evidence.call_drilldown. Query is optional; when blank, the operation returns no transcript rows so callers receive only AI condensed evidence and can decide whether to ask for a theme.

type CallDrilldownEvidenceRow added in v0.4.0

type CallDrilldownEvidenceRow struct {
	CallID                string `json:"-"`
	SegmentIndex          int    `json:"segment_index"`
	SpeakerID             string `json:"speaker_id,omitempty"`
	StartMS               int64  `json:"start_ms"`
	EndMS                 int64  `json:"end_ms"`
	Snippet               string `json:"snippet,omitempty"`
	ContextExcerpt        string `json:"context_excerpt,omitempty"`
	PersonTitleStatus     string `json:"-"`
	PersonTitleSource     string `json:"-"`
	AttributionSource     string `json:"-"`
	AttributionConfidence string `json:"-"`
	PersonTitle           string `json:"-"`
	// SpeakerRole is the buyer-vs-rep signal derived from cached Gong
	// party `affiliation` data: SpeakerRoleInternal / SpeakerRoleExternal /
	// SpeakerRoleUnknown. SpeakerRoleStatus names *why* a role is unknown
	// so the facade layer can preserve uncertainty rather than guessing.
	SpeakerRole       string `json:"-"`
	SpeakerRoleStatus string `json:"-"`
}

CallDrilldownEvidenceRow is one bounded transcript excerpt scoped to a specific call. The shape stays minimal: the call-drilldown facade joins account/opportunity coverage from the call detail rather than denormalizing it onto every excerpt.

The attribution-related fields (PersonTitleStatus, PersonTitleSource, AttributionSource, AttributionConfidence, PersonTitle) describe how the row's speaker_id was matched against Gong-party metadata in the cache. Phase B-1 supports exact Gong-party-id matching only; CRM Contact/Lead attribution is explicitly future work and the row never carries inferred titles or persona buckets.

type CallFactsAttributionSignals added in v0.4.0

type CallFactsAttributionSignals struct {
	AccountIndustryCallCount     int64 `json:"account_industry_call_count"`
	OpportunityStageCallCount    int64 `json:"opportunity_stage_call_count"`
	LifecycleClassifiedCallCount int64 `json:"lifecycle_classified_call_count"`
	OpportunityCallCount         int64 `json:"opportunity_call_count"`
	AccountCallCount             int64 `json:"account_call_count"`
	HasAnyAttributionSignal      bool  `json:"has_any_attribution_signal"`
}

CallFactsAttributionSignals reports the call_facts-derived attribution signals that business analysis tools actually rely on (lifecycle, industry, opportunity stage). The Postgres redacted serving DB may have zero rows in the CRM integration inventory tables (`crm_integrations`, `crm_schema_fields`) and zero rows in the `call_context_fields` view while the curated `call_facts` table is fully populated; readiness reporting must derive attribution coverage from these signals instead of from CRM integration inventory counts. The signals are computed from the readonly-grantable `call_facts` columns (`account_industry`, `opportunity_stage`, `lifecycle_bucket`) so the same query shape works for both the SQLite call_facts view and the Postgres call_facts table under EnforceAllowedColumnBoundary.

type CallFactsCoverage

type CallFactsCoverage struct {
	TotalCalls             int64   `json:"total_calls"`
	TranscriptCount        int64   `json:"transcript_count"`
	MissingTranscriptCount int64   `json:"missing_transcript_count"`
	TranscriptCoverageRate float64 `json:"transcript_coverage_rate"`
	OpportunityCallCount   int64   `json:"opportunity_call_count"`
	AccountCallCount       int64   `json:"account_call_count"`
	ExternalCallCount      int64   `json:"external_call_count"`
	InternalCallCount      int64   `json:"internal_call_count"`
	UnknownScopeCallCount  int64   `json:"unknown_scope_call_count"`
	PurposePopulatedCalls  int64   `json:"purpose_populated_calls"`
	CalendarCallCount      int64   `json:"calendar_call_count"`
	TotalDurationSeconds   int64   `json:"total_duration_seconds"`
}

type CallFactsSummaryParams

type CallFactsSummaryParams struct {
	GroupBy          string
	LifecycleBucket  string
	Scope            string
	System           string
	Direction        string
	TranscriptStatus string
	Limit            int
	LifecycleSource  string
}

type CallFactsSummaryRow

type CallFactsSummaryRow struct {
	GroupBy                string  `json:"group_by"`
	GroupValue             string  `json:"group_value"`
	CallCount              int64   `json:"call_count"`
	TranscriptCount        int64   `json:"transcript_count"`
	MissingTranscriptCount int64   `json:"missing_transcript_count"`
	TranscriptCoverageRate float64 `json:"transcript_coverage_rate"`
	OpportunityCallCount   int64   `json:"opportunity_call_count"`
	AccountCallCount       int64   `json:"account_call_count"`
	ExternalCallCount      int64   `json:"external_call_count"`
	InternalCallCount      int64   `json:"internal_call_count"`
	UnknownScopeCallCount  int64   `json:"unknown_scope_call_count"`
	TotalDurationSeconds   int64   `json:"total_duration_seconds"`
	AvgDurationSeconds     float64 `json:"avg_duration_seconds"`
	LatestCallAt           string  `json:"latest_call_at"`
}

type CallRecord

type CallRecord struct {
	CallID          string
	Title           string
	StartedAt       string
	DurationSeconds int64
	PartiesCount    int64
	ContextPresent  bool
	RawJSON         []byte
	RawSHA256       string
	FirstSeenAt     string
	UpdatedAt       string
}

type CallSearchParams

type CallSearchParams struct {
	CRMObjectType    string
	CRMObjectID      string
	FromDate         string
	ToDate           string
	LifecycleBucket  string
	Scope            string
	System           string
	Direction        string
	TranscriptStatus string
	Limit            int
}

type ContextCounts

type ContextCounts struct {
	Objects int
	Fields  int
}

type FinishSyncRunParams

type FinishSyncRunParams struct {
	Status         string
	Cursor         string
	RecordsSeen    int64
	RecordsWritten int64
	ErrorText      string
	RequestContext string
}

type GongSettingListParams

type GongSettingListParams struct {
	Kind  string
	Limit int
}

type GongSettingRecord

type GongSettingRecord struct {
	Kind      string `json:"kind"`
	ObjectID  string `json:"object_id"`
	Name      string `json:"name,omitempty"`
	Active    bool   `json:"active"`
	UpdatedAt string `json:"updated_at,omitempty"`
}

type GovernanceFilteredExportPlan added in v0.3.0

type GovernanceFilteredExportPlan struct {
	SourceDBPath                  string `json:"source_db_path"`
	OutputDBPath                  string `json:"output_db_path"`
	SuppressedCallCount           int    `json:"suppressed_call_count"`
	DeletedCalls                  int64  `json:"deleted_calls"`
	DeletedTranscripts            int64  `json:"deleted_transcripts"`
	DeletedTranscriptSegments     int64  `json:"deleted_transcript_segments"`
	DeletedContextObjects         int64  `json:"deleted_context_objects"`
	DeletedContextFields          int64  `json:"deleted_context_fields"`
	DeletedProfileCallFactRows    int64  `json:"deleted_profile_call_fact_rows"`
	DeletedScorecardActivityRows  int64  `json:"deleted_scorecard_activity_rows"`
	DeletedGovernanceIngestRows   int64  `json:"deleted_governance_ingest_rows"`
	RemainingSuppressedCandidates int64  `json:"remaining_suppressed_candidates"`
}

func ExportGovernanceFilteredDB added in v0.3.0

func ExportGovernanceFilteredDB(ctx context.Context, sourcePath, outputPath string, suppressedCallIDs []string, overwrite bool) (*GovernanceFilteredExportPlan, error)

type GovernanceIngestSkippedCallParams added in v0.4.0

type GovernanceIngestSkippedCallParams struct {
	CallID         string
	ConfigSHA256   string
	MatchedList    string
	SourceCategory string
	RunID          int64
}

type LateStageSignal

type LateStageSignal struct {
	FieldName             string  `json:"field_name"`
	FieldLabel            string  `json:"field_label"`
	LatePopulatedCalls    int64   `json:"late_populated_calls"`
	NonLatePopulatedCalls int64   `json:"non_late_populated_calls"`
	LateRate              float64 `json:"late_rate"`
	NonLateRate           float64 `json:"non_late_rate"`
	Lift                  float64 `json:"lift"`
}

type LateStageSignalParams

type LateStageSignalParams struct {
	ObjectType          string
	StageField          string
	LateStageValues     []string
	IncludeStageProxies bool
	Limit               int
}

type LateStageSignalsReport

type LateStageSignalsReport struct {
	ObjectType      string            `json:"object_type"`
	StageField      string            `json:"stage_field"`
	LateStageValues []string          `json:"late_stage_values"`
	TotalCalls      int64             `json:"total_calls"`
	LateCalls       int64             `json:"late_calls"`
	NonLateCalls    int64             `json:"non_late_calls"`
	StageCounts     map[string]int64  `json:"stage_counts"`
	Signals         []LateStageSignal `json:"signals"`
}

type LifecycleBucketDefinition

type LifecycleBucketDefinition struct {
	Bucket         string   `json:"bucket"`
	Label          string   `json:"label"`
	Description    string   `json:"description"`
	PrimarySignals []string `json:"primary_signals"`
}

type LifecycleBucketSummary

type LifecycleBucketSummary struct {
	Bucket                 string `json:"bucket"`
	CallCount              int64  `json:"call_count"`
	TranscriptCount        int64  `json:"transcript_count"`
	MissingTranscriptCount int64  `json:"missing_transcript_count"`
	OpportunityCallCount   int64  `json:"opportunity_call_count"`
	AccountCallCount       int64  `json:"account_call_count"`
	TotalDurationSeconds   int64  `json:"total_duration_seconds"`
	LatestCallID           string `json:"latest_call_id"`
	LatestCallAt           string `json:"latest_call_at"`
	HighConfidenceCalls    int64  `json:"high_confidence_calls"`
	MediumConfidenceCalls  int64  `json:"medium_confidence_calls"`
	LowConfidenceCalls     int64  `json:"low_confidence_calls"`
}

type LifecycleCRMFieldComparison

type LifecycleCRMFieldComparison struct {
	BucketA    string                           `json:"bucket_a"`
	BucketB    string                           `json:"bucket_b"`
	ObjectType string                           `json:"object_type,omitempty"`
	Fields     []LifecycleCRMFieldComparisonRow `json:"fields"`
}

type LifecycleCRMFieldComparisonParams

type LifecycleCRMFieldComparisonParams struct {
	BucketA    string
	BucketB    string
	ObjectType string
	Limit      int
}

type LifecycleCRMFieldComparisonRow

type LifecycleCRMFieldComparisonRow struct {
	ObjectType       string  `json:"object_type"`
	FieldName        string  `json:"field_name"`
	FieldLabel       string  `json:"field_label"`
	BucketACallCount int64   `json:"bucket_a_call_count"`
	BucketBCallCount int64   `json:"bucket_b_call_count"`
	BucketAPopulated int64   `json:"bucket_a_populated"`
	BucketBPopulated int64   `json:"bucket_b_populated"`
	BucketARate      float64 `json:"bucket_a_rate"`
	BucketBRate      float64 `json:"bucket_b_rate"`
	RateDelta        float64 `json:"rate_delta"`
}

type LifecycleCallSearchParams

type LifecycleCallSearchParams struct {
	Bucket                 string
	MissingTranscriptsOnly bool
	Limit                  int
	LifecycleSource        string
}

type LifecycleCallSearchResult

type LifecycleCallSearchResult struct {
	CallID            string   `json:"call_id"`
	Title             string   `json:"title"`
	StartedAt         string   `json:"started_at"`
	DurationSeconds   int64    `json:"duration_seconds"`
	Bucket            string   `json:"bucket"`
	Confidence        string   `json:"confidence"`
	Reason            string   `json:"reason"`
	EvidenceFields    []string `json:"evidence_fields,omitempty"`
	OpportunityCount  int64    `json:"opportunity_count"`
	AccountCount      int64    `json:"account_count"`
	TranscriptPresent bool     `json:"transcript_present"`
}

type LifecycleSummaryParams

type LifecycleSummaryParams struct {
	Bucket          string
	LifecycleSource string
}

type LifecycleTranscriptPriority

type LifecycleTranscriptPriority struct {
	CallID          string   `json:"call_id"`
	Title           string   `json:"title"`
	StartedAt       string   `json:"started_at"`
	DurationSeconds int64    `json:"duration_seconds"`
	System          string   `json:"system,omitempty"`
	Direction       string   `json:"direction,omitempty"`
	Scope           string   `json:"scope,omitempty"`
	Bucket          string   `json:"bucket"`
	Confidence      string   `json:"confidence"`
	PriorityScore   int64    `json:"priority_score"`
	Reason          string   `json:"reason"`
	EvidenceFields  []string `json:"evidence_fields,omitempty"`
}

type LifecycleTranscriptPriorityParams

type LifecycleTranscriptPriorityParams struct {
	Bucket          string
	FromDate        string
	ToDate          string
	Scope           string
	System          string
	Direction       string
	Limit           int
	LifecycleSource string
}

type MissingTranscriptCall

type MissingTranscriptCall struct {
	CallID    string
	Title     string
	StartedAt string
}

type MissingTranscriptSearchParams added in v0.3.3

type MissingTranscriptSearchParams struct {
	FromDate        string
	ToDate          string
	LifecycleBucket string
	Scope           string
	System          string
	Direction       string
	CRMObjectType   string
	CRMObjectID     string
	Limit           int
}

type OpportunityCallSummary

type OpportunityCallSummary struct {
	OpportunityID          string `json:"opportunity_id"`
	OpportunityName        string `json:"opportunity_name"`
	Stage                  string `json:"stage,omitempty"`
	Amount                 string `json:"amount,omitempty"`
	CloseDate              string `json:"close_date,omitempty"`
	OwnerID                string `json:"owner_id,omitempty"`
	CallCount              int64  `json:"call_count"`
	TranscriptCount        int64  `json:"transcript_count"`
	MissingTranscriptCount int64  `json:"missing_transcript_count"`
	TotalDurationSeconds   int64  `json:"total_duration_seconds"`
	LatestCallID           string `json:"latest_call_id"`
	LatestCallAt           string `json:"latest_call_at"`
}

type OpportunityCallSummaryParams

type OpportunityCallSummaryParams struct {
	StageValues []string
	Limit       int
}

type OpportunityMissingTranscriptParams

type OpportunityMissingTranscriptParams struct {
	StageValues []string
	Limit       int
}

type OpportunityMissingTranscriptSummary

type OpportunityMissingTranscriptSummary struct {
	OpportunityID          string `json:"opportunity_id"`
	OpportunityName        string `json:"opportunity_name"`
	Stage                  string `json:"stage,omitempty"`
	CallCount              int64  `json:"call_count"`
	MissingTranscriptCount int64  `json:"missing_transcript_count"`
	TranscriptCount        int64  `json:"transcript_count"`
	LatestCallID           string `json:"latest_call_id"`
	LatestCallAt           string `json:"latest_call_at"`
}

type ProfileHistoryEntry added in v0.3.0

type ProfileHistoryEntry struct {
	ProfileID       int64  `json:"profile_id"`
	Name            string `json:"name,omitempty"`
	Version         int    `json:"version"`
	SourcePath      string `json:"source_path,omitempty"`
	SourceSHA256    string `json:"source_sha256"`
	CanonicalSHA256 string `json:"canonical_sha256"`
	ImportedAt      string `json:"imported_at"`
	ImportedBy      string `json:"imported_by,omitempty"`
	IsActive        bool   `json:"is_active"`
	WarningCount    int64  `json:"warning_count"`
}

type ProfileImportParams

type ProfileImportParams struct {
	SourcePath      string
	SourceSHA256    string
	CanonicalSHA256 string
	RawYAML         []byte
	CanonicalJSON   []byte
	Profile         *profilepkg.Profile
	Findings        []profilepkg.Finding
	ImportedBy      string
	StageOnly       bool
}

type ProfileImportResult

type ProfileImportResult struct {
	ProfileID       int64  `json:"profile_id"`
	Imported        bool   `json:"imported"`
	Activated       bool   `json:"activated"`
	SourceSHA256    string `json:"source_sha256"`
	CanonicalSHA256 string `json:"canonical_sha256"`
}

type ProfileQueryInfo

type ProfileQueryInfo struct {
	LifecycleSource     string           `json:"lifecycle_source"`
	Profile             *BusinessProfile `json:"profile,omitempty"`
	UnavailableConcepts []string         `json:"unavailable_concepts,omitempty"`
}

type ProfileReadiness

type ProfileReadiness struct {
	Active                  bool                      `json:"active"`
	Status                  string                    `json:"status"`
	Detail                  string                    `json:"detail"`
	Name                    string                    `json:"name,omitempty"`
	Version                 int                       `json:"version,omitempty"`
	CanonicalSHA256         string                    `json:"canonical_sha256,omitempty"`
	ObjectConceptCount      int                       `json:"object_concept_count,omitempty"`
	FieldConceptCount       int                       `json:"field_concept_count,omitempty"`
	LifecycleBucketCount    int                       `json:"lifecycle_bucket_count,omitempty"`
	MethodologyConceptCount int                       `json:"methodology_concept_count,omitempty"`
	WarningCount            int                       `json:"warning_count,omitempty"`
	UnavailableConcepts     []string                  `json:"unavailable_concepts,omitempty"`
	CacheFresh              bool                      `json:"cache_fresh"`
	CacheStatus             string                    `json:"cache_status"`
	Blocking                []string                  `json:"blocking,omitempty"`
	Checklist               ProfileReadinessChecklist `json:"checklist"`
}

type ProfileReadinessChecklist added in v0.4.0

type ProfileReadinessChecklist struct {
	// Computed reports whether the checklist could be evaluated against an
	// active, parsed profile. False when no profile is active.
	Computed bool `json:"computed"`
	// CreatedDateOnlyConcepts are field concepts whose only mapped CRM field
	// names look like CreatedDate (or its common aliases). docs/profiles.md
	// flags this as a common-but-incorrect mapping pattern.
	CreatedDateOnlyConcepts []string `json:"created_date_only_concepts,omitempty"`
	// MissingLifecycleBuckets lists the required lifecycle buckets that the
	// active profile does not define rules for.
	MissingLifecycleBuckets []string `json:"missing_lifecycle_buckets,omitempty"`
	// LifecycleRulesMissing is true when every defined lifecycle bucket has
	// zero rules and the cohort therefore cannot be partitioned by the
	// profile.
	LifecycleRulesMissing bool `json:"lifecycle_rules_missing"`
	// MethodologyUnmapped is true when the profile's methodology section is
	// empty. Methodology concepts (pain, next steps, MEDDICC, etc.) are
	// optional, but their absence is worth surfacing as a coverage gap.
	MethodologyUnmapped bool `json:"methodology_unmapped"`
	// LossReasonMappingMissing is true when no field concept references a
	// loss-reason-shaped field; rank_loss_reasons / loss_reason rollups will
	// fall back to the legacy loss_reason_present heuristic.
	LossReasonMappingMissing bool `json:"loss_reason_mapping_missing"`
	// SuspectFindings is a stable, sorted list of human-readable findings
	// suitable for operator surfaces.
	SuspectFindings []string `json:"suspect_findings,omitempty"`
}

ProfileReadinessChecklist surfaces a set of mechanically-checked customer profile readiness flags. The intent is operator-facing: if a discovered YAML imports cleanly but the mappings still look suspect (a concept pointing only at CreatedDate, lifecycle missing the required buckets, methodology unmapped, no loss-reason field), readiness should call those out explicitly so business-analysis answers are not silently shaped by a half-mapped profile. Findings are advisory; they do not block import.

func EvaluateProfileReadinessChecklist added in v0.4.0

func EvaluateProfileReadinessChecklist(p *profilepkg.Profile) ProfileReadinessChecklist

EvaluateProfileReadinessChecklist applies a deterministic set of mechanical checks against the active profile and returns operator-facing findings. The checks are intentionally conservative: they flag mappings that docs/profiles.md calls out as common bad patterns (CreatedDate-only field concepts), missing required lifecycle buckets, lifecycle buckets without rules, missing methodology concepts, and the absence of any loss-reason field mapping. The checklist is advisory; it never blocks profile import.

type PublicReadiness

type PublicReadiness struct {
	ConversationVolume    ReadinessFlag `json:"conversation_volume"`
	TranscriptCoverage    ReadinessFlag `json:"transcript_coverage"`
	ScorecardThemes       ReadinessFlag `json:"scorecard_themes"`
	LifecycleSeparation   ReadinessFlag `json:"lifecycle_separation"`
	CRMSegmentation       ReadinessFlag `json:"crm_segmentation"`
	AttributionReadiness  ReadinessFlag `json:"attribution_readiness"`
	CRMInventoryNote      string        `json:"crm_inventory_note,omitempty"`
	RecommendedNextAction string        `json:"recommended_next_action,omitempty"`
}

func BuildPublicReadiness added in v0.4.0

func BuildPublicReadiness(summary *SyncStatusSummary) PublicReadiness

BuildPublicReadiness exposes the sqlite-internal readiness derivation so the Postgres backend can reuse it instead of inlining a partial copy. gong_status callers expect the same shape regardless of backend; the only per-backend difference is how the underlying counters are populated.

type ReadinessFlag

type ReadinessFlag struct {
	Ready        bool     `json:"ready"`
	Status       string   `json:"status"`
	Detail       string   `json:"detail"`
	Requirements []string `json:"requirements,omitempty"`
}

type ScorecardActivityOverview added in v0.3.3

type ScorecardActivityOverview struct {
	TotalAnsweredScorecards int64                         `json:"total_answered_scorecards"`
	DistinctScorecards      int64                         `json:"distinct_scorecards"`
	DistinctCalls           int64                         `json:"distinct_calls"`
	LinkedCallCount         int64                         `json:"linked_call_count"`
	ReviewedUserCount       int64                         `json:"reviewed_user_count"`
	ManualCount             int64                         `json:"manual_count"`
	AutomaticCount          int64                         `json:"automatic_count"`
	TranscriptCount         int64                         `json:"transcript_count"`
	MissingTranscriptCount  int64                         `json:"missing_transcript_count"`
	AverageOverallScore     float64                       `json:"average_overall_score"`
	AverageAnswerScore      float64                       `json:"average_answer_score"`
	LatestReviewTime        string                        `json:"latest_review_time"`
	ByScorecard             []ScorecardActivitySummaryRow `json:"by_scorecard"`
	ByReviewMethod          []ScorecardActivitySummaryRow `json:"by_review_method"`
	ByLifecycle             []ScorecardActivitySummaryRow `json:"by_lifecycle"`
	ByTranscriptStatus      []ScorecardActivitySummaryRow `json:"by_transcript_status"`
}

type ScorecardActivityRecord added in v0.3.3

type ScorecardActivityRecord struct {
	AnsweredScorecardID string  `json:"answered_scorecard_id"`
	ScorecardID         string  `json:"scorecard_id,omitempty"`
	ScorecardName       string  `json:"scorecard_name,omitempty"`
	CallID              string  `json:"call_id,omitempty"`
	CallStartedAt       string  `json:"call_started_at,omitempty"`
	ReviewedUserID      string  `json:"reviewed_user_id,omitempty"`
	ReviewerUserID      string  `json:"reviewer_user_id,omitempty"`
	EditorUserID        string  `json:"editor_user_id,omitempty"`
	ReviewMethod        string  `json:"review_method,omitempty"`
	ReviewTime          string  `json:"review_time,omitempty"`
	VisibilityType      string  `json:"visibility_type,omitempty"`
	OverallScore        float64 `json:"overall_score,omitempty"`
	AverageScore        float64 `json:"average_score,omitempty"`
	AnswerCount         int64   `json:"answer_count"`
	RawSHA256           string  `json:"raw_sha256,omitempty"`
	UpdatedAt           string  `json:"updated_at,omitempty"`
}

type ScorecardActivitySummaryParams added in v0.3.3

type ScorecardActivitySummaryParams struct {
	GroupBy string
	Limit   int
}

type ScorecardActivitySummaryRow added in v0.3.3

type ScorecardActivitySummaryRow struct {
	GroupBy                string  `json:"group_by"`
	GroupValue             string  `json:"group_value"`
	AnsweredScorecardCount int64   `json:"answered_scorecard_count"`
	DistinctCallCount      int64   `json:"distinct_call_count"`
	LinkedCallCount        int64   `json:"linked_call_count"`
	ReviewedUserCount      int64   `json:"reviewed_user_count"`
	ManualCount            int64   `json:"manual_count"`
	AutomaticCount         int64   `json:"automatic_count"`
	TranscriptCount        int64   `json:"transcript_count"`
	MissingTranscriptCount int64   `json:"missing_transcript_count"`
	AverageOverallScore    float64 `json:"average_overall_score"`
	AverageAnswerScore     float64 `json:"average_answer_score"`
	LatestReviewTime       string  `json:"latest_review_time"`
}

type ScorecardDetail

type ScorecardDetail struct {
	ScorecardSummary
	Questions []ScorecardQuestion `json:"questions"`
}

type ScorecardListParams

type ScorecardListParams struct {
	ActiveOnly bool
	Limit      int
}

type ScorecardQuestion

type ScorecardQuestion struct {
	QuestionID   string   `json:"question_id,omitempty"`
	QuestionText string   `json:"question_text"`
	QuestionType string   `json:"question_type,omitempty"`
	IsOverall    bool     `json:"is_overall,omitempty"`
	MinRange     int64    `json:"min_range,omitempty"`
	MaxRange     int64    `json:"max_range,omitempty"`
	AnswerGuide  string   `json:"answer_guide,omitempty"`
	Options      []string `json:"options,omitempty"`
}

type ScorecardSummary

type ScorecardSummary struct {
	ScorecardID     string `json:"scorecard_id"`
	Name            string `json:"name"`
	Active          bool   `json:"active"`
	ReviewMethod    string `json:"review_method,omitempty"`
	WorkspaceID     string `json:"workspace_id,omitempty"`
	QuestionCount   int64  `json:"question_count"`
	SourceCreatedAt string `json:"source_created_at,omitempty"`
	SourceUpdatedAt string `json:"source_updated_at,omitempty"`
	CachedUpdatedAt string `json:"cached_updated_at,omitempty"`
}

type StartSyncRunParams

type StartSyncRunParams struct {
	Scope          string
	SyncKey        string
	Cursor         string
	From           string
	To             string
	RequestContext string
}

type Store

type Store struct {
	// contains filtered or unexported fields
}

func Open

func Open(ctx context.Context, path string) (*Store, error)

func OpenReadOnly

func OpenReadOnly(ctx context.Context, path string) (*Store, error)

func (*Store) ActivateProfile added in v0.3.0

func (s *Store) ActivateProfile(ctx context.Context, ref string) (*ProfileImportResult, error)

func (*Store) ActiveBusinessProfile

func (s *Store) ActiveBusinessProfile(ctx context.Context) (*BusinessProfile, error)

func (*Store) ActiveProfileDocument

func (s *Store) ActiveProfileDocument(ctx context.Context) (*profilepkg.Profile, error)

func (*Store) AnalyzeLateStageSignals

func (s *Store) AnalyzeLateStageSignals(ctx context.Context, params LateStageSignalParams) (*LateStageSignalsReport, error)

func (*Store) CRMFieldPopulationMatrix

func (s *Store) CRMFieldPopulationMatrix(ctx context.Context, params CRMFieldPopulationMatrixParams) (*CRMFieldPopulationMatrix, error)

func (*Store) CacheInventory

func (s *Store) CacheInventory(ctx context.Context) (*CacheInventory, error)

func (*Store) CallDrilldownEvidence added in v0.4.0

func (s *Store) CallDrilldownEvidence(ctx context.Context, params CallDrilldownEvidenceParams) ([]CallDrilldownEvidenceRow, error)

CallDrilldownEvidence returns bounded transcript excerpts scoped to a single call. Callers must provide an already-resolved CallID; the facade layer is responsible for translating call_ref values and applying suppression and blocklist filters before serialization.

func (*Store) CallFactsCoverage

func (s *Store) CallFactsCoverage(ctx context.Context) (*CallFactsCoverage, error)

func (*Store) CallFactsCoverageWithSource

func (s *Store) CallFactsCoverageWithSource(ctx context.Context, sourceArg string) (*CallFactsCoverage, []CallFactsSummaryRow, *ProfileQueryInfo, error)

func (*Store) CallRawJSON added in v0.4.0

func (s *Store) CallRawJSON(ctx context.Context, callID string) (json.RawMessage, error)

func (*Store) ClearGovernanceIngestSkippedCall added in v0.4.0

func (s *Store) ClearGovernanceIngestSkippedCall(ctx context.Context, callID string) error

func (*Store) Close

func (s *Store) Close() error

func (*Store) CompareLifecycleCRMFields

func (s *Store) CompareLifecycleCRMFields(ctx context.Context, params LifecycleCRMFieldComparisonParams) (*LifecycleCRMFieldComparison, error)

func (*Store) DB

func (s *Store) DB() *sql.DB

func (*Store) DeleteGovernanceIngestCachedCall added in v0.4.0

func (s *Store) DeleteGovernanceIngestCachedCall(ctx context.Context, callID string) error

func (*Store) DeleteGovernanceSuppressedCalls added in v0.3.0

func (s *Store) DeleteGovernanceSuppressedCalls(ctx context.Context, callIDs []string) (*GovernanceFilteredExportPlan, error)

func (*Store) FindCallsMissingTranscripts

func (s *Store) FindCallsMissingTranscripts(ctx context.Context, limit int) ([]MissingTranscriptCall, error)

func (*Store) FindCallsMissingTranscriptsByFilters added in v0.3.3

func (s *Store) FindCallsMissingTranscriptsByFilters(ctx context.Context, params MissingTranscriptSearchParams) ([]MissingTranscriptCall, error)

func (*Store) FinishSyncRun

func (s *Store) FinishSyncRun(ctx context.Context, runID int64, params FinishSyncRunParams) error

func (*Store) GetCallDetail

func (s *Store) GetCallDetail(ctx context.Context, callID string) (*CallDetail, error)

func (*Store) GetCallRaw

func (s *Store) GetCallRaw(ctx context.Context, callID string) (json.RawMessage, error)

func (*Store) GetScorecardDetail

func (s *Store) GetScorecardDetail(ctx context.Context, scorecardID string) (*ScorecardDetail, error)

func (*Store) GovernanceDataFingerprint added in v0.3.0

func (s *Store) GovernanceDataFingerprint(ctx context.Context) (string, error)

func (*Store) GovernanceNameCandidates added in v0.3.0

func (s *Store) GovernanceNameCandidates(ctx context.Context) ([]governance.Candidate, error)

func (*Store) ImportProfile

func (s *Store) ImportProfile(ctx context.Context, params ProfileImportParams) (*ProfileImportResult, error)

func (*Store) ListAIHighlights added in v0.4.0

func (s *Store) ListAIHighlights(_ context.Context, _ AIHighlightListParams) ([]AIHighlightRow, error)

ListAIHighlights returns no rows for the SQLite cache: the typed call_ai_highlights read model only exists in the Postgres serving DB. This stub keeps the Store interface uniform without changing SQLite schema or behavior.

func (*Store) ListBusinessConcepts

func (s *Store) ListBusinessConcepts(ctx context.Context) ([]BusinessConcept, error)

func (*Store) ListCRMFields

func (s *Store) ListCRMFields(ctx context.Context, objectType string, limit int) ([]CRMFieldSummary, error)

func (*Store) ListCRMIntegrations

func (s *Store) ListCRMIntegrations(ctx context.Context) ([]CRMIntegrationRecord, error)

func (*Store) ListCRMObjectTypes

func (s *Store) ListCRMObjectTypes(ctx context.Context) ([]CRMObjectTypeSummary, error)

func (*Store) ListCRMSchemaFields

func (s *Store) ListCRMSchemaFields(ctx context.Context, params CRMSchemaFieldListParams) ([]CRMSchemaFieldRecord, error)

func (*Store) ListCRMSchemaObjects

func (s *Store) ListCRMSchemaObjects(ctx context.Context, integrationID string) ([]CRMSchemaObjectRecord, error)

func (*Store) ListGongSettings

func (s *Store) ListGongSettings(ctx context.Context, params GongSettingListParams) ([]GongSettingRecord, error)

func (*Store) ListLifecycleBucketDefinitions

func (s *Store) ListLifecycleBucketDefinitions(ctx context.Context) ([]LifecycleBucketDefinition, error)

func (*Store) ListLifecycleBucketDefinitionsWithSource

func (s *Store) ListLifecycleBucketDefinitionsWithSource(ctx context.Context, requested string) ([]LifecycleBucketDefinition, *ProfileQueryInfo, error)

func (*Store) ListOpportunitiesMissingTranscripts

func (s *Store) ListOpportunitiesMissingTranscripts(ctx context.Context, params OpportunityMissingTranscriptParams) ([]OpportunityMissingTranscriptSummary, error)

func (*Store) ListProfiles added in v0.3.0

func (s *Store) ListProfiles(ctx context.Context) ([]ProfileHistoryEntry, error)

func (*Store) ListScorecards

func (s *Store) ListScorecards(ctx context.Context, params ScorecardListParams) ([]ScorecardSummary, error)

func (*Store) ListUnmappedCRMFields

func (s *Store) ListUnmappedCRMFields(ctx context.Context, params UnmappedCRMFieldParams) ([]UnmappedCRMField, error)

func (*Store) Migrate

func (s *Store) Migrate(ctx context.Context) error

func (*Store) PlanCachePurgeBefore

func (s *Store) PlanCachePurgeBefore(ctx context.Context, startedBefore string) (*CachePurgePlan, error)

func (*Store) PrioritizeTranscriptsByLifecycle

func (s *Store) PrioritizeTranscriptsByLifecycle(ctx context.Context, params LifecycleTranscriptPriorityParams) ([]LifecycleTranscriptPriority, error)

func (*Store) PrioritizeTranscriptsByLifecycleWithSource

func (s *Store) PrioritizeTranscriptsByLifecycleWithSource(ctx context.Context, params LifecycleTranscriptPriorityParams) ([]LifecycleTranscriptPriority, *ProfileQueryInfo, error)

func (*Store) ProfileDocument added in v0.3.0

func (s *Store) ProfileDocument(ctx context.Context, ref string) (*StoredProfileDocument, error)

func (*Store) ProfileInventory

func (s *Store) ProfileInventory(ctx context.Context) (*profilepkg.Inventory, error)

func (*Store) PurgeCacheBefore

func (s *Store) PurgeCacheBefore(ctx context.Context, startedBefore string) (*CachePurgePlan, error)

func (*Store) RecordGovernanceIngestSkippedCall added in v0.4.0

func (s *Store) RecordGovernanceIngestSkippedCall(ctx context.Context, params GovernanceIngestSkippedCallParams) error

func (*Store) RecordGovernanceIngestSkippedCallAndDeleteCachedCall added in v0.4.0

func (s *Store) RecordGovernanceIngestSkippedCallAndDeleteCachedCall(ctx context.Context, params GovernanceIngestSkippedCallParams) error

func (*Store) RefreshActiveProfileReadModel

func (s *Store) RefreshActiveProfileReadModel(ctx context.Context) error

func (*Store) ResolveCallIDByRef added in v0.4.0

func (s *Store) ResolveCallIDByRef(ctx context.Context, ref string) (string, error)

func (*Store) ResolveLifecycleSource

func (s *Store) ResolveLifecycleSource(ctx context.Context, requested string) (string, *BusinessProfile, error)

func (*Store) ScorecardActivityOverview added in v0.3.3

func (s *Store) ScorecardActivityOverview(ctx context.Context, limit int) (*ScorecardActivityOverview, error)

func (*Store) SearchBusinessAnalysisCalls added in v0.3.2

func (s *Store) SearchBusinessAnalysisCalls(ctx context.Context, params BusinessAnalysisCallSearchParams) (*BusinessAnalysisCallSearchResult, error)

func (*Store) SearchBusinessAnalysisEvidence added in v0.3.2

func (s *Store) SearchBusinessAnalysisEvidence(ctx context.Context, params BusinessAnalysisEvidenceSearchParams) ([]BusinessAnalysisEvidenceRow, error)

func (*Store) SearchCRMFieldValues

func (s *Store) SearchCRMFieldValues(ctx context.Context, params CRMFieldValueSearchParams) ([]CRMFieldValueMatch, error)

func (*Store) SearchCallsByLifecycle

func (s *Store) SearchCallsByLifecycle(ctx context.Context, params LifecycleCallSearchParams) ([]LifecycleCallSearchResult, error)

func (*Store) SearchCallsByLifecycleWithSource

func (s *Store) SearchCallsByLifecycleWithSource(ctx context.Context, params LifecycleCallSearchParams) ([]LifecycleCallSearchResult, *ProfileQueryInfo, error)

func (*Store) SearchCallsRaw

func (s *Store) SearchCallsRaw(ctx context.Context, params CallSearchParams) ([]json.RawMessage, error)

func (*Store) SearchTranscriptQuotesWithAttribution

func (s *Store) SearchTranscriptQuotesWithAttribution(ctx context.Context, params TranscriptAttributionSearchParams) ([]TranscriptAttributionSearchResult, error)

func (*Store) SearchTranscriptSegments

func (s *Store) SearchTranscriptSegments(ctx context.Context, query string, limit int) ([]TranscriptSearchResult, error)

func (*Store) SearchTranscriptSegmentsByCRMContext

func (s *Store) SearchTranscriptSegmentsByCRMContext(ctx context.Context, params TranscriptCRMSearchParams) ([]TranscriptCRMSearchResult, error)

func (*Store) SearchTranscriptSegmentsByCallFacts

func (s *Store) SearchTranscriptSegmentsByCallFacts(ctx context.Context, params TranscriptCallFactsSearchParams) ([]TranscriptCallFactsSearchResult, error)

func (*Store) StartSyncRun

func (s *Store) StartSyncRun(ctx context.Context, params StartSyncRunParams) (*SyncRun, error)

func (*Store) SummarizeBusinessAnalysisDimension added in v0.3.2

func (s *Store) SummarizeBusinessAnalysisDimension(ctx context.Context, params BusinessAnalysisDimensionSummaryParams) ([]BusinessAnalysisDimensionRow, error)

func (*Store) SummarizeCallFacts

func (s *Store) SummarizeCallFacts(ctx context.Context, params CallFactsSummaryParams) ([]CallFactsSummaryRow, error)

func (*Store) SummarizeCallFactsWithSource

func (s *Store) SummarizeCallFactsWithSource(ctx context.Context, params CallFactsSummaryParams) ([]CallFactsSummaryRow, *ProfileQueryInfo, error)

func (*Store) SummarizeCallsByLifecycle

func (s *Store) SummarizeCallsByLifecycle(ctx context.Context, params LifecycleSummaryParams) ([]LifecycleBucketSummary, error)

func (*Store) SummarizeCallsByLifecycleWithSource

func (s *Store) SummarizeCallsByLifecycleWithSource(ctx context.Context, params LifecycleSummaryParams) ([]LifecycleBucketSummary, *ProfileQueryInfo, error)

func (*Store) SummarizeOpportunityCalls

func (s *Store) SummarizeOpportunityCalls(ctx context.Context, params OpportunityCallSummaryParams) ([]OpportunityCallSummary, error)

func (*Store) SummarizeScorecardActivity added in v0.3.3

func (s *Store) SummarizeScorecardActivity(ctx context.Context, params ScorecardActivitySummaryParams) ([]ScorecardActivitySummaryRow, error)

func (*Store) SyncStatusSummary

func (s *Store) SyncStatusSummary(ctx context.Context) (*SyncStatusSummary, error)

func (*Store) UpsertCRMIntegration

func (s *Store) UpsertCRMIntegration(ctx context.Context, raw json.RawMessage) (*CRMIntegrationRecord, error)

func (*Store) UpsertCRMSchema

func (s *Store) UpsertCRMSchema(ctx context.Context, integrationID string, objectType string, raw json.RawMessage) (int64, error)

func (*Store) UpsertCall

func (s *Store) UpsertCall(ctx context.Context, raw json.RawMessage) (*CallRecord, error)

func (*Store) UpsertCallContext

func (s *Store) UpsertCallContext(ctx context.Context, callID string, raw json.RawMessage) (ContextCounts, error)

func (*Store) UpsertGongSetting

func (s *Store) UpsertGongSetting(ctx context.Context, kind string, raw json.RawMessage) (*GongSettingRecord, error)

func (*Store) UpsertScorecardActivity added in v0.3.3

func (s *Store) UpsertScorecardActivity(ctx context.Context, raw json.RawMessage) (*ScorecardActivityRecord, error)

func (*Store) UpsertTranscript

func (s *Store) UpsertTranscript(ctx context.Context, raw json.RawMessage) (*TranscriptRecord, error)

func (*Store) UpsertUser

func (s *Store) UpsertUser(ctx context.Context, raw json.RawMessage) (*UserRecord, error)

type StoredProfileDocument added in v0.3.0

type StoredProfileDocument struct {
	Meta    ProfileHistoryEntry `json:"meta"`
	Profile *profilepkg.Profile `json:"profile"`
}

type SyncRun

type SyncRun struct {
	ID             int64
	Scope          string
	SyncKey        string
	Cursor         string
	From           string
	To             string
	RequestContext string
	Status         string
	StartedAt      string
	FinishedAt     string
	RecordsSeen    int64
	RecordsWritten int64
	ErrorText      string
}

type SyncState

type SyncState struct {
	SyncKey       string
	Scope         string
	Cursor        string
	LastRunID     int64
	LastStatus    string
	LastError     string
	LastSuccessAt string
	UpdatedAt     string
}

type SyncStatusSummary

type SyncStatusSummary struct {
	TotalCalls                   int64                       `json:"total_calls"`
	TotalUsers                   int64                       `json:"total_users"`
	TotalTranscripts             int64                       `json:"total_transcripts"`
	TotalTranscriptSegments      int64                       `json:"total_transcript_segments"`
	TotalEmbeddedCRMContextCalls int64                       `json:"total_embedded_crm_context_calls"`
	TotalEmbeddedCRMObjects      int64                       `json:"total_embedded_crm_objects"`
	TotalEmbeddedCRMFields       int64                       `json:"total_embedded_crm_fields"`
	TotalCRMIntegrations         int64                       `json:"total_crm_integrations"`
	TotalCRMSchemaObjects        int64                       `json:"total_crm_schema_objects"`
	TotalCRMSchemaFields         int64                       `json:"total_crm_schema_fields"`
	TotalGongSettings            int64                       `json:"total_gong_settings"`
	TotalScorecards              int64                       `json:"total_scorecards"`
	TotalScorecardActivity       int64                       `json:"total_scorecard_activity"`
	TotalAIHighlights            int64                       `json:"total_ai_highlights"`
	MissingTranscripts           int64                       `json:"missing_transcripts"`
	RunningSyncRuns              int64                       `json:"running_sync_runs"`
	ProfileReadiness             ProfileReadiness            `json:"profile_readiness"`
	PublicReadiness              PublicReadiness             `json:"public_readiness"`
	AttributionCoverage          AttributionCoverage         `json:"attribution_coverage"`
	CallFactsAttribution         CallFactsAttributionSignals `json:"call_facts_attribution"`
	LastRun                      *SyncRun                    `json:"last_run,omitempty"`
	LastSuccessfulRun            *SyncRun                    `json:"last_successful_run,omitempty"`
	States                       []SyncState                 `json:"states"`
}

type TranscriptAttributionSearchParams

type TranscriptAttributionSearchParams struct {
	Query            string
	FromDate         string
	ToDate           string
	LifecycleBucket  string
	Scope            string
	System           string
	Direction        string
	TranscriptStatus string
	Industry         string
	AccountQuery     string
	OpportunityStage string
	Limit            int
}

type TranscriptAttributionSearchResult

type TranscriptAttributionSearchResult struct {
	CallID                 string `json:"call_id,omitempty"`
	Title                  string `json:"title,omitempty"`
	StartedAt              string `json:"started_at"`
	CallDate               string `json:"call_date,omitempty"`
	LifecycleBucket        string `json:"lifecycle_bucket,omitempty"`
	AccountName            string `json:"account_name,omitempty"`
	AccountIndustry        string `json:"account_industry,omitempty"`
	AccountWebsite         string `json:"account_website,omitempty"`
	OpportunityName        string `json:"opportunity_name,omitempty"`
	OpportunityStage       string `json:"opportunity_stage,omitempty"`
	OpportunityType        string `json:"opportunity_type,omitempty"`
	OpportunityCloseDate   string `json:"opportunity_close_date,omitempty"`
	OpportunityProbability string `json:"opportunity_probability,omitempty"`
	ParticipantStatus      string `json:"participant_status"`
	PersonTitleStatus      string `json:"person_title_status"`
	PersonTitleSource      string `json:"person_title_source,omitempty"`
	SpeakerID              string `json:"-"`
	SpeakerRole            string `json:"speaker_role,omitempty"`
	SpeakerRoleStatus      string `json:"speaker_role_status,omitempty"`
	SegmentIndex           int    `json:"segment_index"`
	StartMS                int64  `json:"start_ms"`
	EndMS                  int64  `json:"end_ms"`
	Snippet                string `json:"snippet"`
	ContextExcerpt         string `json:"context_excerpt"`
}

type TranscriptCRMSearchParams

type TranscriptCRMSearchParams struct {
	Query      string
	ObjectType string
	ObjectID   string
	Limit      int
}

type TranscriptCRMSearchResult

type TranscriptCRMSearchResult struct {
	CallID              string `json:"call_id"`
	Title               string `json:"title"`
	StartedAt           string `json:"started_at"`
	ObjectType          string `json:"object_type"`
	ObjectID            string `json:"object_id"`
	ObjectName          string `json:"object_name"`
	MatchingObjectCount int64  `json:"matching_object_count"`
	SpeakerID           string `json:"speaker_id"`
	SegmentIndex        int    `json:"segment_index"`
	StartMS             int64  `json:"start_ms"`
	EndMS               int64  `json:"end_ms"`
	Snippet             string `json:"snippet"`
}

type TranscriptCallFactsSearchParams

type TranscriptCallFactsSearchParams struct {
	Query           string
	FromDate        string
	ToDate          string
	LifecycleBucket string
	Scope           string
	System          string
	Direction       string
	Limit           int
}

type TranscriptCallFactsSearchResult

type TranscriptCallFactsSearchResult struct {
	CallID          string `json:"-"`
	SpeakerID       string `json:"-"`
	StartedAt       string `json:"started_at"`
	CallDate        string `json:"call_date"`
	CallMonth       string `json:"call_month"`
	DurationSeconds int64  `json:"duration_seconds"`
	LifecycleBucket string `json:"lifecycle_bucket"`
	Scope           string `json:"scope"`
	System          string `json:"system"`
	Direction       string `json:"direction"`
	SegmentIndex    int    `json:"segment_index"`
	StartMS         int64  `json:"start_ms"`
	EndMS           int64  `json:"end_ms"`
	Snippet         string `json:"snippet"`
	ContextExcerpt  string `json:"context_excerpt"`
}

type TranscriptRecord

type TranscriptRecord struct {
	CallID       string
	SegmentCount int
	RawJSON      []byte
	RawSHA256    string
	FirstSeenAt  string
	UpdatedAt    string
}

type TranscriptSearchResult

type TranscriptSearchResult struct {
	CallID       string
	SpeakerID    string
	SegmentIndex int
	StartMS      int64
	EndMS        int64
	Text         string
	Snippet      string
}

type TranscriptSegment

type TranscriptSegment struct {
	ID           int64
	CallID       string
	SegmentIndex int
	SpeakerID    string
	StartMS      int64
	EndMS        int64
	Text         string
	RawJSON      []byte
}

type UnmappedCRMField

type UnmappedCRMField struct {
	ObjectType         string  `json:"object_type"`
	FieldName          string  `json:"field_name"`
	FieldLabel         string  `json:"field_label,omitempty"`
	FieldType          string  `json:"field_type,omitempty"`
	ObjectCount        int64   `json:"object_count"`
	PopulatedCount     int64   `json:"populated_count"`
	PopulationRate     float64 `json:"population_rate"`
	DistinctValueCount int64   `json:"distinct_value_count"`
	MinValueLength     int64   `json:"min_value_length"`
	MaxValueLength     int64   `json:"max_value_length"`
	AvgValueLength     float64 `json:"avg_value_length"`
}

type UnmappedCRMFieldParams

type UnmappedCRMFieldParams struct {
	Limit int
}

type UserRecord

type UserRecord struct {
	UserID      string
	Email       string
	FirstName   string
	LastName    string
	DisplayName string
	Title       string
	Active      bool
	RawJSON     []byte
	RawSHA256   string
	FirstSeenAt string
	UpdatedAt   string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL