Skip to main content

Testing

The pyramid of this repository, with the exact commands and what CI runs. Counts below are func Test... declarations at the top level (sub-tests and table rows are not counted), measured on develop.

LayerWhereSizeCommand
Unitinternal/domain/..., internal/application/..., adapters, cmd/api285 tests in 56 files without a build tagmake test
BDD (godog / Gherkin)features/*.feature + features/features_*_test.go (no Go file at the repo root, enforced by TestNoGoFilesAtRepoRoot)9 feature files, 130 scenario definitions and 195 scenarios (1401 steps) once Outline Examples rows are expandedmake bdd
Integration (testcontainers)files tagged //go:build integration43 tests in 13 filesmake integration
Contractinternal/adapters/inbound/http/contract_internal_test.go, internal/testing/repocontract, golden JSON, apis/*.yaml linted by Spectralsee belowmake test, CI api-lint
Mutation.gremlins.yaml over internal/domain/...4 packagesmake mutation
Architecture fitnessinternal/architecture23 tests across 10 filesmake arch-test
Evalsnone in this repositorysee below

Unit​

Plain go test ./... -race; no database and no broker. Use-case tests run over the in-memory adapters, the HTTP adapter is exercised with httptest, the Kafka consumers with fake Reader and DeadLetterWriter implementations (consume_loop_test.go, deadletter_test.go), the relay with a fake store and sink. make coverage re-runs the suite with -coverpkg=./internal/domain/...,./internal/application/... and fails below 90 %. It is the only definition of the coverage scope: repo_lint rule R11 fails any workflow that sets its own -coverpkg.

BDD (godog)​

TestFeatures (in features/features_test.go, package features_test, godog Paths: ["."]) runs every .feature file in features/ with Strict: true. The repository root holds no Go file: TestNoGoFilesAtRepoRoot fails if one appears. It drives the real use cases over the in-memory adapters (the same use cases cmd/api wires over Postgres and Kafka), and feeds the local copies through the consumer use cases with the payloads the producers' contracts define. It does not go through HTTP or Kafka. The clock is fixed and request ids are sequential (repl-0001, ...).

The *_rules.feature and pack_derived_rules.feature files pin the rules the context documentation states and no scenario pinned yet: one rule per scenario, boundaries as Outline rows. Their steps are in features/features_rules_test.go (one registerRulesSteps call) and features/features_pack_test.go. The runner executes 195 scenarios (go test ./features -run TestFeatures -count=1 -v, the N scenarios line); the table counts definitions (^[[:space:]]*Scenario in features/, 130 in all, Outlines count once).

FeatureScenariosCovers
detection.feature26raising at or below the minimum, URGENT, reserved stock, fullest reserve bin and partial fills, rounding to a multiple, NO_SOURCE, stale and redelivered levels, invalid levels, zone and decommissioned filters, pick-face listing, manual requests and their refusals, one open request per face
detection_rules.feature22trigger boundary (projected == min), source-bin ranking by usable stock, reserve-bin and pick-face eligibility, sweep, pick-face view, manual requests
forward_map.feature5the forward map only moves forward in time (stale, equal-instant no-op, replacement, late older map, per-site stamps)
lifecycle.feature16completion by a matching relocation, partial relocations, duplicates, relocations that are not ours, cancellation by slot plan or operator, listing and reading requests
lifecycle_rules.feature14request facts and versions, final states, relocation matching, request-id shape, slot-plan cancellations, policy removal scope
consumer_rules.feature8invalid payloads, version ordering, redelivery of slot plans, layout validation
pack_derived_rules.feature21ADR 0009 pack-derived multiple: CASE level in force, re-derive, stale, repair
policies.feature10declare, change with If-Match, stale and missing versions, bounds, removal cancelling open requests, paging
read_rules.feature8policy invariants, list filters, limit, cursor, state and status validation, last-page paging

Integration (testcontainers)​

Every integration test boots its own Postgres (and Kafka where needed) with testcontainers on the local Docker daemon: no DATABASE_URL, no docker compose, no t.Skip gate (TestPostgresIntegrationTestsUseTestcontainers and TestKafkaIntegrationTestsUseTestcontainers enforce it). The suites:

PackageWhat it proves
cmd/apiPostgres mode migrates, enforces Idempotency-Key and writes the outbox; a replay is byte-identical and carries Idempotency-Replayed: true, a first execution never does; a reused key is 409; a rejection leaves no effect and replays; a 5xx rolls back and is never stored; concurrent requests with one key run once (one answer is a first execution); the noun routes are keyed and the retired verb routes are gone; boot fails closed on an unreachable database
internal/adapters/outbound/postgresthe repository contract (policy, request, read model, processed events, idempotency store) against real Postgres; migrations apply, rerun as a no-op, and every down recreates the previous schema; unit-of-work commit, rollback, panic and nesting; the partial unique index allows one open request per pick face; racing updates; the stale-map guard; outbox ordering, retries, attempt cap and trace context
internal/adapters/outbound/outboxthe relay against real Postgres and Kafka publishes the exact envelopes; a rolled-back unit of work publishes nothing; the attempt cap excludes a poison row and a re-armed row is claimed again
internal/adapters/inbound/kafkathe inventory, slotting and layout consumers against real Kafka and Postgres

Contract​

There is no schemathesis job. The REST and event contracts are guarded by:

  • TestRouterServesExactlyTheDocumentedOperations: all 12 operations of apis/openapi.yaml are routed and the router serves nothing else; TestProblemSlugsMatchTheContract and TestProblemStatusesMatchTheContract: every problem slug the adapter can answer has an example in the spec and every documented slug is produced, with matching statuses.
  • internal/testing/repocontract: one behavioural contract that the in-memory repositories and the Postgres repositories both pass (memory/contract_test.go and postgres/contract_integration_test.go), so the BDD world behaves like production.
  • Golden files in internal/adapters/outbound/events/testdata/ (7 files: requested, completed and cancelled on both topics, and the analytics-only policy declaration) pin the exact bytes of every published CloudEvent.
  • TestEventCatalogueMatchesContract: every full type string apis/asyncapi.yaml declares for this service appears in the CloudEvents ADR.
  • CI api-lint: Spectral over apis/openapi.yaml (.spectral.yaml) and apis/asyncapi.yaml (.spectral.asyncapi.yaml) with --fail-severity=warn.

Mutation (gremlins)​

.gremlins.yaml: one worker, timeout-coefficient 30, thresholds efficacy: 99 and mutant-coverage: 99. Gremlins fails when the measured value is at or below the threshold, so the thresholds sit strictly below the measured 100 % / 100 % (no lived mutants) on the four domain packages replenishment, policy, detection and shared. make mutation runs those four, each on its own (the mutation-fast CI job, blocking on every PR). make mutation-full runs ./internal/domain as a whole (the scheduled mutation job). A new package under internal/domain/ must be added to MUTATION_FAST_PKGS in the Makefile and to the mutation-fast loop in ci.yml.

Architecture fitness tests​

internal/architecture (arch-go and source scanners):

TestRule
TestHexagonalArchitecturedomain imports only domain; application only domain and application; inbound and outbound adapters never import each other; only cmd wires layers
TestEventCatalogueMatchesContract, TestEventCatalogueDetectorthe catalogue ADR lists every type the asyncapi declares for this service
TestCloudEventsOnly, TestNoEventEnvelopeToggleOrFlatEnvelopeevery Kafka message is CloudEvents 1.0; no flat envelope or toggle
TestReplayConsumersSetCommitIntervala consumer on a process-unique group id must set CommitInterval; consumers on a fixed shared group (all three here) commit per message on purpose and are not flagged
TestKafkaConsumerGroupNeverHardcodedInlinegroup ids come from the environment
TestKafkaWritersSetRequiredAcks, TestKafkaWriterTopicNotSetTwicewriters use acks=all and carry no fixed topic
TestOutboxRelaysPassAttemptCapevery relay is built with WithMaxAttempts
TestDeadLetterCallsGuardCancellationevery function that sends to a dead-letter topic checks for a cancelled context (or carries a //dlq:deterministic reason), so a message that failed only because of shutdown is never dead-lettered
TestNoAuthMiddlewareReintroducedno auth middleware (fleet decision 2026-09-11)
TestNoGoFilesAtRepoRoot, TestNoGoFilesAtRepoRootSensorBitesthe repository root holds no .go file (the godog runner and steps live in features/)
TestMCPAdapterDependencyRule, TestMCPOptionalToolInputsCarryOmitemptythe rules of the MCP adapter (internal/adapters/inbound/mcp): dependency direction, optional tool inputs carry omitempty
TestA2AAdapterDependencyRule, TestA2ASurfaceIsReadOnly, TestA2ASDKStaysInTheInboundAdapter (a2a_fitness_test.go)the A2A adapter (internal/adapters/inbound/a2a) and cmd/a2a: dependency direction, the MCP read-only sensor applied to them (no write use case, outbox, event sink, Kafka or ports import), and no outbound A2A client (the SDK stays in the inbound adapter and cmd/a2a)
TestMCPReadOnly... (mcp_readonly_fitness_test.go)the MCP adapter and cmd/mcp are read-only: every use case is classified read or write, and they may not import the outbox, event sink, Kafka, memory doubles or the ports package, nor build an outbox, unit of work or idempotency repository. governance_test.go also fails on any write-verb tool name
TestHexagonalArchitecture analytics subtestsinternal/analytics/** depends on nothing internal except itself; the OLTP domain and application never import the analytics store
TestPostgresIntegrationTestsUseTestcontainers, TestKafkaIntegrationTestsUseTestcontainersintegration tests boot their own containers
Test...SensorBites / ...SensorFailsOnBadFixtureseach sensor is proven to fail on a bad fixture

Evals​

EVALS.md in the root is the fleet's record of harness evaluations (agent runs against inventory-storage, runner tools/harness_eval.py). This repository contains neither the runner nor results of its own, so it has no evals.

CI jobs​

.github/workflows/ci.yml runs on push and pull request to main and develop, weekly (Monday 06:00 UTC) and on dispatch.

JobRunsBlocks
lintgolangci-lint v2.14.0yes
guide-lintscripts/harness/guide_lint.py and test_hook.py (agent guides)no (continue-on-error)
complexitygocyclo, gocognit, cyclop, funlen, nestif (thresholds in .golangci.yml) plus an informational gocyclo reportyes
testgo build, go vet, then make coverage (race, 90 % gate), uploads coverage.outyes
bddgo test ./... -run TestFeatures -vyes
integrationgo test -tags=integration ./... -race -count=1yes
mutation-fastgremlins on the four domain packagesyes
mutationgremlins on ./internal/domain; opens or closes a harness:red issueonly on schedule / dispatch
driftdead code, go mod tidy -diff, knip on web/, coverage-qualityonly on schedule / dispatch, advisory
api-lintSpectral on both specsyes
vulngovulncheck ./...yes
chart-testsrender_test.sh, test_service_selectors.py, test_kong_config.py under charts/pick-face-replenishment/testsyes
arch-testgo test ./internal/architecture/... -vyes
docker-publishbuild the root Dockerfile, push, cosign, SBOM to GHCRonly on push to main
releasetag, retag image, package and push the Helm chart, GitHub releaseonly on push to main

Two more workflows: docs.yml builds this site on every pull request touching docs/**, apis/** or the workflow, and deploys to GitHub Pages on push to main; ai-review.yml is an advisory review of pull requests that touch the domain, application, apis/ or charts/.

Locally: make check is the fast gate (fmt-check vet build lint test, also the lefthook pre-push hook) and make check-all adds coverage arch-test bdd. Integration and mutation are deliberately not part of either.