소스 검색

verify(td): re-audit immutable native evidence with corrected warning classification

codex 2 달 전
부모
커밋
bdee544264
3개의 변경된 파일과 143개의 추가작업 그리고 16개의 파일을 삭제
  1. 24 0
      docs/audits/td-undriven-summary.md
  2. 55 0
      tests/unit/test_td_reaudit.py
  3. 64 16
      tools/run_6400_td.py

+ 24 - 0
docs/audits/td-undriven-summary.md

@@ -0,0 +1,24 @@
+# TD undriven diagnostic interpretation
+
+On TD2026.1 SP2 build6.2.2.200067, the isolated counter and explicitly wired
+BRAM smoke designs did not emit SYN-5025. A three-entry array with a two-bit
+address, guarded reads/writes and a validity mask did emit the summary
+`Using 0 for all undriven pins and nets`, without a named missing driver.
+
+The guarded sparse-array smoke completed synthesis, placement, routing,
+timing and bit generation. A Yosys check allowing uninitialized memory proved
+the observable output defined over16 sequential clock steps. That bounded
+check is evidence about this fixture, not a proof of either full product.
+The native run is `/data/prod2u/runs/td-summary-verified`.
+
+Consequently SYN-5025 alone does not identify a missing functional signal.
+The audit retains it in noteworthy diagnostics, while identified undriven
+net/pin messages (HDL-5314, SYN-5011/5013), unexpected ports and real native
+errors remain blocking. This does not waive the product's functional tests,
+formal obligations or timing requirements.
+
+An earlier receipt is never overwritten to change its status. Use
+`run_6400_td.py --reaudit <receipt> --run-root <new-external-directory>` to
+verify identical current inputs, native log hashes, complete stages and
+bitstream hash, then re-evaluate warnings and timing. The new receipt records
+the original receipt hash/status and reuses its native evidence explicitly.

+ 55 - 0
tests/unit/test_td_reaudit.py

@@ -0,0 +1,55 @@
+import hashlib,json
+from pathlib import Path
+import pytest
+from tools import run_6400_td as td
+
+@pytest.fixture
+def native_run(tmp_path,monkeypatch):
+    root=tmp_path/'source';root.mkdir()
+    native=tmp_path/'native';native.mkdir()
+    inputs={'project.json':'a'*64,'closure.json':'b'*64}
+    monkeypatch.setattr(td,'ROOT',root)
+    monkeypatch.setattr(td,'HARDWARE_PROFILES',{'fixture':{'project':'project.json','closure':'closure.json','artifact_basename':'firmware'}})
+    monkeypatch.setattr(td,'input_manifest',lambda _:inputs)
+    monkeypatch.setattr(td,'source_identity',lambda _: {'source_kind':'unit-fixture'})
+    metrics={k:0 for k in ('total_luts','lut','registers','dsp','eram_bram','mslice','lslice','packed_slices','setup_slack_ns','hold_slack_ns','setup_total_negative_slack_ns','hold_total_negative_slack_ns')}
+    metrics.update(fmax_mhz=50,violation_endpoint_counts=[0,0],all_violation_endpoint_counts_zero=True)
+    monkeypatch.setattr(td,'parse_metrics',lambda *_:dict(metrics))
+    stages={}
+    for name,artifact in [('syn','firmware_gate.db'),('phy','firmware_pr.db'),('bitgen','firmware.bit')]:
+        folder=native/name;folder.mkdir();(folder/artifact).write_bytes(b'unit-fixture')
+        log=folder/(name+'.log');log.write_text('SYN-5025 WARNING: Using 0 for all undriven pins and nets\n')
+        stages[name]={'exit_code':0,'timed_out':False,'log':str(log),'log_sha256':td.sha256(log)}
+    receipt={'schema':'prod2u-6400-td-receipt-v1','run_id':'fixture-native','profile':'fixture','status':'FAIL',
+        'production':True,'simulation_only':False,'missing_outputs':[],'inputs':inputs,
+        'project_sha256':inputs['project.json'],'source_closure_sha256':inputs['closure.json'],
+        'source_manifest_sha256':hashlib.sha256(json.dumps(inputs,sort_keys=True,separators=(',',':')).encode()).hexdigest(),
+        'bitstream_sha256':td.sha256(native/'bitgen/firmware.bit'),'stages':stages}
+    path=native/'td-receipt.json';path.write_text(json.dumps(receipt))
+    return path,receipt,metrics
+
+def test_reaudit_creates_new_hash_bound_receipt(native_run,tmp_path):
+    path,_,_=native_run;before=path.read_bytes()
+    assert td.reaudit_receipt(path,tmp_path/'review')==0
+    result=json.loads((tmp_path/'review/td-receipt.json').read_text())
+    assert result['status']=='PASS' and result['reaudit']['original_status']=='FAIL'
+    assert result['reaudit']['native_receipt_sha256']==hashlib.sha256(before).hexdigest()
+    assert path.read_bytes()==before
+
+@pytest.mark.parametrize('change',['log','bit','stage','inputs','schema','not_production'])
+def test_reaudit_refuses_changed_or_incomplete_native_evidence(native_run,tmp_path,change):
+    path,receipt,_=native_run
+    if change=='log':Path(receipt['stages']['syn']['log']).write_text('changed')
+    elif change=='bit':(path.parent/'bitgen/firmware.bit').write_bytes(b'changed')
+    elif change=='stage':receipt['stages']['phy']['timed_out']=True
+    elif change=='inputs':receipt['project_sha256']='0'*64
+    elif change=='schema':receipt['schema']='not-a-td-receipt'
+    else:receipt['production']=False
+    if change not in ('log','bit'):path.write_text(json.dumps(receipt))
+    with pytest.raises(ValueError):td.reaudit_receipt(path,tmp_path/'review')
+    assert not (tmp_path/'review/td-receipt.json').exists()
+
+def test_reaudit_keeps_timing_failure(native_run,tmp_path):
+    path,_,metrics=native_run;metrics['hold_slack_ns']=-0.001
+    assert td.reaudit_receipt(path,tmp_path/'review')==1
+    assert json.loads((tmp_path/'review/td-receipt.json').read_text())['status']=='FAIL'

+ 64 - 16
tools/run_6400_td.py

@@ -299,13 +299,76 @@ def warning_audit(stage_records: dict[str, dict[str, object]]) -> dict[str, obje
     }
 
 
+def timing_result(metrics: dict[str, object]) -> tuple[list[str], bool]:
+    required_metrics = (
+        "total_luts", "lut", "registers", "dsp", "eram_bram", "mslice",
+        "lslice", "packed_slices", "fmax_mhz", "setup_slack_ns", "hold_slack_ns",
+        "setup_total_negative_slack_ns", "hold_total_negative_slack_ns",
+    )
+    missing_metrics = [name for name in required_metrics if metrics[name] is None]
+    timing_pass = bool(
+        not missing_metrics
+        and metrics["violation_endpoint_counts"]
+        and metrics["all_violation_endpoint_counts_zero"]
+        and metrics["fmax_mhz"] >= 25.0
+        and metrics["setup_slack_ns"] >= 0.0
+        and metrics["hold_slack_ns"] >= 0.0
+        and metrics["setup_total_negative_slack_ns"] == 0.0
+        and metrics["hold_total_negative_slack_ns"] == 0.0
+    )
+    return missing_metrics,timing_pass
+
+
+def reaudit_receipt(path: Path, output: Path) -> int:
+    """Re-evaluate immutable native evidence; never overwrite the original receipt."""
+    path=path.resolve();output=output.resolve()
+    if output==ROOT or ROOT in output.parents or output==path.parent:
+        raise ValueError('reaudit output must be new and external')
+    old=json.loads(path.read_text(encoding='utf-8'))
+    if old.get('schema') not in ('prod2u-6400-td-receipt-v1','prod2u-mrdimm-td-receipt-v1'):
+        raise ValueError('unsupported native TD receipt schema')
+    profile=old['profile'];current=input_manifest(profile)
+    if current!=old['inputs']:raise ValueError('reaudit source inputs differ from the native build')
+    manifest_sha=hashlib.sha256(json.dumps(current,sort_keys=True,separators=(',',':')).encode()).hexdigest()
+    config=HARDWARE_PROFILES[profile];basename=config['artifact_basename']
+    if old['source_manifest_sha256']!=manifest_sha or old['project_sha256']!=current[config['project']] or old['source_closure_sha256']!=current[config['closure']]:
+        raise ValueError('reaudit input identity mismatch')
+    if old.get('simulation_only') is not False or old.get('production') is not True or old.get('missing_outputs'):
+        raise ValueError('reaudit requires a complete production native run')
+    expected={'syn':path.parent/f'syn/{basename}_gate.db','phy':path.parent/f'phy/{basename}_pr.db',
+              'bitgen':path.parent/f'bitgen/{basename}.bit'}
+    for name in ('syn','phy','bitgen'):
+        stage=old['stages'][name];log=Path(stage['log'])
+        if stage['exit_code']!=0 or stage.get('timed_out') or not expected[name].is_file():
+            raise ValueError('reaudit cannot qualify an incomplete native stage: '+name)
+        if sha256(log)!=stage['log_sha256']:raise ValueError('native stage log changed: '+name)
+    if sha256(expected['bitgen'])!=old['bitstream_sha256']:raise ValueError('native bitstream changed')
+    audit=warning_audit(old['stages']);metrics=parse_metrics(path.parent,basename)
+    missing,timing=timing_result(metrics)
+    status='PASS' if audit['status']=='PASS' and timing else 'FAIL'
+    reviewed=dict(old)
+    reviewed.update(run_id=output.name,generated_at=datetime.now(timezone.utc).isoformat(),status=status,
+                    warning_audit=audit,metrics=metrics,missing_metrics=missing,timing_pass_25mhz=timing,
+                    deployment_status='TD_QUALIFIED_HARDWARE_NOT_RUN' if status=='PASS' else 'NOT_QUALIFIED')
+    reviewed['reaudit']={'native_run_id':old['run_id'],'native_receipt':str(path),
+        'native_receipt_sha256':sha256(path),'original_status':old['status'],'reviewer_source':source_identity(ROOT),
+        'reason':'current warning interpretation; native logs, inputs and bitstream verified and reused'}
+    output.mkdir(parents=True,exist_ok=False)
+    result=output/'td-receipt.json';result.write_text(json.dumps(reviewed,indent=2,sort_keys=True)+'\n')
+    print(str(result));return 0 if status=='PASS' else 1
+
+
 def main(argv: list[str] | None = None) -> int:
     parser = argparse.ArgumentParser()
     parser.add_argument(
         "--profile", choices=tuple(HARDWARE_PROFILES), default=DEFAULT_PROFILE
     )
     parser.add_argument("--run-root", type=Path)
+    parser.add_argument("--reaudit",type=Path,help="verify and re-audit an existing native run; no rebuild")
     args = parser.parse_args(argv)
+    if args.reaudit:
+        if args.run_root is None:parser.error('--reaudit requires a new --run-root')
+        return reaudit_receipt(args.reaudit,args.run_root)
     profile_name = args.profile
     profile = HARDWARE_PROFILES[profile_name]
     project_path = ROOT / str(profile["project"])
@@ -379,22 +442,7 @@ def main(argv: list[str] | None = None) -> int:
         status = "FAIL"
     bitstream = expected["bitgen"]
     metrics = parse_metrics(run_root, artifact_basename)
-    required_metrics = (
-        "total_luts", "lut", "registers", "dsp", "eram_bram", "mslice",
-        "lslice", "packed_slices", "fmax_mhz", "setup_slack_ns", "hold_slack_ns",
-        "setup_total_negative_slack_ns", "hold_total_negative_slack_ns",
-    )
-    missing_metrics = [name for name in required_metrics if metrics[name] is None]
-    timing_pass = bool(
-        not missing_metrics
-        and metrics["violation_endpoint_counts"]
-        and metrics["all_violation_endpoint_counts_zero"]
-        and metrics["fmax_mhz"] >= 25.0
-        and metrics["setup_slack_ns"] >= 0.0
-        and metrics["hold_slack_ns"] >= 0.0
-        and metrics["setup_total_negative_slack_ns"] == 0.0
-        and metrics["hold_total_negative_slack_ns"] == 0.0
-    )
+    missing_metrics,timing_pass=timing_result(metrics)
     if not timing_pass:
         status = "FAIL"
     receipt = {