From 07a22d305d8aaaebb512586663438877d86dbbe2 Mon Sep 17 00:00:00 2001 From: dimgigov Date: Sun, 17 May 2026 03:47:17 +0300 Subject: [PATCH] chore: fix all build warnings and add stabilization roadmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix 3× ResultShadowed in cypher.nim, recovery.nim, shell.nim - Remove 6× UnusedImport in test files - Build is now clean: 0 warnings, 294 tests pass - Add 4-week stabilization plan to PLAN.md (Sessions 9.1–9.4) --- PLAN.md | 79 +++++++++++++++++++++++++++++++ src/barabadb/cli/shell.nim | 6 +-- src/barabadb/graph/cypher.nim | 1 - src/barabadb/storage/recovery.nim | 10 ++-- tests/join_tests.nim | 3 -- tests/test_all.nim | 2 - tests/tla_faithfulness.nim | 1 - 7 files changed, 87 insertions(+), 15 deletions(-) diff --git a/PLAN.md b/PLAN.md index 8408d43..c8bc059 100644 --- a/PLAN.md +++ b/PLAN.md @@ -123,3 +123,82 @@ **BaraDB v1.0.0 е production-ready за blogs, e-commerce и small ERP системи.** **Всички distributed gaps са запълнени: replication, gossip transport, sharding migration, inter-module wiring.** + +--- + +## 🆕 Сесия 9 — Stabilization Sprint (май 2026) + +> **Цел:** Да махнем всички workaround-и от `BARADB_DEFICIENCIES.md`, да почистим build-а и да подготвим почвата за типова система. +> **Принцип:** Без нови светове — само stabilizaция на съществуващото. + +### Седмица 1: Deficiency Hunt + Build Cleanup + +| # | Задача | Оценка | Статус | +|---|--------|--------|--------| +| 9.1.1 | Почистване на 9-те build warnings (ResultShadowed + UnusedImport) | 1ч | 🔄 | +| 9.1.2 | Issue #6: Aggregate column names (`count(*)` → `count(*)`, `max(id)` → `max(id)`) | 2ч | 🔄 | +| 9.1.3 | Issue #5: GROUP BY bare columns — първи ред от групата за non-aggregated колони | 4-6ч | 🔄 | +| 9.1.4 | Issue #7+8: Решение за async vs sync client + thread safety | 2ч | 🔄 | +| 9.1.5 | Regression тестове за всички 10 deficiencies | 2ч | 🔄 | + +**Метрика:** NimForum миграционният код маха всички `DISTINCT` workaround-и за GROUP BY. + +--- + +### Седмица 2: Type Safety in Execution Layer + +| # | Задача | Оценка | Статус | +|---|--------|--------|--------| +| 9.2.1 | `IRExpr` носи `expectedType` — всеки AST node знае дали е INT, FLOAT, TEXT, NULL | 4-6ч | 🔄 | +| 9.2.2 | `evalExpr` връща discriminated union (`Value(kind: vkInt64/Float64/String/Null)`) вместо само `string` | 6-8ч | 🔄 | +| 9.2.3 | `irAdd`/`irSub`/`irMul`/`irDiv` използват типовата информация (INT+INT → INT, INT+FLOAT → FLOAT) | 3ч | 🔄 | +| 9.2.4 | `validateType` използва `Value.kind` вместо `parseInt`/`parseFloat` на string | 2ч | 🔄 | + +**Метрика:** Премахваме всички `try: parseFloat catch: return fallback` евристики от `evalExpr`. + +--- + +### Седмица 3: JOIN Performance + +| # | Задача | Оценка | Статус | +|---|--------|--------|--------| +| 9.3.1 | Hash Join: `ON a.col = b.col` с hash table върху по-малката страна | 6ч | 🔄 | +| 9.3.2 | Index Nested Loop Join: ако има B-Tree индекс на join колоната | 4ч | 🔄 | +| 9.3.3 | Benchmark: `thread JOIN category` с 10K/100K/1M редове | 2ч | 🔄 | +| 9.3.4 | Query planner избира между Nested Loop / Hash / Index въз основа на cardinality | 4ч | 🔄 | + +**Метрика:** JOIN с 100K редове е под 100ms. + +--- + +### Седмица 4: Production Hardening + +| # | Задача | Оценка | Статус | +|---|--------|--------|--------| +| 9.4.1 | Property-based tests за `evalExpr` — случайни AST-та, проверка на invariant-и | 4ч | 🔄 | +| 9.4.2 | Fuzz test за wire protocol — случайни байтове в `_requestQueue` на JS client-а | 3ч | 🔄 | +| 9.4.3 | Thread safety audit: `execInsert`/`execUpdate`/`execDelete` с shared `ExecutionContext` | 3ч | 🔄 | +| 9.4.4 | Final integration test: NimForum login + thread list + post create с BaraDB | 4ч | 🔄 | + +**Метрика:** 48 часа continuous fuzzing без crash. NimForum smoke test минава end-to-end. + +--- + +### Рискове и митигации + +| Риск | Митигация | +|------|-----------| +| GROUP BY bare columns е по-сложен от очакваното | Fallback: SQLite behavior (първи ред), не PostgreSQL (грешка) | +| Type safety рефакторингът чупи 294 теста | Правим го на отделен branch, не в `main` | +| Hash Join изисква памет proportional на N | Добавяме `work_mem` лимит като PostgreSQL | + +--- + +### Текущи метрики (преди сесия 9) + +| Метрика | Стойност | +|---------|----------| +| **Тестове** | 294 — 0 failures | +| **Build warnings** | 9 (3× ResultShadowed + 6× UnusedImport) | +| **BARADB_DEFICIENCIES** | 4 непоправени (#5, #6, #7, #8) | +| **Workaround-и в NimForum** | 2 (GROUP BY → DISTINCT, aggregate positional access) | diff --git a/src/barabadb/cli/shell.nim b/src/barabadb/cli/shell.nim index 3843538..faa4729 100644 --- a/src/barabadb/cli/shell.nim +++ b/src/barabadb/cli/shell.nim @@ -164,10 +164,10 @@ proc processCommand*(state: var CliState, input: string): string = of "history", "\\history": if state.history.len == 0: return "(no history)" - var result = "" + var res = "" for i, h in state.history: - result &= " " & $(i + 1) & ": " & h & "\n" - return result + res &= " " & $(i + 1) & ": " & h & "\n" + return res of "verbose": state.verbose = not state.verbose return "Verbose mode: " & (if state.verbose: "ON" else: "OFF") diff --git a/src/barabadb/graph/cypher.nim b/src/barabadb/graph/cypher.nim index 92b89c3..94a20b2 100644 --- a/src/barabadb/graph/cypher.nim +++ b/src/barabadb/graph/cypher.nim @@ -212,7 +212,6 @@ proc executeCypher*(g: Graph, query: CypherQuery): CypherResult = proc toCypher*(query: string): string = ## Convert basic BaraQL to Cypher-like syntax for graph queries - var result = "" let upper = query.toUpper() if upper.startsWith("SELECT") and upper.contains("MATCH"): # Already Cypher-like diff --git a/src/barabadb/storage/recovery.nim b/src/barabadb/storage/recovery.nim index 3353fd0..e74950b 100644 --- a/src/barabadb/storage/recovery.nim +++ b/src/barabadb/storage/recovery.nim @@ -136,19 +136,19 @@ proc analyze*(rec: CrashRecovery): RecoveryResult = return rec.result proc recover*(rec: CrashRecovery, db: LSMTree = nil): RecoveryResult = - let result = rec.analyze() + let analysis = rec.analyze() - if not result.applied: - return result + if not analysis.applied: + return analysis if db == nil: - return result + return analysis # REDO: apply committed entries (txnId < lastCommitted) to LSM-Tree var redoCount = 0 var undoCount = 0 for entry in rec.entries: - if entry.txnId < result.lastTxn: + if entry.txnId < analysis.lastTxn: # Committed — redo if entry.isDelete: db.delete(entry.key) diff --git a/tests/join_tests.nim b/tests/join_tests.nim index 0e603d2..f0c7972 100644 --- a/tests/join_tests.nim +++ b/tests/join_tests.nim @@ -1,13 +1,10 @@ import std/unittest import std/os import std/strutils -import std/times import std/monotimes import std/tables -import barabadb/core/types import barabadb/query/executor as qexec import barabadb/query/parser -import barabadb/query/ast import barabadb/storage/lsm proc execSql(ctx: qexec.ExecutionContext, sql: string): qexec.ExecResult = diff --git a/tests/test_all.nim b/tests/test_all.nim index 81c7f6d..0c035d4 100644 --- a/tests/test_all.nim +++ b/tests/test_all.nim @@ -4,8 +4,6 @@ import std/tables import std/strutils import std/os import std/asyncdispatch -import std/times -import std/random import std/monotimes import std/base64 diff --git a/tests/tla_faithfulness.nim b/tests/tla_faithfulness.nim index 44b6a46..e19fe2f 100644 --- a/tests/tla_faithfulness.nim +++ b/tests/tla_faithfulness.nim @@ -4,7 +4,6 @@ import std/unittest import std/tables -import std/sets import std/sequtils import std/strformat