Dashboard › institutional-transition-lab › Distillation
6b5ff0b3-aedf-43df-b209-e0c21ce14bff["lore_tm_v1_bVZSqKrwU4QhQo4tfg2-MrfPtND2-zRxt_6kTuq7-zk"]
/home/byk/Code/institutional-transition-lab/src/institution_lab/governance_coding.py lines 220–225 show the coding-bundle output includes design_status="performance_blinded_model_informed_development", transition_dates_excluded=True, outcome_data_used=False, model_input_fields=MODEL_INPUT_FIELDS, and documents=output.parse_response() in /home/byk/Code/institutional-transition-lab/src/institution_lab/governance_coding.py strips surrounding whitespace, optionally removes an outer triple-backtick code fence, rejects fenced content with fewer than 3 lines or without a closing exact ``` line as unterminated JSON code fence, parses with json.loads(), and raises ValueError("response must be an object") unless the parsed value is a dictionary.validate_response() requires the response key set to equal RESPONSE_KEYS; requires record_class in RECORD_CLASSES; permits null event_kind but otherwise requires membership in EVENT_KINDS; and permits null title, affected_scope, and ambiguity but otherwise requires each to satisfy _nonempty().validate_response() requires announced_on and effective_on to pass _valid_date() as ISO dates or null, requires body_patch_relation in BODY_PATCH_RELATIONS, and requires confidence to be a finite non-boolean int | float between 0 and 1 inclusive.validate_response() builds source_map from each dictionary in document["sources"], mapping source_id to text.validate_response() requires power_changes to be an array; a non-array value produces power_changes must be an array and is subsequently treated as an empty list for further validation.power_changes[index] entry must be a dictionary whose key set exactly equals POWER_KEYS; actor, target, and scope must be non-empty; right_kind must be in RIGHT_KINDS; direction must be in DIRECTIONS; and change_status must be in CHANGE_STATUSES.evidence_refs value must be a non-empty list. Each reference must be a dictionary whose key set exactly equals REF_KEYS, name a source_id present in source_map, and contain a non-empty quote that is an exact substring of the corresponding source text.validate_response() treats effective_institutional_change, announced_institutional_change, and proposal_only as institutional classes. These classes require at least one power_changes entry, while non-institutional classes must contain no power changes.validate_response() requires a response with record_class == "abstain" to have a non-null ambiguity._validate_run() in governance_coding.py requires bundle["documents"] to be a non-empty list, indexes documents by stringified record_id, and raises ValueError("coding bundle requires documents") otherwise._validate_run() requires each raw response to be a dictionary with a non-empty record_id, rejects duplicate IDs with ValueError(f"{run_id} duplicates {record_id}"), and requires the set of raw-response IDs to exactly equal the set of coding-document IDs._validate_run() checks that the raw response’s coding_id equals bundle["coding_id"], coding_schema_sha256 equals bundle["coding_schema_sha256"], run_id equals the expected run_id, source_url equals the document’s source_url, and model_input_fields exactly equals MODEL_INPUT_FIELDS._validate_run() requires the raw response’s model and reasoning_effort to equal the supplied model and reasoning_effort arguments, and requires elapsed_ms to be a non-boolean integer greater than or equal to 0._validate_run() parses raw["response_text"] through parse_response(); it catches ValueError and json.JSONDecodeError, stores response=None, and appends invalid JSON: {error} on failure. Successfully parsed responses are additionally checked by validate_response(response, document)._validate_run() returns a result per record_id containing exactly the constructed fields response, schema_valid, validation_errors, model, reasoning_effort, and elapsed_ms; schema_valid is True only when the accumulated error list is empty._edge_signature() returns () for a missing or falsey response. Otherwise, for each power_changes edge it strips and records, in order, actor, right_kind, target, direction, change_status, and scope, then appends a compact JSON serialization of the edge’s normalized evidence references._edge_signature() normalizes each dictionary-valued evidence reference to a stripped (source_id, quote) pair, sorts those pairs, serializes them using json.dumps(..., ensure_ascii=False, separators=(",", ":")), sorts the resulting edge tuples, and returns them as a tuple; this makes edge comparison insensitive to power-change ordering and evidence-reference ordering while retaining exact normalized field and quote content.