ci: fix first CI run — tidy, gofmt, ordering test, govulncheck pin
- ids: TestIDsAreTimeOrdered asserted strict lexicographic ordering of back-to-back UUIDv7s, but the sub-ms tail is random and not required to be monotonic. Sleep between samples so each ID lands in a distinct millisecond — the property that actually gives Postgres index locality on (org_id, id desc). - go.mod/go.sum: run go mod tidy. keyfunc/v3, prometheus/client_golang and testcontainers-go/modules/postgres are imported directly and should not be marked // indirect; also drops stale sum entries. - gofmt -w across 12 files flagged by the lint job. - security.yml: pin govulncheck to v1.2.0. @latest triggers a proxy lookup every run, which is the step that hung for 16m on the Gitea runner. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
ee52ae985d
commit
90ac4b169c
16 files changed
+85
-75
No files matched your search
@@ -224,4 +224,3 @@ func TestDisplayNameFallbacks(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package ids_test
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"anchorage/internal/pkg/ids"
|
||||
)
|
||||
@@ -93,11 +94,15 @@ func TestIDsAreUniquePerCall(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestIDsAreTimeOrdered(t *testing.T) {
|
||||
// UUIDv7 is time-ordered, so later-generated IDs should sort after
|
||||
// earlier ones lexicographically. This is the property that gives
|
||||
// Postgres index locality on (org_id, id desc).
|
||||
// UUIDv7 is time-ordered at millisecond granularity; the sub-ms
|
||||
// tail is random and not required to be monotonic, so back-to-back
|
||||
// calls in the same millisecond can sort in either direction. The
|
||||
// property we actually rely on for Postgres index locality on
|
||||
// (org_id, id desc) is that IDs separated by >=1ms sort in
|
||||
// generation order — so sleep between samples.
|
||||
prev := ids.MustNewPin().String()
|
||||
for i := 0; i < 32; i++ {
|
||||
for i := 0; i < 8; i++ {
|
||||
time.Sleep(2 * time.Millisecond)
|
||||
next := ids.MustNewPin().String()
|
||||
if next <= prev {
|
||||
t.Fatalf("UUIDv7 ordering violated: %q followed %q", next, prev)
|
||||
|
||||
@@ -21,8 +21,8 @@ import (
|
||||
|
||||
// Client is a Kubo RPC client.
|
||||
type Client struct {
|
||||
base *url.URL
|
||||
hc *http.Client
|
||||
base *url.URL
|
||||
hc *http.Client
|
||||
}
|
||||
|
||||
// Options configures a Client.
|
||||
|
||||
@@ -369,8 +369,8 @@ func RegisterAdmin(api huma.API, deps AdminDeps) {
|
||||
}
|
||||
type rebalanceResp struct {
|
||||
Body struct {
|
||||
Applied bool `json:"applied"`
|
||||
Moves []scheduler.PlannedMove `json:"moves"`
|
||||
Applied bool `json:"applied"`
|
||||
Moves []scheduler.PlannedMove `json:"moves"`
|
||||
}
|
||||
}
|
||||
huma.Register(api, huma.Operation{
|
||||
|
||||
@@ -303,4 +303,3 @@ func userBody(u *store.User) userBodyT {
|
||||
IsSysadmin: u.IsSysadmin,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@ func RegisterTokens(api huma.API, deps TokenDeps) {
|
||||
Security: []map[string][]string{{"accessToken": {}}},
|
||||
}, func(ctx context.Context, in *struct {
|
||||
Body struct {
|
||||
Label string `json:"label" minLength:"1" maxLength:"128"`
|
||||
Scopes []string `json:"scopes,omitempty"`
|
||||
TTLHours int `json:"ttl_hours,omitempty" minimum:"1"`
|
||||
Label string `json:"label" minLength:"1" maxLength:"128"`
|
||||
Scopes []string `json:"scopes,omitempty"`
|
||||
TTLHours int `json:"ttl_hours,omitempty" minimum:"1"`
|
||||
}
|
||||
}) (*struct {
|
||||
Body struct {
|
||||
|
||||
@@ -20,7 +20,7 @@ type PlannedMove struct {
|
||||
RequestID string `json:"request_id"`
|
||||
FromNode string `json:"from_node"`
|
||||
ToNode string `json:"to_node"`
|
||||
Reason string `json:"reason"` // "down" | "drain"
|
||||
Reason string `json:"reason"` // "down" | "drain"
|
||||
NewFence int64 `json:"new_fence,omitempty"` // populated after apply
|
||||
}
|
||||
|
||||
|
||||
@@ -56,14 +56,16 @@ func New() *Store {
|
||||
|
||||
// ---- store.Store root -----------------------------------------------------
|
||||
|
||||
func (s *Store) Orgs() store.OrgStore { return orgStore{s} }
|
||||
func (s *Store) Users() store.UserStore { return userStore{s} }
|
||||
func (s *Store) Memberships() store.MembershipStore { return memStore{s} }
|
||||
func (s *Store) Tokens() store.TokenStore { return tokenStore{s} }
|
||||
func (s *Store) Nodes() store.NodeStore { return nodeStore{s} }
|
||||
func (s *Store) Pins() store.PinStore { return pinStore{s} }
|
||||
func (s *Store) Audit() store.AuditStore { return auditStore{s} }
|
||||
func (s *Store) WithOrgContext(ctx context.Context, _ ids.OrgID) (context.Context, error) { return ctx, nil }
|
||||
func (s *Store) Orgs() store.OrgStore { return orgStore{s} }
|
||||
func (s *Store) Users() store.UserStore { return userStore{s} }
|
||||
func (s *Store) Memberships() store.MembershipStore { return memStore{s} }
|
||||
func (s *Store) Tokens() store.TokenStore { return tokenStore{s} }
|
||||
func (s *Store) Nodes() store.NodeStore { return nodeStore{s} }
|
||||
func (s *Store) Pins() store.PinStore { return pinStore{s} }
|
||||
func (s *Store) Audit() store.AuditStore { return auditStore{s} }
|
||||
func (s *Store) WithOrgContext(ctx context.Context, _ ids.OrgID) (context.Context, error) {
|
||||
return ctx, nil
|
||||
}
|
||||
|
||||
// Tx in a memstore is a no-op — the same Store is passed back and the
|
||||
// context is forwarded unchanged. Real Postgres implementations open a
|
||||
|
||||
@@ -737,13 +737,13 @@ func (a auditStore) List(ctx context.Context, orgID ids.OrgID, limit, offset int
|
||||
out := []*store.AuditEntry{}
|
||||
for rows.Next() {
|
||||
var (
|
||||
id int64
|
||||
org ids.OrgID
|
||||
actorUser ids.UserID
|
||||
actorTokenJti *string
|
||||
id int64
|
||||
org ids.OrgID
|
||||
actorUser ids.UserID
|
||||
actorTokenJti *string
|
||||
action, target, result string
|
||||
detail []byte
|
||||
created pgtype.Timestamptz
|
||||
detail []byte
|
||||
created pgtype.Timestamptz
|
||||
)
|
||||
if err := rows.Scan(&id, &org, &actorUser, &actorTokenJti, &action, &target, &result, &detail, &created); err != nil {
|
||||
return nil, err
|
||||
|
||||
+15
-15
@@ -88,12 +88,12 @@ type UserStore interface {
|
||||
|
||||
// Membership pairs a user with an org + role.
|
||||
type Membership struct {
|
||||
OrgID ids.OrgID
|
||||
UserID ids.UserID
|
||||
Role string // "orgadmin" | "member"
|
||||
OrgSlug string // populated by List*, empty on raw gets
|
||||
OrgName string
|
||||
Created time.Time
|
||||
OrgID ids.OrgID
|
||||
UserID ids.UserID
|
||||
Role string // "orgadmin" | "member"
|
||||
OrgSlug string // populated by List*, empty on raw gets
|
||||
OrgName string
|
||||
Created time.Time
|
||||
}
|
||||
|
||||
// Role constants.
|
||||
@@ -217,15 +217,15 @@ type Placement struct {
|
||||
// Before and After are both inclusive of their endpoint semantics:
|
||||
// `after <= created < before`.
|
||||
type PinFilter struct {
|
||||
CIDs []string
|
||||
Name string
|
||||
Match string
|
||||
Status []string
|
||||
Before *time.Time
|
||||
After *time.Time
|
||||
Meta map[string]any
|
||||
Limit int
|
||||
Offset int
|
||||
CIDs []string
|
||||
Name string
|
||||
Match string
|
||||
Status []string
|
||||
Before *time.Time
|
||||
After *time.Time
|
||||
Meta map[string]any
|
||||
Limit int
|
||||
Offset int
|
||||
}
|
||||
|
||||
// PinStore manages pins and their placements + refcounts.
|
||||
|
||||
@@ -22,8 +22,8 @@ import (
|
||||
type Hub struct {
|
||||
nc *nats.Conn
|
||||
|
||||
mu sync.Mutex
|
||||
conns map[*websocket.Conn]*clientFilter
|
||||
mu sync.Mutex
|
||||
conns map[*websocket.Conn]*clientFilter
|
||||
}
|
||||
|
||||
type clientFilter struct {
|
||||
|
||||
Reference in new issue
Block a user