Skip to content
Agent Field Notes
Course contentsExpand a topic to choose a lesson.

SYSTEMATIC LEARNING / FOUR-LEVEL COURSE

Tenant isolation and continuous authorization during execution

Build evidence from strict scoped application work to independent recovery/audit, then platform capacity and failure-window decisions.

Learning objectives: Preserve trusted identity and current authorization across data copies, queues, checkpoints and external effects; implement local audits and estimate bounded resources, while declaring unimplemented deployment races and validation.

Content checked: 2026-10-03 · Each level has independent explanations, tasks and inspections

Choose a starting point based on your familiarity with this topic. Current level: Design · Explain the trade-offs. After completing the task, continue to the next level. Reading and self-checks alone do not establish mastery.

On this level

Review the prerequisites

Suitable for: Backend developers learning Agent applications.

Tenant isolation and continuous authorization during execution
Tenant isolation must cover reads, caches, model context, logs, artifacts, and recovery. Establish trusted tenant identity through authentication and service policy, and preserve the same authorization boundaries during every recovery or fallback.

How does the mechanism work?

Step-by-step explanation
  1. How are log and vector indexes isolated?

    Isolation must cover logs and copies of vector data as well as the database.

  2. Why might restoring old backups violate deletion requirements?

    A durable platform must check whether recovery reintroduces deleted data.

  3. What can the execution plane do when the control plane is unavailable?

    A control-plane failure still requires explicit availability boundaries for the execution plane.

Design · Explain the trade-offs

Explain design trade-offs · Tenant isolation and continuous authorization during execution

Objectives of this level: Derive multi-resource capacity and tenant operations, and decide four authorization/replay/recovery failure windows with measurable pending gates.

Visual guide · Carry isolation through the run

Carry isolation through the run

These are platform boundaries to preserve, not a deployed 50-tenant system. Check caches, artifacts, logs and restored context as well as primary reads. Select the figure to open it at full size.

Changed scope: own the platform's failure windows

Design a 50-tenant deployment of this same return-application Agent. Preserve the implemented local invariants; do not claim a diagram deploys shared quota enforcement, tenant scheduling, general outbox, identity federation, encrypted backups or strict cross-service revocation. Those remain proposed integrations unless separately implemented and verified.

Capacity inputs with units and assumptions

These numbers are exercise inputs, not benchmark results, current provider quotas/prices or production experience. This is a separate multi-resource variant from CAREER_PATHS.md’s 300/1200-task, 80-provider-call-slot example; do not combine those inputs or confuse provider call slots with task worker slots. Each task is assumed to occupy active resources for 12 seconds excluding human approval and queue waiting, average 3 model requests, 6,000 token units and 2 tool calls. No retries are included. The 70% planning utilization is an exercise choice, not a universal safe threshold.

{
  "scope": "fictional_capacity_inputs_not_measurements",
  "tenants": 50,
  "peak_tasks_per_min": 120,
  "normal_tasks_per_min": 60,
  "active_seconds_per_task": 12,
  "model_calls_per_task": 3,
  "token_units_per_task": 6000,
  "tool_calls_per_task": 2,
  "worker_slots": 32,
  "model_requests_per_min": 420,
  "token_units_per_min": 840000,
  "tool_requests_per_sec": 10,
  "planning_utilization_percent": 70,
  "burst_minutes": 10,
  "initial_queue": 50,
  "global_queue_cap": 500,
  "tenant_concurrency_cap": 4,
  "tenant_queue_cap": 20
}

Implement plan_capacity in capacity_plan.py before using a reference. All displayed integer fields are required positive exact Python ints except initial_queue may be 0; planning_utilization_percent is 1..100. scope is the exact displayed label. Missing/null/bool/invalid fields raise ValueError("shape"); extra fields are ignored and config is immutable.

def plan_capacity(config):
    raise NotImplementedError("implement plan_capacity")

Return exactly planned_tasks_per_min (workers/model_requests/token_units/tools integer rates), safe_start_rate_per_min, peak_active_slots, uncontrolled_burst_queue and queue_cap_exceeded. Use integer floor for each resource's utilization-adjusted per-minute task rate: worker slots × 60 / active seconds; model RPM / calls; token units/min / units per task; tool requests/sec × 60 / calls. Apply utilization numerator/100 before flooring, then take their minimum. peak_active_slots is ceiling(peak tasks/min × active seconds / 60), before headroom. The uncontrolled burst estimate accepts all offered tasks while starting at the planned minimum: initial_queue + max(0, peak-start_rate) × burst_minutes. It is a fluid estimate, not a measured queue or latency guarantee. overflow means that estimate exceeds global_queue_cap.

Save this unchanged probe as capacity_probe.py beside your implementation:

from copy import deepcopy
import json
from capacity_plan import plan_capacity

config = {'scope': 'fictional_capacity_inputs_not_measurements', 'tenants': 50, 'peak_tasks_per_min': 120, 'normal_tasks_per_min': 60, 'active_seconds_per_task': 12, 'model_calls_per_task': 3, 'token_units_per_task': 6000, 'tool_calls_per_task': 2, 'worker_slots': 32, 'model_requests_per_min': 420, 'token_units_per_min': 840000, 'tool_requests_per_sec': 10, 'planning_utilization_percent': 70, 'burst_minutes': 10, 'initial_queue': 50, 'global_queue_cap': 500, 'tenant_concurrency_cap': 4, 'tenant_queue_cap': 20}
expected = {"planned_tasks_per_min": {"workers": 112, "model_requests": 98, "token_units": 98, "tools": 210},
            "safe_start_rate_per_min": 98, "peak_active_slots": 24,
            "uncontrolled_burst_queue": 270, "queue_cap_exceeded": False}
assert plan_capacity(config) == expected
changed = deepcopy(config)
changed["token_units_per_task"] = 12000
assert plan_capacity(changed) == {"planned_tasks_per_min": {"workers": 112, "model_requests": 98, "token_units": 49, "tools": 210},
    "safe_start_rate_per_min": 49, "peak_active_slots": 24,
    "uncontrolled_burst_queue": 760, "queue_cap_exceeded": True}
invalid = deepcopy(config)
invalid["model_calls_per_task"] = True
try:
    plan_capacity(invalid)
except ValueError as exc:
    assert str(exc) == "shape"
else:
    raise AssertionError("bool must not be a capacity count")
assert config["token_units_per_task"] == 6000
print(json.dumps(expected, sort_keys=True))
print("capacity_assumptions_and_changed_cost_checked")

python3 capacity_probe.py

Expected base: resource rates 112/98/98/210, limiting planned start 98/min, mean-load active slots 24, uncontrolled burst queue 270, no global-cap overflow. Doubling token units changes the token limit to 49/min and burst estimate to 760: overflow. The same worker count cannot solve a provider token bottleneck. Actual latency distributions, synchronized tenants, retries, per-tenant fairness, tool variability and human review need measurement; mean-load arithmetic does not prove a p95 SLO. No price or real model usage is inferred.

From estimates to resource governance and operations

An operator must choose bounded queuing or early rejection/backpressure, not accept an unbounded burst. State per-tenant admission/queue/concurrency, global and provider resource caps separately. A global semaphore alone does not guarantee a small tenant service. Reserve a bounded estimate under a unique task/reservation key; reconcile actual provider usage, retry/tool work and review costs rather than charging a replay twice. Missing usage remains unknown/null. Stop starting work when the relevant budget is exhausted; retain authority and original receipts. Shared reservation atomicity and scheduling are proposed work, not supplied by the arithmetic probe.

Define an operational acceptance plan before rollout: per-tenant oldest queue age and p95 queue wait; admitted/completed/denied/unknown counts with stated denominators; provider rate-limit/retry and utilization; actual cost by usage source; stale-policy denials; receipt conflicts and orphan run/events; deletion/revocation propagation; tenant-scoped audit/export access. For this exercise propose p95 queue wait <=30 seconds and p95 completion <=180 seconds excluding separately reported approval waiting, zero unauthorized body releases and zero duplicate applications. These are targets to test, not observed results. Start with two tenants and an A-heavy/B-small burst plus provider throttling; show B progress, controlled refusal and unchanged receipt/isolation gates. If you cannot run this deployment, mark the measurements pending and supply a test workload and instrumentation plan.

ADR with four required failure windows

Deliver ADR-001-platform-boundaries.md. For each window record the before/after authority and durable facts, rejected alternatives, failure/rollback action, replay rule, residual race and an executable or planned verification:

  1. Permission changes after a read check but before model/body dispatch. A cached TTL alone cannot promise immediate revocation. For a strict no-new-release-after-revoke guarantee, authorization transition and dispatch need a shared coordinator/barrier. Otherwise specify the bounded stale/in-flight allowance; sensitive unknown authority pauses. Data already sent cannot be recalled by local invalidation.
  2. Run/outbox commits; consumer commits; sender dies before delivered mark. Replay the same event and reconcile durable consumer state, but recheck current subject/version before private reads or new effects. Payload authenticity, consumer claim and ordering remain separate. Do not hold a long inference inside a database transaction.
  3. Merchant commits; response is lost; lease expires or cancellation arrives. The original operation key and independent receipt remain authoritative for the effect. Fence stale writers and authenticate reconciliation; a new lease/schema or permission grant is not a new business intention. Local cancel does not undo commit.
  4. Restore an old checkpoint/index/backup while current deletion/permission records are unavailable. Quarantine all consumers, not only the frontend. Obtain newer trusted revocation/tombstone facts before re-serving; unavailable facts leave recovery pending. Rebuild current authorized derivatives. Logical invalidation is not proof of physical erasure of backups or already-sent text.

Compare shared tables/indexes with enforced scope against dedicated partitions/workspaces for high-risk tenants. Include connection-role tests for RLS, queue/cache/artifact/log keys and access, key/credential handling and audit ownership. Migration uses schema-version CAS and old-worker fencing; it still revalidates current authorization instead of copying a historical permit. The workflow-schema-upgrade and task-queue-fairness exercises provide focused local contracts, not a production fleet.

A senior submission is capacity_plan.py plus same-input/changed-cost output, the personal platform audit, a copy-path inventory, budget and fairness acceptance plan, and the ADR with explicit pending deployment checks. A reviewer must challenge a fresh complete constraint and inspect the actual artifacts. Public cases, local pass counts and an architecture document cannot certify employer-level seniority.

career-route; approval; capstone; capstone_zh; rag; memory; outbox; queue; workflow; prereq; protocol; pg; aws; owasp

code example

A replay is not a fresh budget

A task restored under a new worker or schema retains its business intent and budget reservation lineage. Allocating a new operation key or ignoring current authority cannot be justified as rollback.

Acceptance task for this level

Implement capacity_plan.py and run the unchanged/doubled-token/strict-type probe. Deliver ADR-001-platform-boundaries.md, copy-path inventory, per-tenant budget/fairness workload and audit/SLO instrumentation plan; mark unmeasured deployment checks pending.

Acceptance self-checks

Reading this browser’s record…

Hide the answer and check your understanding

Adding workers leaves the 6,000-unit provider limit unchanged. Can it meet every capacity target?

Further explanations and practice

When encountering unfamiliar principles, first read the implementation, continuous questioning and migration cases, and then independently explain the premise and boundaries. Answers and notes are saved to the original account record.

All linked explanations and exercises (1 )

Sources and verification scope

The principles are based on public information; the numbers, cases and tasks are the teaching design of this website. Offline experiments verify the range noted on this page, and the learning effect still needs to be judged through independent tasks and feedback.