Package observer
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.
Stubborn class
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
port | SLObserverPort port | No description in source. |
tried | int tried | No description in source. |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
attach | void attach(String portName) | No description in source. |
portOf | SLObserverPort portOf() | No description in source. |
pump | int pump() | No description in source. |
Faulty class
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
port | SLObserverPort port | No description in source. |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
attach | void attach(String portName) | No description in source. |
portOf | SLObserverPort portOf() | No description in source. |
pump | int 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.
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
doc | SLObserverDocument doc | No description in source. |
obs | SLDocumentObserver obs | No description in source. |
view | SLObserverView view | No description in source. |
dropStage | int dropStage | No description in source. |
edits | int edits | No description in source. |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
banner | void banner(String t) | No description in source. |
pumpAll | void pumpAll() | No description in source. |
settle | int settle() | No description in source. |
setup | void setup() | No description in source. |
dropInNext | void dropInNext() | Each press of Drop in module admits the next module, mid-run. |
act | boolean act(int action) | Turn one view action into the matching observer operation. |
dump | void dump() | No description in source. |
scripted | void scripted() | Scripted clicks on a bare DOM through the view. |
main | void 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.
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
MAX_PORTS | int MAX_PORTS = 14 | No description in source. |
MAX_HOPS | int MAX_HOPS = 4 | No description in source. |
MAX_CYCLES | int MAX_CYCLES = 16 | No description in source. |
MAX_PROPOSALS | int MAX_PROPOSALS = 2 | No description in source. |
MAX_DEPTH | int MAX_DEPTH = 3 | No description in source. |
MAX_FAULTS | int MAX_FAULTS = 3 | No description in source. |
MAX_TRAIL | int MAX_TRAIL = 64 | No description in source. |
doc | SLObserverDocument doc | No description in source. |
ports | SLObserverPort[] ports | No description in source. |
portCount | int portCount | No description in source. |
busy | int busy | No description in source. |
cycles | int cycles | No description in source. |
proposals | int proposals | No description in source. |
depth | int depth | No description in source. |
applied | int applied | No description in source. |
declined | int declined | No description in source. |
dropped | int dropped | No description in source. |
quarantined | int quarantined | No description in source. |
delivered | int delivered | No description in source. |
frozen | int frozen | 1 while frozen: no content may be added by edit() or by a proposal |
trail | String[] trail | No description in source. |
trailCount | int trailCount | No description in source. |
trailLost | int trailLost | No description in source. |
Auditor class
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
port | SLObserverPort port | No description in source. |
changes | int changes | No description in source. |
questions | int questions | No description in source. |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
attach | void attach(String portName) | No description in source. |
portOf | SLObserverPort portOf() | No description in source. |
changeCount | int changeCount() | No description in source. |
pump | int 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).
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
MAX_LINES | int MAX_LINES = 64 | No description in source. |
title | String title | No description in source. |
lines | String[] lines | No description in source. |
count | int count | No description in source. |
revision | int revision | No description in source. |
lastOp | int lastOp | No description in source. |
lastLine | int lastLine | No description in source. |
lastOld | String lastOld | No description in source. |
lastNew | String lastNew | No description in source. |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
configure | void configure(String docTitle) | No description in source. |
getTitle | String getTitle() | No description in source. |
revisionNow | int revisionNow() | No description in source. |
lineCount | int lineCount() | No description in source. |
capacity | int capacity() | No description in source. |
lineAt | String lineAt(int i) | No description in source. |
getLastOp | int getLastOp() | No description in source. |
getLastLine | int getLastLine() | No description in source. |
getLastOld | String getLastOld() | No description in source. |
getLastNew | String getLastNew() | No description in source. |
restore | boolean 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. |
canApply | boolean canApply(int op, int line) | No description in source. |
apply | int 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.
Responder class
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
port | SLObserverPort port | No description in source. |
forbidden | String forbidden | No description in source. |
redactions | int redactions | No description in source. |
declinedCount | int declinedCount | No description in source. |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
attach | void attach(String portName, String forbiddenLine) | No description in source. |
portOf | SLObserverPort portOf() | No description in source. |
redactionCount | int redactionCount() | No description in source. |
declinedTotal | int declinedTotal() | No description in source. |
pump | int 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.
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
kind | int kind | No description in source. |
op | int op | No description in source. |
from | String from | No description in source. |
to | String to | No description in source. |
text | String text | No description in source. |
extra | String extra | CHANGE: the previous text of the line; otherwise free-form |
tag | String tag | who caused a CHANGE (host, a module name) |
line | int line | No description in source. |
revision | int revision | CHANGE: the new revision. PROPOSE: the revision the proposal is based on |
hops | int hops | conversation depth; the observer bounds it |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
configure | void configure(int k, String f, String t, String body) | No description in source. |
getKind | int getKind() | No description in source. |
getOp | int getOp() | No description in source. |
setOp | void setOp(int v) | No description in source. |
getFrom | String getFrom() | No description in source. |
setFrom | void setFrom(String v) | No description in source. |
getTo | String getTo() | No description in source. |
getText | String getText() | No description in source. |
getExtra | String getExtra() | No description in source. |
setExtra | void setExtra(String v) | No description in source. |
getTag | String getTag() | No description in source. |
setTag | void setTag(String v) | No description in source. |
getLine | int getLine() | No description in source. |
setLine | void setLine(int v) | No description in source. |
getRevision | int getRevision() | No description in source. |
setRevision | void setRevision(int v) | No description in source. |
getHops | int getHops() | No description in source. |
setHops | void 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).
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
MAX_IN | int MAX_IN = 16 | No description in source. |
MAX_OUT | int MAX_OUT = 8 | No description in source. |
name | String name | No description in source. |
state | int state | No description in source. |
faults | int faults | No description in source. |
lastFault | String lastFault | No description in source. |
inbox | SLObserverMessage[] inbox | No description in source. |
inCount | int inCount | No description in source. |
outbox | SLObserverMessage[] outbox | No description in source. |
outCount | int outCount | No description in source. |
received | int received | No description in source. |
sent | int sent | No description in source. |
dropped | int dropped | No description in source. |
wantInsert | int wantInsert | what this listener wants: which edit ops, and which line range |
wantReplace | int wantReplace | No description in source. |
wantDelete | int wantDelete | No description in source. |
lineFirst | int lineFirst | No description in source. |
lineLast | int lineLast | No description in source. |
missed | int missed | No description in source. |
filtered | int filtered | No description in source. |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
configure | void configure(String portName) | No description in source. |
getName | String getName() | No description in source. |
getState | int getState() | No description in source. |
setState | void setState(int s) | No description in source. |
isActive | boolean isActive() | No description in source. |
isPaused | boolean isPaused() | No description in source. |
missedCount | int missedCount() | No description in source. |
filteredCount | int filteredCount() | No description in source. |
noteMissed | void noteMissed() | No description in source. |
noteFiltered | void noteFiltered() | No description in source. |
clearMissed | void clearMissed() | No description in source. |
clearFaults | void clearFaults() | No description in source. |
setWant | void setWant(int ins, int rep, int del, int first, int last) | Set what this listener wants. Both line bounds -1 means every line. |
wantsChange | boolean wantsChange(SLObserverMessage m) | Does this listener want a CHANGE message? Other kinds always pass. |
faultCount | int faultCount() | No description in source. |
faultText | String faultText() | No description in source. |
fault | void fault(String why) | No description in source. |
receivedCount | int receivedCount() | No description in source. |
sentCount | int sentCount() | No description in source. |
droppedCount | int droppedCount() | No description in source. |
deliver | boolean deliver(SLObserverMessage m) | Deliver into the inbox. A closed port or a full inbox drops, never blocks. |
takeOut | SLObserverMessage takeOut() | No description in source. |
outPending | int outPending() | No description in source. |
hasMail | boolean hasMail() | No description in source. |
mailCount | int mailCount() | No description in source. |
next | SLObserverMessage next() | No description in source. |
say | boolean say(SLObserverMessage m) | Queue an outbound message. An overflowing outbox counts as a fault. |
note | boolean note(String to, String body) | No description in source. |
ask | boolean ask(String to, String body) | No description in source. |
reply | boolean reply(SLObserverMessage original, String body) | Answer a received message: addressed to its sender, same conversation depth. |
propose | boolean 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. |
reportFault | boolean 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.
Responder class
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
port | SLObserverPort port | No description in source. |
peer | String peer | No description in source. |
asked | int asked | No description in source. |
answered | int answered | No description in source. |
maxAsks | int maxAsks | No description in source. |
lastAnswer | String lastAnswer | No description in source. |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
attach | void attach(String portName, String peerName, int limit) | No description in source. |
portOf | SLObserverPort portOf() | No description in source. |
askedCount | int askedCount() | No description in source. |
answeredCount | int answeredCount() | No description in source. |
latestAnswer | String latestAnswer() | No description in source. |
pump | int 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?".
Responder class
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
port | SLObserverPort port | No description in source. |
lastRevision | int lastRevision | No description in source. |
lines | int lines | No description in source. |
inserts | int inserts | No description in source. |
replaces | int replaces | No description in source. |
deletes | int deletes | No description in source. |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
attach | void attach(String portName) | No description in source. |
portOf | SLObserverPort portOf() | No description in source. |
latestRevision | int latestRevision() | No description in source. |
summary | String summary() | No description in source. |
pump | int 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.
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
MAX_NODES | int MAX_NODES = 48 | No description in source. |
observer | SLDocumentObserver observer | No description in source. |
ids | String[] ids | No description in source. |
tags | String[] tags | No description in source. |
texts | String[] texts | No description in source. |
parents | String[] parents | No description in source. |
latch | int[] latch | No description in source. |
count | int count | No description in source. |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
configure | void configure(SLDocumentObserver o) | No description in source. |
nodeCount | int nodeCount() | No description in source. |
idAt | String idAt(int i) | No description in source. |
tagAt | String tagAt(int i) | No description in source. |
textAt | String textAt(int i) | No description in source. |
parentAt | String parentAt(int i) | No description in source. |
indexOf | int indexOf(String id) | No description in source. |
add | boolean add(String parent, String tag, String id) | No description in source. |
setText | void setText(String id, String t) | No description in source. |
textOf | String textOf(String id) | No description in source. |
type | void type(String t) | A host reports the user typed into the entry, or activated a button. |
press | boolean press(String id) | No description in source. |
taken | boolean taken(String id) | No description in source. |
build | void build() | No description in source. |
entryText | String entryText() | No description in source. |
clearEntry | void clearEntry() | No description in source. |
stateName | String stateName(int s) | No description in source. |
paint | void paint() | Mirror observer state into the nodes. |
service | int service() | Take one latched press: returns the action code, or 0 when idle. |