ingest_semantic_assessments
ingest_semantic_assessments(
x,
assessments=None,
packet=None,
packet_id=None,
provider=None,
model=None,
search_fn=find_terms,
review_dir=None,
quiet=False,
)Ingest a harness’s semantic assessments.
The second half of the review-packet contract: reads the CSV a harness wrote against a packet from :func:~metasalmonpy.write_semantic_review_packet, in the frozen 30-column assessment row, and turns it into the package’s record. It refuses a selection whose IRI the packet did not offer (recorded as an error row, never applied), runs the retry bookkeeping, escalates a final reject_shortlist to request_new_term so the ontology gap is surfaced, runs the bundle validators, merges the result into the suggestions and persists it under review/, so that :func:~metasalmonpy.semantic_llm_assessments returns it for a package path.
A retry is a second harness pass. A retry_search with a usable query is retrieved here through search_fn, and when the search widens the shortlist a continuation packet (review/semantic-review-packet-pass-2.json) is written holding the widened shortlist; nothing from that target is merged or escalated until the harness has answered it. Calling this again after the harness answers the second packet completes the session. There is no third pass. A rejected shortlist earns no second pass: it escalates at once.
This never calls a model, and it reaches the network only through search_fn, for a retry. It never touches the metadata CSVs.
Harness text is redacted at capture: every harness-owned free-text value is redacted before it reaches the record, the harness’s file is never copied into review/, and a file the harness wrote at the packet’s default location is replaced with its redacted form after a successful ingest, with a warning.
A file-level problem aborts the ingest and writes nothing, raising :class:~metasalmonpy.SemanticReviewError with a stable code: packet_version, packet_integrity (the packet no longer matches its packet_id), packet_unbound (nothing names the packet the file was made against), packet_mismatch, header, unknown_target, duplicate_target, provenance and no_pass_2. A row-level problem makes that row an error row or downgrades it with a note, and processing continues.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| x | The package directory or the in-memory dictionary the packet was built from. | required | |
| assessments | The harness’s file: a CSV path or a data frame. Defaults to review/semantic-assessments-pass-<n>.csv for the packet’s pass. |
None |
|
| packet | The packet the file answers: a path or a parsed packet. Defaults to the latest pass in review/. |
None |
|
| packet_id | Optional[str] | The packet_id the assessments were made against. Required unless the harness wrote it in the <csv>.packet-id sidecar beside its CSV; a data frame carries no sidecar, so it needs this argument. A packet other than the one named is refused with code packet_mismatch. |
None |
| provider | Optional[str] | Optional overrides for the llm_provider and llm_model columns of every row. |
None |
| model | Optional[str] | Optional overrides for the llm_provider and llm_model columns of every row. |
None |
| search_fn | Callable | The search function used for a retry. Defaults to :func:~metasalmonpy.find_terms. |
find_terms |
| review_dir | Optional[Union[str, os.PathLike]] | Where the session lives. Defaults to review/ under the package directory; required for in-memory input. |
None |
| quiet | bool | Suppress the summary. | False |
Returns
| Name | Type | Description |
|---|---|---|
| dict | status ("complete" or "awaiting_pass_2"), pass, packet_id, next_packet (the continuation packet’s path, or None), assessments (the record, carrying the validator findings column by column in attrs["semantic_validator_findings"], as semantic_review_ingest.findings_attr() builds them, so that two records concatenate), findings (the same findings as a frame), suggestions, targets, dictionary (with semantic_suggestions, semantic_targets and semantic_llm_assessments in attrs, so :func:~metasalmonpy.detect_semantic_term_gaps and the accessors work unchanged) and summary (counts of decisions, errors, downgrades, escalations and retries). |