Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
59 changes: 56 additions & 3 deletions .github/workflows/contact-small-gap.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
name: Contact small-gap law and source-bound review replay
'on':
pull_request:
paths: ['reviews/contact_kernel_tail_20260925/**', '.github/workflows/contact-small-gap.yml']
paths:
- 'reviews/contact_kernel_tail_20260925/**'
- 'reviews/pr16_fixed_transverse_nonauthor_20260925/**'
- '.github/workflows/contact-small-gap.yml'
workflow_dispatch:
permissions:
contents: read
Expand Down Expand Up @@ -29,9 +32,59 @@ jobs:
PYTHONDONTWRITEBYTECODE: '1'
run: |
python -B -S - <<'PY'
import hashlib,json,os,pathlib,shutil,subprocess,sys
root=pathlib.Path('reviews/contact_kernel_tail_20260925').resolve()
import hashlib,json,os,pathlib,shutil,subprocess,sys,tempfile
root=pathlib.Path('reviews/contact_kernel_tail_20260925')
out=pathlib.Path(os.environ['RUNNER_TEMP'])/'contact-small-gap'
# Fixed workflow-side trust pins; the candidate manifest cannot authorize its own runner.
EXPECTED_BLOBS={
'run_validation.py':'c60624104972b5f619dfcf7c63429e573297125f',
'SOURCE_FILES.json':'a096b6bc5643b983ade7c9f3d02b6490e932ebab',
}
EXPECTED_FILES={
'ANNULUS_ASYMPTOTIC_BRIDGE.md',
'COORDINATION.md',
'KERNEL_TAILS_AND_SMALL_GAP.md',
'README.md',
'RECONNAISSANCE.md',
'RESULTS.json',
'contact_tools.py',
'run_validation.py',
'test_contact_tools.py',
}
EXPECTED_ENTRIES=EXPECTED_FILES|{'SOURCE_FILES.json'}
def require(ok,message):
if not ok:raise RuntimeError(message)
def git_blob(path):
raw=path.read_bytes()
return hashlib.sha1(b'blob '+str(len(raw)).encode()+b'\0'+raw).hexdigest()
def verify_packet(packet):
require(not packet.is_symlink() and packet.is_dir(),'packet root must be a real directory')
entries=list(packet.iterdir())
require({p.name for p in entries}==EXPECTED_ENTRIES,'unexpected packet directory membership')
require(all(not p.is_symlink() and p.is_file() for p in entries),'packet entries must be regular files')
for name,expected in EXPECTED_BLOBS.items():
require(git_blob(packet/name)==expected,'workflow trust-pin mismatch: '+name)
manifest=json.loads((packet/'SOURCE_FILES.json').read_text())
require(set(manifest.get('files',{}))==EXPECTED_FILES,'manifest path set mismatch')
verify_packet(root)
with tempfile.TemporaryDirectory(dir=os.environ['RUNNER_TEMP']) as temp:
for attack in ('manifest-removal','noop-runner','combined'):
packet=pathlib.Path(temp)/attack
shutil.copytree(root,packet)
if attack in ('manifest-removal','combined'):
manifest=json.loads((packet/'SOURCE_FILES.json').read_text())
manifest['files'].pop('run_validation.py',None)
(packet/'SOURCE_FILES.json').write_text(json.dumps(manifest,indent=2,sort_keys=True)+'\n')
if attack in ('noop-runner','combined'):
(packet/'run_validation.py').write_text(
'import argparse\nfrom pathlib import Path\nparser=argparse.ArgumentParser()\nparser.add_argument("--output",type=Path,required=True)\nargs=parser.parse_args()\nargs.output.mkdir(parents=True)\n'
)
try:
verify_packet(packet)
except RuntimeError:
pass
else:
raise RuntimeError('adverse candidate accepted: '+attack)
subprocess.run([sys.executable,'-B','-S',str(root/'run_validation.py'),'--output',str(out)],check=True,timeout=150)
review=pathlib.Path('reviews/pr16_fixed_transverse_nonauthor_20260925')
script=review/'algebra_check.py'
Expand Down
4 changes: 2 additions & 2 deletions reviews/contact_kernel_tail_20260925/SOURCE_FILES.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"sha256": "e85d55f3f2cf4a93b7a3bec22e38fb90c02e37a42a8b208b8b56143a9894b09c"
},
"run_validation.py": {
"bytes": 3914,
"sha256": "a0cde0beda096a027adca71a8e05f64a7bb21e825e7d4f68d8fc6f8cf6709a0b"
"bytes": 7061,
"sha256": "e5b5efe4737ca12bb7d57215f5decc712565107b2a3d8d624053c93bcd4e2fda"
},
"test_contact_tools.py": {
"bytes": 6000,
Expand Down
83 changes: 74 additions & 9 deletions reviews/contact_kernel_tail_20260925/run_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
import argparse
import hashlib
import json
import re
import shutil
import subprocess
import sys

ROOT=Path(__file__).resolve().parent
TEST_COUNT=24
MUTANTS={
'lose_midpoint_shift':('u*u-u*w+Q(1,4)','u*u-u*w'),
'wrong_q_parameter':('q=6*k*(w-2*u)/v','q=6*k*(w-u)/v'),
Expand All @@ -18,6 +20,43 @@
'wrong_gaussian_moment':('(n-1)*out[n-2]/(2*a)','(n+1)*out[n-2]/(2*a)'),
'promote_small_gap_uniformity':("'finite_r_small_k_uniformity':False","'finite_r_small_k_uniformity':True"),
}
EXPECTED_FAILURES={
'lose_midpoint_shift':frozenset({
'test_contact_tools.ContactTests.test_critical_constraints',
'test_contact_tools.ContactTests.test_exact_contact_fixture',
'test_contact_tools.ContactTests.test_typed_determinant_forms',
}),
'wrong_q_parameter':frozenset({
'test_contact_tools.ContactTests.test_critical_constraints',
'test_contact_tools.ContactTests.test_exact_contact_fixture',
'test_contact_tools.ContactTests.test_typed_determinant_forms',
}),
'lose_endpoint_k2':frozenset({
'test_contact_tools.ContactTests.test_w_jacobian_is_counted_once',
}),
'wrong_type_region':frozenset({
'test_contact_tools.ContactTests.test_claim_scope_metadata',
'test_contact_tools.ContactTests.test_exact_shape_integral',
'test_contact_tools.ContactTests.test_two_pieces',
'test_contact_tools.ContactTests.test_type_area',
'test_contact_tools.ContactTests.test_universal_rational_coefficient',
}),
'wrong_height_orientation':frozenset({
'test_contact_tools.ContactTests.test_critical_constraints',
'test_contact_tools.ContactTests.test_saddle_side_remainder_identity',
}),
'wrong_gaussian_moment':frozenset({
'test_contact_tools.ContactTests.test_gaussian_moments_symmetric',
'test_contact_tools.ContactTests.test_gaussian_polynomial_reduction_against_simpson',
}),
'promote_small_gap_uniformity':frozenset({
'test_contact_tools.ContactTests.test_claim_scope_metadata',
}),
}
FAIL_RE=re.compile(r'^FAIL: ([^\s]+) \(([^)]+)\)$',re.MULTILINE)
ERROR_RE=re.compile(r'^ERROR: ',re.MULTILINE)
RUN_RE=re.compile(r'^Ran (\d+) tests? in [^\n]+$',re.MULTILINE)
FAILED_RE=re.compile(r'^FAILED \(failures=(\d+)\)$',re.MULTILINE)

def require(ok,message):
if not ok:raise RuntimeError(message)
Expand All @@ -31,23 +70,48 @@ def identities():
require({'bytes':len(raw),'sha256':hashlib.sha256(raw).hexdigest()}==identity,'identity mismatch: '+name)
return pins

def run_cmd(cmd,cwd,out,name,mutant=False):
def _failure_ids(stderr,name):
matches=list(FAIL_RE.finditer(stderr))
ids=[]
for match in matches:
short,full=match.groups()
require(short==full.rsplit('.',1)[-1],'malformed unittest failure identity '+name)
ids.append(full)
block_end=matches[matches.index(match)+1].start() if matches.index(match)+1<len(matches) else len(stderr)
block=stderr[match.end():block_end]
require('AssertionError:' in block,'non-assertion failure block '+full+' in '+name)
require(len(ids)==len(set(ids)),'duplicate unittest failure identity '+name)
return frozenset(ids)

def run_cmd(cmd,cwd,out,name,mutant=None):
p=subprocess.run(cmd,cwd=cwd,capture_output=True,text=True,timeout=30)
(out/(name+'.stdout')).write_text(p.stdout)
(out/(name+'.stderr')).write_text(p.stderr)
require('Ran 24 tests' in p.stderr and 'skipped=' not in p.stderr,'unexpected test coverage '+name)
if mutant:
require(p.returncode!=0 and 'AssertionError' in p.stderr and 'FAILED (failures=' in p.stderr,'mutant not assertion-detected: '+name)
require('ERROR:' not in p.stderr and 'SyntaxError' not in p.stderr and 'ImportError' not in p.stderr,'invalid-program mutation: '+name)
else:
require(p.returncode==0,'baseline failure '+name)
count=RUN_RE.search(p.stderr)
require(count is not None and int(count.group(1))==TEST_COUNT,'unexpected test coverage '+name)
require(not ERROR_RE.search(p.stderr),'unittest error '+name)
require(not re.search(r'\bskipped\b',p.stderr,re.IGNORECASE),'skipped test '+name)
require(not p.stdout,'unexpected test stdout '+name)
failures=_failure_ids(p.stderr,name)
if mutant is None:
require(p.returncode==0 and not failures and re.search(r'^OK$',p.stderr,re.MULTILINE) is not None,'baseline failure '+name)
return []
expected=EXPECTED_FAILURES[mutant]
summary=FAILED_RE.search(p.stderr)
require(p.returncode==1,'mutant did not exit with unittest failure '+name)
require(summary is not None and int(summary.group(1))==len(expected),'unexpected failure summary '+name)
require(failures==expected,'wrong mutant failure identity '+name+': expected '+repr(sorted(expected))+' got '+repr(sorted(failures)))
return sorted(failures)

def main():
parser=argparse.ArgumentParser(description=__doc__);parser.add_argument('--output',type=Path,required=True)
out=parser.parse_args().output.resolve()
require(not out.exists() and not out.is_relative_to(ROOT),'new output outside source required')
out.mkdir(parents=True);before=identities();source=(ROOT/'contact_tools.py').read_text()
report={'passed':False,'python':sys.version,'distinct_tests':24,'distinct_mutants':len(MUTANTS),'modes':[],
require(set(MUTANTS)==set(EXPECTED_FAILURES),'mutant/failure contract keys differ')
report={'passed':False,'python':sys.version,'distinct_tests':TEST_COUNT,'distinct_mutants':len(MUTANTS),'modes':[],
'expected_failure_ids':{k:sorted(v) for k,v in EXPECTED_FAILURES.items()},
'observed_failure_ids':{},
'meaning':'finite exact algebra and diagnostic implementation checks, not independent continuum review'}
try:
for mode,flags in [('normal',[]),('optimized',['-O'])]:
Expand All @@ -60,7 +124,8 @@ def main():
temp=out/'mutants'/mode/name;temp.mkdir(parents=True)
(temp/'contact_tools.py').write_text(source.replace(old,new))
shutil.copyfile(ROOT/'test_contact_tools.py',temp/'test_contact_tools.py')
run_cmd(cmd,temp,out,'mutation_'+mode+'_'+name,True)
observed=run_cmd(cmd,temp,out,'mutation_'+mode+'_'+name,mutant=name)
report['observed_failure_ids'].setdefault(name,{})[mode]=observed
report['modes'].append(mode)
require(before==identities(),'sources changed')
report.update(passed=True,sources_unchanged=True,source_files=before)
Expand Down
Loading