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 NewID() uuid.UUID
- func Slugify(name string) string
- func ValidateHandle(kind PrincipalKind, handle string) error
- func ValidateRepoName(name string) error
- type AccessFact
- type Branch
- type CLILogin
- type CachedRole
- type ChangesetRow
- type ChangesetTrees
- type Claim
- type Effort
- type EffortState
- type FileChange
- type GitHubApp
- type GitHubCacheScope
- type GitHubInstallationRow
- type GitHubLink
- type GitObject
- type Note
- type NoteCursor
- type NoteFilter
- type Op
- type Org
- type OrgMember
- type OrgWithRole
- type Principal
- type PrincipalKind
- type Provider
- type Q
- 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) AddRepoObjects(ctx context.Context, repoID uuid.UUID, hashes []hash.Hash) 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) AnswersToQuestionsBy(ctx context.Context, author uuid.UUID, since time.Time, limit int) ([]Note, 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) 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) CountCLILoginsSince(ctx context.Context, ip string, since time.Time) (int, 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) 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) DeleteCLILoginsBefore(ctx context.Context, t time.Time) 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) DeleteRepoGrant(ctx context.Context, repo uuid.UUID, principal, team *uuid.UUID) (string, error)
- func (q Q) DeleteTeam(ctx context.Context, team uuid.UUID) 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) 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) 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) 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) 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) 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) 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) LatestRebase(ctx context.Context, effortID uuid.UUID) (Rebase, error)
- func (q Q) LinkGitHub(ctx context.Context, principalID uuid.UUID, githubUserID int64, login 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) ListBranches(ctx context.Context, repoID uuid.UUID) ([]Branch, error)
- func (q Q) ListChangesetTrees(ctx context.Context, repoID uuid.UUID) ([]ChangesetTrees, 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) 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) ListShipments(ctx context.Context, effortID uuid.UUID) ([]Shipment, 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) LogOp(ctx context.Context, repoID, actorID *uuid.UUID, op, target string, ...) 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) 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) ObjectBackfillPending(ctx context.Context, repoID uuid.UUID) (bool, error)
- func (q Q) ObjectBackfillQueue(ctx context.Context) ([]uuid.UUID, error)
- func (q Q) OnChain(ctx context.Context, repoID uuid.UUID, head, target hash.Hash, limit int) (bool, error)
- func (q Q) OpenInvite(ctx context.Context, login string) (SignupInvite, bool, error)
- func (q Q) OpenQuestionsTo(ctx context.Context, to []uuid.UUID, limit int) ([]Note, 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) OrgRole(ctx context.Context, org, person uuid.UUID) (string, error)
- func (q Q) OverdueQuestions(ctx context.Context, owner uuid.UUID, to []uuid.UUID, now time.Time, limit int) ([]Note, 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) 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) QueueObjectBackfill(ctx context.Context, repoID uuid.UUID) error
- func (q Q) QueueObjectBackfills(ctx context.Context) (int, error)
- func (q Q) ReadableRepoIDs(ctx context.Context, principal uuid.UUID, directOnly bool) ([]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) 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) (Repo, RoleFacts, 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) RevokeToken(ctx context.Context, id uuid.UUID) (t Token, revoked bool, err error)
- func (q Q) SaveGitObjects(ctx context.Context, repoID uuid.UUID, objs []GitObject) error
- func (q Q) SaveShipment(ctx context.Context, s Shipment) (Shipment, 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) 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) 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) SetSiteAdmin(ctx context.Context, person uuid.UUID, admin bool) error
- func (q Q) SetTaskState(ctx context.Context, id uuid.UUID, state string, owner *uuid.UUID, ...) 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) StartRebase(ctx context.Context, r Rebase) (Rebase, 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) TouchCLILoginPoll(ctx context.Context, deviceHash []byte, 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) WelcomeDismissed(ctx context.Context, principalID uuid.UUID) (bool, error)
- type Rebase
- type RebaseConflict
- type RebaseState
- type Replayed
- type Repo
- type RepoGrant
- type RoleFacts
- type Shipment
- type ShipmentChange
- type SignupInvite
- type Store
- type Task
- type TaskFilter
- type Team
- type Token
- type Tx
- 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.
Functions ¶
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 // "site admin", "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 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
}
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 ExpiresAt is after now.
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 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 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 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
}
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
}
NoteFilter selects an effort's notes. Zero fields do not filter.
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 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 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) 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) 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) 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) 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) 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) CountCLILoginsSince ¶ added in v0.2.0
CountCLILoginsSince counts logins started from ip since t.
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) 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) DeleteCLILoginsBefore ¶ added in v0.2.0
DeleteCLILoginsBefore removes logins that expired before t.
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 site admins 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) 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) DeleteTeam ¶ added in v0.2.0
DeleteTeam deletes a team, its members and its grants.
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) 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) GetChangeset ¶
GetChangeset loads a changeset by hash.
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: site admins, the roles GitHub reported for people checked since since (via "GitHub"), and direct grants of service principals, by handle.
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) 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.
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) LatestRebase ¶ added in v0.2.0
LatestRebase returns the effort's newest rebase in any state.
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) 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) 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) 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.
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) ListRepoRoleFacts ¶ added in v0.2.0
func (q Q) ListRepoRoleFacts(ctx context.Context, principal uuid.UUID, directOnly bool, org *uuid.UUID) ([]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) ListShipments ¶
ListShipments returns an effort's shipments with their changes.
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) 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) 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) 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) 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) 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) OpenInvite ¶ added in v0.2.0
OpenInvite returns the open invite for login; ok is false when there is none.
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) 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.
func (Q) OrgRole ¶ added in v0.2.0
OrgRole returns person's role in org, or "" when they are not a member.
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) 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) 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) 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) ReadableRepoIDs ¶ added in v0.2.0
func (q Q) ReadableRepoIDs(ctx context.Context, principal uuid.UUID, directOnly bool) ([]uuid.UUID, error)
ReadableRepoIDs returns the ids of the repositories principal can read through grants, teams and organization membership (directOnly: through direct grants only). Site admins are not special here; callers check. GitHub-backed repositories are left out, except for directOnly (service principals keep their direct grants there): 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) 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 active at now 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: site admins, organization owners and admins, the default role for members, direct grants and team grants.
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) (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) (Repo, RoleFacts, error)
RepoRoleFactsByID is RepoRoleFacts for a repository id.
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) 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) SaveGitObjects ¶
SaveGitObjects records mappings; existing ones are kept.
func (Q) SaveShipment ¶
SaveShipment inserts a shipment or updates the one for the same effort and branch, replacing its change list.
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) 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) 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) SetSiteAdmin ¶ added in v0.2.0
SetSiteAdmin makes a person a site admin or not.
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) 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) 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) 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) TouchCLILoginPoll ¶ added in v0.2.0
TouchCLILoginPoll records a poll.
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).
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
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 site admins
// 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 RoleFacts ¶ added in v0.2.0
type RoleFacts struct {
SiteAdmin bool // the principal is a site admin
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
}
RoleFacts are what a principal's role on one repository is computed from, read in one query.
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
CreatedBy uuid.UUID
CreatedAt time.Time
UpdatedAt time.Time
Changes []ShipmentChange
}
Shipment is an effort's changes pushed as a branch, usually with a PR.
type ShipmentChange ¶
ShipmentChange is one changeset in a shipment and the commit made for it.
type SignupInvite ¶ added in v0.2.0
type SignupInvite struct {
GitHubLogin string // lowercased
InvitedBy *uuid.UUID
Note string
SiteAdmin bool // the person becomes a site admin (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.
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 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
}
Workspace is one task's draft inside an effort.
type WorkspaceState ¶
type WorkspaceState string
WorkspaceState is the lifecycle state of a workspace.
const ( WorkspaceOpen WorkspaceState = "open" WorkspaceLanded WorkspaceState = "landed" WorkspaceAbandoned WorkspaceState = "abandoned" )