diff --git a/.github/ci/delivery-v13.md b/.github/ci/delivery-v13.md index ee2bede0..e206c1d7 100644 --- a/.github/ci/delivery-v13.md +++ b/.github/ci/delivery-v13.md @@ -152,3 +152,7 @@ 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. + +The next P07/P09 cohort is documented in [disabled expansion preparation](v13-expansion.md). +That separate manifest/inspector grants no live omission, foundation transition +or queue admission and leaves this active initial-pair contract unchanged. diff --git a/.github/ci/v13-expansion.md b/.github/ci/v13-expansion.md new file mode 100644 index 00000000..8124787a --- /dev/null +++ b/.github/ci/v13-expansion.md @@ -0,0 +1,89 @@ +# P07/P09: disabled CI expansion preparation + +This is preparation, not activation. `v13-prepared-cohort.json` is deliberately +separate from the active P05/P06 projection and delivery policy. No workflow, +live verifier or Mergify queue consumes this file. Merging this preparation +alone cannot grant skipping, a green review receipt or queue admission. + +The source PRs are P07/code#97 and P09/code#103. The manifest records their +owner-confirmed histories and fresh exact-head local Codex review references. +Coordination starts at opensoft/openRepoTools#165 comment6927765450. Old public +heads are observations only. A null source binding is pending, not a wildcard. +P08/code#106 stays held, including `.github/workflows/release.yml`. + +Renewed owner consent (issue165 comments6938017311 and6938099557) requires +P07 before P09. The disabled inspector therefore accepts only that order and +previews P07 first with the original foundation, followed by P09's declared +helper transition. Reversed order refuses; this does not change any live queue +or grant consent to a moved product head. + +The resolved cut includes P09's T237zzi (one trailing empty line removed; +unchanged AST), per lane2 comment6930368576 and lane3 ruling6930389021. +Lane1 published P07 `4e9821ab` and P09 `f4f0ebce`; their declared histories +start at P01 `7f1141be` and landed P03 `6aa8b5c0`, respectively. Each anchor +must contain the common prerequisite and already be in frozen main. This does +not permit rebasing, skipped commits or widening an inventory. Consent6928862535 +is conditional; review links remain pending until actual exact-head reviews. + +Those old cuts are superseded. Owner handoff6947653181 supplies P07's completed +CX-37 cutcab8fcfd, with clean review6948304918 and remaining consent conditions. +Owner handoff6956070097 supplies P09's final165-commit cut1d16c0cc; lane3 agrees +it in6956738431 and the fresh local Codex review6958093018 is clean. The prior +P09fb359e64 remains rejected; its review is not reused. +The disabled manifest binds these exact heads, complete ordered histories, and +their own review and conditional owner-consent references. The first fresh +fast runs on base `804a97be` passed: P07 44382695364 and P09 44388864691. +P09's full preparation run 44380683647 also passed. These are preparation inputs, +not fast-only canary evidence or admission. The helper `tests/sql_register_cleanup.py` is an +exact added regular-file inventory entry, per P07 handoff6940832411 and lane3 +agreement6940947493. Its final T270 ownership record is now in normally merged +spec80 at c245bc3726bfd80aea8ddbe4b8d167c64916e0c9; declaring this path does not +accept the helper's code or broaden live scopes. + +The proposed preparation ceilings are P07 40 commits and P09 165 commits, +counted from their respective declared anchors. P07's complete40-commit CX-37 +chain is owner-confirmed in code97 comment6947653181; P09's complete165-commit +CX-36 chain is owner-confirmed in code103 comment6956070097. These are not automatic +bindings of unpublished heads. Exact bundles, complete ordered SHAs, current +review/consent and validation are still required. Larger or different chains +need explicit reviewed changes; never truncate history or restack a lane to +fit. Live policy limits and all fallback behavior remain unchanged. + +This update retains the exact 40/165 bounds without accepting any other product +head. The prior P09 ceiling of 24 no longer fits its completed chain. Any replacement count needs +explicit boundary/prefix validation and independent review, never truncation. + +Historically, P07's exported CX-31 tip18529e5a had a complete16-commit chain whose +prefixes and exact inventory were checked independently. The ceiling update +does not bind that head or satisfy its conditional consent: the genuine +exact-head review, new33-node hosted verification, fresh full CI and landed +spec80 notes remain separate gates. The observed P09 CX-31 chain has29 commits; +structural acquisition alone does not raise its ceiling or accept that cut. + +With acquired immutable objects in an isolated checkout, inspect a bound cohort: + +```sh +python3 .github/ci/v13_expansion.py --main OBSERVED_MAIN_SHA +``` + +The inspector makes no network calls, changes no ref/index/worktree, and can +write only private immutable merge-preview objects. It rejects stale main, +unsupported histories, mixed paths, unsafe modes, nonempty markers, dependent +members and conflicts. A valid preview still requires **full CI** and grants +**no admission**. Review/consent links are context, not authenticated authority. + +P09's exact inventory includes modified regular files `tests/conftest.py` and +`tests/pgcluster.py`, both frozen-foundation paths. Their before/after blobs must receive a +separate explicit foundation/landing review before any future activation; do +not broaden the live verifier or copy a new digest merely to clear a refusal. +Activation also needs current-main/source/review proofs, reviewed queue and +admission support, complete coverage parity and separate live-batch authority. +No single flag in this manifest can perform those steps. + +The original preparation left both PRs open. Subsequent owner authority permits +checked preparation merges only after spec#80, fresh exact-head product reviews +and CI pass. Neither preparation merge activates delivery or authorizes a queue +command. The separately approved narrow live rollout still requires reviewed +live support and the complete canary gates above. P08 stays held; no ruleset +change/bypass, app grant, paid upgrade, release edit/tag, tool installation, +assembly-pin advance, shared-checkout refresh or lane/session change follows. diff --git a/.github/ci/v13-prepared-cohort.json b/.github/ci/v13-prepared-cohort.json new file mode 100644 index 00000000..7a9d2791 --- /dev/null +++ b/.github/ci/v13-prepared-cohort.json @@ -0,0 +1,270 @@ +{ + "schema_version": 1, + "enabled": false, + "scope": "sql-register-v13-next-preparation", + "base": "804a97be1ab5305e3ed9d4f778e2cf89dacc55f5", + "prerequisite": "7f1141be15ac9c0d20c25c802ba9533c2fec811c", + "spec_revision": "c245bc3726bfd80aea8ddbe4b8d167c64916e0c9", + "owner_coordination": 6927765450, + "held_prs": [106], + "order": ["P07", "P09"], + "profiles": { + "P07": { + "source": { + "number": 97, + "branch": "007-p07-render-writes-shape-divergence-rollback-2", + "anchor": "7f1141be15ac9c0d20c25c802ba9533c2fec811c", + "head": "cab8fcfdee749dbeac5fc916d1c9b642e6d6cc4c", + "commits": [ + "69196d611647dd9d0383a4bec153dd8167652547", + "8ff07b57054e570c4698695f35419291bcbca485", + "81924518f081a2924e45ad8f251c153fd173b89f", + "4e9821abc955c201bb3690e837d70e15cba50e83", + "51aae860c74cc57d3b2f98de55edd964f3b56088", + "c15c1f3f2dbf551ec182085d3dc9b0661bb5dce0", + "4051ec73979ee6f2e5fc3b3cf1c9e188dcbe280a", + "c2c75305a74d8f66025e605233468e5dcac1b38f", + "fe1c8baf5b9d7c49d513beb399b6e5106a21c037", + "a8446eb8a7232363bb7f6dd2fa743b54b12f3444", + "fec6b59a40086470d9e903f57ea1b33ccb8fcbdc", + "973a2ed4415afe8664c15feb31df677790e3d653", + "6d4794186940f64a6904b7551d5d96d40d14b78e", + "61cbdf13597d6bf8126327c8de86736dccd4697e", + "f31f8c0f589142047c26a77e7b9ed90b6896c66d", + "18529e5a1ebc3c0596f0acef30598cb5fa38067a", + "12cd187ee0d7170e157d7dc22fa0b08d9e12c70f", + "66ce53ec09cdb28c8e98666dc0a5beddd42889d1", + "ae408cdf7e18fcd82c34d90d3e6bc0d4624f03c7", + "46cac748bb0b98b07f80370190d9306504e5ea9c", + "ed0bef2e2669bc92274a8eaa33ed1e53ce29d0df", + "f776b435fdc87fe898c23f0a5131adc6fe66c4d6", + "035c336ef5d196746b3df77437588bf44867b04f", + "071f9786a3b21ae1e232d1a2d5a5d9bdc107bb5f", + "d34c7eabb1e30639ceb4b44dc1fc89be043ded3b", + "5a12064729c727d2c0301dc1861ac1369d144217", + "b96ff01415e03bef7b19fb950400d2898ff9be76", + "7b4b45dcd39df7c23145ee793142ada4e6d29138", + "1b6d25e147b70635d7a350d4a0f74bfeff520c7f", + "c2371bef87b777c8b4ee83d01a9a1d647114cd3e", + "73279c1991215f34b7f1870e8fa6a3ee9f4012c2", + "e5aa44e4a157cc48795c45a929e43ee2176a6235", + "464f7f3d066973871622ff515623004cc3afcc1b", + "bb190f7ba236e002eb3414a7a7e7987175222851", + "84c5276143acff30a8b3dd7d1c1a5d3fc798fe09", + "4789068044635b6e295f01732ccfa2412b37310d", + "3267d6dbbc7558390ad2c3c54973fa0d4c6e75d8", + "be88b3c5d794c98b163d70dc8880f08d041ac7e2", + "3bb1265a5cc77580bf80cabe678fd574a950a192", + "cab8fcfdee749dbeac5fc916d1c9b642e6d6cc4c" + ] + }, + "observed_head": "cab8fcfdee749dbeac5fc916d1c9b642e6d6cc4c", + "owner_consent": {"head": "cab8fcfdee749dbeac5fc916d1c9b642e6d6cc4c", "comment": 6947653181}, + "review": {"head": "cab8fcfdee749dbeac5fc916d1c9b642e6d6cc4c", "comment": 6948304918}, + "tasks": ["T210", "T240", "T241", "T270", "T271", "T273"], + "files": { + "tests/fixtures/lanes-edit-v1.1.0/SHA256SUMS": "A", + "tests/fixtures/lanes-edit-v1.1.0/lanes-edit.sh": "A", + "tests/sql_register_cleanup.py": "A", + "tests/test_sql_register_divergence.py": "A", + "tests/test_sql_register_render.py": "A", + "tests/test_sql_register_renderer_git.py": "A", + "tests/test_sql_register_rollback.py": "A", + "tests/test_sql_register_shape.py": "A", + "tests/test_sql_register_writes.py": "A" + } + }, + "P09": { + "source": { + "number": 103, + "branch": "007-p09-guard-measure-writes-disaster-drill-rollback", + "anchor": "6aa8b5c026c6d131b44242f3b3e618b41d6ebf19", + "head": "1d16c0cc5092fd8704a67399acee81ef2436f21a", + "commits": [ + "a8e339446af50be4c90f3d49dbd81e0593150d09", + "366e62fdb2e930e9553a4cd41aaa22df98e43c45", + "492620a70d82242e7830a90cb8cdd3606dfbdd68", + "9f6579d3c62f9bc65055a917759b8a3a88b167eb", + "f047f761a847aea345079b8d89b5f66b46e86e77", + "0e40a16a2ea2d3be54884c65646e1fd18bcb3fda", + "5109125bfc4bf22498d7f06d63e1360c89652c32", + "f4f0ebce68a90628dff9e79183ffbd1de1358ea3", + "21855bbfe22f8d3494c28fea5f2700a86eb65c8f", + "e090913f26a074a3718d434f4477f5750c5c8827", + "4e76dbd2d630b5abab2e2403ad06266977a3b063", + "f85945ff9b231745c8566702fb7c82b0187f93b2", + "8907fc7c0be369053e0e72b5b90cb2bd5216446c", + "881ac5f14b1d92150ea84372b4e055fbf5d0f28f", + "b27e776e69d5cb53574396a848ecae740331a776", + "6f349868d971d5e0d5f2e9fef41b45d5274ba305", + "6c346078f99d2a0cd2fcd0aa2d95d644ba72b52a", + "56706e4527f39acc31141cd03423325171e64e4e", + "01a8873b2b5228ba6bb12eb2a3290acb9dae2a7a", + "8aa33be3791c1f2a1bcb2a2ecd55928349fb8249", + "571c6270a0b711f966d57e9757bdb6fb5b99cb34", + "28f11b989b5e41a2970ce83ccaf76ca19acf4dd6", + "178f46c5a4361dcdc7df69e16351a52dab6084ea", + "c69dd3f6a2852bc4e185996b70d1e013ebd6dcb7", + "8abda6e52744a4425dcbd539ad72eedcb1638292", + "43635414715b50d71a40252adee1936b533b8323", + "e8056119aa5ed5f594552813daa2d0c6af77e497", + "a3a464352a6667f2804d401bbc117e34746f313f", + "21dd36428b5d47eb977a054ea521446f4ec9956d", + "c53e5ace45ba8a4f66f2b34a19411a20983e7088", + "7237a921b0e6aa504b786dafadd4346380e3f0ae", + "227de0aed4ba8b66950e2ead992b660309e25851", + "d28a7c3e28c9bb84059673c92133b34e67274de3", + "779b2161759db7e9ddb5fb61fc117ea29b324efb", + "6b0f9bb9991f66039baeba44a8d36980a29d6b2d", + "970b501d080c05eab6b7f273299be756860d849a", + "e1934c38bd1a3c37ec68464ac6a2b07978120429", + "ab78121ea6c838fa37b164712e24ca45456920d0", + "ca77405096baf9b9a18d7244a320bbf9013d76f7", + "c97d4a175c53b385f23aba77767299bd3e30eee5", + "c963509bdef88917d3f390c88f3a8099e7373a15", + "ddf9d43f2924702982f804de501735bc268f3e30", + "bc74872b933391c27e4ee335c99ec13cdf852991", + "d3a2fd5c3725a504e49b388908c39f4e258d3acf", + "579b191607bc664707d2c4f3577e4fc884c8210e", + "5df6dc8f465e319f02f89b2cca6af7e082c8b2b3", + "a19b94768f40795191d62be38ab12ae1cab0d8f9", + "182fa56e3ee9072179b5c62ef8a78312e8628f25", + "9de78cb7f9f74b00941c921d53ebecf1725e21ea", + "16a45541f3eebecac41204967c6e64e0dd876296", + "f89210a02242f1991470152e520da59145bf88b0", + "e484f2a536f385a437266a48f337a50a0c7369b2", + "bb89fac78cd6a893dc88c83d03a00a0c4d7ee7f0", + "16dcdede2612c6696fd58522b8f55fb030463497", + "d3eb548b7671f6a542e87a8ed0a7285bd403421d", + "99def208db8134ad247361802ccc367548f2ef36", + "51484a1ab85f7b4e5c6dc018e21c21ffb5ff8f83", + "b8f9e35a326a01eb633d5f56730f608224154122", + "c2049c0e00abeb44e98b0f454ee0edf4256c09f4", + "6f8fce16ef68e8188d7918864a203d0f91da75a4", + "d7e46f560406d1fddbc8de4ceea1117fbdd35258", + "21fe95609cf618a0a49cf1907089750decb97ed2", + "f709b8c0068dd112d1c793b74984ed4d5716cf5f", + "4aa3025cc9060b0b807e05022f2fb358af1d6915", + "58a65df286e4567694f08c8f4d3b862b6fd30cdc", + "66988344567a0c92af10e9b6d6a2d66d69322b64", + "e41c2c7bb89d2a99fa1ab37406760f2790995bec", + "96decfcd9ceb49a6977948cc254512d22fcc474a", + "26d4e85c808e3e83f429eff12a380a8283e72770", + "fb359e644717055a010cfecab0251384fc2ae116", + "546eb5ab33606512edd4a5a9046a32df2024a5e8", + "b11fa88366e379ac1c8b5bc308e14d98685b441a", + "2407ea06184100c9c3e4e520ac513c04f562ab1b", + "7fdb1aa9886411fc7af431ed91b089a347293d0a", + "c5e9278fe8bebf01ba59481d3daaaf29ae52d643", + "e8704272cc871d15c77211bfc1d01357c4c86055", + "a15d1c03c09584836966bad7daa7c99fc9eaa398", + "08b4a81a08beefd48028f01d15ea5c33d7c3fd18", + "e5f73a8e6fbfb740b7d3b71630a27ece250842f7", + "d45d17c48781abdef4c7d7c135be73c04475a858", + "d9a1f2bfff7c66fbab7c6768681b901931807a19", + "4d4bf03f93920cb748ccce844c793671231e46d3", + "a1e99a577bb7eb5a0361c7acfedeba64259b1983", + "d29f463b29ccdffcc0dadf780bd18676a40c354a", + "d7bf6f36c4d9d251e0a46b3f3666b72f81c7fc6d", + "f00ffdab15d7b5dfebab8f8a0e21348166b67dae", + "b99d587f84dbd847b8f01be8aa717c78bd3c0d33", + "1222ee2bd6d40d7468bd3606830ba567bc0b5b08", + "3d82630d2539e3b466bac07d036e7350bd77b595", + "e63e7aad564405e60400a59536c4d551ce3a20ce", + "8622aa0c93adedaf761e085456bc7cf1411d9715", + "5c3ffef7b0549acad108542c527c0215560ce81c", + "0bbf0415e8da0067b007512da34248d2f952f84c", + "013894971ba10c5ecf9e2a37eca0c98a06c0e425", + "d5c442b8fc6ae80e309fa362ce3d40e9da443778", + "fab07bcab0231c34b9378277e919683c8f230c00", + "d5ce1bd26bd34fb9ea5e3b8d027d7052ab2ca5c4", + "e6643fc5b8310af45adc3c869c73a2601665d245", + "3f9fcac43986bd98f65f54c3145756eb307a7fb3", + "08f3e4eca2d5741e19f1231ab4d51932322fc84b", + "3c5b68bcbe5c4f6325bdb50db9ea1bae259290a1", + "073afa27a27e4b46671ed24ebdee235a128c7dca", + "2475cfcc033a708762a5773169d73c6ecaa863c0", + "09e51bb9849cc36467fda44faa690e1bec985016", + "a3fd173bef8a13b78df9222244688b22ea434ec0", + "49e256358efab36d5d057fd1197b6de30fb58210", + "1bf25c01a76dd6a2d27bfdce145909eec27e42cc", + "58d05e84642e61e9028600a530ad94619566b191", + "385c547aad6adc44791acab209ed9175b1b0b79d", + "ac229b9f6e8ad93df2f067fed4c6e6c35167aee4", + "61db3c52a6404e67990221027ca2409ca972de12", + "d516068483976d80ad88a3ef908a221d17995aab", + "aa4c32b0e896354d4c9c4867cf27938176b0db16", + "161c30874d9f2171ed3386a1f5290f6bdf9ecd7a", + "7f232883316594c60e25cbc12e6d7d93943f6e7f", + "72497d8a3c45a544c95b62ebe4a64e485ac22c41", + "5d317811f91112071c51c4dc7824c4ebd24020d4", + "e0ace78e5e5d0ecf9117c77c19c2077ad094d955", + "2072e8cb5b2263bfdba3d723948bb2d1e6328cfb", + "d0b83ccf5627bf62c11c27fa5d00f02012983c58", + "fde81e23a897de5891d1cdd8791eb7ac930df0e1", + "3ed57d0d070ac1ffec555a5d61e7bfb8f147a917", + "41b3e4527dcf8defc0100d9d4a8f325b66444987", + "d0afee7fa771c4a683812f1247cd6282d6bc658c", + "6deff662dea0320fc4e3ddc0ece7eae83b06a815", + "882c497bd67eadb24c40e2790f8a2aa1747a9df6", + "aefb982de5870d61402d3ed272191d28bc366941", + "905d8e57ff88c0b599238486c8af21c0f6da3d3c", + "5b2652c6400c7237e953c3409ee8da814c93dc9d", + "7d9119d86d01d430838a2838cc1fe3a3bfbc55bd", + "f8e8aca8af05411511a45b5908b7b6ea3616df7b", + "8ba981120b5e01c16ed5873d447467cbcb5b378b", + "da97a0348abda3cdb881ff4aaf1ddc619f35aeeb", + "99e7df0e1a1c55363297f639385486b80fc004e9", + "e8dca97d9a6622d428c3206b8ee814421fae692f", + "d9bba46079d7d50e38120d8b5055ee453027f015", + "e5c00cfb7c63e1a05265fed3bb8994eec087fbc4", + "5a8c56fc8c58b871040bf1963a0fb55147e730f8", + "cee97907ba7f80d56284afb76ac2a4e232d4d8e4", + "48cfcf7a78249b88e512f639f1ed9eec9e03c37c", + "ad29ebb3fd5b154cc22e747cf09f9f3c3c8d2c9e", + "99a5ce3b16326b81dd06ca0fb0b7430384ac8491", + "fc58ab30cf3576f6804752c5d84d17bfad87beb2", + "f9c12c12330d18c24660d17a2fa2fb864bce2071", + "c6909eb7b3e4ed9350531d080eeaefabb36ff737", + "66bfc0f5cd01ef55860f7e7df8e76d72e759c00a", + "795cdaf7ec753dc1addeb4fab9b30b68c88043f9", + "57232979053f08fadaa6cfe5d0c782eb1d388deb", + "b3d7002481b71d72e8af19e7253f0f7cd89e8a85", + "5115718a332283ba0c575ed6c28eff645df5084d", + "0cfdfe63d21519a88b78973be27a834fb0940df4", + "857a41d2e9826dbc316cc96783c17160ac7d01cb", + "7c65172c753e695f288f68af7e1a651034b83947", + "2f8719543aee9f50118749982cf28d3fea02325a", + "210a0d3195c0950d6cf9e39c56366662ee855060", + "d00c7a60165deb2b2c4faf469794ba3c5ac7fad6", + "4df592c8ca693b9b3a804c0b349edaa811100ee0", + "78710f389cc817fd8f376d8d2fa2898a13b7f358", + "c16cebfe9a3f9b36949e32487bd3c41d20428540", + "21b75ada4e657fb1590fed048a4feabf71f7500a", + "4e436d7f18a09ce611c703812f48887000ef13a0", + "3faf945316e7b104a898cbe9a9718bee9940703b", + "4c637366bc8ed1be7be1498d87c9333b16f1144a", + "7330ce8a83af7c6ffb58b4704e61a6bc4472ea1c", + "1d16c0cc5092fd8704a67399acee81ef2436f21a" + ] + }, + "observed_head": "1d16c0cc5092fd8704a67399acee81ef2436f21a", + "owner_consent": {"head": "1d16c0cc5092fd8704a67399acee81ef2436f21a", "comment": 6956070097}, + "review": {"head": "1d16c0cc5092fd8704a67399acee81ef2436f21a", "comment": 6958093018}, + "tasks": ["T213", "T214", "T215", "T219", "T220", "T224", "T226", "T229", "T230", "T237", "T253", "T254", "T255", "T257", "T258", "T274", "T276", "T278", "T279"], + "files": { + "tests/conftest.py": "M", + "tests/pgcluster.py": "M", + "tests/test_sql_register_bounds.py": "A", + "tests/test_sql_register_disaster.py": "A", + "tests/test_sql_register_drill.py": "A", + "tests/test_sql_register_fixture.py": "M", + "tests/test_sql_register_guard.py": "A", + "tests/test_sql_register_landing_expired.py": "A", + "tests/test_sql_register_managed.py": "A", + "tests/test_sql_register_measure.py": "A", + "tests/test_sql_register_outage.py": "A" + } + } + } +} diff --git a/.github/ci/v13_expansion.py b/.github/ci/v13_expansion.py new file mode 100644 index 00000000..47a52cb6 --- /dev/null +++ b/.github/ci/v13_expansion.py @@ -0,0 +1,160 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Disabled P07/P09 preparation only; never imported by live delivery readers.""" + +from __future__ import annotations + +import argparse +import hashlib +import json +from pathlib import Path + +import shadow_scope as common +import v13_shadow as projection + +CONFIG = ".github/ci/v13-prepared-cohort.json" +SCOPE = "sql-register-v13-next-preparation" +TASKS = { + "P07": ["T210", "T240", "T241", "T270", "T271", "T273"], + "P09": ["T213", "T214", "T215", "T219", "T220", "T224", "T226", "T229", + "T230", "T237", "T253", "T254", "T255", "T257", "T258", "T274", + "T276", "T278", "T279"], +} +SOURCES = { + "P07": (97, "007-p07-render-writes-shape-divergence-rollback-2"), + "P09": (103, "007-p09-guard-measure-writes-disaster-drill-rollback"), +} +# Preparation ceilings only; every exact head and complete ordered chain is +# still bound separately. Never infer a new source binding from these limits. +HISTORY_LIMITS = {"P07": 40, "P09": 165} +FILES = { + "P07": {**{f"tests/test_sql_register_{name}.py": "A" for name in + ("divergence", "render", "renderer_git", "rollback", "shape", "writes")}, + "tests/fixtures/lanes-edit-v1.1.0/SHA256SUMS": "A", + "tests/sql_register_cleanup.py": "A", + "tests/fixtures/lanes-edit-v1.1.0/lanes-edit.sh": "A"}, + "P09": {**{f"tests/test_sql_register_{name}.py": "A" for name in + ("bounds", "disaster", "drill", "guard", "landing_expired", "managed", + "measure", "outage")}, + "tests/test_sql_register_fixture.py": "M", "tests/pgcluster.py": "M", + "tests/conftest.py": "M"}, +} +FULL = {"mode": "preparation", "required_ci": "full", "skip_ci": False, + "queue_admission": False, "activation": False, + "review_references": "not-authenticated"} + + +def require(condition): + if not condition: + raise ValueError("Invalid disabled cohort preparation") + + +def read_policy(root): + raw = (root / CONFIG).read_bytes() + require(len(raw) <= 65536) + policy = json.loads(raw, object_pairs_hook=projection.unique_pairs) + require(isinstance(policy, dict) and set(policy) == { + "schema_version", "enabled", "scope", "base", "prerequisite", "spec_revision", + "owner_coordination", "held_prs", "order", "profiles"}) + require(type(policy["schema_version"]) is int and policy["schema_version"] == 1 + and policy["enabled"] is False and policy["scope"] == SCOPE + and policy["held_prs"] == [106] and type(policy["held_prs"][0]) is int + and policy["order"] == ["P07", "P09"] + and type(policy["owner_coordination"]) is int and policy["owner_coordination"] > 0 + and isinstance(policy["profiles"], dict) and set(policy["profiles"]) == set(SOURCES)) + for key in ("base", "prerequisite", "spec_revision"): + common.sha(policy[key]) + for name, profile in policy["profiles"].items(): + require(isinstance(profile, dict) and set(profile) == { + "source", "observed_head", "owner_consent", "review", "tasks", "files"}) + common.sha(profile["observed_head"]) + require(profile["tasks"] == TASKS[name] and profile["files"] == FILES[name]) + source = profile["source"] + require(isinstance(source, dict) and set(source) == {"number", "branch", "anchor", "head", "commits"}) + common.sha(source["anchor"]) + require(type(source["number"]) is int + and (source["number"], source["branch"]) == SOURCES[name]) + commits = source["commits"] + if source["head"] is None: + require(commits == [] and profile["owner_consent"] is None and profile["review"] is None) + continue + common.sha(source["head"]) + require(isinstance(commits, list) and 1 <= len(commits) <= HISTORY_LIMITS[name] + and all(isinstance(commit, str) for commit in commits) + and len(set(commits)) == len(commits) and commits[-1] == source["head"]) + for commit in commits: + common.sha(commit) + for key in ("owner_consent", "review"): + reference = profile[key] + require(reference is None or (isinstance(reference, dict) + and set(reference) == {"head", "comment"} + and reference["head"] == source["head"] + and type(reference["comment"]) is int and reference["comment"] > 0)) + return policy, hashlib.sha256(raw).hexdigest() + + +def source_tree(root, policy, profile): + projected = {**profile, "files": list(profile["files"])} + anchor, head = profile["source"]["anchor"], profile["source"]["head"] + common.git(root, "merge-base", "--is-ancestor", policy["prerequisite"], anchor) + common.git(root, "merge-base", "--is-ancestor", anchor, policy["base"]) + require(projection.source_lineage(root, anchor, projected)) + changes = common.git(root, "diff", "--name-status", "--no-renames", anchor, head).decode() + rows = [line.split("\t") for line in changes.splitlines()] + require(all(len(row) == 2 for row in rows)) + expected = {**profile["files"], **{projection.MARKERS + task: "A" for task in profile["tasks"]}} + require(len(rows) == len(expected) and {path: status for status, path in rows} == expected) + + +def inspect(root, main): + result = {**FULL, "status": "refused", "reason": "invalid-preparation-context"} + try: + policy, digest = read_policy(root) + require(common.sha(main) == policy["base"]) + common.git(root, "merge-base", "--is-ancestor", policy["prerequisite"], main) + result["manifest_sha256"] = digest + profiles = policy["profiles"] + if any(profile["source"]["head"] is None for profile in profiles.values()): + return {**result, "status": "pending-owner-heads", "reason": "unbound-source"} + for profile in profiles.values(): + source_tree(root, policy, profile) + heads = [profiles[name]["source"]["head"] for name in policy["order"]] + require(common.git(root, "merge-base", "--all", *heads).decode().split() + == [policy["prerequisite"]]) + previous, trees = main, [] + for name, head in zip(policy["order"], heads): + tree = common.sha(common.git(root, "merge-tree", "--write-tree", previous, head).decode().strip()) + require(projection.scoped_diff(root, previous, tree, { + **profiles[name], "files": list(profiles[name]["files"])})) + trees.append({"profile": name, "tree": tree}) + if len(trees) == 1: + previous = common.git(root, "-c", "user.name=Preparation preview", + "-c", "user.email=preview@example.invalid", "-c", "commit.gpgSign=false", + "commit-tree", tree, "-p", main, "-p", head, + "-m", "Preparation-only object; never a queue receipt").decode().strip() + foundation = {} + for path in projection.P01_FILES: + before = common.git(root, "rev-parse", f"{main}:{path}").decode().strip() + after = common.git(root, "rev-parse", f"{trees[-1]['tree']}:{path}").decode().strip() + if before != after: + foundation[path] = {"before": before, "after": after} + ready = all(profile[key] is not None for profile in profiles.values() + for key in ("owner_consent", "review")) + return {**result, "status": "preview-ready-for-review" if ready else "preview-pending-owner-reviews", + "reason": "disabled-preparation-only", "base": main, "previews": trees, + "foundation_changes_requiring_activation_review": foundation} + except common.ERRORS: + return result + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--main", required=True, help="Explicit observed main; never discovered or updated here") + args = parser.parse_args() + result = inspect(Path(__file__).resolve().parents[2], args.main) + print(json.dumps(result, sort_keys=True)) + if result["status"] == "refused": + parser.exit(1, "Preparation refused invalid, stale or unsupported evidence.\n") + + +if __name__ == "__main__": + main() diff --git a/tests/test_ci_v13_expansion.py b/tests/test_ci_v13_expansion.py new file mode 100644 index 00000000..8b343aed --- /dev/null +++ b/tests/test_ci_v13_expansion.py @@ -0,0 +1,330 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Offline next-cohort preparation; never a live batch or activation receipt.""" + +import copy +import importlib +import json + +import pytest + +from conftest import REPO +from test_ci_delivery import batch, commit, delivery, git +from test_ci_cutover import cutover +from test_ci_v13_delivery import route_source, v13, v13_batch + + +def write(root, path, text): + target = root / path + target.parent.mkdir(parents=True, exist_ok=True) + target.write_text(text, encoding="utf-8") + + +@pytest.fixture +def expansion(delivery): + return importlib.import_module("v13_expansion") + + +@pytest.fixture +def policy(): + return json.loads((REPO / ".github/ci/v13-prepared-cohort.json").read_text()) + + +@pytest.fixture +def cohort(tmp_path, expansion, policy): + root = tmp_path / "cohort" + root.mkdir() + git(root, "init", "-q") + git(root, "config", "user.name", "CI Fixture") + git(root, "config", "user.email", "fixture@example.invalid") + git(root, "config", "core.autocrlf", "false") + git(root, "config", "core.filemode", "true") + for path in expansion.projection.P01_FILES: + write(root, path, "# frozen foundation\n") + write(root, "tests/test_sql_register_fixture.py", "# existing fixture\n") + anchor = commit(root, "frozen foundation") + policy["base"] = policy["prerequisite"] = anchor + for name, profile in policy["profiles"].items(): + git(root, "checkout", "-q", "--detach", anchor) + for path in profile["files"]: + write(root, path, "# " + name + " scoped source\n") + for task in profile["tasks"]: + write(root, expansion.projection.MARKERS + task, "") + head = commit(root, name) + profile["source"].update(anchor=anchor, head=head, commits=[head]) + profile["owner_consent"] = profile["review"] = None + git(root, "checkout", "-q", "--detach", anchor) + write(root, expansion.CONFIG, json.dumps(policy)) + return root, policy + + +def assert_full(result, expansion): + for key, value in expansion.FULL.items(): + assert result[key] == value + + +def test_ci_v13_expansion_real_manifest_is_disabled_and_separate(expansion, policy): + loaded, digest = expansion.read_policy(REPO) + assert loaded == policy + assert len(digest) == 64 + assert loaded["enabled"] is False + assert loaded["held_prs"] == [106] + assert loaded["order"] == ["P07", "P09"] + assert expansion.HISTORY_LIMITS == {"P07": 40, "P09": 165} + references = {"P07": (6947653181, 6948304918), "P09": (6956070097, 6958093018)} + for name, profile in loaded["profiles"].items(): + source = profile["source"] + assert source["head"] == profile["observed_head"] == source["commits"][-1] + assert len(source["commits"]) == expansion.HISTORY_LIMITS[name] + for key, comment in zip(("owner_consent", "review"), references[name]): + assert profile[key] == {"head": source["head"], "comment": comment} + assert loaded["profiles"]["P07"]["files"]["tests/sql_register_cleanup.py"] == "A" + assert loaded["profiles"]["P09"]["files"]["tests/conftest.py"] == "M" + active = expansion.projection.read_policy(REPO, "HEAD") + assert set(active["profiles"]) == {"P05", "P06"} + for path in ("delivery_route.py", "delivery_verify.py", "delivery_evidence.py", "delivery_v13.py"): + text = (REPO / ".github/ci" / path).read_text() + assert "v13_expansion" not in text + assert "v13-prepared-cohort" not in text + + +def test_ci_v13_expansion_missing_heads_stay_pending(cohort, expansion): + root, policy = cohort + profile = policy["profiles"]["P07"] + assert profile["observed_head"] is not None + profile["source"].update(head=None, commits=[]) + write(root, expansion.CONFIG, json.dumps(policy)) + result = expansion.inspect(root, policy["base"]) + assert result["status"] == "pending-owner-heads" + assert "previews" not in result + assert_full(result, expansion) + + +@pytest.mark.parametrize("linked", [False, True]) +def test_ci_v13_expansion_preview_preserves_full_and_exposes_foundation(cohort, expansion, linked): + root, policy = cohort + if linked: + for profile in policy["profiles"].values(): + for key in ("review", "owner_consent"): + profile[key] = {"head": profile["source"]["head"], "comment": 123} + write(root, expansion.CONFIG, json.dumps(policy)) + before = (git(root, "rev-parse", "HEAD"), git(root, "status", "--porcelain"), + git(root, "show-ref")) + result = expansion.inspect(root, policy["base"]) + expected = "preview-ready-for-review" if linked else "preview-pending-owner-reviews" + assert result["status"] == expected + assert [row["profile"] for row in result["previews"]] == ["P07", "P09"] + # P07 cannot transition the foundation; P09 changes it only in the final prefix. + helpers = {"tests/conftest.py", "tests/pgcluster.py"} + for helper in helpers: + original = git(root, "rev-parse", f"{policy['base']}:{helper}") + assert git(root, "rev-parse", f"{result['previews'][0]['tree']}:{helper}") == original + changed = git(root, "rev-parse", f"{result['previews'][1]['tree']}:{helper}") + assert changed == git(root, "rev-parse", f"{policy['profiles']['P09']['source']['head']}:{helper}") + assert changed != original + assert set(result["foundation_changes_requiring_activation_review"]) == helpers + assert_full(result, expansion) + assert before == (git(root, "rev-parse", "HEAD"), git(root, "status", "--porcelain"), + git(root, "show-ref")) + + +@pytest.mark.parametrize("name,count", [("P09", 4), ("P09", 12), ("P07", 13), ("P07", 16), + ("P07", 40), ("P09", 24), ("P09", 25), ("P09", 165)]) +def test_ci_v13_expansion_exact_bounded_fixes_can_be_previewed(cohort, expansion, name, count): + root, policy = cohort + (root / expansion.CONFIG).unlink() + profile = policy["profiles"][name] + git(root, "checkout", "-q", "--detach", profile["source"]["head"]) + for index in range(count - 1): + path = "tests/test_sql_register_shape.py" if name == "P07" else "tests/test_sql_register_bounds.py" + write(root, path, f"# exact fix {index}\n") + head = commit(root, "declared fix") + profile["source"]["commits"].append(head) + profile["source"]["head"] = head + git(root, "checkout", "-q", "--detach", policy["base"]) + write(root, expansion.CONFIG, json.dumps(policy)) + result = expansion.inspect(root, policy["base"]) + assert result["status"] == "preview-pending-owner-reviews" + assert_full(result, expansion) + + +@pytest.mark.parametrize("name,limit", [("P07", 40), ("P09", 165)]) +@pytest.mark.parametrize("overflow", [False, True]) +def test_ci_v13_expansion_per_profile_history_ceiling(tmp_path, expansion, policy, name, limit, overflow): + profile = policy["profiles"][name] + commits = [f"{index + 1:040x}" for index in range(limit + int(overflow))] + profile["source"].update(head=commits[-1], commits=commits) + profile["owner_consent"] = profile["review"] = None + write(tmp_path, expansion.CONFIG, json.dumps(policy)) + if overflow: + with pytest.raises(ValueError): + expansion.read_policy(tmp_path) + result = expansion.inspect(tmp_path, policy["base"]) + assert result["status"] == "refused" + assert_full(result, expansion) + else: + loaded, _digest = expansion.read_policy(tmp_path) + assert loaded["profiles"][name]["source"]["commits"] == commits + + +@pytest.mark.parametrize("fault", [None, "unlanded-anchor", "pre-prerequisite", "skipped-source"]) +def test_ci_v13_expansion_per_source_landed_anchor(cohort, expansion, fault): + root, policy = cohort + (root / expansion.CONFIG).unlink() + initial = policy["base"] + write(root, "landed-p03.txt", "# already landed prerequisite\n") + landed = commit(root, "landed P03") + policy["base"] = landed + profile = policy["profiles"]["P09"] + git(root, "checkout", "-q", "--detach", profile["source"]["head"]) + tree = git(root, "merge-tree", "--write-tree", landed, "HEAD") + head = git(root, "commit-tree", tree, "-p", landed, "-m", "P09 on landed P03") + profile["source"].update(anchor=landed, head=head, commits=[head]) + if fault == "unlanded-anchor": + policy["base"] = initial + elif fault == "pre-prerequisite": + policy["prerequisite"] = landed + elif fault == "skipped-source": + profile["source"]["anchor"] = initial + git(root, "checkout", "-q", "--detach", policy["base"]) + write(root, expansion.CONFIG, json.dumps(policy)) + result = expansion.inspect(root, policy["base"]) + assert result["status"] == ("refused" if fault else "preview-pending-owner-reviews") + assert_full(result, expansion) + + +@pytest.mark.parametrize("fault", [ + "enabled", "unknown-key", "boolean-schema", "unknown-profile", "wrong-order", + "release-unheld", "float-held-id", "wrong-number", "wrong-branch", "extra-file", "missing-file", + "wrong-status", "wrong-task", "unbound-lineage", "unbound-review", "wrong-scope", + "bad-observed-head", "boolean-comment", "duplicate-json", "oversized", "bad-anchor", "missing-anchor", + "missing-cleanup-helper", "modified-cleanup-helper", "missing-report-hook", "added-report-hook", +]) +def test_ci_v13_expansion_manifest_refuses_unsafe_or_ambiguous_input(tmp_path, expansion, policy, fault): + profile = policy["profiles"]["P07"] + if fault == "enabled": policy["enabled"] = True + elif fault == "unknown-key": policy["skip_ci"] = True + elif fault == "boolean-schema": policy["schema_version"] = True + elif fault == "unknown-profile": policy["profiles"]["P08"] = copy.deepcopy(profile) + elif fault == "wrong-order": policy["order"].reverse() + elif fault == "release-unheld": policy["held_prs"] = [] + elif fault == "float-held-id": policy["held_prs"] = [106.0] + elif fault == "wrong-number": profile["source"]["number"] = True + elif fault == "wrong-branch": profile["source"]["branch"] = "main" + elif fault == "extra-file": profile["files"]["lane-start"] = "M" + elif fault == "missing-file": profile["files"].pop("tests/test_sql_register_shape.py") + elif fault == "missing-cleanup-helper": profile["files"].pop("tests/sql_register_cleanup.py") + elif fault == "modified-cleanup-helper": profile["files"]["tests/sql_register_cleanup.py"] = "M" + elif fault == "missing-report-hook": policy["profiles"]["P09"]["files"].pop("tests/conftest.py") + elif fault == "added-report-hook": policy["profiles"]["P09"]["files"]["tests/conftest.py"] = "A" + elif fault == "wrong-status": profile["files"]["tests/test_sql_register_shape.py"] = "M" + elif fault == "wrong-task": profile["tasks"].append("T999") + elif fault == "unbound-lineage": profile["source"].update(head=None, commits=["a" * 40]) + elif fault == "unbound-review": profile["source"].update(head=None, commits=[]) + elif fault == "wrong-scope": policy["scope"] = "sql-register-v13" + elif fault == "bad-observed-head": profile["observed_head"] = "bad" + elif fault == "boolean-comment": policy["owner_coordination"] = True + elif fault == "bad-anchor": profile["source"]["anchor"] = "invalid" + elif fault == "missing-anchor": del profile["source"]["anchor"] + raw = json.dumps(policy) + if fault == "duplicate-json": raw = raw.replace('"enabled": false', '"enabled": false, "enabled": false') + elif fault == "oversized": raw += " " * 65537 + write(tmp_path, expansion.CONFIG, raw) + result = expansion.inspect(tmp_path, policy["base"]) + assert result["status"] == "refused" + assert_full(result, expansion) + + +@pytest.mark.parametrize("fault", [ + "extra-path", "nonempty-marker", "deleted-fixture", "executable", "symlink", + "unlisted-commit", "merge-commit", "overlong-history", "wrong-review-head", + "boolean-review-comment", "stale-main", "conflict", "temporary-offscope", "executable-cleanup-helper", +]) +def test_ci_v13_expansion_bound_source_refusals(cohort, expansion, fault): + root, policy = cohort + (root / expansion.CONFIG).unlink() + profile = policy["profiles"]["P07"] + source = profile["source"] + git(root, "checkout", "-q", "--detach", source["head"]) + if fault == "extra-path": write(root, "outside.py", "# mixed\n") + elif fault == "nonempty-marker": write(root, expansion.projection.MARKERS + "T210", "not empty\n") + elif fault == "deleted-fixture": (root / "tests/fixtures/lanes-edit-v1.1.0/SHA256SUMS").unlink() + elif fault == "executable": (root / "tests/test_sql_register_shape.py").chmod(0o755) + elif fault == "executable-cleanup-helper": (root / "tests/sql_register_cleanup.py").chmod(0o755) + elif fault == "symlink": + target = root / "tests/test_sql_register_shape.py" + target.unlink() + target.symlink_to("test_sql_register_render.py") + elif fault == "wrong-review-head": profile["review"] = {"head": "a" * 40, "comment": 123} + elif fault == "boolean-review-comment": profile["review"] = {"head": source["head"], "comment": True} + elif fault == "overlong-history": + source["commits"] = [f"{index + 1:040x}" for index in range(expansion.HISTORY_LIMITS["P07"] + 1)] + source["head"] = source["commits"][-1] + elif fault in ("stale-main", "conflict"): + git(root, "checkout", "-q", "--detach", policy["base"]) + write(root, "tests/pgcluster.py", "# conflicting foundation change\n") + moved = commit(root, "other main") + if fault == "conflict": policy["base"] = moved + elif fault == "merge-commit": + source["head"] = git(root, "commit-tree", git(root, "rev-parse", "HEAD^{tree}"), + "-p", source["head"], "-p", policy["base"], "-m", "merge") + source["commits"].append(source["head"]) + elif fault == "unlisted-commit": + write(root, "tests/test_sql_register_shape.py", "# undeclared fix\n") + source["head"] = commit(root, "unlisted fix") + source["commits"] = [source["head"]] + elif fault == "temporary-offscope": + write(root, "outside.py", "# temporary scope escape\n") + source["commits"].append(commit(root, "off-scope intermediate")) + (root / "outside.py").unlink() + source["head"] = commit(root, "restore final scope") + source["commits"].append(source["head"]) + if fault in {"extra-path", "nonempty-marker", "deleted-fixture", "executable", "symlink", "executable-cleanup-helper"}: + source["head"] = commit(root, "unsafe scoped fix") + source["commits"].append(source["head"]) + write(root, expansion.CONFIG, json.dumps(policy)) + main = moved if fault == "stale-main" else policy["base"] + result = expansion.inspect(root, main) + assert result["status"] == "refused" + assert result["reason"] == "invalid-preparation-context" + assert_full(result, expansion) + + +@pytest.mark.parametrize("fault", ["missing", "executable", "symlink"]) +def test_ci_v13_expansion_report_hook_requires_regular_modified_file(cohort, expansion, fault): + root, policy = cohort + (root / expansion.CONFIG).unlink() + profile = policy["profiles"]["P09"] + source = profile["source"] + git(root, "checkout", "-q", "--detach", source["head"]) + target = root / "tests/conftest.py" + if fault == "executable": + target.chmod(0o755) + else: + target.unlink() + if fault == "symlink": + target.symlink_to("pgcluster.py") + source["head"] = commit(root, "unsafe report hook") + source["commits"].append(source["head"]) + write(root, expansion.CONFIG, json.dumps(policy)) + result = expansion.inspect(root, policy["base"]) + assert result["status"] == "refused" + assert_full(result, expansion) + + +def test_ci_v13_expansion_refusal_never_echoes_private_values(tmp_path, expansion, policy): + private = "PRIVATE_BRANCH_VALUE_DO_NOT_ECHO" + policy["profiles"]["P07"]["source"]["branch"] = private + write(tmp_path, expansion.CONFIG, json.dumps(policy)) + result = expansion.inspect(tmp_path, policy["base"]) + assert result["status"] == "refused" + assert private not in json.dumps(result) + + +@pytest.mark.parametrize("name", ["P07", "P09"]) +def test_ci_v13_expansion_live_delivery_retains_full_fallback(cutover, v13_batch, name): + write(v13_batch["root"], ".github/ci/v13-prepared-cohort.json", + (REPO / ".github/ci/v13-prepared-cohort.json").read_text()) + body = "CI-Shadow: sql-register-v13\nCI-Delivery: sql-register-v13\nCI-Task-Set: " + name + result = route_source(cutover, v13_batch, body) + assert result["omit_full"] is False + assert result["mode"] == "full"