Skip to Content
Recodocs

14 · Verify safety boundaries

Use the same F-250 request in two signed-in sessions and verify exactly what each session receives.

7 min read
Part 4
Operate and release
Model
Qwen2.5-1.5B-Instruct
Data
Synthetic facilities helpdesk
Hardware
Tesla T4 and CPU, in Google Colab
Open in Colab

Should the desk show the F-250 inspection date?

A Facilities Helpdesk operator has fan F-250 selected and asks when it was last inspected. The date belongs to the yard that owns the fan. A second operator asks the same question with the same fan selected. Before the desk replies, which piece of information decides who gets the date?

Industrial ventilation fan illustrating the selected F-250
Facilities Helpdesk · Inspection record

“When was F-250 last inspected?”

Selected asset F-250
From sign-in
Operator · north-yard or south-yard
Check which operator gets the date

The North Yard session returned 2025-11-08. The South Yard session used the same proposal and attempted a scoped read, but returned no record.

Synthetic inspection record. Augapfel’s factory fan photograph illustrates the selected fan. CC BY 2.0.

Change one fact. Hold the request, operation, selected fan and operator role fixed. Change the tenant supplied by sign-in.

Signed-in tenantWhat the desk should do
North Yard, which owns F-250Return the inspection date from the yard’s record.
South YardKeep the response empty after the scoped lookup.

The request identifies the record the operator wants. The signed-in session supplies the tenant that may read it. AWS’s reference architecture uses temporary session tags to carry a tenant ID into the resource check for services including DynamoDB. AWS Security, SaaS tenant isolation

The model missed authorised reads while the dispatcher kept the other sessions empty

Exact status and response on the same matched requests

1
ProposalStrictAllowed datesBlocked releases
Structured proposal96/9624/240/72
Model proposal78/9615/240/72
Paired sampleModel − structured (pp)95% interval (pp)
All matched sessions−18.75−25.00 to −12.50
Owner sessions−37.50−50.00 to −25.00
Source: verified Lesson 14 T4 export. Dispatch ran on the attached host CPU.

Give the dispatcher the trusted session

The model can propose an operation and an asset. The application provides the signed-in tenant and role, the selected asset and cancellation state. The host checks the session before it examines the proposal and checks the selected asset before a read. The inventory function applies the tenant and asset together.

# Reject unusable proposals before the selected asset can reach the read.
elif not valid_proposal(proposal):
    status = "invalid"
elif proposal["asset"] != session.selected_asset:
    status = "selection_mismatch"
else:
    lookup_attempted = True
    row = read_inventory(session.selected_asset, session.tenant, session.role)
    status = "ok" if row else "out_of_scope"
    if row:
        result = {"last_inspection": row["inspection"]}

The restrictions serve different purposes. A cancelled request stops before the lookup. A valid proposal in the other yard reaches the tenant-qualified read and receives no matching row. GitHub's fine-grained tokens illustrate a similar division between the resource owner, the selected repositories and the allowed permissions. Shopify's pod mapping illustrates where a shop's data lives. In the helpdesk, finding the right record location and deciding whether the session may see it are separate jobs. GitHub Docs, fine-grained personal access tokens · Shopify Engineering, shard balancing

The other yard reached a lookup. The guest stopped before it.

Host contract scenarios replayed across 12 equipment families

2
ScenarioReadsDatesStatusExact
owner1212ok12/12
guest00denied12/12
other yard120out of scope12/12
cancelled00cancelled12/12
missing asset00invalid12/12
no proposal00invalid12/12
different selection00selection mismatch12/12
unknown yard00denied12/12
owner repeat1212ok12/12
Source: verified Lesson 14 T4 export. Dispatch ran on the attached host CPU.

Check what the model hands to the host

The recogniser gets the wording and proposes a read. The notebook emits the same model proposal for all session replays of each wording. The dispatcher can therefore decide what happens to a well-formed F-250 request when only the tenant changes. If the output parser cannot read a proposal, the dispatcher receives an empty object.

Fifteen questions produced a usable proposal

One generated proposal per wording, before session checks

3
Proposal stageQuestionsShare
Asked24
Schema valid15
Selected the exact asset15
Source: verified Lesson 14 T4 export. Dispatch ran on the attached host CPU.

When was F-250 last inspected? · same structured read and selected fan

North Yard · recorded
{"status":"ok","response":{"last_inspection":"2025-11-08"}}
South Yard · recorded
{"status":"out_of_scope","response":null}

The tenant changed in the sign-in session. Each row attempted the same scoped lookup. The other yard received an empty body.

F250-00 · When was F-250 last inspected?

Model proposal
{"operation":"lookup_inspection","asset":"F-250"}
Owner · recorded
{"status":"ok","response":{"last_inspection":"2025-11-08"}}
Other yard · same proposal
{"status":"out_of_scope","response":null}

The proposal recognised the fan. The host still used session scope to decide whether to return the record.

F201-00 · When was P-201 last inspected?

Raw model output
```json {"operation":"lookup_inspection","asset":"P-201"} ```
Owner · expected
{"status":"ok","response":{"last_inspection":"2025-10-13"}}
Owner · recorded
{"status":"invalid","response":null}
Other yard · recorded
{"status":"invalid","response":null}

The Markdown fence made the full string invalid JSON. The owner lost a date they could receive. The other yard still received no date, but the status was invalid instead of out of scope.

The model gave a usable proposal for the F-250 opening in both wordings. On the recorded P-201 request, the model returned an otherwise readable object inside a Markdown code fence. The parser rejected the whole string. For the owner, that lost an allowed date. For the other yard, the same failure still withheld the date, but produced invalid before the scoped read could produce out_of_scope.

Score the decision and the disclosure separately

The desk must both decide correctly and avoid disclosing material outside the operator's authorization. A helpful answer can fail the second requirement even when the first is met.

A dispatch passes the strict grade only when its exact status and response match. Let B denote the blocked sessions and A the sessions expected to receive a date. An unexpected non-empty response in (B) counts as a scope exposure. An empty response in (A) counts as a false denial. A wrong returned date is counted separately.

escope=∑i∈B1[ri≠∅]∣B∣edenial=∑i∈A1[ri=∅]∣A∣\begin{aligned} e_{\mathrm{scope}}&=\frac{\sum_{i\in B}\mathbf{1}[r_i\ne\varnothing]}{|B|} \\ e_{\mathrm{denial}}&=\frac{\sum_{i\in A}\mathbf{1}[r_i=\varnothing]}{|A|} \end{aligned}

An empty body kept the boundary even when the status missed

Exact response and date release by matched session scenario

4
Session / proposalExactEmpty allowedBlocked release
owner
Structured proposal
24/240/24—
guest
Structured proposal
24/24—0/24
other yard
Structured proposal
24/24—0/24
cancelled
Structured proposal
24/24—0/24
owner
Model proposal
15/249/24—
guest
Model proposal
24/24—0/24
other yard
Model proposal
15/24—0/24
cancelled
Model proposal
24/24—0/24
Source: verified Lesson 14 T4 export. Dispatch ran on the attached host CPU.

For the paired change, compare each wording and scenario under both input arms. Resample the equipment family as a whole so the family's related wordings and sessions stay together. The estimate uses model minus structured strict accuracy.

si=1[d^i=di]⋅1[r^i=ri]Δ^=1n∑i(si,model−si,structured)\begin{aligned} s_i &= \mathbf{1}[\hat d_i=d_i] \cdot \mathbf{1}[\hat r_i=r_i] \\ \widehat{\Delta} &= \frac{1}{n}\sum_i (s_{i,\mathrm{model}}-s_{i,\mathrm{structured}}) \end{aligned}

On owner sessions alone, the model lost 9 of 24 strict passes, a paired difference of −37.50 points (95% interval −50.00 to −25.00). Both arms withheld dates on every blocked request in this sample. That count describes the particular sessions and dispatcher exercised here.

Check what the audit keeps

The dispatch stores only the outcome status and a marker for whether data was returned. The synthetic worked evidence contains messages and dates in a separate teaching artefact. In the minimal audit, a reviewer can see whether the desk returned a value, but cannot reconstruct which date or request the event refers to. Google documents a metadata audit level for GKE resources including Secrets, where request and response body capture is a separate choice. Google Cloud, GKE audit policy

# Keep the response body out of this audit event.
audit.append({"status": status, "returned": result is not None})

Audit events recorded the decision and whether a value left the desk

300 recorded host dispatches across both experiments

5
Stored fieldsExample returnedExample blocked
returnedtruefalse
statusokdenied

0/300 events held request or response body fields.

Source: verified Lesson 14 T4 export. Dispatch ran on the attached host CPU.

Separate recognition time from permission checks

The model batch timer includes formatting, tokenisation and generation. The host dispatch timer includes the scoped read when one is attempted and appending the audit event. Compare the figures at their own measurement boundaries. Google’s Zanzibar paper serves authorisation as a separate service and reports its own Check API latency. A local dispatch median here describes a different workload. Pang et al., Zanzibar, §§2.1–2.2 and Table 2

Proposal generation and host dispatch ran on different clocks

T4 generation batches and separate CPU dispatch medians

6
GenerationQuestionsWall time (ms)
First batch42863.6
Batch 24751.3
Batch 34953.1
Batch 44927.6
Batch 541032.5
Batch 64817.3
Host pathMedian dispatch (µs)
Structured proposal4.60
Model proposal0.91

Model and tokeniser load took 15.61 s.

Source: verified Lesson 14 T4 export. Dispatch ran on the attached host CPU.

What to keep

DecisionRecorded resultOperating rule
Same-yard operator and selected fanStructured returned 24/24 authorised dates. The model path returned 15/24.Bind the read to the selected asset and the signed-in tenant.
Other-yard operatorEach arm returned zero dates. The model arm recorded nine invalid proposals.Check both the body and the stop reason.
Cancelled requestBoth arms recorded 24/24 cancellations with zero lookup attempts.Read cancellation state before dispatch.
Different selected assetThe contract matrix recorded 12 selection mismatches with zero lookups.Compare the proposed asset against the trusted selection.
Audit eventAll 300 stored events used the same two fields.Keep message and record bodies out of the event.

The scope and cancellation checks are local and use a frozen fixture registry. Authentication, deployed datastore isolation and distributed cancellation require their own measurements.

Next to try, not tested here

  • Update the selected equipment through a trusted UI event. Check whether the prior proposal is stopped.
  • Change the date in a separate test record. Check whether an otherwise identical authorised request returns the new date.
  • Add an opaque correlation key to the audit record. Check that the event shape still excludes request and response bodies.

How it was built

ItemSetting
Development dataSynthetic Facilities Helpdesk, 12 equipment families, two wordings per asset and four paired session scenarios.
Development SHA-25651dbc208b6b20a620237dd76ce0a2db4f10aa75f4f8fc404121e301b8d79a0cf
Separate contract matrix108 dispatches, including an owner repeat for each family.
Model and revisionQwen/Qwen2.5-1.5B-Instruct at 989aa7980e4cf806f80c7fef2b1adb7bc71aa306.
GenerationGreedy, batches of four, up to 32 new tokens. Exact JSON parser.
Record boundaryHost CPU checks the session and proposal and performs the tenant-qualified read.
Strict gradeExact status and exact response, 1,500 paired family-bootstrap draws.
RuntimeTesla T4, CUDA 13.0, Python 3.13.16, PyTorch 2.14.1+cu130, Transformers 4.51.3.

Time and cost. The verified notebook took 39.2 s on the Colab T4 and its host CPU. Model and tokeniser load took 15.61 s within that execution. The median generation batch took 940.3 ms. The reported time covers notebook execution.

Executed notebook · Summary JSON · Raw records JSON · Runtime JSON

Run it yourself

Read the opening and dispatcher to check which inputs carry authority. Use the contract matrix for the trusted session cases, then follow proposal generation and matched replay to reproduce the strict grades. The final cells check the audit shape and timings.

  1. Hold the question and F-250 selection fixed. Change only the signed-in tenant. Predict whether the read runs and which body returns, then inspect opening.owner and opening.other_yard.
  2. Cancel the owner request. Predict whether the inventory function runs, then inspect lookup_attempted, status and returned.
  3. Replace the structured proposal with an empty object and keep the owner session fixed. Predict the stop status, then compare the response and audit event with the successful F-250 read.

Continue to Lesson 15, Make a release decision.

How is this page?

Last updated on