Inspecting kind/errand · the kinds · the language · the modules
kind/errand
- id
- kind/errand
- kind chain
- kind/errand → record
- owner
- the town
- made by
- the town
- version
- 9
- pin
- fazim-dakat
- state
- 9899 bytes
Its spells
To cast them, come in.
Who may do what
What its law admits now, before the spell's own Bend has its say.
| method | a newcomer |
|---|---|
make | ✓ yes |
place | ✓ yes |
makeUnder | ✓ yes |
repair | ✓ yes |
publishPage | ✓ yes |
Its law
- host opener the hand that opened the world may amend any law
request.kind == 2 and request.subject == "the town" - law owner the owner stays; only the owner changes the form, the law, the head, the voice, what it is or the body; anyone makes, 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(form))) and (unchanged(law))) and (unchanged(head))) and (unchanged(voice))) and (unchanged(about))) and (unchanged(body)))) - law kind kinds's law holds
under "kinds"
Its Bend
what it runs: its entry module 22 lines
layer over ./Kind.obend
edition ObjectiveBend 1
import ./Abi.obend as Abi
import ./List.obend as Lists
import ./Form.obend as Form
import ./Rows.obend as Rows
type State = Super.State
form make:
asks: text 1..200
on: object 1..128
done: text 1..400
pays: text 1..400
def make(state: State, input: MakeInput, context: Abi.Context) -> Activity<Super.Done>:
Super.making(state, Lists.List.cons({head: {name: "asks", value: input.asks}, tail: Lists.List.cons({head: {name: "on", value: input.on}, tail: Lists.List.cons({head: {name: "done", value: input.done}, tail: Lists.List.cons({head: {name: "pays", value: input.pays}, tail: Lists.List.nil()})})})}), "", context)
form place:
asks: text 1..200
on: object 1..128
done: text 1..400
pays: text 1..400
id: object 1..64
def place(state: State, input: PlaceInput, context: Abi.Context) -> Activity<Super.Done>:
Super.making(state, Lists.List.cons({head: {name: "asks", value: input.asks}, tail: Lists.List.cons({head: {name: "on", value: input.on}, tail: Lists.List.cons({head: {name: "done", value: input.done}, tail: Lists.List.cons({head: {name: "pays", value: input.pays}, tail: Lists.List.cons({head: {name: "id", value: input.id}, tail: Lists.List.nil()})})})})}), "", context)
the body this kind lays on what it makes 142 lines
Each thing of this kind runs this layer over what the kind is of.
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
- the town
- ownerHandle
- the town
- name
- errand
- of
- record
- form
asks: text 1..200 (71 characters)
asks: text 1..200 on: object 1..128 done: text 1..400 pays: text 1..400
- law
- empty
- head
- empty
- voice
- what is asked and what it pays; a ping is not a debt
- about
- a request with a pay, settled when its condition comes true
- body
layer over ./Record.obend (9457 characters)
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 ""- made
4 rows
- object
- errand/1
- n
- 1
- about
- empty
- object
- errand/2
- n
- 2
- about
- empty
- object
- errand/3
- n
- 3
- about
- empty
- object
- errand/4
- n
- 4
- about
- empty
- count
- 4