Dashboard › institutional-transition-lab › Distillation
22383f08-716e-4c48-96ec-73ad24f92c69["lore_tm_v1_zm2z85n3V9g-0fBgwElCR0jWs99JzXbS-FI-X2Md7nY"]
/home/byk/Code/institutional-transition-lab/src/institution_lab/governance_adjudication.py lines 1–280 of 946. The module imports argparse, hashlib, io, json, os, stat, tempfile, zipfile, Counter, suppress, dataclass, Path, Any, Draft202012Validator, FormatChecker, and validate_response from institution_lab.governance_coding./home/byk/Code/institutional-transition-lab/src/institution_lab/governance_adjudication.py defines allowed values: DECISIONS = {"accept", "revise", "reject", "abstain"}; INSTITUTIONAL_CLASSES = {"effective_institutional_change", "announced_institutional_change", "proposal_only"}; REVIEWER_TYPES = {"human", "llm", "human_llm_assisted"}; REVIEWER_ROLES = {"source_adjudicator", "evidence_auditor", "synthesizer"}; and RESPONSE_SOURCES = {"luna_a", "luna_b", "terra_advisory"}.REQUIRED_INPUT_PINS with exactly 9 fields: workflow_run_id, artifact_id, artifact_sha256, documents_sha256, documents_file_sha256, coding_package_file_sha256, protocol_sha256, coding_schema_sha256, and adjudication_schema_sha256.FROZEN_INPUT_PINS identifies the frozen issue #4 input as workflow_run_id=33063470968, artifact_id=9642983578, artifact_sha256="1f6be91fcd98e43e99d82d5f274536f6c23616e7e6c711e26324a2cc4b06ef06", documents_sha256="d70f7f795847968339a645b6dbd6d4428af6bd6044de44fa2602d4c4343b0ee9", documents_file_sha256="2a62ab05687982c112a29f6126227c26c3ff8defc89ca64662753aaf85c3c0ce", coding_package_file_sha256="14644759f53071adfe1173d4e25bb01931b8c1591fa8a48295dbd0556a754769", protocol_sha256="06d4b3407677fe7fb23046f70164a366db06638e8a29af3daf7661f00d565933", coding_schema_sha256="bfc735a7d8602d1f236a88c2d23b195f0600a8bae86fb8c8936afe7883a41b8e", and adjudication_schema_sha256="6181f5cb60a0462f83be00be301763daa89f11581e68ee1c46a84e8bf4e5be31".CLAIM_FIELDS = {"record_class", "event_kind", "title", "announced_on", "effective_on", "affected_scope", "body_patch_relation"} and resource limits MAX_INPUT_BYTES = 16 * 1024 * 1024, MAX_ARTIFACT_BYTES = 32 * 1024 * 1024, MAX_ARCHIVE_MEMBERS = 128, MAX_ARCHIVE_MEMBER_BYTES = 16 * 1024 * 1024, and MAX_ARCHIVE_EXPANDED_BYTES = 64 * 1024 * 1024.VerifiedInputBundle with fields pins: dict[str, Any], documents: dict[str, Any], coding_package: dict[str, Any], and adjudication_schema: dict[str, Any].canonical_sha256(value) serializes JSON using sort_keys=True, separators=(",", ":"), and allow_nan=False, encodes it, and returns its SHA-256 hex digest; _bytes_sha256(payload) hashes raw bytes._read_regular_file(path, *, max_bytes=MAX_INPUT_BYTES) opens inputs with os.O_RDONLY | os.O_NONBLOCK | getattr(os, "O_NOFOLLOW", 0), converts open failures to ValueError, verifies via os.fstat() and stat.S_ISREG() that the input is a regular file, rejects declared or actual content above max_bytes, and reads at most max_bytes + 1. file_sha256(path) uses this helper with MAX_ARTIFACT_BYTES._reject_duplicate_keys() to raise ValueError(f"duplicate JSON key: {key}"), _reject_non_finite_number() to reject non-finite constants, and _parse_json_object() with object_pairs_hook=_reject_duplicate_keys and parse_constant=_reject_non_finite_number; malformed JSON and non-object top-level values are rejected._validate_manifest_identity(manifest) requires an object whose key set exactly equals REQUIRED_INPUT_PINS; requires positive, exact-type integers for workflow_run_id and artifact_id; and checks every field against FROZEN_INPUT_PINS, raising ValueError(f"input manifest does not identify frozen issue #4 input: {field}") on mismatch._verify_input_payloads() first validates manifest identity, then verifies raw-byte hashes for artifact_sha256, documents_file_sha256, coding_package_file_sha256, protocol_sha256, coding_schema_sha256, and adjudication_schema_sha256. A mismatch raises ValueError(f"input manifest mismatch: {field}")._verify_input_payloads() uses zipfile.ZipFile(io.BytesIO(artifact)); rejects more than MAX_ARCHIVE_MEMBERS, duplicate member names, and total declared expansion above MAX_ARCHIVE_EXPANDED_BYTES. It requires exactly one accessible copy each of documents.json and v1.2-adjudication-package.json, limits each required member to MAX_ARCHIVE_MEMBER_BYTES, and byte-compares each archive member against its durable external file. zipfile.BadZipFile becomes ValueError("artifact is not a valid ZIP archive")._verify_input_payloads() strictly parses documents, checks manifest["documents_sha256"] against canonical_sha256(documents_value), and returns VerifiedInputBundle containing copied pins plus parsed documents, coding_package, and adjudication_schema.verify_input_manifest() accepts Path arguments artifact, documents, coding_package, protocol, coding_schema, and adjudication_schema; validates the manifest, reads each as a guarded regular file (artifact with MAX_ARTIFACT_BYTES, others with the default MAX_INPUT_BYTES), delegates to _verify_input_payloads(), and returns only .pins._duplicates(values: list[str]) returns the set of values occurring more than once using Counter._source_index(document) maps each valid source object’s string source_id to its string text, then adds synthetic source "record_metadata" containing compact, key-sorted JSON for record_id, source_url, published_on, publisher, and source_type._evidence_errors(reference, sources, path, *, claim=False) begins evidence-reference validation: the reference must be an object; ordinary evidence must contain exactly source_id and quote; claim evidence must contain exactly source_id, quote, and field; claim field must belong to CLAIM_FIELDS; and source_id must be a non-empty string. The remainder of this function lies after line 280 and was not shown.