Skip to content

Follow-up: calibration GitHub reader needs UTF-8 and surrogate gates - #700

Draft
justin808 wants to merge 4 commits into
mainfrom
jg-codex/issue-698-calibration-utf8
Draft

Follow-up: calibration GitHub reader needs UTF-8 and surrogate gates#700
justin808 wants to merge 4 commits into
mainfrom
jg-codex/issue-698-calibration-utf8

Conversation

@justin808

Copy link
Copy Markdown
Member

Fixes #698

Head: jg-codex/issue-698-calibration-utf8 @ 7256e09d8d9afc189b9c385a1d372ba244aef6c2
Base: jg-codex/issue-351-utf8-gate @ ac4841b2234e88947b8fc8a7cb796c4fb51e26fa

Changes:

  • Add a shared JSON-string validator for the calibration/evidence readers.
  • Gate calibration GitHub API responses on raw UTF-8 before JSON.parse.
  • Reject lone surrogates in decoded JSON keys and values as CollectionError(kind: "api").
  • Cover the raw-byte and surrogate failures with focused calibration regressions.

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.rb
  • ruby -c skills/pr-batch/lib/autonomous_merge_evidence.rb
  • ruby -c skills/pr-batch/lib/current_integration_evidence.rb
  • ruby -c skills/pr-batch/lib/github_json_string_validation.rb
  • ruby -c skills/pr-batch/bin/autonomous-merge-calibrate-test.rb
  • git diff --check

justin808 and others added 3 commits September 1, 2026 22:38
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
@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@justin808 justin808 added the agent-claimed Active agent-coord claim; visible hint, not lock label Sep 2, 2026
@justin808 justin808 removed the agent-claimed Active agent-coord claim; visible hint, not lock label Sep 2, 2026
@justin808

Copy link
Copy Markdown
Member Author

Shared Validate dependency — exact head acdea70f059fc5b6a4b16c489b885683d977ad00

Hosted Lint, Claude review, and CodeRabbit are green. Validate job 100404501232 failed only at the inherited installed-prompt guard (299 characters of headroom versus required 300) after the installer coverage progressed. This is the shared baseline defect owned by PR #662, not a PR #700 branch defect.

Disposition: do not retry or change PR #700 for this failure. Replay Validate after #662 lands.

@justin808 justin808 mentioned this pull request Sep 3, 2026
7 tasks
Base automatically changed from jg-codex/issue-351-utf8-gate to main September 6, 2026 22:17
@justin808 justin808 added complexity:simplify Removes code, duplicated rules, states or maintenance obligations. Not a merge-readiness verdict. P1 High priority: verified material impact; schedule ahead of speculative improvements triage:drain-first Resolve the existing PR or concrete blocker before starting more work. Not merge approval. labels Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

complexity:simplify Removes code, duplicated rules, states or maintenance obligations. Not a merge-readiness verdict. P1 High priority: verified material impact; schedule ahead of speculative improvements triage:drain-first Resolve the existing PR or concrete blocker before starting more work. Not merge approval.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Follow-up: calibration GitHub reader lacks the UTF-8 and decoded-surrogate gates added in #682

1 participant