|
1 | 1 | # Bering |
2 | | -First Model Discovery tool |
| 2 | + |
| 3 | +Bering is the upstream model discovery tool for Sheaft. |
| 4 | +It consumes trace artifacts and produces canonical `bering-model.json` in |
| 5 | +`BeringResilienceModel` v1.0.0 contract format. |
| 6 | + |
| 7 | +## Contract (strict) |
| 8 | + |
| 9 | +Bering pins `metadata.schema` exactly: |
| 10 | + |
| 11 | +- `name`: `io.mb3r.bering.model` |
| 12 | +- `version`: `1.0.0` |
| 13 | +- `uri`: `https://schemas.mb3r.dev/bering/model/v1.0.0/model.schema.json` |
| 14 | +- `digest`: `sha256:7dc733936a9d3f94ab92f46a30d4c8d0f5c05d60670c4247786c59a3fe7630f7` |
| 15 | + |
| 16 | +Any mismatch fails validation. |
| 17 | + |
| 18 | +## Repository layout |
| 19 | + |
| 20 | +```text |
| 21 | +cmd/bering CLI entrypoint |
| 22 | +internal/app command wiring |
| 23 | +internal/connectors/traces trace file/dir loading and normalization |
| 24 | +internal/discovery model inference from normalized spans |
| 25 | +internal/model model structs, semantic checks, canonical IO |
| 26 | +internal/schema pinned contract constants + JSON Schema validation |
| 27 | +internal/jsoncanon deterministic recursive JSON encoder |
| 28 | +api/schema canonical public schema |
| 29 | +configs sample configs (replicas override) |
| 30 | +examples trace fixtures + expected output artifacts |
| 31 | +docs format, heuristic, and MVP limits |
| 32 | +scripts/ci CI helper scripts |
| 33 | +``` |
| 34 | + |
| 35 | +## Commands |
| 36 | + |
| 37 | +```bash |
| 38 | +bering discover --input <trace-file|dir> [--out bering-model.json] [--replicas replicas.yaml|json] [--discovered-at RFC3339] |
| 39 | +bering validate --input <bering-model.json> |
| 40 | +``` |
| 41 | + |
| 42 | +## Quickstart |
| 43 | + |
| 44 | +### 1) Discover from traces |
| 45 | + |
| 46 | +```bash |
| 47 | +go run ./cmd/bering discover \ |
| 48 | + --input examples/traces/normalized.sample.json \ |
| 49 | + --out examples/outputs/bering-model.normalized.sample.json \ |
| 50 | + --discovered-at 2026-03-03T00:00:00Z |
| 51 | +``` |
| 52 | + |
| 53 | +### 2) Validate artifact |
| 54 | + |
| 55 | +```bash |
| 56 | +go run ./cmd/bering validate \ |
| 57 | + --input examples/outputs/bering-model.normalized.sample.json |
| 58 | +``` |
| 59 | + |
| 60 | +### 3) Run Sheaft manually on generated model |
| 61 | + |
| 62 | +```bash |
| 63 | +# from sibling Sheaft repository |
| 64 | +go run ./cmd/sheaft run \ |
| 65 | + --model ../Bering/examples/outputs/bering-model.normalized.sample.json \ |
| 66 | + --policy configs/gate.policy.example.yaml \ |
| 67 | + --out-dir out \ |
| 68 | + --seed 42 |
| 69 | +``` |
| 70 | + |
| 71 | +## Deterministic output |
| 72 | + |
| 73 | +Bering output is deterministic for identical inputs and flags: |
| 74 | + |
| 75 | +- services sorted by `id` |
| 76 | +- edges sorted by `(from,to,kind,blocking)` |
| 77 | +- endpoints sorted by `id` |
| 78 | +- stable IDs for services/edges/endpoints |
| 79 | +- canonical JSON writer with recursive object-key ordering (future-safe for map fields) |
| 80 | +- optional `--discovered-at` for reproducible timestamps |
| 81 | + |
| 82 | +## Supported trace formats (MVP) |
| 83 | + |
| 84 | +- Normalized JSON: `{"spans": [...]}` payload with canonical span fields. |
| 85 | +- Raw OTel JSON: `resourceSpans/scopeSpans/spans` payload. |
| 86 | + |
| 87 | +Details: [docs/trace-input-format.md](docs/trace-input-format.md) |
| 88 | + |
| 89 | +## CI and local checks |
| 90 | + |
| 91 | +```bash |
| 92 | +make lint |
| 93 | +make test |
| 94 | +make build |
| 95 | +``` |
| 96 | + |
| 97 | +## License |
| 98 | + |
| 99 | +MIT (see [LICENSE](LICENSE)). |
0 commit comments