Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
d019119
test(formal): reproduce commit custody false acceptance with real Git
d6g8k5htny-coder Oct 29, 2026
93af4b6
test(formal): reproduce hidden dependency source changes and ignored …
d6g8k5htny-coder Oct 29, 2026
8d8a9bf
fix(formal): bind core receipts to committed and loaded source bytes
d6g8k5htny-coder Oct 29, 2026
a974750
test(formal): preserve legacy assertions with explicit custody fixtur…
d6g8k5htny-coder Oct 29, 2026
5522d13
test(formal): verify custody source mutations and bytecode-cache isol…
d6g8k5htny-coder Oct 29, 2026
6a4a1c1
verify(formal): preserve custody observations and run exact hosted co…
d6g8k5htny-coder Oct 29, 2026
8619b9f
verify(formal): pin custody runners and preserve verified raw kernel …
d6g8k5htny-coder Oct 29, 2026
5705225
test(formal): cover exact tracked dependency symlinks and hidden reta…
d6g8k5htny-coder Oct 29, 2026
a574ff5
ci: retire only freshly confirmed superseded PR verification runs
d6g8k5htny-coder Oct 29, 2026
f9b8edf
fix(formal): verify exact locked dependency symlink bytes and targets
d6g8k5htny-coder Oct 29, 2026
68ad3f1
Remove generated bytecode from disposable custody fixture
d6g8k5htny-coder Oct 29, 2026
c297f98
Rebind D2 companion consumers to exact custody-hardened core
d6g8k5htny-coder Oct 29, 2026
1ee60bc
Rebind retained D2 test fixtures to the same exact core identities
d6g8k5htny-coder Oct 29, 2026
b54c7a2
Compose current Math routing rules with source-custody repairs
d6g8k5htny-coder Oct 29, 2026
18186f5
Rebind fixture overlay and document endpoint custody limit
d6g8k5htny-coder Oct 29, 2026
6d50c2e
Reobserve retirement of superseded source-bound CI runs
d6g8k5htny-coder Oct 29, 2026
db46797
Preserve cancellation observations and handle terminal races
d6g8k5htny-coder Oct 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
223 changes: 223 additions & 0 deletions .github/workflows/cbz-core-custody.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
name: CBZ core custody verification
on:
push:
branches: [cbz/core-custody-native-20261029]
pull_request:
paths: ['formal/**', '.github/workflows/cbz-core-custody.yml']
concurrency:
group: core-custody-${{ github.event.pull_request.head.ref || github.ref_name }}
cancel-in-progress: true
permissions:
contents: read
jobs:
custody:
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
mode: [normal, optimized]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
fetch-depth: 0
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0
with:
python-version: '3.11.16'
- name: Real Git custody refusal controls
env:
MODE: ${{ matrix.mode }}
PYTHONDONTWRITEBYTECODE: '1'
run: |
set -o pipefail
flags=()
if [ "$MODE" = optimized ]; then flags+=(-O); fi
python -B -S "${flags[@]}" -m unittest discover -s formal/tests -p test_source_custody.py -v 2>&1 | tee "$RUNNER_TEMP/custody-$MODE.log"
- name: Retained complete formal Python suite
env:
MODE: ${{ matrix.mode }}
PYTHONDONTWRITEBYTECODE: '1'
run: |
set -o pipefail
flags=()
if [ "$MODE" = optimized ]; then flags+=(-O); fi
python -B -S "${flags[@]}" -m unittest discover -s formal/tests -p "test_*.py" -v 2>&1 | tee "$RUNNER_TEMP/full-formal-$MODE.log"
- name: Bound source preflight
run: python -B -S formal/gate.py
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
if: always()
with:
name: core-custody-${{ matrix.mode }}
path: |
${{ runner.temp }}/custody-*.log
${{ runner.temp }}/full-formal-*.log
if-no-files-found: error
kernel:
needs: custody
runs-on: ubuntu-24.04
timeout-minutes: 30
env:
LEAN_NUM_THREADS: 2
PYTHONDONTWRITEBYTECODE: '1'
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
fetch-depth: 0
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0
with:
python-version: '3.11.16'
- name: Install exact Lean and locked dependency cache
uses: leanprover/lean-action@24581d74d674803a25a81b10b059c5c0cdd344c6
with:
lake-package-directory: formal
auto-config: 'false'
build: 'false'
test: 'false'
lint: 'false'
use-mathlib-cache: 'true'
use-github-cache: 'false'
- name: Actual core build kernel axiom and negative-control gate
run: python -B -S formal/gate.py --execute
- name: Bind exact current-run receipt
run: python -B -S tools/required_formal_check.py receipt
- name: Preserve raw kernel evidence
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
with:
name: cbz-core-kernel-${{ github.run_id }}-${{ github.run_attempt }}
path: formal/.lake/formal-evidence/
include-hidden-files: true
if-no-files-found: error
retention-days: 90
seal:
needs: kernel
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: write
actions: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0
with:
python-version: '3.11.16'
- name: Verify downloaded raw bytes and publish a recoverable evidence descendant
env:
GH_TOKEN: ${{ github.token }}
run: |
python -B -S - <<'PYSEAL'
import base64,hashlib,importlib.util,json,os,subprocess,sys
from concurrent.futures import ThreadPoolExecutor
from pathlib import Path
repository=os.environ['GITHUB_REPOSITORY']
endpoint='repos/'+repository+'/'
def api(path,body=None):
command=['gh','api',endpoint+path]
raw=None
if body is not None:
command+=['--method','POST','--input','-']
raw=json.dumps(body).encode()
result=subprocess.run(command,input=raw,capture_output=True,check=True)
return json.loads(result.stdout)
run_id=os.environ['GITHUB_RUN_ID']
attempt=os.environ['GITHUB_RUN_ATTEMPT']
source_sha=os.environ['GITHUB_SHA']
out=Path('.cbz-core-kernel-seal')
out.mkdir()
artifact_name='cbz-core-kernel-'+run_id+'-'+attempt
artifacts=api('actions/runs/'+run_id+'/artifacts?per_page=100')
if artifacts.get('total_count',0)>100:
raise SystemExit('artifact listing requires pagination; no truncated selection is admitted')
hits=[row for row in artifacts['artifacts'] if row['name']==artifact_name and not row['expired']]
if len(hits)!=1:
raise SystemExit('expected exactly one current-run kernel evidence artifact')
artifact=hits[0]
archive=out/'artifact.zip'
with archive.open('wb') as handle:
subprocess.run(['gh','api',endpoint+'actions/artifacts/'+str(artifact['id'])+'/zip'],
stdout=handle,check=True)
archive_sha=hashlib.sha256(archive.read_bytes()).hexdigest()
if artifact.get('digest')!='sha256:'+archive_sha:
raise SystemExit('downloaded ZIP differs from independent GitHub artifact digest')
# Reuse the separately self-tested/mutated exact wire-integrity checker, by immutable source.
verifier_commit='4351227b53a3f7f401e59d129530fb68055d0284'
verifier_sha='77463e76d49fc68c0e8db85f6671fc7a0efaccecd93727572b3d02242b8647b1'
blob=api('contents/frontiers/determinant_moment_20261025/artifact_integrity.py?ref='+verifier_commit)
verifier=base64.b64decode(blob['content'],validate=False)
if hashlib.sha256(verifier).hexdigest()!=verifier_sha:
raise SystemExit('downloaded verifier differs from qualified immutable code')
checker=out/'artifact_integrity.py'
checker.write_bytes(verifier)
spec=importlib.util.spec_from_file_location('cbz_core_source_gate',Path('formal/gate.py').resolve())
gate=importlib.util.module_from_spec(spec)
spec.loader.exec_module(gate)
manifest,digest=gate.source_check()
if subprocess.check_output(['git','rev-parse','HEAD'],text=True).strip()!=source_sha:
raise SystemExit('seal source differs from independently supplied workflow commit')
reports={}
for mode in ['normal','optimized']:
report=out/(mode+'.json')
command=[sys.executable,'-B','-S']+(['-O'] if mode=='optimized' else [])+[
str(checker),'--archive',str(archive),'--expected-commit',source_sha,
'--expected-manifest',digest,'--output',str(report)]
subprocess.run(command,check=True)
reports[mode]=json.loads(report.read_text())
if reports[mode].get('status')!='PASS':
raise SystemExit('downloaded byte integrity is not verified')
summary=dict(schema='cbz.core-kernel.native-artifact-observation.v1',
status='VERIFIED_BYTES',scope='BYTE_TRANSPORT_ONLY_KERNEL_RESULT_REMAINS_IN_RAW_RECEIPT',
run_id=run_id,run_attempt=attempt,checked_commit=source_sha,manifest_sha256=digest,
artifact_id=artifact['id'],archive_sha256=archive_sha,verifier_commit=verifier_commit,
verifier_sha256=verifier_sha,reports=reports)
(out/'SUMMARY.json').write_text(json.dumps(summary,indent=2,sort_keys=True)+'\n')
files={name:(out/name).read_bytes() for name in [
'artifact.zip','normal.json','optimized.json','SUMMARY.json','artifact_integrity.py']}
files['SHA256SUMS']=''.join(hashlib.sha256(raw).hexdigest()+' '+name+'\n'
for name,raw in sorted(files.items())).encode()
files['README.md']=(
'# Core source-custody kernel evidence\n\n'
'Actual workflow run '+run_id+', attempt '+attempt+', checked source '+source_sha+'.\n'
'The raw artifact ZIP preserves the executed kernel receipt, generated controls and logs.\n'
'SUMMARY.json and both mode reports verify independently supplied commit/manifest identities\n'
'and every receipt-bound log. The wire check alone awards no mathematical proof.\n'
'Run sha256sum -c SHA256SUMS here; the exact verified checker source is included.\n'
).encode()
prefix='evidence/cbz-core-kernel-'+run_id+'-'+attempt+'/'
def blob_entry(item):
path,raw=item
expected=hashlib.sha1(b'blob '+str(len(raw)).encode()+b'\0'+raw).hexdigest()
result=api('git/blobs',dict(encoding='base64',content=base64.b64encode(raw).decode()))
if result.get('sha')!=expected:
raise SystemExit('published Git blob differs from exact archived bytes')
return dict(path=prefix+path,mode='100644',type='blob',sha=expected)
with ThreadPoolExecutor(max_workers=4) as pool:
entries=list(pool.map(blob_entry,sorted(files.items())))
original=api('git/commits/'+source_sha)
tree=api('git/trees',dict(base_tree=original['tree']['sha'],tree=entries))
commit=api('git/commits',dict(message='Preserve actual source-custody core kernel evidence and verified raw bytes',
tree=tree['sha'],parents=[source_sha]))
branch='cbz/core-kernel-evidence-'+run_id+'-'+attempt
api('git/refs',dict(ref='refs/heads/'+branch,sha=commit['sha']))
readback=api('git/trees/'+tree['sha']+'?recursive=1')
if readback.get('truncated'):
raise SystemExit('evidence tree readback was truncated')
actual={row['path']:row['sha'] for row in readback['tree']}
if any(actual.get(row['path'])!=row['sha'] for row in entries):
raise SystemExit('evidence tree readback differs from archived bytes')
report=dict(status='PUBLISHED_AND_READBACK_MATCHED',branch=branch,commit=commit['sha'],
tree=tree['sha'],source_commit=source_sha,archive_prefix=prefix,
files={prefix+path:hashlib.sha256(raw).hexdigest() for path,raw in sorted(files.items())})
(out/'PUBLICATION.json').write_text(json.dumps(report,indent=2,sort_keys=True)+'\n')
print(json.dumps(report,sort_keys=True))
PYSEAL
- name: Preserve publication and verification reports
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
with:
name: cbz-core-seal-${{ github.run_id }}-${{ github.run_attempt }}
path: .cbz-core-kernel-seal/
include-hidden-files: true
if-no-files-found: error
154 changes: 154 additions & 0 deletions .github/workflows/cbz-retire-superseded-runs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
name: CBZ retire superseded verification runs
on:
push:
branches: [cbz/core-custody-native-20261029]
paths: ['.github/workflows/cbz-retire-superseded-runs.yml']
permissions:
contents: read
actions: write
jobs:
retire-superseded:
runs-on: ubuntu-24.04-arm
timeout-minutes: 10
steps:
- name: Verify policy and retire only freshly confirmed obsolete PR runs
env:
GH_TOKEN: ${{ github.token }}
run: |
python3 -B -S - <<'PYRETIRE'
import json,os,re,subprocess
from pathlib import Path
repository=os.environ['GITHUB_REPOSITORY']
prefix='repos/'+repository+'/'
active={'queued','in_progress','requested','pending','waiting'}
hex40=re.compile('[0-9a-f]{40}')
def stale(run,pr):
return (run.get('event')=='pull_request' and run.get('status') in active
and pr.get('state')=='open' and isinstance(run.get('head_sha'),str)
and isinstance(pr.get('head',{}).get('sha'),str)
and bool(hex40.fullmatch(run['head_sha'])) and bool(hex40.fullmatch(pr['head']['sha']))
and run['head_sha']!=pr['head']['sha'])
base={'event':'pull_request','status':'queued','head_sha':'a'*40}
current={'state':'open','head':{'sha':'b'*40}}
controls=[
(base,current,True),
(dict(base,event='push'),current,False),
(dict(base,status='completed'),current,False),
(dict(base,head_sha='b'*40),current,False),
(base,dict(current,state='closed'),False),
(dict(base,head_sha=None),current,False),
(base,{'state':'open','head':{}},False)]
for run,pr,wanted in controls:
if stale(run,pr)!=wanted:
raise SystemExit('cancellation policy self-test failed')
def api(path,post=False):
command=['gh','api',prefix+path]+(['--method','POST'] if post else [])
result=subprocess.run(command,capture_output=True,check=True)
return json.loads(result.stdout) if result.stdout.strip() else None
def pages(path,key):
rows=[]
for page in range(1,1001):
result=api(path+('&' if '?' in path else '?')+'per_page=100&page='+str(page))
batch=result[key] if key else result
if not isinstance(batch,list):
raise SystemExit('unexpected API pagination shape')
rows.extend(batch)
if len(batch)<100:
return rows
raise SystemExit('pagination bound exhausted without complete enumeration')
def persist(report):
target=Path('cbz-superseded-run-report.json')
temporary=target.with_name(target.name+'.tmp')
temporary.write_text(json.dumps(report,indent=2,sort_keys=True)+'\n')
temporary.replace(target)
def cancel_one(api_call,run_id,latest,pr,records,save):
row=dict(run_id=run_id,pr=pr['number'],old_head=latest['head_sha'],
current_head=pr['head']['sha'],action='CANCEL_REQUEST_IN_FLIGHT')
records.append(row)
save()
try:
api_call('actions/runs/'+str(run_id)+'/cancel',post=True)
except subprocess.CalledProcessError:
observed=api_call('actions/runs/'+str(run_id))
row.update(observed_status=observed['status'],
observed_conclusion=observed.get('conclusion'))
if observed['status']=='completed':
row['action']='ALREADY_TERMINAL_AFTER_REFUSAL'
save()
return
row['action']='CANCELLATION_FAILED'
save()
raise
observed=api_call('actions/runs/'+str(run_id))
row.update(action='CANCELLATION_REQUESTED',observed_status=observed['status'],
observed_conclusion=observed.get('conclusion'))
save()
for scenario in ('requested','race','failed'):
snapshots=[]
test_rows=[]
def fake_api(path,post=False):
if post and scenario!='requested':
raise subprocess.CalledProcessError(1,['gh','api','cancel'])
return {'status':'completed' if scenario=='race' else 'in_progress',
'conclusion':'success' if scenario=='race' else None}
try:
cancel_one(fake_api,17,{'head_sha':'a'*40},
{'number':42,'head':{'sha':'b'*40}},test_rows,
lambda: snapshots.append([dict(row) for row in test_rows]))
except subprocess.CalledProcessError:
if scenario!='failed':
raise
else:
if scenario=='failed':
raise SystemExit('failed cancellation did not fail closed')
expected={'requested':'CANCELLATION_REQUESTED',
'race':'ALREADY_TERMINAL_AFTER_REFUSAL','failed':'CANCELLATION_FAILED'}[scenario]
if not snapshots or snapshots[0][0]['action']!='CANCEL_REQUEST_IN_FLIGHT' or test_rows[0]['action']!=expected:
raise SystemExit('cancellation receipt self-test failed: '+scenario)
rows=[]
report=dict(scope='SUPERSEDED_PR_RUN_ORCHESTRATION_ONLY_NO_TEST_OR_PROOF_CREDIT',
source_commit=os.environ['GITHUB_SHA'],run_id=os.environ['GITHUB_RUN_ID'],
policy_self_tests=len(controls)+3,enumerated_nonterminal_runs=None,
status='IN_PROGRESS',records=rows)
persist(report)
prs=pages('pulls?state=open',None)
runs={}
for status in sorted(active):
for run in pages('actions/runs?status='+status,'workflow_runs'):
runs[run['id']]=run
report['enumerated_nonterminal_runs']=len(runs)
persist(report)
for run_id,run in sorted(runs.items()):
if str(run_id)==os.environ['GITHUB_RUN_ID'] or run.get('event')!='pull_request':
continue
ids=[p.get('number') for p in run.get('pull_requests',[])]
if not ids:
ids=[p['number'] for p in prs if p['head']['ref']==run.get('head_branch')
and p['head']['repo']['full_name']==repository]
if len(ids)!=1 or type(ids[0]) is not int:
rows.append(dict(run_id=run_id,action='RETAINED_UNROUTED_OR_MULTIPLE_PR'))
continue
pr=api('pulls/'+str(ids[0]))
if not stale(run,pr):
rows.append(dict(run_id=run_id,pr=ids[0],action='RETAINED_CURRENT_OR_TERMINAL'))
continue
latest=api('actions/runs/'+str(run_id))
# Fresh PR source and run state are re-read immediately before the POST.
pr=api('pulls/'+str(ids[0]))
if not stale(latest,pr):
rows.append(dict(run_id=run_id,pr=ids[0],action='RETAINED_AFTER_RECHECK'))
continue
cancel_one(api,run_id,latest,pr,rows,lambda: persist(report))
report['status']='COMPLETE'
persist(report)
print(json.dumps(report,sort_keys=True))
PYRETIRE
- name: Preserve exact retirement decisions
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
with:
name: cbz-superseded-runs-${{ github.run_id }}-${{ github.run_attempt }}
path: cbz-superseded-run-report.json
if-no-files-found: error

# Reobserve the source-bound retirement policy after the 2026-10-29 source updates.
Loading
Loading