feat(pebble): polish export markdown + pin format with tests - #202
Open
jpb33333 wants to merge 1 commit into
Open
feat(pebble): polish export markdown + pin format with tests#202jpb33333 wants to merge 1 commit into
jpb33333 wants to merge 1 commit into
Conversation
Tightens the prospect-research export so partial runs, long claims, and heterogeneous confidence values render cleanly, and pins the document shape with structural tests so it can't regress silently. What changed: - pebble/formatting.py (new): escape_md_table_cell, truncate_for_cell, normalize_confidence — pure helpers, no I/O. - pebble/export.py: empty-state section when claims+summary are blank; confidence rendered as "Medium (0.62)" / "High" / "Unknown" instead of raw values; claim text > 240 chars truncates with a footnote pointing to a "Full claim text" detail section; sources ordered by first claim appearance with "(N claims)" suffix and source_title links when present. - pebble/tests/test_export.py (new): 19 structural assertions on header, empty state, summary, claims table, truncation, confidence, sources. - pebble/tests/test_formatting.py (new): 26 helper unit tests. Signature of render_profile_markdown is unchanged. PDF path is untouched beyond a smoke check. Test counts: pebble 290 -> 335 (+45 new), no regressions. financial_forecasting 827 passed/22 skipped, unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit at claude.ai/admin-settings/claude-code.
Once credits are available, push a new commit or reopen this pull request to trigger a review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Tightens
pebble/export.py:render_profile_markdown(the prospect-research export endpoint) so partial runs, long claims, and heterogeneous confidence values render cleanly, and pins the document shape with structural tests so it can't regress silently.Five concrete improvements:
## No information gatheredsection explaining the run was partial (withpartial_reasonwhen available). Previously: header followed by nothing — looked broken.High (0.84)/Medium/Unknown. Previously a raw float like0.73was emitted next to literal strings like"unknown".### Full claim textdetail section below the table. Previously: ugly multi-line table cells that could break Markdown table rendering.## Sourcesnow orders URLs by first claim appearance with a(N claims)suffix when an URL backs multiple claims. Previously sorted alphabetically by URL string.source_title, the source list renders- [Title](url)instead of a bare URL.Also extracts three pure helpers (
escape_md_table_cell,truncate_for_cell,normalize_confidence) into a newpebble/formatting.pymodule so the L2-swarm renderer can adopt them in a follow-up without code coupling.Why
The endpoint had zero tests pinning its output shape and several rough edges that show up on real research runs. This PR fixes the rough edges and locks the format with tests so it stops being a silent-failure surface.
Scoped intentionally to the legacy markdown path on
devrather than the L2-swarmrenderer.py(which lives only onfeat/pebble-l2-swarm/ PR #191). The newpebble/formatting.pyis the seam for coordinated polish — L2 renderer can adopt the same helpers in a follow-up offdevafter PR #191 lands or as part of its split.How tested
pytest pebble/tests/test_export.py pebble/tests/test_formatting.py -v— 45 passed (19 structural format tests + 26 helper unit tests).pytest pebble/tests/ -q— 335 passed (290 baseline + 45 new). No regressions.pytest financial_forecasting/tests/ -q— 827 passed, 22 skipped. No regressions (this PR doesn't touchfinancial_forecasting/).0.62float confidence, two claims sharing a URL — eyeballed rendered markdown to confirm truncation/footnote, normalized confidence label, and(2 claims)suffix on the shared source.Golden path scenarios pinned by tests:
Risk
Low.
render_profile_markdownare the/api/v1/research/profiles/{contact_id}/exportendpoint (pebble/main.py:655); signature is unchanged.use_pebble_chatpermission, so blast radius is JP + whichever staff have that permission today.Rollback
Revert this single commit (
feat(pebble): polish export markdown + pin format with tests). No follow-up cleanup needed; no migrations.Coordinated polish handoff
After this lands,
pebble/orchestrator/renderer.py(currently onfeat/pebble-l2-swarm) can adopt:normalize_confidencefor its degraded/confidence band display.escape_md_table_cellif any tool renderer ever produces tabular output.That follow-up should be its own focused PR off
dev(or part of splitting PR #191).🤖 Generated with Claude Code