Files
windroost/p2_godot_sample/scripts/ch_runtime_content_probe.gd
T
wushenghua 49059fe15e A5: add authority-first CH consumer adapter and fail-fast disposition gate
- add ch_runtime_content.py/.gd: patched pointers require real level/zone;
  unmappable families (C004/C050/C053/C054) raise instead of guessing
- remove field_map.counts silent product-literal fallback in ch_authority.py
- label frozen launch fixture source; add disposition map and G5 gate
- keep UI, battle HUD, locale, OPEN items and gameplay literals untouched

G3 12/12, G4 9 families/160 pointers/open 8, G5 92 dispositions PASS
2026-11-28 02:05:28 +08:00

55 lines
2.8 KiB
GDScript

extends SceneTree
## A5 G5 probe: runtime fail-fast behaviour of the authority-first adapter.
## Writes res://artifacts/ch_runtime_content_gd.json. No UI or gameplay writes.
const Adapter = preload("res://scripts/ch_runtime_content.gd")
const ChAuthority = preload("res://scripts/ch_authority.gd")
func _init() -> void:
var results := []
var hero := {"id": "H01"}
var node := {"id": "R1-C01-N01"}
var enemy := {"id": "E-R1-F1-V1"}
var boss := {"id": "B-R1-01"}
var dps_missing: float = Adapter.hero_base_dps(hero)
var dps_ok: float = Adapter.hero_base_dps(hero, 5)
var hp_missing: float = Adapter.enemy_base_hp(enemy)
results.append({"case": "hero_base_dps_no_level_nan", "pass": is_nan(dps_missing)})
results.append({"case": "hero_base_dps_with_level_finite", "pass": is_finite(dps_ok), "value": dps_ok})
results.append({"case": "enemy_base_hp_no_zone_nan", "pass": is_nan(hp_missing)})
var hp_zone: float = Adapter.enemy_base_hp(enemy, 1)
results.append({"case": "enemy_base_hp_with_zone_finite", "pass": is_finite(hp_zone), "value": hp_zone})
var boss_zone: float = Adapter.boss_base_hp(boss, 1)
results.append({"case": "boss_base_hp_with_zone_finite", "pass": is_finite(boss_zone), "value": boss_zone})
var gold_missing: int = Adapter.node_gold(node)
var gold_zone: int = Adapter.node_gold(node, 1)
results.append({"case": "node_gold_no_zone_negative", "pass": gold_missing < 0})
results.append({"case": "node_gold_with_zone_positive", "pass": gold_zone > 0, "value": gold_zone})
results.append({"case": "stat_value_blocked", "pass": is_nan(Adapter.stat_value({}, "gear"))})
results.append({"case": "counts_blocked", "pass": (Adapter.counts() as Dictionary).is_empty()})
results.append({"case": "relic_rows_blocked", "pass": (Adapter.relic_rows() as Array).is_empty()})
results.append({"case": "partner_rows_blocked", "pass": (Adapter.partner_rows() as Array).is_empty()})
results.append({"case": "legacy_source_label", "pass": Adapter.source_of({"source": Adapter.LEGACY_SOURCE}) == Adapter.LEGACY_SOURCE})
var report := {
"gate": "G5",
"kind": "authority-first runtime adapter fail-fast probe",
"source_bound": ChAuthority.source_bound(),
"results": results,
}
report["status"] = "PASS" if report["source_bound"] and all_pass(results) else "FAIL"
var dir := DirAccess.open("res://artifacts")
if dir == null:
DirAccess.make_dir_recursive_absolute("res://artifacts")
var f := FileAccess.open("res://artifacts/ch_runtime_content_gd.json", FileAccess.WRITE)
f.store_string(JSON.stringify(report, "\t"))
f.close()
print("CH_RUNTIME_CONTENT_GD status=%s cases=%d" % [report["status"], results.size()])
quit(0 if report["status"] == "PASS" else 1)
func all_pass(results: Array) -> bool:
for r in results:
if not bool((r as Dictionary).get("pass", false)):
return false
return true