feat(engine): add per-claim confidence persistence (#465)#812
Merged
Conversation
ada66ce to
09054e5
Compare
Update the compiler prompt to request per-claim source attribution (subjects and source_ids) so claims carry provenance metadata from the LLM response. Pass source ID in the user prompt metadata so the LLM can reference it. Add integration tests verifying claim-level confidence aggregates into article-level confidence and that _persist_claims stores subjects/source_ids correctly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
323b1ee to
bc25d84
Compare
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
subjectsandsource_idsper claim, enabling per-claim source attribution from LLM outputContext
PR #800 shipped Phase 1 of issue #465 (article-level confidence with persistence). This PR advances the issue by closing the gap between the LLM prompt and the existing
CompiledClaimtable schema — the table already hadsubjects,source_ids, andconfidence_scorefields, but the compiler prompt never asked the LLM to populate them. Now it does.What was already in place (from PR #800 and #784):
CompiledClaimtable withconfidence_score,source_ids,last_reinforced_at,subjectscompute_claim_confidence()andaggregate_claim_confidence()pure functions_persist_claims()storing claims with per-claim confidence scores_refresh_confidence_score()aggregating claim scores to article levelGET /wiki/articles/{id}/claimsendpoint and service layerWhat this PR adds:
subjectsandsource_idsfields per claim_build_user_promptpassesSource ID: <uuid>in metadata block_persist_claimscorrectly stores subjects and source_ids from DTOs_build_user_promptincludes source ID in outputNot included (deferred to future PRs):
Test plan
test_build_user_prompt_includes_source_idverifies source ID in prompttest_article_confidence_aggregated_from_claimsverifies claim-to-article aggregationtest_persist_claims_stores_source_ids_and_subjectsverifies claim persistenceruff checkpasses with no errorsmypypasses (4 pre-existing errors in unrelated files)🤖 Generated with Claude Code