Skip to content

fix(review): support focused large frozen scopes - #258

Merged
Alan-TheGentleman merged 5 commits into
mainfrom
fix/review-focused-large-scopes
Jul 31, 2026
Merged

fix(review): support focused large frozen scopes#258
Alan-TheGentleman merged 5 commits into
mainfrom
fix/review-focused-large-scopes

Conversation

@Alan-TheGentleman

@Alan-TheGentleman Alan-TheGentleman commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Closes #242

Summary

  • Adds strict ordinary START focus forwarding for risk, resilience, readability, and reliability while preserving the native default when omitted.
  • Keeps readable changed scopes inline and transports larger scopes as canonical gzip/base64url manifests with SHA-256 integrity.
  • Adds the bounded read-only gentle_review_scope actor tool so every compact path, mode, deletion, and gitlink is consumable without shell access or ambient/full-tree fallback.
  • Resolves and verifies the frozen candidate before FINALIZE status, evidence capture, and mutation; STATUS and FINALIZE use the candidate root rather than the contributor worktree.
  • Reconciles current main and PR fix(review): harden blocking failure paths #257 through normal merge history without rewriting the existing PR branch.

Changes

Area Change
extensions/gentle-ai.ts Registers the bounded scope reader and routes FINALIZE status/mutation through verified candidate roots.
lib/review-candidate-view.ts Adds bounded canonical manifest decompression and deterministic changed-scope pagination.
assets/agents/review-*.md Allows only the new read-only scope tool in addition to existing candidate readers.
tests/review-*.test.ts Proves actor recovery, fail-closed bounds, no full-tree fallback, candidate-root FINALIZE, and workspace isolation.
tests/runtime-harness.mjs Verifies the scope tool is registered by the shipped runtime.
README.md Documents the compact actor channel and its trust boundary.

Test Plan

  • Focused candidate/controller/actor/workspace suites: 248 passed.
  • Full pnpm test under an isolated home: 997 passed, 1 platform skip; runtime harness passed.
  • node scripts/verify-package-files.mjs: 129 package resources passed, including 64 exact v2.2.2 artifacts.
  • git diff --check.
  • Normal-home full run reproduced only the three known pinned-native parity failures caused by the existing global RDD-off setting; the setting was not changed.

Review Notes

  • Compact transport remains deterministic and canonical; encoded transport is capped at 4 KiB, decompressed manifests at 1 MiB, and actor pages at 16 KiB/128 entries.
  • Deleted paths, modes, gitlinks, Unicode paths, immutable candidate binding, and drift diagnostics remain fail closed.
  • Rollback boundary: the new scope tool/allowlist/pagination and candidate-root FINALIZE routing can be reverted together without removing PR fix(review): harden blocking failure paths #257 hardening or the original focus/compact-manifest implementation.

Summary by CodeRabbit

  • New Features

    • Added optional review focus selection for risk, resilience, readability, and reliability.
    • Large review contexts can now be delivered in a compact, paginated format instead of being rejected.
    • Review context preserves Unicode content, file changes, deletions, and linked-repository details.
    • Added a bounded, read-only tool for inspecting changed review scope.
  • Bug Fixes

    • Invalid focus values and unsupported fields are now rejected with clearer validation.
    • Input and policy validation now occurs before review-mode and availability checks.
    • Added integrity and consistency checks for compact review context data.
    • Improved candidate validation and cleanup during finalization.
  • Documentation

    • Updated review guidance for compact context delivery and safe scope inspection.

@Alan-TheGentleman Alan-TheGentleman added the type:bug Bug fix label Jul 31, 2026
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6e44a9c8-dea8-44a2-bbae-04a90dc04a50

📥 Commits

Reviewing files that changed from the base of the PR and between d3cb269 and 1d5fe4e.

📒 Files selected for processing (1)
  • lib/review-candidate-view.ts

📝 Walkthrough

Walkthrough

The change adds native START focus forwarding, canonical compressed manifests for oversized frozen scopes, a bounded scope-reading tool, and candidate-root validation during native FINALIZE.

Changes

Native review routing and candidate context

Layer / File(s) Summary
Canonical compressed candidate manifests
lib/review-candidate-view.ts, tests/review-candidate-view.test.ts
Candidate context uses canonical, integrity-checked gzip/base64url manifests with pagination. Tests cover ordering, UTF-8 data, deletions, gitlinks, transport metadata, and incompressible scopes.
Native START focus validation and routing
extensions/gentle-ai.ts, tests/review-controller-native-routing.test.ts
Ordinary START validates four supported focus values before mode and native availability checks. Valid values are forwarded to native START. Invalid and unknown fields are rejected.
Candidate-root FINALIZE validation
extensions/gentle-ai.ts, tests/review-controller-native-routing.test.ts, tests/review-controller-workspace-root.test.ts
Native FINALIZE reconstructs candidate views before status resolution, validates projection bindings, performs candidate-root status and evidence operations, and cleans up provisional views.
Bounded scope reader and agent integration
extensions/gentle-ai.ts, assets/agents/*, tests/review-actor-tool-deny.test.ts, tests/runtime-harness.mjs, README.md
The read-only gentle_review_scope tool validates and serves paginated frozen scope pages. Review lenses, runtime registration, and dispatch documentation include the tool. Dispatch tests cover readable and compact scope delivery.

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

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant gentle_review
  participant CandidateContext
  participant ReviewActor
  participant gentle_review_scope
  participant NativeReview

  Caller->>gentle_review: START with optional focus
  gentle_review->>gentle_review: validate focus and request fields
  gentle_review->>CandidateContext: build readable or compact frozen scope
  CandidateContext-->>gentle_review: context and manifest digest
  gentle_review->>ReviewActor: dispatch review with validated focus
  ReviewActor->>gentle_review_scope: request manifest page
  gentle_review_scope-->>ReviewActor: validated frozen scope page
  Caller->>gentle_review: FINALIZE with candidate binding
  gentle_review->>NativeReview: resolve status and mutate from candidate root
  NativeReview-->>gentle_review: FINALIZE result
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies support for focused reviews with large frozen scopes, matching the primary changes.
Linked Issues check ✅ Passed The changes implement focus forwarding, bounded manifest transport, pagination, integrity checks, and candidate-root validation required by issue #242.
Out of Scope Changes check ✅ Passed The implementation, tests, agent configuration, runtime checks, and documentation directly support the linked issue objectives.
✨ 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 fix/review-focused-large-scopes

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/review-candidate-view.ts`:
- Around line 1005-1093: Add a concise comment near canonicalStringMap or
hasCanonicalRecordOrder documenting that plain-object enumeration forces
integer-like keys into numeric order, which the canonical round-trip validation
relies on for numeric-looking paths. Do not alter the existing canonicalization
or validation behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9784b9b6-cd04-4b13-be54-ec90b4f54c39

📥 Commits

Reviewing files that changed from the base of the PR and between 4cf8070 and 5b43577.

📒 Files selected for processing (4)
  • extensions/gentle-ai.ts
  • lib/review-candidate-view.ts
  • tests/review-candidate-view.test.ts
  • tests/review-controller-native-routing.test.ts

Comment thread lib/review-candidate-view.ts

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
lib/review-candidate-view.ts (1)

1235-1296: 🚀 Performance & Scalability | 🔵 Trivial | 🏗️ Heavy lift

Repeated full manifest decode on every paginated read.

export function readCandidateContextManifestPage(encoded: string, sha256: string, cursor = 0): CandidateContextPage {
if (!Number.isSafeInteger(cursor) || cursor < 0) throw new CandidateViewError("candidate context manifest cursor is invalid", "candidate-context-cursor-invalid");
const decoded = decodeCandidateContextManifest(encoded, sha256); Each call to readCandidateContextManifestPage re-runs decodeCandidateContextManifest, which base64url-decodes, gunzipSyncs, hashes, checks UTF-8 round-trip, re-gzipSyncs the bytes for the canonical-transport check, JSON.parses, and re-validates the whole manifest structure. It also rebuilds the full entries array from scopeByMode regardless of cursor.

An agent enumerating a large manifest calls this once per page (bounded to 128 entries each). Every call repeats this full decode-and-recompress cost against the same input, so total work scales with pages × manifest size instead of page size. The gzipSync recompression is the most expensive part of this and is pure overhead on repeat calls with an already-verified manifest.

Consider caching the decoded, validated manifest (and its entries array) keyed by sha256 for the duration of a pagination sequence, so only the first page pays the full decode cost and subsequent pages slice from the cached result.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/review-candidate-view.ts` around lines 1235 - 1296, Update
readCandidateContextManifestPage and the surrounding manifest-pagination flow to
reuse a decoded, validated manifest and its flattened entries across pages keyed
by sha256, instead of calling decodeCandidateContextManifest and rebuilding
entries on every request. Ensure the cache is bounded or scoped to the
pagination sequence, preserves existing validation and cursor behavior, and
avoids returning cached data for a different encoded manifest sharing the key.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/review-controller-workspace-root.test.ts`:
- Around line 205-214: The candidateFinalizeTargetStatus function must build the
finalize fixture from the candidate associated with lineageId rather than
creating a new CandidateViewRegistry entry from request.cwd. Resolve the
candidate through the existing lineage-aware finalize lookup, such as
candidateViews.resolveForFinalize(lineageId), and fail closed when no projection
is available; preserve the targetStatusFixture inputs for a successfully
resolved candidate.

---

Outside diff comments:
In `@lib/review-candidate-view.ts`:
- Around line 1235-1296: Update readCandidateContextManifestPage and the
surrounding manifest-pagination flow to reuse a decoded, validated manifest and
its flattened entries across pages keyed by sha256, instead of calling
decodeCandidateContextManifest and rebuilding entries on every request. Ensure
the cache is bounded or scoped to the pagination sequence, preserves existing
validation and cursor behavior, and avoids returning cached data for a different
encoded manifest sharing the key.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e94ca2d5-cecf-4266-824b-52226b1f99dd

📥 Commits

Reviewing files that changed from the base of the PR and between 5b43577 and d3cb269.

📒 Files selected for processing (12)
  • README.md
  • assets/agents/review-readability.md
  • assets/agents/review-reliability.md
  • assets/agents/review-resilience.md
  • assets/agents/review-risk.md
  • extensions/gentle-ai.ts
  • lib/review-candidate-view.ts
  • tests/review-actor-tool-deny.test.ts
  • tests/review-candidate-view.test.ts
  • tests/review-controller-native-routing.test.ts
  • tests/review-controller-workspace-root.test.ts
  • tests/runtime-harness.mjs

Comment thread tests/review-controller-workspace-root.test.ts
@Alan-TheGentleman
Alan-TheGentleman merged commit 3d4a362 into main Jul 31, 2026
2 checks passed
@Alan-TheGentleman
Alan-TheGentleman deleted the fix/review-focused-large-scopes branch July 31, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(review): support focused reviews with large frozen scopes

1 participant