|
| 1 | +name: Temporary Chat bootstrap authority repin |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - fix/repin-chat-bootstrap-authority |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + patch-and-verify: |
| 13 | + if: github.actor != 'github-actions[bot]' |
| 14 | + runs-on: ubuntu-24.04 |
| 15 | + timeout-minutes: 30 |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
| 20 | + persist-credentials: true |
| 21 | + ref: ${{ github.ref_name }} |
| 22 | + - uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 |
| 23 | + with: |
| 24 | + version: 10.34.0 |
| 25 | + - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 |
| 26 | + with: |
| 27 | + node-version: 24.18.1 |
| 28 | + cache: pnpm |
| 29 | + - name: Install frozen dependencies |
| 30 | + run: pnpm install --frozen-lockfile --ignore-scripts |
| 31 | + - name: Fetch exact merged Chat workflow |
| 32 | + run: | |
| 33 | + curl --proto '=https' --tlsv1.2 --fail --location --silent --show-error \ |
| 34 | + 'https://raw.githubusercontent.com/OpenCoven/chat/fa2f9bfeca25a5d9a91660448d18c062ca22a14d/.github/workflows/client-v1-conformance.yml' \ |
| 35 | + --output .tmp-client-v1-conformance.yml |
| 36 | + - name: Repin authority and validator semantics |
| 37 | + run: | |
| 38 | + node --input-type=module <<'NODE' |
| 39 | + import { createHash } from 'node:crypto'; |
| 40 | + import { readFileSync, writeFileSync } from 'node:fs'; |
| 41 | + import { parseReleaseWorkflowDocument } from './scripts/release-readiness.mjs'; |
| 42 | +
|
| 43 | + const oldAuthority = { |
| 44 | + commit: 'a57cc2669aaa0383e46589dbf5ed13ea994eac48', |
| 45 | + tree: '4612ef136ba21bfae553edf6de49234ed2d267aa', |
| 46 | + workflowSize: 442822, |
| 47 | + workflowSha256: '79a73b778b04f47467d243e6bfb5e556f5f61a4cab9aee004c7b5e3f7595c9dc', |
| 48 | + windowsBootstrapSha256: '033500c97f4c5b5a01e45c3d309543ccb384705b8591b11fca9a1aea113ec27d', |
| 49 | + }; |
| 50 | + const newAuthority = { |
| 51 | + commit: 'fa2f9bfeca25a5d9a91660448d18c062ca22a14d', |
| 52 | + tree: 'a9e119f5ab526ec377236d48337ac4860308afd1', |
| 53 | + workflowSize: 442868, |
| 54 | + workflowSha256: '6c3fcc8f0c9b34c918b241597cf97cc25a5e31fef991e1f915d71ea7a85b06cb', |
| 55 | + }; |
| 56 | + const sha256 = (value) => createHash('sha256').update(value).digest('hex'); |
| 57 | + const workflowBytes = readFileSync('.tmp-client-v1-conformance.yml'); |
| 58 | + if ( |
| 59 | + workflowBytes.byteLength !== newAuthority.workflowSize |
| 60 | + || sha256(workflowBytes) !== newAuthority.workflowSha256 |
| 61 | + ) { |
| 62 | + throw new Error('Merged Chat workflow bytes do not match the reviewed #58 authority.'); |
| 63 | + } |
| 64 | + const workflow = parseReleaseWorkflowDocument(workflowBytes.toString('utf8')); |
| 65 | + const platformSteps = workflow.jobs?.['platform-conformance']?.steps; |
| 66 | + if (!Array.isArray(platformSteps)) { |
| 67 | + throw new Error('Merged Chat workflow is missing platform-conformance steps.'); |
| 68 | + } |
| 69 | + const step = (name) => { |
| 70 | + const matches = platformSteps.filter((candidate) => candidate?.name === name); |
| 71 | + if (matches.length !== 1 || typeof matches[0].run !== 'string') { |
| 72 | + throw new Error(`Merged Chat workflow must contain exactly one ${name} run step.`); |
| 73 | + } |
| 74 | + return matches[0]; |
| 75 | + }; |
| 76 | + const windowsBootstrap = step('Bootstrap supervised Windows conformance'); |
| 77 | + const frozenToolchain = step('Require frozen toolchain'); |
| 78 | + const windowsBootstrapSha256 = sha256(windowsBootstrap.run); |
| 79 | + if ( |
| 80 | + windowsBootstrapSha256 === oldAuthority.windowsBootstrapSha256 |
| 81 | + || !windowsBootstrap.run.includes('if ($item -is [IO.FileInfo])') |
| 82 | + || !windowsBootstrap.run.includes('$item = $item.Directory') |
| 83 | + ) { |
| 84 | + throw new Error('Merged Chat workflow does not contain the reviewed strict-PowerShell repair.'); |
| 85 | + } |
| 86 | + if ( |
| 87 | + frozenToolchain.run.includes("['exec', 'tauri', '--version']") |
| 88 | + || !frozenToolchain.run.includes("run('rustc', ['--version'])") |
| 89 | + ) { |
| 90 | + throw new Error('Merged Chat workflow does not defer Tauri verification until after dependency install.'); |
| 91 | + } |
| 92 | +
|
| 93 | + const replaceExact = (path, before, after) => { |
| 94 | + const source = readFileSync(path, 'utf8'); |
| 95 | + const count = source.split(before).length - 1; |
| 96 | + if (count !== 1) { |
| 97 | + throw new Error(`${path}: expected one exact patch target, found ${count}.`); |
| 98 | + } |
| 99 | + writeFileSync(path, source.replace(before, after)); |
| 100 | + }; |
| 101 | + replaceExact( |
| 102 | + 'scripts/github-conformance-evidence.mjs', |
| 103 | + [ |
| 104 | + " `|| !run('rustc', ['--version']).startsWith('rustc ${toolchain.rustVersion} ')`,", |
| 105 | + " `|| run('pnpm', ['exec', 'tauri', '--version'])`,", |
| 106 | + " `!== 'tauri-cli ${toolchain.tauriVersion}')`,", |
| 107 | + ].join('\n'), |
| 108 | + " `|| !run('rustc', ['--version']).startsWith('rustc ${toolchain.rustVersion} '))`,", |
| 109 | + ); |
| 110 | + replaceExact( |
| 111 | + 'tests/conformance-gaps.spec.ts', |
| 112 | + String.raw` '|| !run(\'rustc\', [\'--version\']).startsWith(\'rustc 1.95.0 \')', |
| 113 | + ` + String.raw` '|| run(\'pnpm\', [\'exec\', \'tauri\', \'--version\'])', |
| 114 | + ` + String.raw` '!== \'tauri-cli 2.11.4\')',`, |
| 115 | + String.raw` '|| !run(\'rustc\', [\'--version\']).startsWith(\'rustc 1.95.0 \'))',`, |
| 116 | + ); |
| 117 | +
|
| 118 | + const lockPath = 'conformance/client-v1-cross-repository-lock.json'; |
| 119 | + const lock = JSON.parse(readFileSync(lockPath, 'utf8')); |
| 120 | + const producer = lock.evidenceProducer; |
| 121 | + if ( |
| 122 | + producer?.commit !== oldAuthority.commit |
| 123 | + || producer?.tree !== oldAuthority.tree |
| 124 | + || producer?.workflow?.size !== oldAuthority.workflowSize |
| 125 | + || producer?.workflow?.sha256 !== oldAuthority.workflowSha256 |
| 126 | + || producer?.workflow?.windowsBootstrapScriptSha256 |
| 127 | + !== oldAuthority.windowsBootstrapSha256 |
| 128 | + ) { |
| 129 | + throw new Error('SDK producer lock is not at the expected pre-repin authority.'); |
| 130 | + } |
| 131 | + producer.commit = newAuthority.commit; |
| 132 | + producer.tree = newAuthority.tree; |
| 133 | + producer.workflow.size = newAuthority.workflowSize; |
| 134 | + producer.workflow.sha256 = newAuthority.workflowSha256; |
| 135 | + producer.workflow.windowsBootstrapScriptSha256 = windowsBootstrapSha256; |
| 136 | + producer.workflow.signerDigest = newAuthority.commit; |
| 137 | + producer.workflow.sourceDigest = newAuthority.commit; |
| 138 | + writeFileSync(lockPath, `${JSON.stringify(lock, null, 2)}\n`); |
| 139 | +
|
| 140 | + const authorityPaths = [ |
| 141 | + 'RELEASING.md', |
| 142 | + 'docs/workflows/client-v1-cross-repository-conformance.md', |
| 143 | + 'tests/conformance-contract.spec.ts', |
| 144 | + 'tests/conformance-gaps.spec.ts', |
| 145 | + ]; |
| 146 | + const replacements = [ |
| 147 | + [oldAuthority.commit, newAuthority.commit], |
| 148 | + [oldAuthority.tree, newAuthority.tree], |
| 149 | + [oldAuthority.workflowSha256, newAuthority.workflowSha256], |
| 150 | + [oldAuthority.windowsBootstrapSha256, windowsBootstrapSha256], |
| 151 | + ['442_822', '442_868'], |
| 152 | + ['442,822', '442,868'], |
| 153 | + ['442822', '442868'], |
| 154 | + ]; |
| 155 | + for (const path of authorityPaths) { |
| 156 | + let source = readFileSync(path, 'utf8'); |
| 157 | + for (const [before, after] of replacements) { |
| 158 | + source = source.replaceAll(before, after); |
| 159 | + } |
| 160 | + writeFileSync(path, source); |
| 161 | + } |
| 162 | +
|
| 163 | + console.log(JSON.stringify({ |
| 164 | + producerCommit: newAuthority.commit, |
| 165 | + producerTree: newAuthority.tree, |
| 166 | + workflowSize: newAuthority.workflowSize, |
| 167 | + workflowSha256: newAuthority.workflowSha256, |
| 168 | + windowsBootstrapSha256, |
| 169 | + }, null, 2)); |
| 170 | + NODE |
| 171 | + rm .tmp-client-v1-conformance.yml |
| 172 | + - name: Reject stale producer authority |
| 173 | + run: | |
| 174 | + stale=0 |
| 175 | + for value in \ |
| 176 | + a57cc2669aaa0383e46589dbf5ed13ea994eac48 \ |
| 177 | + 4612ef136ba21bfae553edf6de49234ed2d267aa \ |
| 178 | + 79a73b778b04f47467d243e6bfb5e556f5f61a4cab9aee004c7b5e3f7595c9dc \ |
| 179 | + 033500c97f4c5b5a01e45c3d309543ccb384705b8591b11fca9a1aea113ec27d |
| 180 | + do |
| 181 | + if git grep -n --fixed-strings "$value" -- . ':!.github/workflows/temporary-repin-chat-bootstrap.yml'; then |
| 182 | + stale=1 |
| 183 | + fi |
| 184 | + done |
| 185 | + test "$stale" -eq 0 |
| 186 | + - name: Verify focused conformance contract |
| 187 | + run: | |
| 188 | + pnpm typecheck |
| 189 | + pnpm test:conformance-contract |
| 190 | + pnpm lint |
| 191 | + - name: Commit verified repin and retire temporary workflow |
| 192 | + run: | |
| 193 | + git rm .github/workflows/temporary-repin-chat-bootstrap.yml |
| 194 | + git config user.name 'github-actions[bot]' |
| 195 | + git config user.email '41898282+github-actions[bot]@users.noreply.github.com' |
| 196 | + git add \ |
| 197 | + RELEASING.md \ |
| 198 | + conformance/client-v1-cross-repository-lock.json \ |
| 199 | + docs/workflows/client-v1-cross-repository-conformance.md \ |
| 200 | + scripts/github-conformance-evidence.mjs \ |
| 201 | + tests/conformance-contract.spec.ts \ |
| 202 | + tests/conformance-gaps.spec.ts |
| 203 | + git diff --cached --check |
| 204 | + git commit -m 'fix(conformance): repin merged Chat bootstrap authority' |
| 205 | + git push origin HEAD:${{ github.ref_name }} |
0 commit comments