Documentation
¶
Overview ¶
Package store is the Postgres metadata store: principals, repos, branches, efforts, workspaces, changesets and the operation log. File contents and trees live in the blob store; this package holds everything else.
Index ¶
- Constants
- Variables
- func BlobLockKey(h hash.Hash) int64
- func NewID() uuid.UUID
- func OrderPair(a, b uuid.UUID) (uuid.UUID, uuid.UUID, bool)
- func Slugify(name string) string
- func ValidateHandle(kind PrincipalKind, handle string) error
- func ValidateRepoName(name string) error
- type AccessFact
- type AgentScope
- type AuditEntry
- type AuditFilter
- type Branch
- type CLILogin
- type CachedRole
- type ChangesetRow
- type ChangesetTrees
- type Claim
- type Effort
- type EffortOverlap
- type EffortState
- type FileChange
- type GitHubApp
- type GitHubAppGap
- type GitHubCacheScope
- type GitHubInstallationRow
- type GitHubLink
- type GitObject
- type Identity
- type MergeStats
- type Note
- type NoteCursor
- type NoteFilter
- type ObjectSize
- type Op
- type Org
- type OrgAgreement
- type OrgDeletion
- type OrgMember
- type OrgQuota
- type OrgSSO
- type OrgWithRole
- type Principal
- type PrincipalKind
- type Provider
- type PurgeOrgRow
- type PushKey
- type PushSubscription
- type Q
- func (q Q) AcceptOrgAgreement(ctx context.Context, a OrgAgreement, text []byte) (out OrgAgreement, created bool, err error)
- func (q Q) AcceptedAgreementHashes(ctx context.Context) (map[string][]string, error)
- func (q Q) ActiveClaims(ctx context.Context, effortID uuid.UUID, now time.Time) ([]Claim, error)
- func (q Q) ActiveRebase(ctx context.Context, effortID uuid.UUID) (Rebase, error)
- func (q Q) AddGitHubAppGap(ctx context.Context, what, detail string) error
- func (q Q) AddPurgeCounts(ctx context.Context, orgID uuid.UUID, add map[string]int64) error
- func (q Q) AddRepoObjects(ctx context.Context, repoID uuid.UUID, hashes []hash.Hash) error
- func (q Q) AddServerNotice(ctx context.Context, key string) error
- func (q Q) AddTaskDeps(ctx context.Context, task uuid.UUID, deps []uuid.UUID) error
- func (q Q) AddTeamMember(ctx context.Context, t Team, person uuid.UUID) error
- func (q Q) AdoptChangesets(ctx context.Context, repoID, effortID uuid.UUID, hs []hash.Hash) error
- func (q Q) AdvanceEffort(ctx context.Context, id uuid.UUID, seenVersion int64, newHead hash.Hash) (bool, error)
- func (q Q) AgentScope(ctx context.Context, agentID uuid.UUID) (AgentScope, error)
- func (q Q) AgreementText(ctx context.Context, sha256 string) ([]byte, error)
- func (q Q) AnswersToQuestionsBy(ctx context.Context, author uuid.UUID, since time.Time, limit int) ([]Note, error)
- func (q Q) AnyOrgSSO(ctx context.Context) (bool, error)
- func (q Q) Authenticate(ctx context.Context, secret string) (Principal, error)
- func (q Q) AuthenticateToken(ctx context.Context, secret string) (Principal, uuid.UUID, error)
- func (q Q) CLILoginApprover(ctx context.Context, deviceHash []byte) (uuid.UUID, error)
- func (q Q) CLILoginByDevice(ctx context.Context, deviceHash []byte) (CLILogin, error)
- func (q Q) CLILoginByUserCode(ctx context.Context, userCode string) (CLILogin, error)
- func (q Q) Chain(ctx context.Context, repoID uuid.UUID, head, stop hash.Hash, limit int) ([]ChangesetRow, error)
- func (q Q) ChainLength(ctx context.Context, repoID uuid.UUID, head, stop hash.Hash, limit int) (int, error)
- func (q Q) ChangesetByGitSHA(ctx context.Context, repoID uuid.UUID, sha string) (ChangesetRow, error)
- func (q Q) ClaimByID(ctx context.Context, id uuid.UUID) (Claim, error)
- func (q Q) ClaimByPrefix(ctx context.Context, prefix string) (Claim, error)
- func (q Q) ClaimPush(ctx context.Context, principalID uuid.UUID, item string, at time.Time) (bool, error)
- func (q Q) ClearGitHubAppGap(ctx context.Context, what string) error
- func (q Q) CloseShipments(ctx context.Context, effortID uuid.UUID, state string) error
- func (q Q) CopyTokenSSO(ctx context.Context, from, to uuid.UUID) error
- func (q Q) CountCLILoginsSince(ctx context.Context, ip string, since time.Time) (int, error)
- func (q Q) CountLands(ctx context.Context, ref string, from, to time.Time) (int, error)
- func (q Q) CountObjectBackfills(ctx context.Context) (int64, error)
- func (q Q) CountObjectsWithoutSize(ctx context.Context) (int64, error)
- func (q Q) CountOrgsPendingPurge(ctx context.Context) (int64, error)
- func (q Q) CountOwners(ctx context.Context, org uuid.UUID) (int, error)
- func (q Q) CountPendingCLILogins(ctx context.Context, now time.Time) (int, error)
- func (q Q) CountRepoObjects(ctx context.Context, repoID uuid.UUID) (int, error)
- func (q Q) CreateCLILogin(ctx context.Context, l CLILogin) error
- func (q Q) CreateEffort(ctx context.Context, e Effort) (Effort, error)
- func (q Q) CreateInvite(ctx context.Context, login string, by *uuid.UUID, note string, siteAdmin bool) (SignupInvite, error)
- func (q Q) CreateLoginCode(ctx context.Context, codeHash []byte, principal uuid.UUID, ...) error
- func (q Q) CreateOrg(ctx context.Context, handle, displayName string, owner uuid.UUID) (Org, error)
- func (q Q) CreateOrgWithoutOwner(ctx context.Context, handle, displayName string) (Org, error)
- func (q Q) CreatePrincipal(ctx context.Context, p Principal) (Principal, error)
- func (q Q) CreateRepo(ctx context.Context, r Repo) (Repo, error)
- func (q Q) CreateTeam(ctx context.Context, org Org, name string) (Team, error)
- func (q Q) CreateToken(ctx context.Context, principalID uuid.UUID, name string) (string, error)
- func (q Q) CreateWorkspace(ctx context.Context, w Workspace) (Workspace, error)
- func (q Q) DecideReview(ctx context.Context, id uuid.UUID, state ReviewState, by uuid.UUID, ...) (bool, error)
- func (q Q) DeleteCLILoginsBefore(ctx context.Context, t time.Time) error
- func (q Q) DeleteClosedOverlaps(ctx context.Context, effortID uuid.UUID) error
- func (q Q) DeleteGitHubInstallation(ctx context.Context, id int64) error
- func (q Q) DeleteInvite(ctx context.Context, login string) (ok bool, err error)
- func (q Q) DeleteOpsBefore(ctx context.Context, t time.Time, batch int) (int64, error)
- func (q Q) DeleteOrgSSO(ctx context.Context, org uuid.UUID) (bool, error)
- func (q Q) DeletePushSubscription(ctx context.Context, principalID uuid.UUID, endpoint string) (bool, error)
- func (q Q) DeletePushSubscriptionByID(ctx context.Context, id uuid.UUID) error
- func (q Q) DeleteRepoGrant(ctx context.Context, repo uuid.UUID, principal, team *uuid.UUID) (string, error)
- func (q Q) DeleteSupportGrant(ctx context.Context, repo, person uuid.UUID) (SupportGrant, error)
- func (q Q) DeleteTeam(ctx context.Context, team uuid.UUID) error
- func (q Q) DeletedOrgByHandle(ctx context.Context, handle string, forUpdate bool) (Org, error)
- func (q Q) DeletedOrgGitHub(ctx context.Context, installationID, accountID int64) (string, bool, error)
- func (q Q) DeletedOrgsOwnedBy(ctx context.Context, person uuid.UUID) ([]Org, []OrgDeletion, error)
- func (q Q) DropGitHubCache(ctx context.Context, s GitHubCacheScope) (int64, error)
- func (q Q) EffortByID(ctx context.Context, id uuid.UUID) (Effort, error)
- func (q Q) ExistingRepoIDs(ctx context.Context, ids []uuid.UUID) (map[uuid.UUID]bool, error)
- func (q Q) FileChanges(ctx context.Context, repoID uuid.UUID, h hash.Hash) ([]FileChange, error)
- func (q Q) FinishObjectBackfill(ctx context.Context, repoID uuid.UUID) error
- func (q Q) FinishWorkspace(ctx context.Context, id uuid.UUID, state WorkspaceState, landedAs hash.Hash) error
- func (q Q) FinishedRebaseHeads(ctx context.Context, effortID uuid.UUID) ([]hash.Hash, error)
- func (q Q) ForgetGitHubDelivery(ctx context.Context, id string) error
- func (q Q) ForgetOrgSSOProofs(ctx context.Context, org uuid.UUID) error
- func (q Q) GetBranch(ctx context.Context, repoID uuid.UUID, name string) (Branch, error)
- func (q Q) GetChangeset(ctx context.Context, repoID uuid.UUID, h hash.Hash) (ChangesetRow, error)
- func (q Q) GetEffort(ctx context.Context, repoID uuid.UUID, slug string) (Effort, error)
- func (q Q) GetOrgQuota(ctx context.Context, orgID uuid.UUID) (OrgQuota, error)
- func (q Q) GetOverlap(ctx context.Context, a, b uuid.UUID) (EffortOverlap, error)
- func (q Q) GetReview(ctx context.Context, id uuid.UUID) (Review, error)
- func (q Q) GetReviewForUpdate(ctx context.Context, id uuid.UUID) (Review, error)
- func (q Q) GetServerNotice(ctx context.Context, key string) (ServerNotice, error)
- func (q Q) GetUpstreamSecrets(ctx context.Context, repoID uuid.UUID) (UpstreamSecrets, error)
- func (q Q) GetWorkspace(ctx context.Context, id uuid.UUID) (Workspace, error)
- func (q Q) GetWorkspaceForUpdate(ctx context.Context, id uuid.UUID) (Workspace, error)
- func (q Q) GitHashesFor(ctx context.Context, repoID uuid.UUID, vxHashes []hash.Hash) (map[hash.Hash]string, error)
- func (q Q) GitHubAccessFacts(ctx context.Context, repo uuid.UUID, since time.Time) ([]AccessFact, error)
- func (q Q) GitHubApp(ctx context.Context) (GitHubApp, error)
- func (q Q) GitHubAppGaps(ctx context.Context) ([]GitHubAppGap, error)
- func (q Q) GitHubBackedRepos(ctx context.Context, installations []int64, org *uuid.UUID) ([]Repo, error)
- func (q Q) GitHubInstallationByID(ctx context.Context, id int64) (GitHubInstallationRow, error)
- func (q Q) GitHubLinkOf(ctx context.Context, principalID uuid.UUID) (GitHubLink, bool, error)
- func (q Q) GitHubLinksOf(ctx context.Context, ids []uuid.UUID) (map[uuid.UUID]GitHubLink, error)
- func (q Q) GitHubMembershipCache(ctx context.Context, principal uuid.UUID) (map[int64]CachedRole, error)
- func (q Q) GitHubRoleCache(ctx context.Context, principal uuid.UUID, repos []uuid.UUID) (map[uuid.UUID]CachedRole, error)
- func (q Q) HandleTaken(ctx context.Context, handle string) (bool, error)
- func (q Q) IdentitiesOf(ctx context.Context, person uuid.UUID) ([]Identity, error)
- func (q Q) InitPushKey(ctx context.Context, k PushKey) (PushKey, error)
- func (q Q) InsertChangeset(ctx context.Context, repoID uuid.UUID, effortID *uuid.UUID, ...) (hash.Hash, error)
- func (q Q) InsertClaim(ctx context.Context, c Claim) (Claim, error)
- func (q Q) InsertNote(ctx context.Context, n Note) (Note, error)
- func (q Q) InsertReservation(ctx context.Context, repoID uuid.UUID, rule, value string, ...) (bool, error)
- func (q Q) InsertTask(ctx context.Context, t Task) (Task, error)
- func (q Q) IssueToken(ctx context.Context, principalID uuid.UUID, name string) (Token, string, error)
- func (q Q) KeepMovingClaims(ctx context.Context, workspaceID uuid.UUID, until time.Time) error
- func (q Q) LapseIdleClaims(ctx context.Context, effortID uuid.UUID, now, idleSince time.Time) ([]Claim, error)
- func (q Q) LatestRebase(ctx context.Context, effortID uuid.UUID) (Rebase, error)
- func (q Q) LearnShipmentPR(ctx context.Context, id uuid.UUID, number, url string) error
- func (q Q) LinkGitHub(ctx context.Context, principalID uuid.UUID, githubUserID int64, login string) error
- func (q Q) LinkIdentity(ctx context.Context, person uuid.UUID, issuer, subject, email string) error
- func (q Q) ListActorOps(ctx context.Context, actorID uuid.UUID, limit int) ([]Op, error)
- func (q Q) ListAgents(ctx context.Context, owner uuid.UUID) ([]Principal, error)
- func (q Q) ListAudit(ctx context.Context, f AuditFilter) ([]AuditEntry, error)
- func (q Q) ListBranches(ctx context.Context, repoID uuid.UUID) ([]Branch, error)
- func (q Q) ListChangesetTrees(ctx context.Context, repoID uuid.UUID) ([]ChangesetTrees, error)
- func (q Q) ListEffortOverlaps(ctx context.Context, effortID uuid.UUID) ([]EffortOverlap, error)
- func (q Q) ListEfforts(ctx context.Context, repoID uuid.UUID, state EffortState) ([]Effort, error)
- func (q Q) ListGitHubInstallations(ctx context.Context) ([]GitHubInstallationRow, error)
- func (q Q) ListInvites(ctx context.Context, all bool) ([]SignupInvite, error)
- func (q Q) ListNotes(ctx context.Context, f NoteFilter) ([]Note, error)
- func (q Q) ListOps(ctx context.Context, repoID uuid.UUID, limit int) ([]Op, error)
- func (q Q) ListOrgMembers(ctx context.Context, org uuid.UUID) ([]OrgMember, error)
- func (q Q) ListOrgs(ctx context.Context, person uuid.UUID, all bool) ([]OrgWithRole, error)
- func (q Q) ListPeople(ctx context.Context) ([]Principal, error)
- func (q Q) ListRepoGrants(ctx context.Context, repo uuid.UUID) ([]RepoGrant, error)
- func (q Q) ListRepoOverlaps(ctx context.Context, repoID uuid.UUID) ([]EffortOverlap, error)
- func (q Q) ListRepoRoleFacts(ctx context.Context, principal uuid.UUID, directOnly bool, org *uuid.UUID, ...) ([]Repo, []RoleFacts, error)
- func (q Q) ListRepos(ctx context.Context) ([]Repo, error)
- func (q Q) ListReservations(ctx context.Context, repoID uuid.UUID, rule string) ([]Reservation, error)
- func (q Q) ListReviews(ctx context.Context, f ReviewFilter) ([]Review, error)
- func (q Q) ListShipments(ctx context.Context, effortID uuid.UUID) ([]Shipment, error)
- func (q Q) ListSupportGrants(ctx context.Context, repo uuid.UUID, at time.Time) ([]SupportGrant, error)
- func (q Q) ListTargetOps(ctx context.Context, target string, limit int) ([]Op, error)
- func (q Q) ListTasks(ctx context.Context, f TaskFilter) ([]Task, error)
- func (q Q) ListTeams(ctx context.Context, org Org) ([]Team, error)
- func (q Q) ListTokens(ctx context.Context, principalIDs ...uuid.UUID) ([]Token, error)
- func (q Q) ListWorkspaces(ctx context.Context, effortID uuid.UUID, state WorkspaceState) ([]Workspace, error)
- func (q Q) LockOrg(ctx context.Context, handle string) (Org, error)
- func (q Q) LockOverlapPair(ctx context.Context, a, b uuid.UUID) error
- func (q Q) LockPrincipal(ctx context.Context, id uuid.UUID) error
- func (q Q) LockSystemNoteKey(ctx context.Context, effortID uuid.UUID, key string) error
- func (q Q) LogOp(ctx context.Context, repoID, actorID *uuid.UUID, op, target string, ...) error
- func (q Q) LoginCodeToken(ctx context.Context, codeHash []byte) (uuid.UUID, error)
- func (q Q) LookupGitObjects(ctx context.Context, repoID uuid.UUID, gitHashes []string) (map[string]hash.Hash, error)
- func (q Q) MarkNoteAnswered(ctx context.Context, id uuid.UUID) error
- func (q Q) MarkNotesRead(ctx context.Context, principal uuid.UUID, ids []uuid.UUID) error
- func (q Q) MarkOrgDeleted(ctx context.Context, org Org, by Principal, at, purgeAfter time.Time) (OrgDeletion, error)
- func (q Q) MarkPushResult(ctx context.Context, id uuid.UUID, at time.Time, failure string) error
- func (q Q) MarkServerNoticeLogged(ctx context.Context, key string) (bool, error)
- func (q Q) MarkTokenSSO(ctx context.Context, token, org uuid.UUID) error
- func (q Q) MergePeople(ctx context.Context, keep, merged uuid.UUID) (MergeStats, error)
- func (q Q) MergedPeople(ctx context.Context) (map[uuid.UUID]uuid.UUID, error)
- func (q Q) NoteByID(ctx context.Context, id uuid.UUID) (Note, error)
- func (q Q) NoteByPrefix(ctx context.Context, prefix string) (Note, error)
- func (q Q) NoteForUpdate(ctx context.Context, id uuid.UUID) (Note, error)
- func (q Q) NoteRepos(ctx context.Context, ids []uuid.UUID) (map[uuid.UUID]uuid.UUID, error)
- func (q Q) NotesRead(ctx context.Context, principal uuid.UUID, ids []uuid.UUID) (map[uuid.UUID]bool, error)
- func (q Q) ObjectBackfillPending(ctx context.Context, repoID uuid.UUID) (bool, error)
- func (q Q) ObjectBackfillQueue(ctx context.Context) ([]uuid.UUID, error)
- func (q Q) ObjectSizesKnown(ctx context.Context, hs []hash.Hash) (map[hash.Hash]bool, error)
- func (q Q) ObjectsWithoutSize(ctx context.Context, limit int) ([]hash.Hash, error)
- func (q Q) OnChain(ctx context.Context, repoID uuid.UUID, head, target hash.Hash, limit int) (bool, error)
- func (q Q) OpenEffortsOwnedBy(ctx context.Context, owners []uuid.UUID, limit int) ([]Effort, error)
- func (q Q) OpenInvite(ctx context.Context, login string) (SignupInvite, bool, error)
- func (q Q) OpenQuestionsCopiedTo(ctx context.Context, person uuid.UUID, limit int) ([]Note, error)
- func (q Q) OpenQuestionsTo(ctx context.Context, to []uuid.UUID, limit int) ([]Note, error)
- func (q Q) OpenWorkspacesOf(ctx context.Context, owner uuid.UUID) ([]Workspace, error)
- func (q Q) OrgAgreementByID(ctx context.Context, org, id uuid.UUID) (OrgAgreement, error)
- func (q Q) OrgAgreements(ctx context.Context, org uuid.UUID) ([]OrgAgreement, error)
- func (q Q) OrgAgreementsOf(ctx context.Context, orgs []uuid.UUID) ([]OrgAgreement, error)
- func (q Q) OrgByGitHubID(ctx context.Context, githubOrgID int64) (Org, error)
- func (q Q) OrgByHandle(ctx context.Context, handle string) (Org, error)
- func (q Q) OrgByID(ctx context.Context, id uuid.UUID) (Org, error)
- func (q Q) OrgDeletionByID(ctx context.Context, orgID uuid.UUID) (OrgDeletion, error)
- func (q Q) OrgDeletionsByHandle(ctx context.Context, handle string) ([]OrgDeletion, error)
- func (q Q) OrgObjectHashes(ctx context.Context, orgID uuid.UUID) (own, shared []hash.Hash, err error)
- func (q Q) OrgRecordIDs(ctx context.Context, orgID uuid.UUID) ([]uuid.UUID, error)
- func (q Q) OrgRole(ctx context.Context, org, person uuid.UUID) (string, error)
- func (q Q) OrgSSOOf(ctx context.Context, org uuid.UUID) (OrgSSO, bool, error)
- func (q Q) OrgStoredBytes(ctx context.Context, orgID uuid.UUID) (int64, error)
- func (q Q) OrgUsage(ctx context.Context, orgID uuid.UUID) (repos, openEfforts int64, err error)
- func (q Q) OrgsBySSODomain(ctx context.Context, domain string) ([]Org, error)
- func (q Q) OrgsDueForPurge(ctx context.Context, at time.Time) ([]uuid.UUID, error)
- func (q Q) OrgsWithRepos(ctx context.Context, orgs []uuid.UUID) (map[uuid.UUID]bool, error)
- func (q Q) OverdueQuestions(ctx context.Context, owner uuid.UUID, to []uuid.UUID, now time.Time, limit int) ([]Note, error)
- func (q Q) OverlapCounts(ctx context.Context, repoID uuid.UUID) (map[uuid.UUID][2]int, error)
- func (q Q) PeekLoginCode(ctx context.Context, codeHash []byte, now time.Time) (uuid.UUID, error)
- func (q Q) PendingBackfillsOutside(ctx context.Context, repos []uuid.UUID) (int64, error)
- func (q Q) PendingReviewOf(ctx context.Context, workspace uuid.UUID) (Review, error)
- func (q Q) PeopleByEmail(ctx context.Context, email string) ([]Principal, error)
- func (q Q) PersonByIdentity(ctx context.Context, issuer, subject string) (Principal, error)
- func (q Q) PrincipalByGitHubID(ctx context.Context, githubUserID int64) (Principal, error)
- func (q Q) PrincipalByGitHubLogin(ctx context.Context, login string) (Principal, error)
- func (q Q) PrincipalByHandle(ctx context.Context, handle string) (Principal, error)
- func (q Q) PrincipalByID(ctx context.Context, id uuid.UUID) (Principal, error)
- func (q Q) PrincipalDisabled(ctx context.Context, id uuid.UUID) (disabled bool, into *uuid.UUID, err error)
- func (q Q) PruneBlobDeletions(ctx context.Context, keep time.Duration) error
- func (q Q) PrunePushSent(ctx context.Context, before time.Time) error
- func (q Q) PurgeLeftovers(ctx context.Context, ids []uuid.UUID, hashes [][]byte) ([]string, error)
- func (q Q) PushKey(ctx context.Context) (PushKey, error)
- func (q Q) PushRecipients(ctx context.Context) ([]uuid.UUID, error)
- func (q Q) PushSubscriptions(ctx context.Context, principalID uuid.UUID) ([]PushSubscription, error)
- func (q Q) PutGitHubApp(ctx context.Context, a GitHubApp) error
- func (q Q) PutGitHubMembership(ctx context.Context, githubOrgID int64, principal uuid.UUID, role string, ...) error
- func (q Q) PutGitHubRole(ctx context.Context, repo, principal uuid.UUID, role string, ...) error
- func (q Q) PutOrgSSO(ctx context.Context, c OrgSSO) (OrgSSO, error)
- func (q Q) PutShipmentCheck(ctx context.Context, c ShipmentCheck) error
- func (q Q) PutSystemNoteKey(ctx context.Context, k SystemNoteKey) error
- func (q Q) QueueObjectBackfill(ctx context.Context, repoID uuid.UUID) error
- func (q Q) QueueObjectBackfills(ctx context.Context) (int, error)
- func (q Q) QuotaOrg(ctx context.Context, id uuid.UUID) (Org, error)
- func (q Q) ReadableRepoIDs(ctx context.Context, principal uuid.UUID, directOnly bool, at time.Time) ([]uuid.UUID, error)
- func (q Q) RebaseEffort(ctx context.Context, id uuid.UUID, seenVersion int64, baseBranch string, ...) (bool, error)
- func (q Q) RecordGitHubDelivery(ctx context.Context, id, event string, keep time.Duration) (fresh bool, err error)
- func (q Q) RecordObjectSizes(ctx context.Context, sizes []ObjectSize) error
- func (q Q) ReleaseClaim(ctx context.Context, id uuid.UUID, now time.Time) (Claim, bool, error)
- func (q Q) ReleaseWorkspaceClaims(ctx context.Context, workspaceID uuid.UUID, owner *uuid.UUID, now time.Time) ([]Claim, error)
- func (q Q) RemoveOrgMember(ctx context.Context, org, person uuid.UUID) (bool, error)
- func (q Q) RemoveTeamMember(ctx context.Context, team, person uuid.UUID) (bool, error)
- func (q Q) RepoAccessFacts(ctx context.Context, repo uuid.UUID) ([]AccessFact, error)
- func (q Q) RepoByGitHubID(ctx context.Context, githubRepoID int64) (Repo, error)
- func (q Q) RepoByID(ctx context.Context, id uuid.UUID) (Repo, error)
- func (q Q) RepoByName(ctx context.Context, name string) (Repo, error)
- func (q Q) RepoObjectsMissing(ctx context.Context, repoID uuid.UUID, hashes []hash.Hash) ([]hash.Hash, error)
- func (q Q) RepoRoleFacts(ctx context.Context, name string, principal uuid.UUID, directOnly bool, ...) (Repo, RoleFacts, error)
- func (q Q) RepoRoleFactsByID(ctx context.Context, id, principal uuid.UUID, directOnly bool, at time.Time) (Repo, RoleFacts, error)
- func (q Q) RepoStoredBytes(ctx context.Context, repoID uuid.UUID) (int64, error)
- func (q Q) ReposByRemote(ctx context.Context, remote string, providers ...Provider) ([]Repo, error)
- func (q Q) ReposOfGitHubInstallation(ctx context.Context, installationID int64) ([]Repo, error)
- func (q Q) ResetObjectIndex(ctx context.Context, repoID uuid.UUID) error
- func (q Q) ResolveChangeset(ctx context.Context, repoID uuid.UUID, ref string) (ChangesetRow, error)
- func (q Q) ResolveServerNotice(ctx context.Context, key string, by uuid.UUID) (bool, error)
- func (q Q) RestoreDeletedOrg(ctx context.Context, orgID uuid.UUID) error
- func (q Q) ReviewByPrefix(ctx context.Context, prefix string, repos []uuid.UUID) (Review, error)
- func (q Q) RevokeToken(ctx context.Context, id uuid.UUID) (t Token, revoked bool, err error)
- func (q Q) SSOBlocked(ctx context.Context, org, token uuid.UUID) (bool, error)
- func (q Q) SaveGitObjects(ctx context.Context, repoID uuid.UUID, objs []GitObject) error
- func (q Q) SaveOverlap(ctx context.Context, o EffortOverlap) error
- func (q Q) SavePushSubscription(ctx context.Context, s PushSubscription) (PushSubscription, error)
- func (q Q) SaveShipment(ctx context.Context, s Shipment) (Shipment, error)
- func (q Q) SetAgentScope(ctx context.Context, s AgentScope) error
- func (q Q) SetBranchIfUnchanged(ctx context.Context, b Branch, fromSHA string, tracked bool) (bool, error)
- func (q Q) SetCLILoginApprover(ctx context.Context, deviceHash []byte, token uuid.UUID) error
- func (q Q) SetCLILoginStatus(ctx context.Context, deviceHash []byte, from, to string, ...) (bool, error)
- func (q Q) SetChangesetWarnings(ctx context.Context, repoID uuid.UUID, h hash.Hash, ws []Warning) error
- func (q Q) SetDisplayName(ctx context.Context, principalID uuid.UUID, name string) error
- func (q Q) SetEffortState(ctx context.Context, id uuid.UUID, state EffortState) error
- func (q Q) SetLoginCodeToken(ctx context.Context, codeHash []byte, token uuid.UUID) error
- func (q Q) SetOrgGitHub(ctx context.Context, org uuid.UUID, githubOrgID *int64, login string) error
- func (q Q) SetOrgMember(ctx context.Context, org, person uuid.UUID, role string) error
- func (q Q) SetOrgQuota(ctx context.Context, o OrgQuota) error
- func (q Q) SetPurgeStep(ctx context.Context, orgID uuid.UUID, step string) error
- func (q Q) SetRepoGitHub(ctx context.Context, repo uuid.UUID, githubRepoID, installationID *int64) error
- func (q Q) SetRepoGrant(ctx context.Context, repo uuid.UUID, principal, team *uuid.UUID, role string) (string, error)
- func (q Q) SetRepoUpstream(ctx context.Context, repoID uuid.UUID, remote, defaultBranch string) error
- func (q Q) SetReviewConflicts(ctx context.Context, id uuid.UUID, paths []string, by uuid.UUID, at time.Time) error
- func (q Q) SetShipmentCI(ctx context.Context, c ShipmentCI) error
- func (q Q) SetShipmentState(ctx context.Context, id uuid.UUID, state string) error
- func (q Q) SetSiteAdmin(ctx context.Context, person uuid.UUID, admin bool) error
- func (q Q) SetSupportGrant(ctx context.Context, repo, person uuid.UUID, role string, expires time.Time, ...) (*SupportGrant, error)
- func (q Q) SetTaskState(ctx context.Context, id uuid.UUID, state string, owner *uuid.UUID, ...) error
- func (q Q) SetUpstreamToken(ctx context.Context, repoID uuid.UUID, sealed []byte) error
- func (q Q) SetUpstreamWebhookSecret(ctx context.Context, repoID uuid.UUID, sealed []byte) error
- func (q Q) SetWelcomeDismissed(ctx context.Context, principalID uuid.UUID, dismissed bool) error
- func (q Q) SetWorkspaceBase(ctx context.Context, id uuid.UUID, base hash.Hash) error
- func (q Q) SetWorkspaceChangedPaths(ctx context.Context, id uuid.UUID, paths []string, at time.Time) error
- func (q Q) ShipmentByBranch(ctx context.Context, repoID uuid.UUID, branch string) (Shipment, error)
- func (q Q) ShipmentByPR(ctx context.Context, repoID uuid.UUID, number, branch string) (ShipmentRef, error)
- func (q Q) ShipmentCIs(ctx context.Context, ids []uuid.UUID) (map[uuid.UUID]ShipmentCI, error)
- func (q Q) ShipmentChecks(ctx context.Context, shipmentID uuid.UUID, sha string) ([]ShipmentCheck, error)
- func (q Q) ShipmentsByHeadSHA(ctx context.Context, repoID uuid.UUID, sha string) ([]ShipmentRef, error)
- func (q Q) StartRebase(ctx context.Context, r Rebase) (Rebase, error)
- func (q Q) SubmitReview(ctx context.Context, r Review) (Review, error)
- func (q Q) SystemNoteKey(ctx context.Context, effortID uuid.UUID, key string) (SystemNoteKey, error)
- func (q Q) SystemNotesTo(ctx context.Context, to []uuid.UUID, since time.Time, limit int) ([]Note, error)
- func (q Q) TaskByID(ctx context.Context, id uuid.UUID) (Task, error)
- func (q Q) TaskByPrefix(ctx context.Context, effort uuid.UUID, prefix string) (Task, error)
- func (q Q) TaskDependents(ctx context.Context, task uuid.UUID) ([]Task, error)
- func (q Q) TaskForUpdate(ctx context.Context, id uuid.UUID) (Task, error)
- func (q Q) TeamByName(ctx context.Context, org Org, name string) (Team, error)
- func (q Q) TokenByID(ctx context.Context, id uuid.UUID) (Token, error)
- func (q Q) TokenOwner(ctx context.Context, token uuid.UUID) (uuid.UUID, bool, error)
- func (q Q) TokenSSOOrgs(ctx context.Context, token uuid.UUID) ([]uuid.UUID, error)
- func (q Q) TouchCLILoginPoll(ctx context.Context, deviceHash []byte, at time.Time) error
- func (q Q) TouchIdentity(ctx context.Context, issuer, subject, email string) error
- func (q Q) TouchWorkspace(ctx context.Context, id uuid.UUID, at time.Time) error
- func (q Q) UpdateOrg(ctx context.Context, id uuid.UUID, displayName, defaultRole *string) (Org, error)
- func (q Q) UpdateRebase(ctx context.Context, r Rebase, seenVersion int64) (bool, error)
- func (q Q) UpsertBranch(ctx context.Context, b Branch) error
- func (q Q) UpsertGitHubInstallation(ctx context.Context, in GitHubInstallationRow) error
- func (q Q) UseInvite(ctx context.Context, login string) (ok bool, err error)
- func (q Q) UseLoginCode(ctx context.Context, codeHash []byte, now time.Time) (uuid.UUID, error)
- func (q Q) UseNonce(ctx context.Context, key string, expires time.Time) (bool, error)
- func (q Q) WelcomeDismissed(ctx context.Context, principalID uuid.UUID) (bool, error)
- func (q Q) WithdrawReviews(ctx context.Context, workspace uuid.UUID) error
- type Rebase
- type RebaseConflict
- type RebaseState
- type Replayed
- type Repo
- type RepoGrant
- type Reservation
- type Review
- type ReviewFilter
- type ReviewState
- type RoleFacts
- type ServerNotice
- type Shipment
- type ShipmentCI
- type ShipmentChange
- type ShipmentCheck
- type ShipmentRef
- type SignupInvite
- type Store
- func (s *Store) Close()
- func (s *Store) InTx(ctx context.Context, fn func(tx *Tx) error) error
- func (s *Store) Migrate(ctx context.Context) error
- func (s *Store) MigrateTo(ctx context.Context, upTo int) error
- func (s *Store) Ping(ctx context.Context) error
- func (s *Store) PoolStat() *pgxpool.Stat
- func (s *Store) PurgeOrgRows(ctx context.Context, orgID uuid.UUID, handle string, at time.Time) (OrgDeletion, error)
- func (s *Store) PurgeRepoObjects(ctx context.Context, orgID, repoID uuid.UUID, purged []uuid.UUID) (int, error)
- func (s *Store) PurgeRepoRow(ctx context.Context, orgID, repoID uuid.UUID) error
- func (s *Store) PurgeRepoStep(ctx context.Context, orgID, repoID uuid.UUID, i int) (n int64, ok bool, err error)
- func (s *Store) PurgeTarget(ctx context.Context, orgID uuid.UUID, by string, at time.Time) (PurgeOrgRow, error)
- func (s *Store) RecordRepoObjects(ctx context.Context, repoID uuid.UUID, hashes []hash.Hash, ...) ([]hash.Hash, error)
- func (s *Store) SweepBlobs(ctx context.Context, orgID *uuid.UUID, limit int, ...) (deleted, handled int, err error)
- func (s *Store) TryPurgeLock(ctx context.Context) (alive func(context.Context) bool, unlock func(), ok bool, err error)
- type SupportGrant
- type SystemNoteKey
- type Task
- type TaskFilter
- type Team
- type Token
- type Tx
- type UpstreamSecrets
- type Warning
- type Workspace
- type WorkspaceState
Constants ¶
const DefaultOrg = "default"
DefaultOrg is the organization repositories without an owner part were put in when organizations arrived, and where CreateRepo puts a repo whose OrgID is not set.
const TokenPrefix = "vxt_"
TokenPrefix starts every vx token, so leaked tokens are easy to spot.
Variables ¶
var ErrAmbiguous = errors.New("ambiguous")
ErrAmbiguous is returned when an id prefix matches more than one row.
var ErrCycle = errors.New("dependency cycle")
ErrCycle is returned when a task dependency would make tasks wait for each other.
var ErrExists = errors.New("already exists")
ErrExists is returned when a unique row already exists.
var ErrNotFound = errors.New("not found")
ErrNotFound is returned when a row does not exist.
var ErrPurgeStarted = errors.New("its purge has started")
ErrPurgeStarted is returned when restoring an organization whose purge has begun.
var PurgeBatch = 5000
PurgeBatch is how many rows one purge transaction deletes.
Functions ¶
func BlobLockKey ¶ added in v0.6.0
BlobLockKey is the advisory lock key of one object's hash, shared by the purge (exclusive, while it checks and deletes) and recording (shared, while it checks an object a purge marked).
func OrderPair ¶ added in v0.3.0
OrderPair returns a and b in the order effort_overlaps stores them.
func ValidateHandle ¶
func ValidateHandle(kind PrincipalKind, handle string) error
ValidateHandle checks a handle: lowercase name, and for agents "owner/name".
func ValidateRepoName ¶
ValidateRepoName checks names like "shop-api" or "acme/shop-api".
Types ¶
type AccessFact ¶ added in v0.2.0
type AccessFact struct {
Principal Principal
Role string // read, write or admin
Via string // "org owner", "org admin", "org default", "user:alice", "team:acme/backend"
}
AccessFact is one source of a principal's role on a repository, for listing who has access and why.
type AgentScope ¶ added in v0.4.0
type AgentScope struct {
AgentID uuid.UUID
Allow []string // globs; empty: every path the agent's person may change
Deny []string // globs; win over Allow
MaxLandsPerDay int
MaxLines int // changed lines (added + deleted) per land
MaxFiles int // changed files per land
MaxWorkspaces int // open workspaces at once
UpdatedBy *uuid.UUID
UpdatedAt time.Time
}
AgentScope limits what an agent may change and how much (agent_scopes). The zero value has no limits; zero budgets mean no limit.
func (AgentScope) Unlimited ¶ added in v0.4.0
func (s AgentScope) Unlimited() bool
Unlimited reports whether the scope limits nothing.
type AuditEntry ¶ added in v0.5.0
type AuditEntry struct {
ID int64
At time.Time
Op string
Target string
RepoID *uuid.UUID
Repo string // repository name, "" for server-level entries
Org string // the repository's organization, or the organization an org-level entry is about
ActorID *uuid.UUID
Actor string // principal ref; "" for the server itself
Before json.RawMessage
After json.RawMessage
}
AuditEntry is one operation log entry with the names of what it refers to.
type AuditFilter ¶ added in v0.5.0
type AuditFilter struct {
// Org limits to the organization's repositories and to the
// organization-level entries about it (org.*, team.*, github.org.*
// with the organization as target). OrgHandle must be its handle.
Org *uuid.UUID
OrgHandle string
Repo *uuid.UUID
Actor *uuid.UUID
Since time.Time // at >= Since
Until time.Time // at < Until
AfterID int64 // id > AfterID, for paging
Limit int
Desc bool // newest first
// Payload also reads before and after. Without it they stay nil and
// never leave the database. With ServerPayloadOnly, only those of
// entries without a repository are read.
Payload bool
ServerPayloadOnly bool
}
AuditFilter selects operation log entries for an export. Zero fields do not filter.
type Branch ¶
type Branch struct {
RepoID uuid.UUID
Name string
Head hash.Hash // changeset
GitSHA string
SyncedAt time.Time
}
Branch is an upstream branch that vx follows.
type CLILogin ¶ added in v0.2.0
type CLILogin struct {
DeviceHash []byte
UserCode string
ClientName string
Status string // pending, approved, denied, used
PrincipalID *uuid.UUID
ClientIP string
ExpiresAt time.Time
CreatedAt time.Time
LastPolledAt *time.Time
DecidedAt *time.Time
// HasSecret is true when token_secret_enc is set; vx never sets it (the
// token is created when the CLI collects it).
HasSecret bool
}
CLILogin is a browser login of the CLI (table cli_logins). The device code is known only by its sha256.
type CachedRole ¶ added in v0.2.0
CachedRole is what GitHub said, and when.
type ChangesetRow ¶
type ChangesetRow struct {
Hash hash.Hash
RepoID uuid.UUID
EffortID *uuid.UUID
*object.Changeset
// Warnings the server found in the tree when the change landed. They
// are not part of the changeset's encoding or hash.
Warnings []Warning
}
ChangesetRow is a changeset with the metadata vx keeps beside it.
type ChangesetTrees ¶ added in v0.2.0
type ChangesetTrees struct {
Hash hash.Hash
FirstParent hash.Hash
Tree hash.Hash
SnapshotTree hash.Hash // the uploaded snapshot of a merged land, else zero
}
ChangesetTrees is the tree information of one changeset, for walking every tree in a repo.
type Claim ¶ added in v0.2.0
type Claim struct {
ID uuid.UUID
RepoID uuid.UUID
EffortID uuid.UUID
OwnerID uuid.UUID
WorkspaceID *uuid.UUID
Targets []string
Reason string
CreatedAt time.Time
ExpiresAt time.Time
ReleasedAt *time.Time
RepoName string
EffortSlug string
// WorkspaceOpen is read from the workspace the claim is tied to.
WorkspaceOpen bool
// MovingTo is where the claimed code is being moved (vx claim
// --moving pkg.Func --to path); empty for other claims.
MovingTo string
}
Claim is a stored claim. RepoName and EffortSlug are read from the claim's repo and effort. A claim is active while ReleasedAt is nil and either ExpiresAt is after now or the workspace it is tied to is open: a workspace's claims last as long as the workspace.
type Effort ¶
type Effort struct {
ID uuid.UUID
RepoID uuid.UUID
Slug string
Name string
Goal string
BaseBranch string
Base hash.Hash // upstream changeset the effort sits on
Head hash.Hash
Version int64
State EffortState
OwnerID uuid.UUID
CreatedAt time.Time
UpdatedAt time.Time
}
Effort is a shared line of work that agents land changes into.
type EffortOverlap ¶ added in v0.3.0
type EffortOverlap struct {
RepoID uuid.UUID
EffortA uuid.UUID
EffortB uuid.UUID
Status string // clean, overlap, conflict
Conflicts []string
Warnings []Warning
AHead string // changeset hashes the forecast was computed for
BHead string
TargetHead string // the base branch head both were replayed onto
ANote *uuid.UUID
BNote *uuid.UUID
CheckedAt time.Time
}
EffortOverlap is a stored forecast of what happens when two open efforts of one repository both ship. EffortA < EffortB (byte order of the ids).
type EffortState ¶
type EffortState string
EffortState is the lifecycle state of an effort.
const ( EffortOpen EffortState = "open" EffortShipping EffortState = "shipping" EffortMerged EffortState = "merged" EffortAbandoned EffortState = "abandoned" )
type FileChange ¶
FileChange is a changed path recorded with a changeset, with line counts.
type GitHubApp ¶ added in v0.2.0
type GitHubApp struct {
AppID int64
Slug string
HTMLURL string
ClientID string
ClientSecretEnc []byte
PrivateKeyEnc []byte
WebhookSecretEnc []byte
CreatedBy *uuid.UUID
CreatedAt time.Time
}
GitHubApp is the row of this server's GitHub App. The _Enc fields hold ciphertext sealed with the server key (internal/secret), never plaintext.
type GitHubAppGap ¶ added in v0.4.0
GitHubAppGap is a permission or event the App lacks.
type GitHubCacheScope ¶ added in v0.2.0
type GitHubCacheScope struct {
RepoID *uuid.UUID
GitHubRepoID int64
GitHubOrgID int64
GitHubUserID int64
InstallationID int64
}
GitHubCacheScope selects cached GitHub answers to drop. Every set field adds its own rows (the fields are OR-ed): RepoID or GitHubRepoID that repository's roles; GitHubOrgID the roles on every repository of installations on that account and memberships in it; GitHubUserID every row of the person linked to that GitHub user; InstallationID the roles on every repository of that installation and memberships in its account.
type GitHubInstallationRow ¶ added in v0.2.0
type GitHubInstallationRow struct {
ID int64
AccountID int64
AccountLogin string
AccountType string // Organization or User
OrgID *uuid.UUID
RepositorySelection string
SuspendedAt *time.Time
}
GitHubInstallationRow is an installation of the App as vx records it.
type GitHubLink ¶ added in v0.2.0
GitHubLink is the GitHub account a person signs in with.
type Identity ¶ added in v0.5.0
type Identity struct {
Issuer, Subject string
PersonID uuid.UUID
Email string
CreatedAt time.Time
LastUsedAt *time.Time
}
Identity is a person's account at an identity provider.
type MergeStats ¶ added in v0.5.0
MergeStats is what MergePeople moved.
type Note ¶ added in v0.2.0
type Note struct {
ID uuid.UUID
Seq int64 // insertion order; breaks ties between equal created_at
RepoID uuid.UUID
EffortID uuid.UUID
ThreadID uuid.UUID // the root note; equals ID for a root
Kind string
Targets []string
AuthorID uuid.UUID
ToID *uuid.UUID
Body string
State string // open, answered, closed; "escalated" is computed by readers
AnswerBy *time.Time
CreatedAt time.Time
RepoName string
EffortSlug string
// Supersedes is the earlier note this one replaces. SupersededBy is read
// from the newest note that replaced this one.
Supersedes *uuid.UUID
SupersededBy *uuid.UUID
System bool // posted by vx itself
// CCID is the person a question was copied to because the agent it is
// addressed to was not working when it was asked.
CCID *uuid.UUID
}
Note is a stored board note. RepoName and EffortSlug are read from the note's repo and effort.
func (Note) Cursor ¶ added in v0.2.0
func (n Note) Cursor() *NoteCursor
Cursor returns the position right after n.
type NoteCursor ¶ added in v0.2.0
NoteCursor is a position in a newest-first listing: the listing continues with notes older than it.
type NoteFilter ¶ added in v0.2.0
type NoteFilter struct {
EffortID uuid.UUID
Kinds []string
Since time.Time // created at or after
ThreadID uuid.UUID
Before *NoteCursor
Limit int // 0: 100
// Current leaves out notes a newer note superseded.
Current bool
}
NoteFilter selects an effort's notes. Zero fields do not filter.
type ObjectSize ¶ added in v0.5.0
ObjectSize is the bytes one object takes in the blob store.
type Op ¶
type Op struct {
ID int64
RepoID *uuid.UUID
ActorID *uuid.UUID
Op string
Target string
Before json.RawMessage
After json.RawMessage
At time.Time
}
Op is one entry in the operation log.
type Org ¶ added in v0.2.0
type Org struct {
ID uuid.UUID
Handle string
DisplayName string
DefaultRepoRole string // none, read or write
Personal bool
CreatedAt time.Time
// GitHubOrgID and GitHubLogin are set for an organization linked to a
// GitHub organization: its membership follows GitHub.
GitHubOrgID *int64
GitHubLogin string
}
Org is an organization. Every repository belongs to one.
func (Org) GitHubLinked ¶ added in v0.2.0
GitHubLinked reports whether o follows a GitHub organization.
type OrgAgreement ¶ added in v0.6.0
type OrgAgreement struct {
ID uuid.UUID
OrgID uuid.UUID
VersionID string
SHA256 string // of the text as accepted, hex
AcceptedBy *uuid.UUID
AcceptedByRef string // "user:alice", kept when the person is merged or removed
AcceptedAt time.Time
IP string
}
OrgAgreement is one acceptance of a version of the data processing agreement for an organization.
type OrgDeletion ¶ added in v0.6.0
type OrgDeletion struct {
OrgID uuid.UUID
Handle string
RequestedBy string // principal ref
DeletedAt time.Time
PurgeAfter time.Time
PurgeStarted *time.Time
PurgedAt *time.Time
PurgedBy string // "schedule" or "console"
Step string
Counts map[string]int64
}
OrgDeletion is the record of an organization's deletion. It names no repository and holds no content.
type OrgQuota ¶ added in v0.5.0
type OrgQuota struct {
OrgID uuid.UUID
Repos *int64
StoredBytes *int64
ImportBytes *int64
PushBytes *int64
OpenEfforts *int64
UpdatedBy *uuid.UUID
UpdatedAt time.Time
}
OrgQuota is an organization's override of the server's quotas. A nil field keeps the server's default; 0 means no limit.
type OrgSSO ¶ added in v0.5.0
type OrgSSO struct {
OrgID uuid.UUID
Issuer string
ClientID string
ClientSecretEnc []byte
AllowedDomains []string
RequireSSO bool
UpdatedBy *uuid.UUID
UpdatedAt time.Time
}
OrgSSO is an organization's identity provider configuration.
type OrgWithRole ¶ added in v0.2.0
OrgWithRole is an organization and a person's role in it ("" when not a member).
type Principal ¶
type Principal struct {
ID uuid.UUID
Kind PrincipalKind
Handle string // "alice" or "alice/claude-backend"
ParentID *uuid.UUID
DisplayName string
Email string
SiteAdmin bool // may manage people and every organization (humans only)
CreatedAt time.Time
}
Principal is a human, an agent acting for a human, or a service account.
type PrincipalKind ¶
type PrincipalKind string
PrincipalKind is the type of an identity.
const ( KindHuman PrincipalKind = "human" KindAgent PrincipalKind = "agent" KindService PrincipalKind = "service" )
type Provider ¶
type Provider string
Provider is where a repo's upstream lives.
const ( ProviderGitHub Provider = "github" // remote is "owner/name" ProviderGit Provider = "git" // remote is a git URL or path ProviderNone Provider = "none" // vx only, nothing to sync or ship to // Hosts with a pull request API besides GitHub; remote is the path on // the host ("group/project", "owner/repo", "workspace/repo") and // BaseURL the host's web address. ProviderGitLab Provider = "gitlab" ProviderGitea Provider = "gitea" ProviderForgejo Provider = "forgejo" ProviderBitbucket Provider = "bitbucket" )
func (Provider) HostName ¶ added in v0.4.0
HostName is the provider as people call it: "GitHub", "GitLab", ...
type PurgeOrgRow ¶ added in v0.6.0
type PurgeOrgRow struct {
Org
Deletion OrgDeletion
Repos []uuid.UUID
}
PurgeOrgRow is a deleted organization as the purge sees it.
type PushKey ¶ added in v0.5.0
type PushKey struct {
PrivateKeyEnc []byte // sealed 32-byte P-256 scalar
PublicKey string // base64url uncompressed point
CreatedAt time.Time
}
PushKey is the server's VAPID key (push_keys).
type PushSubscription ¶ added in v0.5.0
type PushSubscription struct {
ID uuid.UUID
PrincipalID uuid.UUID
Endpoint string
P256dh string
Auth string
Device string
CreatedAt time.Time
LastSentAt *time.Time
LastError string
}
PushSubscription is a browser that receives a person's notifications.
type Q ¶
type Q struct {
// contains filtered or unexported fields
}
Q holds the query methods. Store and Tx both embed it, so every query can run on its own or inside a transaction.
func (Q) AcceptOrgAgreement ¶ added in v0.6.0
func (q Q) AcceptOrgAgreement(ctx context.Context, a OrgAgreement, text []byte) (out OrgAgreement, created bool, err error)
AcceptOrgAgreement records an acceptance and keeps the text it was for. Accepting a version the organization accepted before returns that acceptance unchanged, with created false.
func (Q) AcceptedAgreementHashes ¶ added in v0.6.0
AcceptedAgreementHashes returns, for every version id anyone accepted, the hashes of the texts accepted under it (one, unless the operator changed a published text).
func (Q) ActiveClaims ¶ added in v0.2.0
ActiveClaims lists an effort's claims active at now, oldest first.
func (Q) ActiveRebase ¶ added in v0.2.0
ActiveRebase returns the effort's running or stopped rebase.
func (Q) AddGitHubAppGap ¶ added in v0.4.0
AddGitHubAppGap records that GitHub refused a call for want of what.
func (Q) AddPurgeCounts ¶ added in v0.6.0
AddPurgeCounts adds to what a purge removed.
func (Q) AddRepoObjects ¶ added in v0.2.0
AddRepoObjects records that the objects are part of the repo. Recording an object twice is a no-op. Only membership is per repo: the bytes are stored once in the blob store.
func (Q) AddServerNotice ¶ added in v0.5.0
AddServerNotice opens a notice (tests and future upgrades); an existing one is left as it is.
func (Q) AddTaskDeps ¶ added in v0.2.0
AddTaskDeps makes task wait for each of deps. It returns ErrCycle, adding nothing, when one of deps already waits (directly or not) for task. Callers run it in a transaction with the task's other changes.
func (Q) AddTeamMember ¶ added in v0.2.0
AddTeamMember adds person to team. The person must be a member of the team's organization (ErrNotFound otherwise).
func (Q) AdoptChangesets ¶ added in v0.2.0
AdoptChangesets marks changesets as part of an effort; a rebase stores its replayed changes without an effort until it finishes.
func (Q) AdvanceEffort ¶
func (q Q) AdvanceEffort(ctx context.Context, id uuid.UUID, seenVersion int64, newHead hash.Hash) (bool, error)
AdvanceEffort moves the effort head with a compare-and-swap on version. It reports false when another writer moved the head first.
func (Q) AgentScope ¶ added in v0.4.0
AgentScope returns the scope of an agent; the zero value (with AgentID set) when none was ever set.
func (Q) AgreementText ¶ added in v0.6.0
AgreementText returns an accepted text by its SHA-256.
func (Q) AnswersToQuestionsBy ¶ added in v0.2.0
func (q Q) AnswersToQuestionsBy(ctx context.Context, author uuid.UUID, since time.Time, limit int) ([]Note, error)
AnswersToQuestionsBy returns answers created at or after since in threads whose root is a question asked by author, newest first.
func (Q) Authenticate ¶
Authenticate resolves a token to its principal.
func (Q) AuthenticateToken ¶ added in v0.2.0
AuthenticateToken resolves a token to its principal and also returns the token's id, so callers know which token a request was made with.
func (Q) CLILoginApprover ¶ added in v0.5.0
CLILoginApprover is the token that approved a CLI login (uuid.Nil when unknown).
func (Q) CLILoginByDevice ¶ added in v0.2.0
CLILoginByDevice returns a login by device hash, locked for update when run in a transaction.
func (Q) CLILoginByUserCode ¶ added in v0.2.0
CLILoginByUserCode returns a login by user code, locked for update when run in a transaction.
func (Q) Chain ¶
func (q Q) Chain(ctx context.Context, repoID uuid.UUID, head, stop hash.Hash, limit int) ([]ChangesetRow, error)
Chain returns changesets from head back along first parents, stopping before stop (exclusive) or after limit rows. Newest first.
func (Q) ChainLength ¶ added in v0.2.0
func (q Q) ChainLength(ctx context.Context, repoID uuid.UUID, head, stop hash.Hash, limit int) (int, error)
ChainLength counts the changesets Chain would return, without loading them: from head back along first parents, stopping before stop or after limit.
func (Q) ChangesetByGitSHA ¶
func (q Q) ChangesetByGitSHA(ctx context.Context, repoID uuid.UUID, sha string) (ChangesetRow, error)
ChangesetByGitSHA finds the changeset imported from a git commit.
func (Q) ClaimByPrefix ¶ added in v0.2.0
ClaimByPrefix finds the one claim whose id starts with prefix (lowercase hex and dashes). It returns ErrNotFound or ErrAmbiguous otherwise.
func (Q) ClaimPush ¶ added in v0.5.0
func (q Q) ClaimPush(ctx context.Context, principalID uuid.UUID, item string, at time.Time) (bool, error)
ClaimPush records that item is pushed to a principal and reports whether this caller is the first: only the first sends.
func (Q) ClearGitHubAppGap ¶ added in v0.4.0
ClearGitHubAppGap forgets a gap (a call that needed it succeeded); an empty what forgets them all (a new App).
func (Q) CloseShipments ¶ added in v0.3.0
CloseShipments sets the state of an effort's open shipments (merged when the effort was merged, closed when it was abandoned).
func (Q) CopyTokenSSO ¶ added in v0.5.0
CopyTokenSSO gives token to the sign-on marks of token from.
func (Q) CountCLILoginsSince ¶ added in v0.2.0
CountCLILoginsSince counts logins started from ip since t.
func (Q) CountLands ¶ added in v0.4.0
CountLands counts the changes a principal (by ref, "agent:alice/backend") landed in [from, to): distinct change ids of vx changesets it authored in an effort, so rebased copies of a change do not count again.
func (Q) CountObjectBackfills ¶ added in v0.5.0
CountObjectBackfills is how many repositories wait for their objects to be indexed.
func (Q) CountObjectsWithoutSize ¶ added in v0.5.0
CountObjectsWithoutSize counts objects of repositories whose size is not recorded yet.
func (Q) CountOrgsPendingPurge ¶ added in v0.6.0
CountOrgsPendingPurge counts deleted organizations not purged yet.
func (Q) CountOwners ¶ added in v0.2.0
CountOwners returns how many owners org has.
func (Q) CountPendingCLILogins ¶ added in v0.2.0
CountPendingCLILogins counts logins nobody decided yet that have not expired, across all addresses.
func (Q) CountRepoObjects ¶ added in v0.2.0
CountRepoObjects returns how many objects are recorded for the repo.
func (Q) CreateCLILogin ¶ added in v0.2.0
CreateCLILogin stores a new pending login. ErrExists means the user code is taken; the caller picks another.
func (Q) CreateEffort ¶
CreateEffort inserts an effort with a unique slug derived from its name.
func (Q) CreateInvite ¶ added in v0.2.0
func (q Q) CreateInvite(ctx context.Context, login string, by *uuid.UUID, note string, siteAdmin bool) (SignupInvite, error)
CreateInvite invites a GitHub login, or updates the note of an open invite. It returns ErrExists when the invite was already used.
func (Q) CreateLoginCode ¶ added in v0.5.0
func (q Q) CreateLoginCode(ctx context.Context, codeHash []byte, principal uuid.UUID, expires, now time.Time) error
CreateLoginCode stores a one-time web sign-in code by its hash and drops expired ones.
func (Q) CreateOrgWithoutOwner ¶ added in v0.2.0
CreateOrgWithoutOwner inserts an organization nobody owns yet: one that mirrors a GitHub organization, whose members come from GitHub.
func (Q) CreatePrincipal ¶
CreatePrincipal inserts a principal. A person (KindHuman) also gets their personal organization, named like them and owned by them, in the same statement; SiteAdmin is only kept for people.
func (Q) CreateRepo ¶
CreateRepo inserts a repo and its upstream. The repo belongs to r.OrgID; without one it goes to the "default" organization, created on demand (the service always sets OrgID; this keeps low-level callers working).
func (Q) CreateTeam ¶ added in v0.2.0
CreateTeam inserts a team.
func (Q) CreateToken ¶
CreateToken issues a new token for a principal and returns the secret. Only its hash is stored, so the secret cannot be shown again.
func (Q) CreateWorkspace ¶
CreateWorkspace inserts an open workspace.
func (Q) DecideReview ¶ added in v0.4.0
func (q Q) DecideReview(ctx context.Context, id uuid.UUID, state ReviewState, by uuid.UUID, reason string, landed hash.Hash, at time.Time) (bool, error)
DecideReview moves a pending review to approved or rejected. It reports false when the review was not pending any more.
func (Q) DeleteCLILoginsBefore ¶ added in v0.2.0
DeleteCLILoginsBefore removes logins that expired before t.
func (Q) DeleteClosedOverlaps ¶ added in v0.3.0
DeleteClosedOverlaps removes the forecasts of an effort with efforts that are no longer open (or of the effort itself when it closed).
func (Q) DeleteGitHubInstallation ¶ added in v0.2.0
DeleteGitHubInstallation forgets an installation (removed from GitHub). Its repositories stay linked to it, so they stay GitHub-backed and nobody but service principals and support grants has a role on them until they are linked again.
func (Q) DeleteInvite ¶ added in v0.2.0
DeleteInvite withdraws an open invite; ok is false when there is none.
func (Q) DeleteOpsBefore ¶ added in v0.5.0
DeleteOpsBefore deletes up to batch operation log entries older than t and returns how many it deleted.
func (Q) DeleteOrgSSO ¶ added in v0.5.0
DeleteOrgSSO removes an organization's configuration and the sign-on marks of its tokens.
func (Q) DeletePushSubscription ¶ added in v0.5.0
func (q Q) DeletePushSubscription(ctx context.Context, principalID uuid.UUID, endpoint string) (bool, error)
DeletePushSubscription removes a principal's subscription by endpoint; it reports whether one was there.
func (Q) DeletePushSubscriptionByID ¶ added in v0.5.0
DeletePushSubscriptionByID removes a subscription the push service reported gone.
func (Q) DeleteRepoGrant ¶ added in v0.2.0
func (q Q) DeleteRepoGrant(ctx context.Context, repo uuid.UUID, principal, team *uuid.UUID) (string, error)
DeleteRepoGrant removes the grant to principal or team on repo and returns the role it had ("" when there was none).
func (Q) DeleteSupportGrant ¶ added in v0.5.0
DeleteSupportGrant removes person's support grant on repo and returns it (ErrNotFound when there is none).
func (Q) DeleteTeam ¶ added in v0.2.0
DeleteTeam deletes a team, its members and its grants.
func (Q) DeletedOrgByHandle ¶ added in v0.6.0
DeletedOrgByHandle returns a deleted organization that is not purged yet, locking it inside transactions (forUpdate).
func (Q) DeletedOrgGitHub ¶ added in v0.6.0
func (q Q) DeletedOrgGitHub(ctx context.Context, installationID, accountID int64) (string, bool, error)
DeletedOrgGitHub reports whether a deleted organization holds the GitHub installation installationID or the GitHub account accountID (0: do not check that), so syncing it stops.
func (Q) DeletedOrgsOwnedBy ¶ added in v0.6.0
DeletedOrgsOwnedBy lists the deleted, not yet purged organizations person owns, with their deletion records, soonest purge first.
func (Q) DropGitHubCache ¶ added in v0.2.0
DropGitHubCache deletes the cached roles and memberships in scope and reports how many rows went.
func (Q) EffortByID ¶
EffortByID finds an effort by id.
func (Q) ExistingRepoIDs ¶ added in v0.6.0
ExistingRepoIDs reports which of ids are repositories (of live or deleted organizations).
func (Q) FileChanges ¶
FileChanges returns the recorded file list of a changeset.
func (Q) FinishObjectBackfill ¶ added in v0.2.0
FinishObjectBackfill removes the repo from the backfill queue.
func (Q) FinishWorkspace ¶
func (q Q) FinishWorkspace(ctx context.Context, id uuid.UUID, state WorkspaceState, landedAs hash.Hash) error
FinishWorkspace marks a workspace landed (with its changeset) or abandoned.
func (Q) FinishedRebaseHeads ¶ added in v0.2.0
FinishedRebaseHeads returns, newest first, the old-chain heads of the effort's finished rebases: what open workspaces may still be based on.
func (Q) ForgetGitHubDelivery ¶ added in v0.2.0
ForgetGitHubDelivery removes a recorded delivery, so GitHub's redelivery of a delivery that failed to apply is applied.
func (Q) ForgetOrgSSOProofs ¶ added in v0.5.0
ForgetOrgSSOProofs drops the sign-on marks of an organization's tokens, for example after its provider changed.
func (Q) GetChangeset ¶
GetChangeset loads a changeset by hash.
func (Q) GetOrgQuota ¶ added in v0.5.0
GetOrgQuota returns an organization's override; one without a row has every field nil.
func (Q) GetOverlap ¶ added in v0.3.0
GetOverlap loads the forecast of a pair, in either order.
func (Q) GetReviewForUpdate ¶ added in v0.4.0
GetReviewForUpdate loads and locks a review (in a transaction).
func (Q) GetServerNotice ¶ added in v0.5.0
GetServerNotice reads a notice (ErrNotFound when the server never had it).
func (Q) GetUpstreamSecrets ¶ added in v0.4.0
GetUpstreamSecrets returns the sealed token and webhook secret of a repository.
func (Q) GetWorkspace ¶
GetWorkspace loads a workspace.
func (Q) GetWorkspaceForUpdate ¶
GetWorkspaceForUpdate loads a workspace and locks its row until the transaction ends, so two lands of the same workspace cannot race.
func (Q) GitHashesFor ¶
func (q Q) GitHashesFor(ctx context.Context, repoID uuid.UUID, vxHashes []hash.Hash) (map[hash.Hash]string, error)
GitHashesFor returns git hashes for vx objects (the reverse mapping).
func (Q) GitHubAccessFacts ¶ added in v0.2.0
func (q Q) GitHubAccessFacts(ctx context.Context, repo uuid.UUID, since time.Time) ([]AccessFact, error)
GitHubAccessFacts is RepoAccessFacts for a GitHub-backed repository: the roles GitHub reported for people checked since since (via "GitHub"), and direct grants of service principals, by handle. Support grants are listed by ListSupportGrants.
func (Q) GitHubAppGaps ¶ added in v0.4.0
func (q Q) GitHubAppGaps(ctx context.Context) ([]GitHubAppGap, error)
GitHubAppGaps lists the recorded gaps.
func (Q) GitHubBackedRepos ¶ added in v0.2.0
func (q Q) GitHubBackedRepos(ctx context.Context, installations []int64, org *uuid.UUID) ([]Repo, error)
GitHubBackedRepos returns the GitHub-backed repositories of the given installations, by name; org limits them to one organization.
func (Q) GitHubInstallationByID ¶ added in v0.2.0
GitHubInstallationByID returns one installation.
func (Q) GitHubLinkOf ¶ added in v0.2.0
GitHubLinkOf returns the GitHub account linked to a principal; ok is false when there is none.
func (Q) GitHubLinksOf ¶ added in v0.2.0
GitHubLinksOf returns the GitHub accounts linked to any of ids, by principal id; principals without one are left out.
func (Q) GitHubMembershipCache ¶ added in v0.2.0
func (q Q) GitHubMembershipCache(ctx context.Context, principal uuid.UUID) (map[int64]CachedRole, error)
GitHubMembershipCache returns principal's cached memberships in GitHub organizations, by GitHub organization id.
func (Q) GitHubRoleCache ¶ added in v0.2.0
func (q Q) GitHubRoleCache(ctx context.Context, principal uuid.UUID, repos []uuid.UUID) (map[uuid.UUID]CachedRole, error)
GitHubRoleCache returns principal's cached roles on repos, by repo id. Repositories without a cached role are missing from the map.
func (Q) HandleTaken ¶ added in v0.2.0
HandleTaken reports whether a handle is used by a principal or an organization (people's handles and organization handles share one space).
func (Q) IdentitiesOf ¶ added in v0.5.0
IdentitiesOf lists a person's identities, by issuer.
func (Q) InitPushKey ¶ added in v0.5.0
InitPushKey stores k unless a key exists, and returns the stored one: two servers making a key at once agree on the first.
func (Q) InsertChangeset ¶
func (q Q) InsertChangeset(ctx context.Context, repoID uuid.UUID, effortID *uuid.UUID, cs *object.Changeset, files []FileChange) (hash.Hash, error)
InsertChangeset stores a changeset and its file list. Inserting the same changeset twice is a no-op, which makes imports safe to repeat.
func (Q) InsertClaim ¶ added in v0.2.0
InsertClaim stores a claim. A zero ID gets a new one; a zero CreatedAt means now. The repo is taken from the effort.
func (Q) InsertNote ¶ added in v0.2.0
InsertNote stores a note. A zero ID gets a new one; a zero ThreadID makes the note a thread root; a zero CreatedAt means now. The repo is taken from the effort. Supersedes and System are stored as given; SupersededBy is ignored.
func (Q) InsertReservation ¶ added in v0.3.0
func (q Q) InsertReservation(ctx context.Context, repoID uuid.UUID, rule, value string, effortID, by *uuid.UUID) (bool, error)
InsertReservation records value for rule. It reports false, and no error, when that value is already reserved (another call won).
func (Q) InsertTask ¶ added in v0.2.0
InsertTask stores a task. A zero ID gets a new one, an empty State is open and a zero CreatedAt means now. The repo is taken from the effort. Dependencies are added separately with AddTaskDeps.
func (Q) IssueToken ¶ added in v0.2.0
func (q Q) IssueToken(ctx context.Context, principalID uuid.UUID, name string) (Token, string, error)
IssueToken is CreateToken that also returns the new token's record.
func (Q) KeepMovingClaims ¶ added in v0.5.0
KeepMovingClaims detaches the active moving claims of a workspace that lands from it, so they outlive the land, and keeps them until at least until.
func (Q) LapseIdleClaims ¶ added in v0.5.0
func (q Q) LapseIdleClaims(ctx context.Context, effortID uuid.UUID, now, idleSince time.Time) ([]Claim, error)
LapseIdleClaims releases, at now, the claims of an effort that are alive only because their workspace is open (past their own expiry) while that workspace has done nothing since idleSince, and returns them.
func (Q) LatestRebase ¶ added in v0.2.0
LatestRebase returns the effort's newest rebase in any state.
func (Q) LearnShipmentPR ¶ added in v0.4.0
LearnShipmentPR records the pull request number (and its URL, when the shipment has none) of a shipment pushed without one: a person opened the pull request on the host from vx's branch.
func (Q) LinkGitHub ¶ added in v0.2.0
func (q Q) LinkGitHub(ctx context.Context, principalID uuid.UUID, githubUserID int64, login string) error
LinkGitHub links a person to a GitHub account, or updates the login of the account they are already linked to. It returns ErrExists when that GitHub account is linked to someone else.
func (Q) LinkIdentity ¶ added in v0.5.0
LinkIdentity links (issuer, subject) to a person. ErrExists: the identity belongs to someone, or the person has another identity at this issuer.
func (Q) ListActorOps ¶ added in v0.2.0
ListActorOps returns the newest operations a principal performed, in any repo or none (agent creation, token revocation).
func (Q) ListAgents ¶
ListAgents returns the agents acting for owner.
func (Q) ListAudit ¶ added in v0.5.0
func (q Q) ListAudit(ctx context.Context, f AuditFilter) ([]AuditEntry, error)
ListAudit returns entries matching f, oldest first (newest with Desc).
func (Q) ListBranches ¶
ListBranches returns the tracked branches of a repo.
func (Q) ListChangesetTrees ¶ added in v0.2.0
ListChangesetTrees returns the trees of every changeset in the repo, in the order they were created.
func (Q) ListEffortOverlaps ¶ added in v0.3.0
ListEffortOverlaps returns the stored forecasts of an effort with every other effort that is still open, oldest pair first.
func (Q) ListEfforts ¶
ListEfforts lists a repo's efforts, newest first. An empty state lists all.
func (Q) ListGitHubInstallations ¶ added in v0.2.0
func (q Q) ListGitHubInstallations(ctx context.Context) ([]GitHubInstallationRow, error)
ListGitHubInstallations returns every installation, by account login.
func (Q) ListInvites ¶ added in v0.2.0
ListInvites returns invites newest first; open ones only unless all.
func (Q) ListOrgMembers ¶ added in v0.2.0
ListOrgMembers returns org's members by handle.
func (Q) ListOrgs ¶ added in v0.2.0
ListOrgs returns every organization (all) or those person is a member of, with person's role, by handle. Deleted organizations are left out.
func (Q) ListPeople ¶ added in v0.2.0
ListPeople returns every person (KindHuman) by handle.
func (Q) ListRepoGrants ¶ added in v0.2.0
ListRepoGrants returns repo's direct grants: principals first by handle, then teams by name.
func (Q) ListRepoOverlaps ¶ added in v0.3.0
ListRepoOverlaps returns the stored forecasts of every pair of open efforts of a repository.
func (Q) ListRepoRoleFacts ¶ added in v0.2.0
func (q Q) ListRepoRoleFacts(ctx context.Context, principal uuid.UUID, directOnly bool, org *uuid.UUID, at time.Time) ([]Repo, []RoleFacts, error)
ListRepoRoleFacts returns every repository with what principal's role on it is computed from, by name. Callers filter out what it cannot read.
func (Q) ListReservations ¶ added in v0.3.0
func (q Q) ListReservations(ctx context.Context, repoID uuid.UUID, rule string) ([]Reservation, error)
ListReservations lists a repository's reservations, newest first; an empty rule lists every rule's.
func (Q) ListReviews ¶ added in v0.4.0
ListReviews returns reviews, newest first.
func (Q) ListShipments ¶
ListShipments returns an effort's shipments with their changes: oldest first, the parts of a split in part order.
func (Q) ListSupportGrants ¶ added in v0.5.0
func (q Q) ListSupportGrants(ctx context.Context, repo uuid.UUID, at time.Time) ([]SupportGrant, error)
ListSupportGrants returns repo's support grants unexpired at at, by handle. Grants to people who are no longer superadmins are left out: they give no role.
func (Q) ListTargetOps ¶ added in v0.5.0
ListTargetOps returns the newest operations on one target ("user:alice", "github:octocat"), whoever performed them; console operations have no actor.
func (Q) ListTasks ¶ added in v0.2.0
ListTasks lists an effort's tasks: not done first, then by creation.
func (Q) ListTokens ¶ added in v0.2.0
ListTokens returns the tokens of the given principals, active ones first, then newest first.
func (Q) ListWorkspaces ¶
func (q Q) ListWorkspaces(ctx context.Context, effortID uuid.UUID, state WorkspaceState) ([]Workspace, error)
ListWorkspaces lists an effort's workspaces. An empty state lists all.
func (Q) LockOrg ¶ added in v0.2.0
LockOrg looks an organization up and locks it until the transaction ends, so membership checks such as "the last owner stays" cannot race.
func (Q) LockOverlapPair ¶ added in v0.3.0
LockOverlapPair serializes writers of one pair's forecast and notes until the transaction ends, also across servers.
func (Q) LockPrincipal ¶ added in v0.4.0
LockPrincipal locks a principal's row until the transaction ends, so checks of its budgets and the writes they guard happen one at a time.
func (Q) LockSystemNoteKey ¶ added in v0.4.0
LockSystemNoteKey serializes writers of one key until the transaction ends (two deliveries of the same CI result at once post one note).
func (Q) LogOp ¶
func (q Q) LogOp(ctx context.Context, repoID, actorID *uuid.UUID, op, target string, before, after any) error
LogOp appends to the operation log. before and after are marshaled to JSON.
func (Q) LoginCodeToken ¶ added in v0.5.0
LoginCodeToken is the token that asked for a sign-in code (uuid.Nil when none is known or the code does not exist).
func (Q) LookupGitObjects ¶
func (q Q) LookupGitObjects(ctx context.Context, repoID uuid.UUID, gitHashes []string) (map[string]hash.Hash, error)
LookupGitObjects returns the vx hashes known for the given git hashes.
func (Q) MarkNoteAnswered ¶ added in v0.2.0
MarkNoteAnswered marks a question answered.
func (Q) MarkNotesRead ¶ added in v0.3.0
MarkNotesRead records that principal was shown the notes. Ids of notes that do not exist are skipped; marking a note twice keeps the first time.
func (Q) MarkOrgDeleted ¶ added in v0.6.0
func (q Q) MarkOrgDeleted(ctx context.Context, org Org, by Principal, at, purgeAfter time.Time) (OrgDeletion, error)
MarkOrgDeleted hides an organization from now on and records its deletion. It fails with ErrNotFound when the organization is already deleted.
func (Q) MarkPushResult ¶ added in v0.5.0
MarkPushResult records the outcome of a send: when it went out, or why it did not.
func (Q) MarkServerNoticeLogged ¶ added in v0.5.0
MarkServerNoticeLogged records that the server logged a notice. It reports whether this call was the first to do so.
func (Q) MarkTokenSSO ¶ added in v0.5.0
MarkTokenSSO records that token was issued through org's sign-on.
func (Q) MergePeople ¶ added in v0.5.0
MergePeople moves everything that lets merged act to keep: tokens, agents (keeping their handles, so authorship stays readable), organization and team memberships (the higher role wins), repository grants (the higher role wins), identities and, when keep has none, the GitHub link. merged stays as a disabled principal so changes, notes and the op log still name them. Run it in a transaction.
func (Q) MergedPeople ¶ added in v0.5.0
MergedPeople maps each merged person to the person they were merged into.
func (Q) NoteByPrefix ¶ added in v0.2.0
NoteByPrefix finds the one note whose id starts with prefix (lowercase hex and dashes). It returns ErrNotFound or ErrAmbiguous otherwise.
func (Q) NoteForUpdate ¶ added in v0.2.0
NoteForUpdate loads a note and locks its row until the transaction ends.
func (Q) NoteRepos ¶ added in v0.3.0
NoteRepos returns the repository of each of the notes that exist.
func (Q) NotesRead ¶ added in v0.3.0
func (q Q) NotesRead(ctx context.Context, principal uuid.UUID, ids []uuid.UUID) (map[uuid.UUID]bool, error)
NotesRead returns which of the notes principal has seen.
func (Q) ObjectBackfillPending ¶ added in v0.2.0
ObjectBackfillPending reports whether the repo still waits for a backfill.
func (Q) ObjectBackfillQueue ¶ added in v0.2.0
ObjectBackfillQueue lists the repos waiting for a backfill, oldest first.
func (Q) ObjectSizesKnown ¶ added in v0.5.0
ObjectSizesKnown tells which of hs have a recorded size.
func (Q) ObjectsWithoutSize ¶ added in v0.5.0
ObjectsWithoutSize returns up to limit objects that are part of some repository but have no recorded size yet.
func (Q) OnChain ¶
func (q Q) OnChain(ctx context.Context, repoID uuid.UUID, head, target hash.Hash, limit int) (bool, error)
OnChain reports whether target is head or one of its first-parent ancestors, looking back at most limit steps.
func (Q) OpenEffortsOwnedBy ¶ added in v0.5.0
OpenEffortsOwnedBy lists the open and shipping efforts the principals own, most recently updated first, across repositories (the For you page; callers filter by what the viewer may read).
func (Q) OpenInvite ¶ added in v0.2.0
OpenInvite returns the open invite for login; ok is false when there is none.
func (Q) OpenQuestionsCopiedTo ¶ added in v0.5.0
OpenQuestionsCopiedTo returns open questions copied to person (their agent was not working when they were asked), newest first.
func (Q) OpenQuestionsTo ¶ added in v0.2.0
OpenQuestionsTo returns open questions (overdue ones included) addressed to any of the principals, newest first.
func (Q) OpenWorkspacesOf ¶ added in v0.4.0
OpenWorkspacesOf lists the open workspaces a principal owns in open efforts, oldest first.
func (Q) OrgAgreementByID ¶ added in v0.6.0
OrgAgreementByID returns one acceptance of an organization.
func (Q) OrgAgreements ¶ added in v0.6.0
OrgAgreements lists an organization's acceptances, newest first.
func (Q) OrgAgreementsOf ¶ added in v0.6.0
OrgAgreementsOf lists the acceptances of several organizations, newest first, for the banner and notifications.
func (Q) OrgByGitHubID ¶ added in v0.2.0
OrgByGitHubID looks up the organization linked to a GitHub organization.
func (Q) OrgByHandle ¶ added in v0.2.0
OrgByHandle looks an organization up by handle. Deleted organizations are not found (DeletedOrgByHandle reads them).
func (Q) OrgByID ¶ added in v0.5.0
OrgByID looks an organization up by id; deleted ones are not found.
func (Q) OrgDeletionByID ¶ added in v0.6.0
OrgDeletionByID returns the deletion record of an organization.
func (Q) OrgDeletionsByHandle ¶ added in v0.6.0
OrgDeletionsByHandle returns the deletion records of organizations that had handle, newest first (a handle is free again after a purge, so it may have been deleted more than once).
func (Q) OrgObjectHashes ¶ added in v0.6.0
func (q Q) OrgObjectHashes(ctx context.Context, orgID uuid.UUID) (own, shared []hash.Hash, err error)
OrgObjectHashes returns the hashes of the objects an organization's repositories record: those no other repository records (a purge deletes them) and those another repository records too (they stay).
func (Q) OrgRecordIDs ¶ added in v0.6.0
OrgRecordIDs returns the ids of an organization and of every record in it: its repositories, teams, and the rows of every table with an id column that belong to one of its repositories (a repo_id column) or efforts (an effort_id column). It walks the schema, so tables added later are included; with PurgeLeftovers it checks a purge.
func (Q) OrgRole ¶ added in v0.2.0
OrgRole returns person's role in org, or "" when they are not a member.
func (Q) OrgSSOOf ¶ added in v0.5.0
OrgSSOOf returns an organization's configuration; ok is false without one.
func (Q) OrgStoredBytes ¶ added in v0.5.0
OrgStoredBytes is the blob store bytes of the objects of the organization's repositories, each object counted once even when several of its repositories use it. Objects whose size is not recorded yet count 0.
func (Q) OrgUsage ¶ added in v0.5.0
OrgUsage counts what an organization uses: its repositories and its efforts that are open or shipping. Counts only, never names.
func (Q) OrgsBySSODomain ¶ added in v0.5.0
OrgsBySSODomain lists the organizations whose sign-on allows email domain, with their handles.
func (Q) OrgsDueForPurge ¶ added in v0.6.0
OrgsDueForPurge returns the ids of deleted organizations whose grace period ended by at, and of purges that started and did not finish, oldest first.
func (Q) OrgsWithRepos ¶ added in v0.6.0
OrgsWithRepos reports which of orgs have at least one repository.
func (Q) OverdueQuestions ¶ added in v0.2.0
func (q Q) OverdueQuestions(ctx context.Context, owner uuid.UUID, to []uuid.UUID, now time.Time, limit int) ([]Note, error)
OverdueQuestions returns open questions whose deadline is before now and that are either in an effort owned by owner or addressed to one of to, newest first.
func (Q) OverlapCounts ¶ added in v0.3.0
OverlapCounts returns, for each open effort of a repository, how many other open efforts it overlaps or conflicts with (clean pairs are not counted), and how many of those conflict.
func (Q) PeekLoginCode ¶ added in v0.5.0
PeekLoginCode returns who an unexpired code signs in, or ErrNotFound.
func (Q) PendingBackfillsOutside ¶ added in v0.6.0
PendingBackfillsOutside reports whether a repository other than the given ones waits for its object backfill: until it is indexed, the objects it uses are not in repo_objects, so no blob may be deleted.
func (Q) PendingReviewOf ¶ added in v0.4.0
PendingReviewOf returns the workspace's pending review.
func (Q) PeopleByEmail ¶ added in v0.5.0
PeopleByEmail lists the people (enabled ones) whose email is email, ignoring case.
func (Q) PersonByIdentity ¶ added in v0.5.0
PersonByIdentity finds the person linked to (issuer, subject).
func (Q) PrincipalByGitHubID ¶ added in v0.2.0
PrincipalByGitHubID looks a person up by their GitHub user id.
func (Q) PrincipalByGitHubLogin ¶ added in v0.2.0
PrincipalByGitHubLogin looks a person up by the GitHub login last seen for them, ignoring case. Logins can be renamed: use it for display and invites, never to sign someone in.
func (Q) PrincipalByHandle ¶
PrincipalByHandle looks a principal up by handle.
func (Q) PrincipalByID ¶
PrincipalByID looks a principal up by id.
func (Q) PrincipalDisabled ¶ added in v0.5.0
func (q Q) PrincipalDisabled(ctx context.Context, id uuid.UUID) (disabled bool, into *uuid.UUID, err error)
PrincipalDisabled reports whether a principal was disabled (merged into another) and into whom.
func (Q) PruneBlobDeletions ¶ added in v0.6.0
PruneBlobDeletions forgets marks of blobs deleted more than keep ago.
func (Q) PrunePushSent ¶ added in v0.5.0
PrunePushSent forgets pushes older than before: the items they were about are long decided or answered.
func (Q) PurgeLeftovers ¶ added in v0.6.0
PurgeLeftovers walks every table and lists the columns that still hold any of ids (in uuid, uuid[], text and jsonb columns) or hashes (in bytea columns), as "table.column (N rows)". After a purge, with the ids of the organization and of everything that was in it, it must be empty; tests use it so that tables added later are checked too. Not walked: the deletion record (org_deletions), the lifecycle entries of the operation log (org.delete, org.restore, org.purge) and the marks of deleted blobs (blob_deletions, kept a day; hashes, not content).
func (Q) PushKey ¶ added in v0.5.0
PushKey returns the server's VAPID key, or ErrNotFound before the first one is made.
func (Q) PushRecipients ¶ added in v0.5.0
PushRecipients lists the principals with at least one subscription.
func (Q) PushSubscriptions ¶ added in v0.5.0
func (q Q) PushSubscriptions(ctx context.Context, principalID uuid.UUID) ([]PushSubscription, error)
PushSubscriptions lists a principal's subscriptions, oldest first.
func (Q) PutGitHubApp ¶ added in v0.2.0
PutGitHubApp stores the server's GitHub App, replacing an earlier one.
func (Q) PutGitHubMembership ¶ added in v0.2.0
func (q Q) PutGitHubMembership(ctx context.Context, githubOrgID int64, principal uuid.UUID, role string, checkedAt time.Time) error
PutGitHubMembership caches principal's membership in a GitHub organization ("" for none).
func (Q) PutGitHubRole ¶ added in v0.2.0
func (q Q) PutGitHubRole(ctx context.Context, repo, principal uuid.UUID, role string, checkedAt time.Time) error
PutGitHubRole caches principal's role on repo ("" for none).
func (Q) PutShipmentCheck ¶ added in v0.4.0
func (q Q) PutShipmentCheck(ctx context.Context, c ShipmentCheck) error
PutShipmentCheck records the latest report of one check.
func (Q) PutSystemNoteKey ¶ added in v0.4.0
func (q Q) PutSystemNoteKey(ctx context.Context, k SystemNoteKey) error
PutSystemNoteKey records the latest note on key.
func (Q) QueueObjectBackfill ¶ added in v0.2.0
QueueObjectBackfill queues one repo for a backfill.
func (Q) QueueObjectBackfills ¶ added in v0.2.0
QueueObjectBackfills queues every repo that has changesets but no recorded objects, such as repos created by a server older than repo_objects. It returns how many were newly queued.
func (Q) QuotaOrg ¶ added in v0.5.0
QuotaOrg looks an organization up by id, for quota checks on its repositories.
func (Q) ReadableRepoIDs ¶ added in v0.2.0
func (q Q) ReadableRepoIDs(ctx context.Context, principal uuid.UUID, directOnly bool, at time.Time) ([]uuid.UUID, error)
ReadableRepoIDs returns the ids of the repositories principal can read through grants, teams and organization membership (directOnly: through direct grants only), and through support grants unexpired at at. Superadmins are not special here. GitHub-backed repositories are left out, except for directOnly (service principals keep their direct grants there) and support grants: roles on them come from GitHub, and the service adds them.
func (Q) RebaseEffort ¶
func (q Q) RebaseEffort(ctx context.Context, id uuid.UUID, seenVersion int64, baseBranch string, newBase, newHead hash.Hash) (bool, error)
RebaseEffort moves the effort onto a new base branch, base and head, with the same compare-and-swap as AdvanceEffort.
func (Q) RecordGitHubDelivery ¶ added in v0.2.0
func (q Q) RecordGitHubDelivery(ctx context.Context, id, event string, keep time.Duration) (fresh bool, err error)
RecordGitHubDelivery records a webhook delivery id. fresh is false when the delivery was recorded before (a replay or redelivery). Deliveries older than keep are pruned on the way.
func (Q) RecordObjectSizes ¶ added in v0.5.0
func (q Q) RecordObjectSizes(ctx context.Context, sizes []ObjectSize) error
RecordObjectSizes stores object sizes; a size recorded before is kept (objects are immutable, so it cannot differ).
func (Q) ReleaseClaim ¶ added in v0.2.0
ReleaseClaim releases one claim if it is still active at now and returns it; ok is false when it was already released or expired.
func (Q) ReleaseWorkspaceClaims ¶ added in v0.2.0
func (q Q) ReleaseWorkspaceClaims(ctx context.Context, workspaceID uuid.UUID, owner *uuid.UUID, now time.Time) ([]Claim, error)
ReleaseWorkspaceClaims releases the claims tied to a workspace that are not released yet (they lasted as long as the workspace) and returns them. A non-nil owner releases only that principal's claims.
func (Q) RemoveOrgMember ¶ added in v0.2.0
RemoveOrgMember removes person from org and its teams. It reports whether they were a member.
func (Q) RemoveTeamMember ¶ added in v0.2.0
RemoveTeamMember removes person from team and reports whether they were in it.
func (Q) RepoAccessFacts ¶ added in v0.2.0
RepoAccessFacts returns every source of access to repo: organization owners and admins, the default role for members, direct grants and team grants. Support grants are listed by ListSupportGrants.
func (Q) RepoByGitHubID ¶ added in v0.2.0
RepoByGitHubID looks a repo up by its GitHub repository id.
func (Q) RepoByName ¶
RepoByName looks a repo up by name.
func (Q) RepoObjectsMissing ¶ added in v0.2.0
func (q Q) RepoObjectsMissing(ctx context.Context, repoID uuid.UUID, hashes []hash.Hash) ([]hash.Hash, error)
RepoObjectsMissing returns the hashes that are not part of the repo, in the order given. Objects stored only for other repos count as missing.
func (Q) RepoRoleFacts ¶ added in v0.2.0
func (q Q) RepoRoleFacts(ctx context.Context, name string, principal uuid.UUID, directOnly bool, at time.Time) (Repo, RoleFacts, error)
RepoRoleFacts looks up the repository named name together with what principal's role on it is computed from, in one query.
func (Q) RepoRoleFactsByID ¶ added in v0.2.0
func (q Q) RepoRoleFactsByID(ctx context.Context, id, principal uuid.UUID, directOnly bool, at time.Time) (Repo, RoleFacts, error)
RepoRoleFactsByID is RepoRoleFacts for a repository id.
func (Q) RepoStoredBytes ¶ added in v0.5.0
RepoStoredBytes is the blob store bytes of the repository's objects. Objects whose size is not recorded yet count 0.
func (Q) ReposByRemote ¶ added in v0.4.0
ReposByRemote lists the repositories following remote (compared without case) on one of providers, by name. Several vx repositories may follow the same upstream.
func (Q) ReposOfGitHubInstallation ¶ added in v0.2.0
ReposOfGitHubInstallation lists the repos linked to an installation.
func (Q) ResetObjectIndex ¶ added in v0.2.0
ResetObjectIndex forgets which objects are part of the repo and queues it for a backfill, which rebuilds the index from its changesets. It is for repairs and for tests that recreate data from before repo_objects.
func (Q) ResolveChangeset ¶
func (q Q) ResolveChangeset(ctx context.Context, repoID uuid.UUID, ref string) (ChangesetRow, error)
ResolveChangeset finds a changeset by full hash, hex prefix (at least 6 characters) or change ID.
func (Q) ResolveServerNotice ¶ added in v0.5.0
ResolveServerNotice records that by reviewed a notice. It reports whether the notice was still open.
func (Q) RestoreDeletedOrg ¶ added in v0.6.0
RestoreDeletedOrg brings a deleted organization back as it was and drops its deletion record. It fails with ErrPurgeStarted once a purge began.
func (Q) ReviewByPrefix ¶ added in v0.4.0
ReviewByPrefix resolves a review id or a prefix of at least 8 hex characters among reviews of the given repositories (nil: any).
func (Q) RevokeToken ¶ added in v0.2.0
RevokeToken marks a token revoked and returns it. Revoking a token twice keeps the first revocation time; revoked reports whether this call did it.
func (Q) SSOBlocked ¶ added in v0.5.0
SSOBlocked reports whether org requires single sign-on and token was not issued through it.
func (Q) SaveGitObjects ¶
SaveGitObjects records mappings; existing ones are kept.
func (Q) SaveOverlap ¶ added in v0.3.0
func (q Q) SaveOverlap(ctx context.Context, o EffortOverlap) error
SaveOverlap inserts or replaces a pair's forecast. EffortA and EffortB must be ordered (OrderPair).
func (Q) SavePushSubscription ¶ added in v0.5.0
func (q Q) SavePushSubscription(ctx context.Context, s PushSubscription) (PushSubscription, error)
SavePushSubscription adds a subscription, or updates the one with the same endpoint: a browser subscribes once, so the endpoint moves to whoever signed in on it last.
func (Q) SaveShipment ¶
SaveShipment inserts a shipment or updates the one for the same effort and branch, replacing its change list.
func (Q) SetAgentScope ¶ added in v0.4.0
func (q Q) SetAgentScope(ctx context.Context, s AgentScope) error
SetAgentScope stores an agent's scope; an unlimited one removes the row.
func (Q) SetBranchIfUnchanged ¶ added in v0.5.0
func (q Q) SetBranchIfUnchanged(ctx context.Context, b Branch, fromSHA string, tracked bool) (bool, error)
SetBranchIfUnchanged moves a tracked branch to b only while it is still at git commit fromSHA, or, when it was not tracked (tracked false), only while it still is not. It reports whether it moved; false means another server moved the branch first. Imports use it so two servers syncing one branch at once never move it back to an older commit.
func (Q) SetCLILoginApprover ¶ added in v0.5.0
SetCLILoginApprover records which token approved a CLI login.
func (Q) SetCLILoginStatus ¶ added in v0.2.0
func (q Q) SetCLILoginStatus(ctx context.Context, deviceHash []byte, from, to string, principalID *uuid.UUID, at time.Time) (bool, error)
SetCLILoginStatus moves a login from one status to another and reports whether it was in the from status. principalID is recorded when set.
func (Q) SetChangesetWarnings ¶ added in v0.2.0
func (q Q) SetChangesetWarnings(ctx context.Context, repoID uuid.UUID, h hash.Hash, ws []Warning) error
SetChangesetWarnings records the warnings found when a changeset landed. No warnings clears the column.
func (Q) SetDisplayName ¶ added in v0.2.0
SetDisplayName changes a principal's display name.
func (Q) SetEffortState ¶
SetEffortState changes the lifecycle state.
func (Q) SetLoginCodeToken ¶ added in v0.5.0
SetLoginCodeToken records which token asked for a vx ui sign-in code.
func (Q) SetOrgGitHub ¶ added in v0.2.0
SetOrgGitHub links an organization to a GitHub organization (nil: unlink). Its membership then follows GitHub.
func (Q) SetOrgMember ¶ added in v0.2.0
SetOrgMember adds person to org with role, or changes their role.
func (Q) SetOrgQuota ¶ added in v0.5.0
SetOrgQuota stores an override; an empty one deletes the row.
func (Q) SetPurgeStep ¶ added in v0.6.0
SetPurgeStep records where a purge is.
func (Q) SetRepoGitHub ¶ added in v0.2.0
func (q Q) SetRepoGitHub(ctx context.Context, repo uuid.UUID, githubRepoID, installationID *int64) error
SetRepoGitHub links a repository to a GitHub repository through an installation of the App (both nil: unlink). A linked repository is GitHub-backed. Cached roles on it are dropped.
func (Q) SetRepoGrant ¶ added in v0.2.0
func (q Q) SetRepoGrant(ctx context.Context, repo uuid.UUID, principal, team *uuid.UUID, role string) (string, error)
SetRepoGrant grants principal or team (exactly one non-nil) role on repo, replacing an earlier grant to the same subject. It returns the previous role, or "".
func (Q) SetRepoUpstream ¶ added in v0.2.0
func (q Q) SetRepoUpstream(ctx context.Context, repoID uuid.UUID, remote, defaultBranch string) error
SetRepoUpstream changes a repo's remote and default branch, for example after the repository was renamed or transferred on GitHub.
func (Q) SetReviewConflicts ¶ added in v0.4.0
func (q Q) SetReviewConflicts(ctx context.Context, id uuid.UUID, paths []string, by uuid.UUID, at time.Time) error
SetReviewConflicts records that approving the review conflicted; it stays pending.
func (Q) SetShipmentCI ¶ added in v0.4.0
func (q Q) SetShipmentCI(ctx context.Context, c ShipmentCI) error
SetShipmentCI stores a shipment's CI result.
func (Q) SetShipmentState ¶ added in v0.4.0
SetShipmentState sets one shipment's state (a part of a split merged on its own, or left out of a newer split).
func (Q) SetSiteAdmin ¶ added in v0.2.0
SetSiteAdmin makes a person a superadmin (the site_admin column) or not.
func (Q) SetSupportGrant ¶ added in v0.5.0
func (q Q) SetSupportGrant(ctx context.Context, repo, person uuid.UUID, role string, expires time.Time, reason string, by *uuid.UUID) (*SupportGrant, error)
SetSupportGrant gives person role on repo until expires, replacing an earlier support grant to them. It returns the previous grant, if any.
func (Q) SetTaskState ¶ added in v0.2.0
func (q Q) SetTaskState(ctx context.Context, id uuid.UUID, state string, owner *uuid.UUID, now time.Time) error
SetTaskState changes a task's state and owner.
func (Q) SetUpstreamToken ¶ added in v0.4.0
SetUpstreamToken stores a sealed token for a repository; nil clears it.
func (Q) SetUpstreamWebhookSecret ¶ added in v0.4.0
SetUpstreamWebhookSecret stores a sealed webhook secret; nil clears it.
func (Q) SetWelcomeDismissed ¶ added in v0.2.0
SetWelcomeDismissed dismisses the welcome page, or brings it back.
func (Q) SetWorkspaceBase ¶
SetWorkspaceBase records the snapshot the workspace's files are based on.
func (Q) SetWorkspaceChangedPaths ¶ added in v0.3.0
func (q Q) SetWorkspaceChangedPaths(ctx context.Context, id uuid.UUID, paths []string, at time.Time) error
SetWorkspaceChangedPaths records the files an open workspace's working copy has changed.
func (Q) ShipmentByBranch ¶ added in v0.4.0
ShipmentByBranch returns the shipment of an effort in repoID pushed to branch, with its changes.
func (Q) ShipmentByPR ¶ added in v0.4.0
func (q Q) ShipmentByPR(ctx context.Context, repoID uuid.UUID, number, branch string) (ShipmentRef, error)
ShipmentByPR returns the newest shipment of the repository for a pull request: by its number on the host (provider_ref) when number is set, else, or when no shipment has that number, by its head branch.
func (Q) ShipmentCIs ¶ added in v0.4.0
ShipmentCIs returns the CI results of shipments, by shipment id; a shipment without one is missing.
func (Q) ShipmentChecks ¶ added in v0.4.0
func (q Q) ShipmentChecks(ctx context.Context, shipmentID uuid.UUID, sha string) ([]ShipmentCheck, error)
ShipmentChecks returns the checks reported for a shipment's commit, by name.
func (Q) ShipmentsByHeadSHA ¶ added in v0.4.0
func (q Q) ShipmentsByHeadSHA(ctx context.Context, repoID uuid.UUID, sha string) ([]ShipmentRef, error)
ShipmentsByHeadSHA returns the repository's shipments whose pushed head commit is sha, newest first.
func (Q) StartRebase ¶ added in v0.2.0
StartRebase inserts a running rebase. It returns ErrExists when the effort already has a rebase running or stopped.
func (Q) SubmitReview ¶ added in v0.4.0
SubmitReview stores r as the workspace's pending review: a new one, or in place of the workspace's pending review (a later land from the same workspace replaces the snapshot and clears the conflicts). It returns the stored review.
func (Q) SystemNoteKey ¶ added in v0.4.0
func (q Q) SystemNoteKey(ctx context.Context, effortID uuid.UUID, key string) (SystemNoteKey, error)
SystemNoteKey returns the latest note on key in an effort.
func (Q) SystemNotesTo ¶ added in v0.4.0
func (q Q) SystemNotesTo(ctx context.Context, to []uuid.UUID, since time.Time, limit int) ([]Note, error)
SystemNotesTo returns system notes addressed to one of to (review and CI notes for a change's author), created at or after since, that no newer note replaced, newest first.
func (Q) TaskByPrefix ¶ added in v0.2.0
TaskByPrefix finds the one task whose id starts with prefix, within one effort unless effort is uuid.Nil. It returns ErrNotFound or ErrAmbiguous otherwise.
func (Q) TaskDependents ¶ added in v0.2.0
TaskDependents lists the tasks that wait for task, by creation.
func (Q) TaskForUpdate ¶ added in v0.2.0
TaskForUpdate loads a task and locks its row until the transaction ends.
func (Q) TeamByName ¶ added in v0.2.0
TeamByName looks up a team of org, with its members.
func (Q) TokenOwner ¶ added in v0.5.0
TokenOwner is the principal a token belongs to and whether it is still active.
func (Q) TokenSSOOrgs ¶ added in v0.5.0
TokenSSOOrgs lists the organizations a token was issued through.
func (Q) TouchCLILoginPoll ¶ added in v0.2.0
TouchCLILoginPoll records a poll.
func (Q) TouchIdentity ¶ added in v0.5.0
TouchIdentity records a sign-in with an identity and its current email.
func (Q) TouchWorkspace ¶ added in v0.5.0
TouchWorkspace records that an open workspace did something at at.
func (Q) UpdateOrg ¶ added in v0.2.0
func (q Q) UpdateOrg(ctx context.Context, id uuid.UUID, displayName, defaultRole *string) (Org, error)
UpdateOrg changes the display name and default repository role; nil values stay.
func (Q) UpdateRebase ¶ added in v0.2.0
UpdateRebase saves a rebase's progress with a compare-and-swap on its version, and reports false when someone else changed it first (another continue, or an abort).
func (Q) UpsertBranch ¶
UpsertBranch records the current head of an upstream branch.
func (Q) UpsertGitHubInstallation ¶ added in v0.2.0
func (q Q) UpsertGitHubInstallation(ctx context.Context, in GitHubInstallationRow) error
UpsertGitHubInstallation records an installation of the App or updates it (account, linked organization, selection, suspension).
func (Q) UseInvite ¶ added in v0.2.0
UseInvite marks an open invite for login used; ok is false when there is no open invite.
func (Q) UseLoginCode ¶ added in v0.5.0
UseLoginCode deletes a code and returns who it signs in. Of two servers redeeming one code at once, only one gets it; an expired or unknown code is ErrNotFound.
func (Q) UseNonce ¶ added in v0.5.0
UseNonce records an ID token's nonce; false when it was used before. Expired nonces are dropped as it goes.
func (Q) WelcomeDismissed ¶ added in v0.2.0
WelcomeDismissed reports whether a person has dismissed the welcome page.
type Rebase ¶ added in v0.2.0
type Rebase struct {
ID uuid.UUID
RepoID uuid.UUID
EffortID uuid.UUID
State RebaseState
OntoBranch string
Onto hash.Hash
OntoGitSHA string
OldBase hash.Hash
OldHead hash.Hash
SeenHead hash.Hash
NewHead hash.Hash
Replayed []Replayed
Pending []hash.Hash
Conflicts []RebaseConflict
StartedBy uuid.UUID
UpdatedBy uuid.UUID
Version int64
CreatedAt time.Time
UpdatedAt time.Time
}
Rebase is one rebase of an effort onto a newer head of a branch.
type RebaseConflict ¶ added in v0.2.0
type RebaseConflict struct {
Path string `json:"path"`
Kind string `json:"kind"`
Detail string `json:"detail,omitempty"`
Generated bool `json:"generated,omitempty"` // the file says "Code generated ... DO NOT EDIT."
}
RebaseConflict is one path that stopped a rebase.
type RebaseState ¶ added in v0.2.0
type RebaseState string
RebaseState is the lifecycle state of an effort rebase.
const ( RebaseRunning RebaseState = "running" // the server is replaying changes RebaseStopped RebaseState = "stopped" // a change conflicts and waits for a resolution RebaseDone RebaseState = "done" // the effort head moved to the rebased chain RebaseAborted RebaseState = "aborted" // dropped; the effort is unchanged )
func (RebaseState) Active ¶ added in v0.2.0
func (s RebaseState) Active() bool
Active reports whether the rebase is still in progress.
type Repo ¶
type Repo struct {
ID uuid.UUID
Name string
Provider Provider
Remote string
DefaultBranch string
// BaseURL is the web address of a GitLab, Gitea, Forgejo or Bitbucket
// host, e.g. https://gitlab.example.com; empty for other providers.
BaseURL string
OrgID uuid.UUID // the owning organization
Org string // its handle
CreatedAt time.Time
// GitHubRepoID is set for a repository linked to GitHub, and
// GitHubInstallationID while an installation of the App reaches it.
// Such a repository is GitHub-backed: roles on it come from GitHub,
// never from vx grants. Without an installation nobody but service
// principals and support grants has a role on it (it stays GitHub-backed, so access fails closed).
GitHubRepoID *int64
GitHubInstallationID *int64
}
Repo is a repository known to vx and its upstream.
func (Repo) GitHubBacked ¶ added in v0.2.0
GitHubBacked reports whether roles on r come from GitHub: it is linked to a GitHub repository (with or without an installation reaching it now).
type RepoGrant ¶ added in v0.2.0
type RepoGrant struct {
RepoID uuid.UUID
Principal *Principal // set for grants to a person or service
Team *Team // set for grants to a team (without members)
Role string
}
RepoGrant is a direct grant on a repository, to a principal or a team.
type Reservation ¶ added in v0.3.0
type Reservation struct {
RepoID uuid.UUID
Rule string
Value string
EffortID *uuid.UUID
EffortSlug string
EffortOpen bool // the effort exists and is open
ReservedBy string
CreatedAt time.Time
}
Reservation is a value of a vx.toml [unique] rule handed out by vx reserve (rule_reservations). EffortSlug and ReservedBy are read from the effort and principal; empty when those were deleted.
type Review ¶ added in v0.4.0
type Review struct {
ID uuid.UUID
RepoID uuid.UUID
EffortID uuid.UUID
WorkspaceID uuid.UUID
AuthorID uuid.UUID
ChangeID string
Intent string
Base hash.Hash // changeset the snapshot was made on
Tree hash.Hash // the snapshot
Evidence *object.Evidence
DependsOn []string
Model string
Session string
Paths []string // changed files under the human policy
Policies []string // the matching [[policy]] tables, for people
Approvers [][]string // a person must be in every list; empty: anyone with write
State ReviewState
Conflicts []string // paths that conflicted when it was last approved
DecidedBy *uuid.UUID
DecidedAt *time.Time
Reason string
Landed hash.Hash
CreatedAt time.Time
UpdatedAt time.Time
}
Review is a land under a "human" landing policy that waits for a person: the author's snapshot, kept until someone approves or rejects it.
type ReviewFilter ¶ added in v0.4.0
type ReviewFilter struct {
Repos []uuid.UUID // nil: every repository
EffortID uuid.UUID
States []ReviewState
Limit int
}
ReviewFilter selects reviews. Zero fields do not filter.
type ReviewState ¶ added in v0.4.0
type ReviewState string
ReviewState is the lifecycle state of a review.
const ( ReviewPending ReviewState = "pending" // waits for a person ReviewApproved ReviewState = "approved" // a person approved it and it landed ReviewRejected ReviewState = "rejected" // a person rejected it; the workspace stays open ReviewWithdrawn ReviewState = "withdrawn" // the workspace was abandoned )
type RoleFacts ¶ added in v0.2.0
type RoleFacts struct {
Grant string // highest direct or team grant, or ""
OrgRole string // role in the repo's organization, or ""
DefaultRole string // the organization's default role for members
// Support is the role of an unexpired support grant to the principal,
// a superadmin, or "". It counts on every repository, GitHub-backed
// ones too. Superadmins have no other role on a repository than what
// grants, teams, organizations and support grants give them.
Support string
}
RoleFacts are what a principal's role on one repository is computed from, read in one query.
type ServerNotice ¶ added in v0.5.0
type ServerNotice struct {
Key string
CreatedAt time.Time
LoggedAt *time.Time
ResolvedAt *time.Time
ResolvedBy *uuid.UUID
}
ServerNotice is a one-time notice about an upgrade.
type Shipment ¶
type Shipment struct {
ID uuid.UUID
EffortID uuid.UUID
Title string
Branch string
Target string
BaseGitSHA string
HeadGitSHA string
ProviderRef string
URL string
State string
// Split is how the parts of an effort shipped as several pull
// requests relate: "independent" or "stacked"; empty for one PR.
Split string
// Part is the 1-based position among the effort's parts; 0 for one PR.
Part int
CreatedBy uuid.UUID
CreatedAt time.Time
UpdatedAt time.Time
Changes []ShipmentChange
// BaseTree is the target's tree the commits were made on; zero for
// shipments made before v0.4.
BaseTree hash.Hash
}
Shipment is an effort's changes pushed as a branch, usually with a PR.
type ShipmentCI ¶ added in v0.4.0
type ShipmentCI struct {
ShipmentID uuid.UUID
HeadSHA string
State string // pending, passed, failed
UpdatedAt time.Time
}
ShipmentCI is the CI result of a shipment's head commit.
type ShipmentChange ¶
type ShipmentChange struct {
Position int
Changeset hash.Hash
ChangeID string
GitSHA string
// Tree is the tree of the pushed commit; zero for shipments made
// before v0.4. Review comments on lines map to changes through it.
Tree hash.Hash
}
ShipmentChange is one changeset in a shipment and the commit made for it.
type ShipmentCheck ¶ added in v0.4.0
type ShipmentCheck struct {
ShipmentID uuid.UUID
HeadSHA string
Source string // check_run, status, pipeline
Name string
Status string // queued, in_progress, completed
Conclusion string // success, failure, ... once completed
URL string
UpdatedAt time.Time
}
ShipmentCheck is one CI check reported for a shipment's commit.
type ShipmentRef ¶ added in v0.4.0
ShipmentRef is a shipment with the effort and repository it belongs to.
type SignupInvite ¶ added in v0.2.0
type SignupInvite struct {
GitHubLogin string // lowercased
InvitedBy *uuid.UUID
Note string
SiteAdmin bool // the person becomes a superadmin (invites from the server console only)
CreatedAt time.Time
UsedAt *time.Time
}
SignupInvite allows a GitHub login to sign up while sign-up is invite-only.
type Store ¶
type Store struct {
Q
// contains filtered or unexported fields
}
Store is the connection pool plus queries.
func (*Store) Migrate ¶
Migrate applies pending migrations in order, each in its own transaction. Numbers may have gaps (efforts built in parallel reserve numbers), and a migration is applied when its version has not been applied yet, even if a later one has: a lower number landing after a higher one still runs.
func (*Store) MigrateTo ¶ added in v0.2.0
MigrateTo is Migrate that stops after version upTo (0: all), for tests of data migrations.
func (*Store) PoolStat ¶ added in v0.5.0
PoolStat returns the database pool's statistics, for /metrics.
func (*Store) PurgeOrgRows ¶ added in v0.6.0
func (s *Store) PurgeOrgRows(ctx context.Context, orgID uuid.UUID, handle string, at time.Time) (OrgDeletion, error)
PurgeOrgRows deletes the organization itself, after its repositories, and marks the purge done. It logs org.purge with the counts.
func (*Store) PurgeRepoObjects ¶ added in v0.6.0
func (s *Store) PurgeRepoObjects(ctx context.Context, orgID, repoID uuid.UUID, purged []uuid.UUID) (int, error)
PurgeRepoObjects deletes up to PurgeBatch of a repository's object records, and marks for deletion the blobs among them that no repository outside purged (the organization's repositories) records. It returns how many records it deleted; 0 means none are left.
func (*Store) PurgeRepoRow ¶ added in v0.6.0
PurgeRepoRow deletes what is left of a repository: its row and every small table that cascades from it, counted first.
func (*Store) PurgeRepoStep ¶ added in v0.6.0
func (s *Store) PurgeRepoStep(ctx context.Context, orgID, repoID uuid.UUID, i int) (n int64, ok bool, err error)
PurgeRepoStep runs step i of repoPurgeSteps once for a repository and returns how many rows it deleted; ok is false past the last step.
func (*Store) PurgeTarget ¶ added in v0.6.0
func (s *Store) PurgeTarget(ctx context.Context, orgID uuid.UUID, by string, at time.Time) (PurgeOrgRow, error)
PurgeTarget reads a deleted organization for its purge and marks the purge started (a restore is refused from then on).
func (*Store) RecordRepoObjects ¶ added in v0.6.0
func (s *Store) RecordRepoObjects(ctx context.Context, repoID uuid.UUID, hashes []hash.Hash, present func(context.Context, hash.Hash) (bool, error)) ([]hash.Hash, error)
RecordRepoObjects records objects as part of a repository, like AddRepoObjects, and makes sure none of them was deleted by an organization purge meanwhile: a blob can be deleted after the caller put it (the put found it there and skipped writing) and before it was recorded. Recording happens first; then, for the objects a purge marked, present checks under a shared lock on each hash that the blob is still in the store (the purge holds the lock exclusively while it checks and deletes, and sees the recording if it comes later). Objects that are gone are unrecorded again and returned: the caller puts them again and records them once more, or fails and is retried.
func (*Store) SweepBlobs ¶ added in v0.6.0
func (s *Store) SweepBlobs(ctx context.Context, orgID *uuid.UUID, limit int, del func(context.Context, hash.Hash) error) (deleted, handled int, err error)
SweepBlobs deletes up to limit blobs marked for deletion that no repository records, with del (the blob store's delete), and forgets their sizes. Marked blobs a repository records again are unmarked. It returns how many it deleted and how many marks it handled (0: none left).
func (*Store) TryPurgeLock ¶ added in v0.6.0
func (s *Store) TryPurgeLock(ctx context.Context) (alive func(context.Context) bool, unlock func(), ok bool, err error)
TryPurgeLock takes the purge lock if no other server holds it. It is a session lock on a connection of its own: if the server dies, the connection closes and the lock is free again. alive reports whether the lock is still held (the connection works); unlock releases it.
type SupportGrant ¶ added in v0.5.0
type SupportGrant struct {
RepoID uuid.UUID
Person Principal
Role string
ExpiresAt time.Time
Reason string
GrantedBy *Principal // nil when that person is gone
CreatedAt time.Time
}
SupportGrant is a time-limited role a repository's admins gave a superadmin on that repository.
type SystemNoteKey ¶ added in v0.4.0
type SystemNoteKey struct {
EffortID uuid.UUID
Key string
NoteID uuid.UUID
Digest string // what the note said, in short: an unchanged digest posts nothing
}
SystemNoteKey is the latest system note vx posted on one subject.
type Task ¶ added in v0.2.0
type Task struct {
ID uuid.UUID
Seq int64
RepoID uuid.UUID
EffortID uuid.UUID
Title string
Body string
State string // open, taken, done
OwnerID *uuid.UUID
CreatedBy uuid.UUID
CreatedAt time.Time
UpdatedAt time.Time
DependsOn []uuid.UUID // in the order the tasks were created
Blocked bool
RepoName string
EffortSlug string
}
Task is a stored task of an effort's plan. DependsOn and Blocked are read from task_deps: Blocked is set while some task it depends on is not done.
type TaskFilter ¶ added in v0.2.0
TaskFilter selects an effort's tasks. Zero fields do not filter.
type Token ¶ added in v0.2.0
type Token struct {
ID uuid.UUID
PrincipalID uuid.UUID
Name string
CreatedAt time.Time
LastUsedAt *time.Time
RevokedAt *time.Time
}
Token describes a token without its secret, which is never stored.
type Tx ¶
type Tx struct {
Q
// contains filtered or unexported fields
}
Tx is a transaction plus queries.
type UpstreamSecrets ¶ added in v0.4.0
UpstreamSecrets are a repository's sealed host secrets (internal/secret): nil fields mean "use the server's".
type Warning ¶ added in v0.2.0
type Warning struct {
Path string `json:"path"`
Kind string `json:"kind"`
Name string `json:"name,omitempty"`
Decl string `json:"decl,omitempty"`
Files []string `json:"files,omitempty"`
Detail string `json:"detail"`
}
Warning is a problem found in a landed tree that did not stop the land, such as a Go function declared twice in one package.
type Workspace ¶
type Workspace struct {
ID uuid.UUID
EffortID uuid.UUID
OwnerID uuid.UUID
Intent string
ChangeID string
Base hash.Hash
State WorkspaceState
LandedAs hash.Hash
CreatedAt time.Time
UpdatedAt time.Time
// ChangedPaths are the files the working copy last reported as
// changed, at ChangedPathsAt; nil ChangedPathsAt: never reported.
ChangedPaths []string
ChangedPathsAt *time.Time
// ActiveAt is when the workspace last synced, landed or reported its
// files; nil: not since it was created.
ActiveAt *time.Time
}
Workspace is one task's draft inside an effort.
func (Workspace) LastActive ¶ added in v0.5.0
LastActive is when the workspace last did something: ActiveAt, ChangedPathsAt or, failing both, when it was created.
type WorkspaceState ¶
type WorkspaceState string
WorkspaceState is the lifecycle state of a workspace.
const ( WorkspaceOpen WorkspaceState = "open" WorkspaceLanded WorkspaceState = "landed" WorkspaceAbandoned WorkspaceState = "abandoned" )
Source Files
¶
- agent_scopes.go
- audit.go
- branch_cas.go
- chainlen.go
- changesets.go
- claims.go
- cli_logins.go
- dpa.go
- efforts.go
- feedback.go
- foryou.go
- github_app.go
- github_people.go
- github_perms.go
- gitobjects.go
- hosts.go
- logincodes.go
- migrate.go
- notes.go
- objectsizes.go
- ops_target.go
- org_delete.go
- orgs.go
- overlaps.go
- principals.go
- push.go
- quotas.go
- rebases.go
- repoobjects.go
- repos.go
- reservations.go
- reviews.go
- shipments.go
- sso.go
- stats.go
- store.go
- support.go
- tasks.go