Skip to content

fix(dual-solve): read grounding items from the context-pack dict#502

Open
Yurii214 wants to merge 1 commit into
vouchdev:testfrom
Yurii214:fix/dual-solve-grounding
Open

fix(dual-solve): read grounding items from the context-pack dict#502
Yurii214 wants to merge 1 commit into
vouchdev:testfrom
Yurii214:fix/dual-solve-grounding

Conversation

@Yurii214

@Yurii214 Yurii214 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

ground_prompt gated its items on isinstance(pack, ContextPack), but build_context_pack returns a model_dump'd dict in production (its signature is -> dict[str, Any]). so the guard was always false, items was always [], and dual-solve grounding always returned "the knowledge base has nothing on this topic yet." — even when the kb had matching claims. the code engines never received any kb context; the whole grounding feature was silently dead.

this reads items out of the dict (tolerating a ContextPack object too), mirroring the shape handling already in synthesize.py.

the existing test_ground_prompt_renders_items monkeypatched build_context_pack to return a real ContextPack, so it exercised the dead branch and never saw the production dict shape — which is why the bug was invisible to the suite. added test_ground_prompt_renders_real_context_pack, which seeds a real claim and drives the unmocked pipeline.

repro before: a kb with a claim matching the query still yields "nothing". after: - [c1] auth uses jwt tokens.

verified: pytest tests/test_dual_solve.py, mypy src, ruff check src tests all green.

Summary by CodeRabbit

  • Bug Fixes

    • Improved knowledge-base grounding to support multiple context data formats.
    • Grounding entries are now rendered correctly regardless of their underlying representation.
    • Prevented valid context from incorrectly falling back to a “nothing found” response.
  • Tests

    • Added regression coverage for grounding prompts built from real context data.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7ad75331-8277-4e96-9bb2-806670caf1c7

📥 Commits

Reviewing files that changed from the base of the PR and between bfb6b0a and debb239.

📒 Files selected for processing (2)
  • src/vouch/dual_solve.py
  • tests/test_dual_solve.py

Walkthrough

ground_prompt now accepts dictionary- and object-shaped context packs and items, with a regression test covering a real KBStore claim rendered into the grounded prompt.

Changes

Context pack grounding

Layer / File(s) Summary
Ground prompt context compatibility
src/vouch/dual_solve.py, tests/test_dual_solve.py
ground_prompt handles dictionary or object context packs and items, while the regression test verifies rendering from a seeded real claim.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: plind-junior

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: grounding items are now read from the dict-form context pack.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@github-actions github-actions Bot added dual-solve dual-solve orchestration tests tests and fixtures size: XS less than 50 changed non-doc lines labels Jul 16, 2026
@Yurii214 Yurii214 force-pushed the fix/dual-solve-grounding branch from e6a3283 to 2231e2b Compare July 16, 2026 03:12
@plind-junior

Copy link
Copy Markdown
Member

/auto-merge

ground_prompt gated its items on isinstance(pack, ContextPack), but
build_context_pack returns a model_dump'd dict in production, so the guard was
always false and grounding always returned "the knowledge base has nothing on
this topic yet." — even when the kb had matching claims. dual-solve therefore
never fed the code engines any kb context.

read items from the dict (tolerating a ContextPack object too), mirroring
synthesize's grounding. the existing test monkeypatched build_context_pack to
return a ContextPack, so it exercised the dead branch and masked the bug; add a
regression that drives the real, unmocked pipeline.
@Yurii214 Yurii214 force-pushed the fix/dual-solve-grounding branch from 2231e2b to debb239 Compare July 16, 2026 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dual-solve dual-solve orchestration size: XS less than 50 changed non-doc lines tests tests and fixtures

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants