tenseleyflow/shithub / 5cbaaa0

Browse files

repos/sqlc: queries + generated for commit_verification_cache

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
5cbaaa02bc5f29262844f596fb509249c8d1ef21
Parents
e289421
Tree
b916588

19 changed files

StatusFile+-
M internal/actions/sqlc/models.go 14 0
M internal/admin/sqlc/models.go 14 0
M internal/auth/policy/sqlc/models.go 14 0
M internal/billing/sqlc/models.go 14 0
M internal/checks/sqlc/models.go 14 0
M internal/issues/sqlc/models.go 14 0
M internal/meta/sqlc/models.go 14 0
M internal/notif/sqlc/models.go 14 0
M internal/orgs/sqlc/models.go 14 0
M internal/pulls/sqlc/models.go 14 0
M internal/ratelimit/sqlc/models.go 14 0
A internal/repos/queries/commit_verification_cache.sql 62 0
A internal/repos/sqlc/commit_verification_cache.sql.go 183 0
M internal/repos/sqlc/models.go 14 0
M internal/repos/sqlc/querier.go 22 0
M internal/social/sqlc/models.go 14 0
M internal/users/sqlc/models.go 14 0
M internal/webhook/sqlc/models.go 14 0
M internal/worker/sqlc/models.go 14 0
internal/actions/sqlc/models.gomodified
@@ -1889,6 +1889,20 @@ type CodeSearchPath struct {
18891889
 	Tsv     interface{}
18901890
 }
18911891
 
1892
+type CommitVerificationCache struct {
1893
+	RepoID           int64
1894
+	CommitOid        string
1895
+	Reason           string
1896
+	Verified         bool
1897
+	SignerUserID     pgtype.Int8
1898
+	SignerSubkeyID   pgtype.Int8
1899
+	Kind             string
1900
+	SignatureArmored pgtype.Text
1901
+	Payload          []byte
1902
+	VerifiedAt       pgtype.Timestamptz
1903
+	InvalidatedAt    pgtype.Timestamptz
1904
+}
1905
+
18921906
 type DeviceAuthorization struct {
18931907
 	ID              int64
18941908
 	DeviceCodeHash  []byte
internal/admin/sqlc/models.gomodified
@@ -1889,6 +1889,20 @@ type CodeSearchPath struct {
18891889
 	Tsv     interface{}
18901890
 }
18911891
 
1892
+type CommitVerificationCache struct {
1893
+	RepoID           int64
1894
+	CommitOid        string
1895
+	Reason           string
1896
+	Verified         bool
1897
+	SignerUserID     pgtype.Int8
1898
+	SignerSubkeyID   pgtype.Int8
1899
+	Kind             string
1900
+	SignatureArmored pgtype.Text
1901
+	Payload          []byte
1902
+	VerifiedAt       pgtype.Timestamptz
1903
+	InvalidatedAt    pgtype.Timestamptz
1904
+}
1905
+
18921906
 type DeviceAuthorization struct {
18931907
 	ID              int64
18941908
 	DeviceCodeHash  []byte
internal/auth/policy/sqlc/models.gomodified
@@ -1889,6 +1889,20 @@ type CodeSearchPath struct {
18891889
 	Tsv     interface{}
18901890
 }
18911891
 
1892
+type CommitVerificationCache struct {
1893
+	RepoID           int64
1894
+	CommitOid        string
1895
+	Reason           string
1896
+	Verified         bool
1897
+	SignerUserID     pgtype.Int8
1898
+	SignerSubkeyID   pgtype.Int8
1899
+	Kind             string
1900
+	SignatureArmored pgtype.Text
1901
+	Payload          []byte
1902
+	VerifiedAt       pgtype.Timestamptz
1903
+	InvalidatedAt    pgtype.Timestamptz
1904
+}
1905
+
18921906
 type DeviceAuthorization struct {
18931907
 	ID              int64
18941908
 	DeviceCodeHash  []byte
internal/billing/sqlc/models.gomodified
@@ -1889,6 +1889,20 @@ type CodeSearchPath struct {
18891889
 	Tsv     interface{}
18901890
 }
18911891
 
1892
+type CommitVerificationCache struct {
1893
+	RepoID           int64
1894
+	CommitOid        string
1895
+	Reason           string
1896
+	Verified         bool
1897
+	SignerUserID     pgtype.Int8
1898
+	SignerSubkeyID   pgtype.Int8
1899
+	Kind             string
1900
+	SignatureArmored pgtype.Text
1901
+	Payload          []byte
1902
+	VerifiedAt       pgtype.Timestamptz
1903
+	InvalidatedAt    pgtype.Timestamptz
1904
+}
1905
+
18921906
 type DeviceAuthorization struct {
18931907
 	ID              int64
18941908
 	DeviceCodeHash  []byte
internal/checks/sqlc/models.gomodified
@@ -1889,6 +1889,20 @@ type CodeSearchPath struct {
18891889
 	Tsv     interface{}
18901890
 }
18911891
 
1892
+type CommitVerificationCache struct {
1893
+	RepoID           int64
1894
+	CommitOid        string
1895
+	Reason           string
1896
+	Verified         bool
1897
+	SignerUserID     pgtype.Int8
1898
+	SignerSubkeyID   pgtype.Int8
1899
+	Kind             string
1900
+	SignatureArmored pgtype.Text
1901
+	Payload          []byte
1902
+	VerifiedAt       pgtype.Timestamptz
1903
+	InvalidatedAt    pgtype.Timestamptz
1904
+}
1905
+
18921906
 type DeviceAuthorization struct {
18931907
 	ID              int64
18941908
 	DeviceCodeHash  []byte
internal/issues/sqlc/models.gomodified
@@ -1889,6 +1889,20 @@ type CodeSearchPath struct {
18891889
 	Tsv     interface{}
18901890
 }
18911891
 
1892
+type CommitVerificationCache struct {
1893
+	RepoID           int64
1894
+	CommitOid        string
1895
+	Reason           string
1896
+	Verified         bool
1897
+	SignerUserID     pgtype.Int8
1898
+	SignerSubkeyID   pgtype.Int8
1899
+	Kind             string
1900
+	SignatureArmored pgtype.Text
1901
+	Payload          []byte
1902
+	VerifiedAt       pgtype.Timestamptz
1903
+	InvalidatedAt    pgtype.Timestamptz
1904
+}
1905
+
18921906
 type DeviceAuthorization struct {
18931907
 	ID              int64
18941908
 	DeviceCodeHash  []byte
internal/meta/sqlc/models.gomodified
@@ -1889,6 +1889,20 @@ type CodeSearchPath struct {
18891889
 	Tsv     interface{}
18901890
 }
18911891
 
1892
+type CommitVerificationCache struct {
1893
+	RepoID           int64
1894
+	CommitOid        string
1895
+	Reason           string
1896
+	Verified         bool
1897
+	SignerUserID     pgtype.Int8
1898
+	SignerSubkeyID   pgtype.Int8
1899
+	Kind             string
1900
+	SignatureArmored pgtype.Text
1901
+	Payload          []byte
1902
+	VerifiedAt       pgtype.Timestamptz
1903
+	InvalidatedAt    pgtype.Timestamptz
1904
+}
1905
+
18921906
 type DeviceAuthorization struct {
18931907
 	ID              int64
18941908
 	DeviceCodeHash  []byte
internal/notif/sqlc/models.gomodified
@@ -1889,6 +1889,20 @@ type CodeSearchPath struct {
18891889
 	Tsv     interface{}
18901890
 }
18911891
 
1892
+type CommitVerificationCache struct {
1893
+	RepoID           int64
1894
+	CommitOid        string
1895
+	Reason           string
1896
+	Verified         bool
1897
+	SignerUserID     pgtype.Int8
1898
+	SignerSubkeyID   pgtype.Int8
1899
+	Kind             string
1900
+	SignatureArmored pgtype.Text
1901
+	Payload          []byte
1902
+	VerifiedAt       pgtype.Timestamptz
1903
+	InvalidatedAt    pgtype.Timestamptz
1904
+}
1905
+
18921906
 type DeviceAuthorization struct {
18931907
 	ID              int64
18941908
 	DeviceCodeHash  []byte
internal/orgs/sqlc/models.gomodified
@@ -1889,6 +1889,20 @@ type CodeSearchPath struct {
18891889
 	Tsv     interface{}
18901890
 }
18911891
 
1892
+type CommitVerificationCache struct {
1893
+	RepoID           int64
1894
+	CommitOid        string
1895
+	Reason           string
1896
+	Verified         bool
1897
+	SignerUserID     pgtype.Int8
1898
+	SignerSubkeyID   pgtype.Int8
1899
+	Kind             string
1900
+	SignatureArmored pgtype.Text
1901
+	Payload          []byte
1902
+	VerifiedAt       pgtype.Timestamptz
1903
+	InvalidatedAt    pgtype.Timestamptz
1904
+}
1905
+
18921906
 type DeviceAuthorization struct {
18931907
 	ID              int64
18941908
 	DeviceCodeHash  []byte
internal/pulls/sqlc/models.gomodified
@@ -1889,6 +1889,20 @@ type CodeSearchPath struct {
18891889
 	Tsv     interface{}
18901890
 }
18911891
 
1892
+type CommitVerificationCache struct {
1893
+	RepoID           int64
1894
+	CommitOid        string
1895
+	Reason           string
1896
+	Verified         bool
1897
+	SignerUserID     pgtype.Int8
1898
+	SignerSubkeyID   pgtype.Int8
1899
+	Kind             string
1900
+	SignatureArmored pgtype.Text
1901
+	Payload          []byte
1902
+	VerifiedAt       pgtype.Timestamptz
1903
+	InvalidatedAt    pgtype.Timestamptz
1904
+}
1905
+
18921906
 type DeviceAuthorization struct {
18931907
 	ID              int64
18941908
 	DeviceCodeHash  []byte
internal/ratelimit/sqlc/models.gomodified
@@ -1889,6 +1889,20 @@ type CodeSearchPath struct {
18891889
 	Tsv     interface{}
18901890
 }
18911891
 
1892
+type CommitVerificationCache struct {
1893
+	RepoID           int64
1894
+	CommitOid        string
1895
+	Reason           string
1896
+	Verified         bool
1897
+	SignerUserID     pgtype.Int8
1898
+	SignerSubkeyID   pgtype.Int8
1899
+	Kind             string
1900
+	SignatureArmored pgtype.Text
1901
+	Payload          []byte
1902
+	VerifiedAt       pgtype.Timestamptz
1903
+	InvalidatedAt    pgtype.Timestamptz
1904
+}
1905
+
18921906
 type DeviceAuthorization struct {
18931907
 	ID              int64
18941908
 	DeviceCodeHash  []byte
internal/repos/queries/commit_verification_cache.sqladded
@@ -0,0 +1,62 @@
1
+-- SPDX-License-Identifier: AGPL-3.0-or-later
2
+
3
+-- name: UpsertCommitVerification :exec
4
+-- Idempotent upsert. The verification orchestrator + backfill worker
5
+-- both write through this query; both can safely run concurrently
6
+-- against the same (repo_id, commit_oid) without losing data thanks
7
+-- to the (repo_id, commit_oid) primary key + ON CONFLICT clause.
8
+INSERT INTO commit_verification_cache (
9
+    repo_id, commit_oid, reason, verified,
10
+    signer_user_id, signer_subkey_id, kind,
11
+    signature_armored, payload, verified_at
12
+)
13
+VALUES (
14
+    $1, $2, $3, $4,
15
+    $5, $6, $7,
16
+    $8, $9, now()
17
+)
18
+ON CONFLICT (repo_id, commit_oid) DO UPDATE SET
19
+    reason            = EXCLUDED.reason,
20
+    verified          = EXCLUDED.verified,
21
+    signer_user_id    = EXCLUDED.signer_user_id,
22
+    signer_subkey_id  = EXCLUDED.signer_subkey_id,
23
+    kind              = EXCLUDED.kind,
24
+    signature_armored = EXCLUDED.signature_armored,
25
+    payload           = EXCLUDED.payload,
26
+    verified_at       = now(),
27
+    invalidated_at    = NULL;
28
+
29
+-- name: GetCommitVerification :one
30
+-- Single-commit read. Used by the single-commit page renderer and the
31
+-- REST commits/{sha} response. Returns no row when the commit hasn't
32
+-- been verified yet; caller treats that as "compute on demand".
33
+SELECT repo_id, commit_oid, reason, verified,
34
+       signer_user_id, signer_subkey_id, kind,
35
+       signature_armored, payload, verified_at, invalidated_at
36
+FROM commit_verification_cache
37
+WHERE repo_id = $1 AND commit_oid = $2;
38
+
39
+-- name: GetCommitVerificationsForOIDs :many
40
+-- Batch read for the commit-list page. Takes an array of OIDs and
41
+-- returns existing rows; missing OIDs are absent from the result and
42
+-- the renderer treats them as "not yet verified".
43
+SELECT repo_id, commit_oid, reason, verified,
44
+       signer_user_id, signer_subkey_id, kind,
45
+       signature_armored, payload, verified_at, invalidated_at
46
+FROM commit_verification_cache
47
+WHERE repo_id = $1 AND commit_oid = ANY($2::text[]);
48
+
49
+-- name: InvalidateVerificationsForSubkey :exec
50
+-- Stamps invalidated_at on every cache row whose signer_subkey_id
51
+-- matches. Called from the GPG-key soft-delete path in the same tx as
52
+-- SoftDeleteSubkeysForGPGKey so the cache and the keyring stay in
53
+-- sync. The next read of an invalidated row triggers a re-verify.
54
+UPDATE commit_verification_cache
55
+SET invalidated_at = now()
56
+WHERE signer_subkey_id = $1 AND invalidated_at IS NULL;
57
+
58
+-- name: DeleteCommitVerification :exec
59
+-- Used by tests to reset cache state between cases. Not called from
60
+-- production code paths.
61
+DELETE FROM commit_verification_cache
62
+WHERE repo_id = $1 AND commit_oid = $2;
internal/repos/sqlc/commit_verification_cache.sql.goadded
@@ -0,0 +1,183 @@
1
+// Code generated by sqlc. DO NOT EDIT.
2
+// versions:
3
+//   sqlc v1.31.1
4
+// source: commit_verification_cache.sql
5
+
6
+package reposdb
7
+
8
+import (
9
+	"context"
10
+
11
+	"github.com/jackc/pgx/v5/pgtype"
12
+)
13
+
14
+const deleteCommitVerification = `-- name: DeleteCommitVerification :exec
15
+DELETE FROM commit_verification_cache
16
+WHERE repo_id = $1 AND commit_oid = $2
17
+`
18
+
19
+type DeleteCommitVerificationParams struct {
20
+	RepoID    int64
21
+	CommitOid string
22
+}
23
+
24
+// Used by tests to reset cache state between cases. Not called from
25
+// production code paths.
26
+func (q *Queries) DeleteCommitVerification(ctx context.Context, db DBTX, arg DeleteCommitVerificationParams) error {
27
+	_, err := db.Exec(ctx, deleteCommitVerification, arg.RepoID, arg.CommitOid)
28
+	return err
29
+}
30
+
31
+const getCommitVerification = `-- name: GetCommitVerification :one
32
+SELECT repo_id, commit_oid, reason, verified,
33
+       signer_user_id, signer_subkey_id, kind,
34
+       signature_armored, payload, verified_at, invalidated_at
35
+FROM commit_verification_cache
36
+WHERE repo_id = $1 AND commit_oid = $2
37
+`
38
+
39
+type GetCommitVerificationParams struct {
40
+	RepoID    int64
41
+	CommitOid string
42
+}
43
+
44
+// Single-commit read. Used by the single-commit page renderer and the
45
+// REST commits/{sha} response. Returns no row when the commit hasn't
46
+// been verified yet; caller treats that as "compute on demand".
47
+func (q *Queries) GetCommitVerification(ctx context.Context, db DBTX, arg GetCommitVerificationParams) (CommitVerificationCache, error) {
48
+	row := db.QueryRow(ctx, getCommitVerification, arg.RepoID, arg.CommitOid)
49
+	var i CommitVerificationCache
50
+	err := row.Scan(
51
+		&i.RepoID,
52
+		&i.CommitOid,
53
+		&i.Reason,
54
+		&i.Verified,
55
+		&i.SignerUserID,
56
+		&i.SignerSubkeyID,
57
+		&i.Kind,
58
+		&i.SignatureArmored,
59
+		&i.Payload,
60
+		&i.VerifiedAt,
61
+		&i.InvalidatedAt,
62
+	)
63
+	return i, err
64
+}
65
+
66
+const getCommitVerificationsForOIDs = `-- name: GetCommitVerificationsForOIDs :many
67
+SELECT repo_id, commit_oid, reason, verified,
68
+       signer_user_id, signer_subkey_id, kind,
69
+       signature_armored, payload, verified_at, invalidated_at
70
+FROM commit_verification_cache
71
+WHERE repo_id = $1 AND commit_oid = ANY($2::text[])
72
+`
73
+
74
+type GetCommitVerificationsForOIDsParams struct {
75
+	RepoID  int64
76
+	Column2 []string
77
+}
78
+
79
+// Batch read for the commit-list page. Takes an array of OIDs and
80
+// returns existing rows; missing OIDs are absent from the result and
81
+// the renderer treats them as "not yet verified".
82
+func (q *Queries) GetCommitVerificationsForOIDs(ctx context.Context, db DBTX, arg GetCommitVerificationsForOIDsParams) ([]CommitVerificationCache, error) {
83
+	rows, err := db.Query(ctx, getCommitVerificationsForOIDs, arg.RepoID, arg.Column2)
84
+	if err != nil {
85
+		return nil, err
86
+	}
87
+	defer rows.Close()
88
+	items := []CommitVerificationCache{}
89
+	for rows.Next() {
90
+		var i CommitVerificationCache
91
+		if err := rows.Scan(
92
+			&i.RepoID,
93
+			&i.CommitOid,
94
+			&i.Reason,
95
+			&i.Verified,
96
+			&i.SignerUserID,
97
+			&i.SignerSubkeyID,
98
+			&i.Kind,
99
+			&i.SignatureArmored,
100
+			&i.Payload,
101
+			&i.VerifiedAt,
102
+			&i.InvalidatedAt,
103
+		); err != nil {
104
+			return nil, err
105
+		}
106
+		items = append(items, i)
107
+	}
108
+	if err := rows.Err(); err != nil {
109
+		return nil, err
110
+	}
111
+	return items, nil
112
+}
113
+
114
+const invalidateVerificationsForSubkey = `-- name: InvalidateVerificationsForSubkey :exec
115
+UPDATE commit_verification_cache
116
+SET invalidated_at = now()
117
+WHERE signer_subkey_id = $1 AND invalidated_at IS NULL
118
+`
119
+
120
+// Stamps invalidated_at on every cache row whose signer_subkey_id
121
+// matches. Called from the GPG-key soft-delete path in the same tx as
122
+// SoftDeleteSubkeysForGPGKey so the cache and the keyring stay in
123
+// sync. The next read of an invalidated row triggers a re-verify.
124
+func (q *Queries) InvalidateVerificationsForSubkey(ctx context.Context, db DBTX, signerSubkeyID pgtype.Int8) error {
125
+	_, err := db.Exec(ctx, invalidateVerificationsForSubkey, signerSubkeyID)
126
+	return err
127
+}
128
+
129
+const upsertCommitVerification = `-- name: UpsertCommitVerification :exec
130
+
131
+INSERT INTO commit_verification_cache (
132
+    repo_id, commit_oid, reason, verified,
133
+    signer_user_id, signer_subkey_id, kind,
134
+    signature_armored, payload, verified_at
135
+)
136
+VALUES (
137
+    $1, $2, $3, $4,
138
+    $5, $6, $7,
139
+    $8, $9, now()
140
+)
141
+ON CONFLICT (repo_id, commit_oid) DO UPDATE SET
142
+    reason            = EXCLUDED.reason,
143
+    verified          = EXCLUDED.verified,
144
+    signer_user_id    = EXCLUDED.signer_user_id,
145
+    signer_subkey_id  = EXCLUDED.signer_subkey_id,
146
+    kind              = EXCLUDED.kind,
147
+    signature_armored = EXCLUDED.signature_armored,
148
+    payload           = EXCLUDED.payload,
149
+    verified_at       = now(),
150
+    invalidated_at    = NULL
151
+`
152
+
153
+type UpsertCommitVerificationParams struct {
154
+	RepoID           int64
155
+	CommitOid        string
156
+	Reason           string
157
+	Verified         bool
158
+	SignerUserID     pgtype.Int8
159
+	SignerSubkeyID   pgtype.Int8
160
+	Kind             string
161
+	SignatureArmored pgtype.Text
162
+	Payload          []byte
163
+}
164
+
165
+// SPDX-License-Identifier: AGPL-3.0-or-later
166
+// Idempotent upsert. The verification orchestrator + backfill worker
167
+// both write through this query; both can safely run concurrently
168
+// against the same (repo_id, commit_oid) without losing data thanks
169
+// to the (repo_id, commit_oid) primary key + ON CONFLICT clause.
170
+func (q *Queries) UpsertCommitVerification(ctx context.Context, db DBTX, arg UpsertCommitVerificationParams) error {
171
+	_, err := db.Exec(ctx, upsertCommitVerification,
172
+		arg.RepoID,
173
+		arg.CommitOid,
174
+		arg.Reason,
175
+		arg.Verified,
176
+		arg.SignerUserID,
177
+		arg.SignerSubkeyID,
178
+		arg.Kind,
179
+		arg.SignatureArmored,
180
+		arg.Payload,
181
+	)
182
+	return err
183
+}
internal/repos/sqlc/models.gomodified
@@ -1889,6 +1889,20 @@ type CodeSearchPath struct {
18891889
 	Tsv     interface{}
18901890
 }
18911891
 
1892
+type CommitVerificationCache struct {
1893
+	RepoID           int64
1894
+	CommitOid        string
1895
+	Reason           string
1896
+	Verified         bool
1897
+	SignerUserID     pgtype.Int8
1898
+	SignerSubkeyID   pgtype.Int8
1899
+	Kind             string
1900
+	SignatureArmored pgtype.Text
1901
+	Payload          []byte
1902
+	VerifiedAt       pgtype.Timestamptz
1903
+	InvalidatedAt    pgtype.Timestamptz
1904
+}
1905
+
18921906
 type DeviceAuthorization struct {
18931907
 	ID              int64
18941908
 	DeviceCodeHash  []byte
internal/repos/sqlc/querier.gomodified
@@ -39,6 +39,9 @@ type Querier interface {
3939
 	CreateRepo(ctx context.Context, db DBTX, arg CreateRepoParams) (Repo, error)
4040
 	DeclineTransferRequest(ctx context.Context, db DBTX, id int64) error
4141
 	DeleteBranchProtectionRule(ctx context.Context, db DBTX, id int64) error
42
+	// Used by tests to reset cache state between cases. Not called from
43
+	// production code paths.
44
+	DeleteCommitVerification(ctx context.Context, db DBTX, arg DeleteCommitVerificationParams) error
4245
 	DeleteProfilePinsForSet(ctx context.Context, db DBTX, setID int64) error
4346
 	// Used by the rename compensator: drop a single redirect row when
4447
 	// the rename has to be rolled back due to a filesystem failure. We
@@ -55,6 +58,14 @@ type Querier interface {
5558
 	// offers past their expires_at to the expired terminal state.
5659
 	ExpirePendingTransfers(ctx context.Context, db DBTX) (int64, error)
5760
 	GetBranchProtectionRule(ctx context.Context, db DBTX, id int64) (BranchProtectionRule, error)
61
+	// Single-commit read. Used by the single-commit page renderer and the
62
+	// REST commits/{sha} response. Returns no row when the commit hasn't
63
+	// been verified yet; caller treats that as "compute on demand".
64
+	GetCommitVerification(ctx context.Context, db DBTX, arg GetCommitVerificationParams) (CommitVerificationCache, error)
65
+	// Batch read for the commit-list page. Takes an array of OIDs and
66
+	// returns existing rows; missing OIDs are absent from the result and
67
+	// the renderer treats them as "not yet verified".
68
+	GetCommitVerificationsForOIDs(ctx context.Context, db DBTX, arg GetCommitVerificationsForOIDsParams) ([]CommitVerificationCache, error)
5869
 	GetProfilePinSetForOrg(ctx context.Context, db DBTX, ownerOrgID pgtype.Int8) (int64, error)
5970
 	// ─── profile/org pinned repositories ───────────────────────────────
6071
 	GetProfilePinSetForUser(ctx context.Context, db DBTX, ownerUserID pgtype.Int8) (int64, error)
@@ -82,6 +93,11 @@ type Querier interface {
8293
 	InsertRepoTopic(ctx context.Context, db DBTX, arg InsertRepoTopicParams) error
8394
 	// ─── transfer requests ─────────────────────────────────────────────────
8495
 	InsertTransferRequest(ctx context.Context, db DBTX, arg InsertTransferRequestParams) (RepoTransferRequest, error)
96
+	// Stamps invalidated_at on every cache row whose signer_subkey_id
97
+	// matches. Called from the GPG-key soft-delete path in the same tx as
98
+	// SoftDeleteSubkeysForGPGKey so the cache and the keyring stay in
99
+	// sync. The next read of an invalidated row triggers a re-verify.
100
+	InvalidateVerificationsForSubkey(ctx context.Context, db DBTX, signerSubkeyID pgtype.Int8) error
85101
 	// Used by `shithubd hooks reinstall --all` to enumerate every active
86102
 	// bare repo on disk and re-link its hooks.
87103
 	ListAllRepoFullNames(ctx context.Context, db DBTX) ([]ListAllRepoFullNamesRow, error)
@@ -200,6 +216,12 @@ type Querier interface {
200216
 	UpdateRepoGeneralSettings(ctx context.Context, db DBTX, arg UpdateRepoGeneralSettingsParams) error
201217
 	UpdateRepoMergeSettings(ctx context.Context, db DBTX, arg UpdateRepoMergeSettingsParams) error
202218
 	UpsertBranchProtectionRule(ctx context.Context, db DBTX, arg UpsertBranchProtectionRuleParams) (int64, error)
219
+	// SPDX-License-Identifier: AGPL-3.0-or-later
220
+	// Idempotent upsert. The verification orchestrator + backfill worker
221
+	// both write through this query; both can safely run concurrently
222
+	// against the same (repo_id, commit_oid) without losing data thanks
223
+	// to the (repo_id, commit_oid) primary key + ON CONFLICT clause.
224
+	UpsertCommitVerification(ctx context.Context, db DBTX, arg UpsertCommitVerificationParams) error
203225
 	UpsertProfilePinSetForOrg(ctx context.Context, db DBTX, ownerOrgID pgtype.Int8) (int64, error)
204226
 	UpsertProfilePinSetForUser(ctx context.Context, db DBTX, ownerUserID pgtype.Int8) (int64, error)
205227
 	UpsertRepoSourceRemote(ctx context.Context, db DBTX, arg UpsertRepoSourceRemoteParams) (RepoSourceRemote, error)
internal/social/sqlc/models.gomodified
@@ -1889,6 +1889,20 @@ type CodeSearchPath struct {
18891889
 	Tsv     interface{}
18901890
 }
18911891
 
1892
+type CommitVerificationCache struct {
1893
+	RepoID           int64
1894
+	CommitOid        string
1895
+	Reason           string
1896
+	Verified         bool
1897
+	SignerUserID     pgtype.Int8
1898
+	SignerSubkeyID   pgtype.Int8
1899
+	Kind             string
1900
+	SignatureArmored pgtype.Text
1901
+	Payload          []byte
1902
+	VerifiedAt       pgtype.Timestamptz
1903
+	InvalidatedAt    pgtype.Timestamptz
1904
+}
1905
+
18921906
 type DeviceAuthorization struct {
18931907
 	ID              int64
18941908
 	DeviceCodeHash  []byte
internal/users/sqlc/models.gomodified
@@ -1889,6 +1889,20 @@ type CodeSearchPath struct {
18891889
 	Tsv     interface{}
18901890
 }
18911891
 
1892
+type CommitVerificationCache struct {
1893
+	RepoID           int64
1894
+	CommitOid        string
1895
+	Reason           string
1896
+	Verified         bool
1897
+	SignerUserID     pgtype.Int8
1898
+	SignerSubkeyID   pgtype.Int8
1899
+	Kind             string
1900
+	SignatureArmored pgtype.Text
1901
+	Payload          []byte
1902
+	VerifiedAt       pgtype.Timestamptz
1903
+	InvalidatedAt    pgtype.Timestamptz
1904
+}
1905
+
18921906
 type DeviceAuthorization struct {
18931907
 	ID              int64
18941908
 	DeviceCodeHash  []byte
internal/webhook/sqlc/models.gomodified
@@ -1889,6 +1889,20 @@ type CodeSearchPath struct {
18891889
 	Tsv     interface{}
18901890
 }
18911891
 
1892
+type CommitVerificationCache struct {
1893
+	RepoID           int64
1894
+	CommitOid        string
1895
+	Reason           string
1896
+	Verified         bool
1897
+	SignerUserID     pgtype.Int8
1898
+	SignerSubkeyID   pgtype.Int8
1899
+	Kind             string
1900
+	SignatureArmored pgtype.Text
1901
+	Payload          []byte
1902
+	VerifiedAt       pgtype.Timestamptz
1903
+	InvalidatedAt    pgtype.Timestamptz
1904
+}
1905
+
18921906
 type DeviceAuthorization struct {
18931907
 	ID              int64
18941908
 	DeviceCodeHash  []byte
internal/worker/sqlc/models.gomodified
@@ -1889,6 +1889,20 @@ type CodeSearchPath struct {
18891889
 	Tsv     interface{}
18901890
 }
18911891
 
1892
+type CommitVerificationCache struct {
1893
+	RepoID           int64
1894
+	CommitOid        string
1895
+	Reason           string
1896
+	Verified         bool
1897
+	SignerUserID     pgtype.Int8
1898
+	SignerSubkeyID   pgtype.Int8
1899
+	Kind             string
1900
+	SignatureArmored pgtype.Text
1901
+	Payload          []byte
1902
+	VerifiedAt       pgtype.Timestamptz
1903
+	InvalidatedAt    pgtype.Timestamptz
1904
+}
1905
+
18921906
 type DeviceAuthorization struct {
18931907
 	ID              int64
18941908
 	DeviceCodeHash  []byte