File size: 3,192 Bytes
3436bdd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env bash
set -euo pipefail

ROOT="$(cd "$(dirname "$0")/.." && pwd)"
MODE="${1:-resume}"
REGISTRY_PATH="$ROOT/build/system/product_candidate_registry.json"
GOVERNANCE_PATH="$ROOT/build/system/user_governance.json"
CONTINUITY_RESUME_SCRIPT="$ROOT/scripts/render_continuity_flow.sh"

latest_benchmark_summary() {
  find "$ROOT/runs/benchmark" -path '*/summary.json' -type f 2>/dev/null | sort | tail -n 1
}

if [ ! -f "$REGISTRY_PATH" ]; then
  echo "product candidate registry missing: $REGISTRY_PATH" >&2
  exit 1
fi

REGISTRY_JSON="$(cat "$REGISTRY_PATH")"
GOVERNANCE_JSON='{}'
if [ -f "$GOVERNANCE_PATH" ]; then
  GOVERNANCE_JSON="$(cat "$GOVERNANCE_PATH")"
fi

BENCHMARK_PATH="$(latest_benchmark_summary)"
if [ -n "$BENCHMARK_PATH" ] && [ -f "$BENCHMARK_PATH" ]; then
  BENCHMARK_JSON="$(cat "$BENCHMARK_PATH")"
else
  BENCHMARK_JSON='{"aggregate":{},"stability":{}}'
fi

CONTINUITY_JSON='{}'
if [ -x "$CONTINUITY_RESUME_SCRIPT" ]; then
  CONTINUITY_JSON="$("$CONTINUITY_RESUME_SCRIPT" 2>/dev/null || printf '{}')"
fi

jq -n \
  --arg mode "$MODE" \
  --arg registry_path "$REGISTRY_PATH" \
  --arg governance_path "$GOVERNANCE_PATH" \
  --arg benchmark_path "$BENCHMARK_PATH" \
  --argjson registry "$REGISTRY_JSON" \
  --argjson governance "$GOVERNANCE_JSON" \
  --argjson benchmark "$BENCHMARK_JSON" \
  --argjson continuity "$CONTINUITY_JSON" \
  '{
    route:{
      lane:"tooling",
      objective:"manage product delivery through candidate registry, continuity state, and benchmark gates",
      mode:$mode,
      top_candidate_id:($registry.top_candidate_id // null)
    },
    context:{
      product_candidates:($registry.candidates[0:3] // []),
      live_continuity_version:($continuity.route.continuity_version_id // null),
      active_surface:($continuity.context.active_surface // null),
      benchmark:{
        avg_latency_ms:($benchmark.aggregate.avg_latency_ms // null),
        continuity_provider_accuracy:($benchmark.aggregate.continuity_provider_accuracy // null),
        freshness_override_accuracy:($benchmark.aggregate.freshness_override_accuracy // null),
        unsupported_query_abstention_rate:($benchmark.aggregate.unsupported_query_abstention_rate // null)
      }
    },
    action:{
      next_step:(
        if $mode == "verify" then "run benchmark gate and compare delivery metrics"
        elif $mode == "products" then "inspect the candidate registry and choose one bounded slice"
        else "resume delivery from the top candidate and active continuity surface"
        end
      ),
      recommended_candidate:($registry.candidates[0] // null),
      recommended_commands:(
        if $mode == "verify" then
          ["./bin/bvtctl benchmark"]
        elif $mode == "products" then
          ["./bin/bvtctl pm-products","./bin/bvtctl pm-next"]
        else
          ["./bin/bvtctl continuity-resume","./bin/bvtctl pm-next","./bin/bvtctl pm-verify"]
        end
      )
    },
    receipt:{
      governance_source:$governance_path,
      candidate_registry_path:$registry_path,
      benchmark_summary_path:(if $benchmark_path == "" then null else $benchmark_path end),
      promotion_gate:"receipts + benchmark pass"
    }
  }'