Skip to content

Commit c8d783f

Browse files
release-consistency: the archived-change validation fails closed in release mode
Council pass 10, seats gpt-5.6-sol and gpt-5.6-luna, reproduced (RED test output: "SKIPPED — NOT VERIFIED … release consistency passed for studyloop 1.2.3"): - With newly archived changes since the last tag, a resolver that is missing or reports SKIPPED is now a ValueError, not a print-and-return. Release mode is the moment the check exists for; the contributor-machine skip belongs to `just spec-check`, not here. The two early returns that predate the resolver (no tag; no new archives) are unchanged, so the fixture repos in the existing tests still pass. - The pin handed to the resolver is always the Justfile's; the caller's `OPENSPEC_VERSION` environment variable is no longer consulted, so a stale shell export cannot validate the archive against another release. Three RED-first tests with a stand-in resolver (skip -> exit 1; missing -> exit 1 naming the script; env 9.9.9 -> the resolver sees 1.14.1). 29 tests across the release script and gate.
1 parent 218b5fb commit c8d783f

2 files changed

Lines changed: 108 additions & 14 deletions

File tree

‎packages/studyloop/tests/test_release_consistency_script.py‎

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,3 +383,90 @@ def test_release_mode_refuses_an_empty_folded_deferral(tmp_path: Path) -> None:
383383
assert result.returncode == 1
384384
assert "neither archived nor deferred" in result.stderr
385385
assert "some-change" in result.stderr
386+
387+
388+
# ---------------------------------------------------------------------------
389+
# Pass 10 of the 2026-10 review (seats gpt-5.6-sol and gpt-5.6-luna): the
390+
# archived-change validation runs through scripts/openspec-cli.sh. In release
391+
# mode a skip is not a pass -- the release is the moment the check exists for --
392+
# and the pinned version is the Justfile's, never an environment variable's.
393+
# ---------------------------------------------------------------------------
394+
395+
396+
def _write_archived_change_fixture(tmp_path: Path, resolver_body: str) -> None:
397+
"""A tagged repo, then a post-tag commit adding one ARCHIVED change, with a
398+
stand-in `scripts/openspec-cli.sh` whose behaviour the test controls."""
399+
_write_release_fixture(tmp_path, "1.2.3", "2026-09-06")
400+
(tmp_path / "Justfile").write_text(
401+
'export OPENSPEC_VERSION := "1.14.1"\n\nspec-check:\n true\n', encoding="utf-8"
402+
)
403+
scripts = tmp_path / "scripts"
404+
scripts.mkdir()
405+
resolver = scripts / "openspec-cli.sh"
406+
resolver.write_text(resolver_body, encoding="utf-8")
407+
resolver.chmod(0o755)
408+
init_git_repo_with_tag(tmp_path, tag="v1.2.3", tag_date="2026-09-06")
409+
archived = tmp_path / "openspec" / "changes" / "archive" / "2026-09-07-shipped-thing"
410+
archived.mkdir(parents=True)
411+
(archived / "proposal.md").write_text("# proposal\n", encoding="utf-8")
412+
subprocess.run(["git", "add", "-A"], cwd=tmp_path, check=True, capture_output=True)
413+
subprocess.run(
414+
["git", "commit", "-q", "-m", "archive change"],
415+
cwd=tmp_path,
416+
check=True,
417+
capture_output=True,
418+
text=True,
419+
)
420+
421+
422+
def test_release_mode_fails_closed_when_the_archived_validation_is_skipped(
423+
tmp_path: Path,
424+
) -> None:
425+
_write_archived_change_fixture(
426+
tmp_path, "#!/usr/bin/env bash\necho 'SKIPPED — NOT VERIFIED: no openspec here'\nexit 0\n"
427+
)
428+
result = run_release_check(tmp_path)
429+
assert result.returncode == 1, result.stdout + result.stderr
430+
assert "SKIPPED" in result.stderr or "not verified" in result.stderr.lower()
431+
assert "release consistency passed" not in result.stdout
432+
433+
434+
def test_release_mode_fails_closed_when_the_resolver_is_missing_but_archives_are_new(
435+
tmp_path: Path,
436+
) -> None:
437+
_write_archived_change_fixture(tmp_path, "#!/usr/bin/env bash\nexit 0\n")
438+
(tmp_path / "scripts" / "openspec-cli.sh").unlink()
439+
result = run_release_check(tmp_path)
440+
assert result.returncode == 1, result.stdout + result.stderr
441+
assert "openspec-cli.sh" in result.stderr
442+
443+
444+
def test_archived_validation_passes_the_justfile_pin_and_ignores_the_environment(
445+
tmp_path: Path,
446+
) -> None:
447+
"""The resolver is told the Justfile's pin even when the caller's environment carries
448+
another OPENSPEC_VERSION (a stale shell export must not validate another release)."""
449+
seen = tmp_path / "seen-version.txt"
450+
_write_archived_change_fixture(
451+
tmp_path,
452+
"#!/usr/bin/env bash\n"
453+
f'printf "%s" "$OPENSPEC_VERSION" > "{seen}"\n'
454+
'echo \'{"items": [{"id": "2026-09-07-shipped-thing", "valid": true}]}\'\n',
455+
)
456+
argv = [
457+
sys.executable,
458+
str(SCRIPT),
459+
"--repo-root",
460+
str(tmp_path),
461+
"--skip-wheel",
462+
"--release",
463+
]
464+
result = subprocess.run(
465+
argv,
466+
check=False,
467+
text=True,
468+
capture_output=True,
469+
env={**os.environ, "OPENSPEC_VERSION": "9.9.9"},
470+
)
471+
assert result.returncode == 0, result.stdout + result.stderr
472+
assert seen.read_text(encoding="utf-8") == "1.14.1"

‎scripts/check-release-consistency.py‎

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -236,21 +236,14 @@ def validate_new_archives(repo_root: Path) -> None:
236236
to ignore the gate. (The July archive that motivated the scoping was
237237
reconciled against the tree on 2026-09-23; ``--archived --all`` is green
238238
today, and the scoping stays.) Runs the CLI through ``scripts/openspec-cli.sh``
239-
at the pinned ``OPENSPEC_VERSION`` and reads its ``--json`` report; when the
240-
resolver cannot run the pinned CLI it prints SKIPPED locally (and fails under
241-
CI) — the same convention as ``just spec-check``.
239+
at the Justfile's pinned ``OPENSPEC_VERSION`` and reads its ``--json`` report.
240+
Unlike ``just spec-check`` (which may skip on a contributor's machine), release
241+
mode fails closed: with newly archived changes to judge, a resolver that is
242+
missing or reports SKIPPED is an error, not a pass.
242243
"""
243244
import os
244245

245246
resolver = repo_root / "scripts" / "openspec-cli.sh"
246-
if not resolver.is_file():
247-
print("scripts/openspec-cli.sh missing — skipping archived-change validation")
248-
return
249-
env = {
250-
**os.environ,
251-
"OPENSPEC_VERSION": os.environ.get("OPENSPEC_VERSION")
252-
or _openspec_version_from_justfile(repo_root),
253-
}
254247
try:
255248
last_tag = _git(repo_root, "describe", "--tags", "--abbrev=0")
256249
except subprocess.CalledProcessError:
@@ -265,6 +258,18 @@ def validate_new_archives(repo_root: Path) -> None:
265258
if not new_names:
266259
return
267260

261+
# From here on a release is being cut with newly archived changes: the check must RUN.
262+
# A skip is not a pass (pass 10, seat gpt-5.6-sol): before this, a machine without the
263+
# pinned CLI printed SKIPPED and then "release consistency passed".
264+
if not resolver.is_file():
265+
raise ValueError(
266+
"scripts/openspec-cli.sh is missing, so the newly archived change(s) "
267+
f"{', '.join(new_names)} cannot be validated; release mode does not skip this check"
268+
)
269+
# The pin is the Justfile's, never the caller's environment (pass 10, seat gpt-5.6-luna):
270+
# a stale `OPENSPEC_VERSION` export must not validate the archive against another release.
271+
env = {**os.environ, "OPENSPEC_VERSION": _openspec_version_from_justfile(repo_root)}
272+
268273
proc = subprocess.run(
269274
["bash", str(resolver), "validate", "--archived", "--all", "--no-interactive", "--json"],
270275
cwd=repo_root,
@@ -275,9 +280,11 @@ def validate_new_archives(repo_root: Path) -> None:
275280
env=env,
276281
)
277282
if proc.stdout.lstrip().startswith("SKIPPED"):
278-
# the resolver could not run the pinned CLI locally (never under CI, where it exits 1)
279-
print(proc.stdout.strip())
280-
return
283+
raise ValueError(
284+
"openspec archived-change validation did not run (the resolver reported "
285+
f"{proc.stdout.strip()!r}); release mode needs the pinned openspec CLI — install it, "
286+
"or make node available so npx can fetch it"
287+
)
281288
if proc.returncode not in (0, 1):
282289
raise ValueError(
283290
f"openspec archived-change validation could not run (exit {proc.returncode}): "

0 commit comments

Comments
 (0)