From 354ab494d2817b33e2865f07159a060b9e640ae5 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 3 Oct 2026 08:31:56 +0000 Subject: [PATCH] Re-scope the Shadow window to tier glance; notify auto-merge granted autonomy_log.md records the 2026-10-02 doctrine change: notify auto-merge granted early at 13/40 (all clean), and the Shadow window re-scoped to count tier-glance auto-merges toward 20 clean rows, with any reverted row demoting glance back to a human /prm. REFERENCE.md says who merges per declared Consequence tier. lifecycle.py's close/shadow-row now key on glance (target 20, `reverted` added to the action vocabulary); the notify rows stay listed and are named as uncounted. Tests updated to match. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HGSSTEegN9Sbd2TJ6hj1XL --- REFERENCE.md | 22 +++++- autonomy_log.md | 54 ++++++------- scripts/lifecycle.py | 122 +++++++++++++++++------------- tests/test_autonomy_log_shadow.py | 69 ++++++++--------- tests/test_lifecycle_close.py | 40 +++++----- 5 files changed, 174 insertions(+), 133 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index 7deab0038..88320f8cf 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -474,6 +474,19 @@ faculty at conception and all overridable by declaring them: read the witness, not the diff. `judge` is a PI's call — a public API, a default, an error contract, a science-policy question, an external reporter's request. + + **The declared tier also decides who merges** (2026-10-02, + `PyAutoBrain/AUTONOMY.md` "Merge authority follows Consequence"). `notify`: + the shipping session waits for CI inside its turn, merges on green and runs + the `/prm` close-out itself. `glance`: the same, only when the `Witness:` + check passed; the human reads a post-merge summary, and each auto-merge + appends a row to the Shadow window in `autonomy_log.md` (confirmed at 20 + clean rows; any revert demotes `glance` back to a human `/prm`). `judge`, or + no declared header: the human runs `/prm`, as before. Only a tier **written + in the prompt** carries merge authority — a tier the sizing faculty would + infer for a header-less prompt never does. Never auto-merged at any tier: a + `decision-taken` PR, a Heart RED-override or corrective-PR-exception ship, + red/pending/conflicting CI, or a SKIPPED test leg. - **`Witness:`** free text: the machine-checkable claim that will make this reviewable in minutes rather than by reading the diff. Look at what the fast completion records carry — "ids bit-identical, 62 → 9.7 ms", "31-rule @@ -852,7 +865,7 @@ appends to the window): ```bash python3 scripts/lifecycle.py close --date YYYY-MM-DD --from-file \ [--prompt ] [--pr Repo#N …] \ - [--tier notify --gate "" --action [--stage 1|2]] \ + [--tier glance --gate "" --action [--stage 1|2]] \ [--no-shadow-row] [--apply] ``` @@ -867,9 +880,12 @@ it found — and writes nothing. `--apply` does it. takes a repo-relative path or a bare filename. - **It drops the `parked.md` / `planned.md` pointer too**, which `record` does not — only `active.md` was ever pruned. -- **The shadow row is never inferred.** Only `--tier notify` feeds the window, +- **The shadow row is never inferred.** Only `--tier glance` feeds the window + (re-scoped from `notify` on 2026-10-02, when `notify` auto-merge was granted), and only with `--gate` and `--action`: the row records the gate that *ran* and - what the human *did*, so a missing cell yields no row and a line saying so. + what *happened* to the PR — `merged-unchanged` at an auto-merge, amended by + the human if they later find something substantive, `reverted` if it was + backed out — so a missing cell yields no row and a line saying so. `--no-shadow-row` suppresses the leg outright. - **Two refusals**, both exit 1: a record for the slug already exists anywhere under `complete/` (a completion record is the one file here that is not diff --git a/autonomy_log.md b/autonomy_log.md index d2f3435e5..ad7be3339 100644 --- a/autonomy_log.md +++ b/autonomy_log.md @@ -353,38 +353,40 @@ Outcome ∈ `merged-unchanged` / `amended` / `rejected` / `parked` / The calibration row `ship_library` / `ship_workspace` append at PR-open goes in the table **above**, at the end of its last segment, in date order — never in -the Shadow window below, which is `/prm`'s alone, tier-`notify` only, with a -fixed and tested `human action` vocabulary. +the Shadow window below, which is the close-out's alone, tier-`glance` only +(tier-`notify` until 2026-10-02), with a fixed and tested `human action` +vocabulary. -## Shadow window — the tier-`notify` merge decision +## Shadow window — the tier-`glance` merge decision -Opened **2026-08-30**. **RE-OPENED 2026-09-03**: the nominal 2026-09-27 close is -void. The window is **counted, not dated** — it runs to **40 tier-`notify` -candidates** and re-opens from the first row appended by `/prm` close-out. The -rule's own instruction governs: *extend the window; do not lower the bar*. +**RE-SCOPED 2026-10-02 to tier `glance`.** The human granted `notify` +auto-merge early, by dated doctrine edit (`PyAutoBrain/AUTONOMY.md` "Merge +authority follows Consequence — 2026-10-02"), with this window at **13/40, all clean** — all 12 `/prm`-appended rows +`merged-unchanged`, plus one pre-`/prm` stage-2 row; nothing amended, nothing +reverted. The rest of the evidence cited there: ~200 recent +merged PRs across 8 repos carried 0 reviews and mostly merged under an hour +after opening with 1–2 commits, and the first table above stood at 120 +`merged-unchanged` / 12 `amended` / 2 `rejected` / 2 `reverted`. -Nothing fed the table between 2026-08-31 and the row that re-opens the window, -because the append was anchored to a **batch review slot**. The *two-slot -batching epic* was retired on 2026-09-03 -(`complete/archive/epics/two_slot_batching_epic.md`), but the batch slot door -itself was not: it lives on and runs only when a batch is launched, which on -most days is never. So the append moved to `/prm` close-out — the one act that -happens on every shipped task (PyAutoBrain#364). +From 2026-10-02 the window counts **tier-`glance` auto-merges**: a declared +`Consequence: glance` task whose `Witness:` check passed is merged by its +shipping session on green CI, and its close-out appends one row here, recorded +`merged-unchanged` at merge. The human reads the post-merge summary and +**amends the row** to `merged-after-substantive-change` if they find something +substantive, or to `reverted` if it was backed out. `glance` is **confirmed at +20 clean rows**; **any `reverted` row demotes `glance` back to a human +`/prm`** at once, by dated doctrine edit citing the row. -Protocol, power calculation and the **pre-registered decision rule** live in the -tier-`notify` protocol prompt, folded under `## Original prompt` in -`complete/2026/09/prm-shadow-row-notify-tier.md` — read it before appending, and -before interpreting anything here. +The `notify` history (opened 2026-08-30, re-opened 2026-09-03, fed from `/prm` +close-out since PyAutoBrain#364) stays listed below and is named as uncounted. +Its protocol, power calculation and pre-registered rule are in +`complete/2026/09/prm-shadow-row-notify-tier.md` (under `## Original prompt`). -In one line: while the window runs, tier-`notify` work still waits for the human -as it always has, but the gate's verdict and the human's action are both -recorded, so the question "how often would auto-merge have been wrong on this -organism's own work?" is answered with data rather than intuition. +Count toward 20: 0 (stage 1: 0, stage 2: 0) — window re-scoped to tier `glance` 2026-10-02; first `glance` row: none yet; earlier rows not counted (the tier-`notify` window, closed 2026-10-02, and legacy): 14 -Count toward 40: 13 (stage 1: 12, stage 2: 1) — window re-opened 2026-09-03; first /prm-appended row: 2026-09-09; legacy rows not counted: 1 - -One row per tier-`notify` candidate at close-out. `human action` ∈ -`merged-unchanged` / `merged-after-substantive-change` / `not-merged`. +One row per tier-`glance` candidate at close-out. `human action` ∈ +`merged-unchanged` / `merged-after-substantive-change` / `not-merged` / +`reverted`. **Substantive** is fixed in advance: a change the human would have minded finding already merged — a changed default, a user-visible error message, a removed or weakened test, a renamed public thing, a docs claim that was wrong. diff --git a/scripts/lifecycle.py b/scripts/lifecycle.py index af2073fff..249b892c7 100644 --- a/scripts/lifecycle.py +++ b/scripts/lifecycle.py @@ -26,11 +26,11 @@ removing the active/ prompt. Run `index --apply` afterwards. close --date YYYY-MM-DD --from-file [--prompt ] - [--pr Repo#N ...] [--tier notify --gate "" --action ] + [--pr Repo#N ...] [--tier glance --gate "" --action ] [--no-shadow-row] [--apply] The /prm hook: the whole Mind-side close-out as one verb — `record` (which folds the prompt, refreshes the index and prunes active.md), - plus the parked.md/planned.md pointer, plus the tier-`notify` shadow + plus the parked.md/planned.md pointer, plus the tier-`glance` shadow row, plus the sweep for references the merge falsified (printed, never rewritten). Dry run by default. Unlike `record --prompt` it resolves a draft/ prompt too, and it stages nothing. It does NOT render the @@ -100,27 +100,33 @@ ACTIVE_MD = ROOT / "active.md" AUTONOMY_LOG = ROOT / "autonomy_log.md" -# --- the tier-`notify` shadow window --------------------------------------- -# The pre-registered decision rule (protocol prompt: batch_notify_tier_merge) -# grades tier-`notify` candidates over a window of at least 40 rows. The window -# is COUNTED, not dated: it re-opened on 2026-09-03 and runs from the first row -# `/prm` close-out appended, because the old append was anchored to a batch -# review slot that only runs when a batch is launched. +# --- the tier-`glance` shadow window --------------------------------------- +# The window ran over tier-`notify` candidates (protocol prompt: +# batch_notify_tier_merge, 40 rows) until 2026-10-02, when the human granted +# `notify` auto-merge early at 13/40, all clean, by dated doctrine edit +# (PyAutoBrain/AUTONOMY.md "Merge authority follows Consequence — 2026-10-02") +# and re-scoped the window to tier `glance`: each auto-merged `glance` PR +# appends one row, recorded `merged-unchanged` at merge and amended by the +# human if they find something substantive. `glance` is confirmed at 20 clean +# rows; any `reverted` row demotes the tier back to a human `/prm`. The +# `notify` rows stay listed as history and are named as uncounted. SHADOW_HEADING = "## Shadow window" SHADOW_TABLE_HEADER = "| date | task | tier | gate" +SHADOW_TIER = "glance" SHADOW_ACTIONS = ( "merged-unchanged", "merged-after-substantive-change", "not-merged", + "reverted", ) SHADOW_STAGES = ("1", "2") -SHADOW_TARGET = 40 -SHADOW_REOPENED = "2026-09-03" +SHADOW_TARGET = 20 +SHADOW_REOPENED = "2026-10-02" # Rows dated before this are the pre-`/prm` history: listed, never counted as # "the first row `/prm` appended". SHADOW_PRM_EPOCH = "2026-09-07" -SHADOW_COUNT_PREFIX = "Count toward 40:" -SHADOW_COUNT_ANCHOR = "One row per tier-`notify` candidate" +SHADOW_COUNT_PREFIX = f"Count toward {SHADOW_TARGET}:" +SHADOW_COUNT_ANCHOR = "One row per tier-`glance` candidate" H2_RE = re.compile(r"^##\s+(.+?)\s*$") @@ -2282,7 +2288,7 @@ def _out_of_scope() -> None: # --------------------------------------------------------------------------- # -# the tier-`notify` shadow window (autonomy_log.md) +# the tier-`glance` shadow window (autonomy_log.md) # --------------------------------------------------------------------------- # def _md_cells(line: str) -> "list[str]": """The cells of one markdown table row, honouring escaped pipes. @@ -2345,26 +2351,35 @@ def shadow_rows(text: str) -> "list[list[str]]": def shadow_count_line(rows: "list[list[str]]") -> str: """The section's one-line state of the window, derived from the rows. - Only stage-1 and stage-2 rows count: the window's own rule forbids pooling - the two, and legacy rows carry neither (they predate the stage column's - meaning). They stay listed — deleting history to make a counter tidy is how - a pre-registered rule stops being pre-registered — and are named as - uncounted so the number cannot be read as "the table has N rows". + Only tier-`glance` stage-1 and stage-2 rows dated from the re-scope count: + the window's own rule forbids pooling the two stages, legacy rows carry + neither (they predate the stage column's meaning), and every earlier row + belongs to the tier-`notify` window that closed when `notify` was granted + on 2026-10-02. They all stay listed — deleting history to make a counter + tidy is how a pre-registered rule stops being pre-registered — and are + named as uncounted so the number cannot be read as "the table has N rows". """ - staged = [r for r in rows if len(r) > 5 and r[5] in SHADOW_STAGES] - legacy = len(rows) - len(staged) - one = sum(1 for r in staged if r[5] == "1") - two = sum(1 for r in staged if r[5] == "2") - firsts = sorted(r[0] for r in staged if r[0] >= SHADOW_PRM_EPOCH) + graded = [r for r in rows if shadow_counts(r)] + uncounted = len(rows) - len(graded) + one = sum(1 for r in graded if r[5] == "1") + two = sum(1 for r in graded if r[5] == "2") + firsts = sorted(r[0] for r in graded) first = firsts[0] if firsts else "none yet" - line = (f"{SHADOW_COUNT_PREFIX} {len(staged)} (stage 1: {one}, stage 2: " - f"{two}) — window re-opened {SHADOW_REOPENED}; " - f"first /prm-appended row: {first}") - if legacy: - line += f"; legacy rows not counted: {legacy}" + line = (f"{SHADOW_COUNT_PREFIX} {len(graded)} (stage 1: {one}, stage 2: " + f"{two}) — window re-scoped to tier `{SHADOW_TIER}` " + f"{SHADOW_REOPENED}; first `{SHADOW_TIER}` row: {first}") + if uncounted: + line += (f"; earlier rows not counted (the tier-`notify` window, " + f"closed {SHADOW_REOPENED}, and legacy): {uncounted}") return line +def shadow_counts(row: "list[str]") -> bool: + """Whether one table row counts toward the current window.""" + return (len(row) > 5 and row[5] in SHADOW_STAGES + and row[2] == SHADOW_TIER and row[0] >= SHADOW_REOPENED) + + def _shadow_cell(value: str) -> str: """A pipe inside a cell silently splits the row — trade it for a slash.""" return " ".join(str(value).replace("|", "/").split()) @@ -2398,7 +2413,7 @@ def shadow_apply(text: str, row: str) -> str: def cmd_shadow_row(args) -> int: - """Append one tier-`notify` row to the shadow window (the /prm close-out hook). + """Append one tier-`glance` row to the shadow window (the close-out hook). Dry-run by default: the row and the count line it would produce are printed and nothing is written, because the caller is a skill reading a number back @@ -2436,7 +2451,7 @@ def cmd_shadow_row(args) -> int: # # Shipping a task ends with six chores in a fixed order, and `/prm` spends its # prose telling a session to do each one: write the record, remove the prompt, -# drop the registry entry, append the tier-`notify` shadow row, regenerate +# drop the registry entry, append the tier-`glance` shadow row, regenerate # complete/index.md, repoint what the merge falsified. Every one of them was a # step a session could skip — two of them (the index and the `active.md` prune) # were folded into `record` after exactly that, each following its own @@ -2550,22 +2565,23 @@ def close_references(root: Path, slug: str, rel: str) -> "list[str]": def close_shadow_task(args) -> "tuple[str | None, str]": """(the shadow row's task cell, why there is no row). - The tier-`notify` auto-merge decision is pre-registered over 40 candidates - and the close-out is what feeds the window — but only for tier `notify`, - and only with the gate that actually ran and the answer the human actually - gave. Neither is ever inferred here: a missing cell yields no row and a - line saying so.""" + The tier-`glance` auto-merge confirmation is counted over 20 rows and the + close-out is what feeds the window — but only for tier `glance`, and only + with the gate that actually ran and the action that actually happened (an + auto-merge records `merged-unchanged` at merge; the human amends the row + if they later find something substantive). Neither is ever inferred here: + a missing cell yields no row and a line saying so.""" if getattr(args, "no_shadow_row", False): return None, "suppressed (--no-shadow-row)" tier = (getattr(args, "tier", None) or "").strip().lower() if not tier: - return None, ("skipped — no --tier given (pass `--tier notify` with " - "--gate/--action to feed the shadow window)") - if tier != "notify": - return None, f"skipped — tier `{tier}` is not `notify`" + return None, (f"skipped — no --tier given (pass `--tier {SHADOW_TIER}` " + "with --gate/--action to feed the shadow window)") + if tier != SHADOW_TIER: + return None, f"skipped — tier `{tier}` is not `{SHADOW_TIER}`" if not (args.gate and args.action): - return None, ("tier notify, but --gate/--action are missing — the row " - "records the gate that RAN and what the human DID with " + return None, (f"tier {SHADOW_TIER}, but --gate/--action are missing — " + "the row records the gate that RAN and what happened to " "the PR, and neither is ever invented; run " "`lifecycle.py shadow-row … --apply` once you have them") task = args.slug @@ -2615,7 +2631,7 @@ def cmd_close(args) -> int: row = None if task_cell is not None: row = "| " + " | ".join(_shadow_cell(c) for c in ( - args.date, task_cell, "notify", args.gate, args.action, + args.date, task_cell, SHADOW_TIER, args.gate, args.action, args.stage)) + " |" print(f"close: {args.slug}") @@ -2649,7 +2665,7 @@ def cmd_close(args) -> int: if row is not None: sh = _CloseArgs(log=getattr(args, "log", None), date=args.date, - task=task_cell, tier="notify", gate=args.gate, + task=task_cell, tier=SHADOW_TIER, gate=args.gate, action=args.action, stage=args.stage, apply=True) cmd_shadow_row(sh) @@ -2704,7 +2720,7 @@ def main() -> int: "close", help="the Mind-side close-out for one shipped task, as one verb: " "record + remove the prompt + drop the registry entry + index " - "(+ the tier-`notify` shadow row)", + "(+ the tier-`glance` shadow row)", ) cl.add_argument("slug", help="the task slug being closed out") cl.add_argument("--date", required=True, help="completion date YYYY-MM-DD") @@ -2719,12 +2735,13 @@ def main() -> int: metavar="REF", help="the PR(s) this task shipped (`Repo#N`), named in the " "shadow row's task cell") - cl.add_argument("--tier", help="the task's sizing tier; only `notify` " - "feeds the shadow window") - cl.add_argument("--gate", help="with --tier notify: the gate cell copied " + cl.add_argument("--tier", help="the task's declared Consequence tier; " + "only `glance` feeds the shadow window") + cl.add_argument("--gate", help="with --tier glance: the gate cell copied " "from the task's ship calibration row") cl.add_argument("--action", choices=list(SHADOW_ACTIONS), - help="with --tier notify: what the human did with the PR") + help="with --tier glance: what happened to the PR " + "(`merged-unchanged` at an auto-merge)") cl.add_argument("--stage", default="1", choices=list(SHADOW_STAGES), help="the shadow row's protocol stage (default: 1)") cl.add_argument("--no-shadow-row", action="store_true", dest="no_shadow_row", @@ -2737,21 +2754,22 @@ def main() -> int: sr = sub.add_parser( "shadow-row", - help="append one tier-`notify` row to the shadow window in " + help="append one tier-`glance` row to the shadow window in " "autonomy_log.md (the /prm close-out hook)", ) sr.add_argument("--date", help="merge date YYYY-MM-DD (default: today, UTC)") sr.add_argument("--task", required=True, help="task slug plus the PR refs, e.g. " "'my-task (PyAutoBrain#1 / PR#2)'") - sr.add_argument("--tier", default="notify", - help="the sizing tier (default: notify)") + sr.add_argument("--tier", default=SHADOW_TIER, + help=f"the declared Consequence tier (default: " + f"{SHADOW_TIER})") sr.add_argument("--gate", required=True, help="the gate cell, copied from the task's ship " "calibration row (tests/smoke/review/heart/witness" "[/adversary])") sr.add_argument("--action", required=True, choices=list(SHADOW_ACTIONS), - help="what the human did with the PR") + help="what happened to the PR") sr.add_argument("--stage", default="1", choices=list(SHADOW_STAGES), help="1 = four-leg gate + witness; 2 = plus the " "independent-model adversary leg") diff --git a/tests/test_autonomy_log_shadow.py b/tests/test_autonomy_log_shadow.py index ce83a9962..022f94909 100644 --- a/tests/test_autonomy_log_shadow.py +++ b/tests/test_autonomy_log_shadow.py @@ -1,19 +1,20 @@ -"""Contract tests for the tier-`notify` shadow window and its append hook. +"""Contract tests for the tier-`glance` shadow window and its append hook. -The shadow window is a **pre-registered** decision rule: over a window of at -least 40 tier-`notify` candidates, the human's action at close-out decides -whether an agent may ever merge its own low-consequence work. A pre-registered +The shadow window is a **pre-registered** decision rule. It ran over tier-`notify` +candidates until `notify` auto-merge was granted on 2026-10-02; it now counts +tier-`glance` auto-merges, and 20 clean rows confirm `glance` (any `reverted` +row demotes it). A pre-registered rule that anyone can quietly reshape is not pre-registered, so two things are pinned here: 1. **The live ledger's schema** — heading, header row, six cells per row, an allowed `human action` on every row the rule actually grades, and a count line that agrees with the rows it claims to count. A count line drifting - from its table is the exact failure that would let the window "reach 40" - without 40 candidates. + from its table is the exact failure that would let the window "reach 20" + without 20 candidates. 2. **The append itself** — `lifecycle.py shadow-row` on a fixture: dry run writes nothing, `--apply` appends exactly one row and moves the count, and - an action outside the three allowed values is refused. + an action outside the allowed values is refused. Same two rules as the other lifecycle tests: fictional fixtures only (`tests/**` is KEEP-copied into the public template), and every leg must be shown to fail @@ -55,19 +56,19 @@ |------|------|-----------------|-------|---------| | 2026-08-01 | sprocket-calibration (#1) | safe | tests pass | merged-unchanged | -## Shadow window — the tier-`notify` merge decision +## Shadow window — the tier-`glance` merge decision -Opened **2026-08-30**. +Re-scoped **2026-10-02**. -Count toward 40: 1 (stage 1: 1, stage 2: 0) — window re-opened 2026-09-03; \ -first /prm-appended row: 2026-09-07 +Count toward 20: 1 (stage 1: 1, stage 2: 0) — window re-scoped to tier \ +`glance` 2026-10-02; first `glance` row: 2026-10-02 -One row per tier-`notify` candidate at close-out. +One row per tier-`glance` candidate at close-out. | date | task | tier | gate (tests/smoke/review/heart/witness[/adversary]) \ | human action | stage | |------|------|------|---------|--------------|-------| -| 2026-09-07 | flywheel-tuning (Flywheel#1 / PR#2) | notify | tests 3 pass \ +| 2026-10-02 | flywheel-tuning (Flywheel#1 / PR#2) | glance | tests 3 pass \ | merged-unchanged | 1 | ## Freeze overrides @@ -114,9 +115,9 @@ def test_every_row_carries_all_six_cells(): @needs_window -def test_every_prm_appended_row_records_one_of_the_three_allowed_actions(): +def test_every_prm_appended_row_records_one_of_the_allowed_actions(): """`human action` is a merge outcome, and the decision is a count over - exactly three of them. + exactly these. The boundary is the window's own: rows before the `/prm` epoch were appended at **PR-open** by the retired batch protocol, so their action cell @@ -146,7 +147,7 @@ def test_the_count_line_agrees_with_the_rows_it_counts(): assert m, f"count line does not parse: {line!r}" total, one, two = (int(g) for g in m.groups()) - graded = [r for r in rows if r[5] in lifecycle.SHADOW_STAGES] + graded = [r for r in rows if lifecycle.shadow_counts(r)] assert (total, one, two) == ( len(graded), sum(1 for r in graded if r[5] == "1"), @@ -182,19 +183,19 @@ def test_a_dry_run_leaves_the_file_byte_identical(tmp_path): before committing to it, so the default must not write.""" log = _fixture(tmp_path) before = log.read_bytes() - r = _run(log, "--date", "2026-09-08", "--task", "widget-press (Widget#3)", + r = _run(log, "--date", "2026-10-03", "--task", "widget-press (Widget#3)", "--gate", "tests 4 pass", "--action", "merged-unchanged", "--stage", "1") assert r.returncode == 0, r.stderr assert log.read_bytes() == before - assert "| 2026-09-08 | widget-press (Widget#3) | notify |" in r.stdout - assert "Count toward 40: 2 (stage 1: 2, stage 2: 0)" in r.stdout + assert "| 2026-10-03 | widget-press (Widget#3) | glance |" in r.stdout + assert "Count toward 20: 2 (stage 1: 2, stage 2: 0)" in r.stdout def test_apply_appends_exactly_one_row_and_moves_the_count(tmp_path): log = _fixture(tmp_path) before = lifecycle.shadow_rows(log.read_text()) - r = _run(log, "--date", "2026-09-08", "--task", "widget-press (Widget#3)", + r = _run(log, "--date", "2026-10-03", "--task", "widget-press (Widget#3)", "--gate", "tests 4 pass", "--action", "merged-after-substantive-change", "--stage", "2", "--apply") assert r.returncode == 0, r.stderr @@ -203,18 +204,18 @@ def test_apply_appends_exactly_one_row_and_moves_the_count(tmp_path): after = lifecycle.shadow_rows(text) assert len(after) == len(before) + 1 assert after[:-1] == before, "an existing row was rewritten" - assert after[-1] == ["2026-09-08", "widget-press (Widget#3)", "notify", + assert after[-1] == ["2026-10-03", "widget-press (Widget#3)", "glance", "tests 4 pass", "merged-after-substantive-change", "2"] - assert ("Count toward 40: 2 (stage 1: 1, stage 2: 1) — window re-opened " - "2026-09-03; first /prm-appended row: 2026-09-07") in text + assert ("Count toward 20: 2 (stage 1: 1, stage 2: 1) — window re-scoped " + "to tier `glance` 2026-10-02; first `glance` row: 2026-10-02") in text # the rest of the ledger is untouched assert "## Freeze overrides" in text assert "| 2026-08-01 | sprocket-calibration (#1) |" in text -def test_an_action_outside_the_three_values_is_refused(tmp_path): - """The window counts three outcomes. A fourth would be uncountable, and - the rule is pre-registered over exactly these.""" +def test_an_action_outside_the_allowed_values_is_refused(tmp_path): + """The window counts a fixed set of outcomes. Another would be + uncountable, and the rule is pre-registered over exactly these.""" log = _fixture(tmp_path) before = log.read_bytes() r = _run(log, "--task", "t", "--gate", "g", "--action", "merged-ish", @@ -237,7 +238,7 @@ def test_a_pipe_in_a_cell_cannot_split_the_row(tmp_path): """An unescaped pipe in a free-text cell would silently add a column and push `stage` off the end of the row.""" log = _fixture(tmp_path) - r = _run(log, "--date", "2026-09-08", "--task", "widget | press", + r = _run(log, "--date", "2026-10-03", "--task", "widget | press", "--gate", "tests pass | smoke n/a", "--action", "not-merged", "--stage", "1", "--apply") assert r.returncode == 0, r.stderr @@ -261,18 +262,18 @@ def test_the_count_line_is_created_when_the_section_has_none(tmp_path): """A window that predates the count line still gets one, anchored before the paragraph that defines the rows.""" body = FIXTURE.replace( - "Count toward 40: 1 (stage 1: 1, stage 2: 0) — window re-opened " - "2026-09-03; first /prm-appended row: 2026-09-07\n\n", "") + "Count toward 20: 1 (stage 1: 1, stage 2: 0) — window re-scoped to " + "tier `glance` 2026-10-02; first `glance` row: 2026-10-02\n\n", "") assert lifecycle.SHADOW_COUNT_PREFIX not in body log = _fixture(tmp_path, body) - r = _run(log, "--date", "2026-09-08", "--task", "widget-press", + r = _run(log, "--date", "2026-10-03", "--task", "widget-press", "--gate", "tests pass", "--action", "not-merged", "--stage", "1", "--apply") assert r.returncode == 0, r.stderr text = log.read_text() count = next(ln for ln in text.splitlines() if ln.startswith(lifecycle.SHADOW_COUNT_PREFIX)) - assert "Count toward 40: 2" in count + assert "Count toward 20: 2" in count idx = text.index(count) assert idx < text.index(lifecycle.SHADOW_COUNT_ANCHOR) @@ -287,11 +288,11 @@ def test_legacy_rows_are_listed_but_never_counted(tmp_path): "| 2026-08-31 | old-flywheel-run | supervised | tests pass " "| PR #9 opened, merged later | shipped |\n") log = _fixture(tmp_path, body) - r = _run(log, "--date", "2026-09-08", "--task", "widget-press", + r = _run(log, "--date", "2026-10-03", "--task", "widget-press", "--gate", "tests pass", "--action", "not-merged", "--stage", "1", "--apply") assert r.returncode == 0, r.stderr text = log.read_text() assert "| 2026-08-31 | old-flywheel-run |" in text - assert "Count toward 40: 2 (stage 1: 2, stage 2: 0)" in text - assert "legacy rows not counted: 1" in text + assert "Count toward 20: 2 (stage 1: 2, stage 2: 0)" in text + assert "and legacy): 1" in text diff --git a/tests/test_lifecycle_close.py b/tests/test_lifecycle_close.py index 72d35e76f..b268090f4 100644 --- a/tests/test_lifecycle_close.py +++ b/tests/test_lifecycle_close.py @@ -18,6 +18,8 @@ from pathlib import Path from types import SimpleNamespace +import pytest + sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts")) import lifecycle # noqa: E402 @@ -29,16 +31,16 @@ SHADOW_LOG = """\ # Autonomy calibration log -## Shadow window — the tier-`notify` merge decision +## Shadow window — the tier-`glance` merge decision -Count toward 40: 0 (stage 1: 0, stage 2: 0) +Count toward 20: 0 (stage 1: 0, stage 2: 0) -One row per tier-`notify` candidate at close-out. +One row per tier-`glance` candidate at close-out. | date | task | tier | gate (tests/smoke/review/heart/witness[/adversary]) \ | human action | stage | |------|------|------|---------|--------------|-------| -| 2026-09-07 | flywheel-tuning (Flywheel#1) | notify | tests 3 pass \ +| 2026-10-02 | flywheel-tuning (Flywheel#1) | glance | tests 3 pass \ | merged-unchanged | 1 | """ @@ -255,39 +257,41 @@ def test_it_refuses_a_bad_date_and_a_missing_body(tmp_path, monkeypatch, # --------------------------------------------------------------------------- # # the shadow window leg # --------------------------------------------------------------------------- # -def test_tier_notify_with_a_gate_and_an_action_appends_one_row(tmp_path, +def test_tier_glance_with_a_gate_and_an_action_appends_one_row(tmp_path, monkeypatch): root = _mind(tmp_path) _at(monkeypatch, root) assert lifecycle.cmd_close(_args( - root, apply=True, tier="notify", gate="tests 3 pass", - action="merged-unchanged", pr=["Flywheel#8"])) == 0 + root, apply=True, tier="glance", gate="tests 3 pass", + action="merged-unchanged", pr=["Flywheel#8"], date="2026-10-03")) == 0 log = (root / "autonomy_log.md").read_text() - assert "sprocket-calibration (Flywheel#8)" in log - assert "Count toward 40: 2" in log + assert "sprocket-calibration (Flywheel#8) | glance |" in log + assert "Count toward 20: 2" in log -def test_a_tier_that_is_not_notify_appends_nothing(tmp_path, monkeypatch): - """Anything but `notify` is outside the pre-registered window: no row, no - question, no ledger line.""" +@pytest.mark.parametrize("tier", ["notify", "judge"]) +def test_a_tier_that_is_not_glance_appends_nothing(tier, tmp_path, monkeypatch): + """Anything but `glance` is outside the window — `notify` included, since + `notify` auto-merge was granted on 2026-10-02 and its window closed: no + row, no question, no ledger line.""" root = _mind(tmp_path) _at(monkeypatch, root) before = (root / "autonomy_log.md").read_text() assert lifecycle.cmd_close(_args( - root, apply=True, tier="glance", gate="tests 3 pass", + root, apply=True, tier=tier, gate="tests 3 pass", action="merged-unchanged")) == 0 assert (root / "autonomy_log.md").read_text() == before -def test_tier_notify_without_a_gate_writes_no_row_and_says_why(tmp_path, +def test_tier_glance_without_a_gate_writes_no_row_and_says_why(tmp_path, monkeypatch, capsys): - """The row records the gate that RAN and what the human DID — inventing - either is the one thing the protocol cannot survive.""" + """The row records the gate that RAN and what HAPPENED to the PR — + inventing either is the one thing the protocol cannot survive.""" root = _mind(tmp_path) _at(monkeypatch, root) before = (root / "autonomy_log.md").read_text() - assert lifecycle.cmd_close(_args(root, apply=True, tier="notify")) == 0 + assert lifecycle.cmd_close(_args(root, apply=True, tier="glance")) == 0 assert (root / "autonomy_log.md").read_text() == before assert "--gate/--action are missing" in capsys.readouterr().out @@ -297,7 +301,7 @@ def test_no_shadow_row_suppresses_the_leg_outright(tmp_path, monkeypatch): _at(monkeypatch, root) before = (root / "autonomy_log.md").read_text() assert lifecycle.cmd_close(_args( - root, apply=True, tier="notify", gate="tests 3 pass", + root, apply=True, tier="glance", gate="tests 3 pass", action="merged-unchanged", no_shadow_row=True)) == 0 assert (root / "autonomy_log.md").read_text() == before