# The pricing tool your sales team asked for. Built in an afternoon, with access rules and approvals built in.

> Build a governed app with your coding agent: one small pricing tool in Osy#, from the request to running on your laptop, with its data, screen, access rules and approval workflow.

Page: https://osyrin.com/build/ · Index for agents: https://osyrin.com/llms.txt

[Osyrin](https://osyrin.com/)/ For builders

Reps price quotes for their own region. Discounts above 15% go to a manager. See the Osy# source, then run the app on your laptop and try both sides of the approval.

[Run the sample](https://osyrin.com/build/#run) · [Read the source](https://osyrin.com/build/#source)

- One language · Data, screens, access rules and workflows, in one program your agent can hold in view.
- Answers in seconds · The compiler names the line and the fix, so your agent corrects itself instead of guessing.
- Rules on every query · Write who may see a row once. Every screen, report and agent gets the same answer.
- Kits you own · Sign-in, roles, mail and approvals come tested. Every kit we provide is MIT-licensed.

The app first

## Reps price their own region. Big discounts wait for their manager.

On the front page, a sales analyst's pricing tool quietly became infrastructure. This is the same tool, built the governed way. It took a coding agent, about two hundred lines of Osy# and the kits that already exist.

The request · "Our reps need to price quotes for their own region. Anything over 15% off needs their manager's yes."

pricingtool.localhost

![The Quotes page, signed in as Sam Okafor, a manager for the Pacific region. A card says Waiting for your approval: Cedar Clinics, Onboarding, 22% off, 14,820.00, with Decline and Approve buttons. Below it, a New quote form being filled in for Harbor Dental: Premium support, 3 at 18% off, showing Total 11,808.00 and the line Goes to a manager before it can be sent. Then a table of three Pacific quotes: Bluewater Logistics approved, Cedar Clinics with manager, Larkspur Foods with a Send button.](https://osyrin.com/build/quotes-screen@2x.png) ![The same Quotes page in dark mode, signed in as Sam Okafor: Cedar Clinics at 22% off waits for his approval, a new quote shows its total of 11,808.00 as it is priced, and the table lists the three Pacific quotes.](https://osyrin.com/build/quotes-screen-dark@2x.png)

- 1 · **Sam sees the Pacific region only.** — Maria's Mountain quotes never reach his screen, because the rule is part of every query.
- 2 · **Cedar Clinics at 22% waits for him.** — Ava sent it, and above 15% the decision belongs to a Pacific manager.
- 3 · **Bluewater at 10% went straight through.** — Small discounts need no one's yes, so reps keep moving.

A real screenshot of the sample running locally, signed in as Sam, a Pacific manager. The light and dark versions follow this page's theme.

The source, in four parts

## Everything the app does is in its source, and it reads like what it does.

Each part below is copied from the sample's files, line for line. The highlighted lines are the ones doing the work.

### Rules about the data live on the data. (01, Data)

A discount can't pass 40%, a quantity can't be zero, and the total is worked out from the row, never typed in. The form shows the same total live, by the same rule, while the rep is still choosing.

Those hold whatever writes the quote: the screen, an import or an agent. **You declare them once and stop checking.**

model/quotes/quote.osy

quote.osy · lines 12 to 24 · data

```
entity Quote {
  [Required("Who is the quote for?"), MaxLength(120)] string Customer;
  [Required("Pick a product.")] Product Product;
  [Min(0)] decimal ListPrice;
  [Min(1)] int Quantity = 1;
  [Min(0), Max(40)] decimal Discount = 0;
  Region Region;
  [Required("A quote belongs to a rep.")] Principal Rep;
  QuoteStatus Status;
  Principal? ApprovedBy;
  [MaxLength(300)] string? ManagerNote;

  [Stored] decimal Total => PriceOf(ListPrice, Quantity, Discount);
```

quote.osy · lines 41 to 42

```
/// List price times quantity, less the discount, to the cent. The stored total and the form's live total both use it.
decimal PriceOf(decimal listPrice, int quantity, decimal discount) => Math.Round(listPrice * quantity * (100 - discount) / 100, 2);
```

### One line reads the data. No endpoint, no fetch. (02, Screen)

Each `live var` runs on the server as the person looking, and updates the moment a quote changes. The second one is every discount waiting for this manager, already typed.

The card, the table and the form are kit controls, **dressed in your own theme**.

model/quotes/quotes-page.osy

quotes-page.osy · lines 7 to 10 · screen

```
component QuotesPage() {
  live var quotes  = Quote.Include(q => q.Product).OrderByDescending(q => q.Total).Take(200).ToList();
  live var waiting = Workflow.Inbox<Quote>().Where(r => r.SlotAlias == "Manager").Include(r => r.Item.Product).ToList();
  live var me      = SignedInAs();
```

quotes-page.osy · lines 22 to 34

```
      if (waiting.Count() > 0) {
        Card("Waiting for your approval") {
          foreach (var r in waiting) {
            Row(gap: 3, align: Align.Center) {
              Text(r.Item.Customer + " · " + r.Item.Product.Name, fontWeight: FontWeight.Semibold);
              Text(r.Item.Discount + "% off · " + r.Item.Total.ToString("N2"), color: Colors.TextMuted);
              Spacer();
              Button("Decline", onPress: () => Decline(r.Item), tone: Tone.Ghost);
              Button("Approve", onPress: () => Approve(r.Item), tone: Tone.Primary);
            }
          }
        }
      }
```

### Say who may see it once. Every query obeys. (03, Access rules)

Ava sees Pacific and Maria sees Mountain, and no screen filters by hand. The rule is compiled into every read and write, so a report, an export or an agent gets the same answer.

A quote is frozen while a manager decides, and **only the approval itself can write down who approved**.

model/quotes/quote.osy · model/people/people.osy

quote.osy · lines 26 to 34 · access rules

```
  security {
    // Reps and managers see the quotes of the regions they cover. No one sees any other region.
    allow read, create when IsSales where Covers(Region);
    // A draft can be changed. Once it is with a manager, it is frozen.
    allow update when IsSales where Covers(Region) && Status == QuoteStatus.Draft;
    // Only the approval itself writes down who approved, and why.
    deny update ApprovedBy, ManagerNote;
    allow update ApprovedBy, ManagerNote when IsDiscountDesk;
  }
```

people.osy · lines 32 to 33

```
/// The regions the caller covers. Every rule about quotes is written with it.
policy Covers(Region region) => Territory.Any(t => t.Person == user && t.Region == region);
```

### An approval that can wait for days, and never loses its place. (04, Approval workflow)

Above 15% off, the quote goes to a manager of its region, never to the rep who wrote it. If nobody answers in two days, it comes back to the rep with a note.

The run survives restarts and deploys. **The inbox, the clock and the record of who decided come with the engine.**

model/quotes/discount-approval.osy

discount-approval.osy · lines 19 to 44 · workflow

```
  state Draft {
    subscribe Submit();
    on Submit {
      when (NeedsManager(this.Item)) { goto WithManager; }
      default { goto Approved; }
    }
  }

  state WithManager {
    subscribe Decide(Decision decision, string note) as Manager {
      Candidates = u => RoleGrant.Any(g => g.Member == u && g.Role == AppRole.Manager)
                     && Territory.Any(t => t.Person == u && t.Region == this.Item.Region)
                     && u != this.Item.Rep;
      Finished {
        Within = TimeSpan.FromDays(2);
        Unfinished { this.Item.ManagerNote = "No manager answered in two days"; goto Draft; }
      }
    }
    on Manager(Decision decision, string note) {
      this.Item.ManagerNote = note;
      when (decision == Decision.Decline) { goto Draft; }
      default { this.Item.ApprovedBy = actor; goto Approved; }
    }
  }

  terminal success Approved { }
```

**The deeper read.** How the workflow engine keeps thousands of runs going through a new release, with people, deadlines and agents in the same process.

[Read about the workflow engine](https://osyrin.com/workflow-engine)

What the coding agent does

## Your agent writes the app. The compiler keeps it honest.

Use Claude Code, or the coding agent you prefer. It works in one language, asks the toolchain instead of guessing, and builds on kits that are already tested.

01 · It writes Osy#

### You say what the app is for.

One command sets up the project for your agent, with the language's rules and how to check its own work. You describe the request. The agent writes the data, the rules, the screen and the workflow, and the tests that prove them.

your terminal · osy

```
osy init --agent claude -d pricing-tool
cd pricing-tool && claude
```

02 · The compiler answers

### A mistake comes back with its line and its fix.

We broke a copy of the sample on purpose. Here is what `osy validate` said, in seconds each time.

osy validate · excerpts

```
quotes-page.osy:40:87  ERROR  RESOLVE_ERROR  UI: entity 'Quote' has no property 'DiscountPercent' …

discount-approval.osy:39:50  ERROR  RESOLVE_ERROR  `goto Rejected`: 'Rejected' is not a declared state in this workflow
```

03 · It reuses the kits

### The hard parts arrive already done.

The sample writes none of these. It names them in one file, and they come with their own data, screens, security and tests.

- **Sign-in and accounts** — UserAccounts
- **Roles** — Identity
- **Sign-in mail** — Mail · EmailTemplates
- **Durable approvals** — Workflow
- **Tables, forms, cards** — Ui
- **A trail of every change** — Observability

04 · A real bug, kept fixed

### Ava saw her own drafts in the approval inbox. One line fixed it, and a test keeps it fixed.

A compiler catches a wrong field or a missing state. It can't know that a rep's own drafts don't belong under "Waiting for your approval". The first screenshot of this sample showed exactly that: the inbox listed every step Ava could act on, including sending her own quotes.

The fix asks for the manager's step only. Then the test `the_screen_shows_her_region_and_hides_the_rest` signs in as Ava and checks that the card is gone. Take the fix out and `osy check` fails on that test.

**So a behaviour your team cares about becomes a test, and every later change, yours or your agent's, is checked against it.**

quotes-page.osy · line 9 · the fix and its test

```
  live var waiting = Workflow.Inbox<Quote>().Where(r => r.SlotAlias == "Manager").Include(r => r.Item.Product).ToList();
```

quotes.test.osy · lines 109 to 117

```
[Test(SalesTeam)]
[runas(Ava)]
void the_screen_shows_her_region_and_hides_the_rest() {
  Ui.Visit("/");
  Assert.Visible("Bluewater Logistics");
  Assert.Visible("Cedar Clinics");
  Assert.Hidden("Summit Outfitters");
  Assert.Hidden("Waiting for your approval");                                  // her own drafts are hers to send, not to approve
}
```

What the compiler checks

## The checks a careful reviewer makes, run every time your agent checks its work.

Because the whole app is one program, the toolchain can see how the pieces fit. That is what lets an agent build fast without leaving holes for someone else to find.

### Access rules on every query and write

A rule is compiled into every read, so no screen, report or agent can forget it. A rule in the wrong place is refused, with the rewrite.

### The screen and the data, typed together

A page that names a field the data doesn't have won't compile. Rename a field, and every screen that uses it tells you.

### Every workflow step leads somewhere real

A step into a state that doesn't exist is refused. A step that could wait forever, with no deadline, is pointed out before it ships.

### Rules your tests have proven

A rule no test has tried to break is flagged until one proves both the no and the yes. The sample proves both.

### Unbounded queries are flagged

A screen that reads a whole table with no limit is flagged before it ships, so it stays quick when fifty rows become fifty thousand. It flagged this sample's first draft.

### Who can do what, in plain words

`osy explain` turns the rules into sentences for your security review: who reads, creates and changes each kind of record.

Passing **`osy check` gives one verdict:** it validates, runs the lint and runs the app's tests. The sample passes, with 12 tests across access, approval and the screen.

Run it

## On your laptop in a few minutes. Free, and no account needed.

### Submit a quote, then approve it as the manager.

Ava is a rep in the Pacific region and Sam is her manager. You play both, in the real app with a real PostgreSQL database on your own machine.

Each `osy launch --as` opens the app in your browser already signed in, so there are no passwords to type.

Cedar Clinics asks for 22% off. When Ava sends it, it waits for Sam. When Sam approves, the quote shows Approved.

The first run fetches the database once. After that the app starts in seconds. Setup for Windows, Homebrew and the Claude Code plugin is on [osysharp.com/install](https://osysharp.com/install/).

**Get the sample** — The pricing tool's folder: the app, its theme and its 12 tests.

[Download the sample](https://osysharp.com/samples/pricing-tool/)

your terminal · macOS and Linux · osy

```
# 1. Install the tools
curl -fsSL https://osysharp.com/get.sh | sh

# 2. In the sample's folder, load the sales team
osy seed "A sales team in two regions"

# 3. As Ava, press Send on Cedar Clinics (22% off)
osy launch --as ava@pricing.test

# 4. As Sam, press Approve under "Waiting for your approval"
osy launch --as sam@pricing.test
```

- **Run the 12 tests** — `osy check` validates, lints and runs every test, the inbox bug's test included.
- **When you are done** — `osy stop` shuts down the local platform.

Go further

## Everything else about the language is on osysharp.com.

The deeper read · The workflow engine · Processes that wait for people, keep their deadlines and move to a new version while they run. · [Read it →](https://osyrin.com/workflow-engine)

osysharp.com/install · Set up · Install the tools, add the Claude Code plugin and start your first project. · [Get set up →](https://osysharp.com/install/)

osysharp.com/start · From an empty folder · The path from nothing to a running app, step by step. · [Start →](https://osysharp.com/start/)

osysharp.com/reference · The language reference · Every part of Osy#, with examples the compiler builds. · [Open the reference →](https://osysharp.com/reference/)

osysharp.com/guides/security · Access rules · Say who may read it, once. Every query obeys. · [Read the guide →](https://osysharp.com/guides/security/)

osysharp.com/guides/workflows · Workflows · A process that waits three days for a person is still just source. · [Read the guide →](https://osysharp.com/guides/workflows/)

osysharp.com/guides/written-by-agents · Built by agents · Why a coding agent does better when it can ask the toolchain. · [Read the guide →](https://osysharp.com/guides/written-by-agents/)

Your turn

## Run the sample, then build the app your team keeps asking for.

When it is ready for real users, Osyrin runs it inside your organization's policy. [See how policy works →](https://osyrin.com/policy/)

[Run the sample](https://osyrin.com/build/#run) · [Explore Osy#](https://osysharp.com/)

Or write to us at [contact@osyrin.com](mailto:contact@osyrin.com?subject=Building%20on%20Osyrin). Tell us what you would like to build, or where your current approach gets stuck.
