Advanced2 hr 10 min8 implementation labs5 hostile paths

Build Governed spatial agent run

An eight-lab, source-bounded workshop for the complete agent run lifecycle: exact commands and events, durable records, replay, concurrency, unknown outcomes, hostile fixtures, a maintained capstone, and production exit evidence.

Durable boundaryagent run · 7 states · 6 transitions · 6 event identities

Freeze the evidence boundary first

This curriculum teaches the durable host workflow around reviewed Mappls surfaces. It does not manufacture provider endpoints, callbacks, resource states, entitlement, or completion evidence.

The journey blueprint and application event contracts are implementation guidance, not Mappls provider payload specifications.Only linked normalized contracts and source guides may define provider request syntax; empty evidence is never backfilled.The simulator and maintained capstone operate in explicit fixture mode and make no entitlement claim.Credentials, precise production payloads, opaque native objects, and provider secrets stay outside workshop inputs and durable examples.
Lab 1 · 15 min

Model the lifecycle before the UI

Turn the agent run blueprint into an explicit aggregate boundary owned by the application.

Build

asked: A stable run records the user's objective, scenario, actor, tenant, purpose, and bounded inputs before any provider access.planned: A schema-valid allow-listed dependency graph, risk class, scopes, argument bounds, and canonical plan hash are available for inspection.approved: An attributable person approved the exact plan hash, every required scope, purpose, data boundary, policy version, and expiry.executing: A service-side lease owns execution and calls each Mappls tool only after dependencies and authorization are satisfied.completed: The grounded answer, structured outputs, exact tool evidence, provenance, citations, cost, and terminal audit event are committed.rejected: A named approver denied the proposed plan with an attributable reason and no provider calls occurred.failed: Execution stopped with a typed, secret-safe error and retained evidence for every completed step.

Prove before continuing

Every persisted state exists in the reviewed blueprint.Terminal states reject ordinary forward commands.Recovery text is operational guidance, not another hidden state.
Lab 2 · 20 min

Implement every command and event pair

Make intent, actor authority, allowed source state, committed state, and emitted fact reviewable together.

Build

ask by Application user: new aggregate → asked; emit agent.question_received.create_plan by Agent planner: asked → planned; emit agent.plan_created.approve_plan by Human approver: planned → approved; emit agent.plan_approved.reject_plan by Human approver: planned → rejected; emit agent.plan_rejected.start_execution by Execution service: approved → executing; emit agent.execution_started.complete_execution by Execution service: executing → completed; emit agent.execution_completed.

Prove before continuing

ask resolves to governed-spatial-agent-run-agent-question-received without claiming a provider webhook payload.create_plan resolves to governed-spatial-agent-run-agent-plan-created without claiming a provider webhook payload.approve_plan resolves to governed-spatial-agent-run-agent-plan-approved without claiming a provider webhook payload.reject_plan resolves to governed-spatial-agent-run-agent-plan-rejected without claiming a provider webhook payload.start_execution resolves to governed-spatial-agent-run-agent-execution-started without claiming a provider webhook payload.complete_execution resolves to governed-spatial-agent-run-agent-execution-completed without claiming a provider webhook payload.
Lab 3 · 15 min

Persist restart-safe records

Separate business identity, provider evidence, command receipts, immutable facts, audit, and downstream delivery.

Build

Agent run: Durable objective, lifecycle, version, risk, actor, tenant, and purpose boundary. Keys: runId, state, version, tenantId, question, risk.Plan manifest: Canonical tool graph, dependencies, arguments, requested scopes, and integrity identity. Keys: planVersion, planHash, plannerVersion, steps, requiredScopes, policyVersion.Approval grant: Independent attributable authority for one exact plan and bounded time window. Keys: planHash, approvedBy, approvedScopes, purpose, approvedAt, expiresAt.Tool evidence: Resolved arguments, structured response, provider provenance, status, timing, and stable request identity. Keys: toolCallId, stepId, tool, requestId, provenance, completedAt.Grounded result: Answer and machine-readable outputs with per-step citations and inference labels. Keys: runId, answer, citations, generatedAt, modelVersion.

Prove before continuing

Process restart restores the same aggregate version and command result.Opaque SDK or native UI objects are not durable records.Provider evidence and application decisions remain distinguishable.
Lab 4 · 15 min

Make concurrency and replay deterministic

Apply optimistic expected versions and aggregate-scoped idempotency before executing effects.

Build

The model never receives Mappls or customer credentials.Only schema-valid allow-listed tools and bounded arguments can enter a plan.Approval names the canonical immutable plan hash and every required scope.An expired, superseded, partially scoped, or self-approved plan cannot execute.Every factual provider claim is traceable to retained Mappls provenance.Tool failures and persisted evidence never expose secrets.

Prove before continuing

An exact replay returns the first result without another event or version.A reused key with different intent conflicts.A stale expected version changes no durable truth.
Lab 5 · 15 min

Control effects and unknown outcomes

Commit outbox intent atomically, execute effects outside the transaction, and reconcile ambiguous results.

Build

Prompt or retrieved content asks for an unapproved tool: detect with The proposed tool, scope, host, or argument is absent from the validated plan policy. Recover with Reject the plan or stop execution and surface the exact policy denial for human review.Plan changes after approval: detect with Recomputed canonical hash differs from the approved plan hash. Recover with Refuse execution, append a tamper or supersession event, and require a new review.Provider call succeeds but the worker loses its response: detect with Execution lease expires with an ambiguous step and stable request identity. Recover with Reconcile by provider or application request identity before retrying, especially for side-effecting tools.Tool output lacks provenance or contains a secret: detect with Response-envelope validation or redaction policy fails. Recover with Quarantine the output, stop the run safely, rotate any exposed secret, and retain only a sanitized incident record.

Prove before continuing

A timeout remains an unknown outcome until identity-based reconciliation completes.Retries are bounded and preserve the original business and command identities.Dead-letter or manual review retains the entire attempt history.
Lab 6 · 15 min

Run all hostile fixture scenarios

Exercise the success path plus replay, concurrency, state, and response-loss failures without an account.

Build

Complete journey: Commit the shortest reviewed success path to the journey-specific operating target.Idempotent replay: Repeat one command identity and prove that version, event identity, and side effects do not duplicate.Stale version: Reject a command based on an outdated aggregate version without changing durable truth.Invalid transition: Reject a known command when the current state does not permit it.Unknown outcome recovery: Reconcile after a lost response, then replay the original command identity safely.

Prove before continuing

All fixture checks pass for all five scenarios.Rejected commands emit no event and do not increment version.The fixture makes zero provider calls and exposes no write tool.
Lab 7 · 20 min

Trace the Spatial Operations Agent capstone

Follow the maintained source through domain rules, adapter seam, repository transaction, HTTP boundary, UI evidence, and restart test.

Build

Run the app's declared test suite (15 tests).Run fixture mode without a credential.Inspect audit and outbox evidence after each transition.Restart the process and continue the same aggregate.

Prove before continuing

The downloadable archive checksum verifies before execution.The capstone covers the journey target without inventing provider completion.Browser and HTTP surfaces report the same durable version.
Lab 8 · 15 min

Qualify the real integration boundary

Replace only reviewed adapter seams and collect independent production evidence without weakening application invariants.

Build

Runs and time spent in asked, planned, approved, and executing statesApproval, rejection, expiry, and scope-reduction rate by risk classPlan hash mismatch, policy denial, and prompt-injection detectionTool latency, quota, retry, reconciliation, and cost by operationProvider provenance and citation coverageSensitive-location access by tenant, actor, purpose, and retention classExecution leases, orphaned attempts, outbox backlog, and restart recovery

Prove before continuing

Exact product entitlement and regional behavior are validated separately.Provider contract tests cover success, rejection, throttling, timeout, and unknown outcome.Security, privacy, operations, rollback, and product owners approve exact evidence.Fixture completion is never presented as provider or production completion.

Application-owned reliability scaffolds

The aggregate and SQL examples implement host truth; the fixture clients call the credential-free Journey Lab. Replace only the separately reviewed provider adapter seam.

Governed spatial agent run workshop scaffolds
type State = "asked" | "planned" | "approved" | "executing" | "completed" | "rejected" | "failed";
type CommandName = "ask" | "create_plan" | "approve_plan" | "reject_plan" | "start_execution" | "complete_execution";

type Command = {
  name: CommandName;
  aggregateId: string;
  expectedVersion: number;
  idempotencyKey: string;
};

const transitions = {
  "ask": { from: [null], to: "asked", event: "agent.question_received" },
  "create_plan": { from: ["asked"], to: "planned", event: "agent.plan_created" },
  "approve_plan": { from: ["planned"], to: "approved", event: "agent.plan_approved" },
  "reject_plan": { from: ["planned"], to: "rejected", event: "agent.plan_rejected" },
  "start_execution": { from: ["approved"], to: "executing", event: "agent.execution_started" },
  "complete_execution": { from: ["executing"], to: "completed", event: "agent.execution_completed" },
} as const;

export function decide(current: { state: State | null; version: number }, command: Command) {
  const rule = transitions[command.name];
  if (command.expectedVersion !== current.version) throw new Error("version_conflict");
  if (!rule.from.includes(current.state as never)) throw new Error("invalid_transition");
  return {
    state: rule.to as State,
    version: current.version + 1,
    event: rule.event,
    idempotencyKey: command.idempotencyKey,
  };
}

// Persist the result, immutable event, audit row, and outbox intent atomically.
// Store the first result by idempotencyKey before executing another effect.

Exit with reviewable evidence

All 6 reviewed transitions are implemented with actor and source-state checks.All 6 application event identities are immutable and versioned.Exact replay, idempotency conflict, stale version, invalid transition, and unknown outcome are tested.Aggregate, event, audit, command result, and outbox intent commit atomically.The Spatial Operations Agent capstone passes 15 declared tests after archive checksum verification.Provider entitlement, payload, callback, completion, and production behavior remain independently evidenced.
Workshop completion is not production authority

Workshop completion proves an application-owned reliability design only. Production still requires issued entitlement, exact adapter contract tests, regional and quota validation, security/privacy review, operational drills, and independent release approval.

Trace every external claim to an indexed source

Break the application before connecting the provider.

Run all five hostile scenarios and the maintained capstone test suite. Then qualify the exact provider seam under independently reviewed non-production entitlement.