Kafka data generator and load testing tool - generate fake messages, simulate producers and consumers, test broker failures, and run chaos engineering scenarios
Go apache-kafkaapache-sparkchaos-engineeringconsumer-lagdata-engineeringdata-generatordevopsdevops-toolsfake-datafault-injectionflinkkafkakafka-consumerkafka-data-generatorkafka-load-testingkafka-producerkafka-test-dataload-testingstream-processingstress-testing
ci: add website CI build check and Cloudflare deploy-on-merge workflows
aleksandarskrbic7a08e882d8f6
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.mdindex 5a1426f..3510973 100644--- a/.github/ISSUE_TEMPLATE/bug_report.md+++ b/.github/ISSUE_TEMPLATE/bug_report.md@@ -19,8 +19,7 @@ What you expected to happen.**Environment**- OS: [e.g. macOS 14, Ubuntu 22.04]-- Python: [e.g. 3.12]-- khaos version: [e.g. 0.1.0]+- khaos version: [output of `khaos --version`]**Additional context**Any other context, logs, or screenshots.diff --git a/.github/workflows/deploy-website.yml b/.github/workflows/deploy-website.ymlnew file mode 100644index 0000000..a32cbda--- /dev/null+++ b/.github/workflows/deploy-website.yml@@ -0,0 +1,39 @@+name: Deploy Website++on:+ push:+ branches: [main]+ paths:+ - "website/**"+ workflow_dispatch: {}++permissions:+ contents: read++defaults:+ run:+ working-directory: website++jobs:+ deploy:+ runs-on: ubuntu-latest+ env:+ NEXT_PUBLIC_SITE_URL: https://getkhaos.dev+ # Not ambiguous for this account (single Cloudflare account on the token), so this+ # is a plain env var rather than a secret.+ CLOUDFLARE_ACCOUNT_ID: 75e65e168a9fd5e42ab6534a244147a7+ steps:+ - uses: actions/checkout@v4++ - uses: actions/setup-node@v4+ with:+ node-version: "22"+ cache: npm+ cache-dependency-path: website/package-lock.json++ - run: npm ci++ - name: Deploy to Cloudflare+ env:+ CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}+ run: npm run deploydiff --git a/.github/workflows/website-ci.yml b/.github/workflows/website-ci.ymlnew file mode 100644index 0000000..54b8d0d--- /dev/null+++ b/.github/workflows/website-ci.yml@@ -0,0 +1,37 @@+name: Website CI++on:+ pull_request:+ paths:+ - "website/**"++permissions:+ contents: read++defaults:+ run:+ working-directory: website++jobs:+ build:+ runs-on: ubuntu-latest+ env:+ NEXT_PUBLIC_SITE_URL: https://getkhaos.dev+ steps:+ - uses: actions/checkout@v4++ - uses: actions/setup-node@v4+ with:+ node-version: "22"+ cache: npm+ cache-dependency-path: website/package-lock.json++ - run: npm ci++ - run: npm run lint++ - run: npm run build++ # Catches breakage specific to the Cloudflare Worker build, not just the plain Next.js build.+ - name: build Cloudflare Worker bundle+ run: npx opennextjs-cloudflare builddiff --git a/GOAVRO_MIGRATION.md b/GOAVRO_MIGRATION.mddeleted file mode 100644index d2c0b9d..0000000--- a/GOAVRO_MIGRATION.md+++ /dev/null@@ -1,133 +0,0 @@-# Handoff: replace hamba/avro with goavro--Not started yet — this session got interrupted before writing any code. Read this top to-bottom before touching `internal/codec`.--## The ask--Swap the Avro backend in `internal/codec` from `github.com/hamba/avro/v2` to-`github.com/linkedin/goavro/v2`. `DECISIONS.md` D8 already flagged the reason: hamba/avro-is archived upstream with a reported unpatched CVE. goavro is confirmed reachable —-`go list -m -versions github.com/linkedin/goavro/v2` returned versions up to **v2.15.0**-over the proxy in this environment, so `go get github.com/linkedin/goavro/[email protected]` should-work. That `go get` was not run yet (interrupted) — go.mod/go.sum still show only hamba.--This is unrelated to the engine-bugs work done earlier in the same session (metrics wiring,-`target.indices`, `change_producer_rate` — see `git status` / `git diff`, all uncommitted-and already reviewed-pending). Don't conflate the two; this is a fresh, separate task.--## Why this is not a mechanical find-and-replace--hamba/avro and goavro have genuinely different APIs, and the current code leans hard on-hamba's object model. Read `internal/codec/avro.go`, `avro_coerce.go`, and the relevant-bits of `codec.go` in full before starting.--**hamba/avro** (current):-- `avro.ParseWithCache(text, ns, *avro.SchemaCache)` returns a `avro.Schema` — a real object- model: `*avro.RecordSchema` (`.Fields()`, each with `.Name()`/`.Type()`), `*avro.ArraySchema`- (`.Items()`), `*avro.MapSchema` (`.Values()`), `*avro.UnionSchema` (`.Types()`),- `*avro.RefSchema` (`.Schema()`, unwraps a second reference to a named type).-- `avro.Marshal(schema, nativeGoValue)` / `avro.Unmarshal(schema, bytes, &out)` work directly- against plain Go maps (`map[string]any`) and auto-unwrap/auto-wrap unions (a nullable- field is just given its bare value or `nil`, never a wrapped union map).-- Decodes `timestamp-millis` to `time.Time` and `time-millis` to `time.Duration`- automatically — `avroScalar()` in `avro.go` converts these back to plain epoch-millis- `int64` because khaos always generates/round-trips integers, never `time.Time`.-- `coerceAvro()` in `avro_coerce.go` walks the schema alongside the value converting Go- types hamba is strict about (int64→int for `int`, float64→float32 for `float`, string→- []byte for `bytes`), and — this is the part that will need to invert — **unwraps unions**:- for `*avro.UnionSchema` it just recurses into the first non-null branch, because hamba's- `Marshal` doesn't want anything union-shaped on the way in.-- `parseAvro()` uses a *fresh* `avro.SchemaCache` per call specifically so that one topic's- generated schema can never resolve a named-type reference against another topic's cache- entry (`TestAvroParseDoesNotShareNamesBetweenSchemas` pins this — hamba's default parse- path publishes into a shared package-level cache, which is the bug being dodged).--**goavro/v2** (target — verify the exact API against the actual fetched module, this is-from general knowledge, not re-checked against v2.15.0 docs in this session):-- `goavro.NewCodec(schemaJSON string) (*goavro.Codec, error)` — no per-parse cache knob, and- I don't think it has hamba's shared-global-cache problem in the first place (no evidence- goavro publishes named types outside one schema document), but **confirm this** — if it- does leak names across `NewCodec` calls the same isolation problem needs solving.-- `codec.BinaryFromNative(buf []byte, native interface{}) ([]byte, error)` and- `codec.NativeFromBinary(buf []byte) (interface{}, []byte, error)` — the encode/decode- pair. Note `NativeFromBinary` returns `(interface{}, []byte remaining, error)`, not- `(value, error)`.-- **Unions are NOT auto-wrapped/unwrapped.** goavro represents an Avro union value as a Go- `map[string]interface{}` with exactly one key: the branch's type name (e.g. a- `["null","string"]` field holding "hi" must be handed to `BinaryFromNative` as- `map[string]interface{}{"string": "hi"}`, and a null value as literal `nil`). Every- place `coerceAvro` currently *unwraps* a union will need to instead *wrap* it for encode,- and `avroDecodedValue`/`avroScalar` will need to *unwrap* the `{branchName: value}` map- goavro hands back on decode. Get the branch-name-to-Avro-type mapping right (it's the- schema's own type names — `"string"`, `"long"`, a record's `name`, etc.) or every optional- field breaks.-- **No object schema model exposed the same way.** goavro doesn't hand back a walkable- `RecordSchema`/`ArraySchema`/`MapSchema` tree — `avroRecordDoc()`'s trick of walking- `rec.Fields()` in schema order to rebuild a Doc with stable key order won't have that to- lean on. `avroSchemaJSON()` (already in `avro.go`, used for the registry conversion path)- parses the schema text into a generic `map[string]any` — that's the fallback to get field- order back if goavro's package doesn't expose one; check whether goavro's codec object- exposes anything like a parsed schema tree first (there's some `CodecForStandardJSONFull`- variant and possibly a `.Schema()` that only returns the *text* back, not a tree) before- hand-rolling JSON-schema walking.-- Logical type handling (`uuid`, `timestamp-millis`) may or may not be native in whatever- goavro version lands — verify with a quick round-trip test before assuming `avroScalar`'s- `time.Time`/`time.Duration` conversion logic is still needed at all. It's plausible goavro- just hands back a plain `int64` for `timestamp-millis` with no logical-type coercion,- which would *simplify* `avroScalar`, not complicate it — check before porting that- function over unchanged.--## Files touched--- `internal/codec/avro.go` — `avroCodec.Encode`/`Decode`, `parseAvro`, `avroRecordDoc`,- `avroDecodedValue`, `avroScalar`, `derefAvro`. `AvroSchemaText`/`avroFieldEntries`/- `avroTypeOf` (schema *generation*, not parsing) are format-agnostic and should need **no- changes** — they just build the JSON schema text via `codec.Doc`, independent of which- library parses it back.-- `internal/codec/avro_coerce.go` — `coerceAvro` needs a real rewrite (union wrap direction- flips, per above), not a search-and-replace of type names.-- `internal/codec/codec.go` — `newAvroCodec()` currently type-asserts- `parsed.(*avro.RecordSchema)` to build `avroCodec{schema, record}`; whatever replaces- `record` (a wrapper carrying goavro's codec + a field-order list, most likely) gets built- here.-- `internal/codec/avro_test.go` — imports `github.com/hamba/avro/v2` directly in two tests- (`TestAvroRoundTrip`, `TestAvroTimestampNormalisation` both do- `schema.(*avro.RecordSchema)`) — these need to build whatever the new `avroCodec` struct- shape is instead. **The test *behavior* they assert must not change**: exact schema JSON- text (`TestAvroSchemaText`), full round-trip identity including nested record/array/map/- enum/uuid/timestamp *and doc key order* (`TestAvroRoundTrip`), schema-cache isolation- across topics (`TestAvroParseDoesNotShareNamesBetweenSchemas` — port the intent even if- goavro's isolation story turns out to be different), timestamp epoch-millis round-trip- (`TestAvroTimestampNormalisation`).-- Check `internal/codec/registry.go` and `internal/codec/convert.go` for any other direct- `avro.` references (a stale grep from this session found matches only in avro.go/- avro_coerce.go/codec.go, but re-grep after starting — state may have shifted).-- `go.mod`/`go.sum`: remove `github.com/hamba/avro/v2`, add `github.com/linkedin/goavro/v2`.--## Why this needs real care, not a quick swap--This is wire-format code. `HANDOFF.md` records that Avro-through-a-live-Schema-Registry was-verified end to end against the **Java** `kafka-avro-console-consumer` — a subtle behavior-drift here (wrong union wrapping, lost field order, a logical type silently mishandled)-would not show up as a compile error or even necessarily a failing unit test if the test-itself gets ported sloppily; it would show up as bytes a real Avro reader chokes on or-silently misinterprets. Budget time for:-1. Writing the new `avroCodec`/`coerceAvro` carefully, matching goavro's actual native-value- conventions (verify against real `go doc` output / a scratch program, not memory).-2. Porting every existing avro test with the same assertions, not weaker ones.-3. If at all possible, an actual round trip through a running Schema Registry + a real Avro- reader (Java console consumer, or at minimum `avro-tools` on the CLI) — not just Go- round-trip tests, since the whole point of switching libraries is not to introduce a new- interop bug while fixing the CVE/archived-library problem.-4. Once green: update `DECISIONS.md` D8 to reflect it's done (same pattern as D5/D11/D14/D15- in that file — strike through, note what changed, leave the "You" column for the user- rather than filling in "ok" yourself).--## Repo state as of this handoff--- `go.mod`/`go.sum`: unchanged, still hamba/avro only. No `go get` was run.-- No code changes made for this task at all.-- Unrelated to this: earlier in the session, three engine bugs were fixed (dead `/metrics`,- `target.indices` ignored, `change_producer_rate` no-op) — all uncommitted, all tested,- waiting on the user's review. Don't touch those files as part of this task unless asked.diff --git a/HANDOFF.md b/HANDOFF.mddeleted file mode 100644index 44ed89c..0000000--- a/HANDOFF.md+++ /dev/null@@ -1,317 +0,0 @@-# Handoff — khaos Python → Go rewrite--Written for a fresh session with no prior context. Read this top to bottom before touching-anything.-------## 1. Where things stand--The rewrite is **done and working**. Python is deleted. ~13.3k lines of Go across 9-packages, ~14.3k lines of tests, 341 test functions, all green under `-race`.--Verified end to end against a real 3-broker Docker cluster: traffic generation, broker-stop/restart faults, consumer rebalances, correlated flows, and Avro + Protobuf through a-live Schema Registry — with the **Java** `kafka-avro-console-consumer` and-`kafka-protobuf-console-consumer` successfully reading Go-produced records.--Branch: `go-rewrite`. **Nothing is committed.** `git status` shows 86 deletions (the Python-tree), 6 modifications, 8 untracked. That is expected — see rule 1 below.--Verify at any time:--```bash-./scripts/check.sh # gofmt, vet, tests, static build, smoke test. No Docker needed.-./scripts/check.sh -r # same, with the race detector-```-------## 2. HARD RULES — do not break these--### Rule 1: NO git write commands. Ever.--The user explicitly forbade `git add`, `git commit`, `git push`. All work stays as-working-tree changes; they will make the commits themselves. Read-only git (`status`,-`diff`, `show`, `log`) is fine and often necessary — the deleted Python source is still-reachable via `git show HEAD:src/khaos/...`, which is the specification.--### Rule 2: Behaviour must match the Python version exactly.--The user stated this twice, forcefully, after I twice "improved" behaviour without asking.-The Python implementation is the specification, including its bugs. Everything below is-deliberately faithful, each behind a single flippable variable:--| Behaviour | Where | Value |-|---|---|---|-| Topics deleted + recreated every run | `internal/kafka/policy.go:65` | `RecreateTopicsByDefault = true` |-| Partition = CRC32 of key (librdkafka `consistent_random`, NOT murmur2) | `internal/kafka/policy.go:26` + `partitioner.go` | hand-written |-| Eager range+roundrobin rebalancing | `internal/kafka/policy.go:46` | not cooperative-sticky |-| `change_producer_rate` is a **no-op** | `internal/engine/producer.go:137` | `LiveProducerRateChanges = false` |-| Impossible cardinality **hangs forever** | `internal/generate/field.go` | `BoundCardinalityFill = false` |-| Flow instances unbounded | `internal/engine/flow.go:35` | `DefaultFlowConcurrency = 0` |-| `target.indices` / `group_id` accepted and **ignored** | `internal/scenario/incident.go` | filter removed |-| Rebalanced consumer **loses** its failure config | `internal/scenario/incident.go` | `Conf` not passed to `CreateConsumer` |-| Hardcoded `kafka-1/2/3`, `replication_factor <= 3` | `internal/scenario/validate.go:42` | `var Cluster` |--**If you think one of these is a bug: it is. Leave it. Ask first.**--Two things genuinely could not be made identical, both documented in code: faker →-gofakeit produces different values and has no locales, and protobuf+registry no longer-re-registers a regex-parsed schema (Go has no equivalent regex parser).--### Rule 3: The user is terse and wants working code.--Short answers. Verify claims with commands rather than asserting them — I was wrong three-times by inferring instead of checking, and each time running one command would have-caught it.-------## 3. THE IMMEDIATE TASK: restyle the live TUI--This is what the next session is for.--The user compared the Go CLI unfavourably to Python's Rich output ("why is UI so ugly? it-just text"). I restyled the **static** commands with lipgloss and they now look right:--- `internal/tui/../cmd/khaos/style.go` — shared palette, TTY/`NO_COLOR` detection-- `cmd/khaos/scenarios.go` — `list` renders via `charm.land/lipgloss/v2/table`, rounded- border, coloured category headings and scenario names, width-capped and wrapping-- `cmd/khaos/cluster.go` — `cluster-status` same treatment, state coloured green/yellow-- `cmd/khaos/scenarios.go` — `validate` gets `✓` / `!` / `✗` and coloured severities--**`internal/tui/tui.go` (460 lines) has NOT had this treatment.** It is the screen a user-stares at for a whole run, and it still lays out columns by hand:--```go-hdr := fmt.Sprintf("%-28s %12s %12s %10s", "TOPIC", "PRODUCED", "CONSUMED", lagHdr)-row := fmt.Sprintf("%-28s %12d %12d %s", ...)-```--What to do:--- Rebuild the topic table, flow table and totals with `charm.land/lipgloss/v2/table`,- matching the look already established in `cmd/khaos/style.go`. Reuse that palette rather- than inventing a second one — currently `tui.go:90-95` defines its own styles.-- Respect the terminal width (`tea.WindowSizeMsg` is already handled, `m.width`).-- Keep the events pane; consider `charm.land/bubbles/v2` viewport if it needs scrolling.-- **Do not change what is displayed**, only how. `internal/tui/render_test.go` (614 lines)- pins the content; expect to update assertions that hardcode column widths, and keep the- semantic ones.--### Non-negotiable constraint on the TUI--The engine must stay completely independent of it. This is the entire point of the-rewrite: in Python the run executed *inside* `with Live(...)` and the render loop owned-both the duration deadline and the shutdown trigger (`src/khaos/executor/base.py:385-398`),-so a stalled UI could wedge an infinite run.--Therefore:--- `internal/engine` must NEVER import `internal/tui`.-- The TUI's only read API is `engine.Snapshot()` — a pure value it **pulls** on a tick.- Never push from the engine, never hand the TUI a pointer into engine state.-- The output layer runs OUTSIDE the engine's errgroup (`cmd/khaos/run.go`), with its own- context and a panic recover, so a TUI crash degrades to headless instead of killing the- run.-------## 3b. SECOND TASK: image-pull progress on first run--Right now the very first `khaos cluster-up` (or `khaos run`, which auto-starts the cluster)-prints `Starting Kafka cluster...` and then **sits silently for several minutes** while-Docker pulls ~1GB of images. It looks hung. On every later run the images are cached and it-is fast, so the bad experience hits exactly once — on someone's first contact with the tool.--Wanted: detect whether the images are already present, and only if some are missing, show a-real progress bar while they download.--### The facts, all verified on 2026-08-20 — do not re-derive these--**The four images** (from `internal/localcluster/assets/*.yml`):--```-confluentinc/cp-kafka:7.6.0-confluentinc/cp-schema-registry:7.6.0-confluentinc/cp-zookeeper:7.6.0-provectuslabs/kafka-ui:latest-```--Enumerate them at runtime rather than hardcoding — `docker compose -f <file> config --images`-works and respects which compose file is in play, but note it prints **duplicates** (once per-service: cp-kafka appears three times). Dedupe.--**Existence check** — `docker image inspect <ref>`, exit 0 means present:--```bash-docker image inspect confluentinc/cp-kafka:7.6.0 >/dev/null 2>&1-```--**Progress stream** — this is the key find. `docker compose` supports-`--progress json` (values: `auto, tty, plain, json, quiet`) and emits newline-delimited-JSON. `docker pull` does NOT have this flag; it must be `docker compose`.--Real captured output from `docker compose -f <file> --progress json pull`:--```json-{"level":"warning","msg":"... the attribute `version` is obsolete ...","time":"..."}-{"id":"Image confluentinc/cp-zookeeper:7.6.0","status":"Working","text":"Pulling"}-{"id":"32d02e677a77","parent_id":"Image confluentinc/cp-zookeeper:7.6.0","status":"Working","text":"Pulling fs layer","details":"0B"}-{"id":"90bb2e7c3a87","parent_id":"Image confluentinc/cp-zookeeper:7.6.0","status":"Working","text":"Downloading","details":"2.097MB","current":2097152,"total":114892458,"percent":1}-{"id":"32d02e677a77","parent_id":"Image confluentinc/cp-zookeeper:7.6.0","status":"Done","text":"Download complete","details":"0B","percent":100}-{"id":"Image alpine:3.19","status":"Done","text":"Pulled"}-```--So you get, per layer: `current` / `total` bytes and `percent`, with `parent_id` linking the-layer to its image, and `status` of `Working` or `Done`. Summing `current`/`total` across-layers gives a genuine byte-level bar; counting images gives "2 of 4".--Two parsing gotchas, both visible above:-- Lines with `level`/`msg` and no `id` are **log records, not progress** — skip them.-- An image-level event has `id` prefixed `"Image "` and no `parent_id`; a layer event has- `parent_id`. Do not mix them or you will double-count.--### Implementation notes--- Belongs in `internal/localcluster` (a `Pull`/`EnsureImages` method), invoked from- `Cluster.Up` before `compose up`. Keep it out of `cmd/`.-- **If nothing is missing, do nothing at all** — no bar, no output, no delay. That is the- actual ask.-- `docker compose pull --policy missing` exists and skips present images, but you still want- the pre-check so you can decide whether to show any UI.-- Render with `charm.land/bubbles/v2/progress`, styled from `cmd/khaos/style.go`. But the- progress bar lives in a command that has not started the Bubble Tea TUI yet, so either run- a short standalone `tea.Program` for the pull phase or draw with carriage returns. A- standalone program is cleaner and matches the existing separation.-- **Must degrade when stdout is not a TTY** (`--tui off`, CI, piped): emit plain lines such- as `pulling confluentinc/cp-kafka:7.6.0 (1/4)` instead of a bar. `colorEnabled` /- `detectColor()` in `cmd/khaos/style.go` already makes this decision; reuse it rather than- adding a second one.-- Honour context cancellation — Ctrl-C during a 1GB pull must exit promptly.-- Testable without Docker: factor the JSON-stream parser into a pure function over an- `io.Reader` and feed it the captured lines above as a fixture. Do not require a daemon in- CI. The existence check can be an injected `func(string) bool`.--### While you are in there--All four compose files start with an obsolete `version:` key, which makes Docker print a-warning on **every single invocation**:--```-the attribute `version` is obsolete, it will be ignored-```--Deleting that line from `internal/localcluster/assets/*.yml` silences it. Harmless but noisy,-and it will pollute the progress output you are about to parse.-------## 4. Architecture map--```-cmd/khaos/ CLI: main, run/simulate, list/validate, cluster-*, style.go-internal/scenario/ domain model, YAML decode, validation, incidents (no deps)-internal/generate/ field/key/payload generators, correlated flows-internal/codec/ JSON | Avro | Protobuf, ± Schema Registry-internal/kafka/ franz-go clients, SASL/TLS, admin, policy.go, partitioner.go-internal/engine/ producers, consumers, scheduler, counters, Snapshot-internal/localcluster/ Docker Compose control (compose files embedded via go:embed)-internal/tui/ Bubble Tea UI — imports engine, never the reverse-internal/telemetry/ slog, prometheus, /healthz + /metrics-```--Dependency direction: `scenario` ← `codec` ← `generate` ← `engine` → `kafka`.-`tui` and `telemetry` depend on `engine`. Nothing depends on `tui`.--Key types:-- `engine.Snapshot` — the engine's entire read API (`internal/engine/stats.go`)-- `scenario.Command` — incident → command ADT, unit-testable without a broker-- `codec.Codec` — two methods, four implementations-- `codec.Doc` / `generate.Doc` — ordered documents; JSON key order is contractual- (Python's `json.dumps` preserves insertion order, Go maps sort)-------## 5. Traps — I hit every one of these--**`go mod tidy` will silently empty go.mod.** It prunes anything no package imports yet. I-ran it early and wiped every dependency, blocking three parallel agents. If you add-packages incrementally, do not tidy until they all import what they need.--**Test doubles that are more helpful than reality hide real bugs.** `fakeCluster` in-`cmd/khaos/run_teardown_test.go` made `BootstrapServers` return an error when the cluster-was down. The real one falls back to `127.0.0.1:9092` and never errors. `khaos run`'s-auto-start guard tested the error, so it was dead code and shipped broken — `run` on a-stopped cluster died with "connection refused". The double is now faithful, and-`Cluster.Running()` is the correct is-it-up test.--**Port 8080.** The bundled compose stack runs `kafka-ui` on 8080, which collides with the-user's nocodb container. `cluster-up` fails; the error now names the real port (it used to-hardcode a wrong claim about 9092-9094). Stop nocodb with-`docker compose -p 2_pg stop` — **never** `down -v`, their Postgres volume is in there.--**`defaults.py` is a trap.** Python has two disagreeing default sets. `scenarios/scenario.py`-wins for YAML-loaded configs (`acks="1"`, `compression="lz4"`, `200/500/50`);-`defaults.py` says `"all"`/`"none"`/`100/1000/100` and applies only where a config is built-without scenario data. `internal/scenario/types.go` collapses both into one const block —-do not "correct" those values.--**Homebrew.** `khaos` is in homebrew-core as a **Python** formula, auto-bumped by-BrewTestBot from PyPI. Stop publishing to PyPI and it freezes at 0.7.1 Python forever. Fix-is one PR converting it to a Go formula, after which BrewTestBot resumes from git tags. The-user does not care about this (`RUNBOOK.md` §4 marks it OPTIONAL). Do not spend time on it-unless asked. One live constraint though: the formula's test asserts `khaos list` contains-**"Available Scenarios"** — `cmd/khaos/list_contract_test.go` pins that string.--**Tests need no Docker.** `kfake` is an in-process broker speaking the real Kafka protocol.-Use it. `cmd/khaos/main_test.go` drives the whole CLI against it.-------## 6. Verification--```bash-# Fast, no Docker-./scripts/check.sh -r--# With the real cluster (free port 8080 first)-go build -o khaos ./cmd/khaos-./khaos cluster-up-./khaos run traffic/high-throughput -d 15 -k # TUI-./khaos run traffic/high-throughput -d 15 -k --tui off --log-json # headless-./khaos cluster-down-```--`RUNBOOK.md` §2 has a 12-step manual test plan with expected output for each step. The two-steps worth not skipping are **6** (Ctrl-C must stop an infinite run promptly — the defect-this rewrite targets) and **9** (Java consumers reading Go-produced Avro/Protobuf — the-only way to catch a wrong Confluent header).-------## 7. Open items--`DECISIONS.md` — 13 questions, every default already live and Python-matching. The user has-not answered them and does not have to; ignore unless asked.--Remaining work, none blocking:--- **TUI restyle** — section 3. Primary task.-- **Image-pull progress** — section 3b. Secondary task, fully specified.-- `assets/demo.gif` shows the old Rich UI. `scripts/demo.tape` needs **no edits** (every- command in it works); just re-record: `cd scripts && vhs demo.tape && mv demo.gif ../assets/`.- Needs Docker up.-- Final PyPI `0.7.2` announcing the move to Go, so pip users are not stranded. Optional.-- `internal/telemetry` is built and tested but the engine does not feed it yet. The user- said Prometheus is not a priority.-------## 8. Docs in this repo--- `RUNBOOK.md` — build, 12-step manual test plan, GoReleaser, Homebrew-- `DECISIONS.md` — the 13 open decisions with exact file:line for each-- `README.md` — user-facing; install/CLI/architecture updated, YAML reference unchanged- (the scenario format is genuinely identical to Python's)diff --git a/LICENSE b/LICENSEindex d645695..b7d5953 100644--- a/LICENSE+++ b/LICENSE@@ -187,7 +187,7 @@same "printed page" as the copyright notice for easieridentification within third-party archives.- Copyright [yyyy] [name of copyright owner]+ Copyright 2026 aleksandar SkrbicLicensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.diff --git a/TUI_TESTING.md b/TUI_TESTING.mddeleted file mode 100644index ae10aa6..0000000--- a/TUI_TESTING.md+++ /dev/null@@ -1,134 +0,0 @@-# Manual test guide — redesigned live TUI--Step-by-step verification of every feature of the new `internal/tui` renderer.-Complements `RUNBOOK.md` §2 (whole-app test plan); this file covers the run screen.--## 0. Setup (once)--```bash-./scripts/check.sh -r # gofmt, vet, all tests under -race, build. No Docker needed.-go build -o khaos ./cmd/khaos-./khaos cluster-up # needs port 8080 free-```--## 1. The centrepiece, at demo size--Terminal ~120×38:--```bash-./khaos run traffic/high-throughput -d 20 -k-```--Look for:--- Header: `khaos · high-throughput`, a green `●` health dot, a green progress bar- filling left→right, `elapsed 0mNNs / 0m20s`.-- A rounded-border table (same look as `khaos list`): right-aligned, comma-formatted- `PRODUCED`/`CONSUMED` in green/yellow bold, `LAG` green (small numbers), `MSG/S`- settling near 2.0k/s per topic, `BYTES` growing.-- Dim nested group rows: `└─ orders-group-1 ×2` (×2 = consumers in the group).-- TOTAL bar: `N produced · 4.0k/s`, `N consumed · 4.0k/s`, `lag N`, `N.N MB · 1.4 MB/s`,- and a sparkline appearing after ~3 seconds, flat mid-height at steady rate.-- All rules and panes share one right edge with the table.--## 2. Quit keys--Start a run **without** `-d`; verify each of `q`, `Esc`, `Ctrl-C` stops it promptly with-the plain summary and no error line. Any other key must do nothing. (This is the defect-the Go rewrite exists to fix — an infinite run must always stop cleanly.)--## 3. Responsiveness--During a run, resize:--- ~80×24: padding tightens, MSG/S and BYTES yield before topic names truncate, TOTAL bar- compacts to `↑ N ↓ N` arrows, nothing wraps.-- Below ~96 cols with `--lag-poll` on: lag headers compact to `SELF` / `BROKER`.-- Short window (~15 rows) : the topic list cuts with a dim `… N more rows` note- (counts topics *and* group rows); header, TOTAL and `q quit` never scroll away.-- ~40 cols: still no wrapped lines.--## 4. Failure columns from config (the pop-in fix)--```bash-./khaos run testing/consumer-failures -d 20 -k-```--`FAILED` (magenta) and `DLQ` (blue) columns are present **from the very first frame**,-blank until the first simulated failure (blank-instead-of-zero, as in Python), then fill-in without any column shifting. Group rows show their own dim failed/DLQ counts.--## 5. Real broker lag--```bash-./khaos run traffic/consumer-lag -d 30 -k --lag-poll 2s-```--- Headers become `LAG(SELF)` / `LAG(BROKER)` — both from frame one.-- Broker cells start as dim `unknown` (never `0`), then fill with real per-group numbers.-- Lag above 100 turns red; this scenario grows lag, so watch green flip to red.-- TOTAL bar gains a `broker N` segment summing only measured topics.--## 6. Events pane + incidents--```bash-./khaos run chaos/all-incidents -d 60 -k-```--`EVENTS ────` section: dim timestamps; alerts red, warnings yellow, recoveries green,-info dim. During broker stops the health dot flips to `● degraded`, and errors /-rebalances appear on the TOTAL bar. Long or multi-line event messages stay on one line-(newlines collapse to ` · `, then cell-truncate).--## 7. Flows table--```bash-./khaos run flows/order-flow -d 20 -k-```--Second bordered table `FLOW | STARTED | COMPLETED | MSGS | INFLIGHT | ERRORS`, same-style and width as the topic table; yellow `saturated xN` next to the flow name if the-instance pool saturates; many flows cut with `… N more flows`.--## 8. Hidden-counter issues line--```bash-./khaos run testing/duplicate-messages -d 15 -k-```--Under the TOTAL bar a line appears only when non-zero, e.g. `12 duplicates` (also-produce/consume/commit errors when they occur). Absent on a clean run.--## 9. Headless and piping--```bash-./khaos run traffic/high-throughput -d 10 -k --tui off # structured logs, one progress line / 10s-./khaos run traffic/high-throughput -d 8 -k | cat # plain text, ZERO escape codes-NO_COLOR=1 ./khaos list # uncoloured table-```--## 10. One-product check--Run `./khaos list` and `./khaos cluster-status` next to a live run: same rounded border,-same grey frame, same palette (cyan names, green ok, magenta headings) everywhere.--## 11. Shutdown drain--End of any `-d` run: header shows yellow `shutting down`, lag briefly turns red while-consumers drain, then the plain summary prints.--## 12. Demo gif--Already re-recorded at `assets/demo.gif`. To redo:--```bash-cd scripts && PATH=$PWD/..:$PATH vhs demo.tape && mv demo.gif ../assets/-```--(Needs the cluster up; the tape ends with `khaos cluster-down`.)-------Automated coverage for all of the above: `go test ./internal/tui/ -v` — config gates,-`unknown`, the 100 threshold, blank-on-zero, purity, quit keys, width/height bounds,-multi-line events, flow bounding, header priority, and derived-column stability.