File size: 10,013 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
#!/usr/bin/env bash
set -euo pipefail

ROOT="$(cd "$(dirname "$0")/.." && pwd)"
CMD="${1:-help}"
shift || true

print_help() {
  cat <<'EOF'
bvtctl - one conversational control CLI

Primary path:
  bvtctl "summarise the current runtime"
  bvtctl ask "run the demo manifest" runtime/examples/demo_manifest.json
  bvtctl chat

Operator commands:
  bvtctl bootstrap
    Build the bootstrap hotgraph from the source registry.

  bvtctl run [usecase] [goal]
    Run bootstrap + bounded packet generation in one pass.

  bvtctl compile
    Compile the canonical system file into the live API, runtime, control, and inference surfaces.

  bvtctl governance
    Show the compiled user-governed next moves from data_prep reduction surfaces.

  bvtctl continuity-status
    Show the primary continuity runtime state from the live NextGen provider, with local fallback only if needed.

  bvtctl continuity-lineage [version_id]
    Show the continuity lineage packet from the provider-first continuity surface.

  bvtctl continuity-surfaces
    Show the materialized continuity surfaces from the provider-first continuity surface.

  bvtctl continuity-flow [version_id]
    Collapse continuity status, lineage, and activation guidance into one operator packet.

  bvtctl continuity-resume [version_id]
    Return the continuity desk packet for the current live version, optimized for resume and next action.

  bvtctl pm-products
    Show the product candidate registry compiled from reduced user-data governance.

  bvtctl pm-resume
    Return the PM operator desk packet.

  bvtctl pm-next
    Return the PM operator packet focused on the next bounded delivery move.

  bvtctl pm-verify
    Run the PM verification path through the benchmark gate.

  bvtctl memory-readiness
    Show the compiled deterministic-memory readiness read for exact lookup, hologram retrieval, and typed ledger gaps.

  bvtctl memory-runtime
    Show the compiled typed memory runtime artifact.

  bvtctl memory-get <unit_id>
    Deterministically retrieve one typed memory unit by exact id.

  bvtctl memory-as-of <unit_id_or_logical_id> <timestamp>
    Deterministically retrieve the typed memory unit that was effective at a given time.

  bvtctl memory-expand <unit_id>
    Expand one typed memory unit through its deterministic relation edges.

  bvtctl continuity-activate <surface_id> [version_id]
    Activate one continuity surface through the live provider.

  bvtctl continuity-materialize [manifest]
    Instantiate the continuity runtime through the live provider, with local materialization only as fallback.

  bvtctl continuity-materialize-local [manifest]
    Materialize the local fallback continuity slice through the existing runtime and receipts.

  bvtctl execute [manifest]
    Run one bounded local work manifest and emit a receipt.

  bvtctl benchmark
    Run the standalone control benchmark.

  bvtctl corpus-packets
    Build the pilot corpus reasoning packets for the golden abstractions.

  bvtctl self-improve "<goal>"
    Propose one bounded repo improvement through Codex CLI.

  bvtctl self-improve-apply "<goal>"
    Propose, apply, and benchmark one bounded repo improvement.

Inspect surfaces:
  bvtctl packet [usecase] [goal]
  bvtctl policy
  bvtctl scorecard
  bvtctl runtime
  bvtctl api
  bvtctl inference
  bvtctl context
  bvtctl bootstrap-context
  bvtctl ux
  bvtctl kernel-plan

Why:
  the default front door is conversation; the other commands are explicit operator tools.
EOF
}

render_turn_response() {
  local response_path="$1"
  jq -r '
    [
      "Answer: " + .answer_text,
      "Lane: " + .lane,
      "Frontier: " + .tensor_surface.frontier_read,
      "Execution gate: " + (if .execution_gate.allowed then "open" else "closed" end),
      (if .inference.backend == null then empty else "Inference backend: " + .inference.backend.id + " (" + .inference.backend.model + ")" end),
      "System entry: " + .system_context.current_position.slice_id,
      "Profile: " + .system_context.current_position.default_profile,
      "Decision: " + .decision_brief,
      (if .receipt_path == null then empty else "Receipt: " + .receipt_path end),
      (if .runtime_summary == null then empty else "Runtime summary: " + .runtime_summary end),
      "Response packet: " + $response_path
    ] | .[]
  ' --arg response_path "$response_path" "$response_path"
}

run_turn() {
  local user_input="$1"
  local manifest_path="${2:-}"
  local response_path
  response_path="$("$ROOT/api/run_turn.sh" "$user_input" "$manifest_path")"
  render_turn_response "$response_path"
}

run_chat() {
  local manifest_path="${1:-}"
  local prompt="bvtctl> "
  local user_input=""

  cat <<EOF
bvtctl chat - conversational control loop
Type 'exit' or 'quit' to leave.
EOF

  while true; do
    printf '%s' "$prompt"
    if ! IFS= read -r user_input; then
      printf '\n'
      break
    fi
    case "$user_input" in
      "" )
        continue
        ;;
      exit|quit)
        break
        ;;
      *)
        run_turn "$user_input" "$manifest_path"
        printf '\n'
        ;;
    esac
  done
}

case "$CMD" in
  bootstrap)
    "$ROOT/scripts/build_hotgraph.sh"
    ;;
  packet)
    USECASE="${1:-migration_brief}"
    GOAL="${2:-}"
    "$ROOT/scripts/generate_control_packet.sh" "$USECASE" "$GOAL"
    ;;
  run)
    USECASE="${1:-migration_brief}"
    GOAL="${2:-}"
    "$ROOT/scripts/run_v0.sh" "$USECASE" "$GOAL"
    ;;
  compile)
    "$ROOT/scripts/compile_system.sh" "${1:-$ROOT/canon/system.yml}"
    ;;
  governance)
    python3 "$ROOT/scripts/compile_user_governance.py"
    ;;
  continuity-status)
    "$ROOT/scripts/continuity_provider.sh" status
    ;;
  continuity-lineage)
    VERSION_ID="${1:-hv-continuity-control-plane-v1}"
    "$ROOT/scripts/continuity_provider.sh" lineage "$VERSION_ID"
    ;;
  continuity-surfaces)
    "$ROOT/scripts/continuity_provider.sh" surfaces
    ;;
  continuity-flow)
    VERSION_ID="${1:-hv-continuity-control-plane-v1}"
    "$ROOT/scripts/render_continuity_flow.sh" "$VERSION_ID"
    ;;
  continuity-resume)
    VERSION_ID="${1:-hv-continuity-control-plane-v1}"
    "$ROOT/scripts/render_continuity_flow.sh" "$VERSION_ID"
    ;;
  pm-products)
    cat "$ROOT/build/system/product_candidate_registry.json"
    ;;
  pm-resume)
    "$ROOT/scripts/render_pm_operator.sh" resume
    ;;
  pm-next)
    "$ROOT/scripts/render_pm_operator.sh" next
    ;;
  pm-verify)
    "$ROOT/scripts/render_pm_operator.sh" verify
    ;;
  memory-readiness)
    cat "$ROOT/build/system/memory_readiness.json"
    ;;
  memory-runtime)
    python3 "$ROOT/scripts/query_typed_memory.py" show
    ;;
  memory-get)
    UNIT_ID="${1:-}"
    if [ -z "$UNIT_ID" ]; then
      echo "usage: bvtctl memory-get <unit_id>" >&2
      exit 1
    fi
    python3 "$ROOT/scripts/query_typed_memory.py" exact "$UNIT_ID"
    ;;
  memory-as-of)
    UNIT_ID="${1:-}"
    AT_TIME="${2:-}"
    if [ -z "$UNIT_ID" ] || [ -z "$AT_TIME" ]; then
      echo "usage: bvtctl memory-as-of <unit_id_or_logical_id> <timestamp>" >&2
      exit 1
    fi
    python3 "$ROOT/scripts/query_typed_memory.py" as-of "$UNIT_ID" "$AT_TIME"
    ;;
  memory-expand)
    UNIT_ID="${1:-}"
    if [ -z "$UNIT_ID" ]; then
      echo "usage: bvtctl memory-expand <unit_id>" >&2
      exit 1
    fi
    python3 "$ROOT/scripts/query_typed_memory.py" expand "$UNIT_ID"
    ;;
  continuity-activate)
    SURFACE_ID="${1:-}"
    VERSION_ID="${2:-hv-continuity-control-plane-v1}"
    if [ -z "$SURFACE_ID" ]; then
      echo "usage: bvtctl continuity-activate <surface_id> [version_id]" >&2
      exit 1
    fi
    "$ROOT/scripts/continuity_provider.sh" activate "$SURFACE_ID" "$VERSION_ID"
    ;;
  continuity-materialize)
    ARG="${1:-}"
    if [ -n "$ARG" ] && [ -f "$ARG" ]; then
      "$ROOT/scripts/continuity_provider.sh" instantiate "$ARG"
    else
      "$ROOT/scripts/continuity_provider.sh" instantiate "${ARG:-hv-continuity-control-plane-v1}" "hv-conversational-control-plane-v0"
    fi
    ;;
  continuity-materialize-local)
    MANIFEST="${1:-$ROOT/runtime/examples/continuity_v1_manifest.json}"
    MATERIALIZED_MANIFEST="$("$ROOT/runtime/materialize_continuity_slice.sh" "$MANIFEST")"
    "$ROOT/runtime/execute_manifest.sh" "$MATERIALIZED_MANIFEST"
    ;;
  help|--help|-h)
    print_help
    ;;
  policy)
    cat "$ROOT/policy/control_language_v0.json"
    ;;
  scorecard)
    cat "$ROOT/benchmarks/control_scorecard_v0.md"
    ;;
  corpus-packets)
    python3 "$ROOT/scripts/build_corpus_reasoning_packets.py"
    ;;
  runtime)
    cat "$ROOT/runtime/work_manifest_v0.json"
    ;;
  api)
    cat "$ROOT/api/conversational_api_v0.json"
    ;;
  inference)
    cat "$ROOT/inference.yaml"
    ;;
  context)
    "$ROOT/api/build_system_context.sh"
    ;;
  bootstrap-context)
    "$ROOT/api/write_session_bootstrap.sh"
    ;;
  ux)
    cat "$ROOT/ux/orchestrator_ux_v0.md"
    ;;
  execute)
    MANIFEST="${1:-$ROOT/runtime/examples/demo_manifest.json}"
    "$ROOT/runtime/execute_manifest.sh" "$MANIFEST"
    ;;
  turn|ask)
    USER_INPUT="${1:-}"
    MANIFEST="${2:-}"
    if [ -z "$USER_INPUT" ]; then
      echo "usage: bvtctl ask \"<user_input>\" [manifest.json]" >&2
      exit 1
    fi
    run_turn "$USER_INPUT" "$MANIFEST"
    ;;
  chat)
    MANIFEST="${1:-}"
    run_chat "$MANIFEST"
    ;;
  kernel-plan)
    cat "$ROOT/docs/kernel_import_plan.md"
    ;;
  benchmark)
    "$ROOT/benchmarks/run_standalone_control_bench.sh"
    ;;
  self-improve)
    GOAL="${1:-}"
    if [ -z "$GOAL" ]; then
      echo "usage: bvtctl self-improve \"<goal>\"" >&2
      exit 1
    fi
    python3 "$ROOT/scripts/run_self_improve.py" --goal "$GOAL"
    ;;
  self-improve-apply)
    GOAL="${1:-}"
    if [ -z "$GOAL" ]; then
      echo "usage: bvtctl self-improve-apply \"<goal>\"" >&2
      exit 1
    fi
    python3 "$ROOT/scripts/run_self_improve.py" --goal "$GOAL" --apply --stage-on-pass
    ;;
  *)
    USER_INPUT="$CMD"
    if [ "$#" -gt 0 ]; then
      USER_INPUT="$USER_INPUT $*"
    fi
    run_turn "$USER_INPUT"
    ;;
esac