Skip to content

17. End to end: K11 Shop

This chapter follows a complete system through the whole pipeline. Everything in it is real and public: the K11 Shop demo repository and its five open pull requests. Read it with the repository open.

The system

K11 Shop is small but has the parts real systems have:

flowchart LR
    C[Customers<br/>alice, bob] -->|bearer token| API[Orders API]
    API --> DB[(SQLite)]
    API -->|OrderCreated| K[[Kafka<br/>orders.events]]
    K --> INV[Inventory consumer]
    INV -->|StockReserved| K
    INV --> DB
    BO[Back office] -->|cancel command| CMD[[orders.commands]]
    CMD --> CC[Commands consumer]
    CC -->|unreadable| DLQ[[orders.dlq]]
    JOB[Nightly job] --> DB
  • An orders API (src/shop/api/) with bearer-token auth (src/shop/auth/): customers only ever see their own orders.
  • Kafka events described in asyncapi.yaml; an inventory consumer that reserves and releases stock.
  • A commands consumer that sends anything it can't read to a dead-letter queue.
  • A nightly batch job that must be safe to rerun.
  • A contract, openapi.yaml, with two known consumers: the mobile app (critical, reads total) and analytics (medium, reads createdAt).

The folder layout matters: api/, auth/, consumers/ and jobs/ match the gate's default triggers, so changes in each require the right evidence.

Its .qa-mcp/

.qa-mcp/
โ”œโ”€โ”€ api-test.yaml          environments ci and prod, test users alice and bob, the test database, a SKU fixture
โ”œโ”€โ”€ consumers.yaml         mobile-app (critical) and analytics (medium), with the fields each reads
โ”œโ”€โ”€ security.yaml          alice owns a test order; bob must not reach it; five OWASP checks
โ”œโ”€โ”€ integration.yaml       Kafka from ${ENV:KAFKA_BOOTSTRAP}, the sku_totals job, asyncapi.yaml
โ””โ”€โ”€ release-policy.yaml    unit and API tests always; the rest required by what a change touches

The policy is four lines:

name: K11 Shop release policy
required: [junit, api_tests]
max_age_hours: 6
approvers: ["@qa-lead"]

The pipeline

Five jobs on every pull request:

Job Runs Evidence
Unit tests pytest, 13 tests test-results/junit.xml
API functional + security the shop, then API Functional QA (2 flows) and API Security QA (13 checks as alice and bob) api-test-report/, security-report/
API contract contract-ci against the PR's base branch contract-report/
Integration a real Apache Kafka (service container), the shop on Kafka, then 4 integration flows integration-report/
Release gate downloads every report into .qa-mcp/, then the Action one PR comment

On main, every job passes and the gate says ship.

Five pull requests, five decisions

#1 Docs: how to run the pipeline locally โ†’ ๐ŸŸข Ship

A README change. Nothing in it triggers extra evidence, the required unit and API tests pass, and the verdict is ship. A change that touches nothing risky shouldn't need a person.

#2 Inventory: cap automatic reservations at 2 units โ†’ ๐Ÿ”ด Block

The consumer now reserves at most 2 units, "so bulk orders go to manual review". The unit tests pass (they order 2 items). But it also publishes StockReserved with qty 2 for an order of 3, which downstream services would trust.

1 integration flow failed (integration.failed) An order reserves stock through the inventory consumer: the inventory consumer reserves all 3: 0 of 1 matching message(s) within 10s; closest: $.qty: expected 3, got 2

The integration flow on real Kafka caught it, and the closest-message evidence says exactly how the event differs.

#3 Orders API: stop returning total โ†’ ๐Ÿ”ด Block

"Clients can compute it." The field is removed from the API and the spec, and the developer updated the unit tests, which pass.

  • API change breaks mobile-app (contract.breaks_critical_consumer): mobile-app (critical, owner @team-mobile): 2 breaking changes
  • 1 API flow failed (api.flow_failed): A customer orders, sees it reserved, and cancels it
  • 1 integration flow failed (integration.failed): place an order for 3: $.total 30.0: missing

Three independent kinds of evidence agree, and the first names the team to talk to.

#4 Orders: share one order lookup โ†’ ๐Ÿ”ด Block

A "simplification" looks orders up by id only, like the back office does. Now any logged-in customer can read any order.

  • 1 high-severity security finding (security.high): API1:2023 bob can read an object that belongs to alice (GET /orders/{id})
  • 1 test failed (junit.failures): test_customers_only_see_their_own_orders

Here the unit tests catch it too. Two kinds of evidence agree, and the security finding names the OWASP category, the request and the user.

#5 Orders API: drop createdAt โ†’ ๐ŸŸ  Needs a person

Only analytics reads createdAt, and analytics is medium criticality. The unit tests were updated and pass.

Sign-off needed from @qa-lead before release. - API change breaks analytics (contract.breaks_consumer): analytics (medium): 1 breaking change

Not a blocker, and not silently allowed either: the person who knows whether analytics can cope decides, with the evidence in front of them.

What the five show

  • In three of the five (#2, #3, #5), the unit tests pass. The problems live between the parts.
  • Each verdict comes from the evidence you'd expect: integration for a consumer bug, contract for a removed field, security for a missing owner check.
  • The gate's answers span all the useful cases: ship what's safe, block what's broken, and ask a person when it's a judgement call.

Running it yourself

git clone https://github.com/K11-Software-Solutions/k11techlab-release-gate-demo
cd k11techlab-release-gate-demo
pip install -e ".[dev]"
pytest                                   # 13 unit tests
python -m shop.app --port 8095           # the shop (add --kafka localhost:9092 with a local Kafka)

With the K11 tools installed:

export SHOP_URL=http://127.0.0.1:8095 ALICE_TOKEN=alice-test-token BOB_TOKEN=bob-test-token
k11-api-functional-qa-mcp run --env ci
k11-api-security-qa-mcp run --env ci --no-scanners
k11-release-gate-mcp evaluate --base origin/main

The tokens belong to the demo's test users; a real project keeps them in secrets.