Repository navigation
Conversation
There was a problem hiding this comment.
This review found 1 issue(s), including 1 blocking issue(s).
| or not isinstance(replacement.get("observed_at"), str) | ||
| or not replacement["observed_at"].strip() |
There was a problem hiding this comment.
A nonempty value such as "unknown" passes this check and authorizes replacement coverage despite not recording an observation timestamp. Unlike qualify_page, this path never parses the value, so the generated inventory can mark the task draft_annotated_replacement with invalid observation evidence. Parse observed_at as an ISO-8601 datetime and require timezone information before accepting the receipt; add regression cases for malformed and timezone-less timestamps.
There was a problem hiding this comment.
Fixed in 36fbabf. Replacement receipts now parse observed_at with datetime.fromisoformat and require timezone information. Regression coverage rejects both unknown and a timezone-less ISO timestamp. Local query tests pass (443) and the complete PR CI is green.
There was a problem hiding this comment.
This review found 1 issue(s), including 1 blocking issue(s).
| for row in receipt["cases"]: | ||
| replacement = row.get("proposed_replacement") | ||
| if replacement is None: | ||
| continue | ||
| observed_at = replacement.get("observed_at") |
There was a problem hiding this comment.
Validate object types before calling .get(). read_json() only parses JSON, so a receipt containing "cases": [null] or "proposed_replacement": [] raises AttributeError here instead of the intended validation ValueError; the later isinstance(replacement, dict) check cannot handle these inputs. Check each row and each non-null replacement before accessing their fields, and add malformed-object tests to preserve the validation exception contract.
There was a problem hiding this comment.
This review found 1 issue(s), including 1 blocking issue(s).
| replacement_matches = replacement is not None and ( | ||
| replacement["replacement_id"] == page["id"] | ||
| and replacement["replacement_url"] == page["url"] | ||
| ) |
There was a problem hiding this comment.
Replacement coverage is accepted solely on page ID and URL; the receipt's content hash is only checked for hexadecimal syntax. Consequently, a receipt with source_sha256 different from page["source"]["sha256"] still marks the task as draft_annotated_replacement. query_contract.validate_dataset() does not verify this association either. Compare the supplied source/capture hash with the corresponding authored-page evidence before counting replacement coverage, and add a regression test using a well-formed but mismatched hash.
There was a problem hiding this comment.
This review found 1 issue(s), including 1 blocking issue(s).
| source.get("sha256"), str | ||
| ): | ||
| raise ValueError("Replacement page requires source evidence") | ||
| capture_hashes = [source["sha256"], source.get("rendered_sha256")] |
There was a problem hiding this comment.
An explicitly null capture_sha256 is accepted when source_sha256 is valid and the authored source omits rendered_sha256 (as the article fixture does). The initial any(...) succeeds on the source hash, while capture_hashes contains None, so the capture comparison also passes and writes draft_annotated_replacement. Validate every supplied hash as a 64-character hexadecimal string, while requiring at least one hash, and exclude missing hashes from the evidence candidates. Add a regression asserting that a valid source hash plus a null capture hash raises ValueError before output is written.
There was a problem hiding this comment.
This review found 1 issue(s), including 1 blocking issue(s).
| replacement = row.get("proposed_replacement") | ||
| if replacement is None: | ||
| continue |
There was a problem hiding this comment.
Rows without a replacement bypass source-ID validation. For example, appending {"source_task_id": []} or {"source_task_id": "unknown", "proposed_replacement": null} to an otherwise valid receipt still allows output to be written, contrary to the requirement that malformed source IDs fail with ValueError. Validate each row's source_task_id type and membership in the locked population before this early continue, and add tests for absent/null replacements with invalid IDs.
There was a problem hiding this comment.
✅ Re-review complete · a58f41e
No findings in this incremental review.
Bind replacement-source coverage to the locked original task URL, exact task-population hash, replacement page identity, timezone-aware observation time and authored evidence. The existing
source-inventorycommand accepts the optional receipt; original URLs remain explicit when a historical catalog uses a replacement URL.Malformed JSON roots, case rows, replacement objects, schema labels and source IDs fail with
ValueErrorbefore output is written. Source hashes must match the authored source; capture hashes must match its bound source, rendered document or navigation capture. A syntactically valid but unrelated hash cannot authorize coverage. This new optional receipt boundary rejects historical capture-only records that lack a matching authored evidence binding; the historical dataset files remain unchanged.Validation: the full query suite passed (443 tests). All Python CI shards, static checks, packaging checks and automated review pass on the final head. Ruff and
git diff --checkpassed. Paired tests accept matched source/capture hashes and reject well-formed mismatches, alongside invalid timestamps, forged URLs and malformed receipt variants, including invalid source IDs on rows without replacements. Both Python and CLI entry points retain their valid-receipt coverage.This PR changes source-inventory validation only; it does not change extraction scoring or activate a dataset selection. The 811-question live proposal uses original URLs and does not need replacement receipts.