diff --git a/.github/ci/delivery-v13.md b/.github/ci/delivery-v13.md index 0cc7aac9..2967f7f7 100644 --- a/.github/ci/delivery-v13.md +++ b/.github/ci/delivery-v13.md @@ -1,8 +1,8 @@ -# Prepared v1.3 delivery: disabled +# Staged v1.3 delivery: disabled `delivery-v13-policy.json` is **false**. The existing claude-current scope is -unchanged. v1.3 ordinary PR/main CI remains full, and no v1.3 queue is configured -or admitted by this source change. The shadow observer still cannot grant skips, +unchanged. v1.3 ordinary PR/main CI remains full. The separate manual queue is +configured but no member is admitted by this source change. The shadow observer still cannot grant skips, qualification, admission or merge authority. ## Prepared proof boundary @@ -14,8 +14,12 @@ enablement it requires all of: - P01 #88 at its exact projected head, actually merged into main, with the frozen required-PostgreSQL workflow/baseline and unchanged foundation files and empty P01 markers. The original 13 integration jobs are not replaced. -- The exact projected source PR/head/branch, original single P01 parent and - complete regular-file/empty-marker cut. No arbitrary v1.3 PR qualifies. +- The exact projected source PR/head/branch and complete regular-file/empty-marker + cut. The default is one P01 child. An optional trusted `source.commits` list + pins one to three unique full SHAs ending at `source.head`; every commit must + have exactly the previous registered parent, starting at P01, and every + cumulative prefix must obey the same cut. No unpinned fix, merge, reordered + history or temporary off-scope revision qualifies. No arbitrary v1.3 PR qualifies. - An open, ready, same-repository source targeting current main, with its dependency independently resolved by the owner. The preparer does not edit, rebase, retarget or merge lane-owned PRs. @@ -45,14 +49,43 @@ admission. Policy/foundation changes after qualification retain full main CI. This is checked **disabled source preparation**, not a live acceptance receipt. The full-CI parity caller additionally watches the new validator, policy, runbook and tests; its jobs and the parameterless complete suite are unchanged. -No release workflow is touched. Mergify configuration is unchanged. +No release workflow is touched. The four existing queues are unchanged. + +## Staged manual queue + +`openrepotools-sql-register-v13` is manual-only, writer-requested, serial and +limited to at most two members, with no failure splitting or automatic retries. +It uses queue protection injection, not `none` or `merge`. Entry filters require +main-targeted same-repository ready sources, supported P03/P05 v1.3 headers, +test-module/marker paths and app-qualified fast/delivery success. These coarse +filters are NOT exact-head profile acceptance. The trusted source/candidate +verifier still independently checks the registered head, lineage, full cut, +prerequisite, review, fast evidence, live rereads and complete heavy artifacts. +The queue cannot merge without app-qualified `openrepotools-batch-heavy` success. +While the actual delivery flag is false, v1.3 candidate proof refuses. +The false flag blocks qualification and merge through this heavy-held queue, +not a repository writer's ability to request preliminary manual queue entry. +Such a request remains unauthorized during staging. The queue is not claimed +to be mechanically inert; no automatic entry or independent admission-consent +status is introduced or inferred from its coarse filters. + +No queue command is authorized by this staged source. Under subsequent reviewed +enablement, the operator must verify fresh owner consent for the exact two +heads, use only this named queue for fast-only sources and keep both members +stable through qualification. The service's batch size/wait alone does not +guarantee an exact two-member selection; live proof must show the actual members +and one accepted heavy run. A fast/delivery check is never direct-merge authority. Before any future activation: reconcile current owner cuts/plan and P01, require actual required-engine qualification, review the narrow enablement/manual-queue configuration, confirm effective protection and service readiness, and obtain -explicit activation/canary authority. A manual queue must hold complete heavy +fresh exact-head owner consent under the approved staged rollout. A manual queue must hold complete heavy qualification; a fast-only source must never be direct-merged on delivery success. -No queue command is supplied or authorized at this stage. +No queue command is supplied or authorized at this stage. Owner full-CI product +batches are not the efficiency canary and must not be held for it. If such a +batch changes the frozen foundation, efficiency remains full until a separate +reviewed foundation revision and real required-engine qualification; never +silently relax or rehash the freeze to follow main. Live acceptance must show fast-only source and candidate PR CI, exactly one complete heavy caller per accepted batch, no duplicate full main run, and matching diff --git a/.github/ci/delivery_v13.py b/.github/ci/delivery_v13.py index e71890b4..11b852f6 100644 --- a/.github/ci/delivery_v13.py +++ b/.github/ci/delivery_v13.py @@ -48,12 +48,10 @@ def cut(root, base, head): raise ValueError("Unrecognized v1.3 source head") name, profile = matches[0] parent = policy["prerequisite"]["head"] - if common.git(root, "show", "-s", "--format=%P", head).decode().split() != [parent]: - raise ValueError("V1.3 source parent differs") + if not projection.source_lineage(root, parent, profile): + raise ValueError("V1.3 source lineage differs") paths = profile["files"] + [projection.MARKERS + task for task in profile["tasks"]] common.git(root, "diff", "--quiet", "--no-ext-diff", parent, base, "--", *paths) - if not projection.scoped_diff(root, parent, head, profile): - raise ValueError("V1.3 source diff differs") return policy, name, profile diff --git a/.github/ci/task-set-delivery.md b/.github/ci/task-set-delivery.md index d9bc09bc..cfcd5945 100644 --- a/.github/ci/task-set-delivery.md +++ b/.github/ci/task-set-delivery.md @@ -10,6 +10,9 @@ separate evidence/authority gates. All other work retains full CI. The [prepared v1.3 delivery path](delivery-v13.md) is independently **disabled**. Its source publication grants no v1.3 omission, queue admission or owner-PR edit. +The staged `openrepotools-sql-register-v13` queue holds complete heavy proof; +its existence does not turn on the independent false flag. Exact reviewed +linear fix history may be pinned, never inferred from an owner's moving head. P01 and owner dependency resolution, reviewed enablement/queue configuration and separately approved live qualification must precede adoption. Preserve lanes 1–5. diff --git a/.github/ci/v13-shadow.md b/.github/ci/v13-shadow.md index a5cdedbf..043f7a7c 100644 --- a/.github/ci/v13-shadow.md +++ b/.github/ci/v13-shadow.md @@ -4,7 +4,11 @@ This is not an efficiency activation. Ordinary full CI remains required on every existing event. The parameterless full-CI qualification caller still runs every original job when these control files change. No delivery router, verifier, queue or required check consumes the observer's output. Existing claude-current -behavior is unchanged. There is no new queue or permission to omit work. +behavior is unchanged. The observer itself adds no queue or permission to omit +work. A [separate manual v1.3 queue](delivery-v13.md#staged-manual-queue) is now +staged; it does not consume observer output or turn the false delivery flag on. +Its preliminary entry filters and operator-consent boundary are separate from +the trusted heavy qualification required before that queue can merge. The canonical proposal, design, requirements and implementation checklist live in the spec leg at `openspec/changes/qualify-v13-taskset-ci/`. This projection is @@ -46,6 +50,10 @@ The disabled projections additionally bind the observed real cuts: Both source heads have exactly one parent: P01's pinned source head. Their owners' real branches, bases and metadata are not rewritten by this observer. +An explicitly reviewed future `source.commits` binding may pin one to three +linear commits as described in the delivery runbook; every exact parent and +cumulative cut is checked. Missing lineage keeps the original single-child +rule. A new owner commit is never followed automatically. Coordination for this follow-up is assembly issue165 comment6889436296. These bindings record provenance, not review acceptance or approved task-set authority. diff --git a/.github/ci/v13_shadow.py b/.github/ci/v13_shadow.py index 98936ebf..0fc43156 100644 --- a/.github/ci/v13_shadow.py +++ b/.github/ci/v13_shadow.py @@ -48,13 +48,20 @@ def read_policy(root, main): raise ValueError("Unexpected proposed cuts") for profile in policy["profiles"].values(): source = profile["source"] - if (set(source) != {"number", "head", "branch"} + if (set(source) not in ({"number", "head", "branch"}, {"number", "head", "branch", "commits"}) or type(source["number"]) is not int or source["number"] < 1 or source["number"] == prerequisite["number"] or not common.valid_branch(source["branch"]) or not common.source_branch(source["branch"])): raise ValueError("Invalid source binding") common.sha(source["head"]) + commits = source.get("commits", [source["head"]]) + if (not isinstance(commits, list) or not 1 <= len(commits) <= 3 + or any(not isinstance(commit, str) for commit in commits) + or len(set(commits)) != len(commits) or commits[-1] != source["head"]): + raise ValueError("Invalid source lineage") + for commit in commits: + common.sha(commit) for key, pattern in (("tasks", r"T[0-9]{3}"), ("files", r"tests/test_sql_register_[a-z_]+[.]py")): values = profile[key] @@ -135,8 +142,19 @@ def p01_status(root, main, policy, pr): return "merged-contract-observed" +def source_lineage(root, parent, profile): + """Only the trusted, bounded exact history; check every cumulative cut.""" + previous = parent + for commit in profile["source"].get("commits", [profile["source"]["head"]]): + if (common.git(root, "show", "-s", "--format=%P", commit).decode().split() != [previous] + or not scoped_diff(root, parent, commit, profile)): + return False + previous = commit + return True + + def known_child(root, main, policy, cut, pr, prerequisite): - """One immutable P01 child only; this is not a merge or qualification proof.""" + """One immutable P01 cut only; this is not a merge or qualification proof.""" profile = policy["profiles"][cut] source = profile["source"] if (type(pr["number"]) is not int or pr["number"] != source["number"] @@ -151,11 +169,9 @@ def known_child(root, main, policy, cut, pr, prerequisite): r"(?im)^[ \t]*Depends-On:[ \t]*([^\n]*)", pr.get("body") or "")] if dependencies != ["#88"] and not (base == (main, "main") and not dependencies): return False - if common.git(root, "show", "-s", "--format=%P", source["head"]).decode().split() != [parent]: - return False paths = profile["files"] + [MARKERS + task for task in profile["tasks"]] common.git(root, "diff", "--quiet", "--no-ext-diff", parent, main, "--", *paths) - return scoped_diff(root, parent, source["head"], profile) + return source_lineage(root, parent, profile) def observe_pr(env, event, root, main, policy, request, prerequisite): diff --git a/.mergify.yml b/.mergify.yml index 302366ba..357b7192 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -140,3 +140,31 @@ queue_rules: - check-success=@github-actions/openrepotools-delivery merge_conditions: - check-success=@github-actions/openrepotools-batch-heavy + + # Staged manual test-only scope. The independent delivery flag remains false; + # no automatic entry or owner opt-in follows from adding this queue. + - name: openrepotools-sql-register-v13 + branch_protection_injection_mode: queue + batch_size: 2 + batch_max_wait_time: 60 seconds + batch_max_failure_resolution_attempts: 0 + max_checks_retries: 0 + checks_timeout: 90 minutes + merge_method: merge + queue_conditions: + - -draft + - -closed + - -from-fork + - base=main + - 'head~=^(?!main\Z|release/|verify/|mergify/)[A-Za-z0-9][A-Za-z0-9._/-]*\Z' + - 'body~=(?m)^CI-Shadow: sql-register-v13[ \t\r]*$' + - 'body~=(?m)^CI-Delivery: sql-register-v13[ \t\r]*$' + - 'body~=(?m)^CI-Task-Set: P(?:03|05)[ \t\r]*$' + - '-body~=(?im)^[ \t]*Depends-On:' + - '#files>=2' + - '#files<=6' + - '-files~=^(?!(?:tests/test_sql_register_[a-z_]+[.]py|tests/sql_register_landed/T[0-9]{3})\Z)' + - check-success=@github-actions/openrepotools-pr-fast + - check-success=@github-actions/openrepotools-delivery + merge_conditions: + - check-success=@github-actions/openrepotools-batch-heavy diff --git a/tests/test_ci_pilot_queue.py b/tests/test_ci_pilot_queue.py index d125d0e1..1f740205 100644 --- a/tests/test_ci_pilot_queue.py +++ b/tests/test_ci_pilot_queue.py @@ -90,7 +90,7 @@ def test_manual_mergify_queue_is_bounded_and_has_no_automatic_admission(config): "reset_on_external_merge": "always", "skip_intermediate_results": False} assert [q["name"] for q in config["queue_rules"]] == [ "openrepotools-docs-pilot", "openrepotools-real-code-35-36", "openrepotools-code", - "openrepotools-claude-current"] + "openrepotools-claude-current", "openrepotools-sql-register-v13"] queue = config["queue_rules"][0] assert queue["name"] == "openrepotools-docs-pilot" assert queue["batch_size"] == 2 diff --git a/tests/test_ci_v13_delivery.py b/tests/test_ci_v13_delivery.py index ee3e3453..c89a7971 100644 --- a/tests/test_ci_v13_delivery.py +++ b/tests/test_ci_v13_delivery.py @@ -10,7 +10,8 @@ import pytest -from conftest import REPO +from conftest import NEEDS_UPSTREAM, REPO +from test_ci_pilot_queue import reader as yaml_reader, matches from test_ci_delivery import (batch, base_changes, commit, delivery, git, request_for, threads, verify) from test_ci_cutover import (cutover, duplicate_fixture, enable_fixture, install_artifact, @@ -51,12 +52,21 @@ def v13_batch(batch, cutover, v13, request): for task in profile["tasks"]: write(root, projection.MARKERS + task, "") head = commit(root, name) + lineage = [head] + if type(getattr(request, "param", None)) is int: + for index in range(request.param - 1): + write(root, profile["files"][0], f"# {name} reviewed fix {index}\n") + head = commit(root, f"{name} reviewed fix {index}") + lineage.append(head) heads.append(head) profile["source"] = {"number": number, "head": head, "branch": "feature/" + str(number)} + if len(lineage) > 1: + profile["source"]["commits"] = lineage git(root, "checkout", "-q", "--detach", foundation) write(root, projection.CONFIG, json.dumps(policy)) write(root, v13.CONFIG, json.dumps({"schema_version": 1, "scope": v13.SCOPE, - "enabled": getattr(request, "param", True)})) + "enabled": request.param if hasattr(request, "param") + and type(request.param) is bool else True})) write(root, ".github/ci/delivery-policy.json", '{"schema_version":1,"enabled":true}') write(root, "unrelated-later-main", "preserve later main\n") base = commit(root, "later trusted main") @@ -122,6 +132,66 @@ def test_ci_v13_delivery_committed_policy_disabled_and_legacy_unchanged(v13, cut assert v13.projection.read_policy(REPO, "HEAD")["efficiency_enabled"] is False +@NEEDS_UPSTREAM +def test_ci_v13_delivery_manual_queue_is_heavy_held_and_preserves_existing_queues(yaml_reader): + import hashlib + config = yaml_reader(REPO / ".mergify.yml") + assert set(config) == {"merge_queue", "commands_restrictions", "queue_rules"} + assert config["commands_restrictions"]["queue"]["conditions"] == ["sender-permission>=write"] + assert hashlib.sha256(json.dumps(config["queue_rules"][:4], sort_keys=True, + separators=(",", ":")).encode()).hexdigest() == "7b9279424e5552fdee67d1a943adbc95af30c8c7a28889fd5d4f9be6e38097f3" + queue = config["queue_rules"][4] + assert queue["name"] == "openrepotools-sql-register-v13" + assert queue["branch_protection_injection_mode"] == "queue" + assert queue["batch_size"] == 2 and queue["batch_max_wait_time"] == "60 seconds" + assert queue["batch_max_failure_resolution_attempts"] == queue["max_checks_retries"] == 0 + assert queue["checks_timeout"] == "90 minutes" and queue["merge_method"] == "merge" + assert not queue.get("allow_queue_branch_edit", False) + assert queue["merge_conditions"] == ["check-success=@github-actions/openrepotools-batch-heavy"] + + +@pytest.fixture +def v13_queue_source(): + return {"draft": False, "closed": False, "from-fork": False, + "head": "007-p03-import-cutover-operator-tools", "base": "main", + "body": "CI-Shadow: sql-register-v13\nCI-Delivery: sql-register-v13\nCI-Task-Set: P03", + "files": ["tests/test_sql_register_import.py", "tests/sql_register_landed/T211"], + "check-success": ["@github-actions/openrepotools-pr-fast", "@github-actions/openrepotools-delivery"]} + + +@NEEDS_UPSTREAM +@pytest.mark.parametrize("failure", [None, "foundation", "control", "product", "missing-fast", "other-app", + "missing-delivery", "no-heavy", "wrong-heavy-app", "fork", "draft", "closed", "dependency", "base", + "reserved-branch", "unknown-task", "wrong-scope", "too-many-files", "empty"]) +def test_ci_v13_delivery_manual_queue_refusal_vectors(yaml_reader, v13_queue_source, failure): + context = v13_queue_source + queue = yaml_reader(REPO / ".mergify.yml")["queue_rules"][4] + if failure in {"foundation", "control", "product"}: + context["files"].append({"foundation": "tests/pgcluster.py", "control": ".mergify.yml", + "product": "lanes-index"}[failure]) + elif failure in {"missing-fast", "missing-delivery"}: + context["check-success"].remove("@github-actions/openrepotools-" + ( + "pr-fast" if failure == "missing-fast" else "delivery")) + elif failure == "other-app": context["check-success"] = ["@other/pr-fast", "@other/delivery"] + elif failure in {"fork", "draft", "closed"}: + context["from-fork" if failure == "fork" else failure] = True + elif failure == "dependency": context["body"] += "\n depends-on: #88" + elif failure == "base": context["base"] = "p01" + elif failure == "reserved-branch": context["head"] = "verify/preview" + elif failure == "unknown-task": context["body"] = context["body"].replace("P03", "P02") + elif failure == "wrong-scope": context["body"] = context["body"].replace("sql-register-v13", "claude-current") + elif failure == "too-many-files": context["files"] *= 4 + elif failure == "empty": context["files"] = [] + eligible = all(matches(condition, context) for condition in queue["queue_conditions"]) + assert eligible is (failure in {None, "no-heavy", "wrong-heavy-app"}) + if failure in {"no-heavy", "wrong-heavy-app"}: + if failure == "wrong-heavy-app": context["check-success"].append("@other/openrepotools-batch-heavy") + assert not all(matches(condition, context) for condition in queue["merge_conditions"]) + elif failure is None: + context["check-success"].append("@github-actions/openrepotools-batch-heavy") + assert all(matches(condition, context) for condition in queue["merge_conditions"]) + + def test_ci_v13_delivery_fixture_source_uses_test_merge_without_rewriting_owner_head(cutover, v13_batch): batch = v13_batch assert git(batch["root"], "merge-base", batch["base"], batch["heads"][0]) == batch["foundation"] @@ -130,6 +200,53 @@ def test_ci_v13_delivery_fixture_source_uses_test_merge_without_rewriting_owner_ assert "queue_admission" not in result +@pytest.mark.parametrize("v13_batch", [2, 3], indirect=True) +def test_ci_v13_delivery_reviewed_linear_fixes_keep_all_proof_gates(cutover, delivery, v13_batch, v13): + assert route_source(cutover, v13_batch)["omit_full"] is True + proof = verify(delivery, v13_batch) + assert [row["head"] for row in proof["members"]] == v13_batch["heads"] + assert v13.projection.known_child(v13_batch["root"], v13_batch["base"], v13_batch["policy"], + "P03", v13_batch["prs"][7], v13_batch["data"]["pulls/88"]) is True + + +@pytest.mark.parametrize("v13_batch", [3], indirect=True) +@pytest.mark.parametrize("failure", ["empty", "not-list", "duplicate", "reordered", "wrong-last", + "overlong", "abbreviated", "merge", "intermediate-control", "unpinned-fix"]) +def test_ci_v13_delivery_unreviewed_or_unsafe_lineage_refuses(v13, v13_batch, failure): + batch, root = v13_batch, v13_batch["root"] + policy = copy.deepcopy(batch["policy"]) + source = policy["profiles"]["P03"]["source"] + chain = source["commits"] + if failure == "empty": source["commits"] = [] + elif failure == "not-list": source["commits"] = source["head"] + elif failure == "duplicate": source["commits"] = [chain[0], chain[0], chain[-1]] + elif failure == "reordered": source["commits"] = [chain[1], chain[0], chain[-1]] + elif failure == "wrong-last": source["commits"] = chain[:-1] + elif failure == "overlong": source["commits"] = ["a" * 40, *chain] + elif failure == "abbreviated": source["commits"][0] = chain[0][:7] + elif failure == "unpinned-fix": source.pop("commits") + else: + git(root, "checkout", "-q", "--detach", chain[0]) + if failure == "merge": + head = git(root, "commit-tree", git(root, "rev-parse", chain[-1] + "^{tree}"), + "-p", chain[0], "-p", batch["foundation"], "-m", "merge fix") + source["commits"] = [chain[0], head] + else: + write(root, ".github/workflows/extra.yml", "# temporary control\n") + middle = commit(root, "temporary out-of-scope change") + git(root, "rm", ".github/workflows/extra.yml") + write(root, "tests/test_sql_register_import.py", "# corrected source\n") + head = commit(root, "restore final narrow diff") + source["commits"] = [chain[0], middle, head] + assert v13.projection.scoped_diff(root, batch["foundation"], head, policy["profiles"]["P03"]) + source["head"] = head + git(root, "checkout", "-q", "--detach", batch["base"]) + write(root, v13.projection.CONFIG, json.dumps(policy)) + base = commit(root, "trusted lineage fixture") + with pytest.raises((ValueError, subprocess.SubprocessError)): + v13.cut(root, base, source["head"]) + + @pytest.mark.parametrize("v13_batch", [False], indirect=True) def test_ci_v13_delivery_disabled_source_and_candidate_remain_full(cutover, delivery, v13_batch): assert route_source(cutover, v13_batch) == cutover.FULL diff --git a/tests/test_v13_shadow.py b/tests/test_v13_shadow.py index 92df8b3d..6aa73fdc 100644 --- a/tests/test_v13_shadow.py +++ b/tests/test_v13_shadow.py @@ -632,11 +632,17 @@ def test_v13_shadow_controls_trigger_existing_full_reuse_without_selectors(yaml_ def test_v13_shadow_is_disabled_and_not_consumed_by_live_delivery(): policy = json.loads((REPO / ".github/ci/v13-shadow-profiles.json").read_text()) assert policy["efficiency_enabled"] is False - for path in (".github/workflows/tests.yml", ".mergify.yml", ".github/ci/delivery-policy.json", + for path in (".github/workflows/tests.yml", ".github/ci/delivery-policy.json", ".github/ci/delivery_route.py", ".github/ci/delivery_verify.py", ".github/ci/delivery_evidence.py"): text = (REPO / path).read_text() assert "v13_shadow" not in text and "sql-register-v13" not in text + # The staged named queue declares delivery intent, never observation output. + # Its separate false flag and heavy-held merge gate are covered by delivery + # tests; banning its scope name here would forbid even disabled staging. + queue_text = (REPO / ".mergify.yml").read_text() + assert "v13_shadow" not in queue_text and "v13-shadow" not in queue_text + assert "queue_admission" not in queue_text and "skip_ci" not in queue_text def test_v13_shadow_cli_bad_payload_stays_safe_without_network(tmp_path):