From 46e9e2dc46e4a6ccc278f98811fce6538c48da45 Mon Sep 17 00:00:00 2001 From: Bryan <28662377+bryanwieg@users.noreply.github.com> Date: Thu, 26 Nov 2026 18:06:22 +0000 Subject: [PATCH 1/2] Keep Fable to the hardest stages, at medium thinking at most (0.16.0) Fable took 148 of 258 scored stages, mostly Fable low on middle+, at $1.59 a stage against $0.35-0.61 for Opus high at similar token counts: its benchmark run cost understates real spend. - PICK_CEILINGS: Fable is never picked above medium; its higher levels still set the best score, so the floors keep the other tiers' picks. - No premium pair below top, except a --up retry once the standard pairs run out (drops PREMIUM_RATIO_MARGIN). The J2/C2 and speed preferences never move a standard pick onto a premium pair; top is never below middle+'s standard pick. - A tier no pair meets takes the best one, then the 3-point tie rule. On the 258 real stages: Fable low 4 (top+ only), Opus high 220, Opus medium 8, Haiku xhigh 25, Sonnet high 1. Reviews: Opus high, Fable low for a phase with a top+ stage. Co-Authored-By: Claude Opus 5.5 --- README.md | 12 ++-- .../.claude-plugin/plugin.json | 2 +- .../phased-delivery/scripts/select-models.py | 70 ++++++++++--------- .../skills/plan-in-phases/model-selection.md | 28 +++++--- .../tests/test_select_models.py | 53 +++++++++----- 5 files changed, 94 insertions(+), 71 deletions(-) diff --git a/README.md b/README.md index 3fa923f..f1843de 100644 --- a/README.md +++ b/README.md @@ -89,13 +89,13 @@ up for risk. Claude stages and phase reviews are then built headless by a dollar cap: 150k tokens for `small`, 400k for `middle`, 1M for `top` and `top+`, at the pair's input price. A stage stopped at its cap is retried one step down the frontier; one that fails its checks, one step up. Premium models -(output price of $30 or more per million tokens) are used below `top` only -when cheaper than the standard pick and as good, or as the step up past the -last standard pick while their score per unit of cost is within 5% of it; -`top` comes only from a total score of 9 or more. The most capable pair is +(output price of $30 or more per million tokens) are never used below +`top`, except as a retry after a failed build once the standard pairs run +out; `top` comes only from a total score of 9 or more. Fable is picked at +medium thinking at most. The most capable pair is kept for `top+`: a `top` stage with a total of 12 or more or the highest -risk (K2); other `top` stages get the pair one below it, and step up only -when a build fails. They get $10 per phase; past that, builds use none. +risk (K2); other `top` stages get the pair one below it, never premium +while a standard pair is that good, and step up only when a build fails. They get $10 per phase; past that, builds use none. Reviews run on `top`, or on `top+` for a phase with a `top+` stage, and their cost counts against that budget. The builder may edit files and runs only the commands your project's permission rules allow; set diff --git a/plugins/phased-delivery/.claude-plugin/plugin.json b/plugins/phased-delivery/.claude-plugin/plugin.json index ad6f5ff..ca02453 100644 --- a/plugins/phased-delivery/.claude-plugin/plugin.json +++ b/plugins/phased-delivery/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "phased-delivery", - "version": "0.15.3", + "version": "0.16.0", "description": "Plan work as self-contained phases, then implement it phase by phase.", "author": { "name": "Bryan" diff --git a/plugins/phased-delivery/scripts/select-models.py b/plugins/phased-delivery/scripts/select-models.py index 0d57839..9977579 100755 --- a/plugins/phased-delivery/scripts/select-models.py +++ b/plugins/phased-delivery/scripts/select-models.py @@ -77,6 +77,9 @@ ("anthropic", "haiku", "xhigh"), # Haiku: xhigh keeps it a real small option ("anthropic", None, "high"), # other Claude: xhigh and max cost far more ] +# Most thinking a model family is picked at. Pairs above it still set the best +# score the floors measure from, as premium pairs do once the budget is spent. +PICK_CEILINGS = {"fable": "medium"} # Fable above medium is unaffordable DEFAULT_EFFORT = "default" # report row without a thinking-level suffix # A pair is premium when its output price is at least this many dollars per # million tokens. @@ -101,10 +104,6 @@ # A long or wide stage takes a faster pair only at this multiple of the pick's # speed: thinking levels of one model differ by a few percent, which is noise. SPEED_GAIN = 1.2 -# A premium step-up below top is taken while its score per unit of run cost is -# no more than this fraction worse than the standard pick's: a near tie goes to -# the larger model, which may need fewer tokens than the benchmark shows. -PREMIUM_RATIO_MARGIN = 0.05 SCORES_FORM = "J F R C K P V S in that order, each followed by 0, 1 or 2, such as J1F1R0C0K0P0V0S0" HERE = os.path.dirname(os.path.abspath(__file__)) @@ -196,6 +195,11 @@ def effort_denial(effort, ceiling): return None +def over_pick_ceiling(c): + words = set(normalize(c["row"]["model"]).split("-")) + return any(family in words and effort_denial(c["effort"], cap) for family, cap in PICK_CEILINGS.items()) + + def build_candidates(available, profiles): rows_by_base = {} for row in profiles["pairs"]: @@ -299,17 +303,21 @@ def prefer_cheaper(pick, pool): def assign_tiers(scored): best = max(c["score"] for c in scored) + pickable = [c for c in scored if not over_pick_ceiling(c)] or scored + # Below top only standard pairs, as route picks them (premium only on a --up retry). + standard = [c for c in pickable if not c["row"]["premium"]] or pickable tiers = {} for tier, floor in FLOORS.items(): - pick = cheapest([c for c in scored if c["score"] >= floor * best]) - tiers[tier] = prefer_cheaper(pick, scored) - above = [c for c in scored if c["score"] > tiers["middle"]["score"]] + pool = pickable if tier == "top+" else standard + meeting = [c for c in pool if c["score"] >= floor * best] or [max(pool, key=lambda c: c["score"])] + tiers[tier] = prefer_cheaper(cheapest(meeting), pool) + above = [c for c in standard if c["score"] > tiers["middle"]["score"]] if above: pick = min(above, key=lambda c: (c["score"], c["cost"])) tiers["middle+"] = prefer_cheaper(pick, above) else: - tiers["middle+"] = tiers["top+"] - tiers["top"] = below_top_plus(frontier(scored), tiers["top+"], tiers["middle+"]) + tiers["middle+"] = tiers["middle"] + tiers["top"] = below_top_plus(frontier(pickable), tiers["top+"], tiers["middle+"]) return best, tiers @@ -533,11 +541,12 @@ def frontier_pick(front, tier, best): if tier == "middle+": middle = front.index(frontier_pick(front, "middle", best)) return front[min(middle + 1, len(front) - 1)] - if tier == "top": - return below_top_plus(front, frontier_pick(front, "top+", best), frontier_pick(front, "middle+", best)) + if tier == "top": # never below middle+ as route ends it: on a standard pair + standard = [c for c in front if not c["row"]["premium"]] or front + return below_top_plus(front, frontier_pick(front, "top+", best), frontier_pick(standard, "middle+", best)) meeting = meets_floor(front, tier, best) if not meeting: - return max(front, key=lambda c: c["score"]) + return prefer_cheaper(max(front, key=lambda c: c["score"]), front) return prefer_cheaper(cheapest(meeting), front) @@ -573,6 +582,8 @@ def pick_pair(allowed, tier, best, scores, signals, up, down): pick = stepped # The preferences never go below this score, so they cannot undo the risk step. least = pick["score"] + # Nor move a standard pick onto a premium pair, whose run cost understates its real spend. + meeting = [c for c in meeting if c["row"]["premium"] <= pick["row"]["premium"]] if signals and (scores["J"] == 2 or scores["C"] == 2): lighter = min([pick] + [c for c in meeting if c["score"] >= least and c["cost"] <= PREFER_COST_RATIO * pick["cost"]], @@ -622,7 +633,8 @@ def route_main(args): else ("top", "reviews run on top") best = max(c["score"] for c in pool) over_budget = not options.review and options.premium_spent >= PREMIUM_BUDGET_USD - allowed = [c for c in pool if not c["row"]["premium"]] if over_budget else pool + allowed = [c for c in pool if not over_pick_ceiling(c)] + allowed = [c for c in allowed if not c["row"]["premium"]] if over_budget else allowed if not allowed: print("no selectable pair within the premium budget", file=sys.stderr) return 4 @@ -639,27 +651,16 @@ def route_main(args): return 4 standard = [c for c in allowed if not c["row"]["premium"]] if tier not in ("top", "top+") and choice["row"]["premium"] and standard: - # Below top a premium pair must beat the standard pick on cost and score, - # unless the standard pairs cannot give a step up the stage asked for: - # the next model up at low thinking beats more thinking on a smaller one. + # Below top no premium pair: benchmark run cost understates its real spend (Fable low + # averaged 2.6-4.5x Opus high per stage). Only a --up retry after a failed build, once + # the standard pairs run out, takes the cheapest pair above the standard pick. other, other_notes, other_short, _ = pick_pair(standard, tier, best, scores, signals, *steps) - if other is not None and other_short and choice["score"] > other["score"]: - above = next(c for c in front if c["score"] > other["score"]) # front is cheapest first - # A step up the plan asked for (middle+ or risk) takes a premium pair only while - # its score/cost ratio is within the margin of the standard pick's; a --up retry - # after a failure takes it regardless. Cross-multiplied: costs may be 0. - if above["row"]["premium"] and not options.up and above["score"] * other["cost"] \ - < (1 - PREMIUM_RATIO_MARGIN) * other["score"] * above["cost"]: - choice = other - notes = other_notes + [f"premium {above['label']} left out below top: its score/cost " - f"is more than {PREMIUM_RATIO_MARGIN:.0%} below {other['label']}'s"] - else: - choice = above - notes = other_notes + [f"no standard pair above {other['label']} for the step up: " - f"{choice['label']}, the cheapest pair above it"] - elif other is not None and (choice["cost"] > other["cost"] or choice["score"] < other["score"]): - notes = other_notes + [f"premium {choice['label']} left out below top: " - f"{other['label']} costs less or scores at least as well"] + if other is not None and other_short and options.up and choice["score"] > other["score"]: + choice = next(c for c in front if c["score"] > other["score"]) # front is cheapest first + notes = other_notes + [f"--up retry, no standard pair above {other['label']}: " + f"{choice['label']}, the cheapest pair above it"] + elif other is not None: + notes = other_notes + [f"premium {choice['label']} left out below top"] choice = other why += notes row = choice["row"] @@ -683,7 +684,8 @@ def main(argv): available, profiles, candidates, excluded, matches = load_offered( options["available"], options["profiles"]) scored, unscored, metric, cost_field = score_and_cost(candidates) - excluded += unscored + excluded += unscored + [(c["tool_model"], c["effort"], "sets the best score, never picked: above " + "its family's PICK_CEILINGS") for c in scored if over_pick_ceiling(c)] if not scored: print("no selectable candidate; see the exclusions below", file=sys.stderr) for model, effort, reason in excluded: diff --git a/plugins/phased-delivery/skills/plan-in-phases/model-selection.md b/plugins/phased-delivery/skills/plan-in-phases/model-selection.md index 91dcc66..f4563ba 100644 --- a/plugins/phased-delivery/skills/plan-in-phases/model-selection.md +++ b/plugins/phased-delivery/skills/plan-in-phases/model-selection.md @@ -50,11 +50,13 @@ raises `middle` to `middle+` (override 2). `top` has a step above it for the most extreme complexity: **`top+`** is a `top` stage with a total of 12 or more, or with K = 2 (`plan-check.py`'s `hardest`). Only `top+` stages, and the reviews of phases that hold one, -get the most capable pair (Fable high today); other `top` stages get the -frontier pair one below it (Fable medium), and a failed build there steps +get the most capable pair (Fable low today); other `top` stages get the +frontier pair one below it (Opus high), and a failed build there steps up with `--up`. (Changed 2026-11-24: `top` on the most capable pair sent every review and every total of 9 to Fable high, at about twice Fable -medium's run cost.) +medium's run cost. Changed 2026-11-26: Fable still took 148 of 258 scored +stages, mostly Fable low on `middle+`, at $1.59 a stage against $0.35 to +$0.61 for Opus high; its benchmark run cost understates its real spend.) Overrides, which always win over the total: @@ -130,6 +132,9 @@ What the code enforces, so the agent does not: models never above `high`, except Haiku, which may use `xhigh`. Higher levels, and levels the script cannot place, are denied even if offered and charted. The ceilings are the `CEILINGS` table in the script. +- **Pick ceilings:** Fable is never picked above `medium`. Its higher + levels still set the best score the floors are measured from, so the + other tiers keep their picks (`PICK_CEILINGS`). - Each candidate is scored by the Artificial Analysis Intelligence Index (a quarter coding, plus reasoning-heavy science and HLE-Diamond; the free data has no separate coding or reasoning score) and costed by the benchmark run cost, which counts @@ -138,9 +143,10 @@ What the code enforces, so the agent does not: best** (the floors are constants at the top of the script). So a large model at low thinking beats a small model at high thinking when it scores as well for less. `middle+` is the next more capable candidate above - `middle`. `top+` takes the floor of 97% of the best score; `top` is the - frontier pair one below `top+`'s, or `middle+`'s pick when that scores - more. + `middle`. Below `top` only standard-price candidates are picked. `top+` + takes the floor of 97% of the best score; `top` is the frontier pair one + below `top+`'s, or `middle+`'s pick when that scores more. A tier no + candidate meets takes the best-scoring one, then the 3-point tie rule. - **Within 3 points, the cheaper candidate wins.** After a tier picks, any cheaper candidate scoring within 3 index points of the pick replaces it, even across a floor (for `middle+`, only candidates still above @@ -207,21 +213,21 @@ What `route` does, in this order: | Rule | Pick | | --- | --- | -| Candidates | Offered pairs within the thinking-level ceilings that have a score and a benchmark run cost, minus low-gain thinking steps: a step up gaining under 2 points for more than 1.5 times the run cost of the level below. | +| Candidates | Offered pairs within the thinking-level ceilings that have a score and a benchmark run cost, minus low-gain thinking steps: a step up gaining under 2 points for more than 1.5 times the run cost of the level below. The best score is taken here; then pairs above their pick ceiling (Fable above `medium`) are left out. | | Frontier | Only pairs on the score/cost frontier: a pair another beats on both score and cost is never chosen. | -| Tier | The tier from the scores with the overrides above, and `top+` for the hardest `top` stages; `--review` uses `top`, or `top+` when its scores are a `top+` stage's. The pick is the cheapest frontier pair meeting the tier's floor, then any cheaper pair within 3 points; `middle+` is the next frontier pair above the `middle` pick; `top` is the frontier pair one below the `top+` pick, never below `middle+`'s. | +| Tier | The tier from the scores with the overrides above, and `top+` for the hardest `top` stages; `--review` uses `top`, or `top+` when its scores are a `top+` stage's. The pick is the cheapest frontier pair meeting the tier's floor, then any cheaper pair within 3 points; `middle+` is the next frontier pair above the `middle` pick; `top` is the frontier pair one below the `top+` pick, never below `middle+`'s standard pick. | | Premium budget | With `--premium-spent` at or above $10, builds leave premium pairs out. | | Mechanical (J, P and V all 0, tier above `small`) | Thinking at `medium` or below. `small` stages keep the small model's higher levels. | | Long or wide (S, R or F = 2) | Thinking at `high` or below. | | Risk (K of 1 or more) | One frontier pair up, below `top` only: K = 2 makes a `top` stage `top+`. | -| Design or contract (J = 2 or C = 2) | Among pairs meeting the floor that score at least the pick and cost at most 1.5 times it, the lowest thinking level: a larger model at lower thinking. | +| Design or contract (J = 2 or C = 2) | Among pairs meeting the floor that score at least the pick and cost at most 1.5 times it, the lowest thinking level: a larger model at lower thinking. This and the speed preference never move a standard pick onto a premium pair. | | Long or wide (S, R or F = 2) | Among pairs meeting the floor within 3 points of the pick (with K of 1 or more, at least the risk step's score) and costing at most 1.5 times it, the fastest, if at least 1.2 times the pick's speed (thinking levels of one model differ by a few percent). | -| Premium below `top` | A premium pick below `top` (and `top+`) is routed again without premium pairs; the premium pair stays only if it costs no more than that standard pick and scores at least as well. When the standard pairs run out before a step up the stage asked for (`middle+`, risk, `--up`), the cheapest pair scoring above the standard pick is taken instead (the next model up at low thinking, not more thinking on a smaller model), but only when its score divided by its benchmark run cost is no more than 5% below the standard pick's (`PREMIUM_RATIO_MARGIN`); otherwise the standard pick stays. A `--up` retry after a failed build takes it regardless. | +| Premium below `top` | A premium pick below `top` (and `top+`) is routed again without premium pairs, and the standard pick is taken: a premium pair's benchmark run cost understates its real spend. Only a `--up` retry after a failed build, when the standard pairs run out before the step, takes the cheapest pair scoring above the standard pick (the next model up at low thinking, not more thinking on a smaller model). | | `--down N`, `--up N` | Move N frontier pairs cheaper or dearer from the pick, stopping at either end. N is 0 or more; not both at once. | | `--review` | `top`, or `top+` when `--scores` are a `top+` stage's (the driver passes the phase's hardest stage); premium spend and the scores' other signals do not shape it (no caps, risk step or preferences). | The constants (`LOW_GAIN_POINTS`, `LOW_GAIN_COST_RATIO`, `FLOORS`, -`TIE_POINTS`, `PREMIUM_BUDGET_USD`, `PREFER_COST_RATIO`, `SPEED_GAIN`, `CAP_TOKENS`) are +`TIE_POINTS`, `PICK_CEILINGS`, `PREMIUM_BUDGET_USD`, `PREFER_COST_RATIO`, `SPEED_GAIN`, `CAP_TOKENS`) are at the top of the script. ### Limits diff --git a/plugins/phased-delivery/tests/test_select_models.py b/plugins/phased-delivery/tests/test_select_models.py index f319726..e37a486 100644 --- a/plugins/phased-delivery/tests/test_select_models.py +++ b/plugins/phased-delivery/tests/test_select_models.py @@ -130,15 +130,16 @@ def test_route_premium_below_top(offered, tmp_path): # scores more, so astra is left out below top. up = route(offered, "J1F1R0C0K0P2V0S0", "--up", "2") assert pair(up) == ("sol", "high") and not up["premium"] and "below top" in up["why"] - # A premium pair scoring at least as well for less is kept. + # Even a premium pair scoring better for less is left out: benchmark run cost + # understates a premium pair's real spend. better = edited_profiles(tmp_path, {("GPT-9 Astra", "high"): {"intelligence": 59}}) - kept = route(offered, "J1F1R0C0K0P2V0S0", "--up", "2", profiles=better) - assert pair(kept) == ("astra", "high") and kept["premium"] - # When the standard pairs run out before the step asked for, the cheapest - # pair above the standard pick is taken: --up 5 wants nova medium, past - # sol high, the last standard pair, and gets nova low, the next pair up. + held = route(offered, "J1F1R0C0K0P2V0S0", "--up", "2", profiles=better) + assert pair(held) == ("sol", "high") and not held["premium"] + # When the standard pairs run out before a --up retry, the cheapest pair above + # the standard pick is taken: --up 5 wants nova medium, past sol high, the + # last standard pair, and gets nova low, the next pair up. short = route(offered, "J1F1R0C0K0P2V0S0", "--up", "5") - assert pair(short) == ("nova", "low") and "step up" in short["why"] + assert pair(short) == ("nova", "low") and "--up retry" in short["why"] def test_route_fable_limits(tmp_path): @@ -148,29 +149,43 @@ def test_route_fable_limits(tmp_path): assert route(offered_path, "J1F1R1C1K2P1V0S0")["tier"] == "middle+" assert route(offered_path, "J2F1R1C2K0P2V1S0")["tier"] == "top" # Without sol and terra xhigh, the standard pairs end at the middle pick, terra - # high (51.2 for 90, 0.57 per unit), so the middle+ step reaches astra high - # (58.5 for 300, 0.20): a worse score/cost ratio, so terra high stays. + # high, so the middle+ step would reach astra high, premium: terra high stays. narrow = tmp_path / "narrow.json" narrow.write_text(json.dumps({**OFFERED, "models": [ m if m["id"] != "gpt-9-terra" else {**m, "efforts": ["low", "medium", "high"]} for m in OFFERED["models"] if m["id"] != "gpt-9-sol"]})) held = route(narrow, "J1F1R0C0K0P2V0S0") - assert pair(held) == ("terra", "high") and "score/cost" in held["why"] + assert pair(held) == ("terra", "high") and "left out below top" in held["why"] # A --up retry after a failure still steps up to the premium pair. assert pair(route(narrow, "J1F1R0C0K0P2V0S0", "--up", "1")) == ("astra", "high") # The risk step is held the same way, and --up still steps. risk = route(narrow, "J1F1R0C0K1P0V0S0") - assert pair(risk) == ("terra", "high") and "score/cost" in risk["why"] + assert pair(risk) == ("terra", "high") and "left out below top" in risk["why"] assert pair(route(narrow, "J1F1R0C0K1P0V0S0", "--up", "1")) == ("astra", "high") - # A --down retry whose step up lands on a standard pair is not held by the ratio. + # A --down retry after a budget stop goes one pair below the held terra high. down = route(narrow, "J1F1R0C0K1P2V0S0", "--down", "1") - assert pair(down) == ("terra", "high") and "score/cost" not in down["why"] - # Within PREMIUM_RATIO_MARGIN the premium pair is taken: 58.5 for 108 is - # 0.54, 4.8% below terra high's 0.57; 58.5 for 120 (0.49, 14% below) is not. - near = edited_profiles(tmp_path, {("GPT-9 Astra", "high"): {"run_cost_usd": 108}}) - assert pair(route(narrow, "J1F1R0C0K0P2V0S0", profiles=near)) == ("astra", "high") - far = edited_profiles(tmp_path, {("GPT-9 Astra", "high"): {"run_cost_usd": 120}}) - assert pair(route(narrow, "J1F1R0C0K0P2V0S0", profiles=far)) == ("terra", "high") + assert pair(down) == ("terra", "low") and not down["premium"] + # A premium pair barely costlier than terra high is still left out below top. + near = edited_profiles(tmp_path, {("GPT-9 Astra", "high"): {"run_cost_usd": 91}}) + assert pair(route(narrow, "J1F1R0C0K0P2V0S0", profiles=near)) == ("terra", "high") + + +def test_route_pick_ceilings(tmp_path): + # Fable above medium sets the best score the floors measure from but is never + # picked: middle and top stay on Opus high, and only top+ and its reviews get + # Fable, at low (within 3 points of medium), medium on a --up retry. + available = tmp_path / "available.json" + available.write_text(json.dumps({**json.loads(AVAILABLE.read_text()), "models": [ + {"id": m, "efforts": ["low", "medium", "high", "xhigh", "max"]} + for m in ("fable", "opus", "sonnet", "haiku")]})) + profiles = build_profiles(tmp_path, REPORT) + for scores in ("J1F1R0C0K0P0V0S0", "J1F1R1C1K2P0V0S0", "J2F1R1C2K0P2V1S0"): + assert pair(route(available, scores, profiles=profiles)) == ("opus", "high"), scores + assert pair(route(available, "J0F0R0C0K0P0V0S0", "--review", profiles=profiles)) == ("opus", "high") + hardest = "J1F2R2C2K2P2V1S1" + assert pair(route(available, hardest, profiles=profiles)) == ("fable", "low") + assert pair(route(available, hardest, "--review", profiles=profiles)) == ("fable", "low") + assert pair(route(available, hardest, "--up", "3", profiles=profiles)) == ("fable", "medium") def test_route_speed_gain(offered, tmp_path): From 5f1525a44593bd99507482898d6fdfccf9cdbea1 Mon Sep 17 00:00:00 2001 From: Bryan <28662377+bryanwieg@users.noreply.github.com> Date: Thu, 26 Nov 2026 19:05:19 +0000 Subject: [PATCH 2/2] Tests: keep stub CLIs runnable on a noexec /tmp The tests put stub claude and codex scripts on PATH under pytest's temp directory. On a noexec /tmp (the ai-coding sandbox) the stubs could not run, so the real CLI answered and 36 tests failed. When the temp directory is noexec, conftest.py moves it to the ignored tests/.pytest-tmp and stops git there (GIT_CEILING_DIRECTORIES), so test directories are not taken as part of this repository. A noexec --basetemp is refused instead of silently calling the real CLI. Co-Authored-By: Claude Opus 5.5 --- .gitignore | 1 + plugins/phased-delivery/tests/conftest.py | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 plugins/phased-delivery/tests/conftest.py diff --git a/.gitignore b/.gitignore index 6c56ff1..23f50b6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ __pycache__/ .pytest_cache/ +.pytest-tmp/ diff --git a/plugins/phased-delivery/tests/conftest.py b/plugins/phased-delivery/tests/conftest.py new file mode 100644 index 0000000..52f7348 --- /dev/null +++ b/plugins/phased-delivery/tests/conftest.py @@ -0,0 +1,23 @@ +import os +import tempfile +from pathlib import Path + +import pytest + + +def noexec(path): + return bool(os.statvfs(path).f_flag & os.ST_NOEXEC) + + +def pytest_configure(config): + # The tests put stub claude and codex scripts on PATH. On a noexec temp directory + # (the ai-coding sandbox's /tmp) a stub cannot run and the real CLI answers instead, + # so keep the temp files in the repository's ignored .pytest-tmp. + if config.option.basetemp is None and noexec(tempfile.gettempdir()): + config.option.basetemp = str(Path(__file__).parent / ".pytest-tmp") + # and stop git there, so a test directory is never taken as part of this repository + os.environ["GIT_CEILING_DIRECTORIES"] = config.option.basetemp + base = Path(config.option.basetemp or tempfile.gettempdir()) + base.mkdir(parents=True, exist_ok=True) + if noexec(base): + raise pytest.UsageError(f"{base} is mounted noexec: pass --basetemp on a mount that can run files")