Skip to content

feat: implement issue #1090 — [Phase 2] Feed semantic symbol context (callers/callees/type-defs) into the deep + duck tiers - #1226

Merged
don-petry merged 8 commits into
mainfrom
dev-lead/issue-1090-20260714-0624
Jul 14, 2026
Merged

don-petry merged 8 commits into
mainfrom
dev-lead/issue-1090-20260714-0624

Conversation

@don-petry

@don-petry don-petry commented Jul 14, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #1090

Implemented by dev-lead agent. Please review.

Summary by CodeRabbit

  • New Features
    • Added optional symbol-context analysis to deep and “rubber duck” code reviews.
    • Reviews can now cross-check touched functions for related callers, definitions, and type or return-shape issues.
    • Added configurable context limits and graceful fallback when symbol searches are unavailable.
  • Bug Fixes
    • Review processing continues successfully when no functions are detected or context searches fail.
  • Tests
    • Added coverage for symbol detection, context assembly, truncation, logging, and failure handling.

…(callers/callees/type-defs) into the deep + duck tiers
@don-petry
don-petry requested a review from a team as a code owner July 14, 2026 06:52
Copilot AI review requested due to automatic review settings July 14, 2026 06:52
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@don-petry, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 58 minutes

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).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 864031f4-cc1f-4157-93e4-c8eac9a00d71

📥 Commits

Reviewing files that changed from the base of the PR and between 0060b21 and dcee6a2.

📒 Files selected for processing (3)
  • scripts/lib/symbol-context.sh
  • scripts/review-one-pr.sh
  • tests/dev-lead/unit/test_symbol_context_assemble.bats
📝 Walkthrough

Walkthrough

Adds an opt-in symbol-context pipeline that extracts touched functions, gathers GitHub code-search references, exports bounded context for deep and rubber-duck reviews, and includes comprehensive Bats coverage.

Changes

Symbol Context Review

Layer / File(s) Summary
Review prompt context contract
prompts/deep-review.md, prompts/rubber-duck.md
Prompts document and conditionally read $SYMBOL_CONTEXT_FILE for cross-file caller, callee, type, and return-shape validation.
Symbol extraction and context assembly
scripts/lib/symbol-context.sh
Extracts touched symbols, searches GitHub code, formats capped reference contexts, logs counts, and continues gracefully on search failures.
Review preprocessing integration
scripts/review-one-pr.sh
Sources the helper and runs symbol-context assembly only when SYMBOL_CONTEXT_ENABLED=true and GITHUB_REPOSITORY is available.
Symbol context behavior coverage
tests/dev-lead/unit/test_symbol_context_assemble.bats, tests/dev-lead/unit/test_symbol_context_map.bats
Tests language-specific extraction, hunk headers, uniqueness, output export, minimum contexts, failures, empty diffs, logging, and truncation.

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

Sequence Diagram(s)

sequenceDiagram
  participant ReviewScript
  participant SymbolContext
  participant GitHubCodeSearch
  participant ReviewPrompts
  ReviewScript->>SymbolContext: assemble PR diff context
  SymbolContext->>GitHubCodeSearch: search touched symbols
  GitHubCodeSearch-->>SymbolContext: reference snippets
  SymbolContext-->>ReviewScript: export SYMBOL_CONTEXT_FILE
  ReviewScript->>ReviewPrompts: provide optional context file
  ReviewPrompts-->>ReviewScript: cross-file review findings
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ❓ Inconclusive The implementation matches the feature scope, but the holdout eval score and 1.5x cost-cap requirement are not evidenced in the provided context. Run the deep-review holdout evaluation and compare it to the Phase-1 frozen baseline, including median ET/escalated-review cost, then report the results.
✅ 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 names the Phase 2 symbol-context injection into deep and duck tiers, matching the PR's main change.
Out of Scope Changes check ✅ Passed All changes support symbol-context extraction, prompt wiring, and test coverage; no clearly unrelated edits are evident.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev-lead/issue-1090-20260714-0624

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.

@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry
don-petry enabled auto-merge (squash) July 14, 2026 06:53
@donpetry-bot

Copy link
Copy Markdown
Contributor

Advisory bots were rate-limited; auto-approval is withheld until they recover. pr-review-sweep will re-review this PR after 2026-07-14T07:53:53Z.

@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 a semantic symbol-context assembler that extracts touched functions from a diff and gathers caller, callee, and type-definition reference contexts using GitHub code search to aid downstream review tiers. The review feedback focuses on improving the robustness of the shell scripts and BATS tests, including utilizing $BATS_TEST_TMPDIR for temporary files, guarding grep -c commands under set -e, asserting exact exit statuses for grep failures, and applying safer jq parsing patterns with optional chaining and null-coalescing conversions.

Comment thread tests/dev-lead/unit/test_symbol_context_assemble.bats Outdated
Comment thread tests/dev-lead/unit/test_symbol_context_assemble.bats Outdated
Comment thread tests/dev-lead/unit/test_symbol_context_assemble.bats Outdated
Comment thread tests/dev-lead/unit/test_symbol_context_assemble.bats Outdated
Comment thread tests/dev-lead/unit/test_symbol_context_map.bats Outdated
Comment thread scripts/lib/symbol-context.sh
@don-petry
don-petry disabled auto-merge July 14, 2026 06:55

Copilot AI 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.

Pull request overview

Adds an opt-in “symbol context” pre-pass to the PR review cascade that collects cross-file reference snippets for functions touched in the diff, and makes that context available to both the deep-review and rubber-duck tiers (issue #1090, Phase 2).

Changes:

  • Introduces scripts/lib/symbol-context.sh to extract touched functions from a unified diff and (when enabled) assemble per-function reference contexts via gh search code, emitting measurable per-function counts.
  • Wires the symbol-context pass into scripts/review-one-pr.sh behind SYMBOL_CONTEXT_ENABLED (default off).
  • Updates deep-review + rubber-duck prompts to optionally read $SYMBOL_CONTEXT_FILE, and adds Bats unit tests for the mapper/assembler.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/dev-lead/unit/test_symbol_context_map.bats Adds unit tests for the “pure” touched-function extraction helper.
tests/dev-lead/unit/test_symbol_context_assemble.bats Adds unit tests for the I/O “assemble symbol context” path using a stubbed gh.
scripts/review-one-pr.sh Sources the new lib and conditionally runs the symbol-context pass before the review tiers.
scripts/lib/symbol-context.sh Implements touched-function extraction + gh search code context assembly with size/volume caps and graceful degradation.
prompts/rubber-duck.md Allows the duck pass to read $SYMBOL_CONTEXT_FILE for cross-file adversarial checking.
prompts/deep-review.md Allows deep-review to read $SYMBOL_CONTEXT_FILE for cross-file reasoning on touched symbols.

Comment thread scripts/lib/symbol-context.sh Outdated
Comment thread scripts/lib/symbol-context.sh
Comment thread scripts/review-one-pr.sh Outdated
Comment thread tests/dev-lead/unit/test_symbol_context_map.bats
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 14, 2026
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — fix-reviews (applied)

Changes committed and pushed.

@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — review-changes (applied)

Changes committed and pushed.

@don-petry
don-petry enabled auto-merge (squash) July 14, 2026 07:05
@don-petry
don-petry disabled auto-merge July 14, 2026 07:06
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — waiting on PR blockers (intent: fix-reviews)

PR: #1226
No changes were committed, but the PR still has blocking checks or reviews (failing or cancelled checks, or changes-requested reviews). The retry cron will re-attempt automatically. Next attempt after: 2026-07-14T07:39:50Z

@don-petry
don-petry enabled auto-merge (squash) July 14, 2026 07:09
@don-petry
don-petry disabled auto-merge July 14, 2026 07:12
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — fix-bot-comment (no-changes)

Agent reasoning
Issues addressed: 0
- Quality Gate passed with no findings
Skipped (informational): 0
```
The pull request is clean with respect to code quality, security, and static analysis. No changes required.

@don-petry
don-petry enabled auto-merge (squash) July 14, 2026 07:13
@don-petry
don-petry disabled auto-merge July 14, 2026 07:18

@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: 7

🤖 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 `@scripts/lib/symbol-context.sh`:
- Around line 1-3: Add `set -euo pipefail` near the top of the Bash script,
immediately after the shebang in the symbol-context assembler, so it applies
when the file is sourced or run independently.
- Around line 171-288: Throttle searches in assemble_symbol_context so
authenticated code-search requests remain within GitHub’s 10-requests-per-minute
token limit. Add pacing or backoff between sc_search_symbol_contexts calls, or
lower the default SYMBOL_CONTEXT_MAX_FUNCS cap to prevent larger diffs from
exhausting the quota while preserving existing graceful degradation.

In `@scripts/review-one-pr.sh`:
- Around line 694-709: Move the SYMBOL_CONTEXT_ENABLED block that calls
assemble_symbol_context from the pre-TRIAGE_ESCALATE flow into the tier-2 branch
immediately before run_agentic/run_duck. Keep the existing repository guard,
output path, and best-effort behavior unchanged, and defer unsetting PR_DIFF
until after tier-2 symbol-context assembly completes.

In `@tests/dev-lead/unit/test_symbol_context_assemble.bats`:
- Around line 94-103: Strengthen the assertions in the test “emits a measurable
per-function context-count log line (AC `#2`)” by requiring the output to contain
a numeric digit in the context-count portion alongside “assemble_thing”.
Preserve the existing checks for the “[symbol-context]” marker and function
name, and use a regex assertion so malformed values such as “undefined” do not
pass.
- Around line 49-69: Update the introductory stub comment in make_gh_stub to
state that gh search code returns 4 result items, matching the four JSON entries
for scripts/a.sh through scripts/d.sh; leave the stub behavior unchanged.
- Around line 113-119: Update the test “the configured minimum
contexts-per-function is honored” so its fixture distinguishes
SYMBOL_CONTEXT_MIN=2 from the default value: make the GH stub honor --limit or
return only two matching items, then assert the output contains exactly two
matching contexts rather than using a >= 2 check.
- Around line 43-46: Add tests in test_symbol_context_assemble.bats covering
SYMBOL_CONTEXT_MAX_FUNCS with a diff that touches multiple functions. Verify the
configured function cap is enforced and each function’s context output and
logging remain isolated.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 16a3157b-2af4-4880-a8a9-8b3f2ebc5023

📥 Commits

Reviewing files that changed from the base of the PR and between cae96e8 and 0060b21.

📒 Files selected for processing (6)
  • prompts/deep-review.md
  • prompts/rubber-duck.md
  • scripts/lib/symbol-context.sh
  • scripts/review-one-pr.sh
  • tests/dev-lead/unit/test_symbol_context_assemble.bats
  • tests/dev-lead/unit/test_symbol_context_map.bats

Comment thread scripts/lib/symbol-context.sh
Comment thread scripts/lib/symbol-context.sh
Comment thread scripts/review-one-pr.sh Outdated
Comment thread tests/dev-lead/unit/test_symbol_context_assemble.bats
Comment thread tests/dev-lead/unit/test_symbol_context_assemble.bats Outdated
Comment thread tests/dev-lead/unit/test_symbol_context_assemble.bats
Comment thread tests/dev-lead/unit/test_symbol_context_assemble.bats
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — rate-limited (intent: review-changes)

PR: #1226
The retry cron will re-attempt automatically.

@don-petry

Copy link
Copy Markdown
Collaborator Author

Note

@don-petry I received your request but all AI engines are currently rate-limited. I'll retry automatically once the rate limit clears.
Rate limit resets at: unknown

@don-petry
don-petry enabled auto-merge (squash) July 14, 2026 07:26
@don-petry
don-petry disabled auto-merge July 14, 2026 10:09
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — review-changes (applied)

Changes committed and pushed.

@don-petry
don-petry enabled auto-merge (squash) July 14, 2026 10:20
@don-petry
don-petry disabled auto-merge July 14, 2026 10:21
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — waiting on PR blockers (intent: fix-reviews)

PR: #1226
No changes were committed, but the PR still has blocking checks or reviews (failing or cancelled checks, or changes-requested reviews). The retry cron will re-attempt automatically. Next attempt after: 2026-07-14T10:53:49Z

@don-petry
don-petry enabled auto-merge (squash) July 14, 2026 10:23
@sonarqubecloud

Copy link
Copy Markdown

@don-petry
don-petry disabled auto-merge July 14, 2026 11:40
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry
don-petry enabled auto-merge (squash) July 14, 2026 11:40

@donpetry-bot donpetry-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.

Automated review — APPROVED ✓

Risk: MEDIUM
Reviewed commit: dcee6a2ceb081ed5d15e758ce5d9d0680a46fbc6
Review mode: triage-approved (single reviewer)

Summary

Confirms the triage assessment: an opt-in, default-inert symbol-context pass (issue #1090, Phase 2) that feeds caller/callee/type-def reference contexts from gh code search into the deep-review and rubber-duck tiers. New lib scripts/lib/symbol-context.sh + wiring in review-one-pr.sh + prompt docs + two bats suites. Gated behind SYMBOL_CONTEXT_ENABLED (default false), so default review behavior and cost are unchanged. All CI green, all 17 review threads resolved, latest CodeRabbit review on the head SHA is APPROVED.

Linked issue analysis

Closes #1090. All acceptance criteria substantively addressed: (1) >=3 contexts per touched function via SYMBOL_CONTEXT_MIN default 3, using the gh search code fallback path per the #839 LSP no-go; (2) measurable ::notice::[symbol-context] per-function count lines plus a SYMBOL_CONTEXT_COUNTS summary in the block, both covered by tests; (3) the same SYMBOL_CONTEXT_FILE is documented for the rubber-duck prompt so the adversarial pass reasons on equal footing; (4) inert by default and opt-in — when SYMBOL_CONTEXT_ENABLED is not true the file is never set and prompts/cost are byte-identical; graceful degradation on search failure (single ::warning::, always exit 0) is tested; (5) holdout-eval non-regression is satisfied by construction for default behavior since the feature is off by default.

Findings

No blocking findings.

Non-blocking nits:

  • Doc/code mismatch: the assemble_symbol_context header comment says the per-PR function cap defaults to 20, but the code default is ${SYMBOL_CONTEXT_MAX_FUNCS:-10}.
  • ${block:0:max_bytes} truncates by characters rather than bytes under multibyte locales; benign in the C-locale CI environment and consistent with the existing 8 KB downstream-impact cap pattern.

Security review: _symbol_context_gh reuses the GH_PAT convention from downstream-impact.sh without logging the token; the symbol is passed to gh search code as a quoted argument (no eval, no injection path); the search is scoped to $GITHUB_REPOSITORY and explicitly skipped with a warning when that variable is unset, avoiding an unscoped cross-repo search. Search-result snippets flowing into review prompts follow the same trust boundary as the existing downstream-impact block. Secret-scan MCP tool unavailable in this environment; the gitleaks CI check passed.

CI status

All required checks green: shellcheck, bats, unit-tests, CodeQL (actions + python), AgentShield, Agent Security Scan, gitleaks secret scan, SonarCloud quality gate, prompt-coverage, validate-fixtures, holdout-guard, and all workflow-structure guards. Remaining checks skipped by design (dependency-audit ecosystems not present).


Reviewed automatically by the PR-review agent (single-reviewer mode: fable 5). Reply if you need a human review.

@don-petry
don-petry merged commit f5895e8 into main Jul 14, 2026
40 checks passed
@don-petry
don-petry deleted the dev-lead/issue-1090-20260714-0624 branch July 14, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Phase 2] Feed semantic symbol context (callers/callees/type-defs) into the deep + duck tiers

3 participants