quicksearch4datatug

package
v0.47.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 28 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package quicksearch4datatug implements consent-controlled project metadata search.

Index

Constants

View Source
const ConsentVersion = "project-quick-search/1"
View Source
const MaxDocuments = 1000
View Source
const MaxKnownScopes = 256

A repository catalogue bounds only this repository/folder; other customers cannot exhaust its capacity. Entries remain until physical deletion is known.

View Source
const MaxTrackedCollections = 128

Bound failed cleanup resources before creating another provider collection.

Variables

View Source
var (
	ErrInvalid         = errors.New("invalid_request")
	ErrDenied          = errors.New("project_denied")
	ErrUnavailable     = errors.New("search_unavailable")
	ErrConflict        = errors.New("operation_in_progress")
	ErrCapacity        = errors.New("index_capacity_reached")
	ErrConsent         = errors.New("consent_required")
	ErrProvider        = errors.New("provider_unavailable")
	ErrProviderUnknown = errors.New("provider_completion_unknown")
)

Functions

func EqualMetadata

func EqualMetadata(uploaded, canonical Document) bool

EqualMetadata compares the entire uploaded projection, including navigation. No provider-controlled name/tag/source label survives an existence-only check.

func Fold

func Fold(s string) string

func MetadataTags

func MetadataTags(tags []string) []string

func RawTags

func RawTags(value any) []string

Types

type Access

type Access struct {
	Scope                   Scope
	CanManage, Eligible     bool
	Audience                string
	GitHubOwner, GitHubName string
}

Access is always server-derived, including the immutable canonical scope.

type Authority

type Authority interface {
	Resolve(context.Context, string, Scope) (Access, error)
	Admit(context.Context, string, Access, Document) error
}

type CleanupAuthority added in v0.46.2

type CleanupAuthority interface {
	ResolveCleanup(context.Context, string, Scope) (Scope, error)
}

CleanupAuthority grants only deletion of retained metadata, independently of source read access.

type Coverage

type Coverage struct {
	Kind   string `json:"kind"`
	Status string `json:"status"`
	Count  int    `json:"count"`
	Error  string `json:"error,omitempty"`
}

type DALStore

type DALStore struct{ DB dal.DB }

DALStore reuses the host's server-owned database and transaction lifecycle.

func (DALStore) Read

func (s DALStore) Read(ctx context.Context, key string) (State, error)

func (DALStore) Update

func (s DALStore) Update(ctx context.Context, key string, fn func(*State) error) error

func (DALStore) UpdateMany added in v0.46.2

func (s DALStore) UpdateMany(ctx context.Context, keys []string, fn func(map[string]*State) error) error

UpdateMany reads every record before writing, preserving Firestore transaction ordering.

type Document

type Document struct {
	Kind          string    `json:"kind"`
	ID            string    `json:"id"`
	Name          string    `json:"name"`
	QualifiedName string    `json:"qualifiedName,omitempty"`
	SourceName    string    `json:"sourceName,omitempty"`
	ParentID      string    `json:"parentId,omitempty"`
	ParentName    string    `json:"parentName,omitempty"`
	Tags          []string  `json:"tags"`
	Reference     Reference `json:"reference"`
}

func InlineSchemaDocument added in v0.46.5

func InlineSchemaDocument(body []byte, d Document) (Document, error)

func NamedDocument

func NamedDocument(kind, id, title string, tags []string, ref Reference) Document

func NamedDocumentJSON

func NamedDocumentJSON(kind, id string, body []byte, ref Reference) (Document, error)

func SchemaDocument

func SchemaDocument(modelID, modelTitle, schema, table, column, parentKind string, tags []string) Document

func SchemaDocumentFromSource added in v0.46.5

func SchemaDocumentFromSource(read func(string) ([]byte, error), d Document) (Document, error)

SchemaDocumentFromSource is shared by current-source per-item admission.

func SchemaInventory added in v0.46.5

func SchemaInventory(paths []string, read func(string) ([]byte, error)) ([]Document, error)

SchemaInventory consumes an already complete, pinned project file inventory.

func SplitSchemaDocuments added in v0.46.5

func SplitSchemaDocuments(model, schema, table, kind string, body []byte) ([]Document, error)

func (Document) Validate

func (d Document) Validate() error

type FirestoreStore

type FirestoreStore struct{ Client *firestore.Client }

FirestoreStore keeps lifecycle authority server-side; it stores no indexed metadata.

func (FirestoreStore) Read

func (s FirestoreStore) Read(ctx context.Context, key string) (State, error)

func (FirestoreStore) Update

func (s FirestoreStore) Update(ctx context.Context, key string, fn func(*State) error) error

func (FirestoreStore) UpdateMany added in v0.46.2

func (s FirestoreStore) UpdateMany(ctx context.Context, keys []string, fn func(map[string]*State) error) error

type MetadataAuthority added in v0.46.5

type MetadataAuthority interface {
	ReadMetadata(context.Context, string, Access, string) (MetadataSnapshot, error)
}

MetadataAuthority reads current canonical metadata without changing index state.

type MetadataSnapshot added in v0.46.5

type MetadataSnapshot struct {
	Documents      []Document `json:"documents"`
	SourceCoverage []Coverage `json:"sourceCoverage"`
}

type PreviewRequest added in v0.46.5

type PreviewRequest struct {
	EnvironmentID string `json:"environmentId,omitempty"`
}

type Provider

type Provider interface {
	Replace(context.Context, string, []ProviderDocument) error
	Read(context.Context, string) ([]ProviderDocument, error)
	Delete(context.Context, string) error
}

type ProviderDocument

type ProviderDocument struct {
	Document
	Partition  string `json:"partition"`
	Generation uint64 `json:"generation"`
	Key        string `json:"key"`
}

type PublicGitHubVerifier

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

func NewPublicGitHubVerifier

func NewPublicGitHubVerifier(client *http.Client) *PublicGitHubVerifier

func (*PublicGitHubVerifier) ReadFile

func (v *PublicGitHubVerifier) ReadFile(ctx context.Context, repo PublicRepository, branch, file string) ([]byte, error)

func (*PublicGitHubVerifier) Resolve

func (v *PublicGitHubVerifier) Resolve(ctx context.Context, owner, name, folder, branch string) (PublicRepository, error)

type PublicRepository

type PublicRepository struct {
	RepositoryID int64
	Owner, Name  string
	Branch       string
}

type Query

type Query struct {
	Q     string   `json:"q"`
	Kinds []string `json:"kinds,omitempty"`
	Tags  []string `json:"tags,omitempty"`
}

type Reference

type Reference struct {
	EnvironmentID string `json:"environmentId,omitempty"`
	SourceID      string `json:"sourceId,omitempty"`
	DBModelID     string `json:"dbModelId,omitempty"`
	Schema        string `json:"schema,omitempty"`
	Table         string `json:"table,omitempty"`
	Column        string `json:"column,omitempty"`
	ObjectID      string `json:"objectId,omitempty"`
	Folder        string `json:"folder,omitempty"`
}

type Results

type Results struct {
	Items     []Document `json:"items"`
	ItemCount int        `json:"itemCount"`
	Tags      []string   `json:"tags"`
}

type Scope

type Scope struct {
	Audience     string `json:"audience,omitempty"`
	Storage      string `json:"storage"`
	SpaceID      string `json:"spaceID,omitempty"`
	Project      string `json:"project"`
	Branch       string `json:"branch,omitempty"`
	RepositoryID int64  `json:"repositoryId,omitempty"`
}

func (Scope) Key

func (s Scope) Key() string

type Service

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

func NewService

func NewService(store Store, provider Provider, authority Authority) (*Service, error)

func (*Service) CurrentOperation

func (s *Service) CurrentOperation(ctx context.Context, canonical Scope) (WriterOperation, error)

func (*Service) CurrentWriter

func (s *Service) CurrentWriter(ctx context.Context, canonical Scope) (string, time.Time, error)

CurrentWriter is trusted host recovery information, never a browser API.

func (*Service) Disable

func (s *Service) Disable(ctx context.Context, actor string, scope Scope) (Status, error)

func (*Service) Index

func (s *Service) Index(ctx context.Context, actor string, scope Scope, snapshot Snapshot, enable bool) (Status, error)

func (*Service) Preview added in v0.46.5

func (s *Service) Preview(ctx context.Context, actor string, scope Scope, request PreviewRequest) (MetadataSnapshot, error)

func (*Service) RecoverWriter

func (s *Service) RecoverWriter(ctx context.Context, scope Scope, operation string, barrier WriterRecoveryBarrier) error

func (*Service) Search

func (s *Service) Search(ctx context.Context, actor string, scope Scope, q Query) (Results, error)

func (*Service) Status

func (s *Service) Status(ctx context.Context, actor string, scope Scope) (Status, error)

type Snapshot

type Snapshot struct {
	Consent        bool       `json:"consent"`
	ConsentVersion string     `json:"consentVersion"`
	Documents      []Document `json:"documents"`
	SourceCoverage []Coverage `json:"sourceCoverage"`
}

func (Snapshot) Validate

func (s Snapshot) Validate() error

type State

type State struct {
	CatalogueInitialized bool
	KnownScopes          []Scope
	CleanupEpoch         uint64
	CredentialGeneration string
	Scope                Scope
	Generation           uint64
	ConsentActor         string
	ConsentAt            time.Time
	ConsentVersion       string
	Phase                string
	Active               string
	ActiveGeneration     uint64
	Collections          []string
	CleanupOwners        map[string]string
	Lease                string
	LeaseUntil           time.Time
	LastIndexedAt        *time.Time
	Count                int
	Coverage             []Coverage
	Error                string
}

type Status

type Status struct {
	SupportsMetadataPreview bool       `json:"supportsMetadataPreview,omitempty"`
	State                   string     `json:"state"`
	CanManage               bool       `json:"canManage"`
	Eligible                bool       `json:"eligible"`
	Audience                string     `json:"audience"`
	Provider                string     `json:"provider"`
	ConsentVersion          string     `json:"consentVersion,omitempty"`
	LastIndexedAt           *time.Time `json:"lastIndexedAt,omitempty"`
	DocumentCount           int        `json:"documentCount"`
	Error                   string     `json:"error,omitempty"`
	SourceCoverage          []Coverage `json:"sourceCoverage"`
	Revision                uint64     `json:"revision"`
}

type Store

type Store interface {
	Update(context.Context, string, func(*State) error) error
	Read(context.Context, string) (State, error)
}

Store serializes mutations durably across processes. A missing scope is a zero State.

type TransactionalStore added in v0.46.2

type TransactionalStore interface {
	UpdateMany(context.Context, []string, func(map[string]*State) error) error
}

TransactionalStore atomically validates the repository catalogue and claims lifecycle state.

type Typesense

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

func NewTypesense

func NewTypesense(o TypesenseOptions) (*Typesense, error)

func (*Typesense) CredentialGeneration

func (t *Typesense) CredentialGeneration() string

func (*Typesense) Delete

func (t *Typesense) Delete(ctx context.Context, collection string) error

func (*Typesense) Read

func (t *Typesense) Read(ctx context.Context, collection string) ([]ProviderDocument, error)

Read exports the bounded collection, preventing provider pagination from splitting same-name groups and ensuring totals/tags are derived solely after admission.

func (*Typesense) Replace

func (t *Typesense) Replace(ctx context.Context, collection string, docs []ProviderDocument) error

type TypesenseOptions

type TypesenseOptions struct {
	Origin, APIKey, CollectionPrefix string
	CredentialGeneration             string
	HTTPClient                       *http.Client
}

type WriterOperation

type WriterOperation struct {
	ID                   string
	CredentialGeneration string
	LeaseUntil           time.Time
	Scope                Scope
}

WriterOperation is trusted maintenance information, never exposed by routes.

type WriterRecoveryBarrier

type WriterRecoveryBarrier interface {
	FenceWriter(context.Context, Scope, string) error
}

WriterRecoveryBarrier must prove the old process/operation cannot issue any further provider requests (for example after an authoritative instance kill). Lease expiry or a caller assertion alone is not a recovery barrier.

Jump to

Keyboard shortcuts

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