reviewstore

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultRetention = 7 * 24 * time.Hour

Variables

View Source
var (
	ErrExpired            = reviewdata.ErrExpired
	ErrSubmissionConflict = reviewdata.ErrSubmissionConflict
)
View Source
var ErrNotFound = reviewdata.ErrNotFound

Functions

func Reset added in v0.2.1

func Reset(path string) (string, error)

Reset moves current or older diffx state at path to a timestamped backup beside it, then removes earlier backups. It refuses newer or unrecognized state and returns "" when no state exists. Opening a store never resets; only entry points that own an explicit reset decision call Reset.

func VersionID

func VersionID(diffID, revision string) string

Types

type Binding

type Binding = reviewdata.Binding

type ContextInfo

type ContextInfo = reviewdata.ContextInfo

type GitHubStore added in v0.2.1

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

func (*GitHubStore) ClaimRefresh added in v0.2.1

func (s *GitHubStore) ClaimRefresh(ctx context.Context, token string, now, leaseUntil int64) (githubsync.Lease, error)

func (*GitHubStore) CompleteRefresh added in v0.2.1

func (s *GitHubStore) CompleteRefresh(ctx context.Context, lease githubsync.Lease, state string, admissions []githubsync.Admission, now int64) error

func (*GitHubStore) Connection added in v0.2.1

func (s *GitHubStore) Connection(ctx context.Context, ownerID string) (githubsync.Connection, error)

func (*GitHubStore) Connections added in v0.2.1

func (s *GitHubStore) Connections(ctx context.Context) ([]githubsync.Connection, error)

func (*GitHubStore) DeleteConnection added in v0.2.1

func (s *GitHubStore) DeleteConnection(ctx context.Context, ownerID string) error

Follows cascade with their connection.

func (*GitHubStore) DeleteFollow added in v0.2.1

func (s *GitHubStore) DeleteFollow(ctx context.Context, ownerID string, repositoryID int64) error

func (*GitHubStore) Follows added in v0.2.1

func (s *GitHubStore) Follows(ctx context.Context, ownerID string) ([]githubsync.Follow, error)

func (*GitHubStore) KnownOpen added in v0.2.1

func (s *GitHubStore) KnownOpen(ctx context.Context, repositoryID int64) ([]int, error)

func (*GitHubStore) Leased added in v0.2.1

func (s *GitHubStore) Leased(ctx context.Context, repositoryID int64, number int, token string, now int64) (githubsync.Lease, []byte, error)

func (*GitHubStore) LoseInstallation added in v0.2.1

func (s *GitHubStore) LoseInstallation(ctx context.Context, installationID int64, repositoryIDs []int64) error

func (*GitHubStore) PutConnection added in v0.2.1

func (s *GitHubStore) PutConnection(ctx context.Context, c githubsync.Connection) error

func (*GitHubStore) PutFollow added in v0.2.1

func (s *GitHubStore) PutFollow(ctx context.Context, f githubsync.Follow) error

func (*GitHubStore) PutOAuthState added in v0.2.1

func (s *GitHubStore) PutOAuthState(ctx context.Context, hash, ownerID string, expiresAt int64) error

func (*GitHubStore) RecordDelivery added in v0.2.1

func (s *GitHubStore) RecordDelivery(ctx context.Context, id, event string, now int64) error

func (*GitHubStore) RecordLease added in v0.2.1

func (s *GitHubStore) RecordLease(ctx context.Context, lease githubsync.Lease, leased []byte, now int64) error

func (*GitHubStore) ReleaseRefresh added in v0.2.1

func (s *GitHubStore) ReleaseRefresh(ctx context.Context, lease githubsync.Lease, retryAt int64, detail string) error

func (*GitHubStore) RepositoryFollows added in v0.2.1

func (s *GitHubStore) RepositoryFollows(ctx context.Context, repositoryID int64) ([]githubsync.Follow, error)

func (*GitHubStore) RequestRefresh added in v0.2.1

func (s *GitHubStore) RequestRefresh(ctx context.Context, ref githubsync.PullRequestRef, retentionRun string, now int64) error

func (*GitHubStore) RevokeUser added in v0.2.1

func (s *GitHubStore) RevokeUser(ctx context.Context, userID int64) error

func (*GitHubStore) SeenDelivery added in v0.2.1

func (s *GitHubStore) SeenDelivery(ctx context.Context, id string) (bool, error)

func (*GitHubStore) TakeOAuthState added in v0.2.1

func (s *GitHubStore) TakeOAuthState(ctx context.Context, hash string, now int64) (string, error)

type SQLiteQueue

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

SQLiteQueue uses the same database owner as observations; it never opens a second connection pool or permits multiple processes to bypass store ownership.

func (*SQLiteQueue) Accept

func (queue *SQLiteQueue) Accept(ctx context.Context, owner string, request ingestion.Request) (ingestionqueue.Job, error)

func (*SQLiteQueue) Claim

func (queue *SQLiteQueue) Claim(ctx context.Context, duration time.Duration) (ingestionqueue.Delivery, error)

func (*SQLiteQueue) Complete

func (queue *SQLiteQueue) Complete(ctx context.Context, delivery ingestionqueue.Delivery, id string) error

func (*SQLiteQueue) Fail

func (queue *SQLiteQueue) Fail(ctx context.Context, delivery ingestionqueue.Delivery, detail string) error

func (*SQLiteQueue) Get

func (queue *SQLiteQueue) Get(ctx context.Context, owner, id string) (ingestionqueue.Job, error)

func (*SQLiteQueue) Renew

func (queue *SQLiteQueue) Renew(ctx context.Context, delivery ingestionqueue.Delivery, duration time.Duration) error

func (*SQLiteQueue) Retry

func (queue *SQLiteQueue) Retry(ctx context.Context, delivery ingestionqueue.Delivery, next time.Time, detail string) error

type SessionAssociation

type SessionAssociation = reviewdata.SessionAssociation

SessionAssociation records observation, never ownership or authorship.

type StateError added in v0.2.1

type StateError struct {
	Path    string
	Version int
	// contains filtered or unexported fields
}

StateError reports state this binary refuses to open. Version is the stored schema; it is zero for unversioned or unrecognized files.

func (*StateError) Error added in v0.2.1

func (failure *StateError) Error() string

func (*StateError) Older added in v0.2.1

func (failure *StateError) Older() bool

Older reports diffx state written by an earlier schema that cannot upgrade in place.

func (*StateError) Supported added in v0.2.1

func (failure *StateError) Supported() int

Supported is the schema this binary opens.

type Store

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

func Open

func Open(path string) (*Store, error)

func OpenWithRetention

func OpenWithRetention(path string, retention time.Duration) (*Store, error)

OpenWithRetention configures expiry for new observations. Existing expiry and replay identities remain unchanged.

func (*Store) AccountPassword added in v0.2.1

func (store *Store) AccountPassword(ctx context.Context, username string) (identityservice.PasswordCredential, error)

func (*Store) AccountPasswordByID added in v0.2.1

func (store *Store) AccountPasswordByID(ctx context.Context, accountID string) (identityservice.PasswordCredential, error)

func (*Store) ClearMarks

func (store *Store) ClearMarks(ctx context.Context, contextID string, scope review.DiffMode) error

func (*Store) Close

func (store *Store) Close() error

func (*Store) Comments

func (store *Store) Comments(ctx context.Context, contextID string) ([]review.ReviewComment, error)

Comments returns the stream's comments while the context is retained.

func (*Store) Context

func (store *Store) Context(ctx context.Context, ownerID, id string, now time.Time) (ContextInfo, error)

func (*Store) ContextBinding

func (store *Store) ContextBinding(ctx context.Context, ownerID, id string, now time.Time) (Binding, error)

func (*Store) ContextCount

func (store *Store) ContextCount(ctx context.Context, ownerID string, selection ingestion.Selection, now time.Time) (int, error)

func (*Store) Contexts

func (store *Store) Contexts(ctx context.Context, ownerID string, limit int, beforeTime int64, beforeID string, now time.Time) ([]ContextInfo, error)

Contexts uses a keyset cursor; concurrent submissions may move an item across pages.

func (*Store) CreateAccount added in v0.2.1

func (store *Store) CreateAccount(ctx context.Context, account identityservice.Account, passwordHash string, bootstrap bool, created time.Time) (identityservice.Account, error)

CreateAccount commits the owner and its initial credential together. Bootstrap checks all remote accounts in this transaction, so changed env never creates another owner or replaces credentials on restart.

func (*Store) CreateIdentityToken added in v0.2.1

func (store *Store) CreateIdentityToken(ctx context.Context, accountID string, token identityservice.Token, secretHash string) error

func (*Store) CreateSession added in v0.2.1

func (store *Store) CreateSession(ctx context.Context, accountID, expected, secretHash, csrf string, expires time.Time) error

func (*Store) DeleteComment

func (store *Store) DeleteComment(ctx context.Context, contextID, commentID string) (bool, error)

func (*Store) DeleteComments

func (store *Store) DeleteComments(ctx context.Context, contextID string, selected map[string]bool) (int, error)

func (*Store) DeleteContext

func (store *Store) DeleteContext(ctx context.Context, ownerID, id string) error

DeleteContext removes the context and every scope's snapshot. Review state survives while its stream has another observation. Stream heads intentionally survive so older observations remain stale.

func (*Store) DeleteIdentityToken added in v0.2.1

func (store *Store) DeleteIdentityToken(ctx context.Context, accountID, tokenID string) error

func (*Store) DeleteMark

func (store *Store) DeleteMark(ctx context.Context, contextID string, scope review.DiffMode, fileID string) error

DeleteMark and ClearMarks remove only marks visible in this context.

func (*Store) DeleteSession added in v0.2.1

func (store *Store) DeleteSession(ctx context.Context, secretHash string) error

func (*Store) GitHub added in v0.2.1

func (store *Store) GitHub() *GitHubStore

GitHub adapts the store to the integration's storage contract.

func (*Store) IdentityAccounts added in v0.2.1

func (store *Store) IdentityAccounts(ctx context.Context) ([]identityservice.Account, error)

func (*Store) IdentityTokens added in v0.2.1

func (store *Store) IdentityTokens(ctx context.Context, accountID string) ([]identityservice.Token, error)

func (*Store) ImportComments

func (store *Store) ImportComments(ctx context.Context, contextID string, comments []review.ReviewComment) ([]review.ReviewComment, error)

func (*Store) Ingest

func (store *Store) Ingest(ownerID string, request ingestion.Request) (Binding, error)

Ingest atomically commits an immutable observation and its retry identity. Checkout paths are labels; this method never accesses a producer filesystem.

func (*Store) IngestContext

func (store *Store) IngestContext(ctx context.Context, ownerID string, request ingestion.Request) (Binding, error)

func (*Store) Marks

func (store *Store) Marks(ctx context.Context, contextID string, scope review.DiffMode) ([]review.ReviewMark, error)

Marks returns stream marks whose file patch is unchanged in this context, projected onto this context's snapshot.

func (*Store) Observation

func (store *Store) Observation(ownerID, contextID string) (ingestion.Metadata, error)

func (*Store) ObservationContexts

func (store *Store) ObservationContexts(ctx context.Context, ownerID string, limit int, beforeTime int64, beforeID string, filter ingestion.Filter) ([]ContextInfo, error)

ObservationContexts filters immutable observations using captured metadata.

func (*Store) ObservationFileVersion added in v0.2.1

func (store *Store) ObservationFileVersion(ctx context.Context, ownerID, contextID string, mode review.DiffMode, fileID string) (reviewdata.FileVersion, error)

ObservationFileVersion reads only indexed identities. Missing files retain the scope identity so callers can reject stale scope references before file errors.

func (*Store) ObservationPatch

func (store *Store) ObservationPatch(ctx context.Context, ownerID, contextID string, mode review.DiffMode, fileID, fileVersion string) (review.FilePatch, error)

func (*Store) ObservationSnapshot

func (store *Store) ObservationSnapshot(ctx context.Context, ownerID, contextID string, mode review.DiffMode) (review.RepositoryDiff, error)

func (*Store) PruneExpired

func (store *Store) PruneExpired(now time.Time) error

func (*Store) PutComment

func (store *Store) PutComment(ctx context.Context, contextID string, comment review.ReviewComment) error

PutComment stores a comment in the context's stream review. New references must name this context's snapshot; an existing comment may keep the snapshot it was written against.

func (*Store) PutMark

func (store *Store) PutMark(ctx context.Context, contextID string, mark review.ReviewMark) error

func (*Store) Queue

func (store *Store) Queue() *SQLiteQueue

func (*Store) ReplaceComment added in v0.2.1

func (store *Store) ReplaceComment(ctx context.Context, contextID string, comment review.ReviewComment) (bool, error)

ReplaceComment updates an existing stream comment and reports false when it no longer exists, so an edit racing a delete cannot recreate the comment.

func (*Store) ReplacePassword added in v0.2.1

func (store *Store) ReplacePassword(ctx context.Context, accountID, expected, replacement string) error

ReplacePassword fences authentication against password changes/reset, and invalidates every browser session at the same commit. API tokens are independent.

func (*Store) ResolveIdentityToken added in v0.2.1

func (store *Store) ResolveIdentityToken(ctx context.Context, secretHash string, now time.Time) (identityservice.TokenIdentity, error)

func (*Store) ResolveSession added in v0.2.1

func (store *Store) ResolveSession(ctx context.Context, secretHash string, now time.Time) (identityservice.Session, error)

func (*Store) StoredVersion

func (store *Store) StoredVersion(ctx context.Context, ownerID, diffID, versionID string, now time.Time) (review.RepositoryDiff, error)

func (*Store) User

func (store *Store) User(osUID, name string) (User, error)

type User

type User = reviewdata.User

Jump to

Keyboard shortcuts

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