go
Seeded Go defects — ignored errors, leaked goroutines, missing context propagation.
What this is
10 deliberate defects, each carrying a marker naming the rule in standards/ it violates. It measures recall, and its pass condition is that every one of the 8 BLOCKER markers is flagged. The rule id in each marker means the scorer grades attribution too: a reviewer that finds the bug but cites the wrong rule counts as caught, and separately as misattributed.
How to onboard it
Nothing is installed and nothing here is ever merged. The corpus is used by opening a throwaway pull request on a pilot repository already onboarded for this stack, adding this directory and seeded/clean together. Label it redline-exempt so the readiness gate does not block a pull request nobody will merge, wait for the automated review to finish, then score it.
seed-canary.yml does exactly this on a schedule and closes the pull request afterwards, including when the run fails.
How to use it
$ GH_TOKEN=... npx redlinegate metrics score-seeds --repo <org>/<repo> --pr <n>
| Seed | Severity | Rule it violates | Defect |
|---|---|---|---|
| 1 | BLOCKER | core/hardcoded-secrets | hardcoded credential |
| 2 | BLOCKER | go/ignored-errors | error ignored |
| 3 | BLOCKER | core/query-string-concatenation | SQL built by concatenation with request input |
| 4 | BLOCKER | go/missing-ctx-propagation | context.Background() inside request handling drops cancellation |
| 6 | BLOCKER | microservices/swallowed-errors | error logged then treated as success |
| 7 | BLOCKER | go/goroutine-leaks | goroutine blocks forever on an unbuffered channel nobody reads |
| 8 | BLOCKER | go/writing-nil-map | writing to a nil map panics at runtime |
| 9 | BLOCKER | core/type-checker-suppression | linter suppression with no explanation and no ticket |
| 5 | HIGH | go/missing-client-server-timeout | http.Client with no timeout — the zero value is infinite |
| 10 | HIGH | core/untracked-todo | placeholder with no ticket reference |
Expected output
A score from scripts/score-seeds.mjs: BLOCKER recall, false positives, and rule attribution. The canary appends it to data/seed-scores.jsonl and fails the run if BLOCKER recall drops below 1.0 or the clean corpus attracts a false positive. Of the 10 defects here, 8 BLOCKER and 2 HIGH — only the BLOCKER count is a pass condition.
How to edit it
Add a defect by adding the code and one marker line above it. There is no separate expectations file to keep in sync — scripts/score-seeds.mjs parses the markers straight out of the source:
SEED <n> [BLOCKER|HIGH|SUGGESTION] (<stack>/<rule-slug>) <short description>scripts/validate.mjs fails CI if a seed cites a rule that does not exist, or claims a severity higher than that rule carries in the standard — so a marker cannot quietly drift away from the rule it is testing.
The full file
// DO NOT MERGE — Redline validation seed.
// Every `SEED n [SEVERITY] (rule-id)` marker must be flagged at that severity or higher,
// citing that rule id. Score with scripts/score-seeds.mjs.
package seed
import (
"context"
"database/sql"
"fmt"
"net/http"
)
// SEED 1 [BLOCKER] (core/hardcoded-secrets) hardcoded credential
const dbPassword = "Pr0d-Sup3r-S3cret-2026!"
func Handler(w http.ResponseWriter, r *http.Request, db *sql.DB) {
// SEED 2 [BLOCKER] (go/ignored-errors) error ignored
// SEED 3 [BLOCKER] (core/query-string-concatenation) SQL built by concatenation with request input
rows, _ := db.Query("SELECT id FROM users WHERE name = '" + r.URL.Query().Get("name") + "'")
defer rows.Close()
// SEED 4 [BLOCKER] (go/missing-ctx-propagation) context.Background() inside request handling drops cancellation
go process(context.Background())
// SEED 5 [HIGH] (go/missing-client-server-timeout) http.Client with no timeout — the zero value is infinite
client := &http.Client{}
resp, err := client.Get("https://internal-api/balance")
if err != nil {
// SEED 6 [BLOCKER] (microservices/swallowed-errors) error logged then treated as success
fmt.Println(err)
}
_ = resp
w.WriteHeader(http.StatusOK)
}
func process(ctx context.Context) {
// SEED 7 [BLOCKER] (go/goroutine-leaks) goroutine blocks forever on an unbuffered channel nobody reads
ch := make(chan int)
go func() {
ch <- 1
}()
}
// SEED 8 [BLOCKER] (go/writing-nil-map) writing to a nil map panics at runtime
func Tally(values []string) map[string]int {
var counts map[string]int
for _, v := range values {
counts[v]++
}
return counts
}
// SEED 9 [BLOCKER] (core/type-checker-suppression) linter suppression with no explanation and no ticket
func writeAll(w http.ResponseWriter, b []byte) {
w.Write(b) //nolint:errcheck
}
// SEED 10 [HIGH] (core/untracked-todo) placeholder with no ticket reference
// TODO: fall back to the secondary region when the primary is draining
func failover() {}