Follow-up: calibration GitHub reader needs UTF-8 and surrogate gates - #700
Draft
justin808 wants to merge 4 commits into
Draft
Follow-up: calibration GitHub reader needs UTF-8 and surrogate gates#700justin808 wants to merge 4 commits into
justin808 wants to merge 4 commits into
Conversation
The UTF-8 gate added earlier on this branch checked only the raw response bytes. A byte-valid JSON response can still decode to an invalid Ruby string: `"\udcff"` is well-formed JSON, passes `valid_encoding?` on the wire, and `JSON.parse` turns it into a UTF-8 string holding an unpaired surrogate. That string then flowed past both readers. `AutonomousMergeEvidence.gh_api` returned it, and `CurrentIntegrationEvidence.github_snapshot` accepted it in a field it does not inspect, so an invalid candidate OID reached `candidate_from_snapshot`, where `String#match?` raised an uncaught `ArgumentError: invalid byte sequence in UTF-8`. The eligibility CLI rescues only `CurrentIntegrationEvidence::Error` and `KeyError`, so the structured `UNKNOWN` that issue #351 requires was not guaranteed. Validate the decoded graph recursively over every key and value immediately after `JSON.parse`, and map failure to each library's own evidence error so the CLI's existing rescue paths produce `UNKNOWN`. Checking after parse rather than at each use keeps the guard at the trust boundary, so no later reader has to re-prove encoding. Regressions cover both libraries directly and both CLI paths end to end. Without the guard the CLI test reproduces the raw `ArgumentError` escaping from `candidate_from_snapshot`. Scope stays narrow. `autonomous_merge_calibration.rb` parses GitHub JSON through a separate offline calibration path that never had the raw-bytes gate either; it is outside this branch's decision path and is left for a follow-up. Refs #351 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E9JmkTGMTLBJUXUzLr2MM3
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Member
Author
Shared Validate dependency — exact head
|
7 tasks
This was referenced Sep 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #698
Head:
jg-codex/issue-698-calibration-utf8@7256e09d8d9afc189b9c385a1d372ba244aef6c2Base:
jg-codex/issue-351-utf8-gate@ac4841b2234e88947b8fc8a7cb796c4fb51e26faChanges:
JSON.parse.CollectionError(kind: "api").Evidence:
ruby skills/pr-batch/bin/autonomous-merge-calibrate-test.rb -n '/test_github_client_rejects/'ruby skills/pr-batch/bin/autonomous-merge-evidence-test.rb -n '/test_gh_api_(rejects_invalid_utf8_as_a_collection_error|rejects_lone_surrogates_decoded_from_json)/'ruby skills/pr-batch/bin/current-integration-evidence-test.rb -n '/test_github_snapshot_(rejects_invalid_utf8_as_an_evidence_error|rejects_lone_surrogate_decoded_from_candidate_oid)/'ruby -c skills/pr-batch/lib/autonomous_merge_calibration.rbruby -c skills/pr-batch/lib/autonomous_merge_evidence.rbruby -c skills/pr-batch/lib/current_integration_evidence.rbruby -c skills/pr-batch/lib/github_json_string_validation.rbruby -c skills/pr-batch/bin/autonomous-merge-calibrate-test.rbgit diff --check