Documentation
¶
Index ¶
- func ContainsAction(actions string, action string) bool
- func SplitActions(actions string) []string
- type APIKey
- type AgentBriefing
- type AuditEntry
- type BillingInfo
- type DB
- func (db *DB) AddGroupMember(groupID, userID int64) error
- func (db *DB) AddPermission(roleID int64, resourceType, resourcePattern, actions, effect string) (*Permission, error)
- func (db *DB) AddStorageLimit(vaultID int64, additionalMB int64) error
- func (db *DB) AddTraceEdge(sourcePath, targetTraceID, edgeType, section, relevance string) error
- func (db *DB) AddTracePolicy(traceID, policyRef, policyText string) error
- func (db *DB) AddTraceTag(traceID, tag string) error
- func (db *DB) AssignGroupRole(groupID, roleID int64) error
- func (db *DB) AssignRole(userID, roleID int64) error
- func (db *DB) AuthenticateAPIKey(key string) (*APIKey, error)
- func (db *DB) BuildBriefing(actorRole string, taskContext string) (*AgentBriefing, error)
- func (db *DB) CheckStaleReferences(traceID string) ([]StaleReference, error)
- func (db *DB) CleanExpiredTokens() error
- func (db *DB) Close() error
- func (db *DB) CountUsers(vaultID int64) (int, error)
- func (db *DB) CreateAPIKey(userID int64, name string, roleID int64, expiresAt *time.Time) (string, *APIKey, error)
- func (db *DB) CreateBilling(vaultID int64, stripeCustomerID, plan string, maxUsers int, ...) (*BillingInfo, error)
- func (db *DB) CreateGroup(vaultID int64, name, description string) (*Group, error)
- func (db *DB) CreateRole(vaultID int64, name, description string) (*Role, error)
- func (db *DB) CreateToken(tokenType, email string, ttl time.Duration, ...) (string, error)
- func (db *DB) CreateTrace(t *Trace) error
- func (db *DB) CreateUser(email, displayName, password string) (*User, error)
- func (db *DB) CreateVault(name, path string) (*Vault, error)
- func (db *DB) DeleteGroup(groupID int64) error
- func (db *DB) DeleteTrace(traceID string) error
- func (db *DB) FindContradictions(decisionType, decision string, tags []string) ([]Trace, error)
- func (db *DB) FindPrecedent(decisionType string, tags []string, context string, limit int) ([]TraceWithEdges, error)
- func (db *DB) GetAllPermissionsForUser(userID int64) ([]Permission, error)
- func (db *DB) GetAuditLog(limit int) ([]AuditEntry, error)
- func (db *DB) GetBilling(vaultID int64) (*BillingInfo, error)
- func (db *DB) GetBillingByCustomer(stripeCustomerID string) (*BillingInfo, error)
- func (db *DB) GetCurrentRevision(filePath string) (*DocRevision, error)
- func (db *DB) GetFolderContext(folderPath string) (string, error)
- func (db *DB) GetGroup(vaultID int64, name string) (*Group, error)
- func (db *DB) GetGroupMembers(groupID int64) ([]User, error)
- func (db *DB) GetGroupRoles(groupID int64) ([]Role, error)
- func (db *DB) GetKnowledgeGaps(minOccurrences int, days int) ([]KnowledgeGap, error)
- func (db *DB) GetPermissionsForRole(roleID int64) ([]Permission, error)
- func (db *DB) GetPermissionsForUser(userID int64) ([]Permission, error)
- func (db *DB) GetRecentKnowledgeNotes(limit int) ([]KnowledgeNote, error)
- func (db *DB) GetRevisionHistory(filePath string) ([]DocRevision, error)
- func (db *DB) GetRole(vaultID int64, name string) (*Role, error)
- func (db *DB) GetRoleByID(roleID int64) (*Role, error)
- func (db *DB) GetTrace(traceID string) (*Trace, error)
- func (db *DB) GetTraceEdges(traceID string) ([]TraceEdge, error)
- func (db *DB) GetTracePolicies(traceID string) ([]TracePolicy, error)
- func (db *DB) GetTraceTags(traceID string) ([]string, error)
- func (db *DB) GetTracesReferencingDocument(docPath string) ([]Trace, error)
- func (db *DB) GetUser(email string) (*User, error)
- func (db *DB) GetUserByID(id int64) (*User, error)
- func (db *DB) GetUserGroups(userID int64) ([]Group, error)
- func (db *DB) GetUserRoles(userID int64) ([]Role, error)
- func (db *DB) GetVault(name string) (*Vault, error)
- func (db *DB) IndexDocument(filePath, title, tags, content string) error
- func (db *DB) IndexTraceFTS(traceID, traceType, summary, reasoning, decision string) error
- func (db *DB) ListAPIKeys(userID int64) ([]APIKey, error)
- func (db *DB) ListFolderContexts() (map[string]string, error)
- func (db *DB) ListGroups(vaultID int64) ([]Group, error)
- func (db *DB) ListRoles(vaultID int64) ([]Role, error)
- func (db *DB) ListTraces(limit int) ([]Trace, error)
- func (db *DB) ListUsers() ([]User, error)
- func (db *DB) ListVaults() ([]Vault, error)
- func (db *DB) LogAudit(userID int64, action, resourcePath, details string) error
- func (db *DB) LogSearch(query string, resultCount int, actorID string) error
- func (db *DB) Login(email, password string) (string, *User, error)
- func (db *DB) RecordKnowledgeNote(filePath, source, sourceDetail, category string) error
- func (db *DB) RecordRevision(filePath, rev, content, changedBy, changeSummary string) error
- func (db *DB) RemoveDocument(filePath string) error
- func (db *DB) RemoveGroupMember(groupID, userID int64) error
- func (db *DB) RevokeGroupRole(groupID, roleID int64) error
- func (db *DB) RevokeRole(userID, roleID int64) error
- func (db *DB) SearchFTS(query string, limit int) ([]SearchResult, error)
- func (db *DB) SearchTraces(opts TraceSearchOpts) ([]Trace, error)
- func (db *DB) SearchTracesFTS(query string, limit int) ([]Trace, error)
- func (db *DB) SetFolderContext(folderPath, context string) error
- func (db *DB) UpdateBillingStatus(vaultID int64, status string) error
- func (db *DB) UpdateBillingSubscription(vaultID int64, subscriptionID, plan string, maxUsers int, storageLimitMB int64) error
- func (db *DB) UpdateDisplayName(userID int64, name string) error
- func (db *DB) UpdateStorageUsed(vaultID int64, usedMB int64) error
- func (db *DB) UpdateTraceOutcome(traceID, status, notes string) error
- func (db *DB) UseToken(token string) error
- func (db *DB) ValidateToken(token, tokenType string) (*Token, error)
- type DocRevision
- type Group
- type KnowledgeGap
- type KnowledgeNote
- type Permission
- type RecentDoc
- type Role
- type SearchResult
- type StaleReference
- type SyncState
- type Token
- type Trace
- type TraceEdge
- type TracePolicy
- type TraceSearchOpts
- type TraceWithEdges
- type User
- type UserRole
- type Vault
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsAction ¶
func SplitActions ¶
Types ¶
type APIKey ¶
type APIKey struct {
ID int64 `json:"id"`
UserID int64 `json:"user_id"`
Name string `json:"name"`
KeyHash string `json:"-"`
KeyPrefix string `json:"key_prefix"` // first 8 chars for identification
RoleID int64 `json:"role_id"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
type AgentBriefing ¶
type AgentBriefing struct {
// Identity is the L0 identity stack (org → team → individual).
// Populated by the server before returning the briefing; left as-is by BuildBriefing.
// Rendered as the first section of the briefing so the agent sees outer-to-inner
// identity constraints before any decision history.
Identity any `json:"identity,omitempty"`
RecentDocs []RecentDoc `json:"recent_docs"`
RecentTraces []Trace `json:"recent_traces"`
PendingOutcomes []Trace `json:"pending_outcomes"`
KnowledgeGaps []KnowledgeGap `json:"knowledge_gaps,omitempty"`
StaleAlerts []StaleReference `json:"stale_alerts,omitempty"`
Alerts []string `json:"alerts,omitempty"`
}
type AuditEntry ¶
type BillingInfo ¶
type BillingInfo struct {
ID int64 `json:"id"`
VaultID int64 `json:"vault_id"`
StripeCustomerID string `json:"stripe_customer_id"`
StripeSubscriptionID string `json:"stripe_subscription_id"`
Plan string `json:"plan"`
MaxUsers int `json:"max_users"`
StorageLimitMB int64 `json:"storage_limit_mb"`
StorageUsedMB int64 `json:"storage_used_mb"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type DB ¶
type DB struct {
// OnKeyCreated is called after a new API key is successfully inserted.
// The callback receives the key prefix (e.g. "vk_a1b2c3d4"). In cloud
// mode, the tenant pool sets this to index the key in the control plane
// so Bearer-token routing works without a /t/<slug> URL prefix.
OnKeyCreated func(prefix string)
// contains filtered or unexported fields
}
func (*DB) AddGroupMember ¶
func (*DB) AddPermission ¶
func (db *DB) AddPermission(roleID int64, resourceType, resourcePattern, actions, effect string) (*Permission, error)
func (*DB) AddTraceEdge ¶
AddTraceEdge creates a link between a source document and a decision trace.
func (*DB) AddTracePolicy ¶
AddTracePolicy records a policy applied in a decision.
func (*DB) AddTraceTag ¶
AddTraceTag adds a tag to a trace.
func (*DB) AssignGroupRole ¶
func (*DB) AssignRole ¶
func (*DB) BuildBriefing ¶
func (db *DB) BuildBriefing(actorRole string, taskContext string) (*AgentBriefing, error)
BuildBriefing generates a context packet for an agent role.
func (*DB) CheckStaleReferences ¶
func (db *DB) CheckStaleReferences(traceID string) ([]StaleReference, error)
CheckStaleReferences checks if any documents referenced by a trace have been revised since the trace was created.
func (*DB) CleanExpiredTokens ¶
CleanExpiredTokens removes tokens that have expired.
func (*DB) CountUsers ¶
CountUsers returns the number of users with roles assigned for a vault.
func (*DB) CreateAPIKey ¶
func (*DB) CreateBilling ¶
func (*DB) CreateGroup ¶
func (*DB) CreateRole ¶
func (*DB) CreateToken ¶
func (db *DB) CreateToken(tokenType, email string, ttl time.Duration, vaultID, roleID, groupID, inviterID *int64) (string, error)
CreateToken generates a secure random token and stores it.
func (*DB) CreateTrace ¶
CreateTrace inserts a new decision trace.
func (*DB) CreateUser ¶
func (*DB) DeleteGroup ¶
func (*DB) DeleteTrace ¶
DeleteTrace removes a trace and its edges/tags/policies.
func (*DB) FindContradictions ¶
FindContradictions looks for existing traces of the same type with a different decision.
func (*DB) FindPrecedent ¶
func (db *DB) FindPrecedent(decisionType string, tags []string, context string, limit int) ([]TraceWithEdges, error)
FindPrecedent searches for similar past decisions using type, tags, and text matching.
func (*DB) GetAllPermissionsForUser ¶
func (db *DB) GetAllPermissionsForUser(userID int64) ([]Permission, error)
GetPermissionsForUser now includes permissions from group-role assignments. This REPLACES the original method — it unions direct role permissions with group-role permissions.
func (*DB) GetAuditLog ¶
func (db *DB) GetAuditLog(limit int) ([]AuditEntry, error)
func (*DB) GetBilling ¶
func (db *DB) GetBilling(vaultID int64) (*BillingInfo, error)
func (*DB) GetBillingByCustomer ¶
func (db *DB) GetBillingByCustomer(stripeCustomerID string) (*BillingInfo, error)
func (*DB) GetCurrentRevision ¶
func (db *DB) GetCurrentRevision(filePath string) (*DocRevision, error)
GetCurrentRevision returns the latest revision for a document.
func (*DB) GetFolderContext ¶
GetFolderContext returns the context annotation for a folder path.
func (*DB) GetKnowledgeGaps ¶
func (db *DB) GetKnowledgeGaps(minOccurrences int, days int) ([]KnowledgeGap, error)
GetKnowledgeGaps returns queries that returned zero results, aggregated by frequency.
func (*DB) GetPermissionsForRole ¶
func (db *DB) GetPermissionsForRole(roleID int64) ([]Permission, error)
func (*DB) GetPermissionsForUser ¶
func (db *DB) GetPermissionsForUser(userID int64) ([]Permission, error)
func (*DB) GetRecentKnowledgeNotes ¶
func (db *DB) GetRecentKnowledgeNotes(limit int) ([]KnowledgeNote, error)
func (*DB) GetRevisionHistory ¶
func (db *DB) GetRevisionHistory(filePath string) ([]DocRevision, error)
GetRevisionHistory returns all revisions for a document.
func (*DB) GetTraceEdges ¶
GetTraceEdges returns all edges for a trace.
func (*DB) GetTracePolicies ¶
func (db *DB) GetTracePolicies(traceID string) ([]TracePolicy, error)
GetTracePolicies returns policies applied in a trace.
func (*DB) GetTraceTags ¶
GetTraceTags returns tags for a trace.
func (*DB) GetTracesReferencingDocument ¶
GetTracesReferencingDocument returns all traces that used a document as input.
func (*DB) IndexDocument ¶
IndexDocument adds or updates a document in the FTS5 index.
func (*DB) IndexTraceFTS ¶
IndexTrace adds or updates a decision trace in the traces FTS5 index.
func (*DB) ListFolderContexts ¶
ListFolderContexts returns all folder context annotations.
func (*DB) ListTraces ¶
ListTraces returns recent traces, optionally filtered.
func (*DB) ListVaults ¶
func (*DB) Login ¶
Login verifies email/password and returns or creates a session API key. The key is tied to the user's first assigned role, or returns an error if the user has no roles.
func (*DB) RecordKnowledgeNote ¶
func (*DB) RecordRevision ¶
RecordRevision stores a new revision for a document.
func (*DB) RemoveDocument ¶
RemoveDocument removes a document from the FTS5 index.
func (*DB) RemoveGroupMember ¶
func (*DB) RevokeGroupRole ¶
func (*DB) RevokeRole ¶
func (*DB) SearchFTS ¶
func (db *DB) SearchFTS(query string, limit int) ([]SearchResult, error)
SearchFTS performs a BM25-ranked full-text search across the vault.
func (*DB) SearchTraces ¶
func (db *DB) SearchTraces(opts TraceSearchOpts) ([]Trace, error)
SearchTraces searches traces by type, tags, actor, status, and/or free text.
func (*DB) SearchTracesFTS ¶
SearchTracesFTS performs BM25-ranked search across decision traces.
func (*DB) SetFolderContext ¶
SetFolderContext sets the context annotation for a folder.
func (*DB) UpdateBillingStatus ¶
func (*DB) UpdateBillingSubscription ¶
func (*DB) UpdateTraceOutcome ¶
UpdateTraceOutcome records the outcome of a past decision.
type DocRevision ¶
type KnowledgeGap ¶
type KnowledgeNote ¶
type Permission ¶
type Permission struct {
ID int64 `json:"id"`
RoleID int64 `json:"role_id"`
ResourceType string `json:"resource_type"` // "folder", "file", "tag"
ResourcePattern string `json:"resource_pattern"` // "/engineering/**", "#sales", etc.
Actions string `json:"actions"` // comma-separated: "read,write,delete"
Effect string `json:"effect"` // "allow" or "deny"
}
type SearchResult ¶
type SearchResult struct {
FilePath string `json:"file_path"`
Title string `json:"title"`
Tags string `json:"tags"`
Snippet string `json:"snippet"`
Rank float64 `json:"rank"`
Context string `json:"folder_context,omitempty"`
}
SearchResult represents a search hit with relevance scoring.
type StaleReference ¶
type Token ¶
type Token struct {
ID int64 `json:"id"`
Token string `json:"token"`
Type string `json:"type"` // "verify", "invite", "reset"
Email string `json:"email"`
VaultID *int64 `json:"vault_id,omitempty"`
RoleID *int64 `json:"role_id,omitempty"`
GroupID *int64 `json:"group_id,omitempty"`
InviterID *int64 `json:"inviter_id,omitempty"`
ExpiresAt time.Time `json:"expires_at"`
UsedAt *time.Time `json:"used_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
type Trace ¶
type Trace struct {
ID int64 `json:"id"`
TraceID string `json:"trace_id"`
FilePath string `json:"file_path"`
Type string `json:"type"`
Status string `json:"status"`
ActorID string `json:"actor_id"`
ActorRole string `json:"actor_role"`
Decision string `json:"decision"`
Summary string `json:"summary"`
Reasoning string `json:"reasoning"`
Deviation bool `json:"deviation"`
DeviationReason string `json:"deviation_reason,omitempty"`
OutcomeStatus string `json:"outcome_status"`
OutcomeNotes string `json:"outcome_notes,omitempty"`
OutcomeRecordedAt *time.Time `json:"outcome_recorded_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
type TracePolicy ¶
type TraceSearchOpts ¶
type TraceWithEdges ¶
type TraceWithEdges struct {
Trace Trace `json:"trace"`
Edges []TraceEdge `json:"edges"`
Policies []TracePolicy `json:"policies"`
Tags []string `json:"tags"`
}