Document and test claim support bridge

This commit is contained in:
welsberr 2026-05-07 20:43:34 -04:00
parent ef61366eea
commit 0f76e86000
3 changed files with 83 additions and 0 deletions

View File

@ -42,6 +42,7 @@ The adapter exposes JSON-serializable methods suitable for a local web bridge:
- `expand_topic(...)` - `expand_topic(...)`
- `extract_text(text, backend="heuristic")` - `extract_text(text, backend="heuristic")`
- `verify_strings(values, context="", limit=5)` - `verify_strings(values, context="", limit=5)`
- `support_claims(text, context="", limit=5, max_claims=8, min_claim_chars=90)`
- `verify_bibtex(bibtex_text, context="", limit=5)` - `verify_bibtex(bibtex_text, context="", limit=5)`
- `graph(seed_keys, relation_types=None, depth=1, review_status=None, missing_only=False)` - `graph(seed_keys, relation_types=None, depth=1, review_status=None, missing_only=False)`
@ -64,6 +65,7 @@ window.citegeist = {
expandTopic(topicSlug, opts) {}, expandTopic(topicSlug, opts) {},
extractText(text, opts) {}, extractText(text, opts) {},
verifyStrings(values, opts) {}, verifyStrings(values, opts) {},
supportClaims(text, opts) {},
verifyBibtex(bibtexText, opts) {}, verifyBibtex(bibtexText, opts) {},
graph(seedKeys, opts) {} graph(seedKeys, opts) {}
} }
@ -122,6 +124,7 @@ This is sufficient to drive a demonstration app that can:
- preview or apply topic expansion; - preview or apply topic expansion;
- inspect one entry with BibTeX/provenance details; - inspect one entry with BibTeX/provenance details;
- run rough-reference extraction and verification; - run rough-reference extraction and verification;
- rank support-worthy claims in a prose excerpt and inspect suggested references;
- render local citation neighborhoods from `graph()` JSON payloads. - render local citation neighborhoods from `graph()` JSON payloads.
For a first demo, the strongest path is topic exploration rather than generic reference-manager behavior. For a first demo, the strongest path is topic exploration rather than generic reference-manager behavior.

View File

@ -839,6 +839,23 @@
"max_expanded_entries": 100, "max_expanded_entries": 100,
"max_expand_seconds": 20 "max_expand_seconds": 20
} }
}</div>
</div>
<div class="endpoint-card">
<div class="endpoint-head">
<span class="endpoint-method">POST</span>
<span class="endpoint-path">/api/call support_claims</span>
</div>
<p>Analyze a prose excerpt for support-worthy claims, rank them by <code>needs_support_score</code>, and return candidate references not already parsed from the excerpt.</p>
<div class="code-block">{
"method": "support_claims",
"params": {
"text": "Movement may not be modeled at all, but simply assigned a cost value ...",
"context": "artificial life",
"limit": 5,
"max_claims": 5,
"min_claim_chars": 80
}
}</div> }</div>
</div> </div>
<div class="endpoint-card"> <div class="endpoint-card">

View File

@ -2,6 +2,7 @@ from types import SimpleNamespace
from citegeist import BibliographyStore from citegeist import BibliographyStore
from citegeist.app_api import LiteratureExplorerApi from citegeist.app_api import LiteratureExplorerApi
from citegeist.bibtex import BibEntry
from citegeist.bootstrap import BootstrapResult from citegeist.bootstrap import BootstrapResult
from citegeist.app_server import ( from citegeist.app_server import (
LiteratureExplorerAppServer, LiteratureExplorerAppServer,
@ -9,6 +10,7 @@ from citegeist.app_server import (
_request_is_authorized, _request_is_authorized,
create_request_handler, create_request_handler,
) )
from citegeist.verify import VerificationMatch, VerificationResult
class FakeBootstrapper: class FakeBootstrapper:
@ -29,6 +31,38 @@ class FakeBootstrapper:
] ]
class FakeVerifier:
def verify_strings(self, values, context="", limit=5):
return []
def verify_string(self, value: str, context: str = "", limit: int = 5):
return VerificationResult(
query=value,
context=context,
status="high_confidence",
confidence=0.88,
entry=BibEntry(
entry_type="article",
citation_key="support2024",
fields={"title": "Support Paper", "year": "2024"},
),
source_label="openalex:search:Support Paper",
alternates=[
VerificationMatch(
entry=BibEntry(
entry_type="article",
citation_key="alt2023",
fields={"title": "Alternate Support", "year": "2023"},
),
score=0.66,
source_label="crossref:search:Alternate Support",
)
],
input_type="string",
input_key=None,
)
def test_literature_explorer_app_server_dispatch_search(): def test_literature_explorer_app_server_dispatch_search():
store = BibliographyStore() store = BibliographyStore()
try: try:
@ -138,6 +172,35 @@ def test_literature_explorer_app_server_dispatch_bootstrap_with_new_caps():
store.close() store.close()
def test_literature_explorer_app_server_dispatch_support_claims():
store = BibliographyStore()
try:
server = LiteratureExplorerAppServer(LiteratureExplorerApi(store, verifier=FakeVerifier()))
payload = server.dispatch(
"support_claims",
{
"text": """
Long claim text about agents evolving intelligent movement strategies in multiple computational settings without enough direct support [1].
References
[[1]]Earlier Cited Paper
""",
"context": "artificial life",
"limit": 3,
"max_claims": 2,
"min_claim_chars": 40,
},
)
assert payload["context"] == "artificial life"
assert payload["suggestion_count"] == 1
assert payload["suggestions"][0]["suggested_references"][0]["citation_key"] == "support2024"
finally:
store.close()
def test_literature_explorer_http_handler_class_can_be_created(): def test_literature_explorer_http_handler_class_can_be_created():
store = BibliographyStore() store = BibliographyStore()
try: try: