Enterprise AI architecture
Map the system around a user task
Enterprise AI architecture defines how application components cooperate, who owns them and where trust boundaries must be enforced. Consider a fictional help desk serving two organizations, north and south. A user asks for an answer from their own handbook or a draft ticket reply; the system never sends replies automatically. The ordinary help-center search and human queue remain available. Use the deployment reliability, cloud economics and fairness lessons as prerequisites. The aim is not to maximize model usage: it is to deliver useful, authorized assistance with measurable service quality.
Separate the responsibilities
Read this text diagram from left to right: authenticated client → application policy enforcement → tenant-scoped data access and retrieval → model gateway → validated answer or human review. A proposed tool request takes a separate path through a tool executor with independent authorization. A bounded queue carries asynchronous work and rechecks the caller and policy at execution. The gateway owns provider adapters, timeouts, quotas, approved model versions and compatible fallbacks; it does not grant data access. The data service owns document permissions, deletion and tenant metadata. Retrieval returns only allowed evidence, never a global set that the model is asked to filter. Evaluation service runs versioned held-out tests before release; an audit sink records decision IDs and policy/model versions, while observability reports aggregate latency, quality and failures. A deployment controller owns rollback to a tested compatible configuration. This separation is a design proposal, not a requirement to deploy separate microservices: a modular monolith may be sufficient. Enterprise standards and governance should cover the whole application [1].
Enforce the tenant boundary before retrieval
The principal is a server-derived identity record with tenant, groups and active status. A record has a unique ID, tenant, group and deletion flag. This tiny exact filter stands in for a data-access policy, not real authentication. It returns sorted IDs only when the principal is active, the tenant and group match, and the record has not been deleted. Record b belongs to south, c requires finance, and d is deleted. Only a is returned; an inactive identity gets no records. A real service must bind identity to authenticated sessions, enforce row or document policies at storage, apply authorization before ranking, recheck stale candidates and scope caches by identity and policy revision. Treat metadata as trusted only after validation; model-generated tenant IDs cannot grant access. Exercise: change the groups to finance and predict the result. OWASP discusses isolation and least privilege for agentic systems [2].
def visible_records(principal, records): # Principal and records are supplied by trusted application storage. if not principal["active"]: return [] return sorted(r["id"] for r in records if r["tenant"] == principal["tenant"] and r["group"] in principal["groups"] and not r["deleted"])
principal = dict(tenant="north", groups=["support"], active=True)records = [dict(id="a", tenant="north", group="support", deleted=False), dict(id="b", tenant="south", group="support", deleted=False), dict(id="c", tenant="north", group="finance", deleted=False), dict(id="d", tenant="north", group="support", deleted=True)]print(visible_records(principal, records))print(visible_records(dict(principal, active=False), records))Recheck authorization at tool execution
A retrieval result is not permission to call a tool. The executor receives a proposed action, resolves the target from trusted storage and evaluates current access. In this teaching policy only lookup and draft are recognized. A permitted lookup returns read; a draft without reviewed approval returns review; an approved draft returns preview, never a real write. The same record restrictions apply independently at execution; even approval cannot override a different tenant. In a real system validate argument schemas, scope short-lived credentials to action and tenant, bind approvals to the actor, exact payload, resource, expiry and policy version, and enforce idempotency and deadlines. The approved flag below represents that verified evidence, not a flag accepted from the model. No tool or network is called. OWASP describes harm from excessive agency [3].
def tool_decision(principal, target, action, permitted, approved): # All fields are trusted policy evidence except requested action. if not principal["active"] or principal["tenant"] != target["tenant"]: return "deny" if action not in ("lookup", "draft") or action not in permitted: return "deny" if target["deleted"] or target["group"] not in principal["groups"]: return "deny" if action == "draft": return "preview" if approved is True else "review" return "read"
p = dict(tenant="north", groups=["support"], active=True)t = dict(tenant="north", group="support", deleted=False)print(tool_decision(p, t, "lookup", {"lookup"}, False))print(tool_decision(p, t, "draft", {"draft"}, False))print(tool_decision(p, t, "draft", {"draft"}, True))print(tool_decision(p, dict(t, tenant="south"), "lookup", {"lookup"}, True))Operational boundaries and failure paths
Store credentials in a managed secret store; inject only into the service needing them, never into prompts or user-facing logs. Trace allowlisted IDs, outcomes, durations and usage rather than raw sensitive content; protect the audit store with restricted access, retention and integrity controls. A shared index, worker, queue or cache is a cross-tenant boundary: verify tenant scoping after dequeue, before retrieval and before execution. If a gateway fails, use a previously evaluated compatible provider only when policy and residency permit it; otherwise fall back to ordinary search or human assistance. Denied requests must remain denied even when degraded. For practice, draw the service and control paths, mark which owner can disable each feature, and write a negative case for both retrieval and execution. The project tests local decisions, not network isolation or real credential handling.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Enterprise AI architecture quiz
Assess enterprise architecture, trust boundaries, ADRs and governance.
Which component should determine whether a document is visible?
North support requests a south support record. What should happen?
Why recheck policy at tool execution?
What does an approved draft return in the fixture?
What belongs in an allowlisted operational trace?