mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-11-27 18:30:54 +08:00
Refactor PostgreSQL test skipping logic
- Introduced uniform skipping functions in the db package: SkipPGUnavailable and SkipNoPG. - Updated all relevant test files to utilize these new functions for better consistency and readability. - Added new db/testpg.go file to house the skipping logic. - Created architecture and operations documentation to provide a comprehensive overview of the ARTEX system. - Added a verification script to streamline local testing and ensure code quality.
This commit is contained in:
@@ -125,7 +125,7 @@ jobs:
|
||||
# shellcheck is preinstalled on the ubuntu runners. -S warning: the scripts
|
||||
# currently have only info-level notes (intentional A && B || C chains in
|
||||
# update.sh, an unquoted glob in backup.sh's prune), so fail on warnings.
|
||||
- run: shellcheck -S warning install.sh update.sh start.sh scripts/backup.sh reset-password.sh scripts/extract-changelog-section.sh scripts/test-extract-changelog-section.sh .github/scripts/bot.sh scripts/test-bot-context.sh
|
||||
- run: shellcheck -S warning install.sh update.sh start.sh scripts/backup.sh scripts/verify.sh reset-password.sh scripts/extract-changelog-section.sh scripts/test-extract-changelog-section.sh .github/scripts/bot.sh scripts/test-bot-context.sh
|
||||
- run: bash scripts/test-extract-changelog-section.sh
|
||||
# The triage bot's repository summary must expose every top-level
|
||||
# directory; a truncated file list once made it deny that docs/ and
|
||||
|
||||
@@ -651,6 +651,7 @@ CGO_ENABLED=0 go build -tags embedui -o artex ./cmd/artex
|
||||
- Backend: `go run ./cmd/artex` (without `-tags embedui`, the frontend is not embedded)
|
||||
- Frontend: `cd web && npm run dev` (`/api` is reverse-proxied to the backend, with hot reload)
|
||||
- Tests: `go test ./...`
|
||||
- Reproduce all CI checks locally: `./scripts/verify.sh` (add `--full` for `-race` and the static web build)
|
||||
- Mock preview (no backend): `cd web && NEXT_PUBLIC_MOCK=1 npm run dev`
|
||||
|
||||
---
|
||||
@@ -718,6 +719,10 @@ flowchart TB
|
||||
| **db** | PostgreSQL persistence (pgx); embedded schema and numbered migrations applied at startup |
|
||||
| **Supporting** | Recording MITM proxy, approval gate, async enrichment, MCP/skills/memory/report |
|
||||
|
||||
For the code-level map (execution flow, trust boundaries, decisions) see
|
||||
[docs/ARCHITECTURE.md](docs/ARCHITECTURE.md); for startup, configuration precedence,
|
||||
backup and key rotation see [docs/OPS.md](docs/OPS.md).
|
||||
|
||||
---
|
||||
|
||||
## Security
|
||||
|
||||
@@ -26,7 +26,15 @@ func callReadJSON(t *testing.T, tool actool.CoreTool, input string) any {
|
||||
}
|
||||
|
||||
func TestGraphOverviewExpandsAssociatedCompanyScope(t *testing.T) {
|
||||
t.Skip("known failure with a fresh database, pre-existing on unmodified upstream; tracked in BaaRai/ARTEX#9")
|
||||
// Known failure with a freshly seeded database (BaaRai/ARTEX#9). Repro:
|
||||
// ARTEX_PG_DSN=postgres://artex:testpass@localhost:5432/artextest_agent \
|
||||
// go test ./agent -run TestGraphOverviewExpandsAssociatedCompanyScope -count=1 -v
|
||||
// On a fresh DB the company-scope expansion in graphOverviewData is not
|
||||
// visible to the task: the t.Fatalf checks after QueryByTask and
|
||||
// graphOverviewData (company asset linkage, company_scope rows and
|
||||
// company_keywords) fail. Keep the skip until seeding is ordered correctly;
|
||||
// do not delete it.
|
||||
t.Skip("known failure with a fresh database; repro and failing assertions documented above; BaaRai/ARTEX#9")
|
||||
d := testDB(t)
|
||||
defer d.Close()
|
||||
|
||||
|
||||
@@ -17,10 +17,17 @@ import (
|
||||
// Exercise the actual SDK event -> hook -> execution -> result path. No real
|
||||
// model or command is used; the probe tool only returns a fixed string.
|
||||
func TestCaptureApprovalLifecycle(t *testing.T) {
|
||||
t.Skip("known failure with a fresh database, pre-existing on unmodified upstream; tracked in BaaRai/ARTEX#9")
|
||||
// Known failure with a freshly seeded database (BaaRai/ARTEX#9). Repro:
|
||||
// ARTEX_PG_DSN=postgres://artex:testpass@localhost:5432/artextest_agent \
|
||||
// go test ./agent -run TestCaptureApprovalLifecycle -count=1 -v
|
||||
// The checks after ListTaskIntercepts / GetInterceptDetail and the
|
||||
// "unexpected review" t.Fatalf below fail before any other test has seeded
|
||||
// intercept state. Keep this skipped until the fresh-DB setup is fixed;
|
||||
// do not simply delete the skip.
|
||||
t.Skip("known failure with a fresh database; repro and failing assertion documented above; BaaRai/ARTEX#9")
|
||||
dsn, _, err := db.DSN()
|
||||
if err != nil {
|
||||
t.Skip("no test database configured")
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
d, err := db.Open(dsn)
|
||||
if err != nil {
|
||||
|
||||
@@ -15,11 +15,11 @@ func testDB(t *testing.T) *db.DB {
|
||||
t.Helper()
|
||||
dsn, _, err := db.DSN()
|
||||
if err != nil {
|
||||
t.Skipf("no database config (%v)", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
d, err := db.Open(dsn)
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
func TestWorkerReviewContextAcrossToolCalls(t *testing.T) {
|
||||
dsn, _, err := db.DSN()
|
||||
if err != nil {
|
||||
t.Skip("no test database configured")
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
d, err := db.Open(dsn)
|
||||
if err != nil {
|
||||
|
||||
@@ -5,6 +5,11 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// UntrustedBoundaryEnabled reports whether the untrusted-output boundary is on.
|
||||
// Exported for the startup configuration snapshot; the agents themselves keep
|
||||
// calling the private helper below.
|
||||
func UntrustedBoundaryEnabled() bool { return untrustedBoundaryEnabled() }
|
||||
|
||||
// untrustedBoundaryEnabled reports whether Norma's untrusted-output boundary
|
||||
// (agentcore.Options.UntrustedOutputBoundary: tool results framed between
|
||||
// nonce-tagged markers) is on. It is on by default: unset, empty or any other
|
||||
|
||||
+82
-28
@@ -5,6 +5,7 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
@@ -18,9 +19,41 @@ import (
|
||||
|
||||
"github.com/Autumn-27/artex/agent"
|
||||
"github.com/Autumn-27/artex/config"
|
||||
"github.com/Autumn-27/artex/egress"
|
||||
"github.com/Autumn-27/artex/server"
|
||||
)
|
||||
|
||||
// configSnapshot is the single startup log line describing the effective
|
||||
// configuration. It carries no credential material: the DSN is passed through
|
||||
// config.Redact, and no key or token value is ever included.
|
||||
type configSnapshot struct {
|
||||
Version string `json:"version"`
|
||||
ConfigFile string `json:"config_file"`
|
||||
ConfigFileFound bool `json:"config_file_found"`
|
||||
PGDSN string `json:"pg_dsn"`
|
||||
PGDSNSource string `json:"pg_dsn_source"`
|
||||
DataDir string `json:"data_dir"`
|
||||
SkillDir string `json:"skill_dir"`
|
||||
KeyDir string `json:"key_dir"`
|
||||
Addr string `json:"addr"`
|
||||
Proxy string `json:"proxy"`
|
||||
NoiseProfile string `json:"noise_profile"`
|
||||
UntrustedBoundary bool `json:"untrusted_boundary"`
|
||||
TrustedProxies []string `json:"trusted_proxies"`
|
||||
}
|
||||
|
||||
// logConfigSnapshot emits one structured line so an operator can reproduce the
|
||||
// exact configuration of a run from the logs. A serialization failure is
|
||||
// reported but never aborts startup.
|
||||
func logConfigSnapshot(s configSnapshot) {
|
||||
b, err := json.Marshal(s)
|
||||
if err != nil {
|
||||
log.Printf("[config] snapshot unavailable: %v", err)
|
||||
return
|
||||
}
|
||||
log.Printf("[config] snapshot %s", b)
|
||||
}
|
||||
|
||||
// version is the build version, injected at release time via
|
||||
// -ldflags "-X main.version=<tag>". Defaults to "dev" for local builds.
|
||||
var version = "dev"
|
||||
@@ -65,17 +98,59 @@ func run() int {
|
||||
// page can show a live log stream. Do this first, to catch startup logs too.
|
||||
server.StartLogCapture()
|
||||
|
||||
// surface which config file the binary reads (absolute, so `go run`'s relative
|
||||
// "config.json" — resolved against the CWD — is unambiguous).
|
||||
cfgPath := config.Path()
|
||||
// Resolve every effective setting before starting the stores, then emit a
|
||||
// single structured snapshot line. The old code logged the same facts in
|
||||
// five scattered lines, which made a run hard to reproduce from logs.
|
||||
cfgPath := config.Path() // absolute, so `go run`'s relative CWD is unambiguous
|
||||
if abs, e := filepath.Abs(cfgPath); e == nil {
|
||||
cfgPath = abs
|
||||
}
|
||||
if _, e := os.Stat(cfgPath); e == nil {
|
||||
log.Printf("[config] config file: %s", cfgPath)
|
||||
} else {
|
||||
log.Printf("[config] config file: %s (not found — will only try the environment variable ARTEX_PG_DSN)", cfgPath)
|
||||
_, statErr := os.Stat(cfgPath)
|
||||
cfgFound := statErr == nil
|
||||
|
||||
skillDir, err := config.SkillDir()
|
||||
if err != nil {
|
||||
log.Printf("[config] %v", err)
|
||||
return 1
|
||||
}
|
||||
if abs, e := filepath.Abs(skillDir); e == nil {
|
||||
skillDir = abs
|
||||
}
|
||||
// JWT signing key directory (also holds secret.key, see server.NewManager).
|
||||
keyDir := config.KeyDir()
|
||||
// Proxies whose X-Forwarded-For the login rate limit reads; empty trusts none.
|
||||
trusted, err := server.ParseTrustedProxies(os.Getenv("ARTEX_TRUSTED_PROXIES"))
|
||||
if err != nil {
|
||||
log.Printf("[config] ARTEX_TRUSTED_PROXIES: %v", err)
|
||||
return 1
|
||||
}
|
||||
trustedAddrs := make([]string, 0, len(trusted))
|
||||
for _, p := range trusted {
|
||||
trustedAddrs = append(trustedAddrs, p.String())
|
||||
}
|
||||
|
||||
// NewManager resolves the DSN too, but does so internally. Calling
|
||||
// PostgresDSN here is idempotent (no connection, no side effects) and lets
|
||||
// the snapshot show the source and a redacted view even on a failed start.
|
||||
dsn, dsnSource, dsnErr := config.PostgresDSN()
|
||||
if dsnErr != nil {
|
||||
dsn, dsnSource = "", "unavailable"
|
||||
}
|
||||
logConfigSnapshot(configSnapshot{
|
||||
Version: version,
|
||||
ConfigFile: cfgPath,
|
||||
ConfigFileFound: cfgFound,
|
||||
PGDSN: config.Redact(dsn),
|
||||
PGDSNSource: dsnSource,
|
||||
DataDir: *dataDir,
|
||||
SkillDir: skillDir,
|
||||
KeyDir: keyDir,
|
||||
Addr: *addr,
|
||||
Proxy: *proxy,
|
||||
NoiseProfile: egress.ProfileFromEnv().Name,
|
||||
UntrustedBoundary: agent.UntrustedBoundaryEnabled(),
|
||||
TrustedProxies: trustedAddrs,
|
||||
})
|
||||
|
||||
sigCtx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
||||
defer stop()
|
||||
@@ -88,27 +163,6 @@ func run() int {
|
||||
}
|
||||
defer mgr.Close()
|
||||
|
||||
skillDir, err := config.SkillDir()
|
||||
if err != nil {
|
||||
log.Printf("[config] %v", err)
|
||||
return 1
|
||||
}
|
||||
if abs, err := filepath.Abs(skillDir); err == nil {
|
||||
skillDir = abs
|
||||
}
|
||||
log.Printf("[config] skill directory: %s", skillDir)
|
||||
// JWT signing key directory (also holds secret.key, see server.NewManager).
|
||||
keyDir := config.KeyDir()
|
||||
log.Printf("[config] JWT key directory: %s", keyDir)
|
||||
// Proxies whose X-Forwarded-For the login rate limit reads; empty trusts none.
|
||||
trusted, err := server.ParseTrustedProxies(os.Getenv("ARTEX_TRUSTED_PROXIES"))
|
||||
if err != nil {
|
||||
log.Printf("[config] ARTEX_TRUSTED_PROXIES: %v", err)
|
||||
return 1
|
||||
}
|
||||
if len(trusted) > 0 {
|
||||
log.Printf("[config] trusted proxies: %v", trusted)
|
||||
}
|
||||
srv := server.New(ctx, mgr, skillDir, *dataDir, keyDir, server.WithSecretScrub(), server.WithTrustedProxies(trusted))
|
||||
// ReadTimeout bounds how long the request headers and body may take to arrive.
|
||||
// It does not limit how long a handler runs, so an event stream stays open.
|
||||
|
||||
@@ -2,11 +2,37 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Autumn-27/artex/agent"
|
||||
"github.com/Autumn-27/artex/config"
|
||||
)
|
||||
|
||||
// The startup snapshot is meant to be safe to paste into an issue: no DSN
|
||||
// password may survive redaction.
|
||||
func TestConfigSnapshotRedactsDSNPassword(t *testing.T) {
|
||||
s := configSnapshot{
|
||||
Version: "test",
|
||||
ConfigFileFound: true,
|
||||
PGDSN: config.Redact("postgres://artex:super-secret@localhost:5432/artex?sslmode=disable"),
|
||||
PGDSNSource: "environment variable ARTEX_PG_DSN",
|
||||
TrustedProxies: []string{},
|
||||
}
|
||||
b, err := json.Marshal(s)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
out := string(b)
|
||||
if strings.Contains(out, "super-secret") {
|
||||
t.Fatalf("DSN password leaked into snapshot: %s", out)
|
||||
}
|
||||
if !strings.Contains(out, "****") {
|
||||
t.Fatalf("redaction marker missing from snapshot: %s", out)
|
||||
}
|
||||
}
|
||||
|
||||
// The shutdown cause must survive the parent context being cancelled first;
|
||||
// losing it would drop the diagnostic on every graceful stop.
|
||||
func TestShutdownContextPreservesNamedCause(t *testing.T) {
|
||||
|
||||
@@ -20,7 +20,7 @@ func TestActivityOutboxKeepsDetail(t *testing.T) {
|
||||
func TestFlushActivityOutboxReplaysOnce(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
expID, err := d.CreateExploration("outbox", "replay")
|
||||
@@ -63,7 +63,7 @@ func TestFlushActivityOutboxReplaysOnce(t *testing.T) {
|
||||
func TestFlushActivityOutboxDropsStuckRow(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
const missing = int64(9_000_000_000_001)
|
||||
|
||||
@@ -8,7 +8,7 @@ import "testing"
|
||||
func TestActivityPageSessions(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
@@ -129,7 +129,7 @@ func TestActivityPageSessions(t *testing.T) {
|
||||
func TestListByKindPage(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ func testSetup(t *testing.T) (*DB, *AssetStore, *CompanyStore) {
|
||||
t.Helper()
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
return d, d.Assets(), d.Companies()
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ func TestRewriteStockNpxBrowserMCPDoesNotAliasInput(t *testing.T) {
|
||||
func TestSeedAndMigrateBrowserMCP(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
|
||||
origCmd, _, origRaw := readBrowserMCP(t, d)
|
||||
|
||||
+12
-12
@@ -17,7 +17,7 @@ func cleanupCompany(d *DB, id int64) {
|
||||
func TestCompanyUpsertAndGet(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
cs := d.Companies()
|
||||
@@ -64,7 +64,7 @@ func TestCompanyUpsertAndGet(t *testing.T) {
|
||||
func TestCreateCompanyWithScopeRejectsNormalizedDuplicate(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
cs := d.Companies()
|
||||
@@ -103,7 +103,7 @@ func TestCreateCompanyWithScopeRejectsNormalizedDuplicate(t *testing.T) {
|
||||
func TestCreateCompanyWithScopeRollsBackOnScopeWriteFailure(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
cs := d.Companies()
|
||||
@@ -128,7 +128,7 @@ func TestCreateCompanyWithScopeRollsBackOnScopeWriteFailure(t *testing.T) {
|
||||
func TestCompanyScope(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
cs := d.Companies()
|
||||
@@ -166,7 +166,7 @@ func TestCompanyScope(t *testing.T) {
|
||||
func TestCompanyScopeInvalid(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
cs := d.Companies()
|
||||
@@ -195,7 +195,7 @@ func TestCompanyScopeInvalid(t *testing.T) {
|
||||
func TestResolveCompany(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
cs := d.Companies()
|
||||
@@ -236,7 +236,7 @@ func TestResolveCompany(t *testing.T) {
|
||||
func TestUpdateScope(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
cs := d.Companies()
|
||||
@@ -281,7 +281,7 @@ func TestUpdateScope(t *testing.T) {
|
||||
func TestUpdateScopeRollsBackOnInsertFailure(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
cs := d.Companies()
|
||||
@@ -316,7 +316,7 @@ func TestUpdateScopeRollsBackOnInsertFailure(t *testing.T) {
|
||||
func TestDeleteCompany(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
cs := d.Companies()
|
||||
@@ -344,7 +344,7 @@ func TestDeleteCompany(t *testing.T) {
|
||||
func TestDeleteCompanyWithAssetsDeletesBoth(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
cs := d.Companies()
|
||||
@@ -391,7 +391,7 @@ RETURNING id`, domain, id).Scan(&assetID); err != nil {
|
||||
func TestRecomputeAttribution(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
cs := d.Companies()
|
||||
@@ -433,7 +433,7 @@ func TestRecomputeAttribution(t *testing.T) {
|
||||
func TestListCompanies(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
cs := d.Companies()
|
||||
|
||||
@@ -233,7 +233,7 @@ func TestCompanyScopeLimitsAndCheckedErrors(t *testing.T) {
|
||||
func TestCompanyScopeCheckedReturnsSystemErrorSeparately(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
companies := d.Companies()
|
||||
if err := d.Close(); err != nil {
|
||||
|
||||
@@ -233,7 +233,7 @@ func TestParseStructuredCompanyScope(t *testing.T) {
|
||||
func TestCompanyICPAttribution(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Closing the connection must go through t.Cleanup and be **registered before
|
||||
// the data cleanup**: t.Cleanup is last-in-first-out, so registering Close
|
||||
@@ -322,7 +322,7 @@ func TestCompanyICPAttribution(t *testing.T) {
|
||||
func TestCompanyScopeAttribution(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
as := d.Assets()
|
||||
cs := d.Companies()
|
||||
|
||||
@@ -9,7 +9,7 @@ import "testing"
|
||||
func TestProfileMaxTokensRoundTrip(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Close via Cleanup, registered FIRST so it runs LAST: cleanups are LIFO, and a
|
||||
// plain `defer d.Close()` would fire before them — the row-deleting cleanups
|
||||
@@ -77,7 +77,7 @@ func TestProfileMaxTokensRoundTrip(t *testing.T) {
|
||||
func TestProfileMaxTokensDefaults(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Close via Cleanup, registered FIRST so it runs LAST: cleanups are LIFO, and a
|
||||
// plain `defer d.Close()` would fire before them — the row-deleting cleanups
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ import (
|
||||
func TestPoolProfilesOrder(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Close via Cleanup, registered FIRST so it runs LAST: a plain defer would
|
||||
// close the pool before the row-deleting cleanups below run.
|
||||
@@ -83,7 +83,7 @@ func TestDeleteProfileContextHonorsCancellation(t *testing.T) {
|
||||
func TestConfigStores(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
func TestConversationPinOrderingAndPatch(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanup below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
@@ -87,7 +87,7 @@ INSERT INTO exploration_anchors(node_id,asset_id) SELECT fn.id, an.id FROM fn JO
|
||||
func TestBuildCoverageGraphLargeInvariants(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { d.Close() })
|
||||
f := seedLargeCoverageFixture(t, d)
|
||||
|
||||
@@ -100,7 +100,7 @@ func TestCoverageJSONCarriesLedger(t *testing.T) {
|
||||
func TestRecordCoverageUpsertHistory(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanup below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
@@ -157,7 +157,7 @@ func TestRecordCoverageUpsertHistory(t *testing.T) {
|
||||
func TestCoverageCompletenessBudgetThenReviveDone(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanup below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
@@ -221,7 +221,7 @@ func TestCoverageCompletenessBudgetThenReviveDone(t *testing.T) {
|
||||
func TestRecordCoverageRowCap(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanup below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
func TestCustomToolCRUD(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanup below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
+2
-2
@@ -75,7 +75,7 @@ func testDSN(t *testing.T) string {
|
||||
t.Helper()
|
||||
dsn, _, err := DSN()
|
||||
if err != nil {
|
||||
t.Skipf("no database config (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
return dsn
|
||||
}
|
||||
@@ -85,7 +85,7 @@ func testDSN(t *testing.T) string {
|
||||
func TestOpenSeed(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ func assertClearHeads(t *testing.T, d *DB, findingID int64, want TrafficEvidence
|
||||
func TestEvidenceHeadsSealedAtInsert(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { d.Close() })
|
||||
_, fid, s := evidenceFixture(t, d, "insert", false)
|
||||
@@ -106,7 +106,7 @@ func TestEvidenceHeadsSealedAtInsert(t *testing.T) {
|
||||
func TestEvidenceHeadsBackfillAndKeyChecks(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { d.Close() })
|
||||
_, fid, s := evidenceFixture(t, d, "legacy", true)
|
||||
@@ -171,7 +171,7 @@ func TestEvidenceHeadsBackfillAndKeyChecks(t *testing.T) {
|
||||
func TestEvidenceHeadsArchiveRoundTrip(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { d.Close() })
|
||||
if err = d.EnsureLLMRecordsTable(); err != nil {
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
func TestInheritedActivityReadsRequireTerminalIntent(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanups below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
@@ -92,7 +92,7 @@ func TestInheritedActivityReadsRequireTerminalIntent(t *testing.T) {
|
||||
func TestExplorationDirectSourceReadView(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanups below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
@@ -315,7 +315,7 @@ func TestExplorationDirectSourceReadView(t *testing.T) {
|
||||
func TestTaskAssetContextUsesDirectSourceScopeAndAnchors(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanups below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
func TestExplorationFlow(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
@@ -119,7 +119,7 @@ func TestExplorationFlow(t *testing.T) {
|
||||
func TestIntentPauseResumeAndCancelCleanup(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
@@ -252,7 +252,7 @@ func TestIntentPauseResumeAndCancelCleanup(t *testing.T) {
|
||||
func TestNodesPageQueryMatchesID(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
func TestTokenStatsBySessionUsesCompleteIntentHistory(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ func nodeByKey(tree *FindingAssetTree, key string) *FindingAssetNode {
|
||||
func TestBuildFindingAssetTree(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
@@ -164,7 +164,7 @@ func TestBuildFindingAssetTree(t *testing.T) {
|
||||
func TestFindingAssetScopeFilter(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import "testing"
|
||||
func TestFindingQualityByNodeID(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
tk, err := d.CreateTask("finding quality lookup", "goal", nil, 0, 0)
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
func TestFindingReasoningFieldsRoundTrip(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
tk, err := d.CreateTask("finding reasoning fields", "goal", nil, 0, 0)
|
||||
|
||||
+7
-7
@@ -35,7 +35,7 @@ func TestValidFindingReportState(t *testing.T) {
|
||||
func TestDeleteFinding(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
@@ -81,7 +81,7 @@ func TestDeleteFinding(t *testing.T) {
|
||||
func TestSetFindingStatusMirrorsNodePayload(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
@@ -144,7 +144,7 @@ func TestSetFindingStatusMirrorsNodePayload(t *testing.T) {
|
||||
func TestFindingReportState(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
@@ -256,7 +256,7 @@ func TestFindingReportState(t *testing.T) {
|
||||
func TestFindingsPageAndStats(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
@@ -414,7 +414,7 @@ func TestFindingsPageAndStats(t *testing.T) {
|
||||
func TestListFindingsPageUsesStableIDTieBreaker(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
@@ -462,7 +462,7 @@ func TestListFindingsPageUsesStableIDTieBreaker(t *testing.T) {
|
||||
func TestFindingGroupsAndUnassignedPaging(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
@@ -606,7 +606,7 @@ func TestFindingGroupsAndUnassignedPaging(t *testing.T) {
|
||||
func TestAddFindingFollowUpIntent(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ func openClaimInstances(t *testing.T) (*DB, *ExplorationStore, *ExplorationStore
|
||||
dsn := testDSN(t)
|
||||
a, err := Open(dsn)
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { a.Close() })
|
||||
b, err := Open(dsn)
|
||||
@@ -341,7 +341,7 @@ func TestIntentClaimTakeoverRacesHeartbeatAtomically(t *testing.T) {
|
||||
func TestIntentClaimColumnsMigrateIdempotently(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
func TestCompareAndSetIntentStateAllowsSingleWinner(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
expID, err := d.CreateExploration("intent CAS", "only one controller wins")
|
||||
@@ -61,7 +61,7 @@ func TestCompareAndSetIntentStateAllowsSingleWinner(t *testing.T) {
|
||||
func TestCancelIntentPreservesTokenMeteringWithoutDoubleCount(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
expID, err := d.CreateExploration("cancel token rollup", "preserve consumed tokens")
|
||||
@@ -229,7 +229,7 @@ func assertDailyTokenBucketsEqual(t *testing.T, got, want map[string]DailyTokenB
|
||||
func TestCancelIntentPreservesOutputsYieldedByAnotherIntent(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
expID, err := d.CreateExploration("shared intent output", "preserve shared facts and findings")
|
||||
|
||||
@@ -41,7 +41,7 @@ func gone(t *testing.T, es *ExplorationStore, id int64) bool {
|
||||
func TestSoftDeleteIntent(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
expID, err := d.CreateExploration("soft delete", "soft delete")
|
||||
@@ -89,7 +89,7 @@ func TestSoftDeleteIntent(t *testing.T) {
|
||||
func TestHardDeleteCascadesExclusiveDescendants(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
expID, err := d.CreateExploration("hard cascade", "cascade delete")
|
||||
@@ -127,7 +127,7 @@ func TestHardDeleteCascadesExclusiveDescendants(t *testing.T) {
|
||||
func TestHardDeletePreservesSharedAndGoal(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
expID, err := d.CreateExploration("hard preserve", "keep shared/goal")
|
||||
|
||||
+12
-12
@@ -76,7 +76,7 @@ func TestRenderLessonsUsageOmitsTruncated(t *testing.T) {
|
||||
func TestTaskLessonsUsesTaskScopeAndRanksCompanyFirst(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
@@ -174,7 +174,7 @@ func TestTaskLessonsUsesTaskScopeAndRanksCompanyFirst(t *testing.T) {
|
||||
func TestExtractLessonsScopesSingleCompanyFromTaskScope(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
@@ -226,7 +226,7 @@ func TestExtractLessonsScopesSingleCompanyFromTaskScope(t *testing.T) {
|
||||
func TestExtractLessonsSkipsMultiCompanyTask(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
@@ -273,7 +273,7 @@ func TestExtractLessonsSkipsMultiCompanyTask(t *testing.T) {
|
||||
func TestExtractLessonsGenericWhenTaskHasNoCompany(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
@@ -311,7 +311,7 @@ func TestExtractLessonsGenericWhenTaskHasNoCompany(t *testing.T) {
|
||||
func TestTaskLessonsRanksCategoryBeforeGeneric(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
@@ -377,7 +377,7 @@ func TestTaskLessonsRanksCategoryBeforeGeneric(t *testing.T) {
|
||||
func TestLogLessonUsageRecordsOnlyRendered(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
@@ -457,7 +457,7 @@ func insertLessonFinding(t *testing.T, d *DB, taskID int64, status string) int64
|
||||
func TestExtractLessonsRetractsReversedDisposition(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
@@ -569,7 +569,7 @@ func TestExtractLessonsRetractsReversedDisposition(t *testing.T) {
|
||||
func TestExtractLessonsRetireOnlyWhenLastEvidence(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
@@ -660,7 +660,7 @@ func TestExtractLessonsRetireOnlyWhenLastEvidence(t *testing.T) {
|
||||
func TestExtractLessonsRetractsAllRetests(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
@@ -731,7 +731,7 @@ func TestExtractLessonsRetractsAllRetests(t *testing.T) {
|
||||
func TestExtractLessonsDoesNotUnretireWithEvidence(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
@@ -777,7 +777,7 @@ func TestExtractLessonsDoesNotUnretireWithEvidence(t *testing.T) {
|
||||
func TestExtractLessonsLeavesAdopted(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
@@ -820,7 +820,7 @@ func TestExtractLessonsLeavesAdopted(t *testing.T) {
|
||||
func TestExtractLessonsReopenRetractsNothing(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
func TestLLMRecordsMigrateAddsRawColumnsToOldTable(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
if err := d.EnsureLLMRecordsTable(); err != nil {
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
func TestLLMUsageTsIndex(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
|
||||
+3
-3
@@ -13,7 +13,7 @@ import (
|
||||
func TestProfileRetryRoundTrip(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanup below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
@@ -71,7 +71,7 @@ func TestProfileRetryRoundTrip(t *testing.T) {
|
||||
func TestProfileRetryClampedOnSave(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanup below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
@@ -98,7 +98,7 @@ func TestProfileRetryClampedOnSave(t *testing.T) {
|
||||
func TestLLMRetryPolicyRoundTrip(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the restore below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
+3
-3
@@ -52,11 +52,11 @@ func scratchDSN(t *testing.T, suffix string) string {
|
||||
admin.Path = "/postgres"
|
||||
conn, err := sql.Open("pgx", admin.String())
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
if err := conn.Ping(); err != nil {
|
||||
conn.Close()
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
drop := func() error {
|
||||
_, err := conn.Exec(`DROP DATABASE IF EXISTS "` + name + `" WITH (FORCE)`)
|
||||
@@ -189,7 +189,7 @@ func TestOpenRecordsEmbeddedMigrations(t *testing.T) {
|
||||
dsn := testDSN(t)
|
||||
d, err := Open(dsn)
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
applied := assertEmbeddedApplied(t, d)
|
||||
d.Close()
|
||||
|
||||
@@ -18,7 +18,7 @@ func notifyTestDB(t *testing.T) *DB {
|
||||
t.Helper()
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { d.Close() })
|
||||
return d
|
||||
|
||||
+3
-3
@@ -200,7 +200,7 @@ func assertPlainReads(t *testing.T, d *DB, r secretRows) {
|
||||
func TestSecretsAtRestWriteRead(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { d.Close() }) // after the fixture cleanup
|
||||
r := secretFixture(t, d, false)
|
||||
@@ -214,7 +214,7 @@ func TestSecretsAtRestWriteRead(t *testing.T) {
|
||||
func TestSecretsBackfillLegacyAndKeyChecks(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { d.Close() }) // after the fixture cleanup
|
||||
r := secretFixture(t, d, true)
|
||||
@@ -287,7 +287,7 @@ func encryptedCount(t *testing.T, d *DB, dir string) int {
|
||||
func TestSecretSettingsEmptyAndClear(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
d.Exec(deleteSecretSettings)
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
func TestInsertSettingIfAbsentDoesNotOverwrite(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
@@ -50,7 +50,7 @@ func TestInsertSettingIfAbsentDoesNotOverwrite(t *testing.T) {
|
||||
func TestRotatePasswordRollsBackHashWhenVersionCannotIncrement(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
func TestSkillUsageLedger(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ func openTargetDB(t *testing.T) *DB {
|
||||
t.Helper()
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { d.Close() })
|
||||
return d
|
||||
|
||||
@@ -123,7 +123,7 @@ func TestTaskArchiveFormatCompatibility(t *testing.T) {
|
||||
func TestTaskArchiveDatabaseRoundTrip(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
if err := d.EnsureLLMRecordsTable(); err != nil {
|
||||
@@ -335,7 +335,7 @@ VALUES($1,$2,0,'quota_exhausted','balance exhausted',$3,$4,$3)`, task.ID, llmPro
|
||||
func TestTaskArchiveBlockersIgnoreQueuedDependents(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
source, err := d.CreateTaskWithOptions("archive blocker source", "source", TaskCreateOptions{})
|
||||
@@ -400,7 +400,7 @@ func assertPerTaskBlockers(t *testing.T, d *DB, global map[int64]int64, want map
|
||||
func TestRecoverInterruptedArchiveRequiresManualRetry(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
task, err := d.CreateTaskWithOptions("interrupted archive", "must not restart automatically", TaskCreateOptions{})
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
func TestRegisterTaskAssetScopesCreatesAssetsAndPersistsTextScope(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanups below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
@@ -93,7 +93,7 @@ func TestRegisterTaskAssetScopesCreatesAssetsAndPersistsTextScope(t *testing.T)
|
||||
func TestTaskAssetAttachDetachPreservesGlobalAssetAndAnchors(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanups below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
@@ -150,7 +150,7 @@ func TestTaskAssetAttachDetachPreservesGlobalAssetAndAnchors(t *testing.T) {
|
||||
func TestIntentAssetsIncludesDirectSourceProvenance(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanups below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
func TestTaskCategoryCRUDAndTaskAssignment(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanup below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
@@ -73,7 +73,7 @@ func TestTaskCategoryCRUDAndTaskAssignment(t *testing.T) {
|
||||
func TestCreateTaskRejectsMissingCategoryAtomically(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
@@ -94,7 +94,7 @@ func TestCreateTaskRejectsMissingCategoryAtomically(t *testing.T) {
|
||||
func TestSetTasksCategoryBatch(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanups below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
@@ -155,7 +155,7 @@ func TestSetTasksCategoryBatch(t *testing.T) {
|
||||
func TestSetTasksCategoryRejectsBadInputAtomically(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanup below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
@@ -11,7 +11,7 @@ func TestTaskLLMProfileMutationsLockTaskBeforeProfile(t *testing.T) {
|
||||
dsn := testDSN(t)
|
||||
d, err := Open(dsn)
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanup below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
@@ -111,7 +111,7 @@ func TestDeleteProfileLocksNonTaskReferencesBeforeProfile(t *testing.T) {
|
||||
t.Run("agent", func(t *testing.T) {
|
||||
d, err := Open(dsn)
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanup below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
@@ -169,7 +169,7 @@ func TestDeleteProfileLocksNonTaskReferencesBeforeProfile(t *testing.T) {
|
||||
t.Run("conversation", func(t *testing.T) {
|
||||
d, err := Open(dsn)
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanup below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
@@ -226,7 +226,7 @@ func TestNonTaskProfileMutationsLockReferenceBeforeProfile(t *testing.T) {
|
||||
t.Run("agent", func(t *testing.T) {
|
||||
d, err := Open(dsn)
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanup below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
@@ -275,7 +275,7 @@ func TestNonTaskProfileMutationsLockReferenceBeforeProfile(t *testing.T) {
|
||||
t.Run("conversation", func(t *testing.T) {
|
||||
d, err := Open(dsn)
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanup below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
@@ -326,7 +326,7 @@ func TestCreateConversationAndDeleteProfileDoNotDeadlock(t *testing.T) {
|
||||
dsn := testDSN(t)
|
||||
d, err := Open(dsn)
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanup below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
@@ -407,7 +407,7 @@ func TestDeleteProfileRetriesReferenceCommittedAfterInitialScan(t *testing.T) {
|
||||
dsn := testDSN(t)
|
||||
d, err := Open(dsn)
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanup below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
@@ -13,7 +13,7 @@ func TestDeleteTaskTrafficHostsUseOneLockedTransaction(t *testing.T) {
|
||||
dsn := testDSN(t)
|
||||
d, err := Open(dsn)
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
func TestListTasksBulkHydratesTaskContext(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanups below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
@@ -71,7 +71,7 @@ func TestListTasksBulkHydratesTaskContext(t *testing.T) {
|
||||
func TestTaskListMetricsAll(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanup below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
@@ -123,7 +123,7 @@ VALUES ($1,'goal','{}','met'), ($1,'goal','{}','open')`, task.ExplorationID); er
|
||||
func TestTaskListMetricsMatchesAll(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
func TestTaskLLMSpendCountsJudgeNotChat(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
func TestTaskPinOrderingAndRename(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
@@ -71,7 +71,7 @@ func TestTaskPinOrderingAndRename(t *testing.T) {
|
||||
func TestDeleteConversationsReturnsExistingIDs(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
func TestTaskQueuePreservesBootstrapAndFIFOPosition(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
func TestTaskRotationPersistenceAndFailover(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable: %v", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
ids := []int64{}
|
||||
|
||||
@@ -12,7 +12,7 @@ func TestCoverageEnabledWithoutTask(t *testing.T) {
|
||||
func TestCoverageEnabledMissingRowStaysOn(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
on, err := d.Assets().CoverageEnabled(9_000_000_000_001)
|
||||
@@ -24,7 +24,7 @@ func TestCoverageEnabledMissingRowStaysOn(t *testing.T) {
|
||||
func TestCoverageEnabledQueryErrorStaysOn(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
if err := d.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
func TestTaskTemplateCRUDAndNormalizedUniqueness(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanup below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
@@ -87,7 +87,7 @@ func TestTaskTemplateCRUDAndNormalizedUniqueness(t *testing.T) {
|
||||
func TestTaskTemplateDisjointPatchesCompose(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanup below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
+6
-6
@@ -11,7 +11,7 @@ import (
|
||||
func TestTaskLifecycleAndDeleteCascade(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
@@ -85,7 +85,7 @@ func TestTaskLifecycleAndDeleteCascade(t *testing.T) {
|
||||
func TestTaskDeleteCascadeAssets(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanups below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
@@ -211,7 +211,7 @@ func TestTaskDeleteCascadeAssets(t *testing.T) {
|
||||
func TestTaskRelationsAndLLMFailoverChain(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanups below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
@@ -470,7 +470,7 @@ func TestTaskRelationsAndLLMFailoverChain(t *testing.T) {
|
||||
func TestTaskContextRejectsDuplicatesAndAllowsTerminalLLMEdits(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanups below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
@@ -525,7 +525,7 @@ func TestTaskContextRejectsDuplicatesAndAllowsTerminalLLMEdits(t *testing.T) {
|
||||
func TestCreateTaskWithCompanyScopes(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanups below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
@@ -680,7 +680,7 @@ RETURNING id`, domainB, companyB).Scan(&companyAssetB); err != nil {
|
||||
func TestListTasksOrderByIDDesc(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
// Registered FIRST so it runs LAST, after the row cleanups below.
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package db
|
||||
|
||||
// skipper is the part of testing.TB used by the PostgreSQL test helpers below.
|
||||
// A local interface keeps the production package from importing "testing":
|
||||
// *testing.T, *testing.B and the test-only wrappers all satisfy it.
|
||||
type skipper interface {
|
||||
Helper()
|
||||
Skipf(format string, args ...any)
|
||||
}
|
||||
|
||||
// SkipPGUnavailable skips the calling test with one uniform reason when err
|
||||
// reports that the test database could not be configured or opened.
|
||||
//
|
||||
// Every PostgreSQL-dependent test uses this instead of spelling the skip text
|
||||
// inline (the old variants differed by package: "no database config",
|
||||
// "database unavailable", "postgres unavailable — skipping", ...). Call it
|
||||
// with the err returned by DSN(), Open() or NewManager(). It does not change
|
||||
// when a test skips — only how the reason is reported.
|
||||
func SkipPGUnavailable(t skipper, err error) {
|
||||
t.Helper()
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
}
|
||||
}
|
||||
|
||||
// SkipNoPG skips with the same uniform reason when a store is unexpectedly nil
|
||||
// after a successful open (for example Manager.pg when only some backends are
|
||||
// configured). It carries no error because there is none to report.
|
||||
func SkipNoPG(t skipper) {
|
||||
t.Helper()
|
||||
t.Skip("postgres unavailable")
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import "testing"
|
||||
func TestToolUsageLedger(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ func jsonEqual(t *testing.T, a, b string) bool {
|
||||
func TestToolExecSealedAtRest(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
d.Exec(`DELETE FROM tools WHERE key LIKE 't_secexec%'`)
|
||||
@@ -129,7 +129,7 @@ func TestToolExecSealedAtRest(t *testing.T) {
|
||||
func TestToolExecBackfillAndKeyChecks(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
d.Exec(`DELETE FROM tools WHERE key LIKE 't_secexec%'`)
|
||||
|
||||
@@ -26,7 +26,7 @@ func openRewriteRules(t *testing.T) *DB {
|
||||
t.Helper()
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
clean := func() { d.Exec(`DELETE FROM traffic_rewrite_rules WHERE name LIKE 't-rw-%'`) }
|
||||
clean()
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
# ARTEX architecture (code-level companion)
|
||||
|
||||
The README's [Architecture](https://github.com/BaaRai/ARTEX#architecture) section has the
|
||||
component diagram and the 10,000-foot view. This document records the code-level map,
|
||||
the execution flow and the trust boundaries that are easy to miss when reading the
|
||||
packages in isolation.
|
||||
|
||||
## 1. The two graphs
|
||||
|
||||
ARTEX keeps two linked graphs, both in PostgreSQL (`db/schema.sql`):
|
||||
|
||||
| Graph | Answers | Main tables | Code |
|
||||
| --- | --- | --- | --- |
|
||||
| **Asset graph** | *What exists?* | `companies`, `company_scope`, `assets`, `task_scope` | `db/assets.go`, `db/companies.go`, `db/company_scope.go`, `db/task_assets.go` |
|
||||
| **Exploration graph** | *What was tried, with what result and why?* | `explorations`, `exploration_nodes`, `activity`, `intent_*`, `coverage_*` | `db/exploration.go`, `db/coverage_ledger.go`, `db/finding_assets.go` |
|
||||
|
||||
Anchors tie a finding to the assets that justify it (`db/finding_assets.go`). Traffic
|
||||
snapshots are archived separately and referenced from findings
|
||||
(`db/finding_traffic.go`, `db/finding_traffic_archive.go`, `traffic/archive.go`).
|
||||
|
||||
`db.Open` executes the idempotent `schema.sql` on every startup, then applies pending
|
||||
numbered migrations from `db/migrations/*.sql`, recording name + SHA-256 in
|
||||
`schema_migrations`. A published migration is never edited; fix forward with a new one.
|
||||
|
||||
## 2. Package map
|
||||
|
||||
| Package | Responsibility | Notes |
|
||||
| --- | --- | --- |
|
||||
| `cmd/artex` | Process entry point | Flags (`-addr`, `-data`, `-proxy`), startup config snapshot, signal handling, graceful drain |
|
||||
| `config` | Resolve config file + env | `Path`, `Load`, `PostgresDSN`, `SkillDir`, `KeyDir`, `Redact`. Env wins over file |
|
||||
| `db` | All persistence | `DB`, `Manager`-independent stores; AES-256-GCM secret columns in `secrets.go` |
|
||||
| `agent` | LLM roles and tools | `goals`, `planner`, `worker`, `mainagent`, `retester`; `ToolSet` in `tools.go`; tool catalog in `toolcatalog.go` |
|
||||
| `server` | HTTP API + orchestration | `net/http` mux (~270 routes), `Manager`, `Engine`, JWT auth, SSE broadcaster |
|
||||
| `traffic` | Recording proxy | MITM proxy built on `go-mitmproxy`, replay, rewrite rules, body archive |
|
||||
| `evidence` | Evidence store | Persisted request/response snapshots used by findings |
|
||||
| `intercept` | Approval gate | Judge, argv grammar, target gate, pins, risk scoring (a `PreToolUse` hook) |
|
||||
| `guard` | Hook wiring | Binds `intercept` decisions into Norma's hook registry; `NewTargetOnly` for planner/mainagent |
|
||||
| `egress` | Noise governor | Per-host token bucket, jitter, concurrency caps, 429/503 backoff; default profile is strict passthrough |
|
||||
| `llmpool` / `llmrec` | Provider pool / recorder | Rotation, health, usage + raw wire capture |
|
||||
| `mcphttp` | MCP client | HTTP/SSE transport for configured MCP servers |
|
||||
| `notify` | Outbound notifications | Email, webhook, Telegram, Feishu, DingTalk with masking and SSRF guards |
|
||||
| `report` | Deliverables | Markdown, CSV and JSON rendering of findings |
|
||||
| `sidequestion` | Operator Q&A | Asks a human mid-run and suspends intent until answered |
|
||||
| `skills/` | Skill definitions | One `SKILL.md` per subdirectory, loaded from `SkillDir()` |
|
||||
|
||||
The frontend lives in `web/` (Next.js 16, React 19) and is embedded into the Go
|
||||
binary via `server/webui_embed.go` when built with `-tags embedui`.
|
||||
|
||||
## 3. End-to-end flow: goal → finding with evidence
|
||||
|
||||
1. **Task creation.** `server.createTask` → `Manager.CreateTaskWithOptions` writes the
|
||||
task, its scope and seed goals, and creates the exploration graph (`db/tasks.go`).
|
||||
2. **Loop start.** `Engine.Run` (`server/engine.go`) starts a planner loop and N worker
|
||||
goroutines under a task-scoped context. Nothing needs an LLM to be configured for the
|
||||
loops to exist; they idle until one is.
|
||||
3. **Decomposition.** The `goals` role writes goals and operation constraints through
|
||||
`set_goals` / `set_constraints` (`agent/toolcatalog.go`, `agent/tools.go`).
|
||||
4. **Planning.** `Planner.Plan` (`agent/planner.go`) reads the route, queries the asset
|
||||
graph, judges goals and emits intents (`addOneIntent`). Every intent is an
|
||||
exploration node, so it is auditable like any other activity.
|
||||
5. **Execution.** `Worker.Execute` (`agent/worker.go`) claims an intent, runs tools with
|
||||
the guard hooks attached and writes observed facts back to the exploration graph.
|
||||
6. **Tools and traffic.** Shell and HTTP/WebFetch calls go through the recording proxy
|
||||
and the egress governor. Platform-owned HTTP clients use `intercept.PinnedDialer`
|
||||
and `intercept.RedirectCheck` so a redirect or a direct retry cannot leave the gate.
|
||||
7. **Findings.** `addFinding` (`agent/tools.go`) records severity, class, confidence and
|
||||
asset references; `db/findings.go` dedups and keeps the status workflow. Evidence is
|
||||
linked to captured traffic (`traffic/evidence.go`, `db/finding_traffic.go`).
|
||||
8. **Completion.** `prove_goal` marks a goal met; the last met goal completes the task.
|
||||
`goal_met` is deliberately unbound by default because it bypasses per-goal proof.
|
||||
|
||||
## 4. Execution control
|
||||
|
||||
- **Per-task context:** pause/cancel/kill attach a named cause via
|
||||
`context.WithCancelCause` so the activity trace records who initiated a stop.
|
||||
- **Per-intent control:** the UI can pause/cancel one intent; `steerBox` queues a
|
||||
planner course-correction that the worker's `PreToolUse` hook drains before the next
|
||||
tool call, re-planning without killing the run.
|
||||
- **Delete barrier:** `Engine.BeginDelete` makes installing the barrier atomic with
|
||||
registering an in-flight operation; after it returns, no new task-owned writes are
|
||||
admitted and the task context is cancelled once existing writers drain.
|
||||
- **Quiet mode:** an unchanged open-goal fingerprint suppresses redundant planning
|
||||
rounds while work is still in flight.
|
||||
|
||||
## 5. Trust boundaries
|
||||
|
||||
| Boundary | Implementation |
|
||||
| --- | --- |
|
||||
| Tool output → model | Norma's untrusted-output boundary: nonce-tagged markers around tool results. On unless `ARTEX_UNTRUSTED_BOUNDARY` disables it. See `agent/untrusted_boundary.go` |
|
||||
| Command → host | `intercept.ParseSimpleCommand` parses exactly one Bash simple command; pipelines, redirections, wrappers (`env`, `exec`, `eval`, `command`), substitutions and expansions are rejected. `ArgvPrefixOf` derives the human-readable prefix for allow/deny rules |
|
||||
| URL → network | Target gate + `PinnedDialer` + `RedirectCheck`: scope decisions are re-made against a fresh DNS lookup at dial time, and the client connects only to the addresses it compared |
|
||||
| Secrets → disk/log | `db/secrets.go` seals API keys, proxy credentials, MCP env, task credentials and captured auth headers with AES-256-GCM, nonce per value, AAD `table.column`. JWT keys live in `KeyDir()`, never in the browsable data dir. The boot snapshot logs only `config.Redact(dsn)` |
|
||||
| Approval → audit | Every decision records the approver (`jwtSubject`), source and decision; history is queryable through `/api/intercept/history` and `/api/intercept/history/{id}` (with `/execution` for the audit detail). `/api/tasks/{id}/intercept-rules` manages rules, not history |
|
||||
|
||||
## 6. Decisions
|
||||
|
||||
- **ADR-001 — Nonce-tagged untrusted output.** Tool output is framed with a per-run
|
||||
nonce rather than trusting the model to distinguish instructions from data.
|
||||
- **ADR-002 — Pin at dial time.** A URL decision is not enough: DNS can change between
|
||||
the hook and the connection, so the dialer re-resolves and connects only to compared
|
||||
addresses.
|
||||
- **ADR-003 — AES-GCM with per-column AAD.** Sealed values are bound to their table and
|
||||
column (and settings to their key), so a ciphertext cannot be moved to another field.
|
||||
|
||||
## 7. Where to look next
|
||||
|
||||
- `docs/OPS.md` for startup, configuration precedence, backup and key rotation.
|
||||
- `docs/vulnerability-traffic-evidence.md` for how a finding keeps its receipts.
|
||||
- `docs/traffic-rewrite-rules.md` for the rewrite engine.
|
||||
- `scripts/verify.sh` to reproduce the CI checks locally.
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
# ARTEX operations
|
||||
|
||||
## 1. Startup
|
||||
|
||||
Docker (recommended):
|
||||
|
||||
```bash
|
||||
cp .env.example .env # set POSTGRES_PASSWORD; optionally an LLM key
|
||||
docker compose up -d --build
|
||||
docker compose logs artex | grep "Setup token"
|
||||
```
|
||||
|
||||
Open `http://localhost:8787`. The first visit to `/setup` asks for the one-time setup
|
||||
token printed at startup (`[auth] no admin password is set. Setup token for the /setup
|
||||
page: ...` in `server/auth.go`).
|
||||
|
||||
From source (no embedded UI):
|
||||
|
||||
```bash
|
||||
go run ./cmd/artex # backend only, 127.0.0.1:8787
|
||||
cd web && npm run dev # UI on :5173, /api proxied to the backend
|
||||
# or: ./dev.sh # both, plus the traffic proxy on :8788
|
||||
```
|
||||
|
||||
The process prints one `[config] snapshot {...}` line at startup. It is the authoritative
|
||||
record of the effective configuration: config path, DSN source and **redacted** DSN,
|
||||
data/skill/key directories, listen address, proxy, noise profile, untrusted-output
|
||||
boundary and trusted proxies. No password or token value is ever logged there.
|
||||
|
||||
## 2. Configuration precedence
|
||||
|
||||
| Setting | Resolution order | Code |
|
||||
| --- | --- | --- |
|
||||
| Config file | `ARTEX_CONFIG` → `./config.json` → `config.json` next to the binary | `config.Path` |
|
||||
| PostgreSQL DSN | `ARTEX_PG_DSN` → `database.dsn` → assembled `host/port/user/password/dbname` | `config.PostgresDSN` |
|
||||
| Skill directory | `ARTEX_SKILL_DIR` → `skill_dir` → `<binary dir>/skills` | `config.SkillDir` |
|
||||
| JWT / secret key directory | `ARTEX_JWT_KEY_DIR` → `<binary dir>` (never the browsable data dir) | `config.KeyDir` |
|
||||
| Secret encryption key | `ARTEX_SECRET_KEY` → `<key dir>/secret.key` → newly generated key file | `db.InitSecrets` |
|
||||
| Noise profile | `ARTEX_NOISE_PROFILE` (`off` default; `quiet`, `balanced`, `aggressive`), also settable in UI | `egress.ProfileFromEnv` |
|
||||
| Untrusted-output boundary | on by default; `ARTEX_UNTRUSTED_BOUNDARY=0\|false\|off\|no` disables it | `agent/untrusted_boundary.go` |
|
||||
| Trusted proxies for login rate limit | `ARTEX_TRUSTED_PROXIES` (comma-separated IPs/CIDRs; empty trusts none) | `server.ParseTrustedProxies` |
|
||||
| Target user agent | `ARTEX_TARGET_USER_AGENT` (applied by non-`off` noise profiles) | `egress.ProfileByName` |
|
||||
| Budgets | `ARTEX_TASK_BUDGET_TOKENS` / `_TURNS`, `ARTEX_INTENT_BUDGET_TOKENS` / `_TURNS` | `agent/budget.go` |
|
||||
| Live model judge test | `ARTEX_REVIEW_LIVE_CONFIG` (opt-in integration test only) | `server/intercept_live_test.go` |
|
||||
|
||||
Agent profiles, providers, notifications and other runtime settings live in the database
|
||||
and are edited in **System → LLM / Settings / Notify**, not in `config.json`.
|
||||
|
||||
## 3. Backup and restore
|
||||
|
||||
```bash
|
||||
scripts/backup.sh # database dump only, 14 rotations
|
||||
scripts/backup.sh --with-data --keep 30 # also archive the data/ bind mount
|
||||
```
|
||||
|
||||
The dump runs inside the `postgres` compose service, so no host `psql` is needed. Restore:
|
||||
|
||||
```bash
|
||||
gunzip -c backups/artex-db-<ts>.sql.gz | docker compose exec -T postgres \
|
||||
psql -U "$POSTGRES_USER" -d "$POSTGRES_DB"
|
||||
```
|
||||
|
||||
Back up the key directory as well: without it, JWTs cannot be verified and sealed
|
||||
secrets cannot be decrypted. Keep it outside the database backup but under the same
|
||||
access controls.
|
||||
|
||||
## 4. Key rotation
|
||||
|
||||
- **`jwt.key`** — signing key for the 7-day HS256 session tokens. Replacing it
|
||||
invalidates every existing session; all users must log in again. Existing key files
|
||||
are never overwritten by startup (`loadOrCreateJWTKey`).
|
||||
- **`secret.key`** (or `ARTEX_SECRET_KEY`) — AES-256-GCM key for API keys, MCP env,
|
||||
task credentials and captured auth headers. Startup never overwrites an existing key.
|
||||
If it changes, values sealed under the old key cannot be decrypted (the code returns
|
||||
an error rather than leaking ciphertext as plaintext). Re-enter those secrets in the
|
||||
UI, or keep the previous key available until the migration is complete.
|
||||
|
||||
Plan a short maintenance window for either rotation.
|
||||
|
||||
## 5. Diagnostics and local verification
|
||||
|
||||
- `GET /api/health` — liveness, build version and provider health.
|
||||
- `GET /api/logs`, `GET /api/logs/stream` — live backend log sink; the UI shows it under
|
||||
**System → Logs**. The startup snapshot line is here too.
|
||||
- `scripts/verify.sh` — reproduces the CI checks locally (gofmt, build, vet, tests,
|
||||
web type-check and unit tests, shellcheck, python checks). `--full` adds `-race` and
|
||||
the web static build; `--go-only` / `--web-only` narrow the run.
|
||||
- `./scripts/backup.sh --help` — backup options.
|
||||
|
||||
When Postgres is not configured, database-dependent tests skip themselves; that is
|
||||
expected. Set `ARTEX_PG_DSN` to run them. CI uses `go test -p 1 ./...` because test
|
||||
packages share a Postgres service and use suffixed per-package databases
|
||||
(`SuffixTestDatabase`).
|
||||
@@ -325,7 +325,7 @@ func newGateDB(t *testing.T) *gateDB {
|
||||
t.Helper()
|
||||
dsn, _, err := db.DSN()
|
||||
if err != nil {
|
||||
t.Skipf("no database config (%v) - skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
d, err := db.Open(dsn)
|
||||
if err != nil {
|
||||
|
||||
@@ -55,7 +55,7 @@ func targetTestDB(t *testing.T) *db.DB {
|
||||
t.Helper()
|
||||
dsn, _, err := db.DSN()
|
||||
if err != nil {
|
||||
t.Skipf("no database config (%v) - skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
d, err := db.Open(dsn)
|
||||
if err != nil {
|
||||
|
||||
@@ -151,7 +151,15 @@ func (meteredStreamProvider) Stream(context.Context, llm.CompletionRequest) iter
|
||||
}
|
||||
|
||||
func TestSideUsageRecordedOnceOnConsumerCancellation(t *testing.T) {
|
||||
t.Skip("timing-sensitive: passes locally, flaky on CI runners; tracked in BaaRai/ARTEX#9")
|
||||
// Timing-sensitive on 2-core CI runners (BaaRai/ARTEX#9). Repro:
|
||||
// ARTEX_PG_DSN=postgres://artex:testpass@localhost:5432/artextest_race \
|
||||
// go test ./llmrec -run TestSideUsageRecordedOnceOnConsumerCancellation -count=20 -race -v
|
||||
// The `early=` t.Fatalf assertion below compares the single llm_usage row's
|
||||
// count/input/output/worker/status; in the `early` branch the status
|
||||
// occasionally comes back "ok" instead of "error" because the consumer's
|
||||
// cancellation and the recorder's deferred finish race on a loaded runner.
|
||||
// Keep the skip until the metering status is made cancellation-explicit.
|
||||
t.Skip("timing-sensitive on CI runners; repro and failing assertion documented above; BaaRai/ARTEX#9")
|
||||
dsn := os.Getenv("ARTEX_PG_DSN")
|
||||
if dsn == "" {
|
||||
t.Skip("requires isolated ARTEX_PG_DSN")
|
||||
|
||||
@@ -88,11 +88,11 @@ func TestStreamUsageEchoCountedOnce(t *testing.T) {
|
||||
func TestStreamUsageEchoLedgerRow(t *testing.T) {
|
||||
dsn, _, err := db.DSN()
|
||||
if err != nil {
|
||||
t.Skipf("no database config (%v)", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
pg, err := db.Open(dsn)
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer pg.Close()
|
||||
if err := pg.EnsureLLMUsageTable(); err != nil {
|
||||
|
||||
Executable
+161
@@ -0,0 +1,161 @@
|
||||
#!/usr/bin/env bash
|
||||
# Verify ARTEX locally, reproducing the checks from .github/workflows/ci.yml.
|
||||
#
|
||||
# Usage:
|
||||
# scripts/verify.sh [--full] [--go-only] [--web-only] [--keep-going]
|
||||
#
|
||||
# --full also run `go test -race` (the CI package list) and the web static build
|
||||
# --go-only run only the Go checks
|
||||
# --web-only run only the web checks
|
||||
# --keep-going continue after a failed step and report every failure at the end
|
||||
# -h, --help show this help
|
||||
#
|
||||
# The default is the fast set: gofmt, build, vet, tests, web type-check and web
|
||||
# unit tests, shellcheck and the shell/python checks. It does not need Docker.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
usage() { sed -n '2,14p' "$0" | sed 's/^# \?//'; }
|
||||
|
||||
FULL=0
|
||||
GO_ONLY=0
|
||||
WEB_ONLY=0
|
||||
KEEP_GOING=0
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--full) FULL=1; shift ;;
|
||||
--go-only) GO_ONLY=1; shift ;;
|
||||
--web-only) WEB_ONLY=1; shift ;;
|
||||
--keep-going) KEEP_GOING=1; shift ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
*) echo "unknown option: $1" >&2; usage >&2; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
if [ "$GO_ONLY" -eq 1 ] && [ "$WEB_ONLY" -eq 1 ]; then
|
||||
echo "--go-only and --web-only are mutually exclusive" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
FAILED=0
|
||||
run_step() {
|
||||
local label="$1"
|
||||
shift
|
||||
printf '\n==> %s\n' "$label"
|
||||
if "$@"; then
|
||||
return 0
|
||||
fi
|
||||
printf 'FAILED: %s\n' "$label" >&2
|
||||
FAILED=1
|
||||
if [ "$KEEP_GOING" -eq 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
require_cmd() {
|
||||
if ! command -v "$1" >/dev/null 2>&1; then
|
||||
printf 'missing prerequisite: %s\n' "$1" >&2
|
||||
exit 127
|
||||
fi
|
||||
}
|
||||
|
||||
# --go-only and --web-only narrow the run; otherwise both halves are checked.
|
||||
want_go() { [ "$WEB_ONLY" -eq 0 ]; }
|
||||
want_web() { [ "$GO_ONLY" -eq 0 ]; }
|
||||
|
||||
if want_go; then
|
||||
require_cmd go
|
||||
require_cmd git
|
||||
|
||||
want=$(awk '/^go /{print $2; exit}' go.mod)
|
||||
got=$(go env GOVERSION | sed 's/^go//')
|
||||
# Numeric compare, portable to macOS (no GNU `sort -V`). A newer toolchain
|
||||
# is fine: CI deliberately runs a `go-stable` job alongside the pinned floor.
|
||||
version_ge() {
|
||||
awk -v a="$1" -v b="$2" 'BEGIN {
|
||||
split(a, A, "."); split(b, B, ".")
|
||||
for (i = 1; i <= 3; i++) {
|
||||
if (A[i] + 0 > B[i] + 0) exit 0
|
||||
if (A[i] + 0 < B[i] + 0) exit 1
|
||||
}
|
||||
exit 0
|
||||
}'
|
||||
}
|
||||
if [ -z "$want" ] || [ -z "$got" ] || ! version_ge "$got" "$want"; then
|
||||
printf 'Go %s does not meet the go.mod floor %s\n' "$got" "$want" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${ARTEX_PG_DSN:-}" ]; then
|
||||
printf 'note: ARTEX_PG_DSN is unset; PostgreSQL-dependent tests will skip themselves\n'
|
||||
fi
|
||||
|
||||
check_gofmt() {
|
||||
local -a files=()
|
||||
local out
|
||||
mapfile -t files < <(git ls-files '*.go')
|
||||
if [ "${#files[@]}" -eq 0 ]; then
|
||||
return 0
|
||||
fi
|
||||
out=$(gofmt -l "${files[@]}")
|
||||
if [ -n "$out" ]; then
|
||||
printf 'gofmt required:\n%s\n' "$out"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
run_step "gofmt" check_gofmt
|
||||
run_step "go build" go build ./...
|
||||
run_step "go vet" go vet ./...
|
||||
run_step "go test -p 1" go test -p 1 ./...
|
||||
|
||||
if [ "$FULL" -eq 1 ]; then
|
||||
RACE_PKGS=(
|
||||
./agent ./cmd/artex ./config ./db ./evidence ./guard
|
||||
./intercept ./llmpool ./llmrec ./mcphttp ./notify ./server
|
||||
./sidequestion ./traffic ./traffic/rewrite
|
||||
)
|
||||
run_step "go test -race -p 1" go test -race -p 1 "${RACE_PKGS[@]}"
|
||||
fi
|
||||
fi
|
||||
|
||||
if want_web; then
|
||||
require_cmd npm
|
||||
require_cmd npx
|
||||
|
||||
if [ ! -d web/node_modules ] || [ web/package-lock.json -nt web/node_modules ]; then
|
||||
run_step "npm ci" npm --prefix web ci
|
||||
fi
|
||||
run_step "tsc --noEmit" bash -c 'cd web && npx tsc --noEmit'
|
||||
run_step "web polling tests" bash -c 'cd web && npm run test:polling'
|
||||
run_step "web replay tests" bash -c 'cd web && npm run test:replay'
|
||||
run_step "web upload tests" bash -c 'cd web && npm run test:upload'
|
||||
if [ "$FULL" -eq 1 ]; then
|
||||
run_step "web static build" bash -c 'cd web && npm run build:static'
|
||||
fi
|
||||
fi
|
||||
|
||||
# The shell/python checks are part of neither --go-only nor --web-only: they
|
||||
# are cheap and guard the install/update path used by every deployment.
|
||||
if [ "$GO_ONLY" -eq 0 ] && [ "$WEB_ONLY" -eq 0 ]; then
|
||||
require_cmd python3
|
||||
if command -v shellcheck >/dev/null 2>&1; then
|
||||
run_step "shellcheck" shellcheck -S warning \
|
||||
install.sh update.sh start.sh scripts/backup.sh scripts/verify.sh \
|
||||
reset-password.sh scripts/extract-changelog-section.sh \
|
||||
scripts/test-extract-changelog-section.sh .github/scripts/bot.sh \
|
||||
scripts/test-bot-context.sh
|
||||
else
|
||||
printf 'note: shellcheck is not installed; skipping the shellcheck step\n'
|
||||
fi
|
||||
run_step "posture check" python3 scripts/posture_check_test.py
|
||||
run_step "changelog section tests" bash scripts/test-extract-changelog-section.sh
|
||||
run_step "bot context tests" bash scripts/test-bot-context.sh
|
||||
fi
|
||||
|
||||
printf '\n'
|
||||
if [ "$FAILED" -ne 0 ]; then
|
||||
printf 'verification FAILED (one or more steps above)\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
printf 'verification passed\n'
|
||||
@@ -28,11 +28,11 @@ func hasSkillTool(tools []actool.CoreTool) bool {
|
||||
func TestAssembleVisibleSkill(t *testing.T) {
|
||||
dsn, _, err := db.DSN()
|
||||
if err != nil {
|
||||
t.Skipf("no database config (%v) — skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
pg, err := db.Open(dsn)
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer pg.Close()
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ func TestCompanyScopeInputsAcceptStructuredAndLegacyRules(t *testing.T) {
|
||||
func TestCreateCompanyRejectsNormalizedDuplicateWithoutChangingScope(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
|
||||
@@ -76,7 +76,7 @@ func TestCreateCompanyRejectsNormalizedDuplicateWithoutChangingScope(t *testing.
|
||||
func TestDeleteCompanyRefreshesLiveTaskCompanyIDs(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
|
||||
@@ -117,7 +117,7 @@ func TestDeleteCompanyRefreshesLiveTaskCompanyIDs(t *testing.T) {
|
||||
func TestCompanyScopeHTTPErrorClassificationAndBounds(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
s := &Server{m: m}
|
||||
@@ -191,7 +191,7 @@ func TestCompanyScopeHTTPErrorClassificationAndBounds(t *testing.T) {
|
||||
func TestListAssetsClassifiesValidationAndDatabaseErrors(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
s := &Server{m: m}
|
||||
@@ -217,7 +217,7 @@ func TestListAssetsClassifiesValidationAndDatabaseErrors(t *testing.T) {
|
||||
func TestDeleteCompanyRejectsBadJSONAndReportsMissing(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
s := &Server{m: m}
|
||||
@@ -256,7 +256,7 @@ func TestDeleteCompanyRejectsBadJSONAndReportsMissing(t *testing.T) {
|
||||
func TestCompanyScopeSystemFailureIsHTTP500(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
s := &Server{m: m}
|
||||
|
||||
@@ -9,6 +9,8 @@ import (
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/Autumn-27/artex/db"
|
||||
)
|
||||
|
||||
func TestPasswordVersionClaim(t *testing.T) {
|
||||
@@ -50,7 +52,7 @@ func TestPasswordVersionClaim(t *testing.T) {
|
||||
func TestChangePasswordRevokesOldTokenAndKeepsItWhenSaveFails(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
|
||||
@@ -150,7 +152,7 @@ func TestChangePasswordRevokesOldTokenAndKeepsItWhenSaveFails(t *testing.T) {
|
||||
func TestUnreadablePasswordVersionRejectsSessions(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
key := []byte("0123456789abcdef0123456789abcdef")
|
||||
@@ -186,7 +188,7 @@ func TestUnreadablePasswordVersionRejectsSessions(t *testing.T) {
|
||||
func TestLoginRereadsPasswordVersionWhenUnreadable(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
|
||||
@@ -250,7 +252,7 @@ func TestLoginRereadsPasswordVersionWhenUnreadable(t *testing.T) {
|
||||
func TestAbsentPasswordVersionKeepsSessions(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
key := []byte("0123456789abcdef0123456789abcdef")
|
||||
|
||||
+5
-3
@@ -8,6 +8,8 @@ import (
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Autumn-27/artex/db"
|
||||
)
|
||||
|
||||
// jwtKeyDirs returns fresh key, data and legacy base dirs and points
|
||||
@@ -194,7 +196,7 @@ func TestLoadOrCreateJWTKeyNeverOverwrites(t *testing.T) {
|
||||
func TestAuthStatusFailsClosedWhenDataSourceUnavailable(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
// Close the pool so subsequent GetSetting returns an error instead of sql.ErrNoRows.
|
||||
@@ -220,7 +222,7 @@ func TestAuthStatusFailsClosedWhenDataSourceUnavailable(t *testing.T) {
|
||||
func TestAuthInitFailsClosedWhenDataSourceUnavailable(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
if err := m.pg.Close(); err != nil {
|
||||
@@ -245,7 +247,7 @@ func TestAuthInitFailsClosedWhenDataSourceUnavailable(t *testing.T) {
|
||||
func TestAuthInitRequiresSetupToken(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
clearPassword := func() {
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/Autumn-27/artex/db"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
@@ -61,7 +62,7 @@ func changePasswordServer(t *testing.T, clk *fakeClock) (*Server, string, func(r
|
||||
t.Helper()
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { m.Close() })
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
func TestChatUnavailableReasonDistinguishesStates(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
td := t.TempDir()
|
||||
@@ -66,7 +66,7 @@ func TestChatUnavailableReasonDistinguishesStates(t *testing.T) {
|
||||
func TestResolveChatAgentHonoursConversationProfile(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
td := t.TempDir()
|
||||
|
||||
@@ -119,7 +119,7 @@ func TestChatMentionPagination(t *testing.T) {
|
||||
func TestChatMentionWorkerReceivesServerDetails(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ import (
|
||||
func TestCoreTaskLifecyclePG(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
td := t.TempDir()
|
||||
|
||||
@@ -16,7 +16,7 @@ func TestCostLedgerEurOnUsage(t *testing.T) {
|
||||
}
|
||||
t.Cleanup(func() { m.Close() })
|
||||
if m.pg == nil {
|
||||
t.Skip("no postgres for this run")
|
||||
db.SkipNoPG(t)
|
||||
}
|
||||
|
||||
pid, err := m.pg.SaveProfile(&db.LLMProfile{
|
||||
|
||||
@@ -82,7 +82,7 @@ func TestResetSettledRunReseedsBudgetFromUsage(t *testing.T) {
|
||||
t.Setenv("ARTEX_TASK_BUDGET_TOKENS", "100000")
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ func newRetestServer(t *testing.T) (*Server, int64) {
|
||||
t.Helper()
|
||||
dsn, _, err := db.DSN()
|
||||
if err != nil {
|
||||
t.Skip("test postgres not configured")
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
pg, err := db.Open(dsn)
|
||||
if err != nil {
|
||||
|
||||
@@ -39,7 +39,7 @@ func TestFindingPaginationParam(t *testing.T) {
|
||||
func TestFindingGroupsReturnsTaskBucketsAndNormalizesPagination(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
marker := fmt.Sprintf("__server_finding_groups_%d__", time.Now().UnixNano())
|
||||
@@ -149,7 +149,7 @@ func TestFindingGroupsReturnsTaskBucketsAndNormalizesPagination(t *testing.T) {
|
||||
func TestDeepenFindingCreatesAuditedIntentAndRevivesTask(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
|
||||
@@ -278,7 +278,7 @@ func TestDeepenFindingValidatesDescription(t *testing.T) {
|
||||
func TestDeepenAdmissionFailureDiscardsFollowUpIntent(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
task, err := m.CreateTask("deepen rollback", "leave no orphan intent", nil, 0, 0)
|
||||
|
||||
@@ -26,7 +26,7 @@ func TestInheritedActivityDetailAndRelationDeletion(t *testing.T) {
|
||||
m, err := NewManager(dir, "")
|
||||
if err != nil {
|
||||
_ = os.RemoveAll(dir)
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
_ = m.Close()
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
func TestInterceptAlwaysAllowPG(t *testing.T) {
|
||||
dsn, _, err := db.DSN()
|
||||
if err != nil {
|
||||
t.Skip("no test database configured")
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
d, err := db.Open(dsn)
|
||||
if err != nil {
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
func TestInterceptBatchDecideHTTP(t *testing.T) {
|
||||
dsn, _, err := db.DSN()
|
||||
if err != nil {
|
||||
t.Skip("no test database configured")
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
d, err := db.Open(dsn)
|
||||
if err != nil {
|
||||
|
||||
@@ -34,7 +34,7 @@ func TestInterceptFilterParamsDecidedBy(t *testing.T) {
|
||||
func TestInterceptDecidedByHTTP(t *testing.T) {
|
||||
dsn, _, err := db.DSN()
|
||||
if err != nil {
|
||||
t.Skip("no test database configured")
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
d, err := db.Open(dsn)
|
||||
if err != nil {
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
func TestInterceptDetailHTTP(t *testing.T) {
|
||||
dsn, _, err := db.DSN()
|
||||
if err != nil {
|
||||
t.Skip("no test database configured")
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
d, err := db.Open(dsn)
|
||||
if err != nil {
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
func TestInterceptFilterHTTP(t *testing.T) {
|
||||
dsn, _, err := db.DSN()
|
||||
if err != nil {
|
||||
t.Skip("no test database configured")
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
d, err := db.Open(dsn)
|
||||
if err != nil {
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Autumn-27/artex/db"
|
||||
)
|
||||
|
||||
func TestRSILessonsMode(t *testing.T) {
|
||||
@@ -23,7 +25,7 @@ func TestRSILessonsMode(t *testing.T) {
|
||||
func TestTaskLessonsExtractionAndIdempotency(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
if _, err := m.pg.Exec(`DELETE FROM rsi_lessons`); err != nil {
|
||||
@@ -124,7 +126,7 @@ SELECT id,'completed','fixed','{}'::jsonb FROM findings WHERE task_id=$1 AND nam
|
||||
func TestTerminalStatusExtractsLessons(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
if _, err := m.pg.Exec(`DELETE FROM rsi_lessons`); err != nil {
|
||||
|
||||
@@ -124,7 +124,7 @@ func TestLLMTestValidatesUserAgent(t *testing.T) {
|
||||
func TestStoredProfileKeyOnlyForStoredEndpoint(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { m.Close() })
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
@@ -110,7 +110,7 @@ func TestOllamaKeylessProfileLifecycle(t *testing.T) {
|
||||
}
|
||||
t.Cleanup(func() { m.Close() })
|
||||
if m.pg == nil {
|
||||
t.Skip("no postgres for this run")
|
||||
db.SkipNoPG(t)
|
||||
}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
@@ -197,7 +197,7 @@ func TestOllamaListModels(t *testing.T) {
|
||||
}
|
||||
t.Cleanup(func() { m.Close() })
|
||||
if m.pg == nil {
|
||||
t.Skip("no postgres for this run")
|
||||
db.SkipNoPG(t)
|
||||
}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
|
||||
@@ -25,7 +25,7 @@ func TestLLMTestStoredKeyFallbackIsTrimmed(t *testing.T) {
|
||||
}
|
||||
t.Cleanup(func() { m.Close() })
|
||||
if m.pg == nil {
|
||||
t.Skip("no postgres for this run")
|
||||
db.SkipNoPG(t)
|
||||
}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
@@ -105,7 +105,7 @@ func TestLLMTestStoredProfileUsesProfileEndpoint(t *testing.T) {
|
||||
}
|
||||
t.Cleanup(func() { m.Close() })
|
||||
if m.pg == nil {
|
||||
t.Skip("no postgres for this run")
|
||||
db.SkipNoPG(t)
|
||||
}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/Autumn-27/artex/agent"
|
||||
"github.com/Autumn-27/artex/db"
|
||||
"github.com/Autumn-27/artex/llmrec"
|
||||
"github.com/Autumn-27/norma/llm"
|
||||
"github.com/Autumn-27/norma/transcript"
|
||||
@@ -21,7 +22,7 @@ import (
|
||||
func TestRecorderPersistsRawWireBodies(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
pg := m.PG()
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
func TestSeedAssociatesTargetAssetWithTask(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
task, err := m.CreateTask("seed ownership", "seed ownership", nil, 0, 0)
|
||||
@@ -174,7 +174,7 @@ func TestManagerDeleteTaskRestoresFilesAndTrafficWhenPostgresDeleteFails(t *test
|
||||
dataDir := t.TempDir()
|
||||
m, err := NewManager(dataDir, "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { _ = m.Close() })
|
||||
|
||||
|
||||
+4
-2
@@ -7,16 +7,18 @@ import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/Autumn-27/artex/db"
|
||||
)
|
||||
|
||||
// TestMgmtAPI exercises the PostgreSQL-backed management API through the real mux.
|
||||
func TestMgmtAPI(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("database unavailable (%v) — skipping management API test", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
if m.pg == nil {
|
||||
t.Skip("postgres unavailable — skipping management API test")
|
||||
db.SkipNoPG(t)
|
||||
}
|
||||
// New starts the notifier and task-archive workers on context.Background();
|
||||
// closing the pool stops them from claiming later tests' digest batches
|
||||
|
||||
@@ -17,7 +17,7 @@ func TestPlannerQuietSkipEdge(t *testing.T) {
|
||||
}
|
||||
t.Cleanup(func() { _ = m.Close() })
|
||||
if m.pg == nil {
|
||||
t.Skip("no postgres for this run")
|
||||
db.SkipNoPG(t)
|
||||
}
|
||||
|
||||
created, err := m.CreateTaskWithOptions("quiet-mode probe", "probe goal", db.TaskCreateOptions{})
|
||||
@@ -86,7 +86,7 @@ func TestPlannerQuietModeToggleMidRun(t *testing.T) {
|
||||
}
|
||||
t.Cleanup(func() { _ = m.Close() })
|
||||
if m.pg == nil {
|
||||
t.Skip("no postgres for this run")
|
||||
db.SkipNoPG(t)
|
||||
}
|
||||
|
||||
created, err := m.CreateTaskWithOptions("quiet-toggle probe", "goal", db.TaskCreateOptions{})
|
||||
|
||||
@@ -142,7 +142,7 @@ func newSideHTTPFixture(t *testing.T) *sideHTTPFixture {
|
||||
t.Helper()
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
s := &Server{m: m, engine: NewEngine(m), ctx: ctx, jwtKey: []byte("btw-test-signing-key-only"), chatBusy: map[string]bool{}}
|
||||
|
||||
@@ -7,12 +7,14 @@ import (
|
||||
"net/http/httptest"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/Autumn-27/artex/db"
|
||||
)
|
||||
|
||||
func TestSkillGapsReport(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) — skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
task, err := m.CreateTask("skill gaps", "goal", nil, 0, 0)
|
||||
|
||||
@@ -45,7 +45,7 @@ func restoreConcurrencySetting(t *testing.T, m *Manager) func() {
|
||||
func TestAdmitAlreadyRunningTaskDoesNotQueueAfterLimitDecrease(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
|
||||
@@ -87,7 +87,7 @@ func TestAdmitAlreadyRunningTaskDoesNotQueueAfterLimitDecrease(t *testing.T) {
|
||||
func TestAdmissionDoesNotOverwriteConcurrentTerminalStatus(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
defer restoreConcurrencySetting(t, m)()
|
||||
@@ -124,7 +124,7 @@ func TestAdmissionDoesNotOverwriteConcurrentTerminalStatus(t *testing.T) {
|
||||
func TestAdmitKeepsQueuedBootstrapMode(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
|
||||
@@ -167,7 +167,7 @@ func TestAdmitKeepsQueuedBootstrapMode(t *testing.T) {
|
||||
func TestTerminalTaskQueuedByAdmissionKeepsExecutionBarrier(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
defer restoreConcurrencySetting(t, m)()
|
||||
@@ -215,7 +215,7 @@ func TestTerminalTaskQueuedByAdmissionKeepsExecutionBarrier(t *testing.T) {
|
||||
func TestTimedOutTaskRevivalResetsClockAndSettlingAcrossFIFO(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
defer restoreConcurrencySetting(t, m)()
|
||||
@@ -301,7 +301,7 @@ func TestTimedOutTaskRevivalResetsClockAndSettlingAcrossFIFO(t *testing.T) {
|
||||
func TestQueuedTaskCanPauseAndResumeAtFIFOTail(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
defer restoreConcurrencySetting(t, m)()
|
||||
@@ -351,7 +351,7 @@ func TestQueuedTaskCanPauseAndResumeAtFIFOTail(t *testing.T) {
|
||||
func TestReadyFIFOIsAdmittedBeforeNewTask(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
defer restoreConcurrencySetting(t, m)()
|
||||
@@ -398,7 +398,7 @@ func TestReadyFIFOIsAdmittedBeforeNewTask(t *testing.T) {
|
||||
func TestUnavailableTaskReleasesSlotForReadyQueue(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
defer restoreConcurrencySetting(t, m)()
|
||||
@@ -437,7 +437,7 @@ func TestUnavailableTaskReleasesSlotForReadyQueue(t *testing.T) {
|
||||
func TestUnavailableTaskWaitsForActiveLLMCallBeforeParking(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
defer restoreConcurrencySetting(t, m)()
|
||||
@@ -491,7 +491,7 @@ func TestUnavailableTaskWaitsForActiveLLMCallBeforeParking(t *testing.T) {
|
||||
func TestRerunAdmissionFailureRestoresIntentState(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
task, err := m.CreateTask("failed rerun admission", "restore intent", nil, 0, 0)
|
||||
@@ -535,7 +535,7 @@ func TestRerunAdmissionFailureRestoresIntentState(t *testing.T) {
|
||||
func TestTaskLLMResolutionRejectsInvalidExplicitProfile(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
|
||||
@@ -576,7 +576,7 @@ func TestTaskLLMResolutionRejectsInvalidExplicitProfile(t *testing.T) {
|
||||
func TestTaskLLMResolutionPrefersAgentBindingOverTaskChain(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
|
||||
@@ -643,7 +643,7 @@ func TestTaskLLMResolutionPrefersAgentBindingOverTaskChain(t *testing.T) {
|
||||
func TestTaskLLMResolutionReportsDatabaseFailure(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
task, err := m.CreateTask("resolution storage failure", "return server error", nil, 0, 0)
|
||||
@@ -688,7 +688,7 @@ func TestTokenStatsWithoutTaskReturnsStableShape(t *testing.T) {
|
||||
func TestBatchControlLimitCountsDeduplicatedIDs(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
s := newAdmissionTestServer(m, nil)
|
||||
@@ -762,7 +762,7 @@ func TestBatchControlLimitCountsDeduplicatedIDs(t *testing.T) {
|
||||
func TestPauseTaskToolPersistsAndDequeuesTask(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
task, err := m.CreateTask("orchestrated pause", "persist queued pause", nil, 0, 0)
|
||||
@@ -798,7 +798,7 @@ func TestPauseTaskToolPersistsAndDequeuesTask(t *testing.T) {
|
||||
func TestPauseTaskToolUsesOrchestratorCancellationCause(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
task, err := m.CreateTask("orchestrated pause cause", "keep audit reason", nil, 0, 0)
|
||||
|
||||
@@ -9,12 +9,14 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Autumn-27/artex/db"
|
||||
)
|
||||
|
||||
func TestTaskArchiveAPIQueueListAndLimits(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
task, err := m.CreateTask("archive api", "verify 202", nil, 0, 0)
|
||||
|
||||
@@ -7,6 +7,8 @@ import (
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Autumn-27/artex/db"
|
||||
)
|
||||
|
||||
// TestTaskCategoryBatchRoute pins the contract of the batch move endpoint: it is
|
||||
@@ -16,7 +18,7 @@ import (
|
||||
func TestTaskCategoryBatchRoute(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
|
||||
|
||||
@@ -6,12 +6,14 @@ import (
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Autumn-27/artex/db"
|
||||
)
|
||||
|
||||
func TestWorkerControlRoutes(t *testing.T) {
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user