From e7184625511b1bda05dfbf4c6acebcc5fcb1337d Mon Sep 17 00:00:00 2001 From: Antuz tap Date: Sat, 24 Oct 2026 09:23:22 +0000 Subject: [PATCH 1/2] ci: prepare inactive bea Android observation profile --- .github/scripts/read-bea-android-artifact.cjs | 126 ++++++++++++++ .github/scripts/read-bea-android-artifact.py | 118 +++++++++++++ .../bea-android-artifact-readout.test.cjs | 157 ++++++++++++++++++ .../test_bea_android_artifact_readout.py | 140 ++++++++++++++++ .../r5-bea-android-artifact-readout.yml | 36 ++++ docs/r5/BEA-ANDROID-READOUT-PREP.md | 7 + 6 files changed, 584 insertions(+) create mode 100644 .github/scripts/read-bea-android-artifact.cjs create mode 100644 .github/scripts/read-bea-android-artifact.py create mode 100644 .github/tests/bea-android-artifact-readout.test.cjs create mode 100644 .github/tests/test_bea_android_artifact_readout.py create mode 100644 .github/workflows/r5-bea-android-artifact-readout.yml create mode 100644 docs/r5/BEA-ANDROID-READOUT-PREP.md diff --git a/.github/scripts/read-bea-android-artifact.cjs b/.github/scripts/read-bea-android-artifact.cjs new file mode 100644 index 000000000..4adfec391 --- /dev/null +++ b/.github/scripts/read-bea-android-artifact.cjs @@ -0,0 +1,126 @@ +'use strict'; +// One finite metadata projection; no native worker, release authority or selector input. +const assert = require('node:assert/strict'); +const crypto = require('node:crypto'); +const fs = require('node:fs'); +const path = require('node:path'); +const { execFileSync } = require('node:child_process'); +const OWNER = 'KeeperCommunity', REPO = 'bitcoin-keeper'; +const RUN = 40078818062, JOB = 120835800614; +const SOURCE = 'bea6056724dd75d1db99f4ce394ba4896edd10bf'; +const WORKFLOW = null, NATIVE_HEAD_BRANCH = null, WORKFLOW_PULL_REF = null, RUN_CONCLUSION = null; +// Exact terminal Android job/artifact API and upload facts. +const ARTIFACT = null, ZIP_SIZE = null, DIGEST = null; +const NATIVE_CONCLUSION = null, STEP_CONCLUSIONS = null; +const STEPS = ['Build development app', 'Run Android startup and native persistence probes']; +const CONCLUSIONS = ['success', 'failure', 'skipped']; +const NAME = `keeper-diagnostic-native-ANDROID-${SOURCE}-${RUN}-1`; + +async function run({ github, context, core }) { + let owned, primary = false, output, stage = 'SELECTION'; + try { + assert.match(WORKFLOW ?? '', /^[a-f0-9]{40}$/); + assert.ok(typeof NATIVE_HEAD_BRANCH === 'string' && /^codex\/[a-z0-9-]+$/.test(NATIVE_HEAD_BRANCH)); + assert.match(WORKFLOW_PULL_REF ?? '', /^refs\/pull\/[1-9][0-9]*\/merge$/); + assert.ok(['success', 'failure'].includes(RUN_CONCLUSION)); + assert.ok(Number.isSafeInteger(ARTIFACT) && ARTIFACT > 0); + assert.ok(Number.isSafeInteger(ZIP_SIZE) && ZIP_SIZE > 0 && ZIP_SIZE <= 1024 * 1024 + 4096); + assert.match(DIGEST ?? '', /^[a-f0-9]{64}$/); + assert.ok(['success', 'failure'].includes(NATIVE_CONCLUSION)); + assert.ok(Array.isArray(STEP_CONCLUSIONS) && STEP_CONCLUSIONS.length === STEPS.length && + STEPS.every((_, index) => CONCLUSIONS.includes(STEP_CONCLUSIONS[index]))); + assert.equal(context.repo.owner, OWNER); assert.equal(context.repo.repo, REPO); + assert.equal(context.eventName, 'push'); + assert.equal(context.ref, 'refs/heads/codex/r5-bea-android-artifact-readout-20261024'); + const args = { owner: OWNER, repo: REPO, request: { timeout: 30000 } }; + const admit = async () => { + stage = 'API_LOOKUP'; + const [r, j, a] = await Promise.all([ + github.rest.actions.getWorkflowRun({ ...args, run_id: RUN }), + github.rest.actions.getJobForWorkflowRun({ ...args, job_id: JOB }), + github.rest.actions.getArtifact({ ...args, artifact_id: ARTIFACT }), + ]); + stage = 'RUN_BINDING'; + assert.equal(r.data.id, RUN); assert.equal(r.data.run_attempt, 1); + assert.equal(r.data.repository.id, 470904030); assert.equal(r.data.head_repository.id, 470904030); + assert.equal(r.data.head_sha, SOURCE); assert.equal(r.data.event, 'pull_request'); + assert.equal(r.data.head_branch, NATIVE_HEAD_BRANCH); + assert.equal(r.data.path, '.github/workflows/keeper-native-diagnostic.yml'); + assert.equal(r.data.status, 'completed'); assert.equal(r.data.conclusion, RUN_CONCLUSION); + assert.deepEqual(r.data.referenced_workflows, [{ + path: `${OWNER}/${REPO}/.github/workflows/keeper-native-platform.yml@${WORKFLOW}`, + ref: WORKFLOW_PULL_REF, sha: WORKFLOW, + }]); + stage = 'JOB_BINDING'; + assert.equal(j.data.id, JOB); assert.equal(j.data.run_id, RUN); assert.equal(j.data.run_attempt, 1); + assert.equal(j.data.head_sha, SOURCE); assert.equal(j.data.status, 'completed'); + assert.equal(j.data.conclusion, NATIVE_CONCLUSION); + for (const [index, name] of STEPS.entries()) { + const steps = j.data.steps.filter(step => step.name === name); + assert.equal(steps.length, 1); assert.equal(steps[0].status, 'completed'); + assert.equal(steps[0].conclusion, STEP_CONCLUSIONS[index]); + } + const upload = j.data.steps.filter(step => step.name === 'Retain safe Phase A evidence'); + assert.equal(upload.length, 1); assert.equal(upload[0].status, 'completed'); + assert.equal(upload[0].conclusion, 'success'); + stage = 'ARTIFACT_BINDING'; + assert.equal(a.data.id, ARTIFACT); assert.equal(a.data.name, NAME); + assert.equal(a.data.expired, false); assert.equal(a.data.size_in_bytes, ZIP_SIZE); + assert.equal(a.data.digest, `sha256:${DIGEST}`); + assert.equal(a.data.workflow_run.id, RUN); assert.equal(a.data.workflow_run.head_sha, SOURCE); + assert.equal(a.data.workflow_run.repository_id, 470904030); + assert.equal(a.data.workflow_run.head_repository_id, 470904030); + }; + await admit(); + stage = 'DOWNLOAD'; + const download = await github.rest.actions.downloadArtifact({ ...args, artifact_id: ARTIFACT, archive_format: 'zip' }); + const bytes = Buffer.from(download.data); + assert.equal(bytes.length, ZIP_SIZE); + assert.equal(crypto.createHash('sha256').update(bytes).digest('hex'), DIGEST); + stage = 'PRIVATE_FILE'; + const temp = process.env.RUNNER_TEMP; + assert.ok(temp && path.isAbsolute(temp)); assert.equal(fs.realpathSync(temp), path.resolve(temp)); + const filename = path.join(temp, 'r5-bea-android-fixed.zip'); + const descriptor = fs.openSync(filename, 'wx', 0o600); owned = filename; + try { fs.writeFileSync(descriptor, bytes); } + finally { fs.closeSync(descriptor); } + stage = 'DECODE'; + try { + output = execFileSync('python3', ['-B', '.github/scripts/read-bea-android-artifact.py'], + { encoding: 'utf8', timeout: 30000, maxBuffer: 2 * 1024 * 1024, stdio: ['ignore', 'pipe', 'pipe'] }); + } catch (error) { + const match = /^BEA_ANDROID_OBSERVATION_READOUT_FAILED:(SELECTION|PRIVATE_FILE|KERNEL|ZIP_IDENTITY|ZIP_LAYOUT|JSON|ROOT_KEYS|PRODUCT|PROJECTED_METADATA)\n$/.exec(String(error.stdout ?? '')); + if (match) stage = 'DECODE_' + match[1]; + throw error; + } + stage = 'PROJECTION_FRAME'; + const lines = output.trim().split('\n'); + assert.equal(lines.length, 3); + assert.equal(lines[0], 'BEA_ANDROID_OBSERVATIONS_BEGIN'); + assert.equal(lines[2], 'BEA_ANDROID_OBSERVATIONS_END'); + const projection = JSON.parse(lines[1]); + assert.deepEqual(Object.keys(projection).sort(), ['schema', 'scope', 'original_zip_sha256', 'metadata_sha256', 'observations'].sort()); + assert.equal(projection.schema, 1); + assert.equal(projection.scope, 'OBSERVATIONS_ONLY_NOT_NATIVE_ACCEPTANCE_OR_CAUSE'); + assert.equal(projection.original_zip_sha256, DIGEST); + assert.match(projection.metadata_sha256, /^[a-f0-9]{64}$/); + assert.equal(projection.observations.source_sha, SOURCE); + assert.equal(projection.observations.run_id, String(RUN)); + assert.equal(projection.observations.run_attempt, '1'); + await admit(); // Recheck official immutable source/workflow/job/attempt/artifact before releasing output. + } catch (_) { + primary = true; + throw new Error('FIXED_NATIVE_ARTIFACT_READOUT_FAILED_' + stage); + } finally { + if (owned) { + try { fs.unlinkSync(owned); } + catch (_) { + try { core.warning('FIXED_NATIVE_ARTIFACT_PRIVATE_CLEANUP_FAILED'); } catch (_) { /* retain primary */ } + if (!primary) throw new Error('FIXED_NATIVE_ARTIFACT_PRIVATE_CLEANUP_FAILED'); + } + } + } + try { core.info(output.trim()); } + catch (_) { throw new Error('FIXED_NATIVE_ARTIFACT_READOUT_FAILED'); } +} +module.exports = { run }; diff --git a/.github/scripts/read-bea-android-artifact.py b/.github/scripts/read-bea-android-artifact.py new file mode 100644 index 000000000..5606fddbb --- /dev/null +++ b/.github/scripts/read-bea-android-artifact.py @@ -0,0 +1,118 @@ +#!/usr/bin/env python3 +"""Project fixed bea Android failure facts using the unchanged 044 kernel.""" +import hashlib +import importlib.util +import io +import json +import os +from pathlib import Path +import stat +import zipfile + +ROOT = Path(__file__).parent +KERNEL_SHA256 = '1e9fc4370d733041fb5a48dc8c022e3461decafbf970ba030e90784208aed1d9' +SOURCE = 'bea6056724dd75d1db99f4ce394ba4896edd10bf' +WORKFLOW = None +WORKFLOW_REF = None +RUN, ATTEMPT = '40078818062', '1' +ZIP_SIZE = None +DIGEST = None +PRODUCT_STATUS = None +SCOPE = 'OBSERVATIONS_ONLY_NOT_NATIVE_ACCEPTANCE_OR_CAUSE' +PHASE = 'SELECTION' +FIELDS = frozenset(('schema', 'source_sha', 'workflow_sha', 'workflow_ref', 'run_id', 'run_attempt', + 'platform', 'diagnostic_only', 'build', 'smoke', 'native_probe', 'r5_features', 'hardware', 'signing', + 'app_id', 'install_succeeded', 'installed_artifact_verified')) +SAMPLE_FIELDS = frozenset(('sample', 'status', 'completed_stages', 'pin_onboarding_progress', + 'create_new_app_calls', 'other_backend_calls_rejected', 'failure_observation', + 'failed_assertion_snapshot', 'android_runtime_diagnostic')) + + +def require_binding(): + import re + if (type(WORKFLOW) is not str or not re.fullmatch(r'[a-f0-9]{40}', WORKFLOW) or + type(WORKFLOW_REF) is not str or not re.fullmatch( + r'KeeperCommunity/bitcoin-keeper/\.github/workflows/keeper-native-diagnostic\.yml@refs/pull/[1-9][0-9]*/merge', WORKFLOW_REF) or + type(ZIP_SIZE) is not int or not 0 < ZIP_SIZE <= 1024 * 1024 + 4096 or + type(DIGEST) is not str or not re.fullmatch(r'[a-f0-9]{64}', DIGEST) or + PRODUCT_STATUS not in ('PASS', 'FAIL')): + raise ValueError('Exact completed artifact bindings unavailable.') + + +def project(blob): + global PHASE + PHASE = 'SELECTION' + require_binding() + PHASE = 'KERNEL' + source = ROOT / 'read-044-android-artifact.py' + if hashlib.sha256(source.read_bytes()).hexdigest() != KERNEL_SHA256: + raise ValueError('Fixed kernel changed.') + spec = importlib.util.spec_from_file_location('fixed_044_android_kernel', source) + kernel = importlib.util.module_from_spec(spec) + spec.loader.exec_module(kernel) + literals = kernel.public_literals() # Original hash-checked policy remains unchanged. + kernel.SOURCE, kernel.WORKFLOW, kernel.WORKFLOW_REF = SOURCE, WORKFLOW, WORKFLOW_REF + kernel.RUN, kernel.ATTEMPT = RUN, ATTEMPT + kernel.public_literals = lambda: literals | {'onboarding-markers', SOURCE, WORKFLOW, WORKFLOW_REF, RUN, ATTEMPT} + PHASE = 'ZIP_IDENTITY' + if type(blob) is not bytes or len(blob) != ZIP_SIZE or hashlib.sha256(blob).hexdigest() != DIGEST: + kernel.rejected() + PHASE = 'ZIP_LAYOUT' + with zipfile.ZipFile(io.BytesIO(blob)) as archive: + members = archive.infolist() + if len(members) != 1: + kernel.rejected() + entry = members[0] + if (entry.filename != 'android/metadata.json' or entry.orig_filename != entry.filename or + entry.flag_bits & 1 or stat.S_IFMT(entry.external_attr >> 16) not in (0, stat.S_IFREG) or + entry.file_size > kernel.LIMIT or entry.compress_type not in (zipfile.ZIP_STORED, zipfile.ZIP_DEFLATED)): + kernel.rejected() + raw = kernel.canonical_payload(blob, entry, archive.start_dir, archive.comment) + PHASE = 'JSON' + data = json.loads(raw, object_pairs_hook=kernel.pairs, parse_float=kernel.finite, + parse_constant=lambda _: kernel.rejected()) + PHASE = 'ROOT_KEYS' + if type(data) is not dict or not set(data) <= kernel.ROOT_KEYS: + kernel.rejected() + projected = {key: value for key, value in data.items() if key in FIELDS} + PHASE = 'PRODUCT' + product = data.get('product_ui') + if (type(product) is not dict or product.get('status') != PRODUCT_STATUS or + type(product.get('samples')) is not list or not 1 <= len(product['samples']) <= 6 or + any(type(sample) is not dict for sample in product['samples'])): + kernel.rejected() + projected['product_ui'] = {key: product[key] for key in ('status', 'failure_category') if key in product} + projected['product_ui']['samples'] = [{key: value for key, value in sample.items() if key in SAMPLE_FIELDS} + for sample in product['samples']] + PHASE = 'PROJECTED_METADATA' + kernel.validate_metadata(projected) + return {'schema': 1, 'scope': SCOPE, 'original_zip_sha256': DIGEST, + 'metadata_sha256': hashlib.sha256(raw).hexdigest(), 'observations': projected} + + +def main(argv=None): + global PHASE + PHASE = 'SELECTION' + try: + require_binding() + if argv: + raise ValueError('No selectors.') + PHASE = 'PRIVATE_FILE' + path = Path(os.environ['RUNNER_TEMP']) / 'r5-bea-android-fixed.zip' + with os.fdopen(os.open(path, os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK), 'rb') as source: + info = os.fstat(source.fileno()) + if not stat.S_ISREG(info.st_mode) or stat.S_IMODE(info.st_mode) != 0o600 or info.st_size != ZIP_SIZE: + raise ValueError('Invalid private file.') + result = project(source.read(ZIP_SIZE + 1)) + except Exception: + print('BEA_ANDROID_OBSERVATION_READOUT_FAILED:' + PHASE) + return 1 + print('BEA_ANDROID_OBSERVATIONS_BEGIN') + print(json.dumps(result, sort_keys=True, separators=(',', ':'))) + print('BEA_ANDROID_OBSERVATIONS_END') + return 0 + + +if __name__ == '__main__': + import sys + raise SystemExit(main(sys.argv[1:])) diff --git a/.github/tests/bea-android-artifact-readout.test.cjs b/.github/tests/bea-android-artifact-readout.test.cjs new file mode 100644 index 000000000..63965fe22 --- /dev/null +++ b/.github/tests/bea-android-artifact-readout.test.cjs @@ -0,0 +1,157 @@ +'use strict'; +// Fabricated API and byte transport only; no current artifact/native operation. +const assert = require('node:assert/strict'); +const crypto = require('node:crypto'); +const fs = require('node:fs'); +const path = require('node:path'); +const test = require('node:test'); +const vm = require('node:vm'); +const SCRIPT = path.join(__dirname, '../scripts/read-bea-android-artifact.cjs'); +const SOURCE = 'bea6056724dd75d1db99f4ce394ba4896edd10bf'; +const WORKFLOW = 'a'.repeat(40); +const BINDINGS = 'const WORKFLOW = null, NATIVE_HEAD_BRANCH = null, WORKFLOW_PULL_REF = null, RUN_CONCLUSION = null;'; +const PAYLOAD = Buffer.from('OFFLINE_SYNTHETIC_METADATA_ZIP_BYTES'); +const DIGEST = crypto.createHash('sha256').update(PAYLOAD).digest('hex'); +const SELECTION = 'const ARTIFACT = null, ZIP_SIZE = null, DIGEST = null;'; +const OUTCOME = 'const NATIVE_CONCLUSION = null, STEP_CONCLUSIONS = null;'; + +function fixture(options = {}) { + const context = { repo: { owner: 'KeeperCommunity', repo: 'bitcoin-keeper' }, + eventName: 'push', ref: 'refs/heads/codex/r5-bea-android-artifact-readout-20261024' }; + const runData = { id: 40078818062, run_attempt: 1, repository: { id: 470904030 }, + head_repository: { id: 470904030 }, head_sha: SOURCE, event: 'pull_request', + head_branch: 'codex/fixed-native-fixture', + path: '.github/workflows/keeper-native-diagnostic.yml', status: 'completed', conclusion: 'failure', + referenced_workflows: [{path: `KeeperCommunity/bitcoin-keeper/.github/workflows/keeper-native-platform.yml@${WORKFLOW}`, + ref: 'refs/pull/9999/merge', sha: WORKFLOW}] }; + const jobData = { id: 120835800614, run_id: 40078818062, run_attempt: 1, head_sha: SOURCE, + status: 'completed', conclusion: 'failure', steps: [ + ['Build development app', 'success'], ['Run Android startup and native persistence probes', 'failure'], ['Retain safe Phase A evidence', 'success'] + ].map(([name, conclusion]) => ({name, conclusion, status: 'completed'})) }; + const artifact = {id: options.production ? 12551461839 : 991, + name: `keeper-diagnostic-native-ANDROID-${SOURCE}-40078818062-1`, expired: false, + size_in_bytes: options.production ? 9596 : PAYLOAD.length, + digest: 'sha256:' + (options.production ? 'b9182e02a33b7e0568d73654b42d61f66bce8e425d65a6960aa0f4f2194ee13a' : DIGEST), workflow_run: { + id: 40078818062, head_sha: SOURCE, repository_id: 470904030, head_repository_id: 470904030}}; + const calls = [], events = [], output = [], actions = {}; + for (const [name, data] of [['getWorkflowRun', runData], ['getJobForWorkflowRun', jobData], ['getArtifact', artifact]]) { + actions[name] = async args => { calls.push([name, args]); return {data}; }; + } + actions.downloadArtifact = async args => {calls.push(['downloadArtifact', args]); if(options.after) options.after({runData,jobData,artifact}); return {data: options.payload ?? PAYLOAD};}; + const inputs = {github: {rest: {actions}}, context, core: { + info(value) {events.push('info'); if (options.info) throw Error('PRIVATE_SENTINEL'); output.push(value);}, + warning(value) {events.push('warning'); if (options.warning) throw Error('PRIVATE_SENTINEL'); output.push(value);}}}; + let source = fs.readFileSync(SCRIPT, 'utf8'); + assert.ok(source.includes(SELECTION) && source.includes(OUTCOME)); + if (!options.production) source = source.replace(SELECTION, + `const ARTIFACT = 991, ZIP_SIZE = ${PAYLOAD.length}, DIGEST = '${DIGEST}';`).replace(BINDINGS, + `const WORKFLOW = '${WORKFLOW}', NATIVE_HEAD_BRANCH = 'codex/fixed-native-fixture', WORKFLOW_PULL_REF = 'refs/pull/9999/merge', RUN_CONCLUSION = 'failure';`).replace(OUTCOME, + "const NATIVE_CONCLUSION = 'failure', STEP_CONCLUSIONS = ['success', 'failure'];"); + if (options.edit) source = options.edit(source); + const api = {module: {exports: {}}, Buffer, process: {env: {RUNNER_TEMP: '/owned'}}, require(name) { + if (name === 'node:assert/strict') return {...assert, deepEqual(a,b) {assert.deepEqual(JSON.parse(JSON.stringify(a)), JSON.parse(JSON.stringify(b)));}}; + if (name === 'node:crypto') return crypto; + if (name === 'node:path') return path; + if (name === 'node:fs') return {realpathSync: x => x, + openSync(file, flags, mode) {assert.equal(file, '/owned/r5-bea-android-fixed.zip'); assert.equal(flags, 'wx'); assert.equal(mode, 0o600); events.push('open'); return 42;}, + writeFileSync(fd, bytes) {assert.equal(fd,42); assert.deepEqual(bytes,PAYLOAD); events.push('write'); if(options.write) throw Error('PRIVATE_SENTINEL');}, + closeSync(fd) {assert.equal(fd,42); events.push('close'); if(options.close) throw Error('PRIVATE_SENTINEL');}, + unlinkSync() {events.push('unlink'); if(options.unlink) throw Error('PRIVATE_SENTINEL');}}; + if (name === 'node:child_process') return {execFileSync(command,args,settings) { + assert.equal(command,'python3'); assert.deepEqual(Array.from(args),['-B','.github/scripts/read-bea-android-artifact.py']); + assert.equal(settings.timeout,30000); events.push('decoder'); if(options.decoder) { + const error = Error('PRIVATE_SENTINEL'); error.stdout = options.decoderOutput; throw error; + } + return options.wrongOutput ? 'PRIVATE_SENTINEL' : 'BEA_ANDROID_OBSERVATIONS_BEGIN\n' + JSON.stringify({schema:1,scope:'OBSERVATIONS_ONLY_NOT_NATIVE_ACCEPTANCE_OR_CAUSE',original_zip_sha256:DIGEST,metadata_sha256:'a'.repeat(64),observations:{source_sha:SOURCE,run_id:'40078818062',run_attempt:'1'}}) + '\nBEA_ANDROID_OBSERVATIONS_END\n';}}; + throw Error('Unexpected test import'); + }}; + vm.runInNewContext(source,api); + return {context,runData,jobData,artifact,calls,events,output,inputs,invoke:()=>api.module.exports.run(inputs)}; +} + +test('unavailable terminal selection rejects before API filesystem decoder or logging', async()=>{ + const f=fixture({production:true}); + await assert.rejects(f.invoke,/FIXED_NATIVE_ARTIFACT_READOUT_FAILED_SELECTION/); + assert.deepEqual(f.calls,[]); assert.deepEqual(f.events,[]); assert.deepEqual(f.output,[]); +}); + +test('every incomplete observed binding fails before API/filesystem', async()=>{ + for(const [before,after] of [[`WORKFLOW = '${WORKFLOW}'`, 'WORKFLOW = null'], + ["NATIVE_HEAD_BRANCH = 'codex/fixed-native-fixture'", 'NATIVE_HEAD_BRANCH = null'], + ["WORKFLOW_PULL_REF = 'refs/pull/9999/merge'", 'WORKFLOW_PULL_REF = null'], + ["RUN_CONCLUSION = 'failure'", 'RUN_CONCLUSION = null'], + ["ARTIFACT = 991","ARTIFACT = null"], [`ZIP_SIZE = ${PAYLOAD.length}`,'ZIP_SIZE = null'], + [`DIGEST = '${DIGEST}'`,'DIGEST = null'], ["NATIVE_CONCLUSION = 'failure'",'NATIVE_CONCLUSION = null'], + ["STEP_CONCLUSIONS = ['success', 'failure']",'STEP_CONCLUSIONS = null'], + ["STEP_CONCLUSIONS = ['success', 'failure']", "STEP_CONCLUSIONS = ['success', ,]"], + ["STEP_CONCLUSIONS = ['success', 'failure']", "STEP_CONCLUSIONS = ['success', undefined]"], + ["STEP_CONCLUSIONS = ['success', 'failure']", "STEP_CONCLUSIONS = ['success', null]"]]) { + const f=fixture({edit:s=>{assert.ok(s.includes(before)); return s.replace(before,after);}}); + await assert.rejects(f.invoke,/FIXED_NATIVE_ARTIFACT_READOUT_FAILED/); + assert.deepEqual(f.calls,[]); assert.deepEqual(f.events,[]); assert.deepEqual(f.output,[]); + } +}); + +test('synthetic terminal job binds exact outcomes and purge precedes projection output',async()=>{ + for(const completed of [false,true]) { + const f=fixture(); if(completed) Object.assign(f.runData,{status:'completed',conclusion:'failure'}); + await f.invoke(); assert.equal(f.calls.filter(([name])=>name==='getJobForWorkflowRun').length,2); + assert.equal(f.calls[1][1].job_id,120835800614); + assert.ok(f.events.indexOf('close'){ + for(const change of [f=>f.context.eventName='workflow_dispatch',f=>f.context.repo.owner='foreign',f=>f.context.ref='refs/heads/sprint', + f=>f.runData.id++,f=>f.runData.run_attempt++,f=>f.runData.head_sha=WORKFLOW,f=>f.runData.repository.id++, + f=>f.runData.head_repository.id++,f=>f.runData.status='queued',f=>f.runData.referenced_workflows=[], + f=>f.runData.referenced_workflows[0].sha=SOURCE,f=>f.jobData.id++,f=>f.jobData.run_attempt++,f=>f.jobData.run_id++, + f=>f.jobData.status='in_progress',f=>f.jobData.conclusion='success',f=>f.jobData.steps[0].conclusion='failure', + f=>f.jobData.steps[2].conclusion='failure',f=>f.jobData.steps.push(f.jobData.steps[2]),f=>f.artifact.id++, + f=>f.artifact.name+='foreign',f=>f.artifact.size_in_bytes++,f=>f.artifact.expired=true, + f=>f.artifact.digest='sha256:'+'0'.repeat(64),f=>f.artifact.workflow_run.id++,f=>f.artifact.workflow_run.head_sha=WORKFLOW]) { + const f=fixture(); change(f); await assert.rejects(f.invoke,/FIXED_NATIVE_ARTIFACT_READOUT_FAILED/); + assert.equal(f.calls.some(([name])=>name==='downloadArtifact'),false); assert.deepEqual(f.events,[]); assert.deepEqual(f.output,[]); + } +}); + +test('wrong ZIP size or digest fails before any filesystem or log operation',async()=>{ + for(const payload of [Buffer.from('PRIVATE_SENTINEL'),Buffer.alloc(PAYLOAD.length)]) { + const f=fixture({payload}); await assert.rejects(f.invoke,/FIXED_NATIVE_ARTIFACT_READOUT_FAILED/); + assert.deepEqual(f.events,[]); assert.deepEqual(f.output,[]); + } +}); + +test('decoder write close cleanup and logging errors stay fixed and preserve purge ordering',async()=>{ + for(const options of [{write:true,unlink:true,warning:true},{close:true},{decoder:true,unlink:true,warning:true}, + {wrongOutput:true},{unlink:true,warning:true},{info:true}]) { + const f=fixture(options); await assert.rejects(f.invoke,options.unlink&&!options.write&&!options.decoder ? + /FIXED_NATIVE_ARTIFACT_PRIVATE_CLEANUP_FAILED/:/FIXED_NATIVE_ARTIFACT_READOUT_FAILED/); + assert.equal(f.events.filter(x=>x==='unlink').length,1); + if(options.info) assert.ok(f.events.indexOf('unlink'){ + for(const after of [v=>v.runData.run_attempt++,v=>v.jobData.head_sha='0'.repeat(40),v=>v.artifact.expired=true]) { + const f=fixture({after}); + await assert.rejects(f.invoke,/FIXED_NATIVE_ARTIFACT_READOUT_FAILED/); + assert.equal(f.events.includes('info'),false); + assert.equal(f.events.filter(x=>x==='unlink').length,1); + } +}); + +test('decoder diagnostics admit only fixed stage labels without private output',async()=>{ + for(const [decoderOutput,stage] of [ + ['BEA_ANDROID_OBSERVATION_READOUT_FAILED:PRODUCT\n','DECODE_PRODUCT'], + ['BEA_ANDROID_OBSERVATION_READOUT_FAILED:PRIVATE_SENTINEL\n','DECODE'], + ['PRIVATE_SENTINEL','DECODE']]) { + const f=fixture({decoder:true,decoderOutput}); + await assert.rejects(f.invoke,error=>error.message==='FIXED_NATIVE_ARTIFACT_READOUT_FAILED_'+stage); + assert.deepEqual(f.output,[]); + assert.equal(f.events.filter(x=>x==='unlink').length,1); + } +}); diff --git a/.github/tests/test_bea_android_artifact_readout.py b/.github/tests/test_bea_android_artifact_readout.py new file mode 100644 index 000000000..be41442d4 --- /dev/null +++ b/.github/tests/test_bea_android_artifact_readout.py @@ -0,0 +1,140 @@ +"""Original-byte binding and private-output controls, using synthetic receipts only.""" +from contextlib import redirect_stdout +import copy +import hashlib +import importlib.util +import io +import json +import os +from pathlib import Path +import tempfile +import unittest +from unittest import mock +import zipfile + +SPEC = importlib.util.spec_from_file_location('bea_android_readout', + Path(__file__).resolve().parents[1] / 'scripts/read-bea-android-artifact.py') +reader = importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(reader) +FIXTURE_SPEC = importlib.util.spec_from_file_location('fixed_android_fixtures', + Path(__file__).with_name('test_044_android_artifact_readout.py')) +fixtures = importlib.util.module_from_spec(FIXTURE_SPEC) +FIXTURE_SPEC.loader.exec_module(fixtures) + + +TEST_WORKFLOW = 'a' * 40 +TEST_REF = 'KeeperCommunity/bitcoin-keeper/.github/workflows/keeper-native-diagnostic.yml@refs/pull/9999/merge' + + +def fixture(): + value = fixtures.observed_data() + value.update(source_sha=reader.SOURCE, workflow_sha=TEST_WORKFLOW, + workflow_ref=TEST_REF, run_id=reader.RUN, run_attempt=reader.ATTEMPT) + value['commands'] = [{'PRIVATE_PATH_OR_OTHER_UNEXPORTED_CONTENT': 'PRIVATE_SENTINEL'}] + value['product_ui']['performance_scope'] = 'PRIVATE_SENTINEL' + value['product_ui']['samples'][0]['unselected_optional_field'] = 'PRIVATE_SENTINEL' + return value + + +def archive(data=None, raw=None, extra=False): + stream = io.BytesIO() + with zipfile.ZipFile(stream, 'w', zipfile.ZIP_DEFLATED) as output: + output.writestr('android/metadata.json', raw if raw is not None else json.dumps(fixture() if data is None else data)) + if extra: output.writestr('raw.log', 'PRIVATE_SENTINEL') + return stream.getvalue() + + +def bound(blob): + return mock.patch.multiple(reader, ZIP_SIZE=len(blob), DIGEST=hashlib.sha256(blob).hexdigest(), + WORKFLOW=TEST_WORKFLOW, WORKFLOW_REF=TEST_REF, PRODUCT_STATUS='FAIL') + + +class BeaAndroidReadoutTests(unittest.TestCase): + def project(self, data=None, blob=None): + blob = archive(data) if blob is None else blob + with bound(blob): return reader.project(blob) + + def test_unavailable_binding_never_accesses_kernel_archive_or_filesystem(self): + with mock.patch.object(reader.Path, 'read_bytes') as reading, \ + mock.patch.object(reader.zipfile, 'ZipFile') as archive_open, \ + mock.patch.object(reader.os, 'open') as opening: + with self.assertRaises(Exception): reader.project(b'PRIVATE_SENTINEL') + with redirect_stdout(io.StringIO()) as output: + self.assertEqual(reader.main([]), 1) + self.assertEqual(output.getvalue(), 'BEA_ANDROID_OBSERVATION_READOUT_FAILED:SELECTION\n') + reading.assert_not_called(); archive_open.assert_not_called(); opening.assert_not_called() + + def test_each_missing_binding_stays_closed_before_kernel_or_input_access(self): + blob = archive() + for name in ('WORKFLOW', 'WORKFLOW_REF', 'ZIP_SIZE', 'DIGEST', 'PRODUCT_STATUS'): + with bound(blob), mock.patch.object(reader, name, None), \ + mock.patch.object(reader.Path, 'read_bytes') as reading, \ + mock.patch.object(reader.zipfile, 'ZipFile') as archive_open: + with self.subTest(name=name), self.assertRaises(Exception): reader.project(blob) + reading.assert_not_called(); archive_open.assert_not_called() + + def test_new_fixed_marker_label_is_finite_and_other_values_remain_rejected(self): + data = fixture() + facts = data['product_ui']['samples'][0]['android_runtime_diagnostic']['facts'] + facts['commands'] = [{'label': 'onboarding-markers', 'lookup_status': 'SUCCESS'}] + self.assertEqual(self.project(data)['observations']['product_ui']['samples'][0][ + 'android_runtime_diagnostic']['facts']['commands'][0]['label'], 'onboarding-markers') + facts['commands'][0]['label'] = 'PRIVATE_SENTINEL' + with self.assertRaises(Exception): self.project(data) + + def test_bounded_failure_facts_survive_and_unselected_content_never_exports(self): + data = fixture(); result = self.project(data) + self.assertEqual(result['scope'], 'OBSERVATIONS_ONLY_NOT_NATIVE_ACCEPTANCE_OR_CAUSE') + self.assertEqual(result['observations']['smoke'], 'PASS') + self.assertEqual(result['observations']['product_ui']['status'], 'FAIL') + self.assertEqual(result['observations']['product_ui']['samples'][0]['failure_observation'], + data['product_ui']['samples'][0]['failure_observation']) + self.assertEqual(result['observations']['product_ui']['samples'][0]['failed_assertion_snapshot'], + data['product_ui']['samples'][0]['failed_assertion_snapshot']) + self.assertEqual(len(result['metadata_sha256']), 64) + self.assertNotIn('commands', result['observations']) + self.assertNotIn('PRIVATE_SENTINEL', json.dumps(result)) + + def test_wrong_source_platform_attempt_workflow_and_unknown_root_reject(self): + for key, value in [('source_sha', '0' * 40), ('platform', 'IOS'), ('run_attempt', '2'), + ('workflow_sha', '0' * 40), ('raw_logs', 'PRIVATE_SENTINEL')]: + data = fixture(); data[key] = value + with self.subTest(key=key), self.assertRaises(Exception): self.project(data) + + def test_projected_raw_values_unknown_nested_data_and_bad_snapshot_types_reject(self): + changes = [lambda s: s['failure_observation'].update(raw_logs='PRIVATE_SENTINEL'), + lambda s: s['failure_observation']['hierarchy']['flags'].update(onboarding_skip=1), + lambda s: s['failed_assertion_snapshot']['skip'].update(clickable='false'), + lambda s: s['failed_assertion_snapshot'].update(node_count=10001), + lambda s: s['failed_assertion_snapshot'].update(raw='PRIVATE_SENTINEL'), + lambda s: s['android_runtime_diagnostic']['facts'].update(message='PRIVATE_SENTINEL'), + lambda s: s['failed_assertion_snapshot']['failed_assertion'].update(selector='onboarding_skip')] + for change in changes: + data = fixture(); change(data['product_ui']['samples'][0]) + with self.subTest(change=change), self.assertRaises(Exception): self.project(data) + + def test_missing_failed_sample_wrong_product_types_and_unsafe_json_reject(self): + for product in [None, [], {'status': 'PASS', 'samples': [{}]}, + {'status': 'FAIL', 'samples': []}, {'status': 'FAIL', 'samples': [None]}, + {'status': 'FAIL', 'samples': [{}] * 7}]: + data = fixture(); data['product_ui'] = product + with self.subTest(product=product), self.assertRaises(Exception): self.project(data) + for blob in [archive(raw='{"schema":1,"schema":1}'), archive(raw='{"schema":NaN}'), + archive(extra=True), archive() + b'PRIVATE_SENTINEL']: + with self.subTest(size=len(blob)), self.assertRaises(Exception): self.project(blob=blob) + + def test_original_digest_kernel_change_and_private_file_alias_fail_without_observations(self): + blob = archive() + with self.assertRaises(Exception): reader.project(blob) + with bound(blob), mock.patch.object(reader, 'KERNEL_SHA256', '0' * 64), self.assertRaises(Exception): + reader.project(blob) + with tempfile.TemporaryDirectory() as directory, mock.patch.dict(os.environ, {'RUNNER_TEMP': directory}): + source = Path(directory) / 'original.zip'; source.write_bytes(blob); source.chmod(0o600) + target = Path(directory) / 'r5-bea-android-fixed.zip'; target.symlink_to(source) + with bound(blob), redirect_stdout(io.StringIO()) as output: + self.assertEqual(reader.main([]), 1) + self.assertEqual(output.getvalue(), 'BEA_ANDROID_OBSERVATION_READOUT_FAILED:PRIVATE_FILE\n') + + +if __name__ == '__main__': + unittest.main() diff --git a/.github/workflows/r5-bea-android-artifact-readout.yml b/.github/workflows/r5-bea-android-artifact-readout.yml new file mode 100644 index 000000000..5380ab359 --- /dev/null +++ b/.github/workflows/r5-bea-android-artifact-readout.yml @@ -0,0 +1,36 @@ +name: Read fixed bea Android observations + +on: + push: + branches: [codex/r5-bea-android-artifact-readout-20261024] + paths: + - .github/workflows/r5-bea-android-artifact-readout.yml + - .github/scripts/read-bea-android-artifact.cjs + - .github/scripts/read-bea-android-artifact.py + - .github/tests/bea-android-artifact-readout.test.cjs + - .github/tests/test_bea_android_artifact_readout.py + +permissions: + contents: read + actions: read + +concurrency: + group: r5-fixed-bea-android-observation-readout + cancel-in-progress: false + +jobs: + readout: + if: github.repository == 'KeeperCommunity/bitcoin-keeper' && github.event_name == 'push' && github.ref == 'refs/heads/codex/r5-bea-android-artifact-readout-20261024' + runs-on: ubuntu-24.04 + timeout-minutes: 5 + steps: + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + with: + ref: ${{ github.sha }} + persist-credentials: false + - run: node .github/scripts/verify-ci-source.cjs + - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + with: + script: await require('./.github/scripts/read-bea-android-artifact.cjs').run({ github, context, core }) + - if: always() + run: node .github/scripts/verify-ci-source.cjs diff --git a/docs/r5/BEA-ANDROID-READOUT-PREP.md b/docs/r5/BEA-ANDROID-READOUT-PREP.md new file mode 100644 index 000000000..b65137305 --- /dev/null +++ b/docs/r5/BEA-ANDROID-READOUT-PREP.md @@ -0,0 +1,7 @@ +# Local preparation only: exact bea Android observations + +This unpushed reader preparation targets app source bea6056724dd75d1db99f4ce394ba4896edd10bf, native run40078818062 attempt1 and selected Android job120835800614. No actual completed artifact, workflow binding or step outcome has been observed for this profile. Workflow/head/ref/conclusion and artifact ID/size/digest constants are explicitly unavailable; both transport and Python reject before API, kernel or filesystem access. Nothing has been published or dispatched. + +The profile inherits the successful #7153/c79ca transport and unchanged hash-pinned044 Android ZIP/privacy kernel, original metadata policy and source guard. It projects only fixed source/status and product failed-sample facts. The only additional public literal is the reviewed new collector-status label onboarding-markers. It grants no raw-field exception or free-form diagnostic string. The marker collector still exports bounded facts rather than private logs or command arguments. Source/attempt/artifact identity is rechecked before download and before output; an owned0600ZIP is deleted before the bounded JSON is logged. + +Local controls:8Node and8PythonPASS, including each unavailable-binding rejection before access and the fixed new label versus an unknown private string. Actionlint1.7.12PASS; shellcheck/pyflakes unavailable. Synthetic fixture workflow/outcome/artifact facts are test-only and do not describe the current native run. Actual completed bindings and independent review are required before publication of a finite profile. If the failure occurs outside the existing first-product sample scope, review the narrow original-metadata interface required for that actual failure instead of expanding it speculatively. No native or software acceptance is established. From 718fa96e9e5d4949ddf51dbb9502e95481395182 Mon Sep 17 00:00:00 2001 From: Antuz tap Date: Sat, 24 Oct 2026 10:00:21 +0000 Subject: [PATCH 2/2] ci: bind bea Android reader to completed native artifact --- .github/scripts/read-bea-android-artifact.cjs | 6 ++-- .github/scripts/read-bea-android-artifact.py | 10 +++---- .../bea-android-artifact-readout.test.cjs | 29 ++++++++++++------- .../test_bea_android_artifact_readout.py | 3 +- docs/r5/BEA-ANDROID-READOUT-PREP.md | 10 ++++--- 5 files changed, 35 insertions(+), 23 deletions(-) diff --git a/.github/scripts/read-bea-android-artifact.cjs b/.github/scripts/read-bea-android-artifact.cjs index 4adfec391..607970df9 100644 --- a/.github/scripts/read-bea-android-artifact.cjs +++ b/.github/scripts/read-bea-android-artifact.cjs @@ -8,10 +8,10 @@ const { execFileSync } = require('node:child_process'); const OWNER = 'KeeperCommunity', REPO = 'bitcoin-keeper'; const RUN = 40078818062, JOB = 120835800614; const SOURCE = 'bea6056724dd75d1db99f4ce394ba4896edd10bf'; -const WORKFLOW = null, NATIVE_HEAD_BRANCH = null, WORKFLOW_PULL_REF = null, RUN_CONCLUSION = null; +const WORKFLOW = 'fbb97bfe160e4b17d52bdf67aacc3f16aeb22f99', NATIVE_HEAD_BRANCH = 'codex/r5-native-failure-continuation-20261024', WORKFLOW_PULL_REF = 'refs/pull/7154/merge', RUN_CONCLUSION = 'failure'; // Exact terminal Android job/artifact API and upload facts. -const ARTIFACT = null, ZIP_SIZE = null, DIGEST = null; -const NATIVE_CONCLUSION = null, STEP_CONCLUSIONS = null; +const ARTIFACT = 12556810367, ZIP_SIZE = 9632, DIGEST = 'c653b9d73044a8cc67cc098ff561d5a42f0a11d49013ae88dfa9edf5bf69df1b'; +const NATIVE_CONCLUSION = 'failure', STEP_CONCLUSIONS = ['success', 'failure']; const STEPS = ['Build development app', 'Run Android startup and native persistence probes']; const CONCLUSIONS = ['success', 'failure', 'skipped']; const NAME = `keeper-diagnostic-native-ANDROID-${SOURCE}-${RUN}-1`; diff --git a/.github/scripts/read-bea-android-artifact.py b/.github/scripts/read-bea-android-artifact.py index 5606fddbb..35a720784 100644 --- a/.github/scripts/read-bea-android-artifact.py +++ b/.github/scripts/read-bea-android-artifact.py @@ -12,12 +12,12 @@ ROOT = Path(__file__).parent KERNEL_SHA256 = '1e9fc4370d733041fb5a48dc8c022e3461decafbf970ba030e90784208aed1d9' SOURCE = 'bea6056724dd75d1db99f4ce394ba4896edd10bf' -WORKFLOW = None -WORKFLOW_REF = None +WORKFLOW = 'fbb97bfe160e4b17d52bdf67aacc3f16aeb22f99' +WORKFLOW_REF = 'KeeperCommunity/bitcoin-keeper/.github/workflows/keeper-native-diagnostic.yml@refs/pull/7154/merge' RUN, ATTEMPT = '40078818062', '1' -ZIP_SIZE = None -DIGEST = None -PRODUCT_STATUS = None +ZIP_SIZE = 9632 +DIGEST = 'c653b9d73044a8cc67cc098ff561d5a42f0a11d49013ae88dfa9edf5bf69df1b' +PRODUCT_STATUS = 'FAIL' SCOPE = 'OBSERVATIONS_ONLY_NOT_NATIVE_ACCEPTANCE_OR_CAUSE' PHASE = 'SELECTION' FIELDS = frozenset(('schema', 'source_sha', 'workflow_sha', 'workflow_ref', 'run_id', 'run_attempt', diff --git a/.github/tests/bea-android-artifact-readout.test.cjs b/.github/tests/bea-android-artifact-readout.test.cjs index 63965fe22..aac1121b6 100644 --- a/.github/tests/bea-android-artifact-readout.test.cjs +++ b/.github/tests/bea-android-artifact-readout.test.cjs @@ -9,29 +9,30 @@ const vm = require('node:vm'); const SCRIPT = path.join(__dirname, '../scripts/read-bea-android-artifact.cjs'); const SOURCE = 'bea6056724dd75d1db99f4ce394ba4896edd10bf'; const WORKFLOW = 'a'.repeat(40); -const BINDINGS = 'const WORKFLOW = null, NATIVE_HEAD_BRANCH = null, WORKFLOW_PULL_REF = null, RUN_CONCLUSION = null;'; +const BINDINGS = "const WORKFLOW = 'fbb97bfe160e4b17d52bdf67aacc3f16aeb22f99', NATIVE_HEAD_BRANCH = 'codex/r5-native-failure-continuation-20261024', WORKFLOW_PULL_REF = 'refs/pull/7154/merge', RUN_CONCLUSION = 'failure';"; const PAYLOAD = Buffer.from('OFFLINE_SYNTHETIC_METADATA_ZIP_BYTES'); const DIGEST = crypto.createHash('sha256').update(PAYLOAD).digest('hex'); -const SELECTION = 'const ARTIFACT = null, ZIP_SIZE = null, DIGEST = null;'; -const OUTCOME = 'const NATIVE_CONCLUSION = null, STEP_CONCLUSIONS = null;'; +const SELECTION = "const ARTIFACT = 12556810367, ZIP_SIZE = 9632, DIGEST = 'c653b9d73044a8cc67cc098ff561d5a42f0a11d49013ae88dfa9edf5bf69df1b';"; +const OUTCOME = "const NATIVE_CONCLUSION = 'failure', STEP_CONCLUSIONS = ['success', 'failure'];"; function fixture(options = {}) { + const observedWorkflow = options.production ? 'fbb97bfe160e4b17d52bdf67aacc3f16aeb22f99' : WORKFLOW; const context = { repo: { owner: 'KeeperCommunity', repo: 'bitcoin-keeper' }, eventName: 'push', ref: 'refs/heads/codex/r5-bea-android-artifact-readout-20261024' }; const runData = { id: 40078818062, run_attempt: 1, repository: { id: 470904030 }, head_repository: { id: 470904030 }, head_sha: SOURCE, event: 'pull_request', - head_branch: 'codex/fixed-native-fixture', + head_branch: options.production ? 'codex/r5-native-failure-continuation-20261024' : 'codex/fixed-native-fixture', path: '.github/workflows/keeper-native-diagnostic.yml', status: 'completed', conclusion: 'failure', - referenced_workflows: [{path: `KeeperCommunity/bitcoin-keeper/.github/workflows/keeper-native-platform.yml@${WORKFLOW}`, - ref: 'refs/pull/9999/merge', sha: WORKFLOW}] }; + referenced_workflows: [{path: `KeeperCommunity/bitcoin-keeper/.github/workflows/keeper-native-platform.yml@${observedWorkflow}`, + ref: options.production ? 'refs/pull/7154/merge' : 'refs/pull/9999/merge', sha: observedWorkflow}] }; const jobData = { id: 120835800614, run_id: 40078818062, run_attempt: 1, head_sha: SOURCE, status: 'completed', conclusion: 'failure', steps: [ ['Build development app', 'success'], ['Run Android startup and native persistence probes', 'failure'], ['Retain safe Phase A evidence', 'success'] ].map(([name, conclusion]) => ({name, conclusion, status: 'completed'})) }; - const artifact = {id: options.production ? 12551461839 : 991, + const artifact = {id: options.production ? 12556810367 : 991, name: `keeper-diagnostic-native-ANDROID-${SOURCE}-40078818062-1`, expired: false, - size_in_bytes: options.production ? 9596 : PAYLOAD.length, - digest: 'sha256:' + (options.production ? 'b9182e02a33b7e0568d73654b42d61f66bce8e425d65a6960aa0f4f2194ee13a' : DIGEST), workflow_run: { + size_in_bytes: options.production ? 9632 : PAYLOAD.length, + digest: 'sha256:' + (options.production ? 'c653b9d73044a8cc67cc098ff561d5a42f0a11d49013ae88dfa9edf5bf69df1b' : DIGEST), workflow_run: { id: 40078818062, head_sha: SOURCE, repository_id: 470904030, head_repository_id: 470904030}}; const calls = [], events = [], output = [], actions = {}; for (const [name, data] of [['getWorkflowRun', runData], ['getJobForWorkflowRun', jobData], ['getArtifact', artifact]]) { @@ -70,11 +71,19 @@ function fixture(options = {}) { } test('unavailable terminal selection rejects before API filesystem decoder or logging', async()=>{ - const f=fixture({production:true}); + const f=fixture({production:true,edit:s=>s.replace("WORKFLOW = 'fbb97bfe160e4b17d52bdf67aacc3f16aeb22f99'", 'WORKFLOW = null')}); await assert.rejects(f.invoke,/FIXED_NATIVE_ARTIFACT_READOUT_FAILED_SELECTION/); assert.deepEqual(f.calls,[]); assert.deepEqual(f.events,[]); assert.deepEqual(f.output,[]); }); +test('exact observed production bindings select only original artifact and reject bad bytes before file or output',async()=>{ + const f=fixture({production:true,payload:Buffer.alloc(9632)}); + await assert.rejects(f.invoke,/FIXED_NATIVE_ARTIFACT_READOUT_FAILED_DOWNLOAD/); + assert.deepEqual(f.calls.map(([name])=>name),['getWorkflowRun','getJobForWorkflowRun','getArtifact','downloadArtifact']); + assert.equal(f.calls[2][1].artifact_id,12556810367); assert.equal(f.calls[3][1].artifact_id,12556810367); + assert.deepEqual(f.events,[]); assert.deepEqual(f.output,[]); +}); + test('every incomplete observed binding fails before API/filesystem', async()=>{ for(const [before,after] of [[`WORKFLOW = '${WORKFLOW}'`, 'WORKFLOW = null'], ["NATIVE_HEAD_BRANCH = 'codex/fixed-native-fixture'", 'NATIVE_HEAD_BRANCH = null'], diff --git a/.github/tests/test_bea_android_artifact_readout.py b/.github/tests/test_bea_android_artifact_readout.py index be41442d4..a01d6d945 100644 --- a/.github/tests/test_bea_android_artifact_readout.py +++ b/.github/tests/test_bea_android_artifact_readout.py @@ -55,7 +55,8 @@ def project(self, data=None, blob=None): with bound(blob): return reader.project(blob) def test_unavailable_binding_never_accesses_kernel_archive_or_filesystem(self): - with mock.patch.object(reader.Path, 'read_bytes') as reading, \ + with mock.patch.object(reader, 'WORKFLOW', None), \ + mock.patch.object(reader.Path, 'read_bytes') as reading, \ mock.patch.object(reader.zipfile, 'ZipFile') as archive_open, \ mock.patch.object(reader.os, 'open') as opening: with self.assertRaises(Exception): reader.project(b'PRIVATE_SENTINEL') diff --git a/docs/r5/BEA-ANDROID-READOUT-PREP.md b/docs/r5/BEA-ANDROID-READOUT-PREP.md index b65137305..32a664a7e 100644 --- a/docs/r5/BEA-ANDROID-READOUT-PREP.md +++ b/docs/r5/BEA-ANDROID-READOUT-PREP.md @@ -1,7 +1,9 @@ -# Local preparation only: exact bea Android observations +# Exact bea Android failed-sample readout -This unpushed reader preparation targets app source bea6056724dd75d1db99f4ce394ba4896edd10bf, native run40078818062 attempt1 and selected Android job120835800614. No actual completed artifact, workflow binding or step outcome has been observed for this profile. Workflow/head/ref/conclusion and artifact ID/size/digest constants are explicitly unavailable; both transport and Python reject before API, kernel or filesystem access. Nothing has been published or dispatched. +The original inactive preparation is now bound from actual official run/job/artifact metadata and decoded upload logs. Native run40078818062/a1 completed FAILURE on app source bea6056724dd75d1db99f4ce394ba4896edd10bf, branch codex/r5-native-failure-continuation-20261024. Its referenced workflow is fbb97bfe160e4b17d52bdf67aacc3f16aeb22f99 at refs/pull/7154/merge. Android job120835800614 completed FAILURE after a successful build and completed startup/native-persistence/worker probes; its sole first-wallet/relaunch sample failed with exit1. Safe evidence retention passed. The exact failed UI assertion is not in the job log; no Skip cause is inferred. -The profile inherits the successful #7153/c79ca transport and unchanged hash-pinned044 Android ZIP/privacy kernel, original metadata policy and source guard. It projects only fixed source/status and product failed-sample facts. The only additional public literal is the reviewed new collector-status label onboarding-markers. It grants no raw-field exception or free-form diagnostic string. The marker collector still exports bounded facts rather than private logs or command arguments. Source/attempt/artifact identity is rechecked before download and before output; an owned0600ZIP is deleted before the bounded JSON is logged. +The finite artifact is12556810367, name keeper-diagnostic-native-ANDROID-bea6056724dd75d1db99f4ce394ba4896edd10bf-40078818062-1,9632bytes, original ZIP SHA256 c653b9d73044a8cc67cc098ff561d5a42f0a11d49013ae88dfa9edf5bf69df1b, unexpired when observed. Official run/job/step/artifact bindings are checked again before download and before output. Missing constants still reject before API, kernel or filesystem access; the initial unavailable profile is preserved in Git history. -Local controls:8Node and8PythonPASS, including each unavailable-binding rejection before access and the fixed new label versus an unknown private string. Actionlint1.7.12PASS; shellcheck/pyflakes unavailable. Synthetic fixture workflow/outcome/artifact facts are test-only and do not describe the current native run. Actual completed bindings and independent review are required before publication of a finite profile. If the failure occurs outside the existing first-product sample scope, review the narrow original-metadata interface required for that actual failure instead of expanding it speculatively. No native or software acceptance is established. +The profile inherits successful #7153/c79ca transport and unchanged hash-pinned044 Android ZIP/privacy kernel, original metadata policy and source guard. It projects only fixed source/status and product failed-sample facts. The only additional public literal is the reviewed collector-status label onboarding-markers. It grants no raw-field exception or free-form diagnostic string. The marker collector exports bounded facts rather than private logs or command arguments. The owned0600ZIP is deleted before bounded JSON is logged; inherited SDK buffering before exact size/digest validation remains qualified. + +Local controls:9Node and8PythonPASS, including each missing-binding rejection before access, exact production selection rejecting wrong bytes before file/output, and the fixed new label versus an unknown private string. Inherited6Node/16Python kernel controls remain unchanged. Actionlint1.7.12PASS; shellcheck/pyflakes unavailable locally. Synthetic fixture workflow/outcome/artifact facts are test-only. Independent source review and hosted metadata-only readout are pending. Nothing has been published or dispatched. Frozen native sources#7149/d270 and#7154/bea are untouched; no new native run or software acceptance is established.