diff --git a/.github/ci/delivery-v13-policy.json b/.github/ci/delivery-v13-policy.json index 57c10104..e81152c7 100644 --- a/.github/ci/delivery-v13-policy.json +++ b/.github/ci/delivery-v13-policy.json @@ -1 +1 @@ -{"schema_version":1,"scope":"sql-register-v13","enabled":false} +{"schema_version":1,"scope":"sql-register-v13","enabled":true} diff --git a/.github/ci/delivery-v13.md b/.github/ci/delivery-v13.md index 2967f7f7..9012e17b 100644 --- a/.github/ci/delivery-v13.md +++ b/.github/ci/delivery-v13.md @@ -1,19 +1,26 @@ -# Staged v1.3 delivery: disabled +# Reviewed initial v1.3 test-only delivery -`delivery-v13-policy.json` is **false**. The existing claude-current scope is -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. +This source sets `delivery-v13-policy.json` to **true** for the exact registered +P05/P06 pair only. Check the actual default-branch policy after the separately +reviewed code PR merges; a private branch, spec merge or enabled flag alone is +not omission/admission authority or a live acceptance receipt. Existing +claude-current behavior is unchanged. All other v1.3 work retains full CI. +The shadow observer still cannot grant skips, qualification, admission or merge +authority, and its own `efficiency_enabled` remains false. -## Prepared proof boundary +## Trusted proof boundary -The new delivery-specific validator reads the immutable P03/P05 projection but -does not consume shadow observations. Under a separately approved future -enablement it requires all of: +The delivery-specific validator reads the immutable P05/P06 registry data, +never shadow observations. Under the approved staged rollout 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. + frozen required-PostgreSQL workflow/baseline and empty P01 markers. The original + 13 integration jobs are not replaced. An optional explicit `foundation` binds + an independently qualified actual-main ancestor descended from P01 and all + four regular-file helper blobs. Helpers/modes must remain unchanged from that + exact epoch; controls/markers remain frozen from original P01. Missing epochs + retain the original P01-only freeze. No moving-main discovery, rehash or later + helper drift is implicitly approved. - 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 @@ -24,7 +31,7 @@ enablement it requires all of: dependency independently resolved by the owner. The preparer does not edit, rebase, retarget or merge lane-owned PRs. - Unique matching `CI-Shadow: sql-register-v13`, - `CI-Delivery: sql-register-v13` and `CI-Task-Set: P03` (or `P05`) body lines. + `CI-Delivery: sql-register-v13` and `CI-Task-Set: P05` (or `P06`) body lines. These are intent, never review or permission. - Existing authenticated exact-head fast-run/base-history evidence; complete clean hosted Codex or explicit local-review receipt and resolved threads for @@ -46,17 +53,36 @@ admission. Policy/foundation changes after qualification retain full main CI. ## Publication versus activation -This is checked **disabled source preparation**, not a live acceptance receipt. -The full-CI parity caller additionally watches the new validator, policy, +Source publication, including the enabled flag, is not a live acceptance receipt +or a queue command. The full-CI parity caller watches the validator, policy, runbook and tests; its jobs and the parameterless complete suite are unchanged. No release workflow is touched. The four existing queues are unchanged. -## Staged manual queue +The registry points to merged spec revision +`a3366afcc059b4686c990f4715c36dac9b1db05b` and qualified immutable epoch +`f0070e009bc6f183904549b69c710ef3982ca6e6`. Main full run43735780675 and +same-tree run43734991157 passed15/15; matching real-engine smoke43733481662 +verified session clone/query and SIGINT stop/restart/query. Later helper changes +require renewed matching qualification, not automatic advancement of this epoch. + +| Profile | Source | Task set and tasks | Maximum files including markers | +| --- | --- | --- | --- | +| P05 | #92, `2a02cd9eba113329870ed7eba6efd470375b8739` | S007-07: T217, T235, T259 | 4 | +| P06 | #94, `bcc8858bf587fbe86b00264b41caca1b39ccfc72` | S007-09: T212, T256, T225, T242 | 6 | + +Each source has its exact two-commit history pinned in the registry. P05/P06 +owner READY reviews are records6898716602/6898717748, accepted together in +issue165 record6898740891. Their full runs43726550505/43729068826 passed15/15. +Lane2 consent6898422904 applies only to these exact heads with the required +reviews/full CI and lapses on a head change. These receipts do not waive the +fresh source-event, actual enabled-policy, queue and live-acceptance gates. + +## Manual heavy-held 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, +main-targeted same-repository ready sources, supported P05/P06 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, @@ -65,30 +91,50 @@ 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 +Such a request remains unauthorized before enabled-policy and owner-consent +gates pass. 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 +This source alone authorizes no queue command. 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 -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. 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. +Before admission, verify actual required-engine qualification, current exact +owner heads/reviews/consent, actual enabled main and its registry, effective +app-qualified protection and Mergify readiness. Coordinate an idle merge/admission +window without resetting an active owner candidate or imposing a repository freeze. +Owner full-CI product batches are not the efficiency canary. If a batch changes +the frozen foundation, efficiency falls back to full until a separate reviewed +revision and matching real-engine qualification; never silently follow main. + +Lane1 alone adds the three matching intent lines to each owner PR and triggers +a fresh canonical source event without rewriting the head. A body edit alone +does not trigger the opened/synchronize/reopened CI workflows. Do not edit bodies +while any candidate is active. Recheck the current main/base-history snapshot +and verify actual fast-only CI on both exact sources, not old full/fast statuses. + +Only after all gates above pass under the approved owner-consented canary, a +repository writer may request the named queue on both independent members: + +```sh +gh pr comment 92 --repo opensoft/openRepoTools-code \ + --body '@mergifyio queue openrepotools-sql-register-v13' +gh pr comment 94 --repo opensoft/openRepoTools-code \ + --body '@mergifyio queue openrepotools-sql-register-v13' +``` + +Neither this example nor an old consent is reusable admission authority. Verify +the actual candidate contains exactly both registered heads in its recorded +order; a singleton, retry or partial landing is not a clean two-member result. 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 tested/landed prefix and final trees. Local fixture enablement is not that test. Rollback is a normal reviewed false policy. Assembly pins, composed acceptance, SAFE-gated shared-checkout adoption, tools, sessions and releases remain separate. +Passing this first pair is initial test-only acceptance, not blanket v1.3 +adoption. Wider task-set profiles require the next reviewed stage and its proof. diff --git a/.github/ci/delivery_v13.py b/.github/ci/delivery_v13.py index 11b852f6..08dc8a67 100644 --- a/.github/ci/delivery_v13.py +++ b/.github/ci/delivery_v13.py @@ -32,11 +32,7 @@ def configuration(root, base): raise ValueError("V1.3 delivery is not enabled") # Reuse the reviewed immutable projection, NOT classify() or its output. policy = projection.read_policy(root, base) - parent = policy["prerequisite"]["head"] - common.git(root, "merge-base", "--is-ancestor", parent, base) - paths = list(policy["prerequisite"]["blobs"]) + list(projection.P01_FILES) - paths += [projection.MARKERS + task for task in projection.P01_TASKS] - common.git(root, "diff", "--quiet", "--no-ext-diff", parent, base, "--", *paths) + projection.require_foundation(root, base, policy) return policy diff --git a/.github/ci/task-set-delivery.md b/.github/ci/task-set-delivery.md index cfcd5945..475f97e3 100644 --- a/.github/ci/task-set-delivery.md +++ b/.github/ci/task-set-delivery.md @@ -3,18 +3,22 @@ The owner-approved initial efficiency path is documented in [the cutover runbook](delivery-cutover.md). Check the actual committed policy and effective rules: an enabled flag alone never qualifies omission or admission. -Only the fixed opted-in claude-current scope is eligible. A fast-only source +The fixed opted-in claude-current scope retains its existing rules. Its fast-only source MUST use `openrepotools-claude-current`, never direct merge; its delivery success is not heavy integration. Live acceptance and assembly/session adoption are -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. +separate evidence/authority gates. The separately qualified v1.3 path below is +limited to its exact registered test-only pair. All other work retains full CI. + +The [initial v1.3 delivery path](delivery-v13.md) has separate checked enablement +for exact P05#92/P06#94 heads, histories and task inventories on a qualified +immutable foundation. Verify its actual default-branch flag/registry and current +owner consent; a spec merge or source publication alone admits nothing. +Its fast-only sources MUST use `openrepotools-sql-register-v13`, never direct +merge or the ordinary full-CI queue. That queue holds complete trusted heavy +proof; observer output is never authority. P03, other v1.3 cuts, changed heads, +unresolved dependencies or foundation drift retain full fallback. Lane1 alone +owns PR intent/base edits and canonical source events. A successful first pair +does not authorize all-work adoption or a running-session refresh. Preserve lanes 1–5. The earlier [additive fast/candidate preparation](delivery-preparation.md) shipped without queue activation or CI skips. Its diff --git a/.github/ci/v13-shadow-profiles.json b/.github/ci/v13-shadow-profiles.json index 46f7e6d0..c382f717 100644 --- a/.github/ci/v13-shadow-profiles.json +++ b/.github/ci/v13-shadow-profiles.json @@ -2,8 +2,8 @@ "schema_version": 1, "efficiency_enabled": false, "scope": "sql-register-v13", - "spec_revision": "c304e387cf9b5a1ccd3337e926a5d726132b1547", - "planning_status": "v12f draft; owner reconciliation required before activation", + "spec_revision": "a3366afcc059b4686c990f4715c36dac9b1db05b", + "planning_status": "Reviewed initial P05/P06 test-only pair; owner review records 6898716602 and 6898717748; separate admission gates remain", "prerequisite": { "number": 88, "head": "7f1141be15ac9c0d20c25c802ba9533c2fec811c", @@ -12,16 +12,35 @@ ".github/ci/full-ci-baseline.json": "1fd9698a4e5be71b92fa4d9abc7ee6b39f60fcb0" } }, + "foundation": { + "head": "f0070e009bc6f183904549b69c710ef3982ca6e6", + "blobs": { + "tests/conftest.py": "5c4e3d182094bd149e9a68f826ae427dc9739b5d", + "tests/pgcluster.py": "97871b78a222b1b3d7cc05ef1bc4bbbeeaa4419d", + "tests/sql_register_gate.py": "0d0a30d3df586222b4b84a4e91cfb97260781d87", + "tests/sql_register_helpers.py": "cc357350d3438fd59b232c9610273a71f4969bfb" + } + }, "profiles": { - "P03": { - "source": {"number": 93, "head": "81483ab50d1c75b7be3c8932e00efea3d284d102", "branch": "007-p03-import-cutover-operator-tools"}, - "tasks": ["T211", "T218", "T272"], - "files": ["tests/test_sql_register_import.py", "tests/test_sql_register_operator_tools.py", "tests/test_sql_register_cutover.py"] - }, "P05": { - "source": {"number": 92, "head": "3b71c7c532f0da0b6ebbe5aee1c7cc0213a0cd56", "branch": "007-p05-readers-table-and-default-arms"}, + "source": { + "number": 92, + "head": "2a02cd9eba113329870ed7eba6efd470375b8739", + "branch": "007-p05-readers-table-and-default-arms", + "commits": ["3b71c7c532f0da0b6ebbe5aee1c7cc0213a0cd56", "2a02cd9eba113329870ed7eba6efd470375b8739"] + }, "tasks": ["T217", "T235", "T259"], "files": ["tests/test_sql_register_readers.py"] + }, + "P06": { + "source": { + "number": 94, + "head": "bcc8858bf587fbe86b00264b41caca1b39ccfc72", + "branch": "007-p06-refusing-flipped-wip-init-marker", + "commits": ["b65d836b4ea939a43f89cf4e582055bb9e80f890", "bcc8858bf587fbe86b00264b41caca1b39ccfc72"] + }, + "tasks": ["T212", "T256", "T225", "T242"], + "files": ["tests/test_sql_register_build_flip.py", "tests/test_sql_register_marker.py"] } } } diff --git a/.github/ci/v13-shadow.md b/.github/ci/v13-shadow.md index 043f7a7c..76a6f8a7 100644 --- a/.github/ci/v13-shadow.md +++ b/.github/ci/v13-shadow.md @@ -1,12 +1,13 @@ # v1.3 qualification and disabled shadow -This is not an efficiency activation. Ordinary full CI remains required on -every existing event. The parameterless full-CI qualification caller still runs +This observer is not an efficiency activation. Ordinary full CI remains the +fallback except for the separately qualified exact delivery scope. 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. 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. +work. A [separate manual v1.3 queue](delivery-v13.md#manual-heavy-held-queue) +does not consume observer output or itself turn the independent delivery flag on. Its preliminary entry filters and operator-consent boundary are separate from the trusted heavy qualification required before that queue can merge. @@ -17,9 +18,10 @@ not a replacement for feature007's task ledger or owner-approved task cuts. ## Observation contract `v13-shadow-profiles.json` explicitly sets `efficiency_enabled: false`. Its -P03/P05 projection is based on the v12f planning draft at spec revision -`c304e387cf9b5a1ccd3337e926a5d726132b1547`; owners must reconcile current task -sets before any future activation. Exact named regular added/modified tests and +P05/P06 projection is bound to reviewed spec revision +`a3366afcc059b4686c990f4715c36dac9b1db05b` and the exact owner-reviewed cuts +described in the delivery runbook. This registry update does not enable the +observer or make its observations a grant. Exact named regular added/modified tests and the exact cut's empty added markers can be observed. Mixed/control files, deletions, renames, executable/symlink changes, missing/extra/nonempty markers, marker-only edits and arbitrary dependent stacks cannot. The exact known-P01 @@ -31,7 +33,7 @@ observation with exactly one of each line, for example: ```text CI-Shadow: sql-register-v13 -CI-Task-Set: P03 +CI-Task-Set: P05 ``` These lines request **no skips, queue admission or qualification**. CRLF and @@ -45,16 +47,16 @@ The disabled projections additionally bind the observed real cuts: | Cut | Source PR | Immutable head | Source branch | | --- | --- | --- | --- | -| P03 | #93 | `81483ab50d1c75b7be3c8932e00efea3d284d102` | `007-p03-import-cutover-operator-tools` | -| P05 | #92 | `3b71c7c532f0da0b6ebbe5aee1c7cc0213a0cd56` | `007-p05-readers-table-and-default-arms` | +| P05 | #92 | `2a02cd9eba113329870ed7eba6efd470375b8739` | `007-p05-readers-table-and-default-arms` | +| P06 | #94 | `bcc8858bf587fbe86b00264b41caca1b39ccfc72` | `007-p06-refusing-flipped-wip-init-marker` | -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 +Both first commits are P01 children; each has one exact reviewed linear fix. +Their owners' real branches, bases and metadata are not rewritten by this observer. +An explicitly reviewed `source.commits` binding pins 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 +Current owner coordination is issue165 comments6898422904 and6898740891. These bindings record provenance, not review acceptance or approved task-set authority. After the existing exact P01 merged-contract check succeeds, the observer can @@ -100,10 +102,16 @@ The immutable context anchor is source head `7f1141be15ac9c0d20c25c802ba9533c2fec811c`, with workflow blob `e46aca51d4a7a59991c319ee809d46dc61a53d93` and baseline blob `1fd9698a4e5be71b92fa4d9abc7ee6b39f60fcb0`. This does not pin a deployed -provider or adopt the unmerged source. Pending, changed, inaccessible or missing +provider or authorize delivery. Pending, changed, inaccessible or missing prerequisite evidence cannot produce a cut observation. Source/control drift requires a reviewed projection update, not following a mutable PR head. +The optional explicit foundation epoch retains P01 ancestry, frozen controls and +markers, and exact four-file regular modes/blobs with no later drift. Absence +retains the original strict freeze. It never auto-discovers an epoch from main; +matching blobs alone are not a real-engine receipt. Canonical epoch/enablement +requirements live in `openspec/changes/enable-reviewed-v13-test-cuts/` in the spec leg. + `merged-contract-observed` means only that the exact same-repo/main PR source and merge are ancestors of main, the control blobs match and required-engine baseline/foundation markers are present. It is **not proof of successful diff --git a/.github/ci/v13_shadow.py b/.github/ci/v13_shadow.py index 0fc43156..364b8d1f 100644 --- a/.github/ci/v13_shadow.py +++ b/.github/ci/v13_shadow.py @@ -7,6 +7,7 @@ import os from pathlib import Path import re +import subprocess import shadow_scope as common @@ -44,7 +45,15 @@ def read_policy(root, main): raise ValueError("Unexpected prerequisite control inventory") for blob in prerequisite["blobs"].values(): common.sha(blob) - if set(policy["profiles"]) != {"P03", "P05"}: + if "foundation" in policy: + epoch = policy["foundation"] + if (not isinstance(epoch, dict) or set(epoch) != {"head", "blobs"} + or not isinstance(epoch["blobs"], dict) or set(epoch["blobs"]) != set(P01_FILES)): + raise ValueError("Invalid foundation epoch") + common.sha(epoch["head"]) + for blob in epoch["blobs"].values(): + common.sha(blob) + if set(policy["profiles"]) not in ({"P03", "P05"}, {"P05", "P06"}): raise ValueError("Unexpected proposed cuts") for profile in policy["profiles"].values(): source = profile["source"] @@ -69,6 +78,8 @@ def read_policy(root, main): or any(not isinstance(value, str) or not re.fullmatch(pattern, value) for value in values) or len(set(values)) != len(values)): raise ValueError("Invalid profile projection") + if len(profile["files"]) + len(profile["tasks"]) > 6: + raise ValueError("Test-only profile exceeds the staged file bound") if any(len({profile["source"][key] for profile in policy["profiles"].values()}) != 2 for key in ("number", "head", "branch")): raise ValueError("Duplicate source binding") @@ -139,9 +150,34 @@ def p01_status(root, main, policy, pr): for task in P01_TASKS: if common.git(root, "show", f"{main}:{MARKERS}{task}") != b"": return "contract-drift" + try: + require_foundation(root, main, policy) + except (ValueError, subprocess.SubprocessError): + return "contract-drift" return "merged-contract-observed" +def require_foundation(root, main, policy): + """Verify an explicit immutable epoch, never discover one from moving main.""" + parent = policy["prerequisite"]["head"] + epoch = policy.get("foundation") + anchor = epoch["head"] if epoch is not None else parent + if anchor != parent: + common.git(root, "merge-base", "--is-ancestor", parent, anchor) + common.git(root, "merge-base", "--is-ancestor", anchor, main) + controls = list(policy["prerequisite"]["blobs"]) + [MARKERS + task for task in P01_TASKS] + if epoch is None: + common.git(root, "diff", "--quiet", "--no-ext-diff", parent, main, + "--", *controls, *P01_FILES) + return + expected = {f"100644 blob {blob}\t{path}" for path, blob in epoch["blobs"].items()} + found = common.git(root, "ls-tree", anchor, "--", *P01_FILES).decode().splitlines() + if set(found) != expected: + raise ValueError("Foundation epoch tree differs") + common.git(root, "diff", "--quiet", "--no-ext-diff", parent, main, "--", *controls) + common.git(root, "diff", "--quiet", "--no-ext-diff", anchor, main, "--", *P01_FILES) + + def source_lineage(root, parent, profile): """Only the trusted, bounded exact history; check every cumulative cut.""" previous = parent diff --git a/.mergify.yml b/.mergify.yml index 357b7192..9a6f2107 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -141,8 +141,8 @@ queue_rules: 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. + # Reviewed initial test-only scope. Entry is manual, exact-head consent is + # separate, and the queue cannot merge without complete trusted heavy proof. - name: openrepotools-sql-register-v13 branch_protection_injection_mode: queue batch_size: 2 @@ -159,7 +159,7 @@ queue_rules: - '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~=(?m)^CI-Task-Set: P(?:05|06)[ \t\r]*$' - '-body~=(?im)^[ \t]*Depends-On:' - '#files>=2' - '#files<=6' diff --git a/tests/fixtures/ci/v13-initial-profiles.json b/tests/fixtures/ci/v13-initial-profiles.json new file mode 100644 index 00000000..8839ee80 --- /dev/null +++ b/tests/fixtures/ci/v13-initial-profiles.json @@ -0,0 +1,27 @@ +{ + "schema_version": 1, + "efficiency_enabled": false, + "scope": "sql-register-v13", + "spec_revision": "c304e387cf9b5a1ccd3337e926a5d726132b1547", + "planning_status": "Initial disabled projection retained only for legacy contract fixtures", + "prerequisite": { + "number": 88, + "head": "7f1141be15ac9c0d20c25c802ba9533c2fec811c", + "blobs": { + ".github/workflows/tests.yml": "e46aca51d4a7a59991c319ee809d46dc61a53d93", + ".github/ci/full-ci-baseline.json": "1fd9698a4e5be71b92fa4d9abc7ee6b39f60fcb0" + } + }, + "profiles": { + "P03": { + "source": {"number": 93, "head": "81483ab50d1c75b7be3c8932e00efea3d284d102", "branch": "007-p03-import-cutover-operator-tools"}, + "tasks": ["T211", "T218", "T272"], + "files": ["tests/test_sql_register_import.py", "tests/test_sql_register_operator_tools.py", "tests/test_sql_register_cutover.py"] + }, + "P05": { + "source": {"number": 92, "head": "3b71c7c532f0da0b6ebbe5aee1c7cc0213a0cd56", "branch": "007-p05-readers-table-and-default-arms"}, + "tasks": ["T217", "T235", "T259"], + "files": ["tests/test_sql_register_readers.py"] + } + } +} diff --git a/tests/test_ci_v13_delivery.py b/tests/test_ci_v13_delivery.py index c89a7971..3ef22ba6 100644 --- a/tests/test_ci_v13_delivery.py +++ b/tests/test_ci_v13_delivery.py @@ -41,7 +41,12 @@ def v13_batch(batch, cutover, v13, request): for task in projection.P01_TASKS: write(root, projection.MARKERS + task, "") foundation = commit(root, "P01") - policy = json.loads((REPO / projection.CONFIG).read_text()) + policy = json.loads((REPO / "tests/fixtures/ci/v13-initial-profiles.json").read_text()) + mode = getattr(request, "param", True) + if mode == "reviewed-pair": + policy["profiles"] = {"P05": policy["profiles"]["P05"], "P06": { + "tasks": ["T212", "T256", "T225", "T242"], + "files": ["tests/test_sql_register_build_flip.py", "tests/test_sql_register_marker.py"]}} policy["prerequisite"]["head"] = foundation policy["prerequisite"]["blobs"] = { path: git(root, "rev-parse", foundation + ":" + path) for path in projection.CONTROL_PATHS} @@ -53,11 +58,11 @@ def v13_batch(batch, cutover, v13, request): 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) + count = 2 if mode == "reviewed-pair" else mode if type(mode) is int else 1 + for index in range(count - 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: @@ -65,8 +70,7 @@ def v13_batch(batch, cutover, v13, request): 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": request.param if hasattr(request, "param") - and type(request.param) is bool else True})) + "enabled": mode if type(mode) 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") @@ -85,12 +89,13 @@ def v13_batch(batch, cutover, v13, request): batch.update(base=base, heads=heads, candidate=previous, prefixes=prefixes, foundation=foundation, policy=policy) batch["prs"] = {number: batch["data"][f"pulls/{number}"] for number in (7, 8)} - for number, name in zip((7, 8), ("P03", "P05")): + for number, name in zip((7, 8), policy["profiles"]): batch["prs"][number]["body"] = ( f"CI-Shadow: {v13.SCOPE}\nCI-Delivery: {v13.SCOPE}\nCI-Task-Set: {name}") batch["data"][f"commits/{heads[number - 7]}/pulls?per_page=100"] = [batch["prs"][number]] batch["data"]["pulls/88"] = { "number": 88, "state": "closed", "merged": True, "draft": False, + "user": {"login": "writer"}, "merge_commit_sha": foundation, "head": {"sha": foundation, "ref": "p01", "repo": {"full_name": cutover.REPOSITORY}}, "base": {"sha": base, "ref": "main", "repo": {"full_name": cutover.REPOSITORY}}} @@ -125,13 +130,39 @@ def v13_artifact(cutover, v13_batch, delivery): return {"run": run, "record": record, "env": env} -def test_ci_v13_delivery_committed_policy_disabled_and_legacy_unchanged(v13, cutover): +def test_ci_v13_delivery_committed_policy_enabled_with_observer_and_legacy_unchanged(v13, cutover): assert json.loads((REPO / v13.CONFIG).read_text()) == { - "schema_version": 1, "scope": v13.SCOPE, "enabled": False} + "schema_version": 1, "scope": v13.SCOPE, "enabled": True} assert cutover.enabled(REPO) is True assert v13.projection.read_policy(REPO, "HEAD")["efficiency_enabled"] is False +def test_ci_v13_delivery_committed_reviewed_pair_has_exact_qualified_provenance(v13): + policy = v13.projection.read_policy(REPO, "HEAD") + assert policy["spec_revision"] == "a3366afcc059b4686c990f4715c36dac9b1db05b" + assert policy["prerequisite"]["head"] == "7f1141be15ac9c0d20c25c802ba9533c2fec811c" + assert policy["foundation"] == {"head": "f0070e009bc6f183904549b69c710ef3982ca6e6", "blobs": { + "tests/conftest.py": "5c4e3d182094bd149e9a68f826ae427dc9739b5d", + "tests/pgcluster.py": "97871b78a222b1b3d7cc05ef1bc4bbbeeaa4419d", + "tests/sql_register_gate.py": "0d0a30d3df586222b4b84a4e91cfb97260781d87", + "tests/sql_register_helpers.py": "cc357350d3438fd59b232c9610273a71f4969bfb"}} + assert policy["profiles"] == { + "P05": {"source": {"number": 92, + "head": "2a02cd9eba113329870ed7eba6efd470375b8739", + "branch": "007-p05-readers-table-and-default-arms", + "commits": ["3b71c7c532f0da0b6ebbe5aee1c7cc0213a0cd56", + "2a02cd9eba113329870ed7eba6efd470375b8739"]}, + "tasks": ["T217", "T235", "T259"], + "files": ["tests/test_sql_register_readers.py"]}, + "P06": {"source": {"number": 94, + "head": "bcc8858bf587fbe86b00264b41caca1b39ccfc72", + "branch": "007-p06-refusing-flipped-wip-init-marker", + "commits": ["b65d836b4ea939a43f89cf4e582055bb9e80f890", + "bcc8858bf587fbe86b00264b41caca1b39ccfc72"]}, + "tasks": ["T212", "T256", "T225", "T242"], + "files": ["tests/test_sql_register_build_flip.py", "tests/test_sql_register_marker.py"]}} + + @NEEDS_UPSTREAM def test_ci_v13_delivery_manual_queue_is_heavy_held_and_preserves_existing_queues(yaml_reader): import hashlib @@ -153,12 +184,31 @@ def test_ci_v13_delivery_manual_queue_is_heavy_held_and_preserves_existing_queue @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"], + "head": "007-p05-readers-table-and-default-arms", "base": "main", + "body": "CI-Shadow: sql-register-v13\nCI-Delivery: sql-register-v13\nCI-Task-Set: P05", + "files": ["tests/test_sql_register_readers.py", "tests/sql_register_landed/T217", + "tests/sql_register_landed/T235", "tests/sql_register_landed/T259"], "check-success": ["@github-actions/openrepotools-pr-fast", "@github-actions/openrepotools-delivery"]} +@NEEDS_UPSTREAM +@pytest.mark.parametrize("cut, eligible", [("P05", True), ("P06", True), ("P03", False)]) +def test_ci_v13_delivery_reviewed_manual_queue_accepts_only_current_pair( + yaml_reader, v13_queue_source, cut, eligible): + context = v13_queue_source + context["body"] = ("CI-Shadow: sql-register-v13\nCI-Delivery: sql-register-v13\n" + "CI-Task-Set: " + cut) + if cut == "P06": + context["head"] = "007-p06-refusing-flipped-wip-init-marker" + context["files"] = ["tests/test_sql_register_build_flip.py", "tests/test_sql_register_marker.py", + *["tests/sql_register_landed/" + task for task in ("T212", "T256", "T225", "T242")]] + elif cut == "P03": + context["head"] = "007-p03-import-cutover-operator-tools" + context["files"] = ["tests/test_sql_register_import.py", "tests/sql_register_landed/T211"] + queue = yaml_reader(REPO / ".mergify.yml")["queue_rules"][4] + assert all(matches(condition, context) for condition in queue["queue_conditions"]) is eligible + + @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", @@ -178,7 +228,7 @@ def test_ci_v13_delivery_manual_queue_refusal_vectors(yaml_reader, v13_queue_sou 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 == "unknown-task": context["body"] = context["body"].replace("P05", "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"] = [] diff --git a/tests/test_ci_v13_foundation.py b/tests/test_ci_v13_foundation.py new file mode 100644 index 00000000..5e15e1d3 --- /dev/null +++ b/tests/test_ci_v13_foundation.py @@ -0,0 +1,159 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Reviewed foundation epochs in disposable Git histories, never live changes.""" + +from __future__ import annotations + +import copy +import json +import subprocess + +import pytest + +from test_ci_delivery import batch, commit, delivery, git, request_for, verify +from test_ci_cutover import cutover +from test_ci_v13_delivery import route_source, v13, v13_batch, write + + +def advance_fixture(batch, base): + """Reconstruct the same two immutable cuts on a new simulated main.""" + root, previous, prefixes = batch["root"], base, [] + for head in batch["heads"]: + tree = git(root, "merge-tree", "--write-tree", previous, head) + previous = git(root, "commit-tree", tree, "-p", previous, "-p", head, + "-m", "candidate fixture") + prefixes.append(previous) + replacements = dict(zip([batch["base"], *batch["prefixes"]], [base, *prefixes])) + for key in ("data", "env", "event"): + text = json.dumps(batch[key]) + for before, after in replacements.items(): + text = text.replace(before, after) + batch[key] = json.loads(text) + batch.update(base=base, prefixes=prefixes, candidate=previous) + batch["prs"] = {number: batch["data"][f"pulls/{number}"] for number in (7, 8)} + + +def observe_foundation(v13, batch): + """The same foundation facts never turn observer output into authority.""" + env = dict(batch["env"], GITHUB_EVENT_NAME="pull_request") + event = {"action": "synchronize", "number": 7, + "pull_request": copy.deepcopy(batch["prs"][7])} + result = v13.projection.classify(env, event, batch["root"], request_for(batch)) + assert result["mode"] == "shadow" and result["required_ci"] == "full" + assert result["efficiency_enabled"] is False and result["skip_ci"] is False + assert result["queue_admission"] is False and result["qualification"] == "not-qualified" + return result + + +@pytest.fixture +def epoch_batch(v13_batch, v13): + batch, root = v13_batch, v13_batch["root"] + write(root, "tests/pgcluster.py", "# explicitly reviewed new foundation\n") + epoch = commit(root, "owner foundation landing") + policy = copy.deepcopy(batch["policy"]) + policy["foundation"] = {"head": epoch, "blobs": { + path: git(root, "rev-parse", epoch + ":" + path) for path in v13.projection.P01_FILES}} + write(root, v13.projection.CONFIG, json.dumps(policy)) + base = commit(root, "trusted explicit foundation epoch") + advance_fixture(batch, base) + batch.update(policy=policy, epoch=epoch) + return batch + + +def test_ci_v13_foundation_explicit_reviewed_epoch_keeps_source_and_heavy_proof(v13, cutover, delivery, epoch_batch): + batch = epoch_batch + assert v13.configuration(batch["root"], batch["base"])["foundation"]["head"] == batch["epoch"] + assert route_source(cutover, batch)["omit_full"] is True + proof = verify(delivery, batch) + assert proof["full_ci_required"] is True and proof["scope"] == v13.SCOPE + assert [row["head"] for row in proof["members"]] == batch["heads"] + observed = observe_foundation(v13, batch) + assert observed["p01_status"] == "merged-contract-observed" + assert observed["proposed_cut"] == "P03" + + +@pytest.mark.parametrize("failure", ["absent", "null", "extra-key", "short-head", "extra-blob", + "missing-blob", "wrong-blob", "unlanded", "unrelated", "unrelated-landed", "helper-drift", "mode-drift", + "epoch-executable", "epoch-symlink", + "workflow-drift", "baseline-drift", "marker-drift"]) +def test_ci_v13_foundation_uncertain_or_drifted_epoch_refuses(v13, cutover, epoch_batch, failure): + batch, root = epoch_batch, epoch_batch["root"] + policy = copy.deepcopy(batch["policy"]) + epoch = policy["foundation"] + if failure == "absent": policy.pop("foundation") + elif failure == "null": policy["foundation"] = None + elif failure == "extra-key": epoch["allow_drift"] = True + elif failure == "short-head": epoch["head"] = epoch["head"][:7] + elif failure == "extra-blob": epoch["blobs"]["lanes-index"] = "a" * 40 + elif failure == "missing-blob": epoch["blobs"].pop("tests/pgcluster.py") + elif failure == "wrong-blob": epoch["blobs"]["tests/pgcluster.py"] = "a" * 40 + elif failure == "unlanded": epoch["head"] = batch["heads"][0] + elif failure in {"unrelated", "unrelated-landed"}: + epoch["head"] = git(root, "commit-tree", git(root, "rev-parse", "HEAD^{tree}"), + "-m", "unrelated unlanded foundation") + if failure == "unrelated-landed": + joined = git(root, "commit-tree", git(root, "rev-parse", "HEAD^{tree}"), + "-p", git(root, "rev-parse", "HEAD"), "-p", epoch["head"], "-m", "joined unrelated root") + git(root, "checkout", "-q", "--detach", joined) + elif failure in {"epoch-executable", "epoch-symlink"}: + helper = root / "tests/pgcluster.py" + if failure == "epoch-executable": + helper.chmod(0o755) + else: + helper.unlink() + helper.symlink_to("missing-template") + epoch["head"] = commit(root, "bad mode inside the declared epoch") + epoch["blobs"] = {path: git(root, "rev-parse", epoch["head"] + ":" + path) + for path in v13.projection.P01_FILES} + elif failure == "mode-drift": + (root / "tests/pgcluster.py").chmod(0o755) + else: + path = {"helper-drift": "tests/pgcluster.py", "workflow-drift": ".github/workflows/tests.yml", + "baseline-drift": v13.projection.BASELINE, + "marker-drift": v13.projection.MARKERS + v13.projection.P01_TASKS[0]}[failure] + write(root, path, "changed after the reviewed epoch\n") + write(root, v13.projection.CONFIG, json.dumps(policy)) + base = commit(root, "uncertain foundation fixture") + advance_fixture(batch, base) + with pytest.raises((ValueError, subprocess.SubprocessError)): + v13.configuration(root, base) + assert route_source(cutover, batch) == cutover.FULL + assert observe_foundation(v13, batch)["proposed_cut"] is None + + +@pytest.mark.parametrize("v13_batch", ["reviewed-pair"], indirect=True) +def test_ci_v13_foundation_reviewed_pair_uses_unchanged_narrow_proof(v13, cutover, delivery, epoch_batch): + batch = epoch_batch + assert set(batch["policy"]["profiles"]) == {"P05", "P06"} + assert all(len(profile["source"]["commits"]) == 2 for profile in batch["policy"]["profiles"].values()) + assert route_source(cutover, batch)["omit_full"] is True + proof = verify(delivery, batch) + assert proof["scope"] == v13.SCOPE and proof["full_ci_required"] is True + assert [row["head"] for row in proof["members"]] == batch["heads"] + observed = observe_foundation(v13, batch) + assert observed["p01_status"] == "merged-contract-observed" + assert observed["proposed_cut"] == "P05" + + +@pytest.mark.parametrize("v13_batch", ["reviewed-pair"], indirect=True) +@pytest.mark.parametrize("failure", ["old-task", "head", "unknown-pair", "too-many-files", "too-many-markers"]) +def test_ci_v13_foundation_reviewed_pair_does_not_broaden_scope(v13, cutover, delivery, epoch_batch, failure): + batch, root = epoch_batch, epoch_batch["root"] + if failure == "old-task": + batch["prs"][7]["body"] = batch["prs"][7]["body"].replace("P05", "P03") + elif failure == "head": + batch["prs"][7]["head"]["sha"] = batch["heads"][1] + else: + policy = copy.deepcopy(batch["policy"]) + if failure == "unknown-pair": + policy["profiles"]["P04"] = policy["profiles"].pop("P06") + elif failure == "too-many-files": + policy["profiles"]["P05"]["files"] += [ + "tests/test_sql_register_extra_one.py", "tests/test_sql_register_extra_two.py", + "tests/test_sql_register_extra_three.py"] + else: + policy["profiles"]["P06"]["tasks"].append("T299") + write(root, v13.projection.CONFIG, json.dumps(policy)) + advance_fixture(batch, commit(root, "unqualified profile fixture")) + with pytest.raises((ValueError, subprocess.SubprocessError)): + verify(delivery, batch) + assert route_source(cutover, batch) == cutover.FULL diff --git a/tests/test_v13_shadow.py b/tests/test_v13_shadow.py index 6aa73fdc..af116540 100644 --- a/tests/test_v13_shadow.py +++ b/tests/test_v13_shadow.py @@ -73,7 +73,7 @@ def fixture(tmp_path, shadow): write(root, shadow.MARKERS + task, "") write(root, "tests/test_sql_register_import.py", "# initial test\n") foundation = commit(root, "P01 foundation") - policy = json.loads((REPO / shadow.CONFIG).read_text()) + policy = json.loads((REPO / "tests/fixtures/ci/v13-initial-profiles.json").read_text()) policy["prerequisite"]["head"] = foundation policy["prerequisite"]["blobs"] = { path: git(root, "rev-parse", "HEAD:" + path) for path in shadow.CONTROL_PATHS} @@ -390,7 +390,7 @@ def stack_fixture(tmp_path, shadow, request): for task in shadow.P01_TASKS: write(root, shadow.MARKERS + task, "") foundation = commit(root, "P01 source") - policy = json.loads((REPO / shadow.CONFIG).read_text()) + policy = json.loads((REPO / "tests/fixtures/ci/v13-initial-profiles.json").read_text()) profile = policy["profiles"][cut] policy["prerequisite"]["head"] = foundation policy["prerequisite"]["blobs"] = {