Skara Brae — Quality Check Procedure

# Skara Brae — Quality Check Procedure

## Purpose

Systematic verification that the implementation matches design notes, passes all code checks, and follows Clean Code / Clean Architecture principles.

## Procedure

### Step 1: Code Checks

```bash
# Rust build + clippy
cd ~/Development/skara-brae/skara-brae-server && cargo clippy -- -W clippy::all 2>&1

# Rust tests
cd ~/Development/skara-brae/skara-brae-server && cargo test 2>&1

# Vue typecheck
cd ~/Development/skara-brae/skara-brae-client && npx vue-tsc --noEmit 2>&1
```

### Step 2: Implementation vs Design Notes

For each design note, verify the implementation matches:

| Note | ID | What to Check |
|---|---|---|
| Game Concept Overview | `fcd381c235694f29abf73665317a40f5` | Character system (races, classes, stats), economy model, adventure structure |
| Combat System & Stat Scaling | `5ff1fed180fa4b39b4cdb925f34c1008` | BIGINT stats, open-ended d100, crit tables, crit caps by level diff |
| Mechanics Source Mapping | `81ac5941f07d4cdcb41a4797c7ec1c99` | BT1/RM/IF/Torn mapping consistency |
| Project Plan | `088737f31c514f1da21cc42c0ab6acc1` | Resolved inconsistencies, next priorities |
| Tech Stack & Architecture | `980c3eb587294e4383474b94988f2f88` | Crate structure, dependency direction, deployment |
| Skill & Magic System | `8bee50c2a9194ec491612ace0bd40fe4` | Spell system design vs implementation |
| Medals & Honours | `e368348dd9c341f59fe55594a0fbca96` | Medal system (not yet implemented) |
| Idle Fantasy Inspirations | `fea2d81f0414484fa4edf126f8ca17ed` | Features adopted from IF |

Check items:
- [x] Stats are i64 (BIGINT) — not i32
- [x] 5 races match design (Human, Elf, Dwarf, Hobbit, HalfElf)
- [x] 10 classes match design (Warrior through Sorcerer, no Cleric)
- [x] Crit damage cap by level difference implemented
- [x] Open-ended d100 combat rolls
- [x] BT1 items (127), enemies (125), spells (79), songs (6) all present
- [x] Zones match BT1 dungeon structure (8 zones)
- [x] Shop economy uses BT1 gold values
- [x] Bard songs with combat integration
- [x] Spell system with SP costs, learning, combat casting
- [x] Training costs gold (not just energy)
- [x] Review Board level-up: XP threshold polynomial (18×100×(level-1)²), gold cost, max level 100

### Step 3: Clean Architecture Audit

Check dependency direction:
- [x] `sb-shared` → no dependencies on other game crates (domain types only)
- [x] `sb-core` → depends only on `sb-shared` + `sb-common` (domain services, no HTTP)
- [x] `sb-api` → depends on `sb-core`, `sb-shared`, `sb-auth`, `sb-db` (HTTP adapters)

Check layer violations:
- [x] No `serde_json` in domain logic (only in LazyLock data loaders)
- [x] No `include_str!` called during business logic (only module-level const)
- [ ] No `rand::rng()` in domain functions (2 violations: create_character, resolve_combat_full)
- [ ] Route handlers delegate to domain services (14 handlers still have inline logic)

Check code quality:
- [ ] No magic numbers (25+ remaining in combat/character code)
- [x] No abbreviations in variable names
- [x] Functions do one thing, are short
- [x] No duplicated logic across modules
- [x] No comments that restate code
- [x] Fail fast, return early — happy path flat
- [x] No mixed concerns (HTTP + business logic in same function)

### Step 4: Bug Scan

- [x] All gold/energy/nerve/SP costs are both displayed AND enforced
- [x] All state mutations happen inside write locks
- [x] No unwrap() on fallible operations in route handlers (11 low-risk remain)
- [x] All enum match arms exhaustive
- [x] No integer overflow paths (xp_for_level uses saturating arithmetic)

## Audit History

| Date | Clippy | Tests | vue-tsc | Criticals Found | Criticals Fixed |
|---|---|---|---|---|---|
| 2026-08-03 #1 | 18 warnings | 0 tests | clean | 3 | 3 |
| 2026-08-03 #2 | 0 | 42 pass | clean | 4 | 4 |
| 2026-08-03 #3 | 0 | 44 pass | clean | 1 | 1 |

## Quality Gate

A check passes when:
- Zero clippy warnings (excluding allowed lints)
- Zero typecheck errors
- All tests pass
- Zero critical architecture violations
- All tracked inconsistencies have a ticket or accepted rationale

id: 837e81dd86d04905aa6de44f33cf21f4
parent_id: d1892c7c531848f5a5a3ac5e1749f7cf
created_time: 2026-08-03T05:05:16.986Z
updated_time: 2026-08-03T10:20:47.020Z
is_conflict: 0
latitude: 0.00000000
longitude: 0.00000000
altitude: 0.0000
author: 
source_url: 
is_todo: 0
todo_due: 0
todo_completed: 0
source: joplin-desktop
source_application: net.cozic.joplin-desktop
application_data: 
order: 1785733516986
user_created_time: 2026-08-03T05:05:16.986Z
user_updated_time: 2026-08-03T10:20:47.020Z
encryption_cipher_text: 
encryption_applied: 0
markup_language: 1
is_shared: 0
share_id: 
conflict_original_id: 
master_key_id: 
user_data: 
deleted_time: 0
is_locked: 0
extracted_resource_ids: 
type_: 1