Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0260afd
docs(prd-4173): record the M4 decisions before code
Nov 11, 2026
e9b4365
store: issue tracker repo link, never-enabled marker and issue-number…
Nov 11, 2026
4c8e062
store: owner-scoped link write, fail-closed guard, lock timeout (PRD …
Nov 11, 2026
f408ea5
store: say which tables 00425 locks and what lock_timeout bounds
Nov 11, 2026
f32a510
test: record forge calls for an unlinked repo before the M4 rerouting…
Nov 11, 2026
395838e
test: record the MR lanes, PRD link patch, autopilot and board writes…
Nov 11, 2026
5def560
test: record promote, issue detail and column setup; keep the poller'…
Nov 11, 2026
aef2320
docs(prd-4173): owner guidance for M4 — S4 bounds and reconnect claus…
Nov 11, 2026
6a59465
issuetrackersvc: link a never-enabled repo to a YouTrack project and …
Nov 11, 2026
f7bd0df
test: the issuetracker connection fake satisfies the widened Querier
Nov 11, 2026
ada63ae
forgetest: owner-only golden file modes; note why golden paths are tr…
Nov 11, 2026
ac45c6e
issuetrackersvc: the upsert itself refuses a linked connection's acco…
Nov 11, 2026
9512aa4
api: refuse sync, runs, schedules and issue creation on a never-enabl…
Nov 11, 2026
972d6a1
issuetrackersvc: a first connect never overwrites a row another conne…
Nov 11, 2026
4afc6b7
issuetrackersvc: name the accepted boundary of Connect's fall-through
Nov 11, 2026
2afdaa5
api: no run of any kind and no schedule on a never-enabled repo (PRD …
Nov 11, 2026
9856050
forgesvc: owner-scoped issue source per repo, M4 write guard and link…
Nov 11, 2026
b472f40
poller: a linked repo whose issue tracker cannot be built gets a refu…
Nov 12, 2026
7e683ec
api: route run creation, schedules, lifecycle and the worker issue ro…
Nov 12, 2026
08343f6
api: resolvers return an error without a store; linked filing answers…
Nov 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions api/cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"time"

"github.com/google/uuid"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgtype"
"github.com/jackc/pgx/v5/pgxpool"

Expand All @@ -34,6 +35,8 @@ import (
"github.com/vtmocanu/uzi/api/internal/healthsvc"
"github.com/vtmocanu/uzi/api/internal/hostedsvc"
"github.com/vtmocanu/uzi/api/internal/hub"
"github.com/vtmocanu/uzi/api/internal/issuetracker"
"github.com/vtmocanu/uzi/api/internal/issuetrackersvc"
mw "github.com/vtmocanu/uzi/api/internal/middleware"
"github.com/vtmocanu/uzi/api/internal/notifysvc"
"github.com/vtmocanu/uzi/api/internal/oidc"
Expand Down Expand Up @@ -1001,6 +1004,20 @@ func run() error {
wsvc.SetRepoGuard(pcheck)

h := handler.New(pool, q, cfg, box, svc, wsvc, pcheck, liveHub, settingsCache)
// External issue tracker connections and the repo link (PRD #4173 M4). The link and
// the reconnect rule run in transactions on the pool. An empty allowlist
// (UZI_ISSUE_TRACKER_ALLOWED_BASE_URLS) still boots: Connect then refuses every URL.
itSvc := issuetrackersvc.New(q, box, cfg.IssueTrackerBaseURLAllowed, issuetracker.New).
UseTransactions(pool, func(tx pgx.Tx) issuetrackersvc.Querier { return q.WithTx(tx) })
h.SetIssueTrackerService(itSvc)
// The same service is forgesvc's driver source for a linked repo's issue side (DL-5);
// without it a linked repo fails closed.
svc.SetIssueTrackerDrivers(itSvc)
// DL-5: the services M2 left on their own forge factories resolve a linked repo's
// issue side through forgesvc too; each fails closed for a linked repo without it.
// provisionsvc needs none: enabling a linked repo only records column rows.
wsvc.SetIssueSources(svc)
lifecycle.SetIssueSources(svc)
svc.SetMergedPredecessorRecovery(q, h.RecoveryService())

var bgWG sync.WaitGroup
Expand Down Expand Up @@ -1055,6 +1072,7 @@ func run() error {
// schedule that came due while the api was down fire promptly after a restart.
if cfg.SchedulerCheckInterval > 0 {
scheduler := schedsvc.New(q, wsvc, svc, settingsCache, notifier, vlt, cfg.SchedulerCheckInterval, slog.Default())
scheduler.SetIssueSources(svc)
scheduler.SetCIRepair(schedsvc.CIRepairConfig{MaxJobs: cfg.CIFixMaxJobs, LogTailBytes: cfg.CIFixLogTailBytes, MaxAttempts: cfg.CIAutofixMaxAttempts, ConfigPaths: cfg.CIAutofixConfigPaths, ArtifactMaxFiles: cfg.CIArtifactMaxFiles, ArtifactMaxBytes: cfg.CIArtifactMaxBytes})
// Admin-health loop-beat: the scheduler is one of the four loops (PRD #1484 M2, D15).
// Registered ONLY inside this started-block, so a not-started scheduler
Expand Down Expand Up @@ -1888,6 +1906,8 @@ func (g gateSubmitter) ConfirmProposalForUser(ctx context.Context, userID, runID
return slacksvc.CreatedIssue{}, slacksvc.ErrChatProposalHandled
case errors.Is(err, workersvc.ErrProposalNotFound):
return slacksvc.CreatedIssue{}, slacksvc.ErrChatProposalGone
case errors.Is(err, workersvc.ErrRepoNeverEnabled):
return slacksvc.CreatedIssue{}, slacksvc.ErrChatProposalRepoNeverEnabled
case errors.Is(err, workersvc.ErrProposalRepoGone),
errors.Is(err, workersvc.ErrForgeBuild),
errors.Is(err, workersvc.ErrForgeIssueWrite),
Expand Down Expand Up @@ -2006,6 +2026,7 @@ func steerRunCardMessage(err error) string {
func isInternalStartRunErr(err error) bool {
switch {
case errors.Is(err, workersvc.ErrRepoNotFound), errors.Is(err, workersvc.ErrIssueNotFound),
errors.Is(err, workersvc.ErrRepoNeverEnabled),
errors.Is(err, workersvc.ErrNotPRDIssue),
errors.Is(err, workersvc.ErrActiveRunExists), errors.Is(err, workersvc.ErrBranchInUse),
errors.Is(err, workersvc.ErrDescriptionTooLarge), errors.Is(err, workersvc.ErrForgeIssueRead):
Expand All @@ -2022,6 +2043,8 @@ func startRunCardMessage(err error) string {
switch {
case errors.Is(err, workersvc.ErrRepoNotFound):
return "That repo isn't yours, or it no longer exists."
case errors.Is(err, workersvc.ErrRepoNeverEnabled):
return "That repo has never been enabled; enable it in uzi first."
case errors.Is(err, workersvc.ErrIssueNotFound):
return "That issue isn't on this repo's board."
case errors.Is(err, workersvc.ErrNotPRDIssue):
Expand Down
41 changes: 41 additions & 0 deletions api/internal/forge/forgetest/golden.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package forgetest

import (
"os"
"path/filepath"
"strings"
"testing"
)

// UpdateGoldenEnv, when set to 1, makes AssertGolden rewrite the golden file
// instead of comparing against it.
const UpdateGoldenEnv = "UZI_UPDATE_GOLDEN"

// AssertGolden compares lines (one recorded forge call per line) with
// testdata/<name> in the calling test's package directory. With
// UZI_UPDATE_GOLDEN=1 it writes the file instead. A missing golden file fails
// the test and names the variable, so a new golden is never created silently.
func AssertGolden(t testing.TB, name string, lines []string) {
t.Helper()
path := filepath.Join("testdata", name)
got := strings.Join(lines, "\n")
if len(lines) > 0 {
got += "\n"
}
if os.Getenv(UpdateGoldenEnv) == "1" {
if err := os.MkdirAll(filepath.Dir(path), 0o750); err != nil {
t.Fatalf("golden %s: mkdir: %v", path, err)
}
if err := os.WriteFile(path, []byte(got), 0o600); err != nil {
t.Fatalf("golden %s: write: %v", path, err)
}
return
}
want, err := os.ReadFile(path) //nolint:gosec // G304: a golden file under the calling test package testdata dir
if err != nil {
t.Fatalf("golden %s unreadable (%v); generate it with %s=1", path, err, UpdateGoldenEnv)
}
if string(want) != got {
t.Fatalf("forge calls differ from golden %s (regenerate only if the change is intended, with %s=1)\n--- want\n%s--- got\n%s", path, UpdateGoldenEnv, want, got)
}
}
Loading
Loading