> ## Documentation Index
> Fetch the complete documentation index at: https://docs.manthan.systems/llms.txt
> Use this file to discover all available pages before exploring further.

# Examples Overview

> The ten numbered examples under examples/ — what's actually implemented, and what's still a stub

`examples/` is meant as a learning path — run `npm run <script>` from the `examples/` directory for any of the ten, per `examples/package.json` and `examples/README.md`. Each example has its own `README.md` with a `Goal`, `Learn`, and `Run` section.

<Warning>
  **Only three of the ten examples have implemented `run.ts` bodies.** `examples/04-trust-record`, `05-verification`, `06-replay`, `07-human-approval`, `08-vendor-payment`, `09-expense-approval`, and `10-purchase-order` currently contain nothing but a single `console.log("Parmana Example NN - <Title>")` line — no execution, no API calls, no output beyond that string. Their sibling fixture files (e.g. `08-vendor-payment/policy.json`, `08-vendor-payment/transaction.json`) are also empty. Only `01-hello-world`, `02-policy-evaluation`, and `03-runtime-execution` run real code. Treat the "Learn" sections in the still-stubbed examples' READMEs as stated intent, not as a description of what running them today shows you.
</Warning>

## Walkthroughs

### 01 — Hello World

**Goal** (per its README): create the smallest valid `BusinessTransaction`. `run.ts` builds a plain object inline and prints it — it never calls a policy engine, the runtime, or the API:

```ts theme={null}
const transaction = {
  businessTransactionId: "txn-001",
  metadata: { executionMode: "SYNC" },
  authority: { authorityId: "authority-1" },
  authorization: { authorizationId: "authz-1" },
  intent: { intentId: "intent-1", action: "vendor-payment" },
  policy: { name: "vendor-payment", version: "1.0.0" },
  signals: { amount: 2500, riskScore: 15 },
  status: BusinessTransactionStatus.RECEIVED,
  createdAt: new Date(),
};
```

Run with `npm run hello`. See [`examples/01-hello-world/README.md`](https://github.com/parmana-ai/parmana/tree/main/examples/01-hello-world) and [`run.ts`](https://github.com/parmana-ai/parmana/tree/main/examples/01-hello-world/run.ts). As [Guides → Basic Execution](/docs/guides/basic-execution#what-the-bundled-examples-actually-show) notes, this object is missing several fields the canonical [`BusinessTransaction`](/docs/concepts/business-transaction) type requires (`authority.authorityType`, `intent.target`, etc.) — it's illustrative, not a template.

### 02 — Policy Evaluation

Constructs a `PolicyEngine` and calls `evaluate()` directly against an inline policy and signals object. Run with `npm run policy`. See [`examples/02-policy-evaluation/README.md`](https://github.com/parmana-ai/parmana/tree/main/examples/02-policy-evaluation) and [`run.ts`](https://github.com/parmana-ai/parmana/tree/main/examples/02-policy-evaluation/run.ts).

<Warning>
  This example's policy rules use string conditions (`"riskScore <= 50"`) and string actions (`"approve"`). The real `PolicyCondition` type ([Packages → policy](/docs/packages/policy)) is a structured object (`{ signal, greater_than, equals, all, any }`), and `PolicyEngine.evaluateCondition()` only reads `condition.signal` — a plain string condition never matches. Running this example produces `REJECT` / `"no_rule_matched"` for both rules regardless of the `riskScore` value, not the approve/reject split the example's own naming implies. This looks like a bug in the example, not a demonstration of intended behavior — see [Packages → policy](/docs/packages/policy#policyengine-evaluate) for the condition shape that actually works.
</Warning>

### 03 — Runtime Execution

Constructs a `RuntimeEngine` directly with an empty `RuntimePipeline([])` and calls `runtime.execute(transaction as any)`, printing the result. Run with `npm run runtime`. See [`examples/03-runtime-execution/README.md`](https://github.com/parmana-ai/parmana/tree/main/examples/03-runtime-execution) and [`run.ts`](https://github.com/parmana-ai/parmana/tree/main/examples/03-runtime-execution/run.ts). This exercises the lower-level `RuntimeEngine` API from [`runtime`](/docs/packages/runtime) with zero pipeline stages configured — not the `ExecutionTrustApplication`/`RuntimeFactory` path that `POST /execute` actually uses.

### 08 — Vendor Payment

Per its README, the intended goal is "Complete vendor payment workflow," covering `BusinessTransaction`, Runtime, Verification, and Replay together — the closest thing in this directory to an end-to-end scenario. In this snapshot, though, `run.ts` is one of the unimplemented stubs (`console.log("Parmana Example 08 - Vendor Payment")`), and its `policy.json`/`transaction.json` fixture files are empty. There's a real `vendor-payment` policy shipped at the monorepo root (`policies/vendor-payment/1.0.0/policy.json` and `2.0.0/`), used throughout [REST API](/docs/api/execute) and [Guides](/docs/guides/basic-execution) examples in this documentation — but the `08-vendor-payment` example directory itself doesn't yet wire it into a runnable script. See [`examples/08-vendor-payment/README.md`](https://github.com/parmana-ai/parmana/tree/main/examples/08-vendor-payment).

## The rest

<CardGroup cols={2}>
  <Card title="04 — Execution Trust Record">Goal: generate an `ExecutionTrustRecord`. `Learn`: Trust Record, Evidence, Receipt. `Run`: `npm run trust-record`. Stub — see warning above.</Card>
  <Card title="05 — Verification">Goal: verify an `ExecutionTrustRecord`. `Learn`: VerificationService, Verification. `Run`: `npm run verification`. Stub.</Card>
  <Card title="06 — Replay">Goal: replay a recorded decision deterministically. `Learn`: ReplayEngine, Determinism, Policy Replay. `Run`: `npm run replay`. Stub.</Card>
  <Card title="07 — Human Approval">Goal: demonstrate human-in-the-loop approval. `Learn`: Override, Human Approval. `Run`: `npm run human-approval`. Stub — see [Guides → Human Override](/docs/guides/human-override) for why there's no reachable code path for this yet regardless.</Card>
  <Card title="09 — Expense Approval">Goal: an approval workflow example (no `Learn` section in its README). `Run`: `npm run expense-approval`. Stub.</Card>
  <Card title="10 — Purchase Order">Goal: a purchase order execution workflow (no `Learn` section in its README). `Run`: `npm run purchase-order`. Stub.</Card>
</CardGroup>

## Related

<CardGroup cols={2}>
  <Card title="Basic Execution" href="/docs/guides/basic-execution">The real path examples 01 and 03 partially illustrate.</Card>
  <Card title="policy package" href="/docs/packages/policy">The condition schema example 02 gets wrong.</Card>
  <Card title="Human Override" href="/docs/guides/human-override">Why example 07 can't demonstrate its stated goal today even if implemented.</Card>
  <Card title="Getting Started" href="/docs/getting-started/quickstart">A working path independent of these examples.</Card>
</CardGroup>
