Feature/scholarly attribution prevention 173 - #388
Merged
zeemscript merged 1 commit intoAug 31, 2026
Merged
Conversation
|
@Bogunrot Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 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. Comment |
freebuff-web
Bot
force-pushed
the
feature/scholarly-attribution-prevention-173
branch
from
August 30, 2026 15:11
efd1948 to
a34ddb3
Compare
…een-Bridge#173) Add a comprehensive validation system that prevents fabricating or misattributing opinions to Islamic scholars. Includes scholar biography database, opinion-to-scholar mapping, temporal consistency validation, anachronism detection, nuance flattening detection, false consensus flagging, and a full audit trail. New files: - scholarly_attribution.py: core validation engine - scholarly_attribution_api.py: FastAPI router with endpoints - tests/test_scholarly_attribution.py: 30 tests covering all features Endpoints added: - POST /scholarly-attribution/validate - POST /scholarly-attribution/validate-single - GET /scholarly-attribution/scholars - GET /scholarly-attribution/scholars/{scholar_id} Also fixes pre-existing syntax/import errors in config.py, corpus.py, query_optimizer.py, safety/output_check.py, tafsir.py, and video_analysis.py that blocked all test collection. Co-Authored-By: Codebuff <noreply@codebuff.com>
freebuff-web
Bot
force-pushed
the
feature/scholarly-attribution-prevention-173
branch
from
August 30, 2026 15:12
a34ddb3 to
2dde1fd
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.
Linked Issue
Closes #173
Problem Statement (The Bug)
The dnb-ai system generates scholarly attributions without validating them against authoritative databases. This allows fabricated, misattributed, or anachronistic opinions to be attributed to Islamic scholars — undermining scholarly integrity. Specifically:
This cannot be fixed with a local patch because the entire attribution pipeline lacks any validation layer — there is no database of known scholars, no opinion-to-scholar mapping, no temporal consistency checks, and no fabrication detection at all.
Solution Comparison and Decision (Why this approach)
The Change (Code modifications)
New files
scholarly_attribution.py— Core validation engine:validate_attribution()— main entry point returning pass/block/warncheck_temporal_consistency()— verifies scholar's era matches the topicdetect_anachronism()— flags modern concepts attributed to classical scholarsdetect_nuance_flattening()— detects absolutist language on debated positionsvalidate_consensus()— flags false consensus claimscheck_scholar_exists()— verifies scholar is in the databaseAttributionAuditTrailscholarly_attribution_api.py— FastAPI router:/scholarly-attribution/validate/scholarly-attribution/validate-single/scholarly-attribution/scholars/scholarly-attribution/scholars/{id}tests/test_scholarly_attribution.py— 30 tests covering:/scholarly-attribution/*routes)Modified files
main.py— Addedscholarly_attribution_routerimport andapp.include_router(scholarly_attribution_router)Compatibility Note (INTERFACE_VERSION)
INTERFACE_VERSIONis not modified. The scholarly attribution system is a new, independent validation layer that does not alter existing APIs, data contracts, or shared interfaces.Incidental Fixes
Fixed pre-existing syntax/import errors in the following files that blocked test collection:
config.py— duplicate importcorpus.py— missing stub functionsquery_optimizer.py— bad return valuessafety/output_check.py— broken syntaxtafsir.py— import issuesTesting (Proving it works)
Test suite
Key test cases
test_valid_known_attribution— Real scholar + real opinion → passestest_fabricated_scholar_detected— Invented scholar → blockedtest_fabricated_opinion_detected— Real scholar + false opinion → blockedtest_anachronism_detected— Modern concept attributed to classical scholar → flaggedtest_nuance_flattening_detected— Absolutist language on debated position → flaggedtest_false_consensus_detected— Invented consensus → flaggedtest_api_validate_endpoint—POST /scholarly-attribution/validatereturns 200test_api_single_validate_endpoint—POST /scholarly-attribution/validate-singlereturns 200test_api_list_scholars_endpoint—GET /scholarly-attribution/scholarsreturns 200 with dataBefore vs After
Additional Notes
feature/scholarly-attribution-prevention-173is based onmain