How sematic rag should behave¶
For Oracle ERP + Salesforce RAG, each test should verify:
- Correct object identification
- Correct field-level mapping
- Correct policy retrieval
- Correct workflow dependency retrieval
- Correct cross-system linkage awareness
- Correct risk/approval thresholds
- Correct environment restrictions
- Correct version awareness
π§ͺ 10 Black-Box Test Scenarios¶
Each test below contains:
- User Question
- Expected RAG Retrieval (What must be surfaced)
- What Failure Looks Like
β Test 1 β Field Ownership & Source of Truth¶
Question:¶
Which system is the source of truth for customer credit limit?
Expected Retrieval:¶
- Salesforce Account.Credit_Limit__c field
- Policy document stating Salesforce owns credit limit
- Integration mapping showing sync to Oracle AR
- Dependency rule: "Oracle AR balance cannot override credit limit"
Failure:¶
- Says Oracle is source of truth
- Doesnβt mention integration mapping
- Misses policy constraints
β Test 2 β Approval Threshold Logic¶
Question:¶
What happens if I increase a customer's credit limit by more than 15%?
Expected Retrieval:¶
- Business rule: >10% requires approval
- Workflow: Credit Limit Approval Flow
- Required approver role
- SLA for approval
- ERP sync condition after approval
Failure:¶
- Only retrieves field definition
- Misses approval threshold
- Misses workflow dependency
β Test 3 β Cross-System Dependency Awareness¶
Question:¶
If I deactivate a customer in Salesforce, what is impacted in Oracle ERP?
Expected Retrieval:¶
- Salesforce Account.Status field
- Integration mapping to Oracle AR customer status
- Policy: "Deactivation requires AR balance check"
- Dependency: Cannot deactivate if open invoices exist
Failure:¶
- Only retrieves Salesforce field
- Doesnβt mention AR or invoice dependency
β Test 4 β Financial Close Restriction¶
Question:¶
Can customer credit limits be modified during financial close?
Expected Retrieval:¶
- Close window policy document
- ERP restriction rule
- Environment flag: close_period_active
- Compliance rule: SOX constraint
Failure:¶
- Says βYesβ without policy context
- Does not retrieve close window restriction
β Test 5 β Field Validation Constraint¶
Question:¶
What validations apply to the credit limit field?
Expected Retrieval:¶
- Field type (currency)
- Max allowed value
- Required justification field
- Approval rule threshold
- Dependency: Risk tier must be evaluated
Failure:¶
- Only retrieves field type
- Misses validation and policy constraints
β Test 6 β Workflow Trigger Discovery¶
Question:¶
What workflows are triggered when a new enterprise customer is created?
Expected Retrieval:¶
- Salesforce Account creation workflow
- Risk assessment process
- Oracle ERP customer provisioning
- Credit review process
- Required data enrichment step
Failure:¶
- Only retrieves object schema
- Misses workflow chain
β Test 7 β Risk Tier Dependency¶
Question:¶
How is customer risk tier determined and where is it used?
Expected Retrieval:¶
- Field: Risk_Tier__c (Salesforce)
- Risk scoring process documentation
- Policy linking risk tier to credit approval threshold
- ERP AR collection priority rule
Failure:¶
- Only retrieves field location
- Misses downstream usage in approval logic
β Test 8 β Schema Drift Awareness¶
Question:¶
What changed in customer schema in the last release?
Expected Retrieval:¶
- Versioned schema metadata
- Newly added fields
- Deprecated fields
- Policy updates referencing new fields
Failure:¶
- Returns outdated schema
- No version awareness
β Test 9 β Permission Constraint Awareness¶
Question:¶
Who is authorized to override customer credit block?
Expected Retrieval:¶
- Role definition (Finance Manager)
- Policy override rule
- Audit logging requirement
- Required justification documentation
Failure:¶
- Does not retrieve RBAC mapping
- Misses override logging requirement
β Test 10 β Multi-System Transaction Awareness¶
Question:¶
What steps are required to fully onboard a new B2B customer across systems?
Expected Retrieval:¶
- Salesforce account creation schema
- Required fields list
- Oracle ERP customer creation process
- Credit assessment workflow
- Integration dependency mapping
- Sequence constraints
- Failure rollback rule
Failure:¶
- Only retrieves Salesforce object
- Misses Oracle provisioning
- Misses process order
π How to Score Black-Box Tests¶
Each question should be evaluated on:
| Dimension | Score |
|---|---|
| Correct Object Identified | 1 |
| Correct Fields Retrieved | 1 |
| Policy Retrieved | 1 |
| Workflow Dependency Retrieved | 1 |
| Cross-System Impact Retrieved | 1 |
| Version Correct | 1 |
Max per test: 6 Production readiness target: β₯ 5 average
π Advanced Black-Box Test (Edge Case)¶
Question:¶
Increase ACME's credit limit to 2 million.
RAG must retrieve:
- Current credit limit
- Risk tier
- Approval threshold
- Max allowed limit
- ERP impact
- Financial close restriction
If it only retrieves field name and value β your RAG is shallow.
π¨ Red Flags in Testing¶
Your RAG is not enterprise-grade if:
- It retrieves only schema but not policy
- It ignores workflow documentation
- It doesnβt surface cross-system dependencies
- It misses versioned updates
- It retrieves irrelevant objects frequently
- It retrieves too much noise
π What Good Enterprise Semantic RAG Looks Like¶
When a question is asked, the retrieval bundle should look like:
Retrieval bundle¶
Primary Object: Salesforce.Account
Relevant Fields: Credit_Limit__c, Risk_Tier__c
Policies: Credit Increase Approval Rule v3.2
Workflow: Credit Approval Flow
ERP Dependency: AR_Customer_Sync
Close Window Restriction: Enabled
If retrieval lacks one of these dimensions β planning will be unsafe.
π§ Final Insight¶
Semantic RAG in enterprise is not about answering questions.
It is about enabling safe orchestration decisions.
If retrieval does not surface:
- Constraints
- Dependencies
- Ownership
- Approval requirements
Then your ReAct agent becomes dangerous.
Iβll show you:
- What to extract
- How to normalize it
- How to chunk it
- How to embed it
- How to store it
- How to enable safe retrieval
- A concrete example
π― Goal¶
Turn this:
- Salesforce metadata
- Oracle ERP configuration
- Policy documents
- Workflow definitions
- Integration mappings
Into structured semantic retrieval units that support safe planning.
1οΈβ£ Step 1 β Define Canonical Knowledge Model¶
Before indexing anything, define a unified metadata schema.
This is critical.
We do NOT dump raw JSON.
We normalize into a canonical document model:
{
"id": "SF_ACCOUNT_CREDIT_LIMIT_V3",
"system": "Salesforce",
"entity_type": "Field",
"object_name": "Account",
"field_name": "Credit_Limit__c",
"version": "3.2",
"environment": "prod",
"category": "Schema | Policy | Workflow | Integration",
"risk_level": "Medium",
"content": "... natural language enriched description ...",
"structured_metadata": {
"data_type": "Currency",
"max_value": 1000000,
"approval_threshold_percent": 10,
"sync_target": "Oracle_AR_Customer"
}
}
This is what gets embedded.
2οΈβ£ Step 2 β Extract Metadata From Systems¶
A. Salesforce¶
Use:
- Metadata API
- Tooling API
Extract:
- Object definitions
- Field metadata
- Validation rules
- Workflow rules
- Apex triggers
- Flow definitions
B. Oracle ERP¶
Extract:
- Table schema
- Business rule configuration
- Approval hierarchies
- GL rules
- AR/AP dependencies
- Customizations
C. Enterprise Policy Docs¶
Parse:
- PDF policies
- Confluence docs
- Compliance documentation
- SOPs
Use document parser β structured text.
3οΈβ£ Step 3 β Semantic Enrichment¶
Raw metadata is not enough.
We enrich it.
Example:
Raw:
Enriched document:
The Credit Limit field on the Salesforce Account object
defines the maximum allowable credit exposure for a customer.
Business Rules:
- Maximum allowed value is 1,000,000 USD.
- Increases above 10% require Finance Manager approval.
- Field syncs to Oracle AR_Customer.credit_limit.
- Cannot be modified during financial close window.
- Requires Risk_Tier__c evaluation before update.
Dependent Workflows:
- Credit Approval Flow
- AR Sync Process
Now the embedding captures meaning and dependencies.
This is critical.
4οΈβ£ Step 4 β Intelligent Chunking Strategy¶
Never chunk randomly by tokens.
Chunk by semantic unit:
Good Chunk Types:¶
- One object + its fields
- One policy rule
- One workflow definition
- One integration mapping
Each chunk should answer:
- What is this?
- What are its constraints?
- What are its dependencies?
- What system owns it?
5οΈβ£ Step 5 β Embedding Strategy¶
For each chunk:
Store:
Example metadata columns:
| Column | Purpose |
|---|---|
| system | Salesforce / Oracle |
| entity_type | Field / Policy / Workflow |
| object_name | Account |
| version | 3.2 |
| environment | prod/sandbox |
| risk_level | high/medium/low |
| category | schema/policy/integration |
This enables hybrid filtering.
6οΈβ£ Step 6 β Storage Example (Postgres + pgvector)¶
Example table:
CREATE TABLE enterprise_rag_index (
id TEXT PRIMARY KEY,
system TEXT,
entity_type TEXT,
object_name TEXT,
field_name TEXT,
category TEXT,
version TEXT,
environment TEXT,
risk_level TEXT,
content TEXT,
embedding VECTOR(1536)
);
Index:
7οΈβ£ Step 7 β Retrieval Mechanism¶
When user asks:
Increase credit limit for ACME
Pipeline:
1οΈβ£ Intent Detection¶
Detect: credit limit change
2οΈβ£ Query Expansion¶
Expand query:
3οΈβ£ Hybrid Query¶
SELECT *
FROM enterprise_rag_index
WHERE system IN ('Salesforce', 'Oracle')
AND category IN ('Schema', 'Policy', 'Workflow', 'Integration')
ORDER BY embedding <-> query_embedding
LIMIT 10;
4οΈβ£ Rerank Results¶
Optional: cross-encoder reranker
8οΈβ£ Example End-to-End¶
Letβs walk a full example.
Input:¶
What happens if I increase credit limit by 20%?
Retrieved Chunks:¶
1οΈβ£ Salesforce Account.Credit_Limit__c field definition 2οΈβ£ Policy: >10% requires approval 3οΈβ£ Workflow: Credit Approval Flow 4οΈβ£ Integration: Sync to Oracle AR 5οΈβ£ Close window restriction
Final RAG Context Given to LLM:¶
Field: Credit_Limit__c (Salesforce Account)
- Max value: 1,000,000
- Approval threshold: >10%
Policy:
- Increases above 10% require Finance Manager approval.
Workflow:
- Credit Approval Flow triggered on update.
Integration:
- Syncs to Oracle AR_Customer.credit_limit.
Restriction:
- Modifications blocked during financial close window.
Now the agent can safely plan.
9οΈβ£ Versioning Mechanism¶
When Salesforce metadata changes:
- Detect change (webhook / scheduled sync)
- Rebuild enriched chunk
- Increment version
- Soft-delete old version
- Re-embed
Never overwrite blindly.
π Automation Pipeline¶
Production indexing pipeline looks like:
Salesforce Metadata Pull
β
Normalization
β
Semantic Enrichment
β
Chunking
β
Embedding
β
Vector DB Insert
β
Index Refresh
Run:
- On deployment
- Nightly
- On metadata change
1οΈβ£1οΈβ£ Common Mistakes¶
β Embedding raw JSON β Chunking by token size β No metadata filters β No versioning β Mixing production + sandbox β Indexing transactional data
1οΈβ£2οΈβ£ Advanced Enhancement (Very Powerful)¶
Add structured relationships:
Account.Credit_Limit__c
β triggers β Credit Approval Flow
β syncs_to β Oracle_AR_Customer.credit_limit
β constrained_by β Close_Window_Policy
Store relationships in graph DB.
Then combine:
- Vector search for semantic match
- Graph traversal for dependency expansion
This gives enterprise-grade reasoning.
π Production Rule¶
Semantic RAG must retrieve:
- Object
- Field
- Policy
- Workflow
- Integration dependency