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

# Turn underwriting guidelines into a program

> Write underwriting guidelines in RSL: call a rating function, give questions to roles and refer submissions, work one submission to bind, then release the program on Effective.

This guide builds on [Write your first rating function](https://docs.canary.effectiveai.app/rsl/tutorial/first-rater.md), which writes the rating function it calls.
You write an underwriting **guideline** for a synthetic staffing liability program of Example Mutual, then work one submission on its log.

A guideline is a process. The log of one submission folds into a status: the open questions, who answers each, and the acts that are free to take.
The process calls a rating function for the premium. The function reads only its inputs. The process reads the log and who acts.

## Underwriting rules

The rating manual has four rules:

* The premium is \$2 for each \$1,000 of payroll.
* A firm with claims pays 1.5 times that premium.
* The basic limit is \$1,000,000. A higher limit, up to \$2,000,000, costs 1.1 times that premium.
* The program rates a payroll of \$1,000 or more.

The underwriting guideline adds five:

* A professional employer organization (PEO) must be in operation for 3 years or more and be financially sound.
* An underwriter judges the loss experience and the financial soundness.
* A manager signs off a firm in operation for less than 3 years.
* A manager signs off a premium of \$10,000 or more.
* An underwriter quotes and binds.

A staffing firm 2 years old, with a \$2,500,000 payroll, a clean loss record and the basic limit, pays \$5,000 after the manager signs off.
The rates, rules and citations are synthetic.

## Save the rating function

Make a folder for the program:

```sh theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
mkdir staffing
cd staffing
```

Save the rater as `rater.rsl`:

> [accordion] rater.rsl
>
> ```rsl staffing/rater.rsl theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
> spec {
>     rsl: "0.4",
>     component: rater,
>     carrier: "Example Mutual",
>     state: PA,
>     product: "Staffing Liability",
>     version: "0.1.0",
>     effective_date: 2026-01-01
> }
>
> Sources = {
>     rules: Source = {
>         artifact: artifact("5b0e7c0e-6f0a-4c56-9d39-0d1f1a1c7e11"),
>         kind: pdf
>     }
> }
>
> Types = {
>     Experience = {
>         no_claims,
>         claims
>     }
> }
>
> Constants = {
>     rate_per_1000 [cite: rules:p1] = 2,
>     claims_factor [cite: rules:p2] = 1.5,
>     basic_limit [cite: rules:p3] = 1000000,
>     higher_limit_factor [cite: rules:p3] = 1.1
> }
>
> Records = {
>     Policy = {
>         inputs {
>             payroll: Num {precision: int} where self in [0, 100000000] [cite: rules:p1],
>             experience: Experience [cite: rules:p2],
>             limit: Num {precision: int} per quote where self in [1000000, 2000000] [cite: rules:p3]
>         },
>         step rating [cite: rules:p1] {
>             experience_factor: Num = if self.experience = @Experience.no_claims then 1 else claims_factor,
>             limit_factor: Num = if self.limit > basic_limit then higher_limit_factor else 1,
>             premium: Premium [cite: rules:p1] =
>                 round(self.payroll / 1000 * rate_per_1000 * self.experience_factor * self.limit_factor, 2, half_up)
>         }
>     } where self.payroll >= 1000 [code: "PAYROLL_BELOW_MINIMUM", message: "The payroll must be at least $1,000.", cite: rules:p1]
> }
>
> RatingOutcomes = {
>     premium: Policy.premium
> }
> ```

```sh theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
rslc check rater.rsl
```

```text theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
PASS rater.rsl (strict)
cost premium: 3 (each list of size 1: 3, 3: 3, 10: 3)
```

The function takes the payroll, the loss experience and the limit, and returns `premium`.
Its check `PAYROLL_BELOW_MINIMUM` refuses a payroll below \$1,000.
`per quote` on `limit` makes the limit a **term**: each offer may set its own limit. Every other input is a fact that all offers share.

## Write the guideline

Create `guideline.rsl` beside `rater.rsl`. The parts below build it from top to bottom, and the whole file follows them.

### Use the rating function

```rsl theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
use ts = "rater.rsl"
```

The guideline starts with the same `spec` header as a rater, with `component: guideline`.
`use` links the rater under the short name `ts`, so its record is `ts.Policy`.

### Grant roles and acts

```rsl theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
Roles = { assistant < uw < manager }

Acts = {
    quote: offer live -> live by @Role.uw,
    bind: accept live -> bound by @Role.uw,
    decline: refuse live -> declined by @Role.uw,
    withdraw: end live -> closed by @Role.assistant,
}
```

`Roles` lists the roles from lowest to highest, and a role acts for each role below it.
Each act names its kind, the states it moves between, and the lowest role that takes it.

### Ask the questions

```rsl theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
Records = {
    Submission = {
        inputs {
            operation: Operation [cite: guideline:p1],
            years_in_operation: Num {precision: int} where self in [0, 300] [cite: guideline:p1],
            financially_sound: Bool by @Role.uw when self.operation = @Operation.peo [cite: guideline:p1],
            policy: ts.Policy,
            policy.experience by @Role.uw
        },
```

* `policy: ts.Policy` takes the inputs of the rater as one input. The guideline asks each of them under `policy`.
* `by @Role.uw` grants a question to the underwriter. A question that lacks `by` is open to every role.
* `policy.experience by @Role.uw` grants one question of the rater to the underwriter, by its path.
* `when` makes `financially_sound` a follow-up: the log asks it only for a PEO.

An input can also carry the words that a host shows. The `questions` example words two questions this way:

```rsl theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
home_business: Bool [ask: "Do you run a business from the home?", help: "Count paid work you do at home for your own customers.", group: "Business"],
```

```rsl theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
customers_visit: Bool when self.home_business [ask: "Do customers visit the home?", group: "Business"],
```

`ask` is the question, `help` the longer text, and `group` the section. The words change what a host asks, and the premium stays the same.
[Input contract](https://docs.canary.effectiveai.app/rsl/reference/input-contract.md) lists every key, and `rslc examples get questions` saves the whole file.

### Call the rating function

```rsl theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
step premium [cite: guideline:p2] {
    premium: Premium = ts(self.policy).premium
}
```

`ts(self.policy).premium` calls the rater on the policy and reads its `premium`.
A policy that breaks a check of the rater makes the submission ineligible.

### Add eligibility and referrals

```rsl theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
} where self.operation != @Operation.peo or (self.years_in_operation >= established_years and self.financially_sound) [code: "PEO_NOT_ESTABLISHED", message: "A PEO must be in operation for at least 3 years and be financially sound.", cite: guideline:p1]
    refer new_venture when self.years_in_operation < established_years
        to @Role.manager because "The firm is in operation for less than 3 years." [cite: guideline:p1]
    refer large_account when self.premium >= large_premium
        to @Role.manager because "The premium is $10,000 or more." [cite: guideline:p2]
```

* The `where` rule has a code. A submission that breaks it is `ineligible`, and the log refuses `quote`.
* A `refer` rule holds the offer act while its condition holds: the underwriter can still record a quote, but it is held, and `bind` refuses it (`NOT_READY`) until the named role decides `Approved` or `Declined`.
* A decision stands while the values that its condition reads stay the same. When one changes, the decision lapses.

### Check the guideline

The whole file, with its header, source and constants:

> [accordion] guideline.rsl
>
> ```rsl staffing/guideline.rsl theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
> spec {
>     rsl: "0.4",
>     component: guideline,
>     carrier: "Example Mutual",
>     state: PA,
>     product: "Staffing Liability Underwriting Guideline",
>     version: "0.1.0",
>     effective_date: 2026-01-01
> }
>
> use ts = "rater.rsl"
>
> Roles = { assistant < uw < manager }
>
> Acts = {
>     quote: offer live -> live by @Role.uw,
>     bind: accept live -> bound by @Role.uw,
>     decline: refuse live -> declined by @Role.uw,
>     withdraw: end live -> closed by @Role.assistant,
> }
>
> Sources = {
>     guideline: Source = {
>         artifact: artifact("0c1f6f43-1f55-4a55-8a53-7d1b6f0e2a22"),
>         kind: pdf
>     }
> }
>
> Types = {
>     Operation = {
>         staffing,
>         peo
>     }
> }
>
> Constants = {
>     established_years [cite: guideline:p1] = 3,
>     large_premium [cite: guideline:p2] = 10000
> }
>
> Records = {
>     Submission = {
>         inputs {
>             operation: Operation [cite: guideline:p1],
>             years_in_operation: Num {precision: int} where self in [0, 300] [cite: guideline:p1],
>             financially_sound: Bool by @Role.uw when self.operation = @Operation.peo [cite: guideline:p1],
>             policy: ts.Policy,
>             policy.experience by @Role.uw
>         },
>         step premium [cite: guideline:p2] {
>             premium: Premium = ts(self.policy).premium
>         }
>     } where self.operation != @Operation.peo or (self.years_in_operation >= established_years and self.financially_sound) [code: "PEO_NOT_ESTABLISHED", message: "A PEO must be in operation for at least 3 years and be financially sound.", cite: guideline:p1]
>         refer new_venture when self.years_in_operation < established_years
>             to @Role.manager because "The firm is in operation for less than 3 years." [cite: guideline:p1]
>         refer large_account when self.premium >= large_premium
>             to @Role.manager because "The premium is $10,000 or more." [cite: guideline:p2]
> }
>
> RatingOutcomes = {
>     premium: Submission.premium
> }
> ```

```sh theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
rslc check guideline.rsl
```

```text theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
PASS guideline.rsl (strict)
cost premium: 4 (each list of size 1: 4, 3: 4, 10: 4)
cost new_venture: 1 (each list of size 1: 1, 3: 1, 10: 1)
cost large_account: 5 (each list of size 1: 5, 3: 5, 10: 5)
```

One check covers both files: the rater alone, then the guideline and its call.
The cost of `large_account` holds the call, because its condition reads the premium.

## Work a submission

`rslc log` records one submission in a log file. Each command names its writer as `--as role:name`, and prints the entries it wrote and the status.

### Open and answer

Save the answers of the applicant as `application.json`:

```json staffing/application.json theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
{
  "operation": "staffing",
  "years_in_operation": 2,
  "policy": {
    "payroll": 2500000,
    "limit": 1000000
  }
}
```

Open a log for the guideline, then answer from the file as the assistant:

```sh theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
rslc log open submission.jsonl --program guideline.rsl --as assistant:intake
rslc log answer submission.jsonl --file application.json --as assistant:intake
```

```text theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
  1  assistant:intake  opened guideline.rsl (program 0d275e29240f)
...
  5  assistant:intake  answered years_in_operation = 2
status: incomplete
open (2):
  policy.experience  input    @uw
  new_venture        signoff  @manager  because: The firm is in operation for less than 3 years.
                       reads years_in_operation = 2
referrals:
  new_venture  Open  @manager
```

The status lists what is still open, with the lowest role for each. The firm is 2 years old, so `new_venture` is open before the premium is known.
An assistant who answers `policy.experience` gets the refusal `NOT_AUTHORIZED`, and the log stays as it was.

### Answer as the underwriter

```sh theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
rslc log answer submission.jsonl policy.experience=no_claims --because "Loss runs, five years" --as uw:alice
```

```text theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
  6  uw:alice  answered policy.experience = "no_claims" because "Loss runs, five years"
status: referred
open (1):
  new_venture  signoff  @manager  because: The firm is in operation for less than 3 years.
                 reads years_in_operation = 2
referrals:
  new_venture  Open  @manager
outcomes known so far:
  premium = 5000
```

Every input has an answer, so the premium is known: 2,500 × \$2 is \$5,000. The referral waits for the manager.

### Sign off as manager

A sign-off answers the referral by its name:

```sh theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
rslc log answer submission.jsonl new_venture=Approved --because "Experienced owners." --as manager:morgan
```

```text theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
  7  manager:morgan  signed off new_venture = Approved on years_in_operation = 2 because "Experienced owners."
status: ready
referrals:
  new_venture  Approved  @manager
outcomes:
  premium = 5000
```

The status is `ready`: the offer act is free to take.

### Quote

```sh theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
rslc log act submission.jsonl quote q1 --as uw:alice
```

```text theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
  8  uw:alice  offered q1: 1 outcomes
status: ready
offers:
  q1  stands
referrals:
  new_venture  Approved  @manager
outcomes:
  premium = 5000
```

The offer `q1` keeps the \$5,000 premium. It stands while the answers stay the same.

### Change an answer

The applicant reports a higher payroll:

```sh theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
rslc log answer submission.jsonl policy.payroll=3000000 --as uw:alice
```

```text theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
  9  uw:alice  answered policy.payroll = 3000000
status: ready
offers:
  q1  lapsed (policy.payroll changed)
referrals:
  new_venture  Approved  @manager
outcomes:
  premium = 6000
```

The offer rests on every answer, so `q1` lapses. The sign-off stands, because `new_venture` reads only `years_in_operation`.
Now change the answer that the referral reads:

```sh theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
rslc log answer submission.jsonl years_in_operation=1 --as uw:alice
```

```text theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
 10  uw:alice  answered years_in_operation = 1
status: referred
offers:
  q1  lapsed (policy.payroll, years_in_operation changed)
open (1):
  new_venture  signoff  @manager  because: The firm is in operation for less than 3 years.
                 reads years_in_operation = 1
referrals:
  new_venture  Open  @manager  (sign-off lapsed)
outcomes known so far:
  premium = 6000
```

The manager approved a firm 2 years old, so the sign-off lapses and the referral opens again.

### Sign off and bind

```sh theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
rslc log answer submission.jsonl new_venture=Approved --because "Still acceptable." --as manager:morgan
rslc log act submission.jsonl quote q2 --as uw:alice
rslc log act submission.jsonl bind q2 --as uw:alice
```

```text theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
 11  manager:morgan  signed off new_venture = Approved on years_in_operation = 1 because "Still acceptable."
...
 13  uw:alice  accepted q2
status: accepted
offers:
  q1  lapsed (policy.payroll, years_in_operation, new_venture changed)
  q2  accepted
referrals:
  new_venture  Approved  @manager
outcomes:
  premium = 6000
```

`q1` stays in the log under its name, so the new offer takes a new name.
`bind` takes an offer only while it stands, so the bound premium matches the answers in the log. An accepted submission is final.

### Read the log

The log file holds one JSON object on each line. These are entries 7, 8 and 13:

```text theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
{"seq":7,"at":"2026-11-26T02:21:32+00:00","by":{"role":"manager","id":"morgan"},"kind":"decide","on":"new_venture","value":"Approved","note":"Experienced owners.","stamp":{"key":"5ff2f1b6020a11cb7f4c9a2c5e3617907f4f5b30e1d0cac9c5541137f444a7f6","read":{"years_in_operation":2}}}
{"seq":8,"at":"2026-11-26T02:21:32+00:00","by":{"role":"uw","id":"alice"},"kind":"act","on":"quote","value":"q1","stamp":{"act":"offer","key":"b6fa9f76f86d97882cd35b53c421a65c1f8fffaaa1584c7546ea0a10b090a507","outcomes":{"premium":5000}}}
{"seq":13,"at":"2026-11-26T02:21:33+00:00","by":{"role":"uw","id":"alice"},"kind":"act","on":"bind","value":"q2","stamp":{"act":"accept","state":"bound"}}
```

* `kind` is the shape of the entry, and `on` is what it is about.
* `decide` is the sign-off. `stamp.read` holds the answer that the manager read.
* `act` is an act of the program. `stamp.act` says what it did: `offer`, then `accept`.
* `at` is the time of your run. Commands only add lines, and each status follows from the lines.

`rslc log history submission.jsonl` lists every entry with its number and its writer.

## Release it on Effective

To take real submissions, release the guideline on Effective:

1. Package it with `rslc export guideline.rsl --format bundle --out guideline.zip`. The bundle carries the rating function it uses.
2. [Upload the bundle](https://docs.canary.effectiveai.app/api-reference/your-programs/upload-a-program-bundle.md), then [release it](https://docs.canary.effectiveai.app/api-reference/your-programs/release-an-uploaded-program-bundle.md) under a version number.

Releasing makes you the holder of each role the guideline declares, so you can work a submission
straight away. [Programs on Effective](https://docs.canary.effectiveai.app/rsl/programs-on-effective.md) shows each call, and how to
hand the roles to your team. Then [take in submissions](https://docs.canary.effectiveai.app/guides/underwriting/submissions.md).

## Next steps

* [Run a submission](https://docs.canary.effectiveai.app/rsl/how-to/run-a-submission.md) covers each command: documents, offer options, declines, scripts and `--json`.
* [Processes](https://docs.canary.effectiveai.app/rsl/concepts/processes.md) and [Rules and decisions](https://docs.canary.effectiveai.app/rsl/concepts/rules-and-decisions.md) explain the model behind the log.
* [Submission log](https://docs.canary.effectiveai.app/rsl/reference/submission-log.md) lists every entry, status, refusal code and script line.
* [Check messages for guidelines](https://docs.canary.effectiveai.app/rsl/reference/check-messages/guidelines.md) explains each message that `rslc check` gives a guideline.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.