SleelaDoc API
HTML documentation for the SLeeLa standard library (/lib)
Home › Packages › observer

Package observer

This package contains 10 source unit(s) defining 16 class(es) / struct(s). Each unit below lists its fields (the values it stores) and methods (the actions it performs), with a plain explanation of each.

observer-demo #sleela 2.5 (lib/observer/observer-demo.sleela)

ObserverDemo class

Runnable, self-checking demonstrator for the dynamic document observer (lib/observer). It starts a standing document, then drops modules in (as nested classes) while the program is running, and verifies the safety envelope: proposals not mutations, optimistic concurrency, the proposal depth cap, hop-limited conversations, fault quarantine, sender stamping, admission refusals, and the cycle cap. Prints PASS/FAIL per check and a final tally.

Carries the standard Metadata Class record — eleven catalogued provenance attributes (version, id, author, date, copyright, trademark, corporation, origin, birth date, science rating, national schedule) with matching get/set accessors. These are omitted from the tables below for brevity.

Stubborn class

Fields — the named values this unit stores.

FieldDeclarationWhat it holds
portSLObserverPort portNo description in source.
triedint triedNo description in source.

Methods — the actions this unit can perform.

MethodSignatureWhat it does
attachvoid attach(String portName)No description in source.
portOfSLObserverPort portOf()No description in source.
pumpint pump()No description in source.

Faulty class

Fields — the named values this unit stores.

FieldDeclarationWhat it holds
portSLObserverPort portNo description in source.

Methods — the actions this unit can perform.

MethodSignatureWhat it does
attachvoid attach(String portName)No description in source.
portOfSLObserverPort portOf()No description in source.
pumpint pump()No description in source.

observer-gui-demo #sleela 2.5 (lib/observer/observer-gui-demo.sleela)

ObserverGuiDemo class

Runnable GUI demonstrator for the dynamic document observer. It drives SLObserverView, a retained widget tree, with scripted button clicks (append, replace, drop in a module, quit) and prints the rendered nodes, so the behavior is checkable without a display. The same view can be mounted on real widgets by any host.

Carries the standard Metadata Class record — eleven catalogued provenance attributes (version, id, author, date, copyright, trademark, corporation, origin, birth date, science rating, national schedule) with matching get/set accessors. These are omitted from the tables below for brevity.

Fields — the named values this unit stores.

FieldDeclarationWhat it holds
docSLObserverDocument docNo description in source.
obsSLDocumentObserver obsNo description in source.
viewSLObserverView viewNo description in source.
dropStageint dropStageNo description in source.
editsint editsNo description in source.

Methods — the actions this unit can perform.

MethodSignatureWhat it does
bannervoid banner(String t)No description in source.
pumpAllvoid pumpAll()No description in source.
settleint settle()No description in source.
setupvoid setup()No description in source.
dropInNextvoid dropInNext()Each press of Drop in module admits the next module, mid-run.
actboolean act(int action)Turn one view action into the matching observer operation.
dumpvoid dump()No description in source.
scriptedvoid scripted()Scripted clicks on a bare DOM through the view.
mainvoid main()No description in source.

SLDocumentObserver #sleela 2.5 (lib/observer/SLDocumentObserver.sleela)

SLDocumentObserver class

Defines SLDocumentObserver — a dynamic document observer. Modules are admitted through bounded ports WHILE THE PROGRAM IS RUNNING; when the standing document changes every active module is told, and may answer, converse with the others, or PROPOSE an edit. The observer is the only writer of the document, and it applies a proposal only if it is based on the current revision, within the per-cycle and depth budgets, and accepted by the document. Hop limits bound conversations, repeated faults quarantine a module, and everything is written to a bounded audit trail. Drive it as a cycle: edit(...) delivers the change; then while beginCycle() is true, pump every module, then endCycle() routes what they said. beginCycle() is false when nobody has mail or the cycle cap is hit.

Carries the standard Metadata Class record — eleven catalogued provenance attributes (version, id, author, date, copyright, trademark, corporation, origin, birth date, science rating, national schedule) with matching get/set accessors. These are omitted from the tables below for brevity.

Fields — the named values this unit stores.

FieldDeclarationWhat it holds
MAX_PORTSint MAX_PORTS = 14No description in source.
MAX_HOPSint MAX_HOPS = 4No description in source.
MAX_CYCLESint MAX_CYCLES = 16No description in source.
MAX_PROPOSALSint MAX_PROPOSALS = 2No description in source.
MAX_DEPTHint MAX_DEPTH = 3No description in source.
MAX_FAULTSint MAX_FAULTS = 3No description in source.
MAX_TRAILint MAX_TRAIL = 64No description in source.
docSLObserverDocument docNo description in source.
portsSLObserverPort[] portsNo description in source.
portCountint portCountNo description in source.
busyint busyNo description in source.
cyclesint cyclesNo description in source.
proposalsint proposalsNo description in source.
depthint depthNo description in source.
appliedint appliedNo description in source.
declinedint declinedNo description in source.
droppedint droppedNo description in source.
quarantinedint quarantinedNo description in source.
deliveredint deliveredNo description in source.
frozenint frozen1 while frozen: no content may be added by edit() or by a proposal
trailString[] trailNo description in source.
trailCountint trailCountNo description in source.
trailLostint trailLostNo description in source.

Auditor class

Fields — the named values this unit stores.

FieldDeclarationWhat it holds
portSLObserverPort portNo description in source.
changesint changesNo description in source.
questionsint questionsNo description in source.

Methods — the actions this unit can perform.

MethodSignatureWhat it does
attachvoid attach(String portName)No description in source.
portOfSLObserverPort portOf()No description in source.
changeCountint changeCount()No description in source.
pumpint pump()No description in source.

SLObserverDocument #sleela 2.5 (lib/observer/SLObserverDocument.sleela)

SLObserverDocument class

Defines SLObserverDocument — the standing document a dynamic observer watches: up to 64 text lines and a revision counter that moves by exactly one on every accepted edit. Every edit is validated first and a refused edit changes nothing (fail closed).

Carries the standard Metadata Class record — eleven catalogued provenance attributes (version, id, author, date, copyright, trademark, corporation, origin, birth date, science rating, national schedule) with matching get/set accessors. These are omitted from the tables below for brevity.

Fields — the named values this unit stores.

FieldDeclarationWhat it holds
MAX_LINESint MAX_LINES = 64No description in source.
titleString titleNo description in source.
linesString[] linesNo description in source.
countint countNo description in source.
revisionint revisionNo description in source.
lastOpint lastOpNo description in source.
lastLineint lastLineNo description in source.
lastOldString lastOldNo description in source.
lastNewString lastNewNo description in source.

Methods — the actions this unit can perform.

MethodSignatureWhat it does
configurevoid configure(String docTitle)No description in source.
getTitleString getTitle()No description in source.
revisionNowint revisionNow()No description in source.
lineCountint lineCount()No description in source.
capacityint capacity()No description in source.
lineAtString lineAt(int i)No description in source.
getLastOpint getLastOp()No description in source.
getLastLineint getLastLine()No description in source.
getLastOldString getLastOld()No description in source.
getLastNewString getLastNew()No description in source.
restoreboolean restore(String[] saved, int savedCount, int savedRevision)Put back a saved state exactly: the lines, their count and the revision counter. Used by a host that rolls a session back (it bypasses the observer, so the host must tell its own listeners). Refused when the saved state does not fit.
canApplyboolean canApply(int op, int line)No description in source.
applyint apply(int op, int line, String text)Apply one edit. Returns the new revision, or -1 with NO change made.

SLObserverGuardModule #sleela 2.5 (lib/observer/SLObserverGuardModule.sleela)

SLObserverGuardModule class

A drop-in module for the dynamic document observer. The nested class SLObserverGuardModule.Responder watches for a forbidden line (exact match) and PROPOSES replacing it with a redaction marker. It never edits the document itself: the observer decides, and tells the guard the result.

Carries the standard Metadata Class record — eleven catalogued provenance attributes (version, id, author, date, copyright, trademark, corporation, origin, birth date, science rating, national schedule) with matching get/set accessors. These are omitted from the tables below for brevity.

Responder class

Fields — the named values this unit stores.

FieldDeclarationWhat it holds
portSLObserverPort portNo description in source.
forbiddenString forbiddenNo description in source.
redactionsint redactionsNo description in source.
declinedCountint declinedCountNo description in source.

Methods — the actions this unit can perform.

MethodSignatureWhat it does
attachvoid attach(String portName, String forbiddenLine)No description in source.
portOfSLObserverPort portOf()No description in source.
redactionCountint redactionCount()No description in source.
declinedTotalint declinedTotal()No description in source.
pumpint pump()No description in source.

SLObserverMessage #sleela 2.5 (lib/observer/SLObserverMessage.sleela)

SLObserverMessage class

Defines SLObserverMessage — the one envelope the dynamic document observer and its modules speak. A message is a NOTE, QUESTION, ANSWER, PROPOSE, FAULT, or CHANGE; CHANGE is what the observer sends when the standing document moves, and the rest are how modules converse with the observer and with each other. The observer stamps the sender on routing so a module cannot impersonate another.

Carries the standard Metadata Class record — eleven catalogued provenance attributes (version, id, author, date, copyright, trademark, corporation, origin, birth date, science rating, national schedule) with matching get/set accessors. These are omitted from the tables below for brevity.

Fields — the named values this unit stores.

FieldDeclarationWhat it holds
kindint kindNo description in source.
opint opNo description in source.
fromString fromNo description in source.
toString toNo description in source.
textString textNo description in source.
extraString extraCHANGE: the previous text of the line; otherwise free-form
tagString tagwho caused a CHANGE (host, a module name)
lineint lineNo description in source.
revisionint revisionCHANGE: the new revision. PROPOSE: the revision the proposal is based on
hopsint hopsconversation depth; the observer bounds it

Methods — the actions this unit can perform.

MethodSignatureWhat it does
configurevoid configure(int k, String f, String t, String body)No description in source.
getKindint getKind()No description in source.
getOpint getOp()No description in source.
setOpvoid setOp(int v)No description in source.
getFromString getFrom()No description in source.
setFromvoid setFrom(String v)No description in source.
getToString getTo()No description in source.
getTextString getText()No description in source.
getExtraString getExtra()No description in source.
setExtravoid setExtra(String v)No description in source.
getTagString getTag()No description in source.
setTagvoid setTag(String v)No description in source.
getLineint getLine()No description in source.
setLinevoid setLine(int v)No description in source.
getRevisionint getRevision()No description in source.
setRevisionvoid setRevision(int v)No description in source.
getHopsint getHops()No description in source.
setHopsvoid setHops(int v)No description in source.

SLObserverPort #sleela 2.5 (lib/observer/SLObserverPort.sleela)

SLObserverPort class

Defines SLObserverPort — the bounded mailbox a module is admitted through. The observer delivers into the inbox and collects from the outbox; the module only ever reads its own inbox and writes its own outbox, so a misbehaving module can hurt nothing but itself (full inbox drops, outbox overflow and reported faults count toward quarantine).

Carries the standard Metadata Class record — eleven catalogued provenance attributes (version, id, author, date, copyright, trademark, corporation, origin, birth date, science rating, national schedule) with matching get/set accessors. These are omitted from the tables below for brevity.

Fields — the named values this unit stores.

FieldDeclarationWhat it holds
MAX_INint MAX_IN = 16No description in source.
MAX_OUTint MAX_OUT = 8No description in source.
nameString nameNo description in source.
stateint stateNo description in source.
faultsint faultsNo description in source.
lastFaultString lastFaultNo description in source.
inboxSLObserverMessage[] inboxNo description in source.
inCountint inCountNo description in source.
outboxSLObserverMessage[] outboxNo description in source.
outCountint outCountNo description in source.
receivedint receivedNo description in source.
sentint sentNo description in source.
droppedint droppedNo description in source.
wantInsertint wantInsertwhat this listener wants: which edit ops, and which line range
wantReplaceint wantReplaceNo description in source.
wantDeleteint wantDeleteNo description in source.
lineFirstint lineFirstNo description in source.
lineLastint lineLastNo description in source.
missedint missedNo description in source.
filteredint filteredNo description in source.

Methods — the actions this unit can perform.

MethodSignatureWhat it does
configurevoid configure(String portName)No description in source.
getNameString getName()No description in source.
getStateint getState()No description in source.
setStatevoid setState(int s)No description in source.
isActiveboolean isActive()No description in source.
isPausedboolean isPaused()No description in source.
missedCountint missedCount()No description in source.
filteredCountint filteredCount()No description in source.
noteMissedvoid noteMissed()No description in source.
noteFilteredvoid noteFiltered()No description in source.
clearMissedvoid clearMissed()No description in source.
clearFaultsvoid clearFaults()No description in source.
setWantvoid setWant(int ins, int rep, int del, int first, int last)Set what this listener wants. Both line bounds -1 means every line.
wantsChangeboolean wantsChange(SLObserverMessage m)Does this listener want a CHANGE message? Other kinds always pass.
faultCountint faultCount()No description in source.
faultTextString faultText()No description in source.
faultvoid fault(String why)No description in source.
receivedCountint receivedCount()No description in source.
sentCountint sentCount()No description in source.
droppedCountint droppedCount()No description in source.
deliverboolean deliver(SLObserverMessage m)Deliver into the inbox. A closed port or a full inbox drops, never blocks.
takeOutSLObserverMessage takeOut()No description in source.
outPendingint outPending()No description in source.
hasMailboolean hasMail()No description in source.
mailCountint mailCount()No description in source.
nextSLObserverMessage next()No description in source.
sayboolean say(SLObserverMessage m)Queue an outbound message. An overflowing outbox counts as a fault.
noteboolean note(String to, String body)No description in source.
askboolean ask(String to, String body)No description in source.
replyboolean reply(SLObserverMessage original, String body)Answer a received message: addressed to its sender, same conversation depth.
proposeboolean propose(int op, int line, String body, int baseRevision)Ask the observer to edit the document (op 0 insert, 1 replace, 2 delete). The edit is only applied if baseRevision is still current.
reportFaultboolean reportFault(String why)No description in source.

SLObserverReviewModule #sleela 2.5 (lib/observer/SLObserverReviewModule.sleela)

SLObserverReviewModule class

A drop-in module for the dynamic document observer. The nested class SLObserverReviewModule.Responder opens a conversation when admitted: it asks the auditor for its change count and keeps asking while answers come back (up to a fixed number of questions). The observer hop limit is what finally ends the conversation.

Carries the standard Metadata Class record — eleven catalogued provenance attributes (version, id, author, date, copyright, trademark, corporation, origin, birth date, science rating, national schedule) with matching get/set accessors. These are omitted from the tables below for brevity.

Responder class

Fields — the named values this unit stores.

FieldDeclarationWhat it holds
portSLObserverPort portNo description in source.
peerString peerNo description in source.
askedint askedNo description in source.
answeredint answeredNo description in source.
maxAsksint maxAsksNo description in source.
lastAnswerString lastAnswerNo description in source.

Methods — the actions this unit can perform.

MethodSignatureWhat it does
attachvoid attach(String portName, String peerName, int limit)No description in source.
portOfSLObserverPort portOf()No description in source.
askedCountint askedCount()No description in source.
answeredCountint answeredCount()No description in source.
latestAnswerString latestAnswer()No description in source.
pumpint pump()No description in source.

SLObserverSummaryModule #sleela 2.5 (lib/observer/SLObserverSummaryModule.sleela)

SLObserverSummaryModule class

A drop-in module for the dynamic document observer. The nested class SLObserverSummaryModule.Responder tracks the latest revision, line count and edit mix, and answers the question "summary?".

Carries the standard Metadata Class record — eleven catalogued provenance attributes (version, id, author, date, copyright, trademark, corporation, origin, birth date, science rating, national schedule) with matching get/set accessors. These are omitted from the tables below for brevity.

Responder class

Fields — the named values this unit stores.

FieldDeclarationWhat it holds
portSLObserverPort portNo description in source.
lastRevisionint lastRevisionNo description in source.
linesint linesNo description in source.
insertsint insertsNo description in source.
replacesint replacesNo description in source.
deletesint deletesNo description in source.

Methods — the actions this unit can perform.

MethodSignatureWhat it does
attachvoid attach(String portName)No description in source.
portOfSLObserverPort portOf()No description in source.
latestRevisionint latestRevision()No description in source.
summaryString summary()No description in source.
pumpint pump()No description in source.

SLObserverView #sleela 2.5 (lib/observer/SLObserverView.sleela)

SLObserverView class

Defines SLObserverView — the modest GUI for the dynamic document observer. It is a small retained widget tree (labels, an entry, buttons) that mirrors the standing document, the module roster and the audit trail, and turns button presses into latched actions the host loop services with the same take-the-latch discipline as the gui package. It is self-contained on purpose: a host walks nodeCount()/tagAt()/textAt() to mount it on real widgets and calls press(id) when a button is activated.

Carries the standard Metadata Class record — eleven catalogued provenance attributes (version, id, author, date, copyright, trademark, corporation, origin, birth date, science rating, national schedule) with matching get/set accessors. These are omitted from the tables below for brevity.

Fields — the named values this unit stores.

FieldDeclarationWhat it holds
MAX_NODESint MAX_NODES = 48No description in source.
observerSLDocumentObserver observerNo description in source.
idsString[] idsNo description in source.
tagsString[] tagsNo description in source.
textsString[] textsNo description in source.
parentsString[] parentsNo description in source.
latchint[] latchNo description in source.
countint countNo description in source.

Methods — the actions this unit can perform.

MethodSignatureWhat it does
configurevoid configure(SLDocumentObserver o)No description in source.
nodeCountint nodeCount()No description in source.
idAtString idAt(int i)No description in source.
tagAtString tagAt(int i)No description in source.
textAtString textAt(int i)No description in source.
parentAtString parentAt(int i)No description in source.
indexOfint indexOf(String id)No description in source.
addboolean add(String parent, String tag, String id)No description in source.
setTextvoid setText(String id, String t)No description in source.
textOfString textOf(String id)No description in source.
typevoid type(String t)A host reports the user typed into the entry, or activated a button.
pressboolean press(String id)No description in source.
takenboolean taken(String id)No description in source.
buildvoid build()No description in source.
entryTextString entryText()No description in source.
clearEntryvoid clearEntry()No description in source.
stateNameString stateName(int s)No description in source.
paintvoid paint()Mirror observer state into the nodes.
serviceint service()Take one latched press: returns the action code, or 0 when idle.