fix(build): clear pre-existing task check gate blockers (#719)
Baseline `task check` failed on a clean main checkout, blocking unrelated in-flight work. Fixes only those pre-existing failures: - bootstrap.go: extract wireWebStoreSurfaces from setupObservability (cyclop 16 > 15) and startEmbeddedNATS from connectNATS (nestif). - telegram_setup_test.go: os.Setenv -> t.Setenv (usetesting). - install_script_test.go: exec.Command -> exec.CommandContext with t.Context() (noctx). - Taskfile: add a ui:deps install step shared by `ui` and `test:ui`. ui/node_modules is gitignored and nothing in the gate installed it, so `task test:ui` died on a missing jsdom rather than a real test failure. - shutdown_watchdog_test.go: `go fix` output adopted verbatim. Refs bead archie-core-14cs.
This commit is contained in:
1 parent
6af0d51459
commit
4ae6de7dfd
5 files changed
+57
-42
No files matched your search
+13
-2
@@ -44,16 +44,27 @@ tasks:
|
||||
cmds:
|
||||
- govulncheck ./...
|
||||
|
||||
ui:
|
||||
desc: Build the dashboard into ui/dist (committed; the Go build embeds it)
|
||||
ui:deps:
|
||||
desc: Install the dashboard's node dependencies (ui/node_modules is gitignored)
|
||||
internal: true
|
||||
dir: ui
|
||||
cmds:
|
||||
- npm install --no-audit --no-fund
|
||||
|
||||
ui:
|
||||
desc: Build the dashboard into ui/dist (committed; the Go build embeds it)
|
||||
dir: ui
|
||||
deps: [ui:deps]
|
||||
cmds:
|
||||
- npm run build
|
||||
|
||||
test:ui:
|
||||
desc: Run the dashboard's node tests (DOM-building primitives)
|
||||
dir: ui
|
||||
# Without this, a fresh clone fails the gate on a missing jsdom rather
|
||||
# than a real test failure: ui/node_modules is gitignored and nothing
|
||||
# else in `task check` installs it.
|
||||
deps: [ui:deps]
|
||||
cmds:
|
||||
- npm test
|
||||
|
||||
|
||||
@@ -352,10 +352,22 @@ func (b *boot) setupObservability() {
|
||||
// issue is re-polled and the work is done again. It gets only that one
|
||||
// method, not the forge client.
|
||||
b.web.Issues = b.forgeClient
|
||||
// Capture storage: openProductionTaskStore's declared return type is the
|
||||
// narrow store.TaskStore, so the CaptureStore surface (implemented by
|
||||
// the same *store.Store) needs its own assertion here rather than a
|
||||
// direct field reuse. See docs/prds/event-capture-storage.md.
|
||||
b.wireWebStoreSurfaces()
|
||||
sink := bus.Subscribe(256)
|
||||
go persistAndBroadcastEvents(sink, b.st, b.web, log)
|
||||
}
|
||||
|
||||
// wireWebStoreSurfaces attaches the dashboard's optional storage surfaces.
|
||||
// openProductionTaskStore's declared return type is the narrow
|
||||
// store.TaskStore, so each wider surface (all implemented by the same
|
||||
// *store.Store) needs its own assertion here rather than a direct field
|
||||
// reuse. A store that does not implement one degrades that dashboard feature
|
||||
// with a warning instead of aborting bootstrap. The BindingStore/
|
||||
// BindingDispatcher/BindingTaskCreator split keeps each interface under the
|
||||
// interfacebloat limit. See docs/prds/event-capture-storage.md,
|
||||
// docs/prds/payload-field-mapping.md and docs/prds/webhook-intake-security.md.
|
||||
func (b *boot) wireWebStoreSurfaces() {
|
||||
cfg, log := b.cfg, b.log
|
||||
if cs, ok := b.st.(store.CaptureStore); ok {
|
||||
b.web.Captures = cs
|
||||
} else {
|
||||
@@ -365,21 +377,11 @@ func (b *boot) setupObservability() {
|
||||
b.web.CaptureMaxEvents = cfg.Capture.MaxEvents
|
||||
b.web.CaptureMaxBodyBytes = int64(cfg.Capture.MaxBodyBytes)
|
||||
b.web.CaptureLimiter = webhookguard.NewRateLimiter(cfg.Capture.RatePerSecond, cfg.Capture.RateBurst, time.Now)
|
||||
// Mapping storage: same narrow-assertion pattern as CaptureStore above,
|
||||
// for the same reason -- openProductionTaskStore's declared return type
|
||||
// doesn't expose it. See docs/prds/payload-field-mapping.md.
|
||||
if ms, ok := b.st.(store.MappingStore); ok {
|
||||
b.web.Mappings = ms
|
||||
} else {
|
||||
log.Warn("mapping storage unavailable: task store does not implement MappingStore")
|
||||
}
|
||||
// Binding storage: same narrow-assertion pattern as CaptureStore/MappingStore
|
||||
// above, for the same reason. The daemon arm/dispatch logic is wired in
|
||||
// Phase E; here only the storage handle is shared so /api/bindings has
|
||||
// somewhere to read/write. The BindingStore/BindingDispatcher/
|
||||
// BindingTaskCreator split keeps each interface under the
|
||||
// interfacebloat limit; the concrete *store.Store satisfies all three.
|
||||
// See docs/prds/webhook-intake-security.md.
|
||||
if bs, ok := b.st.(store.BindingStore); ok {
|
||||
b.web.Bindings = bs
|
||||
} else {
|
||||
@@ -390,8 +392,6 @@ func (b *boot) setupObservability() {
|
||||
} else {
|
||||
log.Warn("binding dispatcher unavailable: task store does not implement BindingDispatcher")
|
||||
}
|
||||
sink := bus.Subscribe(256)
|
||||
go persistAndBroadcastEvents(sink, b.st, b.web, log)
|
||||
}
|
||||
|
||||
// connectNATS opens the NATS client. External mode dials cfg.NATS.URL;
|
||||
@@ -413,25 +413,11 @@ func (b *boot) connectNATS(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
// Embedded. Start the in-process server before dialing, and register
|
||||
// its shutdown BEFORE the client close below so the client closes
|
||||
// first (cleanups run LIFO).
|
||||
host := ""
|
||||
if b.containerPool != nil {
|
||||
host = b.containerPool.HostGateway()
|
||||
}
|
||||
srv, err := nats.StartEmbedded(ctx, nats.EmbeddedOptions{
|
||||
Host: host,
|
||||
StoreDir: filepath.Join(filepath.Dir(cfg.DBPath), "nats"),
|
||||
}, log)
|
||||
var err error
|
||||
url, natsToken, err = b.startEmbeddedNATS(ctx)
|
||||
if err != nil {
|
||||
log.Error("embedded nats start failed", "err", err)
|
||||
return err
|
||||
}
|
||||
b.addCleanup(func() { srv.Shutdown() })
|
||||
url = srv.ClientURL()
|
||||
natsToken = srv.Token()
|
||||
log.Info("embedded nats started", "url", url)
|
||||
}
|
||||
|
||||
// Composition owns the subject list: the bus must not know which
|
||||
@@ -454,6 +440,28 @@ func (b *boot) connectNATS(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// startEmbeddedNATS starts the in-process nats-server and returns the client
|
||||
// URL and token to dial it with. Its shutdown is registered BEFORE the caller
|
||||
// registers the client close, so the client closes first (cleanups run LIFO).
|
||||
func (b *boot) startEmbeddedNATS(ctx context.Context) (string, string, error) {
|
||||
cfg, log := b.cfg, b.log
|
||||
host := ""
|
||||
if b.containerPool != nil {
|
||||
host = b.containerPool.HostGateway()
|
||||
}
|
||||
srv, err := nats.StartEmbedded(ctx, nats.EmbeddedOptions{
|
||||
Host: host,
|
||||
StoreDir: filepath.Join(filepath.Dir(cfg.DBPath), "nats"),
|
||||
}, log)
|
||||
if err != nil {
|
||||
log.Error("embedded nats start failed", "err", err)
|
||||
return "", "", err
|
||||
}
|
||||
b.addCleanup(func() { srv.Shutdown() })
|
||||
log.Info("embedded nats started", "url", srv.ClientURL())
|
||||
return srv.ClientURL(), srv.Token(), nil
|
||||
}
|
||||
|
||||
// setupContainers builds the managed autonomous-worker pool. Failure degrades
|
||||
// rather than aborting because the native interactive agent and dashboard do
|
||||
// not require Docker; repository tasks park instead of falling back to a host
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package archied
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -73,8 +72,7 @@ func TestShutdownWatchdogCompletingWithinLeashDoesNotExit(t *testing.T) {
|
||||
// needed.
|
||||
func TestBootStartShutdownWatchdogDisarmRunsLast(t *testing.T) {
|
||||
b := newBootstrap()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
ctx := t.Context()
|
||||
b.startShutdownWatchdog(ctx)
|
||||
|
||||
if len(b.cleanups) != 1 {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package archied
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
@@ -61,8 +60,7 @@ func TestResolveTelegramTokenDoesNotUseTokenEnvWhenSecretRefIsSet(t *testing.T)
|
||||
Token: secret.SecretRef{Engine: "bws", Key: "telegram-token"},
|
||||
TokenEnv: "TELEGRAM_LEGACY_TOKEN",
|
||||
}
|
||||
os.Setenv("TELEGRAM_LEGACY_TOKEN", "token-from-env")
|
||||
t.Cleanup(func() { os.Unsetenv("TELEGRAM_LEGACY_TOKEN") })
|
||||
t.Setenv("TELEGRAM_LEGACY_TOKEN", "token-from-env")
|
||||
|
||||
got, err := resolveTelegramToken(cfg, registry)
|
||||
if err != nil {
|
||||
|
||||
@@ -140,7 +140,7 @@ func TestUpdateWatchdogRestoresTaskDatabaseOnDaemonRollback(t *testing.T) {
|
||||
}
|
||||
}
|
||||
for path, version := range map[string]int{dbPath: 2, backupPath: 1} {
|
||||
if output, err := exec.Command("sqlite3", path, fmt.Sprintf("PRAGMA user_version=%d; CREATE TABLE tasks (id INTEGER);", version)).CombinedOutput(); err != nil {
|
||||
if output, err := exec.CommandContext(t.Context(), "sqlite3", path, fmt.Sprintf("PRAGMA user_version=%d; CREATE TABLE tasks (id INTEGER);", version)).CombinedOutput(); err != nil {
|
||||
t.Fatalf("create database %s: %v: %s", path, err, output)
|
||||
}
|
||||
}
|
||||
@@ -157,7 +157,7 @@ func TestUpdateWatchdogRestoresTaskDatabaseOnDaemonRollback(t *testing.T) {
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("watchdog failed: %v\n%s", err, output)
|
||||
}
|
||||
output, err := exec.Command("sqlite3", dbPath, "PRAGMA user_version;").Output()
|
||||
output, err := exec.CommandContext(t.Context(), "sqlite3", dbPath, "PRAGMA user_version;").Output()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user