mirror of
https://github.com/nearai/ironclaw.git
synced 2026-09-03 08:06:01 +08:00
fix(test): stop reporting a failure when zero bundles were skipped
`grep -c` exits 1 when the count is zero, so `|| echo 0` appended a second zero and the compare against "0" failed -- the healthy case reported "FAIL A6 0". Same shape of bug as the missing log directory: the test was wrong, not the product. Also records why B5's execution check is best-effort: display-preview subtitles redact paths, so `python3 <path>` cannot be attributed to the bundle from the preview alone. The inline `python3 -c` fallback is the reliable signal, which makes a false negative possible and a false positive not. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -274,7 +274,10 @@ if await_answer "$TA2"; then
|
||||
else
|
||||
fail "A6 the fresh conversation never answered"
|
||||
fi
|
||||
SKIPS=$(grep -ac "skipping skill bundle" "$LOG_DIR/server-2.log" 2>/dev/null || echo 0)
|
||||
# `grep -c` exits 1 when the count is zero, so `|| echo 0` appended a SECOND zero and the compare
|
||||
# against "0" failed -- reporting a failure for the healthy case. Count without the fallback.
|
||||
SKIPS=$(grep -ac "skipping skill bundle" "$LOG_DIR/server-2.log" 2>/dev/null)
|
||||
SKIPS=${SKIPS:-0}
|
||||
if [ "${SKIPS:-0}" = "0" ]; then
|
||||
pass "A6 no bundle was skipped as unvalidatable"
|
||||
else
|
||||
@@ -336,6 +339,11 @@ for m in d.get("messages") or []:
|
||||
print(" $ " + (p.get("subtitle") or "")[:160].replace("\n", " "))
|
||||
PY
|
||||
# Did it RUN the bundled script, or re-type the algorithm inline?
|
||||
#
|
||||
# Best-effort: display-preview subtitles REDACT paths, so `python3 <path>` cannot be attributed to
|
||||
# the bundle from the preview alone. The inline `python3 -c "<algorithm>"` is the reliable tell, so
|
||||
# a false "no" is possible and a false "yes" is not. Worth replacing with a check against the shell
|
||||
# capability's recorded input once that is readable from the timeline.
|
||||
RAN_FILE=$(python3 - "$WORK/tb2.json" "$SCRIPT_SKILL" <<'PY'
|
||||
import json, sys
|
||||
d = json.load(open(sys.argv[1])); skill = sys.argv[2]
|
||||
|
||||
69
tenants/reborn-cli/users/reborn-cli/ckd_epi_egfr.py
Normal file
69
tenants/reborn-cli/users/reborn-cli/ckd_epi_egfr.py
Normal file
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env python3
|
||||
"""CKD-EPI 2021 race-free eGFR calculator."""
|
||||
import math
|
||||
|
||||
def compute_egfr(sex, age, scr, unit="mg/dL"):
|
||||
"""Compute eGFR (mL/min/1.73 m²) and CKD stage.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
sex : str
|
||||
'male' or 'female'
|
||||
age : numeric
|
||||
Age in years
|
||||
scr : numeric
|
||||
Serum creatinine value
|
||||
unit : str
|
||||
'mg/dL' or 'umol/L'
|
||||
|
||||
Returns
|
||||
-------
|
||||
dict with keys egfr (float), stage (str)
|
||||
"""
|
||||
if unit.lower() == "umol/l":
|
||||
scr = scr / 88.42 # convert to mg/dL
|
||||
|
||||
if sex.lower() == "female":
|
||||
kappa = 0.7
|
||||
alpha = -0.241
|
||||
sex_factor = 1.012
|
||||
else:
|
||||
kappa = 0.9
|
||||
alpha = -0.302
|
||||
sex_factor = 1.0
|
||||
|
||||
scr_over_kappa = scr / kappa
|
||||
min_part = min(scr_over_kappa, 1) ** alpha
|
||||
max_part = max(scr_over_kappa, 1) ** (-1.200)
|
||||
age_factor = 0.9938 ** age
|
||||
|
||||
egfr = 142 * min_part * max_part * age_factor * sex_factor
|
||||
egfr = round(egfr, 1)
|
||||
|
||||
if egfr >= 90:
|
||||
stage = "G1"
|
||||
elif egfr >= 60:
|
||||
stage = "G2"
|
||||
elif egfr >= 45:
|
||||
stage = "G3a"
|
||||
elif egfr >= 30:
|
||||
stage = "G3b"
|
||||
elif egfr >= 15:
|
||||
stage = "G4"
|
||||
else:
|
||||
stage = "G5"
|
||||
|
||||
return {"egfr": egfr, "stage": stage}
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
patients = [
|
||||
("62-year-old female", "female", 62, 1.3),
|
||||
("45-year-old male", "male", 45, 0.9),
|
||||
("78-year-old male", "male", 78, 2.1),
|
||||
]
|
||||
print(f"{'Patient':<30} {'eGFR (mL/min/1.73m²)':<25} {'CKD Stage':<10}")
|
||||
print("-" * 65)
|
||||
for label, sex, age, scr in patients:
|
||||
result = compute_egfr(sex, age, scr)
|
||||
print(f"{label:<30} {result['egfr']:<25} {result['stage']:<10}")
|
||||
Reference in New Issue
Block a user