Skip to main content
This tutorial follows Write your first rater. You write a second RSL file, a guideline, for a synthetic staffing liability program of Example Mutual. Then you work one submission by hand as an assistant, an underwriter and a manager. A rater holds the filed math. A guideline holds the underwriting rules around it: who answers each question, which submissions are eligible, and which submissions need a sign-off.

The underwriting rules

The example program has a rating manual with 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.
Its underwriting guideline adds five rules:
  • 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 that is 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 that is 2 years old, with a $2,500,000 payroll, a clean loss record and the basic limit, gets a $5,000 premium after the manager signs off. The rates, rules and citations are synthetic.

Save the rater and check it

Create a folder for the program:
Save the following rater as rater.rsl.
staffing/rater.rsl
Check it:
The rater asks for the payroll, the loss experience and the limit, and returns one premium. Its coded rule, PAYROLL_BELOW_MINIMUM, refuses a payroll below $1,000, the lowest payroll that the manual rates. The mark per quote on limit makes the limit a term: each quote of one submission may set its own limit. Every other input is a fact that all quotes of the submission share. Run a submission quotes two limits side by side.

Write the guideline

Create guideline.rsl beside rater.rsl, and write it from top to bottom in the seven parts below. The complete file follows the last part.

Name the program and use the rater

A guideline starts with the same header as a rater. The use line links the rater in the same folder under the short name ts. From here, the rater’s record is ts.Policy.

Declare the roles and the acts

Roles lists the roles from lowest to highest. A role does everything that the roles below it do, so a manager also answers an underwriter’s questions. Acts names the lowest role that quotes and the lowest role that binds.

Cite the guideline and declare its values

These sections work as they do in a rater. The guideline cites its own source document, and the artifact ID here is a placeholder for the synthetic guideline.

Ask the questions

  • policy: ts.Policy takes the rater’s record as one input. The guideline then asks every question of the rater under policy.
  • by @Role.uw gives a question to the underwriter. A question that lacks by is open to every role.
  • policy.experience by @Role.uw gives one of the rater’s questions to the underwriter, by its path.
  • when asks for financially_sound only when the firm is a PEO.

Read the rater’s premium

ts(self.policy).premium is the rater’s premium outcome for this policy. A guideline reads a rater through its inputs and its outcomes only, so the rater’s inner calculations stay free to change. A policy that breaks a coded rule of the rater makes the submission ineligible.

Add the eligibility rule

Close the record with a where rule that has a code:
A submission that breaks this rule moves to the Ineligible stage and shows the code and the message. The answers stay in the log, so a corrected answer makes the submission eligible again. Decline a submission shows the stage and the decision that follows it.

Add the two referrals

Write the referrals after the rule, then close Records and name the outcome:
A referral has a name, a condition, the lowest role that signs it off, and the reason shown to that role. While its condition holds, the submission waits for an answer of Approved or Declined from that role.

Check the guideline

Your file now matches this one:
staffing/guideline.rsl
One check covers both files. The compiler links the rater into the guideline and checks them as one program. Each referral is a calculated outcome, so the check reports a cost for it beside the premium.

Work a submission

rslc submission records one submission in a log file. Each command names who acts, as --as role:name. Each command prints the entries it wrote and then the status of the submission.

Open the log as the assistant

Save the applicant’s answers as application.json:
staffing/application.json
Open a log for this guideline:
The first line is entry 1 of the log. The characters after program start a hash of the guideline and the rater, so the same files give the same characters. The status lists four open questions with the lowest role that may answer each. The policy line stands for the rater’s questions that every role answers.

Answer from the application

The file answers four questions. The log records one entry for each answer and names the file as its source. The firm is 2 years old, so the new_venture referral is open before the premium is known.

Read the status

status prints the same block at any time and leaves the log as it is:
Each open line gives the question, its kind, the lowest role that may answer, and the reason for a referral. An input takes an answer. A signoff takes Approved or Declined.

See a refusal

Answer the underwriter’s question as the assistant:
The log refuses the command with the code NOT_AUTHORIZED and stays as it was. The candidates line lists the roles that may answer. A refused command exits with code 2, and the refusal is kept in submission.refused.jsonl, beside the log.

Answer as the underwriter

--because records the reason beside the answer. Every rating answer is in, so the premium is known: 2,500 × $2 is $5,000. The stage stays Open while the referral waits for the manager.

Sign off the referral as the manager

A sign-off is an answer to the referral’s name:
Every question has an answer and the referral is approved, so the stage is Quotable.

Quote

A quote is a log entry with a name. It keeps the outcomes of the moment, here a $5,000 premium, and it stands while the answers stay the same.

Change an answer

The applicant reports a higher payroll. Record it as the underwriter:
The quote q1 lapses, because a quote rests on every answer. The sign-off stands, because the condition of new_venture reads only years_in_operation. The premium is now $6,000. Now change an answer that the referral reads:
The manager approved a firm that was 2 years old. The sign-off lapses with that answer, and the referral is open again. The manager signs off the corrected submission:

Quote again and bind

The quote q1 stays in the log under its name, so the new quote takes a new name:
Bind the quote that stands:
The submission is Bound at a $6,000 premium. bind takes a quote only while it stands, so a bound premium always matches the answers in the log. A bound submission is final: the log refuses every later write.

Read the log

history lists every entry with its number and its writer:
The log file holds the same entries, one JSON object on each line. Open submission.jsonl in an editor. Lines 7 and 8 hold the first sign-off and the first quote:
at holds the time of your run. read holds the answer that the manager saw at the sign-off. Each key is a hash of the answers that the sign-off or the quote rests on. Commands only add lines, and each status is computed from the lines.

Decline a submission

A second applicant is a PEO that is 2 years old. Open a second log for it:
Answer two questions from its application:
The answers break the eligibility rule, so the stage is Ineligible. The log refuses a quote in this stage. The submission stays open, because a wrong answer and a true one look the same to the log. A person decides what follows:
  • Correct the answer. An answer of 4 years returns the submission to the Open stage.
  • Decline the submission. close declined records the decision.
The application is right, so the underwriter declines:
close declined takes the role of the quote act, here uw, and it works only while a rule or a sign-off declines. The entry names the code that the decision rests on. Declined is final, like Bound.

Run the whole story as a script

A script file holds the same story, one step on each line, with the results it expects. Save this one as bind.script.
staffing/bind.script
rslc script plays the steps on a log in memory and checks each expect line. A line that starts with refused passes when the log refuses the step with that code. Keep the script beside the guideline as its test, and run it after each change.

Next steps