In Part 1, I looked at one narrow roaming failure: a traveler's phone shows full bars and 5G, yet nothing loads—and the home operator cannot tell whether the fault sits inside the visited network.
The idea was simple: keep raw telemetry in-country and ship one bounded question instead.
This post shows how to build that channel safely. It is a worked example, not a shrink-wrapped telecom product—so before any code, here is an honest inventory of what actually runs today, what is simulated, and what is still missing.
The two operators below—OpCo FR (home) and OpCo DE (visited)—are fictional sister companies in the same telecom group.
Status at a Glance: Real vs. Simulated vs. Missing
| Status | Component | Details |
|---|---|---|
| 🟢 Works today | Discovery, DLP, 30s Grant, Offline Verify & Receipts | did:web key discovery, strict JSON Schema + Telecom DLP blocking raw IMSI/MSISDN, a 30-second single-use Ed25519 grant bound to the request hash and allowed_checks, offline verification by the executing service against its locally pinned gateway key, a local hash-chained SQLite WAL audit log, and receipts signed by both the executing service and the gateway (plus the caller's token signature when present). |
| 🟡 Simulated | Network Telemetry & Pseudonym Key | Synthetic visited-network sessions (Berlin congestion, Munich silent blackhole, Zurich velocity spike, Frankfurt fraud burst) and a fixed demo HMAC key for session_ref. |
| ⚪ Not built yet | Production Federation Ops | Automatic daily HMAC key exchange for key_epoch, a detached did:web caller signature over the raw request body bound into the receipt digest, historical key lookup for old receipts, a shared cross-company trust registry (beyond the gateway's local partner list), and wholesale settlement. |
1. The Single Allowed Question
OpCo FR's agent can ask OpCo DE exactly one thing:
"For this pseudonymised session, in this coarse cell group, over the last few minutes: is something failing on your side?"
OpCo DE replies with one status code from a fixed vocabulary—such as visited_ran_congestion, user_plane_blackhole, session_not_found, or ok—plus coarse buckets (low / medium / high / saturated) and a suggested home action. No raw logs. No packet traces. No phone number.
(The skill schema also defines bill_risk and fraud checks for future experiments. This walkthrough focuses on connectivity because Part 1 argued it is the strongest real-world case—and the gateway's default grant only authorizes ["connectivity"].)
2. Threat Model: Who Are We Protecting Against?
Any security architecture is meaningless without naming the threats it does—and does not—address.
| Protected Against | Not Protected Against |
|---|---|
1. A tricked or prompt-injected AI agent trying to widen its query, smuggle a raw IMSI/MSISDN, or pivot to another tool. | A dishonest partner that simply returns fabricated network answers. |
| 2. A bypassed gateway inside OpCo DE's network—if someone hits the executing service directly, it still refuses any unapproved, expired, replayed, or modified call. | A compromised private signing key (production deployments need HSM/KMS custody and revocation). |
| 3. Post-incident finger-pointing weeks later over what was asked, under whose permission, and what came back. | An overly permissive policy—if the gateway policy approves too much, the cryptography faithfully enforces that mistake. |
3. "Why Not Just a Normal API With mTLS?"
For conventional, deterministic software, mTLS + OAuth + strict schema validation + good logging is often enough—and simpler.
The extra cryptographic machinery earns its keep when the caller is an AI agent whose parameters and tool choices vary from call to call. A standard bearer token authorizes the caller; it does not cryptographically lock this specific request or let the downstream executor verify it offline.
| Security Question | Standard API + mTLS / OAuth | Trust Gateway |
|---|---|---|
| Is the transport encrypted? | Yes | Yes (run over mTLS too) |
| Is this exact request authorized? | Not by default | Yes — 30s grant bound to the canonical SHA-256 hash of the parameters |
| Does the executing service verify approval offline? | Usually trusts the upstream proxy | Yes — checks signature, TTL, hash, scope & replay locally |
| Is there a signed record both sides can check? | Separate, mutable local logs | Yes — receipt signed by provider + gateway (full caller did:web body sig ⚪) |
| How are partner keys discovered? | Manual certificate/secret swaps | Public key published at /.well-known/did.json (did:web) |
Standing on prior art: None of these primitives are invented from scratch—OAuth Rich Authorization Requests (RFC 9396), DPoP (RFC 9449), HTTP Message Signatures (RFC 9421), UCAN, and Biscuit all narrow authority beyond plain bearer tokens. What Trust Gateway packages together for agent callers is: per-call parameter-bound grants + offline executor checks + signed receipts + did:web discovery.
An honest sanity check: If a diagnostic query never varies, you don't need an AI agent to call it—a fixed script will do. This architecture becomes essential as soon as autonomous agents begin choosing, chaining, and parameterizing cross-company tools on their own.
4. The Five-Step Execution Flow
OpCo FR (Home Network) OpCo DE (Visited Network) ────────────────────── ───────────────────────── 1. Publishes skill manifest & Ed25519 public key via did:web 2. Agent builds bounded query (pseudonym + cell_group + checks) ──────────▶ 3. Trust Gateway (Firewall): • Authenticates caller • Enforces strict JSON Schema • Blocks raw IMSI / MSISDN (DLP) • Mints 30s, single-use Ed25519 Grant bound to canonical SHA-256(params) 4. Skill Executor (Independent Verify): • Verifies Grant offline w/ pinned pubkey 5. Home acts on coarse verdict ◀─────────────── • Checks hash, TTL, allowed_checks, JTI (steer to alternate partner, • Queries local 5-min telemetry in-country or open targeted ticket) • Returns verdict + signed receipt Two properties do the heavy lifting:
- Zero shared static passwords across companies. OpCo DE resolves partner public keys via
did:weband caches them with a short TTL. Rotating or revoking a key cuts off new calls once the cache expires. - Defense in depth (two independent gates). Even if an attacker bypasses the gateway entirely, the executor rejects any request whose grant is missing, expired, replayed, forged, widened, or altered by a single byte.
And remember the operational fallback: security is fail-closed, business continuity is graceful. If OpCo DE does not reply within a tight timeout, OpCo FR simply falls back to its existing troubleshooting flow.
5. Inside the Four Building Blocks
(The snippets below are trimmed for readability; full Rust code lives in third_party_agent/src/roaming.rs, trust-engine, and trust-sdk.)
Block 1: A Strict, Zero-PII Input Contract 🟢
The skill (io.lianxi.skill.diagnose_roaming_session@v1, exposed as diagnose_roaming_session) locks down every field and sets additionalProperties: false—so there is nowhere to smuggle a phone number or extra metadata. Before any grant is minted, the gateway's inbound Telecom DLP gate also actively scans and rejects raw 14–15 digit IMSI or E.164 MSISDN values.
{ "id": "io.lianxi.skill.diagnose_roaming_session@v1", "name": "diagnose_roaming_session", "input_schema": { "type": "object", "additionalProperties": false, "required": ["session_ref", "key_epoch", "cell_group_id", "checks", "window_s"], "properties": { "session_ref": { "type": "string", "pattern": "^hmac-sha256:[a-f0-9]{64}$" }, "key_epoch": { "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$" }, "cell_group_id": { "type": "string", "pattern": "^cg_[a-z0-9]{6,12}$" }, "checks": { "type": "array", "minItems": 1, "maxItems": 3, "items": { "type": "string", "enum": ["connectivity", "bill_risk", "fraud"] } }, "window_s": { "type": "integer", "minimum": 60, "maximum": 600 } } } } (The version lives inside id rather than the did:web identifier because @ is invalid in did:web syntax.)
Why HMAC-SHA256 instead of a plain hash? Because subscriber IDs (IMSI/MSISDN) come from a small, structured number space—a plain SHA-256 hash can be brute-forced in minutes. Keying the hash with a daily rotating secret (key_epoch) prevents offline rainbow-table reversal (currently a fixed test key in the demo 🟡).
GDPR note: Because both operators can recompute
session_refwithin the same day, it is pseudonymised personal data, not anonymous data. It dramatically shrinks the blast radius (fewer logs and systems ever touch raw subscriber IDs), but still requires a valid legal basis and bilateral data-processing terms.
Block 2: A 30-Second, Single-Use, Parameter-Bound Grant 🟢
Only after schema and DLP checks pass does the gateway mint an Ed25519-signed ExecutionGrant valid for 30 seconds, pinned to the RFC 8785 canonical SHA-256 hash of the exact arguments:
{ "grant_id": "eg_01J9X8K4M2P7Q9R1", "issuer": "did:web:trust.lianxi.io", "caller_did": "did:web:agents.opco-fr.lianxi.io", "skill": "diagnose_roaming_session@v1", "allowed_checks": ["connectivity"], "bound_params_sha256": "sha256:7d3b91a4e0c8...", "issued_at": "2026-11-16T19:42:10Z", "expires_at": "2026-11-16T19:42:40Z", "single_use": true, "gateway_sig": "ed25519:91f4c8a2d003..." } Notice "allowed_checks": ["connectivity"]. Even though the skill schema supports "fraud", this grant explicitly forbids it—and the executor enforces that boundary independently.
(Remember: cryptography only enforces what policy authorizes. The gateway's policy engine—not the signature—decides who gets which checks.)
Block 3: Offline Verification Inside the Executor 🟢/🟡
The executing service (third_party_agent) does not blindly trust the gateway or follow key URLs embedded in the token. It verifies the grant completely offline against a locally mounted Ed25519 public key (grant_signing.pub.pem).
Here is simplified pseudocode mirroring the Rust verifier in third_party_agent/src/roaming.rs:
PINNED_GATEWAY_PUBKEY_PEM = load_local_file("/app/keys/grant_signing.pub.pem") EXPECTED_SKILLS = {"diagnose_roaming_session", "io.lianxi.skill.diagnose_roaming_session@v1"} def execute_roaming_check(grant_jwt, params): # 1. Offline cryptographic & policy verification (zero network calls) claims = verify_ed25519_jwt(grant_jwt, PINNED_GATEWAY_PUBKEY_PEM) assert not is_expired(claims["exp"]) assert claims["tool_name"] in EXPECTED_SKILLS assert claims["caller_did"].startswith(("did:web:", "did:twin:")) assert canonical_sha256(params) == claims["input_hash"] # blocks 1-char tamper assert set(params["checks"]) <= set(claims["allowed_checks"]) # blocks scope creep consume_jti_once(claims["jti"]) # blocks replay # 2. Local in-country telemetry lookup (synthetic in demo 🟡) session = local_vplmn_store.lookup(params["session_ref"], params["key_epoch"], params["cell_group_id"], params["window_s"]) if not session: return verdict("session_not_found") if session.ran_prb_load > 0.92: return verdict("visited_ran_congestion", action="trigger_sor_refresh_to_alternate_vplmn") # Attached + attempted PDU setup + almost zero uplink traffic if session.attached and session.pdu_setup_attempts > 0 and session.uplink_bytes < 1_000: return verdict("user_plane_blackhole", confidence="medium", action="trigger_sor_refresh_and_reset_pdu_session") return verdict("ok") Why user_plane_blackhole is deliberately "medium" confidence: Near-zero uplink traffic can also happen when a phone is simply sitting idle in someone's pocket. Returning "medium" confidence signals the home operator to corroborate with its own home-routed metrics before resetting a customer's session.
Change even one character of cell_group_id after the grant is issued and canonical_sha256(params) != claims["input_hash"] fails immediately—offline, before the telemetry store is ever touched.
Block 4: A Tamper-Evident Signed Receipt 🟢
After execution, the provider signs (action_id, grant_jti, output_hash, status) via X-Lianxi-Provider-Signature, and the gateway countersigns the full ExecutionReceipt and appends it synchronously to its hash-chained SQLite WAL audit store:
{ "receipt_id": "rcpt_8841a9f02c", "grant_jti": "eg_01J9X8K4M2P7Q9R1", "capability_id": "io.lianxi.skill.diagnose_roaming_session@v1", "input_hash": "7d3b91a4e0c8...", "output_hash": "4e10c8b7f291...", "issuer_did": "did:web:trust.lianxi.io", "counterparty_did": "did:web:agents.opco-fr.lianxi.io", "outcome": "success", "executed_at": "2026-11-16T19:42:10.318Z", "latency_ms": 184, "finops_unit": "1_tier1_roaming_guard_eval", "signature": "ed25519:c70e119a4f88...", "provider_sig": "ed25519:4a91e0b8c312...", "grant": { "... 30-second ExecutionGrant summary ..." } } Read the trust model of this receipt carefully:
- Both Ed25519 signatures over the receipt (
provider_sigand gatewaysignature) come from OpCo DE's side (the gateway also preservescaller_sigfrom the caller's bearer token when present). That makes the receipt primarily OpCo DE's signed attestation of what it executed. Making it fully bilateral requires OpCo FR's agent to sign the canonical request body with its owndid:webkey and binding that signature into the signed receipt digest (on the roadmap ⚪). - Hashes, not payloads: The receipt stores
input_hashandoutput_hash—never the raw query or verdict—so verifying a dispute later requires the party holding the original JSON to hash it and compare. - No neutral timestamp authority yet: Each gateway maintains its own hash-chained SQLite WAL log, but without an external RFC 3161 timestamp authority, wall-clock timestamps remain self-asserted.
- Key rotation history (⚪): Verifying a receipt months later requires knowing which public key was valid at
executed_at; today's demo verifies against currently published keys.
6. Blind Spots I Still Have
I would rather list these up front than wait for someone in the comments to catch them:
- Sourcing
cell_group_idcleanly: The home operator needs a coarse location hint to ask the question. User-location IEs in roaming signaling often provide it, but availability varies by partner and roaming generation (4G vs. 5G SA). -
did:webinherits DNS/TLS trust: Whoever controls DNS and the web server controls/.well-known/did.json. The gateway restricts execution to a local verified-partner allowlist, but multi-operator production needs a shared cross-company trust registry ⚪. - Key custody: Production signing keys belong in HSMs/KMS with tested rotation and emergency revocation procedures.
- Standards coexistence: This sits alongside 5G SEPP, NWDAF, and GSMA Open Gateway / CAMARA—it does not replace them and would need clean schema mapping.
- Unproven ROI: This proves how to ask safely, not whether the business case pays off. Only a real two-OpCo pilot measuring fault attribution and handling-time reduction can answer that.
- Sister OpCos first, alliances second: Nothing technical restricts this to sister operators—the barrier is commercial (liability, SLAs, data-processing contracts). Sister OpCos inside one group are simply the fastest place to pilot; preferred-partner alliances can follow once a shared trust registry and full bilateral caller signatures are in place.
7. Try All Five Scenarios Live (Zero Sign-Up)
The public sandbox at portal.lianxi.io includes a one-click guest mode ("🧪 Try Instant Guest Sandbox (No Sign-Up)"). Everything runs on synthetic data.
Open the diagnose_roaming_session card and click through the built-in Quick Presets:
- Valid Question (RAN Congestion): Queries
cg_ber01awith a valid HMACsession_ref→ returnsvisited_ran_congestion, the 30-secondreceipt.grant, and the dual-signedExecutionReceipt. - Sneak in a Phone Number (Raw IMSI): Injects
"imsi": "208019988776655"→ blocked by the gateway's Telecom DLP before any grant is minted. - Change One Character (Offline Tamper): Uses the sandbox's
_simulate_post_grant_tamperhook so the gateway mints a valid grant forcg_ber01aand then mutatescell_group_idon the wire → rejected offline by the executor becauseinput_hashno longer matches. - Ask for Fraud Check (Scope Escalation): Requests
["connectivity", "fraud"]→ rejected offline by the executor because the grant only authorizesallowed_checks: ["connectivity"]. - Silent Blackhole (Medium Confidence): Queries
cg_muc02b→ returnsuser_plane_blackholewith"confidence": "medium".
8. When Is This Pattern Actually Worth It?
Roaming is a clean teaching example because the corporate and legal boundary is obvious. The same pattern is worth the complexity whenever all three hold:
- Raw data cannot cross a legal, national, or corporate boundary.
- The caller is an AI agent whose queries vary dynamically, making static shared API keys too broad.
- A third stakeholder (DPO, security lead, regulator, or wholesale finance) needs verifiable proof of what ran.
If only #1 is true and the caller is a deterministic microservice, a plain mTLS API is still the right tool.
Missed Part 1? Read Part 1: Full Bars, Zero Service — Closing the Narrow Roaming Blind Spot Between Sister Operators. Explore the live platform and open artifacts at lianxi.io. Where does this design break down in your environment? I'd love to hear it in the comments.

