Phase 20.34: add MirBuilderBox + LLVMEmitBox (Hako, delegate/provider stubs with stable tags); add quick canaries (phase2034) for presence and SKIP policy; update phase docs + CURRENT_TASK

This commit is contained in:
nyash-codex
2025-11-02 19:19:55 +09:00
parent cf3908d438
commit 4edd9517a4
5 changed files with 176 additions and 0 deletions

View File

@ -0,0 +1,46 @@
// MirBuilderBox — Program(JSON v0) → MIR(JSON v0)
// Contract (Phase 20.34, staged):
// - I/F is stable; implementation starts as a delegate to Runner path.
// - Unsupported or unavailable paths must FailFast with stable tags (no silent fallback).
//
// API
// - emit_from_program_json_v0(program_json: String, opts: Map|Null) -> String|Null
// Returns MIR(JSON v0) on success, or prints a tag and returns null on failure/skip.
//
// Toggles (delegate first):
// - HAKO_MIR_BUILDER_DELEGATE=1 — implementation delegated to Runner (--program-json-to-mir).
// In this initial stub, we only indicate delegation via a stable tag.
static box MirBuilderBox {
// Availability probe (for canaries)
is_available() {
// For now, availability means delegate toggle is present
local t = env.get("HAKO_MIR_BUILDER_DELEGATE")
if t == null { return 0 }
if ("" + t) == "1" { return 1 } else { return 0 }
}
// Main entry
emit_from_program_json_v0(program_json, opts) {
if program_json == null {
print("[mirbuilder/input/null] program_json is null")
return null
}
// Minimal validation: must include version/kind
local s = "" + program_json
if !(s.contains("\"version\"")) || !(s.contains("\"kind\"")) {
print("[mirbuilder/input/invalid] missing version/kind keys")
return null
}
// Delegate-first policy (Phase 20.34 Milestone A)
local d = env.get("HAKO_MIR_BUILDER_DELEGATE")
if d != null && ("" + d) == "1" {
print("[mirbuilder/delegate] use Runner --program-json-to-mir")
return null
}
// Provider not wired yet
print("[mirbuilder/delegate/missing] no provider; enable HAKO_MIR_BUILDER_DELEGATE=1")
return null
}
}