diff --git a/.github/workflows/ci-config.md b/.github/workflows/ci-config.md index a026bff..e8417fa 100644 --- a/.github/workflows/ci-config.md +++ b/.github/workflows/ci-config.md @@ -28,8 +28,8 @@ This artifact defines the CI pipeline **for the settings-and-admin-ui feature**. | Frontend job | `frontend` (lint non-blocking + strict build) | **Unchanged.** New TS under `ui/src/{pages/admin,components/admin,api,types}` compiles via the existing `tsc -b && vite build`. No new job. | | E2E job | `e2e` (Playwright, **non-blocking** via `continue-on-error: true`) | **Delta — see §3.** The feature adds `admin.spec.ts`; the self-seeding gap that made E2E non-blocking is partially closeable for the admin spec. | | Gate aggregate | `gate` job, blocking set = {backend, frontend, backend-full}; e2e informational | **Unchanged.** E2E stays informational in v1 (see §3 rationale). | -| Migration test | None at CI level (sibling's `migration_017` test runs in `backend-full`) | **Delta — see §4.** Migration 018 round-trip test must run in CI against a fresh schema, not just `backend-full`. | -| Deploy/rollback | `deploy.sh`, `rollback.sh` (recreate, smoke-gated, auto-rollback) | **Unchanged by this stage.** Stage 4.1 owns the CD delta. This artifact records the migration-018 rollback implication for 4.1 (§6). | +| Migration test | None at CI level (sibling's `migration_017` test runs in `backend-full`) | **Delta — see §4.** Migration 019 round-trip test must run in CI against a fresh schema, not just `backend-full`. | +| Deploy/rollback | `deploy.sh`, `rollback.sh` (recreate, smoke-gated, auto-rollback) | **Unchanged by this stage.** Stage 4.1 owns the CD delta. This artifact records the migration-019 rollback implication for 4.1 (§6). | **Net effect on `ci.yml`: small.** The feature's code flows through the existing jobs automatically. The `ci.yml` edits this feature requires are: (a) widen vet scope (drop `internal/opencode`, keep `internal/repos`/`internal/settings`/`internal/config`), (b) add `internal/config` to the fast unit gate, (c) add a `-race` step on the concurrency-touching packages, and (d) extend the `e2e` job's spec set to include `admin.spec.ts` once it self-seeds. All reviewed below. @@ -48,7 +48,7 @@ The 5-job structure from the sibling feature is retained. This feature's code is | Job | Purpose | Gate command | Pinned toolchain | Service | Timeout | This feature's impact | |-----|---------|--------------|------------------|---------|---------|-----------------------| -| `backend` | Build + vet + db/api/config unit + race | `go build ./...` → `go vet` (widened, §5) → `go test ./internal/db/... ./internal/api/... ./internal/config/... -count=1` → `go test -race ./internal/repos/... ./internal/config/... ./internal/settings/... -count=1` | Go 1.26.1 | postgres:16 | 10m | New `internal/db/migration_018*`, `internal/repos`, `internal/settings/*`, `internal/api/settings_handlers*`, `internal/api/auth_guard*`, `internal/config` write-path tests run here. Vet scope widened (§5); `internal/config` added to fast unit gate (§5.1); `-race` step added (§5.2). | +| `backend` | Build + vet + db/api/config unit + race | `go build ./...` → `go vet` (widened, §5) → `go test ./internal/db/... ./internal/api/... ./internal/config/... -count=1` → `go test -race ./internal/repos/... ./internal/config/... ./internal/settings/... -count=1` | Go 1.26.1 | postgres:16 | 10m | New `internal/db/migration_019*`, `internal/repos`, `internal/settings/*`, `internal/api/settings_handlers*`, `internal/api/auth_guard*`, `internal/config` write-path tests run here. Vet scope widened (§5); `internal/config` added to fast unit gate (§5.1); `-race` step added (§5.2). | | `frontend` | Lint (non-blocking) + strict build | `npm run lint` → `npm run build` | Node 22.23 | — | 10m | New `ui/src/{pages/admin,components/admin,api,types}` compiles via `tsc -b`. No change. | | `backend-full` | Full Go suite (release gate) | `go test ./... -count=1` | Go 1.26.1 | postgres:16 | 15m | Picks up the full new test set automatically. | | `e2e` | Playwright smoke + non-regression | `npm run test:e2e` | Go 1.26.1 + Node 22.23 + chromium | postgres:16 | 20m | **Add `admin.spec.ts`** (§3). | @@ -94,17 +94,17 @@ The sibling feature's `migration_017` (`repos_registry`) is tested via `internal `discovered-rules` R-TEST-03 (BINDING GAP-RULE) is explicit: migration N must have a local round-trip test: empty DB → run migration N → tables exist → seed → verify schema, using a fresh test DB with no `schema_migrations` rows so the migration actually runs. The 2.2 baseline said "no CI"; the current baseline has CI, so the "no CI" half of R-TEST-03's rationale is stale — but the **"no migration test framework"** half is still true. The round-trip test is still the only pre-flight defense against a failed production migration (team-practices §6.3). -### 4.2 This feature's migration: 018 +### 4.2 This feature's migration: 019 -**Migration 017 is taken on `main`** (`repos_registry`, sibling feature). This feature's migration is **018** (the `unit-of-work` artifact references "017" because it was written before the sibling feature's migration landed; the developer at 3.6 renumbers to 018 to avoid collision, following the same precedent the sibling feature used when it renumbered from 013 to 017). The schema content is **thinned** per `bolt-plan` revision 2 / `test-results` revision 2: only `feature_defaults`, `server_config`, `audit_events.actor`, and `idx_audit_events_type_time` are added. **No `llm_*` tables, no `cicd_platforms` table** — those were removed by the Q7/Q8 scope cut. +**Migration 017 is taken on `main`** (`repos_registry`, sibling feature). This feature's migration is **019** (the `unit-of-work` artifact references "017" because it was written before the sibling feature's migration landed; the developer at 3.6 renumbers to 019 to avoid collision, following the same precedent the sibling feature used when it renumbered from 013 to 017). The schema content is **thinned** per `bolt-plan` revision 2 / `test-results` revision 2: only `feature_defaults`, `server_config`, `audit_events.actor`, and `idx_audit_events_type_time` are added. **No `llm_*` tables, no `cicd_platforms` table** — those were removed by the Q7/Q8 scope cut. -### 4.3 CI behavior for migration 018 +### 4.3 CI behavior for migration 019 -The migration round-trip tests (`internal/db/migration_018_test.go::TestMigration_RoundTrip`, `::TestMigration_AdditiveOnly`, `::TestMigration_ActorNullable`, `::TestMigration_NoReposTableAlteration`, `::TestMigration_Atomicity`, `::TestMigration_NumberIs018`, `::TestFeatureDefaults_ValidatorMinimal` — per `test-results` §2.1 T-MIG-01..07) run against a **fresh test DB with no `schema_migrations` rows**. In CI, the `backend` and `backend-full` jobs create the test DBs via the existing `for db in devteam_test_db ...` loop, but the test harness's `setupTestDB(t)` applies all registered migrations — which means migration 018 runs as part of `setupTestDB`, not as a fresh-DB test. +The migration round-trip tests (`internal/db/migration_019_test.go::TestMigration019_RoundTrip`, `::TestMigration019_AdditiveOnly`, `::TestMigration019_ActorNullable`, `::TestMigration019_NoReposTableAlteration`, `::TestMigration019_Atomicity`, `::TestMigration019_NumberIs019`, `::TestFeatureDefaults_ValidatorMinimal` — per `test-results` §2.1 T-MIG-01..07) run against a **fresh test DB with no `schema_migrations` rows**. In CI, the `backend` and `backend-full` jobs create the test DBs via the existing `for db in devteam_test_db ...` loop, but the test harness's `setupTestDB(t)` applies all registered migrations — which means migration 019 runs as part of `setupTestDB`, not as a fresh-DB test. **Decision for v1: no new CI step for the migration round-trip test.** Rationale: -1. The round-trip test (`TestMigration_RoundTrip` and siblings) are **Go test functions** that create their own isolated DB (or truncate `schema_migrations` + all tables) within the test. They run in the existing `backend` and `backend-full` jobs automatically — they're `_test.go` files under `internal/db/`, picked up by `go test ./internal/db/...` and `go test ./...`. -2. Adding a dedicated "fresh DB" CI step would require either (a) a second postgres service container with a separate `CREATE DATABASE` and a custom `go test -run TestMigration_RoundTrip` invocation, or (b) a test-harness refactor to expose a `setupFreshTestDB(t)` helper. Both are test-infrastructure work whose value is marginal given that the tests already run in the existing jobs — the "fresh DB" isolation is the test's own responsibility, not the CI job's. +1. The round-trip test (`TestMigration019_RoundTrip` and siblings) are **Go test functions** that create their own isolated DB (or truncate `schema_migrations` + all tables) within the test. They run in the existing `backend` and `backend-full` jobs automatically — they're `_test.go` files under `internal/db/`, picked up by `go test ./internal/db/...` and `go test ./...`. +2. Adding a dedicated "fresh DB" CI step would require either (a) a second postgres service container with a separate `CREATE DATABASE` and a custom `go test -run TestMigration019_RoundTrip` invocation, or (b) a test-harness refactor to expose a `setupFreshTestDB(t)` helper. Both are test-infrastructure work whose value is marginal given that the tests already run in the existing jobs — the "fresh DB" isolation is the test's own responsibility, not the CI job's. 3. The test's own `setupFreshTestDB(t)` helper (the developer implements this per `test-results` §1.3: "Fresh test DB with no `schema_migrations` rows") handles isolation **inside** the test. CI just needs to provide a postgres endpoint, which it already does. **If the developer at 3.6 finds that the migration tests cannot isolate a fresh DB within the shared `devteam_test_db`** (e.g., because `setupTestDB` runs all migrations before the test gets control), the fallback is a one-line addition to the `backend` job's "Create test databases" step: `CREATE DATABASE devteam_test_fresh;` and a `DEVTEAM_TEST_FRESH_DSN` env var the tests read. This is a **contingent** edit — not made now, but recorded so 3.6/4.1 don't re-derive it. The default assumption is that the tests isolate themselves. @@ -156,13 +156,13 @@ Rationale: U-CONFIG-01 (the config write/materialize/reconcile path) is the linc This runs in the `backend` job alongside the db/api/config unit gate so a race regression fails the fast gate, not just `backend-full`. The `-race` flag is not added to `backend-full`'s `go test ./...` (the full suite under `-race` is ~3× slower and not justified for the single-operator repo); the targeted race step covers the concurrency-touching packages. -## 6. Migration 018 Rollback Implication (input to 4.1) +## 6. Migration 019 Rollback Implication (input to 4.1) This is a **CI-pipeline-stage record** for the downstream deployment stage, not a CI change itself. Per `team-practices` §6.3/§6.4 and the existing `rollback.sh`: -- **Migration 018 is forward-only** (no `Down`), per the established convention (R-TEST-03, `team-practices` §6.4). -- **Code rollback** (via `rollback.sh`): `git revert` the merge commit, rebuild, restart. The reverted binary does not know about migration 018's tables — they are orphaned but harmless (additive, <1 MB, ignored by the old code). Same posture as the sibling feature's migration 017. -- **Data rollback** (if migration 018 fails in production): manual `pg_restore` from the last `pg_dump` backup, or a forward-fix migration 019. **No automated data rollback.** This is the inherited posture (`team-practices` §6.3); this feature does not change it. +- **Migration 019 is forward-only** (no `Down`), per the established convention (R-TEST-03, `team-practices` §6.4). +- **Code rollback** (via `rollback.sh`): `git revert` the merge commit, rebuild, restart. The reverted binary does not know about migration 019's tables — they are orphaned but harmless (additive, <1 MB, ignored by the old code). Same posture as the sibling feature's migration 017. +- **Data rollback** (if migration 019 fails in production): manual `pg_restore` from the last `pg_dump` backup, or a forward-fix migration 020. **No automated data rollback.** This is the inherited posture (`team-practices` §6.3); this feature does not change it. - **The startup reconciler (U-CONFIG-01, FR-CONFIG-05)** is the crash-recovery path for the DB→YAML materialize layer: if the materialized YAML is stale vs DB after a failed deploy, the next successful boot re-materializes from DB. This is a **new** rollback-adjacent property this feature introduces — 4.1 should record it in the rollback runbook as "config-state recovery does not require DB restore for the settings store; the reconciler handles it on next boot." ## 7. What This Pipeline Does NOT Do (scoped out, recorded) @@ -206,7 +206,7 @@ Inherited from the sibling feature's `ci-config.md` §7 and reaffirmed for this 4. **Dep-tidy gate will catch uncommitted deps** — `go mod tidy && git diff --exit-code go.mod go.sum` fails if `go-playground/validator` is imported but not in `go.mod`. Same for `npm ci` vs `zod` in `package-lock.json`. ✓ 5. **Vet scope widening is safe and `internal/opencode` is excluded** — the new packages (`internal/repos`, `internal/settings`, `internal/config`) are net-new or extended code with no inherited vet warnings. `internal/opencode` is not built by this feature (scope cut, Q7) and is therefore correctly absent from the vet scope. Verified against `bolt-plan` revision 2 §6. ✓ 6. **E2E non-blocking posture is explicit** — §3.2 records the rationale; the `ci.yml` `continue-on-error: true` and the `gate` job's blocking condition are unchanged. ✓ -7. **Migration 018 (not 017)** — verified `internal/db/migration_017.go` on `main` is `repos_registry` (sibling feature); this feature's migration is 018. The `unit-of-work` "017" reference is renumbered by the developer at 3.6. ✓ +7. **Migration 019 (not 017)** — verified `internal/db/migration_017.go` on `main` is `repos_registry` (sibling feature); this feature's migration is 019. The `unit-of-work` "017" reference is renumbered by the developer at 3.6. ✓ 8. **No scope creep** — §7 records every omitted gate (coverage, security scan, container, release notes, matrix, cross-browser, CI/CD, opencode builder) with its source rationale, and the scope-cut resolutions for CI/CD and Providers. ✓ 9. **Baseline shift is recorded** — §0 flags the 2.2 "no CI" staleness so 4.1/4.3 and the reviewer gate operate against the current baseline. ✓ 10. **Race gate is binding** — §5.3 encodes `quality-report` rev2 QO-14 as a CI step in the `backend` job, not merely a developer-local recommendation. ✓ diff --git a/.github/workflows/quality-gates.md b/.github/workflows/quality-gates.md index 17c8783..b906c1f 100644 --- a/.github/workflows/quality-gates.md +++ b/.github/workflows/quality-gates.md @@ -48,7 +48,7 @@ Inherited gates (G1–G9) are the sibling feature's set, unchanged in command an | ID | Gate | This feature's re-scope | |----|------|--------------------------| | G2 | Go vet | **Vet scope widened** to include `./internal/repos/... ./internal/settings/... ./internal/config/...` (the feature's new + extended packages). `internal/opencode` is **excluded** — the builder package is owned by the sibling feature (scope cut, Q7). See `ci-config.md` §5.1. The widened scope is a strict superset of the sibling's; no regression. | -| G3 | Go unit (db+api+config) | **`internal/config` added to the fast gate** (`ci-config.md` §5.2) so the linchpin (U-CONFIG-01) fails fast. Picks up this feature's new tests in `internal/db` (migration 018 round-trip, audit actor overload, audit constants structural), `internal/api` (settings handlers, auth guard, repos CRUD), and `internal/config` (write path, reconcile, masking helper). The command is widened; the test set grows. | +| G3 | Go unit (db+api+config) | **`internal/config` added to the fast gate** (`ci-config.md` §5.2) so the linchpin (U-CONFIG-01) fails fast. Picks up this feature's new tests in `internal/db` (migration 019 round-trip, audit actor overload, audit constants structural), `internal/api` (settings handlers, auth guard, repos CRUD), and `internal/config` (write path, reconcile, masking helper). The command is widened; the test set grows. | | G4 | Go full suite | **Picks up `internal/repos`, `internal/settings`, `internal/config` write-path tests.** The command is unchanged; the test set grows. (`internal/opencode` is not built by this feature — scope cut.) | | G5 | Dep-tidy | **Enforces the two endorsed deps**: `go-playground/validator` (Go) and `zod` (npm, via `npm ci` strict). If either is imported but uncommitted, G5 (Go) or `npm ci` (frontend) fails. | | G8 | E2E | **Adds `admin.spec.ts`** to the spec set (5 v1 describe groups + 2 placeholder assertions — `ci-config.md` §3.3). Still non-blocking in v1 (`ci-config.md` §3.2). | @@ -59,7 +59,7 @@ These are **not new CI jobs** — they are Go test functions that run inside the | ID | Gate | Test function(s) / command | Runs in | Blocks | Source | |----|------|----------------------------|---------|--------|--------| -| G10 | Migration 018 round-trip (thinned) | `migration_018_test.go::TestMigration_RoundTrip`, `::TestMigration_AdditiveOnly`, `::TestMigration_ActorNullable`, `::TestMigration_NoReposTableAlteration`, `::TestMigration_Atomicity`, `::TestMigration_NumberIs018`, `::TestFeatureDefaults_ValidatorMinimal` | G3 (db subset), G4 | Bolt 0 go/no-go; release-candidate status | FR-MIG-01..04, R-TEST-03, `test-results` rev2 §2.1 T-MIG-01..07 | +| G10 | Migration 019 round-trip (thinned) | `migration_019_test.go::TestMigration019_RoundTrip`, `::TestMigration019_AdditiveOnly`, `::TestMigration019_ActorNullable`, `::TestMigration019_NoReposTableAlteration`, `::TestMigration019_Atomicity`, `::TestMigration019_NumberIs019`, `::TestFeatureDefaults_ValidatorMinimal` | G3 (db subset), G4 | Bolt 0 go/no-go; release-candidate status | FR-MIG-01..04, R-TEST-03, `test-results` rev2 §2.1 T-MIG-01..07 | | G11 | Config write path (linchpin) | `config_test.go::TestWriteConfig_RoundTrip`, `::TestWriteConfig_CrashInjection`, `::TestWriteConfig_ValidationRejects`, `::TestReconcile_RegeneratesStaleYAML`, `::TestBootstrapFields_YAMLOnly`, `::TestReconcile_BootstrapUntouched`, `::TestWriteConfig_EmitsAuditEvent`, `::TestWriteConfig_AuditFailureNoRevert`, `::TestValidator_EnvVarRefPattern`, `::TestValidationDetails_SecretMasked`, `::TestLoadConfig_Unchanged` | G3 (config subset — added in rev2), G4 | Bolt 0 go/no-go; release-candidate status | FR-CONFIG-01..08, R-CONFIG-MATERIALIZE, R-CONFIG-VALIDATION, `test-results` rev2 §2.2 T-CONFIG-01..11 | | G12 | Auth guard (fail-closed) | `auth_guard_test.go::TestAdminGuard_LocalhostAllowed`, `::TestAdminGuard_NonLocalhost_TokenMatch`, `::TestAdminGuard_NonLocalhost_TokenMissingOrWrong_401`, `::TestAdminGuard_FailClosed_WhenEnvUnset`, `::TestAdminGuard_RejectsBeforeSideEffect`, `::TestAdminGuard_RejectionNoAudit`, `::TestAdminGuard_PluggableMiddleware`, `server_test.go::TestGetRepos_Unguarded` | G3 (api subset) | Bolt 0 go/no-go; release-candidate status; 4.1 security gate | FR-ROUTE-03, R-AUTH-ABSENT, `test-results` rev2 §2.4 T-AUTH-01..08 | | G13 | Audit constants + actor overload | `audit_events_test.go::TestFourEventConstants`, `::TestRecordAuditEventWithActor_PopulatesActor`, `::TestRecordAuditEvent_BackwardCompat`, `::TestActor_EmptyIsNULL`, `::TestActor_DefaultOperator`, `::TestActor_FromEnvOnly`, `::TestDetails_NoSecret` | G3 (db subset) | Bolt 0 go/no-go; release-candidate status; scope-creep block (QO-11) | FR-AUDIT-04 (rev2), FR-AUDIT-ACTOR-01..03, BR-AUDIT-01, `test-results` rev2 §2.3 T-AUDIT-CONST-01..07 | @@ -108,7 +108,7 @@ The bolt-level go/no-go checkpoints map to CI gates as follows. This lets the bu | Bolt | Bolt gate (from `quality-report` rev2 §3 / `bolt-plan` rev2 §2) | CI gate(s) | MVP? | v1? | |------|------------------------------------------------------------------|------------|------|-----| -| 0 — Walking Skeleton | Migration 018 round-trip green; config write path round-trip + crash-injection green; audit actor overload + 4 constants green; auth guard fail-closed green; POST /api/repos thin slice green; admin shell renders (4 v1 tabs + 2 placeholders) | G10, G11, G12, G13, G3 (api subset), G7 (shell build), G8 (shell E2E, non-blocking) | ✅ MVP | ✅ v1 | +| 0 — Walking Skeleton | Migration 019 round-trip green; config write path round-trip + crash-injection green; audit actor overload + 4 constants green; auth guard fail-closed green; POST /api/repos thin slice green; admin shell renders (4 v1 tabs + 2 placeholders) | G10, G11, G12, G13, G3 (api subset), G7 (shell build), G8 (shell E2E, non-blocking) | ✅ MVP | ✅ v1 | | 1 — Repos | Repos service concurrent-write green; repos CRUD handlers green; `admin.spec.ts` repos cases green; `GET /api/repos` shape unchanged; `repos.yaml.lock` gitignored | G14, G3 (api subset), G8 (admin.spec, non-blocking), G4 (non-regression) | ✅ MVP | ✅ v1 | | 2 — Defaults (MVP complete) | Defaults precedence 4-branch green; `createFeature` backward-compat green; `FEATURE_DEFAULTS_MUTATED` emitted; defaults handlers guarded; `DefaultsTab` E2E green | G15, G3 (api subset), G8 (admin.spec, non-blocking) | ✅ MVP | ✅ v1 | | 3 — Server | DSN write-only green; restart classification green; `roles.*` not exposed; server handlers guarded; `ServerTab` E2E green | G16, G3 (api subset), G8 (admin.spec, non-blocking) | ❌ (v1 completeness) | ✅ v1 | @@ -203,13 +203,13 @@ merge to main → deploy.sh (4.3 re-runs G8 as smoke) 4.1 Deployment Pipeline consumes G9 (the `gate` job status) as its promotion input. 4.3 Deployment Execution re-runs **G8 (E2E)** post-deploy as the smoke test (P10: "deployment is not done until smoke passes"). `deploy.sh`'s pre-flight `gh run list --branch main` check is the branch-protection backstop for the private repo. -### 6.1 Migration 018 rollback trigger (input to 4.1) +### 6.1 Migration 019 rollback trigger (input to 4.1) Per principle #2 ("Rollback is not optional") and the existing `rollback.sh`: - **Smoke gate (G8) fails post-deploy** → `deploy.sh` auto-invokes `rollback.sh`. The rollback procedure is git-based: `git revert` the merge commit on `main`, rebuild, restart the systemd unit. -- **Migration 018 is forward-only** (no `Down`). Code rollback (via `rollback.sh`) leaves migration 018's tables orphaned but harmless (additive, <1 MB, ignored by the reverted binary). Same posture as the sibling feature's migration 017. -- **Data rollback** (if migration 018 fails in production): manual `pg_restore` or forward-fix migration 019. No automated data rollback — inherited posture. +- **Migration 019 is forward-only** (no `Down`). Code rollback (via `rollback.sh`) leaves migration 019's tables orphaned but harmless (additive, <1 MB, ignored by the reverted binary). Same posture as the sibling feature's migration 017. +- **Data rollback** (if migration 019 fails in production): manual `pg_restore` or forward-fix migration 020. No automated data rollback — inherited posture. - **Config-state recovery (new this feature)**: the startup reconciler (U-CONFIG-01, FR-CONFIG-05) re-materializes stale YAML from DB on next successful boot. 4.1 should record this in the rollback runbook: "settings-store config-state recovery does not require DB restore; the reconciler handles it on next boot." --- @@ -232,7 +232,7 @@ Per `quality-report` rev2 §5 and the sibling feature's `quality-gates.md`: 4. **Bolt mapping is consistent** with `bolt-plan` rev2 §2 and `quality-report` rev2 §3. MVP = Bolts 0–2; their gates (G10–G15) are the MVP sign-off set. v1 = Bolts 0–4; their gates (G10–G17) are the v1 sign-off set. ✓ 5. **Rule mapping covers the binding `discovered-rules`** — R-BUILD-*, R-TEST-01..06, R-TEST-08 all have an enforcing gate or an explicit "not a gate" note. ✓ 6. **Risk mapping covers the 8 v1 RAID risks** — every v1 risk has an enforcing gate, marked MVP / v1-completeness per the 1.7-gate strict scope. The 3 provider/cicd risks are **resolved by scope cut**, not deferred — no gate is defined for them because there is no code to gate. ✓ -7. **Rollback trigger is concrete** — G8 failure post-deploy → `rollback.sh` (git revert + rebuild + restart); migration 018 forward-only; reconciler handles config-state recovery. ✓ +7. **Rollback trigger is concrete** — G8 failure post-deploy → `rollback.sh` (git revert + rebuild + restart); migration 019 forward-only; reconciler handles config-state recovery. ✓ 8. **Scope discipline** — no coverage gate, no security scan gate, no performance gate, no cross-browser gate, no CI/CD gate, no opencode builder gate. Each omission is recorded with its source rationale (`ci-config.md` §7, `quality-report` rev2 §5). ✓ 9. **v1 scope is binding** — G20 (Providers integration) is explicitly gated on the sibling feature reaching 2.6; it is recorded for traceability but not enforced in v1. The CI/CD and opencode builder gates are removed entirely (resolved by scope cut, not deferred). ✓ 10. **Baseline shift is recorded** — §0 flags the 2.2/3.6 "no CI" staleness so 4.1/4.3 and the reviewer gate operate against the current baseline. ✓ diff --git a/internal/api/config_handlers_test.go b/internal/api/config_handlers_test.go index d446c7a..a110772 100644 --- a/internal/api/config_handlers_test.go +++ b/internal/api/config_handlers_test.go @@ -26,8 +26,12 @@ func configTestServer(t *testing.T) *Server { } func openTestDB() (d *db.DB, err error) { - return db.Open(db.Config{DSN: "host=localhost port=5432 user=devteam password=devteam dbname=devteam_test_db sslmode=disable"}, - "host=localhost port=5432 user=devteam password=devteam dbname=devteam_test_db sslmode=disable") + // Use devteam_test_config (same as internal/config tests) to avoid + // cross-package parallel races with internal/db tests on devteam_test_db. + // The config handler tests truncate audit_events/providers which would + // collide with internal/db.TestGetAuditEventsFiltered if sharing the DB. + return db.Open(db.Config{DSN: "host=localhost port=5432 user=devteam password=devteam dbname=devteam_test_config sslmode=disable"}, + "host=localhost port=5432 user=devteam password=devteam dbname=devteam_test_config sslmode=disable") } func truncateForAPITest(d *db.DB) { diff --git a/internal/role/streamer_test.go b/internal/role/streamer_test.go index 53cba0b..f4c9336 100644 --- a/internal/role/streamer_test.go +++ b/internal/role/streamer_test.go @@ -331,6 +331,11 @@ func TestStreamOutputRetryOnceOnFlushError(t *testing.T) { // within a single flush: the DB flush call completes before the channel send // (U-BK-03 / ADR-8). The unbuffered channel forces the send to block until the // receiver consumes, so the recorded order is strict. +// +// Synchronization: a buffered done channel lets the receiver acknowledge +// each line without blocking. After StreamOutput returns, the test drains +// the done channel to ensure all receiver appends have landed before +// asserting order. func TestStreamOutputPersistBeforePushOrder(t *testing.T) { order := make([]string, 0, 4) var mu sync.Mutex @@ -341,14 +346,16 @@ func TestStreamOutputPersistBeforePushOrder(t *testing.T) { return nil } - // Unbuffered channel — the send blocks until the receiver consumes, so - // the next flush cannot start until the previous channel send completes. + // Unbuffered channel — the send blocks until the receiver consumes. + // Buffered done channel — receiver acknowledges without blocking. lineCh := make(chan OutputLine) + done := make(chan struct{}, 4) go func() { for line := range lineCh { mu.Lock() order = append(order, "chan:"+line.Line) mu.Unlock() + done <- struct{}{} } }() @@ -363,8 +370,11 @@ func TestStreamOutputPersistBeforePushOrder(t *testing.T) { } close(lineCh) - // Wait briefly for the receiver to observe the last send + the close. - time.Sleep(50 * time.Millisecond) + // Drain the done channel — 2 lines sent, 2 acks expected. + <-done + <-done + // Brief wait for the receiver goroutine to observe close. + time.Sleep(10 * time.Millisecond) mu.Lock() defer mu.Unlock()