opsis

2026-11-29

Condition-based observability for Common Lisp

Upstream URL

github.com/quasi/opsis

Author

Abhijit Rao <quasi@quasilabs.in>

License

MIT
README

Opsis (ὄψις)

Condition-based observability for Common Lisp. Libraries signal structured events. Applications decide what to do with them.

;; In your library — zero dependencies
(opsis/c:emit :tool-exec-completed
              :level :info
              :source "my-tool"
              :data '(:duration-ms 42 :result-size 1024))

;; In your application — plug in what you need
(opsis:with-observability ((opsis:default-sinks))
  (opsis/c:with-correlation ()
    (run-my-application)))

Output:

2026-02-25T14:30:02 [INFO] [ax7f3b2c] my-tool/tool-exec-completed (:DURATION-MS 42 :RESULT-SIZE 1024)

Comes with 2 SKILLS for development or integration. Point your agent to the project and it will figure out how to use it.

Why

Most CL observability tools bind the library author to a format, a destination, or a performance cost. Opsis inverts this. Libraries call emit — a thin wrapper around cl:signal — and pay nothing if no handlers are installed. Applications install sinks that decide how to format, filter, and route events.

This is the CL condition system used as an observability bus:

  • Near-zero overhead when unused — unhandled signal returns immediately
  • No format coupling — the event carries a keyword kind and a raw data plist; sinks render it
  • Structural composability — with-observability nests naturally via handler-bind
  • Rich payloads — data carries arbitrary CL objects, not pre-formatted strings
  • Automatic correlation — events capture *correlation-id* from dynamic scope

Install

Clone to your Quicklisp local-projects directory and load:

(ql:quickload "opsis/conditions")   ; signaling only — zero deps
(ql:quickload "opsis")              ; full system: sinks + with-observability
(ql:quickload "opsis/vigil")        ; optional vigil metrics sink

The Two Roles

Library author: signal, don't decide

Depend only on opsis/conditions (zero external dependencies):

(ql:quickload "opsis/conditions")

;; Emit at key lifecycle points
(opsis/c:emit :request-received :source "my-lib" :level :info
              :data (list :method method))

(opsis/c:emit :request-failed :source "my-lib" :level :error
              :message (princ-to-string condition)
              :data (list :method method))

Calls to emit are silent no-ops if no application has installed a sink. Near-zero overhead (one function call, no I/O).

Application: install sinks, own the output

;; One-liner sensible default — stderr at :warn
(opsis:with-observability ((opsis:default-sinks))
  (run-server))

;; Custom configuration (vigil-sink requires opsis/vigil loaded)
(opsis:with-observability
    ((make-instance 'opsis:stderr-sink :name "console" :min-level :debug)
     (make-instance 'opsis:vigil-sink :name "metrics" :store my-vigil-store))
  (run-server))

Correlation IDs

Wrap request boundaries in with-correlation. All events inside automatically carry the same ID:

(opsis/c:with-correlation ()
  ;; All emit calls here share one correlation ID
  (handle-request req))

;; Propagate to sub-processes
(opsis/c:with-correlation (opsis/c:*correlation-id*)
  (delegate-to-worker task))

The stderr-sink includes the ID in every output line. Post-mortem: grep by correlation ID to trace a complete interaction.

Custom Sinks

Subclass sink using telos:defclass/i (plain defclass will fail — sink uses the telos:intentful-class metaclass), then implement sink-handle:

(telos:defclass/i my-sink (opsis:sink)
  ()
  (:role "alert forwarder")
  (:purpose "send errors to external alerting"))

(defmethod opsis:sink-handle ((sink my-sink) event)
  (when (eq :error (opsis/c:event-level event))
    (alert-pagerduty (opsis/c:event-message event))))

Override sink-accepts-p for custom filtering beyond level:

(defmethod opsis:sink-accepts-p ((sink my-sink) event)
  (and (call-next-method)
       (string= "my-lib" (opsis/c:event-source event))))

Event Slots

SlotReaderTypeDefault
kindevent-kindkeywordrequired
levelevent-level:debug :info :warn :error:info
messageevent-messagestring or nilnil
dataevent-dataanynil
sourceevent-sourcestring or nilnil
correlationevent-correlationstring or nil*correlation-id*
timestampevent-timestampuniversal-time(get-universal-time)

Systems

SystemPurposeDependencies
opsis/conditionsemit, event condition, correlationnone
opsisSink protocol, with-observability, stderr/null sinksopsis/conditions, bordeaux-threads, local-time, telos
opsis/vigilVigil metrics sinkopsis, vigil

Tests

(asdf:test-system "opsis/conditions")  ; conditions tests
(asdf:test-system "opsis")             ; sinks + integration tests
(asdf:test-system "opsis/vigil")       ; vigil sink tests

Documentation

DocumentPurpose
Design docArchitecture decisions, system design
Dev skillWorking on opsis (contributors)
Integration skillUsing opsis in another project (agent-oriented)

Status

Under active development. API is stabilising. Not yet in Quicklisp.

License

MIT. Copyright 2026 Abhijit Rao (quasi / quasiLabs).

Dependencies (4)

  • bordeaux-threads
  • fiveam
  • local-time
  • telos

Dependents (0)

    • GitHub
    • Quicklisp