Dashboard › institutional-transition-lab › Session 1Ma0qqTA0QBU
1Ma0qqTA0QBUSux53This replaces one twice-empty ZIP reviewer with a smaller disjoint scope. Read only src/institution_lab/governance_adjudication.py and tests/test_governance_adjudication.py; do not edit files. Scope ONLY bounded member decoding and integrity after a separate parser supplies trusted compressed-data slices and central metadata: safe handling of STORED, DEFLATE, BZIP2, and LZMA or a justified narrower allowlist; hard decoded-byte limits independent of declared sizes and ZipExtFile.read(n); compressed-stream EOF/trailing-byte validation; decoded-size and CRC verification; data-descriptor handling/boundaries for the current pinned archive; malformed/truncated streams whose decoded payload or CRC could otherwise match; normalized codec exceptions. Do NOT design EOCD, central-directory path/name, local-header, collision, or file-mode validation. Return concrete minimal helper signatures, codec APIs/state checks, validation order, limits, normalized errors, and deterministic fail-first test mutations. Return substantive guidance or BLOCKED: <exact tool/error>, and end exactly SUBSTANTIVE or BLOCKED.
<path>/home/byk/Code/institutional-transition-lab/src/institution_lab/governance_adjudication.py</path>
<type>file</type>
<content>
1: from __future__ import annotations
2:
3: import argparse
4: import hashlib
5: import io
6: import json
7: import os
8: import stat
9: import tempfile
10: import zipfile
11: from collections import Counter
12: from contextlib import suppress
13: from dataclasses import dataclass
14: from pathlib import Path
15: from typing import Any
16:
17: from jsonschema import Draft202012Validator, FormatChecker
18:
19: from institution_lab.governance_coding import validate_response
20:
21: DECISIONS = {"accept", "revise", "reject", "abstain"}
22: INSTITUTIONAL_CLASSES = {
23: "effective_institutional_change",
24: "announced_institutional_change",
25: "proposal_only",
26: }
27: REVIEWER_TYPES = {"human", "llm", "human_llm_assisted"}
28: REVIEWER_ROLES = {"source_adjudicator", "evidence_auditor", "synthesizer"}
29: RESPONSE_SOURCES = {"luna_a", "luna_b", ...
<path>/home/byk/Code/institutional-transition-lab/tests/test_governance_adjudication.py</path> <type>file</type> <content> 1: from __future__ import annotations 2: 3: import copy 4: import json 5: import os 6: import subprocess 7: import sys 8: import zipfile 9: from pathlib import Path 10: 11: import pytest 12: 13: from institution_lab import governance_adjudication 14: from institution_lab.governance_adjudication import ( 15: DECISIONS, 16: FROZEN_INPUT_PINS, 17: REQUIRED_INPUT_PINS, 18: REVIEWER_ROLES, 19: REVIEWER_TYPES, 20: canonical_sha256, 21: file_sha256, 22: validate_adjudication, 23: validate_adjudication_fragment, 24: validate_against_schema, 25: verify_input_manifest, 26: ) 27: from institution_lab.governance_coding import ( 28: BODY_PATCH_RELATIONS, 29: CHANGE_STATUSES, 30: DIRECTIONS, 31: EVENT_KINDS, 32: RECORD_CLASSES, 33: RIGHT_KINDS, 34: ) 35: 36: ROOT = Path(__file__).parents[1] 37: MAX_TEST_ARCHIVE_MEMBERS = 256 38: 39: 40: def ...
/usr/bin/bash: line 1: python: command not found
class LZMADecompressor:
def __init__(self):
self._decomp = None
self._unconsumed = b''
self.eof = False
def decompress(self, data):
if self._decomp is None:
self._unconsumed += data
if len(self._unconsumed) <= 4:
return b''
psize, = struct.unpack('<H', self._unconsumed[2:4])
if len(self._unconsumed) <= 4 + psize:
return b''
self._decomp = lzma.LZMADecompressor(lzma.FORMAT_RAW, filters=[
lzma._decode_filter_properties(lzma.FILTER_LZMA1,
self._unconsumed[4:4 + psize])
])
data = self._unconsumed[4 + psize:]
del self._unconsumed
result = self._decomp.decompress(data)
self.eof = self._decomp.eof
return result
def _get_decompressor(compress_type):
_check_compression(compress_type)
if compress_type == ZIP_STORED:
return ...
class LZMACompressor:
def __init__(self):
self._comp = None
def _init(self):
props = lzma._encode_filter_properties({'id': lzma.FILTER_LZMA1})
self._comp = lzma.LZMACompressor(lzma.FORMAT_RAW, filters=[
lzma._decode_filter_properties(lzma.FILTER_LZMA1, props)
])
return struct.pack('<BBH', 9, 4, len(props)) + props
def compress(self, data):
if self._comp is None:
return self._init() + self._comp.compress(data)
return self._comp.compress(data)
def flush(self):
if self._comp is None:
return self._init() + self._comp.flush()
return self._comp.flush()
/usr/lib/python3.12/zipfile/__init__.py
def _open_to_write(self, zinfo, force_zip64=False):
if force_zip64 and not self._allowZip64:
raise ValueError(
"force_zip64 is True, but allowZip64 was False when opening "
"the ZIP file."
)
if self._writing:
raise ValueError("Can't write to the ZIP file while there is "
"another write handle open on it. "
"Close the first handle before opening another.")
# Size and CRC are overwritten with correct data after processing the file
zinfo.compress_size = 0
zinfo.CRC = 0
zinfo.flag_bits = 0x00
if zinfo.compress_type == ZIP_LZMA:
# Compressed data includes an end-of-stream (EOS) marker
zinfo.flag_bits |= _MASK_COMPRESS_OPTION_1
if not self._seekable:
zinfo.flag_bits |= _MASK_USE_DATA_DESCRIPTOR
if not zinfo.external_attr:
zinfo.external_attr ...
deflate sync 6425 62 True False 0 0 bzlen 97 bzcutfull 1 False 0 True bzcutfull 2 False 0 True bzcutfull 3 False 0 True bzcutfull 4 False 0 True bzcutfull 5 False 0 True bzcutfull 6 False 0 True bzcutfull 7 False 0 True bzcutfull 8 False 0 True bzcutfull 9 False 0 True bzcutfull 10 False 0 True lzlen 67 lzcutfull 1 False 0 True lzcutfull 2 False 0 True lzcutfull 3 False 0 True lzcutfull 4 False 0 True lzcutfull 5 False 0 True lzcutfull 6 False 0 True
Found 39 matches
/home/byk/Code/institutional-transition-lab/src/institution_lab/governance_adjudication.py:
Line 10: import zipfile
Line 32: "artifact_id",
Line 33: "artifact_sha256",
Line 43: "artifact_id": 9642983578,
Line 44: "artifact_sha256": "1f6be91fcd98e43e99d82d5f274536f6c23616e7e6c711e26324a2cc4b06ef06",
Line 65: MAX_INPUT_BYTES = 16 * 1024 * 1024
Line 66: MAX_ARTIFACT_BYTES = 32 * 1024 * 1024
Line 67: MAX_ARCHIVE_MEMBERS = 128
Line 68: MAX_ARCHIVE_MEMBER_BYTES = 16 * 1024 * 1024
Line 69: MAX_ARCHIVE_EXPANDED_BYTES = 64 * 1024 * 1024
Line 94: def _read_regular_file(path: Path, *, max_bytes: int = MAX_INPUT_BYTES) -> bytes:
Line 113: return _bytes_sha256(_read_regular_file(path, max_bytes=MAX_ARTIFACT_BYTES))
Line 150: if type(manifest.get("artifact_id")) is not int or manifest["artifact_id"] < 1:
Line 151: raise ValueError("input manifest artifact_id is invalid")
Line 157: def _verify_input_payloads(
Line 160: ...
<path>/home/byk/Code/institutional-transition-lab/src/institution_lab/governance_adjudication.py</path>
<type>file</type>
<content>
1: from __future__ import annotations
2:
3: import argparse
4: import hashlib
5: import io
6: import json
7: import os
8: import stat
9: import tempfile
10: import zipfile
11: from collections import Counter
12: from contextlib import suppress
13: from dataclasses import dataclass
14: from pathlib import Path
15: from typing import Any
16:
17: from jsonschema import Draft202012Validator, FormatChecker
18:
19: from institution_lab.governance_coding import validate_response
20:
21: DECISIONS = {"accept", "revise", "reject", "abstain"}
22: INSTITUTIONAL_CLASSES = {
23: "effective_institutional_change",
24: "announced_institutional_change",
25: "proposal_only",
26: }
27: REVIEWER_TYPES = {"human", "llm", "human_llm_assisted"}
28: REVIEWER_ROLES = {"source_adjudicator", "evidence_auditor", "synthesizer"}
29: RESPONSE_SOURCES = {"luna_a", "luna_b", ...
Found 17 matches
/home/byk/Code/institutional-transition-lab/tests/test_governance_adjudication.py:
Line 8: import zipfile
Line 65: with zipfile.ZipFile(paths["artifact"], "w") as archive:
Line 66: archive.writestr("documents.json", paths["documents"].read_bytes())
Line 67: archive.writestr(
Line 703: with zipfile.ZipFile(artifact, "w") as archive:
Line 704: archive.writestr("documents.json", documents.read_bytes())
Line 705: archive.writestr("v1.2-adjudication-package.json", coding_package.read_bytes())
Line 743: with zipfile.ZipFile(artifact, "w") as archive:
Line 744: archive.writestr("documents.json", b"different documents")
Line 745: archive.writestr("v1.2-adjudication-package.json", coding_package.read_bytes())
Line 772: with pytest.raises(ValueError, match="artifact member mismatch: documents.json"):
Line 890: zipfile.ZipFile(paths["artifact"], "a") as archive,
Line 892: archive.writestr("documents.json", ...
<path>/home/byk/Code/institutional-transition-lab/tests/test_governance_adjudication.py</path> <type>file</type> <content> 1: from __future__ import annotations 2: 3: import copy 4: import json 5: import os 6: import subprocess 7: import sys 8: import zipfile 9: from pathlib import Path 10: 11: import pytest 12: 13: from institution_lab import governance_adjudication 14: from institution_lab.governance_adjudication import ( 15: DECISIONS, 16: FROZEN_INPUT_PINS, 17: REQUIRED_INPUT_PINS, 18: REVIEWER_ROLES, 19: REVIEWER_TYPES, 20: canonical_sha256, 21: file_sha256, 22: validate_adjudication, 23: validate_adjudication_fragment, 24: validate_against_schema, 25: verify_input_manifest, 26: ) 27: from institution_lab.governance_coding import ( 28: BODY_PATCH_RELATIONS, 29: CHANGE_STATUSES, 30: DIRECTIONS, 31: EVENT_KINDS, 32: RECORD_CLASSES, 33: RIGHT_KINDS, 34: ) 35: 36: ROOT = Path(__file__).parents[1] 37: MAX_TEST_ARCHIVE_MEMBERS = 256 38: 39: 40: def ...
<path>/home/byk/Code/institutional-transition-lab/tests/test_governance_adjudication.py</path>
<type>file</type>
<content>
670:
671:
672: @pytest.mark.parametrize("field", ["workflow_run_id", "artifact_id"])
673: def test_frozen_input_identifiers_are_reverified(field: str) -> None:
674: adjudication = _adjudication()
675: adjudication["inputs"][field] += 1
676:
677: errors, summary = _validate(adjudication)
678:
679: assert f"input pin mismatch: {field}" in errors
680: assert summary["canonicalization_gate"] == "closed"
681:
682:
683: def test_input_manifest_rejects_changed_file_bytes(
684: tmp_path: Path,
685: monkeypatch: pytest.MonkeyPatch,
686: ) -> None:
687: artifact = tmp_path / "artifact.zip"
688: documents = tmp_path / "documents.json"
689: coding_package = tmp_path / "coding-package.json"
690: protocol = tmp_path / "protocol.md"
691: coding_schema = tmp_path / "coding-schema.json"
692: adjudication_schema = tmp_path / "adjudication-schema.json"
693: paths ...
archive 423046 documents.json method 8 flags 0x8 usize 445940 csize 120892 crc 0x35777f offset 0 extract 20 luna-a.json method 8 flags 0x8 usize 56076 csize 7161 crc 0x13265cc6 offset 120952 extract 20 luna-b.json method 8 flags 0x8 usize 52967 csize 6651 crc 0x8a7d80b4 offset 128170 extract 20 adjudication-package.json method 8 flags 0x8 usize 149490 csize 13779 crc 0x2184f7c5 offset 134878 extract 20 preliminary-package.json method 8 flags 0x8 usize 107543 csize 10349 crc 0x4487be4d offset 148728 extract 20 preliminary-summary.json method 8 flags 0x8 usize 707 csize 353 crc 0xf4d04071 offset 159147 extract 20 preliminary-summary.md method 8 flags 0x8 usize 543 csize 311 crc 0x1053e63c offset 159570 extract 20 summary.json method 8 flags 0x8 usize 703 csize 351 crc 0x1b21a9a7 offset 159949 extract 20 summary.md method 8 flags 0x8 usize 542 csize 309 crc 0x81ccf098 offset 160358 extract 20 terra-route.json method 8 flags 0x8 usize 391727 csize 105388 crc 0x995204cc offset 160723 ...
def read(self, n=-1):
"""Read and return up to n bytes.
If the argument is omitted, None, or negative, data is read and returned until EOF is reached.
"""
if self.closed:
raise ValueError("read from closed file.")
if n is None or n < 0:
buf = self._readbuffer[self._offset:]
self._readbuffer = b''
self._offset = 0
while not self._eof:
buf += self._read1(self.MAX_N)
return buf
end = n + self._offset
if end < len(self._readbuffer):
buf = self._readbuffer[self._offset:end]
self._offset = end
return buf
n = end - len(self._readbuffer)
buf = self._readbuffer[self._offset:]
self._readbuffer = b''
self._offset = 0
while n > 0 and not self._eof:
data = self._read1(n)
if n < len(data):
self._readbuffer = data
...
documents.json 44 120936 504b07087f7735003cd80100f4cd0600 0x8074b50 True True True luna-a.json 120993 128154 504b0708c65c2613f91b00000cdb0000 0x8074b50 True True True luna-b.json 128211 134862 504b0708b4807d8afb190000e7ce0000 0x8074b50 True True True adjudication-package.json 134933 148712 504b0708c5f78421d3350000f2470200 0x8074b50 True True True preliminary-package.json 148782 159131 504b07084dbe87446d28000017a40100 0x8074b50 True True True preliminary-summary.json 159201 159554 504b07087140d0f461010000c3020000 0x8074b50 True True True preliminary-summary.md 159622 159933 504b07083ce65310370100001f020000 0x8074b50 True True True summary.json 159991 160342 504b0708a7a9211b5f010000bf020000 0x8074b50 True True True summary.md 160398 160707 504b070898f0cc81350100001e020000 0x8074b50 True True True terra-route.json 160769 266157 504b0708cc045299ac9b01002ffa0500 0x8074b50 True True True terra.json 266213 272695 504b0708e4acc22b52190000e0aa0000 0x8074b50 True True ...
<path>/home/byk/Code/institutional-transition-lab/tests/test_governance_adjudication.py</path>
<type>file</type>
<content>
954: @pytest.mark.parametrize("value", [float("nan"), float("inf"), float("-inf")])
955: def test_canonical_sha256_rejects_non_finite_numbers(value: float) -> None:
956: with pytest.raises(ValueError, match="Out of range float values"):
957: canonical_sha256({"value": value})
958:
959:
960: def test_committed_frozen_input_manifest_verifies() -> None:
961: input_directory = ROOT / "cases/review/oss-governance-adjudication-v1"
962: manifest = json.loads(
963: (ROOT / "cases/review/oss-governance-adjudication-v1.inputs.json").read_text()
964: )
965:
966: verified = verify_input_manifest(
967: manifest,
968: artifact=input_directory / "artifact-9642983578.zip",
969: documents=input_directory / "documents.json",
970: coding_package=input_directory / "v1.2-coding-package.json",
971: protocol=ROOT / ...
accepted_truncated_stream= True codec_eof= False compressed_bytes= 22 accepted_trailing_bytes= True unused_bytes= 8
True 16 16 1055
/usr/bin/python3: No module named pytest
No files found
b'\x07' error Error -3 while decompressing data: invalid block type b'\x06' error Error -3 while decompressing data: invalid block type b'not-deflate' error Error -3 while decompressing data: invalid block type
Found 29 matches
/home/byk/Code/institutional-transition-lab/src/institution_lab/governance_adjudication.py:
Line 10: import zipfile
Line 32: "artifact_id",
Line 33: "artifact_sha256",
Line 41: FROZEN_INPUT_PINS = {
Line 43: "artifact_id": 9642983578,
Line 44: "artifact_sha256": "1f6be91fcd98e43e99d82d5f274536f6c23616e7e6c711e26324a2cc4b06ef06",
Line 150: if type(manifest.get("artifact_id")) is not int or manifest["artifact_id"] < 1:
Line 151: raise ValueError("input manifest artifact_id is invalid")
Line 152: for field, value in FROZEN_INPUT_PINS.items():
Line 157: def _verify_input_payloads(
Line 160: artifact: bytes,
Line 169: "artifact_sha256": _bytes_sha256(artifact),
Line 180: with zipfile.ZipFile(io.BytesIO(artifact)) as archive:
Line 183: raise ValueError("artifact member count exceeds limit")
Line 187: raise ValueError(f"artifact member is not unique: {member_name}")
Line 189: raise ValueError("artifact ...
<path>/home/byk/Code/institutional-transition-lab/src/institution_lab/governance_adjudication.py</path>
<type>file</type>
<content>
1: from __future__ import annotations
2:
3: import argparse
4: import hashlib
5: import io
6: import json
7: import os
8: import stat
9: import tempfile
10: import zipfile
11: from collections import Counter
12: from contextlib import suppress
13: from dataclasses import dataclass
14: from pathlib import Path
15: from typing import Any
16:
17: from jsonschema import Draft202012Validator, FormatChecker
18:
19: from institution_lab.governance_coding import validate_response
20:
21: DECISIONS = {"accept", "revise", "reject", "abstain"}
22: INSTITUTIONAL_CLASSES = {
23: "effective_institutional_change",
24: "announced_institutional_change",
25: "proposal_only",
26: }
27: REVIEWER_TYPES = {"human", "llm", "human_llm_assisted"}
28: REVIEWER_ROLES = {"source_adjudicator", "evidence_auditor", "synthesizer"}
29: RESPONSE_SOURCES = {"luna_a", "luna_b", ...
Found 48 matches
/home/byk/Code/institutional-transition-lab/tests/test_governance_adjudication.py:
Line 8: import zipfile
Line 52: "artifact": tmp_path / "artifact.zip",
Line 65: with zipfile.ZipFile(paths["artifact"], "w") as archive:
Line 73: "artifact_id": 9642983578,
Line 74: "artifact_sha256": file_sha256(paths["artifact"]),
Line 94: "artifact",
Line 195: "source_text_truncated": False,
Line 197: "patch_selection_truncated": False,
Line 210: "source_text_truncated": False,
Line 212: "patch_selection_truncated": False,
Line 244: "artifact_id": 9642983578,
Line 245: "artifact_sha256": "0" * 64,
Line 288: "artifact_id": 9642983578,
Line 289: "artifact_sha256": "0" * 64,
Line 379: ("evidence_bounds", {"source_text_truncated": True}),
Line 426: documents["documents"][0]["evidence_bounds"]["source_text_truncated"] = True
Line 636: adjudication["inputs"]["artifact_sha256"] = "wrong"
Line 640: ...
<path>/home/byk/Code/institutional-transition-lab/tests/test_governance_adjudication.py</path> <type>file</type> <content> 1: from __future__ import annotations 2: 3: import copy 4: import json 5: import os 6: import subprocess 7: import sys 8: import zipfile 9: from pathlib import Path 10: 11: import pytest 12: 13: from institution_lab import governance_adjudication 14: from institution_lab.governance_adjudication import ( 15: DECISIONS, 16: FROZEN_INPUT_PINS, 17: REQUIRED_INPUT_PINS, 18: REVIEWER_ROLES, 19: REVIEWER_TYPES, 20: canonical_sha256, 21: file_sha256, 22: validate_adjudication, 23: validate_adjudication_fragment, 24: validate_against_schema, 25: verify_input_manifest, 26: ) 27: from institution_lab.governance_coding import ( 28: BODY_PATCH_RELATIONS, 29: CHANGE_STATUSES, 30: DIRECTIONS, 31: EVENT_KINDS, 32: RECORD_CLASSES, 33: RIGHT_KINDS, 34: ) 35: 36: ROOT = Path(__file__).parents[1] 37: MAX_TEST_ARCHIVE_MEMBERS = 256 38: 39: 40: def ...
<path>/home/byk/Code/institutional-transition-lab/tests/test_governance_adjudication.py</path>
<type>file</type>
<content>
680: assert summary["canonicalization_gate"] == "closed"
681:
682:
683: def test_input_manifest_rejects_changed_file_bytes(
684: tmp_path: Path,
685: monkeypatch: pytest.MonkeyPatch,
686: ) -> None:
687: artifact = tmp_path / "artifact.zip"
688: documents = tmp_path / "documents.json"
689: coding_package = tmp_path / "coding-package.json"
690: protocol = tmp_path / "protocol.md"
691: coding_schema = tmp_path / "coding-schema.json"
692: adjudication_schema = tmp_path / "adjudication-schema.json"
693: paths = {
694: "artifact": artifact,
695: "documents": documents,
696: "coding_package": coding_package,
697: "protocol": protocol,
698: "coding_schema": coding_schema,
699: "adjudication_schema": adjudication_schema,
700: }
701: for path in paths.values():
702: path.write_text(path.name)
703: with zipfile.ZipFile(artifact, "w") as ...
b'abc' 3 9 True 0
1 44 43 1792 True False 2 BadZipFile Bad CRC-32 for file 'x' 3 BadZipFile Bad CRC-32 for file 'x' 4 BadZipFile Bad CRC-32 for file 'x' 5 BadZipFile Bad CRC-32 for file 'x' 6 BadZipFile Bad CRC-32 for file 'x' 7 BadZipFile Bad CRC-32 for file 'x' 8 BadZipFile Bad CRC-32 for file 'x' 9 BadZipFile Bad CRC-32 for file 'x'
1792 0x4151b4ac 4bca2fcd4b494dd1cdcc2b494d2fca2ca9d42d02d2a9c5c599f97949a372a372a372a372a372a372c3540e00 4bca2fcd4b494dd1cdcc2b494d2fca2ca9d42d02d2a9c5c599f97949a372a372a372a372a372a372c3540e
Found 21 matches
/home/byk/Code/institutional-transition-lab/src/institution_lab/governance_adjudication.py:
Line 65: MAX_INPUT_BYTES = 16 * 1024 * 1024
Line 66: MAX_ARTIFACT_BYTES = 32 * 1024 * 1024
Line 67: MAX_ARCHIVE_MEMBERS = 128
Line 68: MAX_ARCHIVE_MEMBER_BYTES = 16 * 1024 * 1024
Line 69: MAX_ARCHIVE_EXPANDED_BYTES = 64 * 1024 * 1024
Line 106: payload = source.read(max_bytes + 1)
Line 157: def _verify_input_payloads(
Line 180: with zipfile.ZipFile(io.BytesIO(artifact)) as archive:
Line 182: if len(infos) > MAX_ARCHIVE_MEMBERS:
Line 183: raise ValueError("artifact member count exceeds limit")
Line 187: raise ValueError(f"artifact member is not unique: {member_name}")
Line 188: if sum(info.file_size for info in infos) > MAX_ARCHIVE_EXPANDED_BYTES:
Line 198: raise ValueError(f"artifact member missing: {member_name}") from error
Line 199: if info.file_size > MAX_ARCHIVE_MEMBER_BYTES:
Line 200: raise ...
<path>/home/byk/Code/institutional-transition-lab/src/institution_lab/governance_adjudication.py</path>
<type>file</type>
<content>
1: from __future__ import annotations
2:
3: import argparse
4: import hashlib
5: import io
6: import json
7: import os
8: import stat
9: import tempfile
10: import zipfile
11: from collections import Counter
12: from contextlib import suppress
13: from dataclasses import dataclass
14: from pathlib import Path
15: from typing import Any
16:
17: from jsonschema import Draft202012Validator, FormatChecker
18:
19: from institution_lab.governance_coding import validate_response
20:
21: DECISIONS = {"accept", "revise", "reject", "abstain"}
22: INSTITUTIONAL_CLASSES = {
23: "effective_institutional_change",
24: "announced_institutional_change",
25: "proposal_only",
26: }
27: REVIEWER_TYPES = {"human", "llm", "human_llm_assisted"}
28: REVIEWER_ROLES = {"source_adjudicator", "evidence_auditor", "synthesizer"}
29: RESPONSE_SOURCES = {"luna_a", "luna_b", ...
<path>/home/byk/Code/institutional-transition-lab/tests/test_governance_adjudication.py</path> <type>file</type> <content> 1: from __future__ import annotations 2: 3: import copy 4: import json 5: import os 6: import subprocess 7: import sys 8: import zipfile 9: from pathlib import Path 10: 11: import pytest 12: 13: from institution_lab import governance_adjudication 14: from institution_lab.governance_adjudication import ( 15: DECISIONS, 16: FROZEN_INPUT_PINS, 17: REQUIRED_INPUT_PINS, 18: REVIEWER_ROLES, 19: REVIEWER_TYPES, 20: canonical_sha256, 21: file_sha256, 22: validate_adjudication, 23: validate_adjudication_fragment, 24: validate_against_schema, 25: verify_input_manifest, 26: ) 27: from institution_lab.governance_coding import ( 28: BODY_PATCH_RELATIONS, 29: CHANGE_STATUSES, 30: DIRECTIONS, 31: EVENT_KINDS, 32: RECORD_CLASSES, 33: RIGHT_KINDS, 34: ) 35: 36: ROOT = Path(__file__).parents[1] 37: MAX_TEST_ARCHIVE_MEMBERS = 256 38: 39: 40: def ...
Found 13 matches /home/byk/Code/institutional-transition-lab/tests/test_governance_adjudication.py: Line 25: verify_input_manifest, Line 661: verify_input_manifest( Line 726: verify_input_manifest(manifest, **paths) Line 772: with pytest.raises(ValueError, match="artifact member mismatch: documents.json"): Line 773: verify_input_manifest(manifest, **paths) Line 783: original_verify = governance_adjudication.verify_input_manifest Line 792: "verify_input_manifest", Line 872: verify_input_manifest( Line 896: with pytest.raises(ValueError, match="artifact member is not unique: documents.json"): Line 897: verify_input_manifest( Line 919: with pytest.raises(ValueError, match="artifact member count exceeds limit"): Line 920: verify_input_manifest( Line 966: verified = verify_input_manifest(
<path>/home/byk/Code/institutional-transition-lab/tests/test_governance_adjudication.py</path>
<type>file</type>
<content>
620: assert any("reviewer_ids must be unique" in error for error in errors)
621: assert summary["canonicalization_gate"] == "closed"
622:
623:
624: def test_malformed_reviewer_id_does_not_crash_manual_validation() -> None:
625: adjudication = _adjudication()
626: adjudication["records"][0]["reviewer_ids"] = [{"invalid": "reviewer"}]
627:
628: errors, summary = _validate(adjudication)
629:
630: assert any("reviewer_ids must contain non-empty strings" in error for error in errors)
631: assert summary["canonicalization_gate"] == "closed"
632:
633:
634: def test_every_input_pin_is_reverified() -> None:
635: adjudication = _adjudication()
636: adjudication["inputs"]["artifact_sha256"] = "wrong"
637:
638: errors, summary = _validate(adjudication)
639:
640: assert "input pin mismatch: artifact_sha256" in errors
641: assert ...
1810 61 1810 True False 0xc27b61de 16 18 16 True False 0x22ccea73 1825 75 1824 False False 0xd3f37109
<path>/usr/lib/python3.12/zipfile/__init__.py</path>
<type>file</type>
<content>
660: append = result.append
661: for c in data:
662: k = key2 | 2
663: c ^= ((k * (k^1)) >> 8) & 0xFF
664: update_keys(c)
665: append(c)
666: return bytes(result)
667:
668: return decrypter
669:
670:
671: class LZMACompressor:
672:
673: def __init__(self):
674: self._comp = None
675:
676: def _init(self):
677: props = lzma._encode_filter_properties({'id': lzma.FILTER_LZMA1})
678: self._comp = lzma.LZMACompressor(lzma.FORMAT_RAW, filters=[
679: lzma._decode_filter_properties(lzma.FILTER_LZMA1, props)
680: ])
681: return struct.pack('<BBH', 9, 4, len(props)) + props
682:
683: def compress(self, data):
684: if self._comp is None:
685: return self._init() + self._comp.compress(data)
686: return self._comp.compress(data)
687:
688: def ...
<path>/usr/lib/python3.12/zipfile/__init__.py</path>
<type>file</type>
<content>
1010: break
1011: buf += data
1012: n -= len(data)
1013: return buf
1014:
1015: def _update_crc(self, newdata):
1016: # Update the CRC using the given data.
1017: if self._expected_crc is None:
1018: # No need to compute the CRC if we don't have a reference value
1019: return
1020: self._running_crc = crc32(newdata, self._running_crc)
1021: # Check the CRC if we're at the end of the file
1022: if self._eof and self._running_crc != self._expected_crc:
1023: raise BadZipFile("Bad CRC-32 for file %r" % self.name)
1024:
1025: def read1(self, n):
1026: """Read up to n bytes with at most one read() system call."""
1027:
1028: if n is None or n < 0:
1029: buf = self._readbuffer[self._offset:]
1030: self._readbuffer = b''
1031: ...
<path>/home/byk/Code/institutional-transition-lab/src/institution_lab/governance_adjudication.py</path>
<type>file</type>
<content>
1: from __future__ import annotations
2:
3: import argparse
4: import hashlib
5: import io
6: import json
7: import os
8: import stat
9: import tempfile
10: import zipfile
11: from collections import Counter
12: from contextlib import suppress
13: from dataclasses import dataclass
14: from pathlib import Path
15: from typing import Any
16:
17: from jsonschema import Draft202012Validator, FormatChecker
18:
19: from institution_lab.governance_coding import validate_response
20:
21: DECISIONS = {"accept", "revise", "reject", "abstain"}
22: INSTITUTIONAL_CLASSES = {
23: "effective_institutional_change",
24: "announced_institutional_change",
25: "proposal_only",
26: }
27: REVIEWER_TYPES = {"human", "llm", "human_llm_assisted"}
28: REVIEWER_ROLES = {"source_adjudicator", "evidence_auditor", "synthesizer"}
29: RESPONSE_SOURCES = {"luna_a", "luna_b", ...
<path>/home/byk/Code/institutional-transition-lab/tests/test_governance_adjudication.py</path> <type>file</type> <content> 1: from __future__ import annotations 2: 3: import copy 4: import json 5: import os 6: import subprocess 7: import sys 8: import zipfile 9: from pathlib import Path 10: 11: import pytest 12: 13: from institution_lab import governance_adjudication 14: from institution_lab.governance_adjudication import ( 15: DECISIONS, 16: FROZEN_INPUT_PINS, 17: REQUIRED_INPUT_PINS, 18: REVIEWER_ROLES, 19: REVIEWER_TYPES, 20: canonical_sha256, 21: file_sha256, 22: validate_adjudication, 23: validate_adjudication_fragment, 24: validate_against_schema, 25: verify_input_manifest, 26: ) 27: from institution_lab.governance_coding import ( 28: BODY_PATCH_RELATIONS, 29: CHANGE_STATUSES, 30: DIRECTIONS, 31: EVENT_KINDS, 32: RECORD_CLASSES, 33: RIGHT_KINDS, 34: ) 35: 36: ROOT = Path(__file__).parents[1] 37: MAX_TEST_ARCHIVE_MEMBERS = 256 38: 39: 40: def ...
{'id': 4611686018427387905, 'lc': 3, 'lp': 0, 'pb': 2, 'dict_size': 8388608}
Found 4 matches /home/byk/Code/institutional-transition-lab/tests/test_governance_adjudication.py: Line 729: def test_input_manifest_rejects_files_not_from_pinned_artifact( Line 883: def test_input_manifest_rejects_duplicate_artifact_members( Line 908: def test_input_manifest_rejects_excessive_artifact_member_count( Line 960: def test_committed_frozen_input_manifest_verifies() -> None:
<path>/home/byk/Code/institutional-transition-lab/tests/test_governance_adjudication.py</path>
<type>file</type>
<content>
680: assert summary["canonicalization_gate"] == "closed"
681:
682:
683: def test_input_manifest_rejects_changed_file_bytes(
684: tmp_path: Path,
685: monkeypatch: pytest.MonkeyPatch,
686: ) -> None:
687: artifact = tmp_path / "artifact.zip"
688: documents = tmp_path / "documents.json"
689: coding_package = tmp_path / "coding-package.json"
690: protocol = tmp_path / "protocol.md"
691: coding_schema = tmp_path / "coding-schema.json"
692: adjudication_schema = tmp_path / "adjudication-schema.json"
693: paths = {
694: "artifact": artifact,
695: "documents": documents,
696: "coding_package": coding_package,
697: "protocol": protocol,
698: "coding_schema": coding_schema,
699: "adjudication_schema": adjudication_schema,
700: }
701: for path in paths.values():
702: path.write_text(path.name)
703: with zipfile.ZipFile(artifact, "w") as ...
b'bounded member\nbounded m' 1920 33 1 False 0 0xb58c09bd b'zip-member-integrity\nzip' 2688 46 1 False 0 0xcf208d18 b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17' 2048 290 1 False 0 0x9f5edd58
<path>/home/byk/Code/institutional-transition-lab/src/institution_lab/governance_adjudication.py</path>
<type>file</type>
<content>
1: from __future__ import annotations
2:
3: import argparse
4: import hashlib
5: import io
6: import json
7: import os
8: import stat
9: import tempfile
10: import zipfile
11: from collections import Counter
12: from contextlib import suppress
13: from dataclasses import dataclass
14: from pathlib import Path
15: from typing import Any
16:
17: from jsonschema import Draft202012Validator, FormatChecker
18:
19: from institution_lab.governance_coding import validate_response
20:
21: DECISIONS = {"accept", "revise", "reject", "abstain"}
22: INSTITUTIONAL_CLASSES = {
23: "effective_institutional_change",
24: "announced_institutional_change",
25: "proposal_only",
26: }
27: REVIEWER_TYPES = {"human", "llm", "human_llm_assisted"}
28: REVIEWER_ROLES = {"source_adjudicator", "evidence_auditor", "synthesizer"}
29: RESPONSE_SOURCES = {"luna_a", "luna_b", ...
4bca2fcd4b494d51c84dcd4d4a2de24a1ae58e7247b9a3dc51ee2877944b7b2e00 33 32 1920 0xb58c09bd
Found 50 matches
/home/byk/Code/institutional-transition-lab/tests/test_governance_adjudication.py:
Line 8: import zipfile
Line 52: "artifact": tmp_path / "artifact.zip",
Line 65: with zipfile.ZipFile(paths["artifact"], "w") as archive:
Line 66: archive.writestr("documents.json", paths["documents"].read_bytes())
Line 67: archive.writestr(
Line 73: "artifact_id": 9642983578,
Line 74: "artifact_sha256": file_sha256(paths["artifact"]),
Line 94: "artifact",
Line 244: "artifact_id": 9642983578,
Line 245: "artifact_sha256": "0" * 64,
Line 288: "artifact_id": 9642983578,
Line 289: "artifact_sha256": "0" * 64,
Line 636: adjudication["inputs"]["artifact_sha256"] = "wrong"
Line 640: assert "input pin mismatch: artifact_sha256" in errors
Line 663: artifact=Path("unused"),
Line 672: @pytest.mark.parametrize("field", ["workflow_run_id", "artifact_id"])
Line 687: artifact = tmp_path / "artifact.zip"
Line 694: ...
<path>/home/byk/Code/institutional-transition-lab/tests/test_governance_adjudication.py</path> <type>file</type> <content> 1: from __future__ import annotations 2: 3: import copy 4: import json 5: import os 6: import subprocess 7: import sys 8: import zipfile 9: from pathlib import Path 10: 11: import pytest 12: 13: from institution_lab import governance_adjudication 14: from institution_lab.governance_adjudication import ( 15: DECISIONS, 16: FROZEN_INPUT_PINS, 17: REQUIRED_INPUT_PINS, 18: REVIEWER_ROLES, 19: REVIEWER_TYPES, 20: canonical_sha256, 21: file_sha256, 22: validate_adjudication, 23: validate_adjudication_fragment, 24: validate_against_schema, 25: verify_input_manifest, 26: ) 27: from institution_lab.governance_coding import ( 28: BODY_PATCH_RELATIONS, 29: CHANGE_STATUSES, 30: DIRECTIONS, 31: EVENT_KINDS, 32: RECORD_CLASSES, 33: RIGHT_KINDS, 34: ) 35: 36: ROOT = Path(__file__).parents[1] 37: MAX_TEST_ARCHIVE_MEMBERS = 256 38: 39: 40: def ...
<path>/home/byk/Code/institutional-transition-lab/tests/test_governance_adjudication.py</path>
<type>file</type>
<content>
640: assert "input pin mismatch: artifact_sha256" in errors
641: assert summary["canonicalization_gate"] == "closed"
642:
643:
644: def test_frozen_pins_include_the_versioned_adjudication_schema() -> None:
645: assert set(FROZEN_INPUT_PINS) == REQUIRED_INPUT_PINS
646: assert FROZEN_INPUT_PINS["adjudication_schema_sha256"] == (
647: "6181f5cb60a0462f83be00be301763daa89f11581e68ee1c46a84e8bf4e5be31"
648: )
649:
650:
651: @pytest.mark.parametrize("field", sorted(FROZEN_INPUT_PINS))
652: def test_input_manifest_rejects_self_consistent_substitute(field: str) -> None:
653: manifest = {
654: **FROZEN_INPUT_PINS,
655: "adjudication_schema_sha256": "5" * 64,
656: }
657: value = manifest[field]
658: manifest[field] = value + 1 if isinstance(value, int) else "f" * 64
659:
660: with pytest.raises(ValueError, match=f"frozen issue #4 input: {field}"):
661: ...
/usr/bin/bash: line 1: pytest: command not found
<path>/home/byk/Code/institutional-transition-lab/src/institution_lab/governance_adjudication.py</path>
<type>file</type>
<content>
1: from __future__ import annotations
2:
3: import argparse
4: import hashlib
5: import io
6: import json
7: import os
8: import stat
9: import tempfile
10: import zipfile
11: from collections import Counter
12: from contextlib import suppress
13: from dataclasses import dataclass
14: from pathlib import Path
15: from typing import Any
16:
17: from jsonschema import Draft202012Validator, FormatChecker
18:
19: from institution_lab.governance_coding import validate_response
20:
21: DECISIONS = {"accept", "revise", "reject", "abstain"}
22: INSTITUTIONAL_CLASSES = {
23: "effective_institutional_change",
24: "announced_institutional_change",
25: "proposal_only",
26: }
27: REVIEWER_TYPES = {"human", "llm", "human_llm_assisted"}
28: REVIEWER_ROLES = {"source_adjudicator", "evidence_auditor", "synthesizer"}
29: RESPONSE_SOURCES = {"luna_a", "luna_b", ...
zipfile_accepted=True decoded=1920 codec_eof=False crc_matches=True compressed=32/33
<path>/home/byk/Code/institutional-transition-lab/tests/test_governance_adjudication.py</path> <type>file</type> <content> 1: from __future__ import annotations 2: 3: import copy 4: import json 5: import os 6: import subprocess 7: import sys 8: import zipfile 9: from pathlib import Path 10: 11: import pytest 12: 13: from institution_lab import governance_adjudication 14: from institution_lab.governance_adjudication import ( 15: DECISIONS, 16: FROZEN_INPUT_PINS, 17: REQUIRED_INPUT_PINS, 18: REVIEWER_ROLES, 19: REVIEWER_TYPES, 20: canonical_sha256, 21: file_sha256, 22: validate_adjudication, 23: validate_adjudication_fragment, 24: validate_against_schema, 25: verify_input_manifest, 26: ) 27: from institution_lab.governance_coding import ( 28: BODY_PATCH_RELATIONS, 29: CHANGE_STATUSES, 30: DIRECTIONS, 31: EVENT_KINDS, 32: RECORD_CLASSES, 33: RIGHT_KINDS, 34: ) 35: 36: ROOT = Path(__file__).parents[1] 37: MAX_TEST_ARCHIVE_MEMBERS = 256 38: 39: 40: def ...
Your first result was empty. This is your one permitted retry. Read only src/institution_lab/governance_adjudication.py and tests/test_governance_adjudication.py; do not edit files. Scope ONLY bounded member decoding and integrity after a separate parser supplies trusted compressed-data slices and central metadata: safe handling of STORED, DEFLATE, BZIP2, and LZMA or a justified narrower allowlist; hard decoded-byte limits independent of declared sizes and ZipExtFile.read(n); compressed-stream EOF/trailing-byte validation; decoded-size and CRC verification; data-descriptor handling/boundaries for the current pinned archive; malformed/truncated streams whose decoded payload or CRC could otherwise match; normalized codec exceptions. Do NOT design EOCD, central-directory path/name, local-header, collision, or file-mode validation. Return concrete minimal helper signatures, codec APIs/state checks, validation order, limits, normalized errors, and deterministic fail-first test mutations. You MUST return either substantive evidence/guidance ending exactly SUBSTANTIVE, or an exact blocker with tool/error evidence ending exactly BLOCKED. Never return empty.
0 16 18 1 ab564ac94f2ecd4dcd2b2956b28a8ead0500 1 17 19 1 ab564ac94f2ecd4dcd2b2956b28a8ead550000 8 24 20 1 ab564ac94f2ecd4dcd2b2956b28a8ead55800200 64 80 21 1 ab564ac94f2ecd4dcd2b2956b28a8ead55a0100000 128 144 21 1 ab564ac94f2ecd4dcd2b2956b28a8ead5518600000 256 272 21 1 ab564ac94f2ecd4dcd2b2956b28a8ead5518e10000 1024 1040 26 1 ab564ac94f2ecd4dcd2b2956b28a8ead551805a360148c580000
<path>/home/byk/Code/institutional-transition-lab/src/institution_lab/governance_adjudication.py</path>
<type>file</type>
<content>
1: from __future__ import annotations
2:
3: import argparse
4: import hashlib
5: import io
6: import json
7: import os
8: import stat
9: import tempfile
10: import zipfile
11: from collections import Counter
12: from contextlib import suppress
13: from dataclasses import dataclass
14: from pathlib import Path
15: from typing import Any
16:
17: from jsonschema import Draft202012Validator, FormatChecker
18:
19: from institution_lab.governance_coding import validate_response
20:
21: DECISIONS = {"accept", "revise", "reject", "abstain"}
22: INSTITUTIONAL_CLASSES = {
23: "effective_institutional_change",
24: "announced_institutional_change",
25: "proposal_only",
26: }
27: REVIEWER_TYPES = {"human", "llm", "human_llm_assisted"}
28: REVIEWER_ROLES = {"source_adjudicator", "evidence_auditor", "synthesizer"}
29: RESPONSE_SOURCES = {"luna_a", "luna_b", ...
Date: Sep 9, 2026 * 🟡 (18:34) `/home/byk/Code/institutional-transition-lab/src/institution_lab/governance_adjudication.py` defines `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…
Date: Sep 9, 2026 * 🟡 (16:11) Test execution was blocked because `pytest` was unavailable: `/usr/bin/bash: line 1: pytest: command not found`. * 🟡 (16:17) `/home/byk/Code/institutional-transition-lab/src/institution_lab/governance_adjudication.py` defines archive limits: `MAX_INPUT_BYTES = 16 * 1024 * 1024`, `MAX_ARTIFACT_BYTES = 32 * 1024 * 1024`, `MAX_ARCHIVE_MEMBERS = 128`, `MAX_ARCHIVE_MEMB…
Date: Sep 9, 2026 * 🟡 (15:59) `test_frozen_pins_include_the_versioned_adjudication_schema()` in `/home/byk/Code/institutional-transition-lab/tests/test_governance_adjudication.py:644-648` asserts `set(FROZEN_INPUT_PINS) == REQUIRED_INPUT_PINS` and pins `adjudication_schema_sha256` to `6181f5cb60a0462f83be00be301763daa89f11581e68ee1c46a84e8bf4e5be31`. * 🟡 (15:59) `test_input_manifest_rejects_sel…
Date: Sep 9, 2026 * 🟡 (15:16) Python 3.12 ZIP reading logic inspected at `/usr/lib/python3.12/zipfile/__init__.py:1015-1112`: `ZipExtFile._update_crc()` computes CRC only when `_expected_crc` is set and raises `BadZipFile("Bad CRC-32 for file %r" % self.name)` only once `_eof` is true; `_read1()` truncates decompressed output to `self._left`, sets EOF when declared uncompressed bytes are exhaust…
Date: Sep 9, 2026 * 🟡 (15:08) A ZIP/compression probe produced three exact result rows: `1810 61 1810 True False 0xc27b61de`, `16 18 16 True False 0x22ccea73`, and `1825 75 1824 False False 0xd3f37109`. * 🟡 (15:09) Python 3.12 ZIP implementation inspected at `/usr/lib/python3.12/zipfile/__init__.py:671-719`: `LZMACompressor` lazily initializes a raw `lzma.LZMACompressor` using `lzma.FILTER_LZMA…
Date: Sep 9, 2026 * 🟡 (14:16) A raw byte/compression probe produced the exact result `b'abc' 3 9 True 0`. * 🟡 (14:31) ZIP corruption probe case 1 produced `1 44 43 1792 True False`; cases 2 through 9 each raised `BadZipFile: Bad CRC-32 for file 'x'`. * 🟡 (14:37) A ZIP/CRC probe produced exact values: payload length `1792`, CRC `0x4151b4ac`, and hex strings `4bca2fcd4b494dd1cdcc2b494d2fca2ca9d4…
* 🟡 (14:00) Raw decompression probes for payloads `b'\x07'`, `b'\x06'`, and `b'not-deflate'` each failed with `Error -3 while decompressing data: invalid block type`. * 🟡 (14:02) A new search found 29 artifact-related matches in `/home/byk/Code/institutional-transition-lab/src/institution_lab/governance_adjudication.py`, spanning `import zipfile`, `FROZEN_INPUT_PINS`, `_verify_input_payloads()`…
Date: Sep 9, 2026 * 🟡 (13:25) Compression-stream probes returned `deflate sync 6425 62 True False 0 0`; BZIP2 payload length was `97`, and full-stream cuts `1` through `10` each returned `False 0 True`; LZMA payload length was `67`, and full-stream cuts `1` through `6` each returned `False 0 True`. * 🟡 (13:26) Search found 39 ZIP/artifact-related matches in `/home/byk/Code/institutional-transit…
* 🟡 (13:23) Inspected ZIP write initialization in `_open_to_write(self, zinfo, force_zip64=False)`: rejects `force_zip64=True` when `_allowZip64` is false; rejects opening another write handle while `_writing` is true; resets `zinfo.compress_size` and `zinfo.CRC`; sets `zinfo.flag_bits`, including `_MASK_COMPRESS_OPTION_1` for `ZIP_LZMA` EOS markers and `_MASK_USE_DATA_DESCRIPTOR` for non-seekab…
Date: Sep 9, 2026 * 🟡 (13:08) Inspected Python 3.12’s standard-library ZIP implementation at `/usr/lib/python3.12/zipfile/__init__.py`: `LZMADecompressor` buffers the ZIP LZMA header and properties, then initializes `lzma.LZMADecompressor(lzma.FORMAT_RAW, filters=[lzma._decode_filter_properties(lzma.FILTER_LZMA1, ...)])`; `_get_decompressor(compress_type)` supports `ZIP_STORED`, `ZIP_DEFLATED`, …
Date: Sep 9, 2026 * 🟡 (13:07) User supplied the complete 1,024-line file `/home/byk/Code/institutional-transition-lab/tests/test_governance_adjudication.py`. * 🟡 (13:07) `tests/test_governance_adjudication.py` imports `zipfile`, sets `MAX_TEST_ARCHIVE_MEMBERS = 256`, and creates pinned test archives containing `documents.json` and `v1.2-adjudication-package.json`. * 🟡 (13:07) Existing ZIP-rela…
Date: Sep 9, 2026 * 🔴 [enforced-scope] (13:03) User stated this review replaces one twice-empty ZIP reviewer with a smaller, disjoint scope. * 🔴 [requested-review] (13:03) User requested a read-only review of exactly `src/institution_lab/governance_adjudication.py` and `tests/test_governance_adjudication.py`; no files may be edited. * 🟡 (13:03) User requested guidance limited to bounded ZIP-me…