Skip to content

Add verified-backport evidence contract - #694

Draft
justin808 wants to merge 6 commits into
mainfrom
jg-codex/issue-204-verified-backport-core
Draft

justin808 wants to merge 6 commits into
mainfrom
jg-codex/issue-204-verified-backport-core

Conversation

@justin808

@justin808 justin808 commented Sep 2, 2026

Copy link
Copy Markdown
Member

Problem

Backports currently have no durable contract for distinguishing mechanically patch-equivalent evidence reuse from semantic adaptation. That makes safe reuse difficult and risks turning an optimization into an implicit waiver.

Contract

  • Adds strict verified-backport-v1 JSON Schema evidence for source repo/PR/head/merge identity, trusted merged status, source review and CI evidence, target branch/base/head identity, mechanical patch relation, target-only delta rationale, reused evidence, consumer-owned target requirements, review-generated changes, and forward-port dispositions.
  • Adds a side-effect-free Ruby classifier and a thin stdin/file CLI.
  • Only matching git patch-id --stable identities bound to the recorded source head and target base/head can classify as exact.
  • The result always carries the explicit consumer target requirements and target_gates_waived: false.

Fail-closed behavior

Missing or malformed fields, schema extensions, stale source/patch evidence, contradictory patch or target-policy claims, incomplete reuse, untrusted/failed evidence, conflicted or semantic relations, target-only deltas, review-generated behavior changes, and UNKNOWN values route to ordinary-full. Full handling emits no reused evidence. Behavior-changing review fixes additionally require a terminal durable HTTPS forward-port disposition.

Focused verification

  • JSON_SCHEMER_VERSION=$(tr -d '[:space:]' < .json-schemer-version) ruby skills/pr-batch/bin/verified-backport-classify-test.rb
    • 11 runs, 115 assertions, 0 failures, 0 errors
  • Focused Ruby syntax checks: pass
  • Focused RuboCop for the classifier/library/test: 3 files inspected, no offenses
  • The focused test is registered in bin/validate; broad local validation was intentionally not launched per issue-owner instructions.

Replay evidence

The fixtures bind real React on Rails PR/head/base/patch identities:

  • #4677 / source #4656: identical stable patch IDs, validation-focused exact lane enters the fast path.
  • #4676 / source #4654: semantic adaptation plus the review-found post-pull downgrade defect remains ordinary/full.
  • #4684 / source #4661: semantic adaptation plus review-found GitHub response-framing and legacy-status defects remains ordinary/full.

Risks

  • This PR defines evidence and classification only; it does not yet collect live GitHub/git evidence or wire routing into pr-batch.
  • Stable patch ID is intentionally the sole accepted exact mechanism in v1. Other equivalence mechanisms must be added explicitly with tests rather than inferred.
  • Historical semantic replay dispositions point to durable review threads; workflow wiring must enforce the consumer's chosen forward-port lifecycle before closeout.

Follow-ups after this contract stabilizes

  1. Add verified_backport lane delivery mode and receipt-path handoff to skills/pr-batch/SKILL.md and workflows/pr-processing.md.
  2. Resolve the helper portably, collect the schema receipt before routing, persist the classifier result, and route only classification: exact to evidence reuse.
  3. Map the consumer seam into target_requirements; keep branch protection, unresolved-thread rules, and target current-head CI/review as independent mandatory gates.
  4. Before requesting hosted work, query current target-head runs and reuse only equivalent active/green target coverage; never use source evidence as target-head completion.
  5. On any review-generated behavior change, update the receipt, exit the fast path, run focused target validation/review, and require a durable forward-port disposition.
  6. Teach completed-batch audit to replay per-PR receipts while still running cross-PR interaction, combined-tip, missing-forward-port, and consumer-required aggregate checks.
  7. Add wiring contract/replay tests alongside those shared-surface edits once overlapping PRs have cleared.

Refs #204

Summary by CodeRabbit

  • New Features

    • Added verified backport evidence classification for determining whether patches are exact matches or require ordinary-full handling.
    • Added validation of source trust, reviews, checks, target requirements, patch relationships, adaptations, and forward-port dispositions.
    • Added a command-line interface that accepts JSON evidence and returns a classification result.
  • Documentation

    • Added a formal schema describing supported verified backport evidence and validation rules.
  • Tests

    • Added comprehensive coverage for valid, invalid, incomplete, contradictory, and malformed evidence scenarios.

@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 5ee91b45-3f37-4130-a245-386787dbd931

📥 Commits

Reviewing files that changed from the base of the PR and between db989c3 and f8ac848.

📒 Files selected for processing (8)
  • bin/validate
  • docs/schemas/verified-backport-v1.json
  • skills/pr-batch/bin/verified-backport-classify
  • skills/pr-batch/bin/verified-backport-classify-test.rb
  • skills/pr-batch/fixtures/verified-backport/react-on-rails-4676-semantic-review-fix.json
  • skills/pr-batch/fixtures/verified-backport/react-on-rails-4677-exact-validation-focused.json
  • skills/pr-batch/fixtures/verified-backport/react-on-rails-4684-semantic-review-fixes.json
  • skills/pr-batch/lib/verified_backport.rb

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Important

Approval pending

CodeRabbit has no unresolved comments, but it has not reviewed the latest commit.

Use the checkbox below to review the latest commit. CodeRabbit will approve the changes if it finds no blocking issues.

  • 🔍 Trigger review

Walkthrough

The change adds a versioned verified-backport evidence schema, a Ruby classifier and CLI, representative fixtures, extensive fail-closed tests, and validation-script integration.

Changes

Verified backport classification

Layer / File(s) Summary
Evidence schema
docs/schemas/verified-backport-v1.json
Defines strict structures for source evidence, target requirements, patch relations, target-only deltas, reused evidence, review-generated changes, and forward-port dispositions.
Classification engine
skills/pr-batch/lib/verified_backport.rb
Validates evidence, checks source and target conditions, identifies exact patch matches, detects behavior changes, and returns classification details.
CLI and evidence fixtures
skills/pr-batch/bin/verified-backport-classify, skills/pr-batch/fixtures/verified-backport/*
Adds JSON input handling and records exact and semantic-adaptation replay cases.
Classifier validation
skills/pr-batch/bin/verified-backport-classify-test.rb, bin/validate
Tests schema conformance, exact classification, invalid evidence, policy contradictions, unknown values, forward-port completeness, malformed JSON, and CLI usage errors. Runs the test with the pinned JSON Schemer version.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: 🔵 Low · up to f8ac8

The PR adds a fail-closed backport classifier but does not yet connect it to merge or review enforcement. It can still label caller-supplied evidence as exact without independently verifying its provenance, so future consumers must authenticate and recompute the underlying source, review, CI, and patch claims before reusing evidence; the PR is otherwise mergeable with this owner follow-up.

Sequence Diagram(s)

sequenceDiagram
  participant Input as JSON input
  participant CLI as verified-backport-classify
  participant Classifier as VerifiedBackport.classify
  Input->>CLI: JSON from stdin or input file
  CLI->>Classifier: parsed evidence
  Classifier->>Classifier: validate schema and classification rules
  Classifier-->>CLI: classification result
  CLI-->>Input: JSON output
Loading
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the problem, contract, fail-closed behavior, verification, risks, and follow-ups. However, it does not use the required Why, What changed, How to review and verify, and Test p… Restructure the description using the required headings. Add completed Test plan entries with the exact commands and observed results, or remove non-applicable checkbox items. Include the Agent details disclosure and its applicable subsecti…
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 42 functions across 2 files. (6 skipped: 6… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding the verified-backport evidence contract.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the problem, contract, fail-closed behavior, verification, risks, and follow-ups. However, it does not use the required Why, What changed, How to review and verify, and Test plan sections. It also omits the required test-plan checklist results.

Resolution

Restructure the description using the required headings. Add completed Test plan entries with the exact commands and observed results, or remove non-applicable checkbox items. Include the Agent details disclosure and its applicable subsections.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 42 functions across 2 files. (6 skipped: 6 unsupported.)

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jg-codex/issue-204-verified-backport-core

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 coordination claim; reconciled from private backend label Sep 2, 2026
@justin808

Copy link
Copy Markdown
Member Author

Independent exact-head review — BLOCKING

Reviewer lane: codex-m5-pr694-backport-review (9b5810f3-fd4e-4afa-b403-943432feb8f3)

  • Exact head: 21d52a3
  • Current main: db989c3; it is the head commit's direct parent, git diff --check is clean, and GitHub reports the PR mergeable.
  • Focused verification: classifier/schema suite passed twice at different seeds (11 runs, 115 assertions each); Ruby syntax and focused 3-file RuboCop passed; 25/25 CLI runs were byte-identical. Independently recomputed stable patch IDs match the three receipts: #4656/#4677 are equal; #4654/#4676 and #4661/#4684 differ.
  • Hosted state at this head: Lint and Claude review are green. Validate's only failure is the shared Deduplicate batch-title contracts and restore prompt headroom #662 prompt-headroom defect (299 bytes vs the 300-byte floor), not a PR-specific failure.
  • Review threads: 0 unresolved.

Blocking findings:

  1. VerifiedBackport.contract_shape? checks keys but does not enforce the JSON Schema's value constraints. A bounded mutation changing the source review URL from HTTPS to HTTP produced a JSON Schema pattern error, yet the runtime returned classification: exact, fast_path: true, and no reasons. The runtime boundary must enforce the schema (or equivalently validate every constraint) before exact classification, with a regression test.
  2. Schema-valid evidence is still too weak to earn the fast path. A receipt containing one self-attested “accepted” review and one arbitrary passed selector check classified exact. The shipped #4677 exact fixture demonstrates the gap: its only reused check is job 86998660379, detect-changes from Assets Precompile Check, while the substantive green required-pr-gate and Pro/package jobs at the same source head are omitted. Bind reusable source evidence to an explicit source policy/required-coverage set and make completeness testable.
  3. The #4684 fixture's response-framing change/disposition uses discussion-r3590737543. That URL is a reply resolving an unrelated partial-pagination finding as “no code change is needed”; the actual live response-framing probe and fix are in discussion-r3590737544. As written, the replay reports forward_port_complete: true without linking the claimed change.
  4. forward_port_complete? accepts ambiguous identities: two distinct behavior changes can share one id and one disposition, and one change can have conflicting tracked/not-applicable dispositions; both schema-valid probes reported complete. Require unique change IDs and exactly one non-conflicting terminal disposition per behavior change.

Verdict: BLOCKING. Next writer action: close these four contract/fixture gaps with focused regression tests, then request a new exact-head review. After #662 lands, update from main and rerun hosted Validate.

Comment thread skills/pr-batch/bin/verified-backport-classify Outdated
Comment thread skills/pr-batch/lib/verified_backport.rb
@claude

claude Bot commented Sep 2, 2026

Copy link
Copy Markdown

Code review (correctness / quality / performance)

Reviewed the new evidence contract (schema, classifier, CLI, tests, fixtures). This is a self-contained addition not yet wired into any caller, so no cross-file breakage was found, and the fail-closed classification logic itself (patch-identity, staleness, independence, forward-port checks) traced correctly against its 115-assertion test suite.

Two minor findings posted inline:

  • skills/pr-batch/bin/verified-backport-classify: missing else on the arg-count check makes a caller usage bug (2+ args) indistinguishable from genuinely malformed evidence.
  • skills/pr-batch/lib/verified_backport.rb: contract_shape? (full JSON-Schema validation) runs 2-3x per classify call with no memoization — worth avoiding before this is invoked in a batch loop.

No security or correctness issues found in the classifier logic itself. Note there's already a more substantive blocking review on this PR (semantic gaps in schema enforcement and evidence completeness) — the two items above are independent, lower-severity code-quality/perf notes on top of that.

@justin808 justin808 added agent-claimed Active agent coordination claim; reconciled from private backend and removed agent-claimed Active agent coordination claim; reconciled from private backend labels Sep 2, 2026
@justin808

Copy link
Copy Markdown
Member Author

Address-review status for PR #694 at exact head f8ac8485.

Scan scope: current head after the pushed fix. The bounded wait for the new review wave timed out after 180s with claude-review and validate still IN_PROGRESS; Lint and CodeRabbit passed. This is a non-cutoff status, so the next pass must use check all reviews.

Detailed review outcomes

Mattered

  • None.

Optional

  • skills/pr-batch/bin/verified-backport-classify:8 - add a distinct usage error for 2+ positional args (@claude[bot]) - fixed inline in f8ac8485.
  • skills/pr-batch/lib/verified_backport.rb:53 - avoid redundant full schema validation per classify call (@claude[bot]) - declined; not worth the extra caching plumbing for this small helper.

Skipped

  • Review summary from @justin808 at 2026-09-02T12:23:41Z - stale exact-head blocking review from 21d52a31; the current head already carries the schema/fixture coverage and the findings are not current.
  • Issue comment from @coderabbitai at 2026-09-02T10:00:07Z - draft-PR boilerplate with no actionable review.
  • Review summary from @claude[bot] at 2026-09-02T13:12:25Z - informational summary; the actionable points were the two inline comments, which are now resolved.

Validation

  • ruby skills/pr-batch/bin/verified-backport-classify-test.rb
  • ruby -c skills/pr-batch/bin/verified-backport-classify
  • ruby -c skills/pr-batch/bin/verified-backport-classify-test.rb
  • ruby -c skills/pr-batch/lib/verified_backport.rb
  • rubocop skills/pr-batch/bin/verified-backport-classify skills/pr-batch/bin/verified-backport-classify-test.rb skills/pr-batch/lib/verified_backport.rb
  • git diff --check

Non-cutoff status only. The next review pass must use check all reviews.

@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

@justin808 Acknowledged. The next review pass will check all reviews before it determines the result.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Comment thread skills/pr-batch/bin/verified-backport-classify Outdated
Comment thread skills/pr-batch/lib/verified_backport.rb
Comment thread skills/pr-batch/lib/verified_backport.rb
Comment thread skills/pr-batch/lib/verified_backport.rb
@claude

claude Bot commented Sep 2, 2026

Copy link
Copy Markdown

Review summary

Reviewed for code quality, bugs, security, and performance. Posted 4 inline findings:

  1. Error masking in verified-backport-classify — file I/O errors (missing/unreadable file) are caught by the same rescue as malformed JSON, silently reported as a valid classification with exit 0.
  2. Duplicated contract logiccontract_shape? hand-duplicates the JSON Schema's required/additionalProperties:false constraints, creating two sources of truth that can drift.
  3. Reimplemented helperexact_keys? duplicates logic already present (with slightly different semantics) in merge-assurance and autonomous-merge-closeout.
  4. Redundant validationforward_port_complete? (and the underlying schema validation) can run 2-3x per single classify() call on identical data.

No blocking security issues found. Nothing structural stood out beyond the above — mostly maintainability/DRY concerns worth addressing before this logic gets reused more widely per the stated follow-up plan.

@justin808 justin808 added agent-claimed Active agent coordination claim; reconciled from private backend and removed agent-claimed Active agent coordination claim; reconciled from private backend labels Sep 2, 2026
@justin808

Copy link
Copy Markdown
Member Author

PR #694 review checkpoint at 84cf4c1c81f73bb5a3bf3cf23ef58d23055aae30.

Scan scope: default cutoff (no prior summary checkpoint); no check all reviews override.
Status: cutoff-safe. All four current Claude threads were handled and resolved.

Audit

Mattered

  • 3917890053 fixed in 84cf4c1c: verified-backport-classify now exits 66 with a clear stderr message when stdin/file input cannot be read; malformed JSON still returns the existing invalid-contract classification. Added a regression test for the missing-file path.

Skipped

  • 3917891154 declined: docs/schemas/verified-backport-v1.json is the canonical shape contract; the local contract_shape? check is a small fail-closed cross-check, not a second source of truth.
  • 3917892011 declined: keeping the local exact_keys? helper avoids cross-file scope; extracting a shared helper would broaden the change beyond this PR.
  • 3917892910 declined: the extra forward_port_complete? schema pass is a minor cost on a standalone classifier and not material enough to justify threading cached state through the call chain.

External/shared blockers

  • No local code blockers remain. GitHub still shows the PR as draft with mergeable_state: unstable, so hosted review/CI churn may continue to settle on the new head.

Future full-PR scans should start after this comment unless you say check all reviews.

@justin808 justin808 added agent-claimed Active agent coordination claim; reconciled from private backend and removed agent-claimed Active agent coordination claim; reconciled from private backend labels Sep 2, 2026
* origin/main:
  Deduplicate batch-title contracts and restore prompt headroom (#662)
@justin808 justin808 removed the agent-claimed Active agent coordination claim; reconciled from private backend label Sep 2, 2026
@justin808

justin808 commented Sep 2, 2026

Copy link
Copy Markdown
Member Author

Reconciled exact current main f15211f985e30a85fd846c8ebc37c94bc22b90b7 into 0b7362629ccd91264b3af2f3305ed10bfdfa71b7. Local focused checks passed: ruby skills/pr-batch/bin/verified-backport-classify-test.rb, git diff --check, dry-run skills/pr-batch/bin/stale-assignment-sweep --repo shakacode/agent-workflows, and bin/lint. Review threads remain resolved; hosted checks relaunched on the new head.

Comment thread skills/pr-batch/lib/verified_backport.rb
Comment thread skills/pr-batch/bin/verified-backport-classify
Comment thread skills/pr-batch/lib/verified_backport.rb
Comment thread skills/pr-batch/lib/verified_backport.rb
Comment thread skills/pr-batch/lib/verified_backport.rb
@claude

claude Bot commented Sep 2, 2026

Copy link
Copy Markdown

Code Review Summary

Reviewed the new "verified backport" evidence classifier: the JSON Schema (docs/schemas/verified-backport-v1.json), the Ruby library (skills/pr-batch/lib/verified_backport.rb), the CLI wrapper (skills/pr-batch/bin/verified-backport-classify), its test suite, fixtures, and the bin/validate wiring.

Overall this is a well-tested, fail-closed contract with a solid Ruby test suite (11 runs, 115 assertions per the PR description) and a schema that mirrors the design intent closely. Left 5 inline comments:

  1. Bug (correctness): contradictory-target-policy (verified_backport.rb:202) fires for merely-unknown CI policy (current_head_ci == "UNKNOWN"), not just genuinely self-contradictory policy — conflating two distinct failure modes under one reason code.
  2. Likely dead code (correctness): the rescue EncodingError around File.read(path, encoding: "UTF-8") in verified-backport-classify (lines 17-22, and similarly for stdin) is probably unreachable — a single encoding: option only tags the string, it doesn't validate/transcode, so invalid-UTF-8 input silently falls through to the generic JSON::ParserError path (exit 0, generic result) instead of the intended distinct "unable to read input file" message + exit 66.
  3. Duplication/maintainability: contract_shape?'s hand-rolled OBJECT_KEYS/exact_keys? machinery (~30 lines) re-implements key-set validation the JSON Schema (required + additionalProperties: false at every level) already fully performs — two sources of truth that must be kept in sync by hand.
  4. Minor/efficiency: contract_shape? (full schema validation) runs up to 3x per classify call due to nested calls through forward_port_complete?.
  5. Nit: PATCH_ID regex is a byte-for-byte duplicate of SHA — could just alias to avoid drift.

No security concerns identified — this is a pure classifier operating on JSON evidence with no external I/O, network calls, or shell execution beyond reading the input file/stdin.

@justin808 justin808 added the agent-claimed Active agent coordination claim; reconciled from private backend label Sep 2, 2026
@justin808

Copy link
Copy Markdown
Member Author

PR #694 checkpoint at 243053408a99a8c97dc826c837beb5de28a43d35.

Scan scope: default cutoff after the prior checkpoint at 2026-09-02T19:54:32Z.

Review audit
  • Mattered
    • https://github.com/shakacode/agent-workflows/pull/694#discussion_r3918878455: fixed. contradictory-target-policy now only applies when current_head_ci is known, so schema-allowed UNKNOWN stays in target-policy-missing.
    • https://github.com/shakacode/agent-workflows/pull/694#discussion_r3918879502: fixed. Invalid UTF-8 now fails at read time with EncodingError and exit 66 instead of falling through to JSON parsing.
  • Optional
    • https://github.com/shakacode/agent-workflows/pull/694#discussion_r3918880285: declined. The manual key check remains deliberate fail-closed validation.
    • https://github.com/shakacode/agent-workflows/pull/694#discussion_r3918880981: declined. The repeated schema validation is an efficiency-only refactor.
    • https://github.com/shakacode/agent-workflows/pull/694#discussion_r3918881553: declined. PATCH_ID intentionally mirrors the SHA shape today.
  • Validation
    • ruby -c skills/pr-batch/bin/verified-backport-classify
    • ruby -c skills/pr-batch/lib/verified_backport.rb
    • ruby -c skills/pr-batch/bin/verified-backport-classify-test.rb
    • ruby skills/pr-batch/bin/verified-backport-classify-test.rb
    • git diff --check
    • bin/lint
  • Capacity scan
    • Direct scan of justin-2021-mbp-m1-max.local showed the heaviest load was user-owned rspack; root-owned processes were routine system daemons.
  • Thread state
    • All 5 unresolved current-head review threads were replied to and resolved.

Future default scans should start after this comment unless you say check all reviews.

@justin808 justin808 removed the agent-claimed Active agent coordination claim; reconciled from private backend label Sep 2, 2026
Comment on lines +102 to +125
def test_self_attested_review_and_arbitrary_selector_cannot_earn_the_fast_path
evidence = fixture("react-on-rails-4677-exact-validation-focused")
source_head = evidence.dig("source", "head_sha")
evidence["source_evidence"] = {
"reviews" => [{
"id" => "self-attested-review",
"head_sha" => source_head,
"status" => "accepted",
"url" => "https://github.com/shakacode/react_on_rails/pull/4656"
}],
"checks" => [{
"id" => "arbitrary-selector",
"name" => "detect-changes",
"head_sha" => source_head,
"status" => "passed",
"url" => "https://github.com/shakacode/react_on_rails/actions/runs/29305769015/job/86998660379"
}]
}
evidence["reused_evidence"] = [
{ "kind" => "review", "source_id" => "self-attested-review", "head_sha" => source_head },
{ "kind" => "check", "source_id" => "arbitrary-selector", "head_sha" => source_head }
]

result = classify(evidence)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test doesn't exercise the scenario it claims to test.

test_self_attested_review_and_arbitrary_selector_cannot_earn_the_fast_path replaces source_evidence with a hash that omits the required required_coverage key (line 105-119), and the new review object omits the required actor field. Both are required by the JSON schema (docs/schemas/verified-backport-v1.json) and by OBJECT_KEYS["source_evidence"]/OBJECT_KEYS["review_evidence"] in verified_backport.rb.

As a result, contract_shape? fails on this evidence for an unrelated reason (invalid-contract — missing keys), before the code ever reaches the "self-attested review" / "arbitrary selector" resolution logic in reuse_reasons/source_reasons that this test is named for and presumably meant to guard.

Concretely: if reuse_reasons's resolution check (source_ids.fetch(item["kind"], []).include?(item["source_id"])) or the reviewer-independence check ever regressed to accept a self-attested review or an arbitrary/unlisted check id as valid "reused evidence", this test would still pass (green) because it fails earlier on the missing required_coverage/actor keys — masking the regression.

Suggested fix: keep required_coverage (with review_ids/check_ids pointing at the fabricated ids) and the actor field intact in the replacement source_evidence, so the test actually exercises resolution/independence logic rather than short-circuiting on invalid-contract.

},
"durableUrlOrUnknown": {
"oneOf": [
{"type": "string", "pattern": "^https://[^\\s]+$"},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unanchored regex pattern lets multi-line strings pass URL validation.

"pattern": "^https://[^\\s]+$" uses ^/$, which in Ruby (the engine json_schemer compiles this against) match line boundaries, not string boundaries — unlike \A/\z. A value such as "https://example.com\nanything-at-all" will validate successfully against this pattern in Ruby, even though it's clearly not a single clean durable URL.

This matters here because, unlike the SHA fields (which are all re-validated with a properly-anchored \A...\z regex in verified_backport.rb's valid_sha?, or compared via == to an already-validated value), reviewEvidence.url and checkEvidence.url are never re-checked anywhere in verified_backport.rb — only forwardPortDisposition.url gets the stricter durable_url? check (\Ahttps://[^\s]+\z). So a source_evidence.reviews[].url / checks[].url value with injected trailing content after a newline would pass schema validation with no secondary guard.

Same issue applies to the sha pattern on line 58/67 and repository pattern on line 98, though those are all independently re-validated with anchored Ruby regexes (valid_sha?, valid_source?) elsewhere, so they don't have the same exposure.

Suggested fix: anchor with \\A/\\z (or \\A...\\z equivalents that Ruby's regex engine treats as true string boundaries) in the schema pattern, e.g. "^https://[^\\s]+$""\\Ahttps://[^\\s]+\\z".

@justin808 justin808 added complexity:complexify Adds enduring logic, modes, contracts or operational obligations; value is judged separately. P3 Parked: low-priority optional work; requires explicit reprioritization before implementation. triage:park Defer during backlog reduction; requires fresh evidence or explicit reprioritization. labels Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

complexity:complexify Adds enduring logic, modes, contracts or operational obligations; value is judged separately. P3 Parked: low-priority optional work; requires explicit reprioritization before implementation. triage:park Defer during backlog reduction; requires fresh evidence or explicit reprioritization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant