feat(ingestion): add opt-in best-effort document admission
Freeze temporary partial-extraction admission in new uploads. Bypass manual approval, retain recognition warnings, and accept ambiguous legal references during bounded chunking. Preserve strict defaults, immutable evidence and atomic publication. Expose effective policy and safe failure categories with regression coverage.
This commit is contained in:
@@ -138,3 +138,34 @@ def test_configuration_reports_testing_availability_without_claiming_calibration
|
||||
# A malformed embedding request policy still prevents configured availability.
|
||||
e.settings=e.settings.model_copy(update={'embedding_limits':None})
|
||||
assert not client.get('/api/v1/configuration').json()['capabilities']['voice']
|
||||
|
||||
|
||||
@pytest.mark.parametrize('kind', ['image', 'direct_pdf', 'factual'])
|
||||
def test_best_effort_upload_publishes_without_manual_approval(document_api, kind):
|
||||
from tests.support.extraction import pdf_bytes
|
||||
client, _, _, e = document_api
|
||||
headers = login(client, e)
|
||||
e.settings = e.settings.model_copy(update={'allow_partial_extraction': True,
|
||||
'vision_provider': 'gemini', 'vision_endpoint': 'https://test.invalid',
|
||||
'vision_model': 'fixture-flash'})
|
||||
if kind == 'image':
|
||||
content, name = image_bytes('PNG'), 'best-effort.png'
|
||||
elif kind == 'direct_pdf':
|
||||
content, name = pdf_bytes([[('text', 'Article 1: fee is 5%', 10, 20)]]), 'best-effort.pdf'
|
||||
else:
|
||||
content, name = b'Question: fee?\nAnswer: 5%\n', 'best-effort.md'
|
||||
response = upload(client, headers, content, name)
|
||||
assert response.status_code == 202, response.text
|
||||
identifier = response.json()['document_id']
|
||||
# Later deployment toggles must not reinterpret the admitted document.
|
||||
e.settings = e.settings.model_copy(update={'allow_partial_extraction': False})
|
||||
process(e, FakeVision(warnings=('Small unrecognized region',)))
|
||||
detail = polling(client, identifier)
|
||||
assert detail['status'] == 'ready' and not detail['review_required']
|
||||
assert not detail['is_active'] and not detail['searchable']
|
||||
if kind != 'factual':
|
||||
assert detail['extraction_quality_decision'] == 'accepted_with_warnings'
|
||||
with e.engine.connect() as conn:
|
||||
assert conn.execute(text('SELECT count(*) FROM document_chunks WHERE document_id=:id'), {'id': UUID(identifier)}).scalar_one() > 0
|
||||
snapshot = conn.execute(text('SELECT processing_profile FROM documents WHERE id=:id'), {'id': UUID(identifier)}).scalar_one()
|
||||
assert snapshot['extraction']['allow_partial_extraction'] is True
|
||||
|
||||
Reference in New Issue
Block a user