Isolate cloud model access before enabling product RAG workflows
Some checks failed
verify / verify (push) Has been cancelled
Some checks failed
verify / verify (push) Has been cancelled
The API and ingestion tools now use a fixed internal model gateway while governed profiles, embedding cache assignments, traceable citations, and stable API errors establish the boundaries required by later workflows. Constraint: The current Alibaba Cloud workspace rejects all three live model calls with authentication failures Rejected: Give the API or seed tools the Bailian key and direct egress | combines database access, cloud credentials, and public network access Rejected: Mix offline and Bailian vectors in one demo namespace | makes profile activation and retrieval ambiguous Confidence: high Scope-risk: moderate Reversibility: clean Directive: Keep Bailian credentials and egress exclusive to model-gateway and create a new immutable profile hash for any embedding identity change Tested: make verify; 121 backend tests; 14 frontend tests; fresh and populated Alembic upgrade-downgrade-upgrade; two idempotent offline seeds; Docker health and HTTP retrieval; isolated provider smoke Not-tested: Successful live Bailian responses because the supplied workspace credential currently fails authentication
This commit is contained in:
@@ -5,9 +5,12 @@ import pytest
|
||||
from app.adapters.fake import FakeEmbeddingProvider
|
||||
from app.core.config import Settings
|
||||
from app.tools.seed_demo import (
|
||||
BAILIAN_NAMESPACE,
|
||||
OFFLINE_NAMESPACE,
|
||||
embed_in_batches,
|
||||
embedding_profile_hash,
|
||||
load_documents,
|
||||
namespace_for_mode,
|
||||
prepare_chunks,
|
||||
)
|
||||
|
||||
@@ -38,6 +41,44 @@ async def test_seed_preparation_batches_and_hash_binds_twenty_documents() -> Non
|
||||
assert all(item.embedding_text == item.embedding_prefix + item.cloud_text for item in chunks)
|
||||
assert len({item.chunk_id for item in chunks}) == 20
|
||||
assert all(len(item.outbound_manifest_sha256) == 64 for item in chunks)
|
||||
assert all(item.embedding_elapsed_ms >= 0 for item in chunks)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_live_and_offline_seed_namespaces_cannot_share_document_identity() -> None:
|
||||
documents = load_documents(DOCUMENTS_PATH)
|
||||
settings = Settings()
|
||||
vectors, model = await embed_in_batches(
|
||||
FakeEmbeddingProvider(),
|
||||
[f"标题:{item.title}\n正文:{item.content}" for item in documents],
|
||||
)
|
||||
profile_hash = embedding_profile_hash(settings, "fake")
|
||||
|
||||
offline = prepare_chunks(
|
||||
documents,
|
||||
vectors,
|
||||
profile_hash=profile_hash,
|
||||
embedding_model=model,
|
||||
namespace=OFFLINE_NAMESPACE,
|
||||
)
|
||||
live = prepare_chunks(
|
||||
documents,
|
||||
vectors,
|
||||
profile_hash=profile_hash,
|
||||
embedding_model=model,
|
||||
namespace=BAILIAN_NAMESPACE,
|
||||
)
|
||||
|
||||
assert OFFLINE_NAMESPACE.knowledge_base_id != BAILIAN_NAMESPACE.knowledge_base_id
|
||||
assert OFFLINE_NAMESPACE.access_scope_id != BAILIAN_NAMESPACE.access_scope_id
|
||||
assert {item.document_id for item in offline}.isdisjoint({item.document_id for item in live})
|
||||
assert namespace_for_mode("fake") is OFFLINE_NAMESPACE
|
||||
assert namespace_for_mode("bailian") is BAILIAN_NAMESPACE
|
||||
|
||||
|
||||
def test_seed_rejects_unknown_provider_namespace() -> None:
|
||||
with pytest.raises(ValueError, match="invalid_provider_mode"):
|
||||
namespace_for_mode("unknown")
|
||||
|
||||
|
||||
def test_seed_rejects_fixture_not_explicitly_marked_synthetic(tmp_path: Path) -> None:
|
||||
|
||||
Reference in New Issue
Block a user