DelveTalkcome in

Inspecting errand/3 · the kinds · the language · the modules

errand/3

Go there its page the town

id
errand/3
kind chain
errand/3 → kind/errand → record
owner
yue
made by
yue
after
After kind/errand.
version
4
pin
larun-mizak
state
873 bytes

Its spells

  • writedelvetalk errand/3 write / text: <text, 1 to 280 characters>
    its Bend
  • linesdelvetalk errand/3 lines / from: <a number from 0 to 1000000000>
    its Bend
  • settledelvetalk errand/3 settle / by: <text, 1 to 128 characters>
    its Bend

To cast them, come in.

Who may do what

What its law admits now, before the spell's own Bend has its say.

methoda newcomer
write✓ yes
lines✓ yes
door✓ yes
undoor✓ yes
arm✓ yes
settle✓ yes
repay✓ yes
tend✓ yes
admit✓ yes
set✓ yes
repair✓ yes

Its law

  • host opener the hand that opened the world may amend any lawrequest.kind == 2 and request.subject == "the town"
  • law owner the owner stays; only the owner changes the keeper, the doors, its scene or its code; anyone else only by its spells, and places rules, wants and verbs on it(unchanged(owner)) and ((request.subject == new.owner) or ((((((((request.kind == 0) or (request.kind == 4)) and (unchanged(keeper))) and (unchanged(cites))) and (unchanged(start))) and (unchanged(passages))) and (unchanged(cooldown))) and (unchanged(requires))))
  • law kept a line, an admission or a mark is only added; only the keeper admits(((insertOnly(lines)) and (insertOnly(admitted))) and (insertOnly(marks))) and ((unchanged(admitted)) or (request.subject == new.keeper))
  • law methods what was written, waits, was admitted and marked, who is here, who left, the variables, what lies here and when it was tended change only by their spells, never by a proposal(request.kind == 3) implies ((((((((((unchanged(lines)) and (unchanged(pending))) and (unchanged(admitted))) and (unchanged(marks))) and (unchanged(presence))) and (unchanged(left))) and (unchanged(vars))) and (unchanged(mine))) and (unchanged(things))) and (unchanged(tended)))
  • want pending a line waits for its keeper(not (new.keeper == "")) and (count(new.pending) >= 1) asks delvetalk {request.object} admit
  • want door it opens onto nothing yetcount(new.cites) == 0 asks delvetalk {request.object} door
  • law kind kind/errand's law holdsunder "kind/errand"

Rules and wants on it

  • rule pay by yue, entry 1156when ("done" in new.marks.name) and ((request.method == "settle") or (request.method == "repay"))delvetalk ember/1 write / text: a warmth for the ember: someone weathered the moth's wing, and the errand kept its word.

Its Bend

what it runs: its entry module 142 lines
layer over ./Record.obend
edition ObjectiveBend 1
import ./Abi.obend as Abi
import ./List.obend as Lists
import ./Document.obend as Document
import ./Form.obend as Form
import ./Plan.obend as Plans
import ./World.obend as World
import ./Card.obend as Card
import ./Scenes.obend as Scenes
import ./Relation.obend as Relations
import ./Rows.obend as Rows
import ./Text.obend as Text
# The errand's body, over RECORD (docs/OVERHAUL.md §2, an errand is a rule with a pay; TENURE §3B):
# a record made with what it asks (`asks`), the thing it is about (`on`), the condition that does it
# (`done`, in the law grammar, judged at each write on `on`) and the spell that pays (`pays`, which may
# name the doer as `{request.subject}`), all fixed. As its kind finishes it, it places one rule on `on`
# under its maker (`made`): when `done` holds of a write there, it casts `delvetalk <errand> settle / by:
# {request.subject}`, the maker's turn.
#
# Its maker's `pay` rule occupies that name while open. `settle` takes the call from the maker's
# rule on `on` alone: it replaces `pay` with the claimant's spell, marks `done` by them (a mark kept,
# never dropped), and takes its rule off `on`, in one turn. Registration must succeed before the
# claim is written; the pay fires at that write as `rule:<errand>:pay:<height>`. A second completion
# pays nobody. The pay is judged by what it touches; refused, the claim stands and its receipt says
# why. `repay` replaces or reconstructs the same rule for the recorded claimant.
type State = Super.State
sum Payment:
  open: {}
  claim: {by: String}
  retry: {by: String}
form arm:
form repay:
form settle:
  by: text 1..128
form write:
  text: text 1..280
form lines:
  from: natural 0..1000000000
form door:
  label: text 1..32
  to: text 1..128
form undoor:
  label: text 1..32
def write(state: State, input: WriteInput, context: Abi.Context) -> Activity<Nat>:
  Super.write(state, {text: input.text}, context)
def lines(state: State, input: LinesInput, context: Abi.Context) -> Activity<Card.Replied>:
  Super.lines(state, {from: input.from}, context)
def door(state: State, input: DoorInput, context: Abi.Context) -> Activity<Card.Replied>:
  Super.door(state, {label: input.label, to: input.to}, context)
def undoor(state: State, input: UndoorInput, context: Abi.Context) -> Activity<Card.Replied>:
  Super.undoor(state, {label: input.label}, context)
def actions(state: State, context: Abi.Context) -> Lists.List<String>:
  Lists.concat(if context.principal == state.owner then Text.words("settle write lines door undoor") else Text.words("settle write lines"), if context.principal == state.maker then Text.words("arm repay") else Text.words(""))
def methods() -> Lists.List<String>:
  Text.words("~made ~act")
def on(state: State) -> String:
  Super.field(state, "on")
# The completion rule's name on `on`: the errand's id as an identifier.
def settles(context: Abi.Context) -> String:
  Text.identifier(context.object)
def made(state: State, input: {}, context: Abi.Context) -> Activity<Bool>:
  if context.caller != state.kind then false else replacingPay(state, Payment.open({}), context)
def placing(state: State, context: Abi.Context) -> Activity<Bool>:
  match world.rule({object: {world: context.world, object: on(state)}, name: settles(context), when: Super.field(state, "done"), then: "delvetalk {context.object} settle / by: {{request.subject}}"}):
    case placed(_): Super.armedNow(state, context)
    case refused(r): Super.unarmed(state, on(state), r.clause, r.reading, context)
# Its maker replaces its rules while open.
def arm(state: State, context: Abi.Context) -> Activity<Bool>:
  if context.principal != state.maker then Super.armRefused(state, context) else if Super.marked(state, "done") then false else rearming(state, context)
def rearming(state: State, context: Abi.Context) -> Activity<Bool>:
  match world.unrule({object: {world: context.world, object: on(state)}, name: settles(context)}):
    case _: replacingPay(state, Payment.open({}), context)
# Its maker's rule on `on` settles it; anyone else, or another's rule there, is told what does. The
# first to come claims it; a principal is one word (a DID, a handle, a thing's `@<id>`).
def settle(state: State, input: SettleInput, context: Abi.Context) -> Activity<Bool>:
  if Super.ruledFrom(state, on(state), context) == false then Card.refusing(false, {clause: "ruled", reading: ruled(state)}, context) else if Super.marked(state, "done") then false else if oneWord(input.by) == false then Card.refusing(false, {clause: "by", reading: "a doer is one principal"}, context) else claiming(state, input.by, context)
def ruled(state: State) -> String:
  "it settles when {Super.field(state, \"done\")} holds of a write on {on(state)}"
def oneWord(by: String) -> Bool:
  by != "" && Text.contains(by, " ") == false && Text.contains(by, "\n") == false && Text.contains(by, "{{") == false && Text.contains(by, "}}") == false
# The rule's registration precedes the claim; a refused registration leaves completion open.
def claiming(state: State, by: String, context: Abi.Context) -> Activity<Bool>:
  replacingPay(state, Payment.claim({by: by}), context)
# The maker removes any placed pay rule before registering the spell for this phase. The same
# rule reserves the name while open, pays the claim, and casts a retry for its recorded hand.
def replacingPay(state: State, payment: Payment, context: Abi.Context) -> Activity<Bool>:
  match world.unrule({object: Plans.self(context), name: "pay"}):
    case _: placingPay(state, payment, context)
def placingPay(state: State, payment: Payment, context: Abi.Context) -> Activity<Bool>:
  match world.rule({object: Plans.self(context), name: "pay", when: payWhen(), then: payFor(state, payment)}):
    case placed(_): paymentPlaced(state, payment, context)
    case refused(r): paymentRefused(state, payment, r, context)
def paymentPlaced(state: State, payment: Payment, context: Abi.Context) -> Activity<Bool>:
  match payment:
    case open(_): placing(state, context)
    case claim(c): claimed(state, c.by, context)
    case retry(_): repaying(state, context)
def paymentRefused(state: State, payment: Payment, refusal: Card.Refusal, context: Abi.Context) -> Activity<Bool>:
  match payment:
    case open(_): Super.unarmed(state, context.object, refusal.clause, refusal.reading, context)
    case _: Card.refusing(false, refusal, context)
def claimed(state: State, by: String, context: Abi.Context) -> Activity<Bool>:
  let written(_) = write {marks: insert {name: "done", who: by, handle: "", at: context.height}}
  unsettling(state, context)
def unsettling(state: State, context: Abi.Context) -> Activity<Bool>:
  match world.unrule({object: {world: context.world, object: on(state)}, name: settles(context)}):
    case _: true
# The pay fires at the claim and at each `repay`, never at another write.
def payWhen() -> String:
  "\"done\" in new.marks.name and (request.method == \"settle\" or request.method == \"repay\")"
# The open rule holds the maker's spell; settlement and retry bind its recorded doer.
def payFor(state: State, payment: Payment) -> String:
  match payment:
    case open(_): Super.field(state, "pays")
    case claim(c): replaced(Super.field(state, "pays"), "{{request.subject}}", c.by)
    case retry(r): replaced(Super.field(state, "pays"), "{{request.subject}}", r.by)
def replaced(text: String, needle: String, by: String) -> String:
  let at = Text.indexOf(text, needle)
  if at == textLength(text) then text else "{textTake(text, at)}{by}{replaced(textDrop(text, at + textLength(needle)), needle, by)}"
# The maker casts the pay again for the hand that claimed it (a pay refused, or one its maker owes again).
def repay(state: State, context: Abi.Context) -> Activity<Bool>:
  if context.principal != state.maker then Card.refusing(false, {clause: "notMaker", reading: "Only its maker pays it again"}, context) else retrying(state, context)
def retrying(state: State, context: Abi.Context) -> Activity<Bool>:
  match Relations.lookup(state.marks, {name: "done"}):
    case some(m): replacingPay(state, Payment.retry({by: m.value.who}), context)
    case none(_): Card.refusing(false, {clause: "open", reading: "Nobody has done it yet"}, context)
def repaying(state: State, context: Abi.Context) -> Activity<Bool>:
  let written(_) = write {lines: insert {author: context.principal, handle: context.handle, verb: "repay", text: "pay requested again", at: context.height, n: state.next}, next: add 1n}
  true
def doneBy(state: State, context: Abi.Context) -> String:
  match Relations.lookup(state.marks, {name: "done"}):
    case some(m): "done by {Card.shown(m.value.who, m.value.handle, context)} at entry {natText(m.value.at)}"
    case none(_): "open"
def headLine(state: State, context: Abi.Context, id: String) -> Document.Document:
  let asks = Super.field(state, "asks")
  let condition = Super.field(state, "done")
  let pays = Super.field(state, "pays")
  Document.text("ERRAND from {Card.shown(state.maker, state.makerHandle, context)}{Card.mine(state.maker, context)}, {doneBy(state, context)}: {asks}\nOn {on(state)}, done when: {condition}\nPays: {pays}\n{payLine(state, id)}{Super.inactiveLine(state, id)}")
# Where its pay stands, once claimed: `rules` reads its firing and receipt, or why it did not fire.
def payLine(state: State, id: String) -> String:
  if Super.marked(state, "done") then "Its pay: delvetalk {id} rules\n" else ""
layer 0 (Layer0), laid by its kind 142 lines, the entry module's but for 2
--- the entry module
+++ this layer
@@ -39 +39 @@
-  from: natural 0..1000000000
+  from: natural 1..1000000000

set it in type, all 142 lines

Amend it in the workshop

Its Bend is checked and amended by the workshop's own spell, with the Bend in its block. To send it, come in; the box is here then.

Its fields

owner
yue
keeper
empty
keeperHandle
empty
head
empty
kind
kind/errand
fields
4 rows
  1. name
    asks
    value
    rain on the silver bell in the garden — the moth's resting wing wants weathering
  2. name
    on
    value
    garden/1/bell/6
  3. name
    done
    value
    count(new.lines) >= 1
  4. name
    pays
    value
    delvetalk ember/1 write / text: a warmth for the ember: someone weathered the moth's wing, and the errand kept its word.
maker
yue
makerHandle
yue
post
empty
lines
empty
pending
empty
admitted
empty
marks
1 rows
  1. name
    done
    who
    yue
    handle
    empty
    at
    1155
next
1
cites
1 rows
  1. label
    to the garden
    to
    garden/1
    description
    empty
    examples
    empty
start
empty
passages
empty
cooldown
0
requires
empty
presence
empty
vars
empty
mine
empty
left
empty
things
empty
weather
empty
tended
29865857
chose
empty
tone
empty
oddLimit
0