Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

realmwatch source realm

RealmWatch — the on-chain leash for an autonomous agent.

Overview

RealmWatch — the on-chain leash for an autonomous agent.

An off-chain agent watches things and posts alerts. This realm is its public control and audit layer:

  • a registry of what the agent is allowed to watch,
  • an append-only log of everything the agent did,
  • a STOP flag and a per-epoch action cap that the REALM enforces.

The point: the cap and the kill switch do not live in the agent's code, where a bug (or a prompt injection) could talk the agent out of them. They live here, in the chain's state. A PostAlert that arrives while STOP is set, or after the epoch cap is spent, reverts. The agent cannot sweet-talk a smart contract.

Trust model:

  • The owner (deployer) configures: agent address, watches, cap, STOP. Only the owner can change configuration.
  • The registered agent address — and only it — can append log entries, and only within the cap and only while not stopped.
  • The agent may trip STOP itself (self-arrest), but only the owner can clear it.
  • All privileged entry points require a direct user call (maketx call from the EOA), never a realm-to-realm call, so caller identity cannot be laundered through another contract.

Functions 20

func AddWatch

crossing Action
1func AddWatch(cur realm, id string, kind string, target string, note string)
source

AddWatch registers a new watch target. Owner only.

func ClaimOwnership

crossing Action
1func ClaimOwnership(cur realm)
source

ClaimOwnership sets the owner when the deploy-time capture was empty. It can only ever succeed once, and only while no owner is set; the deployer calls it immediately after addpkg.

func EntryAt

Action
1func EntryAt(seqNo uint64) string
source

EntryAt returns one log entry as "seq|height|kind|severity|watchID|summary", or "" if out of range. seqNo is 1-based, matching Entry.Seq.

func PostAlert

crossing Action
1func PostAlert(cur realm, kind string, severity string, watchID string, summary string) string
source

PostAlert appends one entry to the log. This is the agent's ONLY write action, and the realm gates it four ways:

  1. caller must be the registered agent, calling directly,
  2. STOP must be clear,
  3. the named watch must exist and be active,
  4. the per-epoch cap must not be exhausted.

Any violation panics, the transaction reverts, and nothing is written. Returns the sequence number of the new entry.

func SetAgent

crossing Action
1func SetAgent(cur realm, addr address)
source

SetAgent registers (or replaces) the agent address allowed to post.

func SetCap

crossing Action
1func SetCap(cur realm, cap uint64, epochLenBlocks int64)
source

SetCap sets the per-epoch action cap and the epoch length in blocks. Changing the cap restarts the current window. Owner only.

func SetStopped

crossing Action
1func SetStopped(cur realm, stop bool)
source

SetStopped is the kill switch. Owner only. While stopped, every agent post reverts on-chain.

func SetWatchActive

crossing Action
1func SetWatchActive(cur realm, id string, active bool)
source

SetWatchActive pauses or resumes a single watch without deleting it. A paused watch rejects agent posts. Owner only.

func TripStop

crossing Action
1func TripStop(cur realm)
source

TripStop lets the agent arrest itself: if the agent concludes it is compromised or confused, it can halt itself without waiting for the owner. Only the owner can clear the stop afterwards.

func WatchIDs

Action
1func WatchIDs() string
source

WatchIDs returns the registered watch ids, comma-separated, in registration order (active and paused).

func WatchTarget

Action
1func WatchTarget(id string) string
source

WatchTarget returns "kind|target|active" for one watch, or "".

Types 2

type Entry

struct
1type Entry struct {
2	Seq      uint64
3	Height   int64
4	Kind     string // "BASELINE" | "CHANGE" | "HEARTBEAT" | "NOTE"
5	Severity string // "INFO" | "WARN" | "CRIT"
6	WatchID  string // watch this entry belongs to ("" = system)
7	Summary  string // one line, agent-written, human-readable
8}
source

Entry is one append-only log record. Entries are never edited or deleted; Seq is monotone for the life of the realm.

type Watch

struct
1type Watch struct {
2	ID     string // unique, owner-chosen, e.g. "tavern-board"
3	Kind   string // "realm" | "balance" | "height"
4	Target string // realm path, g1 address, or "" for height
5	Note   string // human note: why this is watched
6	Active bool
7}
source

Watch is one registered monitoring target.

Dependencies

Imports 4

/r/g15gz99k0zsv59wgvyv5ulxzv5f2dkyzvh0zhaga/realmwatch

Imported by indexer

Source Files 3