Threat Modeling Compound AI Systems
Map trust boundaries, data flows, and authority for compound AI systems. Learn field projection, access checks, and failure analysis for security.
Language AI HandbookAll chapters Threat Modeling Compound AI Systems
A library asks for a catalog assistant that answers which room holds a title. Its catalog stores the location. Adding a model introduces a second question: which parts of a catalog record should the model see before it phrases the answer? That decision belongs at the read boundary, where a component can enforce it. A review of the assistant starts by drawing that boundary and identifying who owns the check.
We will map two designs for the same fictional read-only assistant. Both provide the room and shelf for a caller-visible catalog entry. One gives the answer model the entire approved record. The other hands it only the fields needed for the question. We can compare their exposure without measuring model behavior or estimating incident probabilities.
Why compound systems need their own threat model
A compound AI system combines a model with application components such as retrieval, policy, and rendering. In the catalog assistant, the policy service determines which records a reader may access, the retrieval service reads them, and the model proposes a reply. A change to retrieval or to the renderer can change the assistant's behavior even when the model is unchanged. Scope the review to the whole path from the reader's request to the reply.
Start with concrete outcomes. A catalogue answer can be wrong, a staff note can reach a reader who lacks access to it, or an authorized reader can lose access when the service fails. These are integrity, confidentiality, and availability concerns, respectively. Assign an owner and a test to each concern. That gives the team a way to revisit a design decision after a component changes.
What changes when the model is one component?
Think of this as reviewing something that makes an application decision in stages. You can hand the same natural-language request to two deployments and get different capabilities even when their application code uses the same model. In one design the application preselects a catalog entry and tasks the model with phrasing a reply. In another the application asks the model to recommend which entry to use. The input sentence stays the same. The second design adds a choice about which information to retrieve, and the application has to check that choice under the reader's authority.
That example also shows why a prompt is a poor place to document a permission decision. You need a way to trace the decision to the actor that can enforce it and the state it reads. A model-facing instruction can describe how to phrase an answer with insufficient evidence. The service that retrieves the record owns the check that decides whether the evidence can be obtained at all. Those two decisions can change on different release cycles. Treat them as distinct rows when assigning ownership and tests.
A diagram or matrix will be wrong if it leaves out an alternate route. The familiar place to start is the live request. Draw it through to the response first. Then ask whether the same data can take a separate route through caching, review, or troubleshooting. The test is whether a reviewer could come back after release and ask, for every arrow, what operation runs and what fields cross. If the team can only point to a prompt or to a diagram of model calls, the next step is to inspect the surrounding software.
This exercise focuses on application boundaries the developer can inspect. It uses a fictional dataset and named roles to keep distinctions clear. That lets you work through security implications without having to learn a provider's APIs or infer how an external service behaves.
The anatomy of a threat model
In its Threat Modelling guidance, the UK's National Cyber Security Centre recommends accounting for components, their interactions and data flows, interconnections, and trust boundaries. A boundary identifies a place where a control can govern the transfer. In this exercise the application receives the catalog record from retrieval and then selects the fields allowed across the separate boundary to the answer model.
Record a few details about each crossing. Describe the claim you want to rely on, the component that enforces it, and how you would check it. Include an assumption whenever the claim depends on another component. For example, limiting the model's input to public fields depends on both the completeness of the field selection and the accuracy of the catalog's visibility labels. If ownership or evidence is missing, record the open item so it can be resolved.
The assumptions behind the diagram
A design diagram changes meaning when an assumption changes. Use terms that can be verified by an application owner. A useful working record for one assumption includes an observable condition, the service owner who can check it, and what the control should do if the condition fails. For the model handoff, an observable condition is that the actual request contains only fields from the agreed selection. The application owner can check a captured test request with fixture field values. If a field is unexpected, the assistant can return an unavailable result while the service owner examines the request builder.
Treat a threat as a condition or event that could undermine an asset. Treat a vulnerability as a weakness that could let the condition affect that asset. Our read boundary gives a simple example without any operational attack. A reader who has lost access should no longer get the current record. A component that assumes all previously cached authorizations still hold risks showing information after policy changes. Notice that the test can be written from the desired outcome, without constructing an intrusion. Provide two authenticated fixture identities with different intended visibility. Ask the same question and assert the documented results.
It also helps to log which assumptions are explicitly outside the chapter. Here we describe intended behavior for a single library request with no external send interface, one catalog and one renderer. We assume the source store has a staff-only field that the application can see before projecting the model context. We use public field to mean these three fields are displayable for this record once the reader's access check succeeds. In another workflow with private records, a field may have different visibility when the reader, purpose, resource, or destination changes. That policy needs its own check before any projection.
Some threat models carry numerical risk ratings. A rating is only as interpretable as the scale and the evidence behind it. In this example record the impact in plain language and show whether a named control exists in the design. A field-count difference will be useful later because it has a clear unit. We leave the probability that a design yields a bad answer unspecified.
A running example: the catalog assistant
The user asks for the location of a title. The application keeps the authenticated reader identity and current catalog authorization in request state. The catalog has three public fields: title, room, and shelf. A fourth field, staff note, is for catalog operators. A request to the model can contain caller-visible catalog data. Catalog administration and externally addressed replies are outside the interface of both designs.
The example uses one fabricated record. It has a stale room in the source data, so every design in this chapter needs a way to handle source corrections. The record also contains an operator-only note. That gives us two independent things to check. We can examine whether the note crosses a boundary. Separately, the catalog owner can compare the record's verification state with the current physical location.
PythonIn [3]Expand
from dataclasses import dataclass
from enum import Enum
@dataclass(frozen=True)
class CatalogRecord:
title: str
room: str
shelf: str
staff_note: str
record = CatalogRecord(
"Folding Maps", "East", "E4", "Location awaiting verification"
)A single entry can have two kinds of integrity that are worth tracking separately. First is integrity of the stored location. The catalog team can define whether the record matches the physical location of the item. Second is integrity of the rendered answer relative to the selected record. The renderer can check whether the text claims the same room and shelf as the source values. If the renderer passes its check while the record is stale, its test made a true statement about one boundary. The incident still belongs partly to the source owner. Keep these controls in separate rows so a passing response check does not settle the source-freshness issue.
Plan for a useful unavailable response. Suppose an approved record is missing a shelf value because the library is moving stock. If room and shelf together are required, the check should have a defined outcome for the missing field. That means deciding as a product matter whether to present the room with an explicit partial-result label or to present no location at all. The fixtures below use a complete location. A production test must use the product decision for missing values as its expected result.
Record the audience where you draw the renderer. If two devices can use the same assistant under two different identities, then the source store and model can behave correctly while the result ends up attached to the wrong session. Review application state that records where a reply should appear and how retries handle it. The question at this crossing is whose screen can receive the answer. The model's input field selection is about a different audience, the answer model and the service hosting it.
Pick a few vocabulary rules with your team. We will use asset for something the system is meant to protect, actor for someone who acts, and component for software that handles a role. An operator can be a human actor. The renderer is a component acting on the application's decision. Authority is the right to read a record or to show a result, as determined by policy and enforceable by application code. Trust is contextual. You might trust the retrieval service to return the catalog record for a key and still consider the record's location unverified because the operator has not checked it recently.
Step 1: Enumerate assets and actors
Start with the assets affected by the request. The reader is entitled to the three public fields for this entry. Catalog operators retain the authority to change records. The model's request context and the renderable answer contain copies or transformations of whatever the preceding components hand them. Identify who can see each representation, including telemetry if it retains any of the same information.
The table below uses actor for a human or component with a defined role. A model can affect the displayed wording because the renderer consumes its proposal. The application still owns the choice of resource and audience. Mapping both responsibilities makes it possible to check which component to change if a test fails.
PythonIn [4]Expand
actors = {
"Reader": "Ask for a visible entry",
"Application": "Check authorization and select a response route",
"Retrieval service": "Read the requested catalog record",
"Answer model": "Propose wording for the selected data",
"Renderer": "Display the result in the current session",
"Catalog operator": "Maintain catalog fields and visibility labels",
}
for actor, responsibility in actors.items():
print(f"{actor} — {responsibility}")ConsoleOut [4]Expand
Reader — Ask for a visible entry Application — Check authorization and select a response route Retrieval service — Read the requested catalog record Answer model — Propose wording for the selected data Renderer — Display the result in the current session Catalog operator — Maintain catalog fields and visibility labels
After the first inventory, read each row as a scenario with an owner. For the requester, the main asset is usable approved information. Their test should observe location, identity binding, and understandable refusal or unavailability. For the operator, it is record integrity and the ability to correct it in the proper administrative interface. Their test can follow a benign location change through the date of last verification and into use by the read-only route. For the application owner, it is dependable enforcement. Their tests should inspect traffic at the visibility and field-selection boundaries using fixtures.
A short worksheet can stop two owners from assuming that the other one checks a field. Include the field and its expected owner along with the component where it is checked. For our staff note, the catalog team owns the data's sensitivity label, and the application team owns its exclusion from the model. For the checked location, the catalog team owns the physical location and the renderer owner owns agreement between the record and the displayed values. Responsibility can cross a team boundary with the data, but the two check results remain distinct.
Keep non-human services in the inventory wherever they handle a copy. The assistant's application may need access to the record that contains a staff note, even if it never gives the note to the answer model. A reviewer then asks whether the authorized retrieval could return a smaller record in advance. Placing projection earlier would remove the need for this application stage to handle the note. This is a new architecture, so it should get a new matrix row or version rather than a claim that an existing projection already provides that behavior.
During a read-only review, include background data stores that exist in your design, including any store that only helps operators. A redacted diagnostic record is still an asset if staff can correlate it with reader sessions. Ask the operator what decision they need to investigate. Use that requirement to decide which attributes need to cross this boundary. Besides a store's contents, capture who can read it and what deletion or retention rules it follows.
Step 2: Draw trust boundaries
Mark a boundary when responsibility or scope changes. A request entering the application crosses from reader-controlled inputs to application request handling. A catalog row returning from retrieval crosses into answer preparation. The rendered result crosses from the application back to the current reader session.
For each boundary, write the check in terms that can fail. At the retrieval return, check that there is a caller-visible record and select only viewable fields. At rendering, bind display to the current session and check that the reported location matches the selected record. If the record is unavailable, both designs can show an explicitly unavailable result. This keeps an unverified location out of the reply.
PythonIn [5]Expand
boundary_checks = {
"Reader → application": "Bind request to the authenticated reader",
"Application → retrieval service": "Check current record-read authorization",
"Retrieval service → application": "Accept the result for the authorized record",
"Application → answer model": "Project the approved response fields",
"Answer model → renderer": "Check that the proposed location matches the source",
"Renderer → reader": "Render to the current reader session",
}
assert len(boundary_checks) == 6One component can sit on both sides of different checks. The application owns the retrieval request and the model handoff, for instance. It makes a resource decision at the first boundary and an exposure decision at the second. Write them as separate controls so that passing one check never implies that the other happened.
If a team puts a label such as internal on an entire region of a diagram, ask what property the label signifies. A field can come from an authenticated service without carrying authority to propose a new operation. Likewise, a request from a verified account can still be rejected if the policy denies that particular read. These examples are easier to handle if the diagram says exactly which fact the crossing establishes. For the lookup boundary, establish authenticated identity and permission for the requested record. For the model boundary, establish which fields have been selected and that they are carried as evidence.
The value of a boundary drawing is that it can identify who takes the next decision. Imagine the team grants the renderer permission to consult the original catalog record to compare location values. Who owns that read? It can reuse the application's existing authorized record snapshot, or it can request a separate read under current authority. Reusing a snapshot avoids another lookup but ties the answer to the freshness and authorization rules for that snapshot. An additional read raises questions about how to handle changes between the two readings. Neither choice is present in the toy run. The worksheet should record what a deployed route does.
Use a table when drawing the system with colleagues who work on different components. For every row, identify the sending component, the receiving component, the field or operation, and the local decision about it. Then check that the selected branch makes sense when the record is missing and when the access check denies it. A review meeting that only follows rows in which every service succeeds can miss the route users see during outages.
The rendering check is an example of something structured enough to test without running the answer model. Supply a proposal object expected to pass and one expected to fail the semantic comparison, with no free-text instructions in either. For a real service, check the normal entry point separately so the semantic validator cannot be accidentally omitted by a formatting or retry path.
Step 3: Trace control flow and data flow
A control-flow map shows who selects the next operation. A data-flow map shows which information is carried along each transfer. Here the application chooses a lookup, reads a record, and selects fields for the model. The record carries catalog data into the answer stage. It grants no new permissions. The renderer accepts a location proposal only after checking the source values. A proposal is data crossing the boundary to the renderer before that check.
PythonIn [6]Expand
operation_order = (
"bind reader identity",
"check read authorization",
"retrieve record",
"select fields",
"construct answer proposal",
"validate location and display",
)
assert operation_order.index(
"check read authorization"
) < operation_order.index("retrieve record")PythonIn [7]Expand
data_transfers = (
("Reader", "Application", "Authenticated request and title lookup"),
("Application", "Retrieval service", "Authorized catalog entry identifier"),
("Retrieval service", "Application", "Catalog record"),
("Application", "Answer model", "Selected public fields"),
("Answer model", "Renderer", "Proposed location"),
("Renderer", "Reader", "Checked location or unavailable status"),
)
for sender, recipient, data in data_transfers:
print(f"{sender} → {recipient} | {data}")ConsoleOut [7]Expand
Reader → Application | Authenticated request and title lookup Application → Retrieval service | Authorized catalog entry identifier Retrieval service → Application | Catalog record Application → Answer model | Selected public fields Answer model → Renderer | Proposed location Renderer → Reader | Checked location or unavailable status
A data-flow line does not describe the right to make the next decision. For example, the model sees the shelf field, but the renderer checks the proposal against the selected shelf value before displaying it. Keeping policy in the application also gives a reviewer a concrete place to inspect who may read a record when the session changes.
Follow information and decisions on separate maps
An arrow labelled location record can transfer data. An arrow labelled check read authorization transfers a request to evaluate a policy. They can refer to the same resource yet belong to different maps. If you merge the maps too early, it is easy to infer that a component carrying the record can authorize another lookup. Conversely a component that can authorize access does not necessarily need the full record for that decision. The authority map says who acts under whose permission. The data-flow map says which representation travels where.
The distinction becomes practical in a retry. A service might retry an authorized read after a timeout. The retry decision is a control-flow edge. The record received on success is a data-flow edge. If the user's visibility changes before the retry, the architecture needs a rule about reusing the previous authorization or consulting current state. Even if the retry eventually returns a record with the expected fields, the project still needs to check that its chosen rule was applied. A test focusing only on successful lookup values will miss the authorization question.
Table snapshots can be helpful when a diagram gets crowded. Freeze the scope to one request and record the executed operation sequence as evidence in a test. Record keys or types at each data crossing using toy values. Look for a place where the deployed path takes a different branch from the diagram. A difference can mean an incorrect implementation or a stale diagram. Investigate that difference before treating the model as a complete basis for design decisions.
The example below represents operations and data transfers as tuples because their order is declared. Tuple order expresses the route we intend to examine. The fact that the tuple puts a check before a lookup does not enforce that order anywhere else. The useful next inspection for a deployed app is to find the actual lookup call and verify which successful predicate leads to it.
Step 4: Reason about failure propagation
Write down the earliest point at which each assumption can fail, then follow the resulting data to the next boundary. A stale location begins in the catalog. Projecting fewer fields still passes the location through, and a comparison against the same stale source still agrees. The data owner needs a way to correct the catalog. If the system tracks when a location was verified, the application can check that provenance or return an unavailable result.
Now consider visibility. An unexpected field in a record response is a concern before model input is built. Both designs below use explicit projections, and neither projection includes the staff note. Another component can still mishandle it between retrieval and the projection. Review the retrieval service and intermediate application handling separately. In this example the staff note reaches the application, so testing only model exposure cannot establish that the note stayed out of application telemetry.
PythonIn [8]Expand
@dataclass(frozen=True)
class FieldSet:
public_fields: tuple[str, ...]
full_public = FieldSet(("title", "room", "shelf"))
location_only = FieldSet(("room", "shelf"))PythonIn [9]Expand
def project(record: CatalogRecord, fields: FieldSet) -> dict[str, str]:
available = {
"title": record.title,
"room": record.room,
"shelf": record.shelf,
}
return {field: available[field] for field in fields.public_fields}
public_context = project(record, full_public)
location_context = project(record, location_only)
assert (
"staff_note" not in public_context and "staff_note" not in location_context
)
assert project(record, FieldSet(())) == {}The available-field dictionary above defines the allowlist. Selecting an unlisted field raises an error. Empty selection produces an empty dictionary. In this notebook those are properties of a local function. A deployed system would also need to test that its actual context builder is the only path from retrieval into the model.
Compare the consequences of different faults
There are two different repair routes in the previous example. If the location record is stale, an application can detect a stale verification date only when the data includes a trustworthy verification record and the application checks it. When the location has been recently verified but the model proposes a different room, comparison with the selected record can catch the discrepancy even without a freshness field. The first concern belongs upstream near catalog maintenance. The second belongs downstream near formatting and response validation. Keep both in review because a summary that says data integrity is checked could hide which one is covered.
For a known boundary, list check, fallback, and owner together. If source projection fails because a required field is missing, fallback can be a deterministic unavailable status. If the rendering semantic check fails, fallback can be a template populated from the validated location record or an unavailable result, whichever the product allows. If the caller is denied at retrieval, a fallback should preserve the denial. When you choose an evidence trail for each branch, include the outcome as well as whether the normal path completed.
A small matrix is sufficient for this comparison because we care about which component sees each field. It is not a model of data retention or downstream analytics, which would add further columns. The next architectural question is whether each path carries the fields its consumer needs. A reviewer can trace the model context, the renderer's structured inputs, and any staff troubleshooting surface as separate destinations. Lower exposure at one destination says nothing about the others until their flows have been reviewed.
We will distinguish risk from reachability. A path in the diagram shows a transfer that can occur under the route's assumptions. Its presence does not assign a frequency or impact. Two paths can reach the same component and affect different assets because they carry different fields or operate under different authority. This is why the matrix measures the named field reach and leaves any overall severity judgment for evidence about the actual application.
As a readiness exercise, imagine a third design that applies the same public projection inside retrieval. The staff-only field then never crosses from retrieval into the application for that route. The existing model-context plot would give the same values as the corresponding application-side projection. A comparison of application exposure would distinguish them. That observation is a good test of whether a plot's dependent variable answers the question a reviewer is asking.
Worked example: two architectures, one matrix
Keep the answer contract fixed while changing what the answer model sees. The broader design projects all three public fields. The narrow design projects room and shelf. Both retain the original title at the application level when needed for the display. Neither enables editing, and both check the proposed location before rendering.
Read each matrix row as an individual effect in the declared design. Here "model input" denotes data present in the answer model's request context. "Application only" means the application's intermediate result can contain that field and the model context does not. A control outside the route has no operation in this exercise.
PythonIn [10]Expand
matrix = [
("Title", "Model input", "Application only"),
("Room", "Model input", "Model input"),
("Shelf", "Model input", "Model input"),
("Staff note", "Application only", "Application only"),
("Edit catalog", "Outside route", "Outside route"),
]
for item, full_view, narrow_view in matrix:
print(f"{item:15} {full_view:18} {narrow_view}")ConsoleOut [10]Expand
Title Model input Application only Room Model input Model input Shelf Model input Model input Staff note Application only Application only Edit catalog Outside route Outside route
PythonIn [11]Expand
public_counts = [len(public_context), len(location_context)]
full_count, narrow_count = public_counts
fewer_fields = full_count - narrow_count
assert public_counts == [3, 2]
assert fewer_fields == 1The count uses the keys in each example dictionary. Both contexts carry the same room and shelf values. Narrowing the projection removes one public field, the title. This count tracks scope in a declared configuration. Fields can vary in sensitivity and in how much information they contain, so equal counts would tell you little about privacy risk.
VisualizationOut [12]Expand

The diagram exposes a narrow tradeoff for this task. Location-only keeps the answer ingredients and omits a field the model does not need. A later feature that needs to compare titles changes the functional requirement. Update the projection and its boundary test together when that requirement changes.
Conditions for comparing views
A comparison depends on a fixed task. We are looking up one caller-visible catalog entry and providing the room and shelf. Neither route asks the answer model to select a different resource. The same catalog source, current reader and return route apply. To explain any matrix difference, a reader should be able to point to one design choice. With a different source or more permissive user, the field reach might change for an unrelated reason. Hold the access decision fixed while you compare the projections.
There are two distinct ways to count data here. The number of field names describes the shape of a record. The number of distinct field values across a batch describes a different property and can change when data varies while the schema stays fixed. The plot uses the first count for one row. It cannot tell how many people the fuller view could identify, how much text it contains, or how much work the model uses. Those observations require a different experiment and privacy or performance criteria.
A useful control expectation for both views is that the public location values returned by projection still match the source. That makes the effect of changing scope easier to verify. For this toy example, dictionary values are direct copies. For a deployed system with normalization, decide whether a value such as room E01 can be shortened to E1. The application needs a checked mapping if such normalization can change the apparent location. Failing to define equivalence at the comparison step can make valid answers fail while invalid ones with similar labels still pass.
If you include a third experimental view for a room-only route, write down the changed task contract. For example, a visitor guide might answer which hall to enter without identifying a shelf. A field count of one would then be expected for this new contract. Under the original task with a required shelf, that same projection would omit an essential field. You can distinguish content minimization from missing functionality by testing the task outcome and the allowed fields in separate assertions.
Step 5: Map authority, the part that makes or breaks security
For the catalog lookup, authority means permission for an authenticated reader to read the requested record at the time of the check. The application's capability to perform the service call is necessary, but the service capability is only one input to the decision. In the fixture below the authorized entry set represents the reader's current permissions. The answer-model context plays no role in that set.
PythonIn [13]Expand
def has_read_permission(
entry_id: str, current_visible_entries: frozenset[str]
) -> bool:
return entry_id in current_visible_entries
entry_id = "catalog-entry-1"
approved_entries = frozenset({entry_id})
assert has_read_permission(entry_id, approved_entries)
assert not has_read_permission("catalog-entry-2", approved_entries)
assert not has_read_permission(entry_id, frozenset())This check describes a declared state at one decision. A design with changing permissions needs to say whether the read and the later display share an authorization snapshot or perform separate checks against current state. That choice determines what happens if access changes between retrieval and display. The catalog exercise assumes authorization at the read boundary and a session-bound reply, with no access changes during the simulated request.
Bound authority to the current decision
Each authorization worksheet needs a subject, one operation, a resource, and a state or time at which the rule is evaluated. Those terms make it easier to discuss a question such as what happens when the reader signs out. In the example, the subject is the current reader session, the operation is reading the entry, and the resource is its identifier. The fixture supplies the identifier set at the point of evaluation. Similar prototypes sometimes put the set into model context because it seems convenient. Doing so exposes policy data to the answer stage without deciding who enforces membership.
Track authority across delegated calls, too. A service account may have rights to retrieve many records on behalf of the application. A user-visible action still needs the application to establish the invoking reader's permission for the specific entry. One way to review this is to examine a failing fixture for an account that is valid but lacks access to one record. The lookup can be denied even though the infrastructure client has its own valid authentication. This distinction belongs in the service test alongside ordinary successful cases.
Trust boundaries can change within the same request. If the application computes a draft in one session and later shows it inside a separate workspace, those endpoints can have different audiences. A model proposal about where to send a reply cannot establish the user's authority to send it there. The design controls in this chapter only display results to the current client, and include no external send route. Add the audience and the necessary authorization checks to the model if that capability is introduced later.
Revocation is a design question about timing. An application may choose to recheck at each sensitive boundary. Another architecture may issue access untied to model output for a limited lifetime, according to policy. A reviewer needs to know which decision that deployment makes, whether there is a distinct cached result, and how long the application can continue after a permission update. Our fixture simulates decisions using a supplied set. It models none of the time between allocation of that set and a distributed operation.
Code: assembling the full analysis harness
The first replay checks the matrix's four named data rows against the two projected dictionaries and the declared application record. The edit row records that neither architecture exposes an editing operation. A second check reports whether each view still carries the selected location and whether the title and staff note have the intended visibility.
PythonIn [14]Expand
field_names = {
"Title": "title",
"Room": "room",
"Shelf": "shelf",
"Staff note": "staff_note",
}
checked_data_rows = []
for label, field in field_names.items():
assert hasattr(record, field)
destinations = tuple(
"Model input" if field in context else "Application only"
for context in (public_context, location_context)
)
checked_data_rows.append((label, *destinations))
assert matrix[:-1] == checked_data_rows
design_checks = {
"both supply the intended location": all(
context["room"] == record.room and context["shelf"] == record.shelf
for context in (public_context, location_context)
),
"only full public view supplies the title": "title" in public_context
and "title" not in location_context,
"both keep the staff note out of the model": all(
"staff_note" not in context
for context in (public_context, location_context)
),
}
assert all(design_checks.values())
for property_name, holds in design_checks.items():
print(f"{property_name} | {holds}")ConsoleOut [14]Expand
both supply the intended location | True only full public view supplies the title | True both keep the staff note out of the model | True
A useful follow-up for a real catalog team would be to turn those properties into a release test that inspects the actual model request. Include a second fixture whose location is missing and check that the renderer reports that state. The fixture here only exercises the case where room and shelf are present. Its passing checks say nothing about network configuration, storage guarantees, or which fields a separate service records in logs.
Turn assumptions into small defensive checks
Start with a replay that exercises the same entry under two explicitly different permission assignments. Verify that the authorized projection contains the documented fields and the route with no permission returns the documented denial. Exercise empty selections and changed source records separately. This gives the tester a concrete expectation without involving any live model or production resource. Keep the data small enough that a reviewer can derive the expected output on paper.
A second test compares route conformance. For a known caller-visible entry, capture the actual fields sent at the model boundary in a test run. Assert the exact allowed key set and check that protected fields never cross it. Verify the output audience separately. For example, the same test should distinguish an answer rendered in the intended session from a response that is never shown. A missing display event cannot be interpreted as evidence that the data boundary worked; the context inspection supplies the evidence for that boundary.
A test report should explain which parts of the system it observed. The toy checks above operate on a dictionary constructed from a known record. They do not run the application that owns identity and storage. Detailed checks of external implementation can be added when inspecting a real repository. Start with the component named in the threat model and trace it to the normal call path, including any background variants. That makes changes to the map auditable when a future engineer moves the boundary or adds a new fallback.
Keep fixtures and modeling assumptions in version control with the corresponding design description. A changed expected key set in a test can be a purposeful feature decision. The reviewer should be able to read the change and confirm which authority and data decisions it affects. An unchanged test should still fail if the capability or fields exceed the approved scope. Adjust the invariant when requirements change and state why it changed.
A replay for a missing location
Run one more defensive replay using the library's room assignment workflow. In this fixture a source value can be missing during a shelf move. That is an input-state problem, and the scope of both context projections stays the same. The application should show an unavailable status unless it has a designated partial-result policy. This replay represents unavailable as a missing selection in memory. The function accepts only a context dictionary and returns either a pair of strings or no pair. It does not read the catalog or attempt to repair the source value.
PythonIn [15]Expand
def complete_location(context: dict[str, str]) -> tuple[str, str] | None:
room = context.get("room")
shelf = context.get("shelf")
if not room or not shelf:
return None
return room, shelf
missing_shelf = {"room": record.room, "shelf": ""}
assert complete_location(public_context) == ("East", "E4")
assert complete_location(location_context) == ("East", "E4")
assert complete_location(missing_shelf) is None
assert complete_location({}) is NoneThe replay is deliberately small. The function checks presence, and its empty-string convention matters to the test. It treats a nonempty string as present. A real catalog may need to normalize whitespace or validate that a shelf code belongs to the room. If the library defines these conditions, a test should name the validator that enforces them and show a known-valid location and one lacking the required relation. Presence alone establishes only the property we checked above.
You can make a second comparison independent of field coverage. Suppose the recorded room is East in the catalog and the application receives a proposed West, E4. The test can treat the proposed pair as fixture data and reject it because the validated source pair differs. Use a typed interface for proposal fields so the comparison does not have to guess where a room name sits in free-form text.
PythonIn [16]Expand
def matches_selected_location(
proposed: tuple[str, str], context: dict[str, str]
) -> bool:
location = complete_location(context)
return location is not None and proposed == location
assert matches_selected_location(("East", "E4"), location_context)
assert not matches_selected_location(("West", "E4"), location_context)
assert not matches_selected_location(("East", "E4"), missing_shelf)This test deliberately compares the proposal with the record. If the record is outdated, equality can accept an outdated answer. That limitation tells the reviewer where to add another check. It is a question about catalog maintenance rather than about the type of the proposal or which fields the renderer is allowed to read.
Read the matrix from the perspective of different owners
A library systems administrator can start at the asset column, locate the disputed field, and check what got across the model boundary. A catalog operator can start at the source first and check whether the record matched the physical location at the time it was updated. The two investigations might end up in the same review, but they ask for different evidence. To investigate a stale shelf, the operator might ask for a record update time. To investigate model scope, the application owner needs the shape of the actual context request. The observed update time cannot establish the context shape.
A review can ask all three questions using a single benign replay while recording different observations. First, does the current reader pass the read check? Second, which fields does the answering component see? Third, does the displayed position match the selected reply data? Collect each answer where the predicate was checked. If the system only records that a request succeeded, it cannot supply any of these distinctions later. If it stores the entire record to supply all distinctions at once, that introduces a new data flow that merits review.
The most practical change log for this exercise traces the changed cell back to an owner and a requirement. If location-only starts carrying the title, explain which task now needs it. If staff note starts reaching another component, identify what rule makes that transfer legitimate and whether the component's access scope is appropriate. If the renderer is replaced, inspect the new component's audience binding and output check separately. This is the kind of maintenance threat modeling supports: specific questions about changed responsibilities rather than redoing a generic checklist from memory.
Limitations of threat modeling for AI systems
Our model specifies one entry, two projections, a read authorization check, and one output route. Systems that use caches or background jobs will need those transfers in the model too. Revisit the relevant boundaries when a new component can receive data or select an operation. The NCSC's secure AI design guidance places threat modeling and mitigations alongside functionality and the deployment environment in design decisions.
Three outcomes remain possible under both designs. The catalog can be stale, the renderer can be unavailable, and control implementation can diverge from the map. The map helps the team name a responsible owner for each outcome and choose an appropriate check. Availability needs a failure-path test. Freshness needs a source owner and evidence about updates. The exposure claim needs inspection of the fields the model receives.
Record uncertainty that can guide later review
What remains after a control is added depends on what that control observes. Removing the title from the model context will not change the room value that the catalog returned. Enforcing a strict display schema prevents arbitrary new fields from appearing through that parser, but a syntactically valid wrong room can still be shown if the application fails to compare it with the available evidence. Report the assumption and the part of the route it governs. Avoid combining those facts into an arbitrary single assurance score.
Real systems may replace the service that retrieves records while leaving the model contract unchanged. A reviewer can ask whether the trust boundary has stayed at the same position even if one service name changed. Perhaps the new retrieval service returns only public fields by default, or perhaps it persists the full record in a temporary cache. Those possibilities imply different data flows regardless of the answer text. Compare the new and old route using the same fixtures before accepting a claim that behavior is equivalent.
Documentation can get out of date incrementally. First someone adds a useful annotation to the response, then a retry is introduced, or a cached result starts being reused by a new view. Record these as changes to crossings when they happen. You need enough detail in the original model to discover which owners should look again, while leaving implementation specifics to verified code and config. A thorough-looking diagram without that update path offers little evidence about the current deployment.
Finally, decide how a reviewer will know that an identified concern was resolved. An impact statement describes what the user or operator would observe. A test measures one or more declared controls. Evidence about the implementation connects the two. In the catalog example, direct inspection of fixture context keys offers evidence against excess model input. A recorded catalog maintenance process supplies different evidence for location freshness. Treat each control as a claim with a scope and an owner.
Summary
At each crossing, record the data that moves, the component that controls the next operation, and the authority it needs. In the catalog example, both architectures send room and shelf to the model, and the broader one sends the title too. The field count records that difference. The access decision and the rendering check have separate owners and separate evidence.
When you take the worksheet to a new system, start by stating the authorized task and its output destination. Then walk the shortest ordinary route for a single record. Inspect the provenance of decisions about scope, and map all data copies observed at that scope. As you add paths for unavailable dependencies, identify who chooses them and under what authority. A useful finish is a pair of fixture scenarios that reach the same boundary under different permission states. Treat claims about which data arrives, whether the operation can proceed, and where the response goes as separate test outcomes.
If you remove a task or retire a capability, revisit the boundary map. A former writer or external receiver may no longer belong in the allowed route. Deleting it from the drawing does not remove it from the implementation. The owner should verify that only the intended paths remain in the deployed configuration, including paths reached by retries and alternative user interfaces. The tests here provide examples of expected outcomes at selected crossings.
The next chapter considers how to keep retrieved content in a data role when a model interprets it.
Key Parameters
The important parameters in this notebook describe the example's scope. They are declared as names, view definitions, and conditions rather than model settings. Changing one of these values changes what you can infer from the run.
| Parameter | Value in the fixture | What to inspect before changing it |
|---|---|---|
| Requested operation | Read one catalog location | Locate all branches that can read the record, including retries. |
| Reader visibility | Current identifier set evaluated by the membership check | Verify identity binding and document when the application reevaluates permission. |
| Full public view | Title, room, shelf | Confirm each field is visible for the intended model request. |
| Location-only view | Room, shelf | Confirm the task can be answered without passing the title to the model. |
| Rendering audience | Current client session | Verify the reply route under session changes and retries. |
| Staff-note handling | Available to the application and excluded from both modeled contexts | Identify other places the field could appear, such as a diagnostics system. |
Use these values to explain a changed test result. For example, when a new viewing task needs the title, that change belongs in the definition of the task before you add the title to the narrow view. If the new task also allows a new audience, update the response boundary as a separate change. The checks will then tell you which expected behavior changed and which constraints should continue to apply.
Quiz
Ready to test your understanding? Take this quick quiz to reinforce what you've learned about threat modeling compound AI systems.
Threat Modeling Compound AI Systems
Join the discussionAsk a question or share what you learned.
Keep exploring
Reference
Citation details
Cite or share this article.


Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!