Skip to content

fix(domain): typed fail-closed analysis scope on Finding (#5531) - #9941

Merged
EffortlessSteven merged 4 commits into
mainfrom
claude/typed-analysis-scope
Oct 23, 2026
Merged

EffortlessSteven merged 4 commits into
mainfrom
claude/typed-analysis-scope

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Replace the free-text analysis_scope: repo evidence marker as the scope authority with a typed, required Finding.analysis_scope (Diff | Repo), so a repo-mode producer cannot omit its scope and consumers fail closed.

Swarm / Source Boundary

  • ordinary feature, analyzer, editor, docs, spec, fixture, badge, dependency, or repo-ops development for ripr-swarm

Source-of-Truth Links

Proposal: n/a
Spec: n/a (capability registry, #5531)
ADR: n/a
Plan item: #5531
Governing issue or accepted claim: #5531 (typed, fail-closed analysis scope replacing the evidence-line marker for repo-mode TS/JS #9896 and Python #9923)
Acceptance delta (one sentence): A repo-mode finding's scope is a typed domain field set by construction (not an optional evidence string), and the TypeScript gap-record and Python repair-card consumers read it and fail closed when scope is repo or contradictory.

Candidate Relationships

Candidate branch: claude/typed-analysis-scope
Stack parent or prerequisite PR (if any): none
Proposed replacement of PR (if any; not yet accepted): none
Acceptance retained from a replaced candidate (if any): n/a
Accepted winner and losing candidate disposition (when decided): n/a

Scope

  • Domain: AnalysisScope enum, required Finding.analysis_scope, Finding::mark_repo_scoped, Finding::analysis_mode.
  • Producers: typescript/repo.rs and python/repo/evidence.rs call mark_repo_scoped.
  • Consumers: typescript_gap_record_for, python_repair_card read analysis_mode().
  • Mechanical: analysis_scope: Diff added at the 51 existing Finding literals.

Scope Classification

  • One architectural seam

Production delta:

  • Typed scope owned by the domain; the compatibility evidence line analysis_scope: repo (disclosed in docs/LANGUAGE_ADAPTER_PREVIEW.md) is now derived from it in one place and kept in findings[].evidence.
  • Finding::analysis_mode() returns None (no card/packet) when typed scope is Diff but the legacy line says repo.
  • Serde: default + skip_serializing_if = diff, so serialized diff Findings are byte-identical. No JSON schema field added. The typed field is not in the hand-rendered check report JSON; scope round-trips through that report via the evidence line, and a contradiction fails closed (documented in docs/LANGUAGE_ADAPTER_PREVIEW.md).
  • Deliberate source-level break: Finding is public and the new field is required, so external ripr::Finding { .. } struct literals stop compiling until they add analysis_scope. That is the price of having no silent Diff default; it is what makes an unscoped repo finding impossible to construct. (AnalysisScope is re-exported at the crate root; policy/public_api.txt is updated.)

Evidence/support delta:

  • Negative tests: typed Repo without the line projects no TS record or Python card; legacy line on typed Diff fails closed; mark_repo_scoped idempotent; serialization omits/roundtrips scope.
  • Producer-level tests in the real TS and Python repo runs: every repo-mode finding has analysis_scope == Repo, and the diff-mode control has Diff (producer_sets_typed_analysis_scope_*).

Single acceptance criterion:

  • A repo-scoped finding never projects a repair card/packet, and an unscoped repo finding cannot be constructed.

Non-goals:

  • No change to capability cells, JSON schema, or rendered output; no xtask changes.

Support-tier Impact

  • none

Claim/proof notes:

  • Design rejected alternatives: a Finding builder (about 90 literals, larger churn); keeping the string as authority with a stricter parser (still string-typed and fail-open on omission).

Policy Impact

  • none (policy/public_api.txt gains the two AnalysisScope lines)

Proof

cargo fmt --check
cargo clippy -p ripr --all-targets -- -D warnings   # also --features lang-typescript, lang-python
cargo xtask check-public-api
cargo xtask check-output-contracts
cargo xtask goldens prepare && cargo xtask goldens check
cargo test -j2 -p ripr --features lang-typescript,lang-python --lib -- failclosed analysis_scope typed_scope repo_scoped

Result, failures, or skipped proof:

  • fmt, clippy (default, +lang-typescript, +lang-python; latest head with both features), check-public-api, check-output-contracts, goldens check: pass. Focused tests: 17 passed at the latest head.
  • Rendered output vs origin/main for a Python fixture (diff and repo, json and human): byte-identical (see PR comment). TypeScript not rendered separately.
  • cargo xtask precommit: exit 1 only on the covered_by instrument timeout (SIGKILL after 300s under cargo lock contention); no source/policy gate failed. Hosted CI covers the remainder.

Claim Boundary

May claim: scope is typed and consumers fail closed. Must not claim: any change to repo-mode repair support (still not_proven) or to public output.

Rollback

Revert the squash commit; no schema or persisted-format change.

Spec-Test-Code Traceability

Static Language Check

  • Static output avoids killed, survived, untested, proven, and adequate.
  • Unknowns include stop reasons where applicable.

CI Economics

n/a

Engineering Check

  • No new panic, unwrap, expect, todo, or unimplemented in production code.
  • No new panic, unwrap, expect, todo, or unimplemented in tests.
  • Public JSON/schema changes are documented (none).

🤖 Generated with Claude Code

https://claude.ai/code/session_01EsjwSbvSPQdZfNsK689oNn

Replace the free-text `analysis_scope: repo` evidence marker as the scope
authority with a typed `Finding.analysis_scope` (Diff|Repo). Every Finding
construction must state its scope; repo producers set it through
`Finding::mark_repo_scoped`, which also derives the disclosed compatibility
evidence line in one place. Consumers (TypeScript gap record, Python repair
card) read `Finding::analysis_mode`, which fails closed when the typed scope
and the legacy evidence line disagree.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EsjwSbvSPQdZfNsK689oNn
@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 27 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 126 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: cd744099-a46c-420d-8b79-ccb3106d7488
📥 Commits

Reviewing files that changed from the base of the PR and between b777448 and 9c6e132.

📒 Files selected for processing: 55
  • crates/ripr/src/analysis/classifier/finding.rs
  • crates/ripr/src/analysis/classify/gap_admission.rs
  • crates/ripr/src/analysis/diagnostic_origin.rs
  • crates/ripr/src/analysis/language/perl/mod.rs
  • crates/ripr/src/analysis/language/python/classify.rs
  • crates/ripr/src/analysis/language/python/repo/evidence.rs
  • crates/ripr/src/analysis/language/rust/lexical_test_grip.rs
  • crates/ripr/src/analysis/language/rust/mod.rs
  • crates/ripr/src/analysis/language/rust/oracles.rs
  • crates/ripr/src/analysis/language/rust/probes.rs
  • crates/ripr/src/analysis/language/typescript/bun_bridge.rs
  • crates/ripr/src/analysis/language/typescript/classifier.rs
  • crates/ripr/src/analysis/language/typescript/parse.rs
  • crates/ripr/src/analysis/language/typescript/repo.rs
  • crates/ripr/src/analysis/sort.rs
  • crates/ripr/src/analysis/summary.rs
  • crates/ripr/src/analysis/witness/tests.rs
  • crates/ripr/src/app/check_artifact.rs
  • crates/ripr/src/app/repair_card_handoff.rs
  • crates/ripr/src/app/selector.rs
  • crates/ripr/src/app/tests/mod.rs
  • crates/ripr/src/app/tests/python_repo_mode_repair_failclosed.rs
  • crates/ripr/src/app/tests/typescript_repo_mode_repair_failclosed.rs
  • crates/ripr/src/domain/context_packet.rs
  • crates/ripr/src/domain/diagnostic_witness.rs
  • crates/ripr/src/domain/finding_test_evidence.rs
  • crates/ripr/src/domain/mod.rs
  • crates/ripr/src/domain/probe.rs
  • crates/ripr/src/lib.rs
  • crates/ripr/src/lsp/diagnostics.rs
  • crates/ripr/src/lsp/lens.rs
  • crates/ripr/src/lsp/tests.rs
  • crates/ripr/src/mcp/gaps.rs
  • crates/ripr/src/output/badge/tests.rs
  • crates/ripr/src/output/diff_report.rs
  • crates/ripr/src/output/github.rs
  • crates/ripr/src/output/human.rs
  • crates/ripr/src/output/human/triage.rs
  • crates/ripr/src/output/json/context_packet.rs
  • crates/ripr/src/output/json/finding_alignment.rs
  • crates/ripr/src/output/json/mod.rs
  • crates/ripr/src/output/json/report.rs
  • crates/ripr/src/output/next_step.rs
  • crates/ripr/src/output/perl_gap_record_projection.rs
  • crates/ripr/src/output/perl_preview_card.rs
  • crates/ripr/src/output/pilot/types.rs
  • crates/ripr/src/output/preview_actionability.rs
  • crates/ripr/src/output/python_repair_card.rs
  • crates/ripr/src/output/render.rs
  • crates/ripr/src/output/sarif.rs
  • crates/ripr/src/output/typescript_packet_projection.rs
  • crates/ripr/src/output/typescript_preview_card.rs
  • crates/ripr/tests/context_packet_totals.rs
  • docs/LANGUAGE_ADAPTER_PREVIEW.md
  • policy/public_api.txt
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces an explicit AnalysisScope enum to track whether a Finding was produced under Diff or Repo mode, replacing the legacy approach of relying solely on free-text evidence lines. It updates Finding constructions across tests and adapters, implements safe resolution logic (analysis_mode) that fails closed on contradictions, and ensures backward-compatible serialization. The review feedback suggests importing REPO_SCOPE_EVIDENCE_LINE locally within mark_repo_scoped to clean up fully-qualified paths, and recommends using the REPO_SCOPE_EVIDENCE_LINE constant instead of hardcoded string literals in the newly added tests in typescript_packet_projection.rs and human.rs.

Comment thread crates/ripr/src/domain/probe.rs Resolved
Comment thread crates/ripr/src/output/human.rs Resolved
… and tests (#5531)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EsjwSbvSPQdZfNsK689oNn

Copy link
Copy Markdown
Member Author

Head 58120f8. Results:

  • cargo xtask goldens prepare then goldens check: both exit 0 (the earlier failure was the offline fixture-dependency environment error).
  • Rendered output, branch vs origin/main (f0e0ea0): built a Python fixture and rendered diff-mode and repo-mode in both json and human formats with a temporary test (not committed). All four outputs are byte-identical after normalizing the temp root path, and the repo-mode JSON contains the same 3 analysis_scope: repo evidence lines on both sides. TypeScript was not rendered separately; it shares the same mark_repo_scoped path and the same untouched renderers.
  • precommit: exit 1 only on the covered_by instrument timeout, as reported.

Generated by Claude Code

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Decision

  • Needs reviewer attention before upstream: findings remain.

Confirmed findings

  • Typed scope is centralized in Finding and derived repo evidence is idempotent, preventing producer-local duplicate scope logic.
  • Both repair-card consumers use analysis_mode rather than independently interpreting the compatibility evidence marker.

Verification questions

  • Confirm rust compilation and feature-gated consumer tests are the remaining proof dependency because the ripr sensor failed with exit code 2.
  • Confirm a complete sibling inventory of capability-table consumers is not present in the supplied packet, so absence of additional bypasses outside the named pair is not independently established.

Refuted

  • This source-UB packet indicates a newly introduced unsafe memory-lifetime issue.; refuted because: The patch changes typed metadata and capability gating; unsafe-review found no new or worsened gaps, and the inspected changed paths contain no new unsafe pointer or thread-lifetime contract.
  • The typed-scope refactor exposes an ArrayBuffer/TypedArray resize, detach, transfer, or stale-length safety issue.; refuted because: The changed logic copies ProbeId, pushes owned strings, matches an enum, and scans immutable evidence. None of these operations reallocates, moves, detaches, transfers, or resizes an active-view backing store.
  • Repo-mode scope marking could race with asynchronous mutation of Finding evidence and create duplicate compatibility lines.; refuted because: No changed route exposes concurrent or async access; mark_repo_scoped performs a synchronous mutation, and its single-threaded call path cannot interleave with another invocation.
  • The typed scope addition could expose an unsafe or information-disclosure primitive.; refuted because: No unsafe/native operation or sensitive-data sink is introduced. The enum owns control-flow metadata, and unsafe-review reports zero new or worsened gaps.
  • The PR changes public output by serializing the new enum for ordinary diff findings.; refuted because: AnalysisScope defaults to Diff and serde skip_serializing_if omits Diff; the new serialization test asserts omission and repo round-trip, consistent with the seeded byte-identical golden/render evidence.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.
  • Execution evidence for the targeted tests is scheduled but not yet present in the supplied receipts.

…ort JSON (#5531)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EsjwSbvSPQdZfNsK689oNn
@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 23, 2026 10:11
@EffortlessSteven
EffortlessSteven merged commit 3768d84 into main Oct 23, 2026
50 checks passed
@EffortlessSteven
EffortlessSteven deleted the claude/typed-analysis-scope branch October 23, 2026 11:14
EffortlessSteven pushed a commit that referenced this pull request Oct 23, 2026
…ne added in #9941

The fact-index projection digests hash the findings' Debug rendering. #9941
added Finding.analysis_scope, which changed all three digests on main. Every
Perl finding is diff-scoped, so dropping that one line renders the exact field
set the pre-index implementation produced; the original #8896 digests match
again, so the byte-level equivalence claim is kept rather than re-pinned.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ko9uTzfEN9vJcshsDpo2NB
EffortlessSteven added a commit that referenced this pull request Oct 23, 2026
…cope line (#10007)

The fact-index projection digests hash the findings' Debug rendering. #9941
added Finding.analysis_scope, which changed all three digests on main. Every
Perl finding is diff-scoped, so dropping that one line renders the exact field
set the pre-index implementation produced; the original #8896 digests match
again, so the byte-level equivalence claim is kept rather than re-pinned.


Claude-Session: https://claude.ai/code/session_01Ko9uTzfEN9vJcshsDpo2NB

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants