mirror of
https://github.com/alirezarezvani/claude-skills.git
synced 2026-11-26 22:28:38 +00:00
* feat: mobile-release, cloud-finops and support-ops plugins Three new plugins for gaps the library had no skill for: - engineering/mobile-release: iOS privacy-manifest and Play release checks, plus a PROCEED/HOLD/HALT staged-rollout gate. - engineering/cloud-finops: FOCUS-export allocation coverage, commitment utilization/coverage/ESR, robust cost anomalies. - business-growth/support-ops: business-hours SLA attainment, Erlang C staffing, ticket deflection finder. Each ships 3 stdlib scripts, 3 cited references, a cs-* agent and commands, mirrors into its domain bundle, trigger and behaviour eval cases with fixtures, and refreshed counters, mirrors and baselines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L8KYFKgTBNWHqHJNQWHwnq * feat: trigger tuning, skill-router hooks and eval cases for the new plugins - Descriptions rewritten in user words after held-out trigger evals (cloud-finops 12/24 -> 19/24 positives, 0 near-miss fires). - Skill-router UserPromptSubmit hooks in mobile-release, cloud-finops, support-ops and both bundles; 0 wrong hints across 2,355 eval prompts. - support-ops scoped to interval scheduling; headcount and hiring stay with capacity-planner (the old note wrongly said it had no queueing). - support-ops Report section and mobile-release reason-code rule from behaviour-eval transcripts; behaviour eval prompt names the review. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L8KYFKgTBNWHqHJNQWHwnq * fix(mobile-release, support-ops): small-sample HALTs, platform check, backlog drain From review on #1153: - rollout_gate: Play thresholds judged on the 95% Wilson lower bound; below --min-users a significant regression or device breach is a HOLD, not a HALT (1 crash among 40 users no longer halts a 1% rollout). - rollout_gate: baseline and release on different platforms exit 3; an Android row without anr_users says ANR was not checked. - staffing_plan: backlog drain spread over the first --drain-hours rows only, at the arrivals' effective AHT (divided by concurrency); footer states one row = one hour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L8KYFKgTBNWHqHJNQWHwnq * fix(mobile-release, support-ops): input validation and documented caveats From the second review on #1153: - rollout_gate: inf/NaN counts and out-of-range percentages exit 3; exactly two rows required, matching the docstring; repeated looks across stages and the staged-cohort bias documented. - staffing_plan: non-finite inputs exit 3; staffed is defined as paid agents rostered before shrinkage. - business-growth/CLAUDE.md lists all six skills. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L8KYFKgTBNWHqHJNQWHwnq --------- Co-authored-by: Claude <noreply@anthropic.com>
256 lines
12 KiB
Python
256 lines
12 KiB
Python
#!/usr/bin/env python3
|
|
"""Decide the next step of a staged (Android) or phased (iOS) rollout.
|
|
|
|
Compares the new release's crash and ANR numbers with the previous release
|
|
(the baseline) and with Google Play's "bad behavior" thresholds, and returns
|
|
PROCEED, HOLD or HALT for the current stage.
|
|
|
|
Input: a CSV with exactly two rows, the baseline and the new release (the
|
|
baseline is the row whose release starts with "baseline", else the first). Columns (counts, not percentages, so the test is honest):
|
|
|
|
release, platform (android|ios), rollout_pct, users,
|
|
crashed_users, anr_users (android, optional), worst_device_crash_pct (optional)
|
|
|
|
Decision, in order
|
|
HALT Android user-perceived crash rate >= 1.09% or ANR rate >= 0.47%
|
|
(Play bad-behavior thresholds), judged on the one-sided 95% Wilson
|
|
lower bound so a handful of users cannot trip it; a rate above the
|
|
threshold whose bound is not is a HOLD. A single phone model >= 8%
|
|
is a HALT once --min-users is reached, a HOLD before
|
|
HALT crash (or ANR) rate is worse than baseline by more than
|
|
--max-regression (relative) AND the difference is significant
|
|
(one-sided two-proportion z-test, p < --alpha) on at least
|
|
--min-users users; below that it is a HOLD (the normal
|
|
approximation needs the counts)
|
|
HOLD fewer than --min-users users on the release: not enough data
|
|
HOLD worse than baseline by more than --max-regression, not yet
|
|
significant: wait for more users before widening
|
|
PROCEED otherwise: next percentage of the ladder
|
|
|
|
Ladders: iOS phased release is fixed by Apple at 1, 2, 5, 10, 20, 50, 100%
|
|
over seven days and can only be paused (up to 30 days) or released to all;
|
|
users can still download the version manually while paused. Android staged
|
|
rollout percentages are yours to set; the default ladder here is
|
|
1, 5, 10, 20, 50, 100 (change with --ladder).
|
|
|
|
Re-running the gate at every stage on two metrics means several looks at
|
|
alpha 0.05, so the false-HALT rate over a whole rollout is above 5%; lower
|
|
--alpha if a false HALT is expensive for you.
|
|
|
|
Exit codes: 0 PROCEED, 2 HOLD, 3 bad input, 4 HALT.
|
|
Thresholds verified 2026-11-17. Deterministic, stdlib only, no network.
|
|
"""
|
|
import argparse
|
|
import csv
|
|
import io
|
|
import json
|
|
import math
|
|
import sys
|
|
|
|
RULES_VERIFIED = "2026-11-17"
|
|
EXIT = {"PROCEED": 0, "HOLD": 2, "BAD_INPUT": 3, "HALT": 4}
|
|
PLAY_CRASH, PLAY_ANR, PLAY_DEVICE = 1.09, 0.47, 8.0
|
|
IOS_LADDER = [1, 2, 5, 10, 20, 50, 100]
|
|
ANDROID_LADDER = [1, 5, 10, 20, 50, 100]
|
|
|
|
SAMPLE = """release,platform,rollout_pct,users,crashed_users,anr_users,worst_device_crash_pct
|
|
baseline 4.11.0,android,100,412000,1480,1050,2.1
|
|
4.12.0,android,5,21800,131,49,3.4
|
|
"""
|
|
|
|
|
|
def z_one_sided(x1, n1, x0, n0):
|
|
"""p-value that rate1 > rate0 (pooled two-proportion z-test)."""
|
|
if n1 == 0 or n0 == 0:
|
|
return 1.0
|
|
p1, p0 = x1 / n1, x0 / n0
|
|
p = (x1 + x0) / (n1 + n0)
|
|
se = math.sqrt(p * (1 - p) * (1 / n1 + 1 / n0))
|
|
if se == 0:
|
|
return 0.0 if p1 > p0 else 1.0
|
|
z = (p1 - p0) / se
|
|
return 0.5 * math.erfc(z / math.sqrt(2))
|
|
|
|
|
|
def wilson_lower(x, n, z=1.6449):
|
|
"""One-sided 95% Wilson lower bound of x/n, in percent."""
|
|
if n == 0:
|
|
return 0.0
|
|
p = x / n
|
|
den = 1 + z * z / n
|
|
centre = p + z * z / (2 * n)
|
|
margin = z * math.sqrt(p * (1 - p) / n + z * z / (4 * n * n))
|
|
return 100.0 * max(0.0, (centre - margin) / den)
|
|
|
|
|
|
def to_int(row, key, required=True):
|
|
v = (row.get(key) or "").strip()
|
|
if not v:
|
|
if required:
|
|
raise ValueError(f"missing {key} in row {row.get('release')}")
|
|
return None
|
|
try:
|
|
f = float(v)
|
|
if not math.isfinite(f):
|
|
raise ValueError
|
|
n = int(f)
|
|
except ValueError:
|
|
raise ValueError(f"{key}='{v}' is not a number in row {row.get('release')}")
|
|
if n < 0:
|
|
raise ValueError(f"{key} is negative in row {row.get('release')}")
|
|
return n
|
|
|
|
|
|
def parse(text):
|
|
rows = list(csv.DictReader(io.StringIO(text)))
|
|
if len(rows) != 2:
|
|
raise ValueError(f"need exactly two rows, the baseline and the new release; got {len(rows)}")
|
|
base = next((r for r in rows if (r.get("release") or "").lower().startswith("baseline")), rows[0])
|
|
new = rows[-1] if rows[-1] is not base else rows[-2]
|
|
out = []
|
|
for r in (base, new):
|
|
d = {
|
|
"release": r.get("release", "").strip(),
|
|
"platform": (r.get("platform") or "").strip().lower(),
|
|
"rollout_pct": float(r.get("rollout_pct") or 0),
|
|
"users": to_int(r, "users"),
|
|
"crashed_users": to_int(r, "crashed_users"),
|
|
"anr_users": to_int(r, "anr_users", False),
|
|
"worst_device_crash_pct": float(r["worst_device_crash_pct"]) if (r.get("worst_device_crash_pct") or "").strip() else None,
|
|
}
|
|
for k in ("rollout_pct", "worst_device_crash_pct"):
|
|
if d[k] is not None and not (math.isfinite(d[k]) and 0 <= d[k] <= 100):
|
|
raise ValueError(f"{k} must be a number from 0 to 100 in row {d['release']}")
|
|
if d["platform"] not in ("android", "ios"):
|
|
raise ValueError(f"platform must be android or ios in row {d['release']}")
|
|
if d["users"] == 0:
|
|
raise ValueError(f"users is 0 in row {d['release']}")
|
|
if d["crashed_users"] > d["users"] or (d["anr_users"] or 0) > d["users"]:
|
|
raise ValueError(f"more affected users than users in row {d['release']}")
|
|
out.append(d)
|
|
if out[0]["platform"] != out[1]["platform"]:
|
|
raise ValueError(f"baseline {out[0]['release']} is {out[0]['platform']} but {out[1]['release']} is {out[1]['platform']}; compare releases on the same platform")
|
|
return out
|
|
|
|
|
|
def next_step(pct, ladder):
|
|
for step in ladder:
|
|
if step > pct + 1e-9:
|
|
return step
|
|
return None
|
|
|
|
|
|
def decide(base, new, min_users, max_reg, alpha, ladder):
|
|
reasons, verdict = [], "PROCEED"
|
|
rate = lambda x, n: 100.0 * x / n
|
|
metrics = {}
|
|
for name, key in (("crash", "crashed_users"), ("anr", "anr_users")):
|
|
if new[key] is None or base[key] is None:
|
|
continue
|
|
r1, r0 = rate(new[key], new["users"]), rate(base[key], base["users"])
|
|
p = z_one_sided(new[key], new["users"], base[key], base["users"])
|
|
rel = (r1 - r0) / r0 if r0 > 0 else (math.inf if r1 > 0 else 0.0)
|
|
metrics[name] = {"release_pct": round(r1, 3), "baseline_pct": round(r0, 3),
|
|
"relative_change": None if math.isinf(rel) else round(rel, 3), "p_worse": round(p, 4)}
|
|
|
|
def escalate(v, why):
|
|
nonlocal verdict
|
|
order = {"PROCEED": 0, "HOLD": 1, "HALT": 2}
|
|
if order[v] > order[verdict]:
|
|
verdict = v
|
|
reasons.append(f"{v}: {why}")
|
|
|
|
if new["platform"] == "android":
|
|
for name, key, limit in (("crash", "crashed_users", PLAY_CRASH), ("ANR", "anr_users", PLAY_ANR)):
|
|
if new[key] is None:
|
|
continue
|
|
r = rate(new[key], new["users"])
|
|
lo = wilson_lower(new[key], new["users"])
|
|
if lo >= limit:
|
|
escalate("HALT", f"user-perceived {name} rate {r:.3f}% (95% lower bound {lo:.3f}%) >= Play bad-behavior threshold {limit}%")
|
|
elif r >= limit:
|
|
escalate("HOLD", f"user-perceived {name} rate {r:.3f}% is above the Play threshold {limit}% but its 95% lower bound {lo:.3f}% is not; wait for more users")
|
|
if new["anr_users"] is None:
|
|
reasons.append("NOTE: no anr_users for this Android release; ANR was not checked")
|
|
if new["worst_device_crash_pct"] is not None and new["worst_device_crash_pct"] >= PLAY_DEVICE:
|
|
if new["users"] >= min_users:
|
|
escalate("HALT", f"a phone model at {new['worst_device_crash_pct']}% crash rate >= Play per-device threshold {PLAY_DEVICE}%")
|
|
else:
|
|
escalate("HOLD", f"a phone model at {new['worst_device_crash_pct']}% crash rate >= {PLAY_DEVICE}% on fewer than {min_users} users; confirm before halting")
|
|
for name, m in metrics.items():
|
|
rel = m["relative_change"]
|
|
worse = rel is None or rel > max_reg
|
|
if worse and m["p_worse"] < alpha and new["users"] < min_users:
|
|
escalate("HOLD", f"{name} rate {m['release_pct']}% vs baseline {m['baseline_pct']}% looks like a regression (p={m['p_worse']}), but on fewer than {min_users} users the test is not reliable; pause widening and recheck")
|
|
elif worse and m["p_worse"] < alpha:
|
|
escalate("HALT", f"{name} rate {m['release_pct']}% vs baseline {m['baseline_pct']}% is a significant regression (p={m['p_worse']})")
|
|
elif worse:
|
|
escalate("HOLD", f"{name} rate {m['release_pct']}% vs baseline {m['baseline_pct']}% is worse by more than {int(max_reg * 100)}% but not yet significant (p={m['p_worse']}); wait for more users")
|
|
if new["users"] < min_users:
|
|
escalate("HOLD", f"only {new['users']} users on the release (< {min_users}); not enough data to widen")
|
|
if not metrics:
|
|
escalate("HOLD", "no comparable crash counts")
|
|
|
|
step = next_step(new["rollout_pct"], ladder)
|
|
if verdict == "PROCEED":
|
|
action = f"widen to {step}%" if step else "rollout complete"
|
|
if new["platform"] == "ios":
|
|
action = "let the phased release continue" + (f" (next automatic step {step}%)" if step else "")
|
|
elif verdict == "HOLD":
|
|
action = ("pause the phased release (up to 30 days) or leave it on schedule only if the trend is improving"
|
|
if new["platform"] == "ios" else f"stay at {new['rollout_pct']:g}% and re-run after more users")
|
|
else:
|
|
action = ("pause the phased release and ship a fix; paused versions can still be downloaded manually, so consider removing the build from sale if the crash is severe"
|
|
if new["platform"] == "ios" else "halt the staged rollout in Play Console, fix, and ship a new version code")
|
|
return {"verdict": verdict, "action": action, "reasons": reasons or ["no threshold or regression triggered"],
|
|
"metrics": metrics, "release": new["release"], "baseline": base["release"],
|
|
"rollout_pct": new["rollout_pct"], "next_step_pct": step, "rules_verified": RULES_VERIFIED}
|
|
|
|
|
|
def render(res):
|
|
out = [f"Rollout gate: {res['verdict']} for {res['release']} at {res['rollout_pct']:g}% (baseline {res['baseline']})",
|
|
f"Action: {res['action']}", ""]
|
|
for name, m in res["metrics"].items():
|
|
rel = "n/a" if m["relative_change"] is None else f"{m['relative_change'] * 100:+.0f}%"
|
|
out.append(f" {name:5s} {m['release_pct']:.3f}% vs {m['baseline_pct']:.3f}% ({rel}, p_worse={m['p_worse']})")
|
|
out.append("")
|
|
out += [f"- {r}" for r in res["reasons"]]
|
|
return "\n".join(out)
|
|
|
|
|
|
def main(argv=None):
|
|
ap = argparse.ArgumentParser(description=__doc__.split("\n")[0], epilog="Exit codes: 0 PROCEED, 2 HOLD, 3 bad input, 4 HALT.")
|
|
ap.add_argument("--input", help="CSV with a baseline row and the new release row")
|
|
ap.add_argument("--min-users", type=int, default=1000, help="users needed on the release before widening (default 1000)")
|
|
ap.add_argument("--max-regression", type=float, default=0.25, help="relative worsening tolerated vs baseline (default 0.25 = 25%%)")
|
|
ap.add_argument("--alpha", type=float, default=0.05, help="significance level of the one-sided test (default 0.05)")
|
|
ap.add_argument("--ladder", help="Android percentages, comma-separated (default 1,5,10,20,50,100)")
|
|
ap.add_argument("--sample", action="store_true", help="run on a built-in example")
|
|
ap.add_argument("--output", choices=["text", "json"], default="text")
|
|
a = ap.parse_args(argv)
|
|
try:
|
|
if a.sample:
|
|
text = SAMPLE
|
|
elif a.input:
|
|
with open(a.input, encoding="utf-8") as fh:
|
|
text = fh.read()
|
|
else:
|
|
raise ValueError("give --input FILE or --sample")
|
|
base, new = parse(text)
|
|
if not 0 < a.alpha < 1 or a.max_regression < 0 or a.min_users < 0:
|
|
raise ValueError("--alpha must be in (0,1); --max-regression and --min-users must be >= 0")
|
|
ladder = ANDROID_LADDER
|
|
if new["platform"] == "ios":
|
|
ladder = IOS_LADDER
|
|
elif a.ladder:
|
|
ladder = sorted(float(x) for x in a.ladder.split(","))
|
|
except (OSError, ValueError) as exc:
|
|
print(f"error: {exc}", file=sys.stderr)
|
|
return EXIT["BAD_INPUT"]
|
|
res = decide(base, new, a.min_users, a.max_regression, a.alpha, ladder)
|
|
print(json.dumps(res, indent=2) if a.output == "json" else render(res))
|
|
return EXIT[res["verdict"]]
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|