fix(ci): isolate Compose project namespace from host stacks #94
Merged
syntropicagent opened 3 weeks ago

Summary

Pins COMPOSE_PROJECT_NAME=ki-ci at the top of the CI job so every docker compose invocation (buildspec, ci-check.sh, verify-clean-bootstrap.sh) targets an isolated, disposable project instead of deriving the project name from the workspace directory.

Root cause (KI-390 and friends)

The Compose project name defaulted to the checkout directory name, which collided with the long-running work stack on the CI host:

  • KI-388: CI's docker compose down -v operated on the shared project and recreated the stack's data volumes (2026-08-14 05:12)
  • KI-389 (cancelled): verify-clean-bootstrap created kokonut_bootstrap_5367 in the shared Postgres; the cleanup trap never fired on cancellation
  • KI-390: CREATE DATABASE kokonut_bootstrap_5367 collided with the orphan → red build

Changes

  • Export COMPOSE_PROJECT_NAME=ki-ci before any Compose usage
  • Pre-flight guard: verifies the namespace is pinned, fails fast otherwise (prevents regression to host-shared projects)
  • No changes needed in ci-check.sh / verify-clean-bootstrap.sh — they inherit the env var

Expected effect

  • KI-390's bootstrap collision disappears (fresh project per run)
  • CI can never again touch non-CI Compose stacks on the host
  • Stale CI state is fully cleaned by the existing down -v (now scoped to ki-ci)
Commits were merged into target branch
  • fix(ci): isolate Compose project namespace from host stacks
    CI's Compose project name defaulted to the workspace directory name,
    which collided with the long-running 'work' stack on the CI host
    (/onedev-build/work). Consequences observed in KI-388..390:
    
    - CI 'docker compose down -v' operated on the shared project and
      recreated the stack's data volumes (2026-08-14 05:12)
    - verify-clean-bootstrap created/dropped databases in the shared
      Postgres; a cancelled build (#389) left an orphaned
      kokonut_bootstrap_5367 database whose cleanup trap never fired
    - build #390 then failed on CREATE DATABASE collision
    
    Fix: pin COMPOSE_PROJECT_NAME=ki-ci at the top of the job so every
    docker compose call (buildspec, ci-check.sh, verify-clean-bootstrap.sh)
    targets an isolated, disposable project regardless of checkout path.
    
    Add a pre-flight guard that verifies the namespace is pinned and fails
    fast if it is not, preventing regression to host-shared projects.
    
    Co-authored-by: Syntropic Agent <syntropic-agent@kokonut.network>
    3 weeks ago
  • fix(ci): start CI database before ci-check bootstrap gate
    With the isolated ki-ci namespace (previous commit), no PostgreSQL
    container exists when ci-check.sh runs its Clean PostgreSQL bootstrap
    check — previously it accidentally reached the shared host stack's
    database. Start the database service (ki-ci project) before the
    fast-fail gate and wait for pg_isready. The infra step later runs
    'down -v' + fresh 'up', so this early container is disposable.
    
    Co-authored-by: Syntropic Agent <syntropic-agent@kokonut.network>
    3 weeks ago
  • fix(ci): keep early bootstrap database off host port 5432
    KI-392: the early database (started for the bootstrap check) published
    127.0.0.1:5432 via docker-compose.ci.yml, colliding with another stack
    holding that port on the CI host. The bootstrap check is exec-based
    ('docker compose exec database psql'), so the port publish is
    unnecessary at this stage — use the base compose file only (ports stay
    private). The infra step later recreates the project with the ci.yml
    override for the host-run test suite.
    
    Co-authored-by: Syntropic Agent <syntropic-agent@kokonut.network>
    3 weeks ago
  • fix(ci): make ci.yml host ports configurable to avoid shared-host conflicts
    KI-393 got through all 65 fast-fail checks, then the infra step hit
    'Bind for 127.0.0.1:8123 failed: port is already allocated' — the dev
    'work' stack on the CI host holds 5432/8123.
    
    Make docker-compose.ci.yml host ports configurable via CI_PG_HOST_PORT /
    CI_CH_HOST_PORT (defaults unchanged: 127.0.0.1:5432/8123, so local dev
    behavior is identical). The CI buildspec pins high ports 15432/18123.
    
    Tests reach the databases via the Compose network (PG_HOST=database /
    CH_HOST=clickhouse), so the published ports are for host-side debugging
    only; nothing in CI depends on the specific host port values.
    
    Co-authored-by: Syntropic Agent <syntropic-agent@kokonut.network>
    3 weeks ago
  • fix(ci): make directus/gateway/grpc host ports configurable
    KI-394 cleared the database/clickhouse conflicts but hit the next tier:
    the base compose file publishes directus 8055, gateway 8099, and grpc
    50051 — all held by the dev 'work' stack on the shared CI host.
    
    Make these ports env-driven with current defaults (DIRECTUS_HOST_PORT,
    GATEWAY_HOST_PORT, GRPC_HOST_PORT — local dev behavior unchanged) and
    pin high ports in the CI buildspec: 18055 / 18099 / 50052.
    
    The grpc container healthcheck targets 127.0.0.1:50051 inside the
    container (unaffected by host mapping); the one test referencing 50051
    mocks the channel entirely.
    
    Co-authored-by: Syntropic Agent <syntropic-agent@kokonut.network>
    3 weeks ago
  • test: fix statistically unsound triangular sampling assertion
    test_scenario_param_sample_triangular asserted the sample mean of 100
    triangular draws ≈ the mode (0.05), but the distribution's true mean is
    (a+b+c)/3 ≈ 0.0733. With n=100 the sample mean has SE ≈ 0.003, so the
    0.03 tolerance fails ~1.5% of runs — a flake that hit KI-395.
    
    Assert against the true distribution mean with n=2000 (SE ≈ 0.0006,
    tolerance 0.01 ≈ 16 SE): zero failures across 500 seeded trials.
    Bounds assertion retained unchanged.
    
    Co-authored-by: Syntropic Agent <syntropic-agent@kokonut.network>
    3 weeks ago
  • syntropicagent commented 3 weeks ago

    Merged on Wasabi's explicit instruction. CI KI-396 green: all fast-fail gates, 4,098 tests, static analysis, Solidity, and hooks passed. This unblocks PR #93 (consolidation work) whose CI was blocked by the same compose-namespace collision.

  • syntropicagent merged 3 weeks ago (merge commit: 3a6b5b17 )
1/1
Submitter syntropicagent
Target chore/platform-consolidation-dedup
Source fix/ci-compose-namespace-isolation
Merge Strategy
Create Merge Commit
Watchers (1)
Reference
pr KI-94
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover