init: company-haness 설계
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
"""benchmark 입력(brief·rubric·fixtures·evidence-pack) sha256 — controller 주입 감사·재현용."""
|
||||
import hashlib
|
||||
import os
|
||||
|
||||
|
||||
def sha256_file(path):
|
||||
h = hashlib.sha256()
|
||||
with open(path, "rb") as f:
|
||||
for chunk in iter(lambda: f.read(65536), b""):
|
||||
h.update(chunk)
|
||||
return h.hexdigest()
|
||||
|
||||
|
||||
def sha256_tree(root):
|
||||
"""디렉토리 정규화 hash: (상대경로, 파일hash) 를 경로 정렬해 연쇄."""
|
||||
h = hashlib.sha256()
|
||||
for rel in sorted(os.path.relpath(os.path.join(dp, fn), root)
|
||||
for dp, _, fns in os.walk(root) for fn in fns):
|
||||
h.update(rel.encode())
|
||||
h.update(sha256_file(os.path.join(root, rel)).encode())
|
||||
return h.hexdigest()
|
||||
|
||||
|
||||
def benchmark_input(brief, rubric, fixtures_dir, evidence_pack_dir):
|
||||
return {
|
||||
"brief-sha256": sha256_file(brief),
|
||||
"rubric-sha256": sha256_file(rubric),
|
||||
"fixture-set-sha256": sha256_tree(fixtures_dir),
|
||||
"evidence-pack-sha256": sha256_tree(evidence_pack_dir),
|
||||
}
|
||||
Reference in New Issue
Block a user