Skip to content

Commit ec2e005

Browse files
GottZclaude
andcommitted
fix(test): T07 Admin-Key + Mig-118-Zählstand, T19 excluded-Typen generisch
Zwei belegte Defekte aus dem test.sh-Lauf 2026-07-25T12:21Z (post-deploy, v4.19.0 / Mig 108–118): [FAIL] T07 SCHEMA_INTEGRITY -- Zähl-Fallback (Prä-Deploy, Exit 3/Transport-Auth-Fehler): expected 46 tables + 40 columns, got tables=50 columns=41 [FAIL] T19 GRAPH_EGO -- payload check: success!=true;nodes=0;edges=0; stats.truncated missing T07: der `ctx contract`-Aufruf lief ohne Key-Override, die CLI zog damit den Private-Key aus ~/.config/ctx/config. /api/contract ist admin-gated → HTTP 403 → Exit 3 → stiller Abstieg in den Zähl-Fallback, der seinerseits auf dem Prä-Deploy-Stand (46/40, Mig 107) festhing. Fix: Aufruf mit CTX_KEY="$CTX_ADMIN_KEY" (Env schlägt Datei, internal/cli.LoadConfig; CTX_BASE_URL bleibt aus der Datei), und die Fallback-Erwartung auf den Ist-Stand 50 Tabellen / 41 Spalten gehoben — als benannte Konstanten T07_EXPECT_TABLES/T07_EXPECT_COLUMNS, mit Kommentar, dass die Zahlen an Migration 118 hängen und bei Schema-Migrationen nachzuziehen sind. T19: die Fokus-Block-Auswahl (höchster Grad in context_dream_links) schloss nur den Hardcode-Typ 'system-meta' aus. Seit M107 existiert der Typ 'checkpoint' mit retrieval-Policy 'excluded', und der aktuelle Top-Grad- Block war genau so einer → /api/graph/ego antwortet 404, alle vier Assertions fielen. Fix: LEFT JOIN auf context_block_types (scope='_global', Join-Schlüssel context_blocks.type_name) und Filter config->'retrieval'->>'policy' IS DISTINCT FROM 'excluded' — generisch statt Hardcode-Liste; LEFT JOIN, damit Blöcke ohne Registry-Zeile drinbleiben. Verifikation (Einzel-Proben gegen das Live-System, kein voller Lauf): - T07 Primärpfad: Exit 0, "Schema Contract: ok (mode=warn source=default) … manifest_max=118 live_max=118 excluded_snapshot_tables=4 … no drift findings" - T07 Zähl-Fallback: tables=50, columns=41 gegen die neuen Konstanten → OK - T19 Fokus-SQL: 019e9adf-f21c-7ac5-bfcc-bdb0c15bd0f6, type_name= audit-trail (Policy damped) statt vorher checkpoint; GET /api/graph/ego → HTTP 200, "OK 242 nodes 563 edges"; 404-Gleichheit: invisible=404 missing=404 bodies_equal=yes Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 137ca74 commit ec2e005

1 file changed

Lines changed: 26 additions & 5 deletions

File tree

test.sh

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,28 +256,41 @@ fi
256256
#
257257
# Fallback (KEINE Gate-Abschwächung): solange die installierte CLI älter
258258
# als W03-4 ist ("contract" unbekannt) oder Transport/Auth fehlschlägt,
259-
# fällt T07 auf exakt die alte Zähl-Probe zurück (46 Tabellen / 40 Spalten
259+
# fällt T07 auf exakt die alte Zähl-Probe zurück (50 Tabellen / 41 Spalten
260260
# context_blocks) — dieselbe Prüfstärke wie vor dieser Welle, nicht
261261
# schwächer. Das Upgrade auf den generierten Contract greift automatisch,
262262
# sobald die deployte CLI "contract" kennt — kein Script-Change nötig.
263+
#
264+
# ⚠ Die Fallback-Zahlen sind handgepflegt und hängen am Migrations-Stand:
265+
# 50/41 gilt ab Migration 118 (vorher 46/40, Stand Mig 107). Bei neuen
266+
# Migrationen mit Tabellen-/Spalten-Änderung müssen sie hier nachgezogen
267+
# werden — der `ctx contract`-Pfad oben braucht das nicht.
263268
T="T07 SCHEMA_INTEGRITY"
264269

270+
# Zähl-Fallback-Erwartung, an Migration 118 gebunden (siehe Kommentar oben).
271+
T07_EXPECT_TABLES=50
272+
T07_EXPECT_COLUMNS=41
273+
265274
t07_count_fallback() {
266275
local reason="$1"
267276
local tc col
268277
tc=$($DB_CMD -c "SELECT count(*) FROM information_schema.tables WHERE table_schema='public' AND table_name NOT LIKE '%_snapshot_%';" 2>/dev/null | tr -d '[:space:]')
269278
col=$($DB_CMD -c "SELECT count(*) FROM information_schema.columns WHERE table_name='context_blocks';" 2>/dev/null | tr -d '[:space:]')
270-
if [[ "$tc" == "46" ]] && [[ "$col" == "40" ]]; then
279+
if [[ "$tc" == "$T07_EXPECT_TABLES" ]] && [[ "$col" == "$T07_EXPECT_COLUMNS" ]]; then
271280
pass "$T (contract-CLI nicht verfügbar — Zähl-Fallback (Prä-Deploy); tables=$tc, columns=$col; $reason)"
272281
else
273-
fail "$T" "Zähl-Fallback (Prä-Deploy, $reason): expected 46 tables + 40 columns, got tables=$tc columns=$col"
282+
fail "$T" "Zähl-Fallback (Prä-Deploy, $reason): expected $T07_EXPECT_TABLES tables + $T07_EXPECT_COLUMNS columns (Stand Mig 118), got tables=$tc columns=$col"
274283
fi
275284
}
276285

277286
# set -e-sicher: der if/else fängt den Exit-Code ab, BEVOR eine Pipe/Zuweisung
278287
# ihn verschlucken könnte (Projekt-Quirk "EXIT nach Pipe misst die Pipe";
279288
# dasselbe Muster wie state.sh's Contract-Zeile, W03-5).
280-
if t07_out=$(ctx contract 2>&1); then
289+
# CTX_KEY-Override: die CLI zieht ihren Key sonst aus ~/.config/ctx/config
290+
# (Private-Key) — /api/contract ist admin-gated, das gäbe HTTP 403 → Exit 3 →
291+
# stiller Abstieg in den Zähl-Fallback. Env schlägt Datei (internal/cli:
292+
# LoadConfig, ENV > ~/.config/ctx/config); CTX_BASE_URL bleibt aus der Datei.
293+
if t07_out=$(CTX_KEY="${CTX_ADMIN_KEY:-}" ctx contract 2>&1); then
281294
t07_rc=0
282295
else
283296
t07_rc=$?
@@ -368,9 +381,17 @@ fi
368381
T="T19 GRAPH_EGO"
369382
# Focus: the highest-degree non-archived private/shared block (visible to
370383
# KEY_PRIVATE, guaranteed >= 1 edge so the edge-count assertion is meaningful).
384+
# Typen mit retrieval-Policy 'excluded' scheiden generisch aus — /api/graph/ego
385+
# antwortet für sie 404. Kein Hardcode mehr ('system-meta' war die Liste bis
386+
# M107 den Typ 'checkpoint' einführte, der prompt den Top-Grad-Block stellte):
387+
# der JOIN liest die Policy aus der Registry. context_block_types ist
388+
# scope-qualifiziert (name+scope unique); '_global' ist die Basis-Ebene, die
389+
# jeder Tenant erbt. LEFT JOIN, damit Blöcke ohne Registry-Zeile drinbleiben.
371390
t19_focus=$($DB_CMD -c "SELECT b.id FROM context_blocks b
372391
JOIN context_dream_links l ON l.source_block_id = b.id OR l.target_block_id = b.id
373-
WHERE NOT b.is_archived AND b.type_name <> 'system-meta' AND b.scope IN ('private','shared')
392+
LEFT JOIN context_block_types t ON t.name = b.type_name AND t.scope = '_global'
393+
WHERE NOT b.is_archived AND b.scope IN ('private','shared')
394+
AND t.config->'retrieval'->>'policy' IS DISTINCT FROM 'excluded'
374395
GROUP BY b.id ORDER BY count(*) DESC LIMIT 1;" 2>/dev/null | tr -d '[:space:]')
375396
if [[ -z "$t19_focus" ]]; then
376397
fail "$T" "no linked block found to use as focus"

0 commit comments

Comments
 (0)