Skip to content

Record JupyterGIS events from Jupyter Server event feeds - #4

Open
hodczak wants to merge 1 commit into
mainfrom
jupyter
Open

hodczak wants to merge 1 commit into
mainfrom
jupyter

Conversation

@hodczak

@hodczak hodczak commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Note

🤖 This PR is AI-generated and human-reviewed, based on human-written notes.

Tip

📓 ai/examples/jupyter.ipynb demonstrates this PR against a real Jupyter Server.

This PR lets Trail record what users do in JupyterGIS. JupyterGIS posts events to Jupyter
Server, Jupyter Server broadcasts them on its event feed, and Trail subscribes to that feed and
records each message as an event on the map file's asset.

  • Server discovery: find running Jupyter servers from their runtime files, or add one by hand with trail.jupyter.connect().
  • Feed subscriptions: keep one websocket subscription per server, with reconnects, backoff, and a connection state.
  • Event recording: resolve each message's map path to a tracked asset and record a JupyterEvent. Messages that cannot be attributed are skipped with a reason.
  • Shared sessions: factor the run lifecycle out of WatchdogSession into a Session base. Watchdog and Jupyter sessions hold Trail's lock together.
  • Console: the terminal starts both sessions, reports server state changes, and shows subscribed servers in its header.

Event flow

An event travels from JupyterGIS to Trail's log as follows:

flowchart TD
    gis["JupyterGIS (browser)"] -- "POST /api/events" --> js["Jupyter Server"]
    js -. "writes at startup" .-> rt[("jpserver-*.json")]
    subgraph session ["trail.jupyter.session"]
        refresh["Servers.refresh()<br/>every 2 s"]
        sub["Server.subscribe()"]
        con["Consumer.text_to_message()"]
        msg["Message"]
    end
    rt -. "JSONs.refresh()" .-> refresh
    refresh -- "starts" --> sub
    js -- "/api/events/subscribe" --> sub
    sub -- "feed text" --> con
    con --> msg
    msg -- "_message_to_asset()" --> asset["Asset (.jGIS file)"]
    msg -- "JupyterEvent.apply()" --> events[("trail.events")]
    msg -- "kept" --> msgs[("session.messages")]
Loading
  1. Jupyter, reached as trail.jupyter, owns discovery and one JupyterSession.
  2. Every 2 seconds the session calls Servers.refresh(). It rereads the runtime files through JSONs and starts a Server.subscribe() task for each eligible server.
  3. Each feed message goes to the session's Consumer, which wraps it in a Message, resolves its map file, and records a JupyterEvent.
  4. The session keeps the latest messages in Messages for debugging.

Access map

Everything in this PR is reached from a Trail. Solid arrows are attributes; dotted arrows are lookups by key:

flowchart TD
    trail(["Trail"]) -- ".jupyter" --> jupyter(["Jupyter"])
    trail -- ".events" --> events(["Events"])
    jupyter -- ".jsons" --> jsons(["JSONs"])
    jupyter -- ".manual" --> manual(["dict[str, JSON]"])
    jupyter -- ".disconnected" --> disconnected(["set[str]"])
    jupyter -- ".session" --> session(["JupyterSession"])
    jsons -. "[path]" .-> json(["JSON"])
    session -- ".servers" --> servers(["Servers"])
    session -- ".consumer" --> consumer(["Consumer"])
    session -- ".messages" --> messages(["Messages"])
    servers -. "[url]" .-> server(["Server"])
    messages -. "[id]" .-> message(["Message"])
    events -. "[id]" .-> event(["JupyterEvent"])
Loading

Entry point

Jupyter is reached through Trail.jupyter, the only new attribute on Trail. Everything else in this PR is reached through it.

Jupyter(Node)

Jupyter holds the Jupyter integration of one project: server discovery, manually added servers, and the current session. Its repr lists the servers of that session.

trail.jupyter: Jupyter

>>> trail.jupyter
Servers (0)
Attribute Meaning
session The current JupyterSession. del trail.jupyter.session closes it and creates a fresh one
jsons JSONs: the runtime files Trail discovers automatically
manual dict[str, JSON]: servers added with connect(), by URL
disconnected set[str]: URLs closed by disconnect(). Excluded from automatic reconnection
on_notice Callback for status text such as state changes. The console prints it
on_message Callback for each kept Message
  • Jupyter.connect(url=, token=, root=) adds a server Trail cannot discover, such as one in a container, to manual.
    • url is the server's HTTP(S) base URL, such as http://localhost:8888/ or http://localhost:8888/jupyter/.
    • token is its authentication token, or an empty string.
    • root is the server's document root as Trail sees it. Feed messages name files relative to it. Discovery reads it from root_dir in the runtime file.
  • Jupyter.disconnect(url) closes the server's feed and adds its URL to disconnected. The set lives on Jupyter, not the session, so later refreshes and replacement sessions in the same process do not reconnect. It is not saved to disk. connect() removes the URL again.
  • Jupyter.overlaps(root) decides whether a discovered server can name a tracked file. Servers that do not overlap stay available and are not subscribed. Jupyter.is_inside(folder) decides whether a new map file belongs to the project.
  • A failing on_notice or on_message callback only warns.

After a disconnect, connect() reattaches the same server. The manual details differ from the runtime file's, so the server is replaced by a new Server with the next number:

trail.jupyter.manual: dict[str, JSON]

>>> trail.jupyter.manual
{'http://127.0.0.1:43913/': JSON(url='http://127.0.0.1:43913/', root=PosixPath('/tmp/trail-jupyter-ts19as0a/project'), path=None, pid=None, mtime=0.0, is_password_protected=False)}

Server discovery

Jupyter Server writes jpserver-<pid>.json to its runtime directory at startup and removes it at shutdown. jupyter --paths lists that directory; JUPYTER_RUNTIME_DIR overrides it.

  • JSON holds the connection details of one server.
  • Secret hides its token.
  • JSONs reads the runtime files into JSON instances.

JSON

JSON is a frozen dataclass of one server's connection details, from its runtime file or from connect().

trail.jupyter.jsons[path]: JSON

>>> info = next(iter(trail.jupyter.jsons.values()))
>>> info
JSON(url='http://127.0.0.1:43913/', root=PosixPath('/tmp/trail-jupyter-ts19as0a/project'), path=PosixPath('/tmp/trail-jupyter-ts19as0a/runtime/jpserver-310177.json'), pid=310177, mtime=1796354587.8447666, is_password_protected=False)
>>> info.token
<secret>
>>> info.is_running
True
Field Meaning
url Base HTTP(S) URL, normalized by normalize_url() and used as the server key
root Document root. Feed paths are relative to it
token Authentication token as a Secret. Excluded from the repr and from equality
path Runtime file the details came from, or None for connect()
pid Server process ID from the runtime file
mtime Runtime file modification time, in seconds since the epoch
is_password_protected Whether a password is configured. Trail can still connect with a token
  • JSON.is_running is always True for a manually added server, even before a connection succeeds. For a discovered server it is False if the PID is invalid, the process has exited or is a zombie, or the PID was reused by a process started after the runtime file was written.
  • normalize_url() adds the trailing slash and rejects a token query string, user:password@host credentials, non-HTTP schemes, and fragments.

Secret

Secret holds a token. Its repr and string are <secret>, and pickling it raises TypeError, so tokens cannot reach reprs, logs, or the event log.

JSONs(Mapping[Path, JSON])

JSONs maps runtime file paths to their JSON.

trail.jupyter.jsons: JSONs

>>> trail.jupyter.jsons
JSONs (1)
    /tmp/trail-jupyter-ts19as0a/runtime/jpserver-310177.json: http://127.0.0.1:43913/ /tmp/trail-jupyter-ts19as0a/project
  • JSONs.refresh() is called by Servers.refresh(). It globs jpserver-*.json, rereads a file only when its modification time or size changed, and drops entries for removed files.

Note

🚧 Invalid runtime files and Unix-socket servers are skipped silently (todo).


Sessions

A session is a run that lasts from start() to close() or stop(). This PR adds a Jupyter session beside the filesystem one and moves their shared lifecycle into a base class.

Session(Node)

Session is the base of WatchdogSession and JupyterSession. It supplies async with: __aenter__ starts a run and __aexit__ stops it.

  • bool(session) says whether a run has started in this process and has not closed. A forked child does not inherit the run.
  • is_active says whether the run's tasks are alive.
  • Both subclasses acquire trail.lock when they start. Two sessions in one process share it; another process cannot record into the same project until both release it.

WatchdogSession, with Handler, Access, Accesses, Watches, and Arrival, moves from trail.session to trail.watchdog. trail.session keeps only the base class.

JupyterSession(Session)

JupyterSession is the run that discovers servers and listens to their feeds. It does nothing until started.

trail.jupyter.session: JupyterSession

>>> session = trail.jupyter.session
>>> bool(session)
False
>>> session.is_active
False
>>> session.start()
True
>>> bool(session)
True
>>> session.is_active
True
>>> trail.lock.holders
{<trail.jupyter.session.JupyterSession at 0x7f781373e7e0>,
 <trail.watchdog.WatchdogSession at 0x7f7812ac6480>}

In the notebook, the watchdog session started on the kernel's loop when the project opened, so both sessions hold the lock.

The notebook stops the session at the end:

>>> await session.stop()
>>> bool(session)
False
>>> server.state
'stopped'

Servers and subscriptions

  • Servers holds the servers of one session and decides which to subscribe to.
  • Server holds one subscription, its state, and its message counts.

Servers(Mapping[str, Server])

Servers maps normalized server URLs to Server instances. Lookup normalizes the key, so servers['http://127.0.0.1:43913'] also works.

trail.jupyter.session.servers: Servers

>>> trail.jupyter.session.servers
Servers (1)
    0. Server
        number: 1
        state: subscribed
        url: http://127.0.0.1:43913/
        root: PosixPath('/tmp/trail-jupyter-ts19as0a/project')
        counts: Counts(received=0, recorded=0, skipped=Counter(), other=Counter())

Servers.refresh() reconciles the servers with the runtime files and Jupyter.manual:

  • A URL that disappears is marked stopped.
  • If several runtime files share a URL, the running server with the newest file wins, so a stale file cannot hide a live server.
  • Changed details, such as a restarted server with a new token, replace the Server with a new one and a new number. The old one is marked stopped.
  • A server is subscribed only if it is running, is not in Jupyter.disconnected, has a token when password-protected, and overlaps the project or was added with connect().

Server

Server is one Jupyter server and the state of its feed subscription.

trail.jupyter.session.servers[url]: Server

Field Meaning
servers The Servers that holds it
number Order in which the session found it, from 1. A short label in notices. A restarted server on the same URL gets a new number
json The JSON it was found with
state Connection state, one of State below
last_error Reason for the latest state, or empty
counts Counts of messages received, recorded, skipped by Reason, and other by schema for schemas Trail does not handle
subjects Asset of each JupyterGIS client's map view, by feed subject
task Task running subscribe()
backoff, ceiling First and longest reconnect wait, 0.5 s and 30 s

Connection states

State Meaning
available Found but not subscribed, often because it does not overlap the project
connecting Opening the feed connection
subscribed Connected and receiving messages
retrying Connection failed or closed; waiting to reconnect
refused HTTP 401/403, a redirect, or TLS verification failure
unsupported HTTP 404: the server has no event feed
error An unexpected error ended the subscription
disconnected Closed by disconnect()
stopped Runtime file or process gone, or the session ended

A server moves between these states as follows. The dashed states end the subscription task: refused, unsupported and error; the server stays in that state until it is disconnected, its runtime file goes away, or changed connection details make Servers.refresh() replace it with a new Server.

flowchart TD
    available([available])
    connecting([connecting])
    subscribed([subscribed])
    retrying([retrying])
    refused([refused])
    unsupported([unsupported])
    error([error])
    any(["any state"])
    disconnected([disconnected])
    stopped([stopped])
    available -- "eligible, session active" --> connecting
    connecting -- "websocket open" --> subscribed
    subscribed -- "connection closed" --> retrying
    retrying -- "after backoff" --> connecting
    connecting -- "connection failed" --> retrying
    connecting -- "401/403, redirect, TLS" ---> refused
    connecting -- "404" ---> unsupported
    connecting -- "unexpected error" ---> error
    any -- "disconnect()" --> disconnected
    any -- "process gone, session ends" --> stopped
    stopped -- "session restarts" --> connecting
    classDef dead stroke-dasharray: 5 4
    class refused,unsupported,error dead
Loading

Feed subscription

Server.subscribe() is the task started by Servers.refresh():

  1. JupyterGIS posts each event to POST /api/events.
  2. Jupyter Server validates it against the schema JupyterGIS registered and broadcasts it on /api/events/subscribe.
  3. subscribe() connects to that websocket with Tornado's websocket_connect, sending the token in an Authorization header, never in the URL.
  4. Each message goes to session.consumer.text_to_message(). A consumer error is counted and does not end the feed.
  5. When the connection drops, it waits and reconnects, doubling the wait up to ceiling.

The server remembers which asset each subject's map resolved to, so later messages from that view follow the same asset after a rename:

trail.jupyter.session.servers[url].subjects: dict[str, Asset]

>>> server.subjects
{'client-1': Asset
     id: 6b4cf4d161f847fc950ad230589515df
     path: /tmp/trail-jupyter-ts19as0a/project/map.jGIS
     st_size: 2 B
     st_mtime: 2026-12-03 19:23:06}
  • Server.locate() resolves a feed path below the server root. Absolute paths, .., backslashes, drive letters, and null bytes return None.
  • Server.close() closes the socket, cancels the task, and sets the state.

Messages and events

  • Consumer turns feed text into messages and events.
  • Message records one message and what became of it.
  • Messages keeps the latest messages.
  • JupyterEvent is the recorded event.

Consumer(Node)

Consumer interprets feed messages for one session. It numbers arrivals and remembers recorded deliveries.

trail.jupyter.session.consumer: Consumer

>>> consumer = session.consumer
>>> consumer.number
1
>>> consumer.deliveries
OrderedDict()

Jupyter Server sends each event to subscribers as one line of JSON text. It is the data JupyterGIS posted, with schema_id added at the top level. Jupyter Server adds no envelope or timestamp, so Message.timestamp is Trail's arrival time. This is the raw feed text for the notebook's first event, read from a second subscription opened with server.endpoint and server.headers():

{"schema_id": "https://schema.jupytergis.org/events/document/v1", "subject": "client-1", "verb": "opened", "object": {"document_path": "map.jGIS"}}

Indented for reading:

{
  "schema_id": "https://schema.jupytergis.org/events/document/v1",
  "subject": "client-1",
  "verb": "opened",
  "object": {
    "document_path": "map.jGIS"
  }
}

Consumer.text_to_message(server, text) handles one message:

  1. Count it as received and give it the next arrival number.
  2. Parse the JSON and pop schema_id. Invalid text is counted as invalid message; a schema outside https://schema.jupytergis.org/events/ is counted under counts.other.
  3. Build a Message and pass it to _record_message(). A malformed payload is skipped as invalid payload.
  4. Keep the message in session.messages and pass it to on_message, unless it was skipped as unsaved, outside root, or outside project.

Consumer._record_message() records a message:

  • It validates verb, object, object.document_path, and subject, then resolves the asset with _message_to_asset(). It returns early if the message was skipped.
  • A message with a stream and seq is a delivery. A repeat of the same server URL, stream, and sequence number is skipped as duplicate delivery; only the first is recorded. The last 10,000 deliveries are remembered.
  • The event class comes from JupyterEvent.registry by schema. An unregistered schema records the base JupyterEvent.
  • Event.apply() appends the event to trail.events. The message keeps the event, and counts.recorded increases.

Consumer._message_to_asset() returns the tracked asset of the message's .jGIS file, or None. It writes the file's absolute path to message.src_path:

  • An earlier message from the same subject supplies the asset through server.subjects, even if the file was renamed.
  • A path that no longer exists is followed through logged moves by _moved(), newest first.
  • A new map file in a project folder is tracked before its event is recorded.

Message checks

The checks run in this order: a message that passes a check continues down, and one that fails leaves to the right. Dashed outcomes are counted on the server but not kept in session.messages; the others are kept with their reason.

flowchart TD
    text["feed text"]
    text --> parse["JSON object with schema_id?"]
    parse -- yes --> prefix["JupyterGIS schema?"]
    parse -- no --> invalid["invalid message"]
    prefix -- yes --> payload["verb, object and document_path valid?"]
    prefix -- no --> other["counts.other"]
    payload -- yes --> saved["map saved to a file?"]
    payload -- no --> badpayload["invalid payload"]
    saved -- yes --> root["inside the server root?"]
    saved -- no --> unsaved["unsaved"]
    root -- yes --> resolve["resolve the asset: server.subjects,<br/>logged moves, tracked path"]
    root -- no --> outroot["outside root"]
    resolve --> off["not offtrailed, ignored<br/>or Trail metadata?"]
    off -- yes --> project["tracked, or in a project folder?"]
    off -- no --> offtrailed["offtrailed"]
    project -- yes --> exists["file exists?"]
    project -- no --> outproject["outside project"]
    exists -- yes --> track["track the map if new"]
    exists -- no --> missing["file missing"]
    track --> dup["delivery not recorded yet?"]
    dup -- yes --> record(["JupyterEvent.apply(): recorded"])
    dup -- no --> duplicate["duplicate delivery"]
    invalid ~~~ other
    other ~~~ badpayload
    badpayload ~~~ unsaved
    unsaved ~~~ outroot
    outroot ~~~ offtrailed
    offtrailed ~~~ outproject
    outproject ~~~ missing
    missing ~~~ duplicate
    classDef dropped stroke-dasharray: 5 4
    class invalid,other,unsaved,outroot,outproject dropped
Loading

If the file cannot be used, the message is skipped with a Reason:

Reason When
invalid message Text is not a JSON object with a schema ID
invalid payload A field is missing or has the wrong type
unsaved The map has no file
outside root The path escapes the server root
outside project The file is not in a folder the project tracks
offtrailed The file is offtrailed, ignored, Trail metadata, or no longer tracked
file missing The file does not exist
duplicate delivery A delivery that was already recorded
consumer error The consumer raised while handling the message

The notebook's unsaved map is counted on the server but not kept:

>>> server.counts
Counts(received=3, recorded=1, skipped=Counter({<Reason.FILE_MISSING: 'file missing'>: 1, <Reason.UNSAVED: 'unsaved'>: 1}), other=Counter())

Message

Message is one feed message and its outcome. The payload is excluded from the repr.

trail.jupyter.session.messages[id]: Message

>>> session.messages.select[-1]
Message (1)
    0. Message
        number: 2
        timestamp: 03:23:08.284
        server: http://127.0.0.1:43913/
        schema: https://schema.jupytergis.org/events/document/v1
        src_path: /tmp/trail-jupyter-ts19as0a/project/missing.jGIS
        outcome: skipped
        reason: file missing
Field Meaning
number Arrival number. It advances before filtering, so kept messages can have gaps
timestamp Arrival time, used to order messages that arrive asynchronously
server URL of the sending server
schema Schema ID of the payload
data Payload without its schema ID
id UUID generated by Trail, the key in Messages
src_path Absolute path of the map file
outcome Outcome: pending, recorded, or skipped
reason Reason it was skipped, or empty
event Event it became. The repr shows its ID

Messages(Collection[str, Message])

Messages keeps the latest messages for debugging. It is in memory only.

trail.jupyter.session.messages: Messages

>>> trail.jupyter.session.messages
Messages (1)
    0. Message
        number: 1
        timestamp: 03:23:08.209
        server: http://127.0.0.1:43913/
        schema: https://schema.jupytergis.org/events/document/v1
        src_path: /tmp/trail-jupyter-ts19as0a/project/map.jGIS
        outcome: recorded
        event: 433bb8045c4d4bf187f92aebd14f7546
  • It holds at most limit messages, 1000 by default, dropping the oldest. Arrival numbers are unchanged when older messages drop.
  • It supports the collection selections, such as messages.select('outcome=skipped') and messages.select[-1].

JupyterEvent(Event)

JupyterEvent is an event reported by a Jupyter server's feed. Its entry is the map's asset.

trail.events[id]: JupyterEvent

>>> trail.events.select('cls=JupyterEvent')
Events (1)
    0. JupyterEvent
        id: 433bb8045c4d4bf187f92aebd14f7546
        timestamp: 03:23:08.209
        server: http://127.0.0.1:43913/
        src_path: /tmp/trail-jupyter-ts19as0a/project/map.jGIS
        schema: https://schema.jupytergis.org/events/document/v1
        verb: opened
  • schema and data hold the schema ID and a copy of the payload. Dictionary keys in the payload are interned.
  • JupyterEvent.verb reads the payload's verb and is selectable, as in events cls=JupyterEvent verb=opened.
  • Subclasses register by schema in JupyterEvent.registry. __init_subclass__ rejects a second class for the same schema.
  • src_path holds the resolved filesystem path; data keeps the path JupyterGIS emitted. Nested payload fields are selectable with dotted names, so data.object.document_path=map.jGIS and entry.path=map.jGIS select the same event.
  • The event replays from the log with its asset and unknown schemas intact.

Note

🧩 This PR registers no JupyterEvent subclasses, so every message is recorded as the base JupyterEvent. Later PRs add the JupyterGIS event classes.


Changes to existing classes

  • Event.apply() now appends the event and returns its entry by default instead of raising NotImplementedError. JupyterEvent uses this default.
  • Event.from_record() dispatches to the named class's own from_record, so subclasses can restore their fields.
  • Trail.jupyter creates the Jupyter instance on first access.
  • Run runs trail.watchdog.session and trail.jupyter.session together and prints Jupyter notices as warnings.
  • Renderer.header() adds jupyter subscribed/expected while the session is active. Renderer.verb() uses a JupyterEvent's verb as its heading.

Tests

The test fixtures build a project tracking *.jgis with one map.jGIS, and a Server rooted at the project. An autouse fixture in tests/conftest.py points JUPYTER_RUNTIME_DIR at a temporary folder, so tests never see real servers. Each linked phrase below opens its test.

Discovery and servers

tests/jupyter/test_servers.py covers runtime files, server replacement, and URL handling:

  • A changed runtime file is reread when its token changes with the same modification time, or its modification time changes with the same token length. A partial file containing only { is skipped, and a removed file drops its entry.
  • A server with sock set to /tmp/jupyter.sock is skipped and is discovered once sock is '', the value Jupyter writes. The password flag is read. This test fails if Unix-socket support is added.
  • A server with a dead PID of 999999999 is stopped, and is_stopped after its file is deleted.
  • A server restarted on the same URL with a new token becomes a new Server. The old one is stopped, and the new token is in the Authorization header but not in the repr or endpoint.
  • A stale runtime file with another token and a dead PID does not hide the live server on the same URL.
  • overlaps and is_inside accept the project, its parent, and nested folders as appropriate. is_inside implies overlaps.
  • Secret and normalize_url: the token is hidden and cannot be pickled, and URLs with a token query, credentials, ftp://, or a fragment are rejected.
  • The session starts only when asked. Deleting it makes a fresh run, and the lock is released afterward.

Sessions and the lock

tests/jupyter/test_lock.py:

Subscription

The subscription test runs a Tornado HTTPServer with a fake /base/api/events/subscribe feed that checks the token and sends one map message on each connection. It runs twice:

  • When the token is accepted, the first message is recorded. Closing the socket triggers a reconnect, which records a second. An invalid message counts as invalid message and the next valid one is recorded. disconnect() leaves the server disconnected. Reopening the project replays three events, and the token is in neither the request URLs nor the log.
  • When the feed returns 403, the server stays refused without retrying.

Consumer

tests/jupyter/test_consumer.py covers path resolution and skipping:

  • Only repeated stream deliveries are duplicates: of five opened map.jGIS messages, four are recorded. Another view's stream and messages without a stream are recorded.
  • Each variant of a path that escapes the server root is rejected.
  • A real other.jGIS under a home-directory server root is skipped as outside project once the project is narrowed to a subfolder.
  • Missing and offtrailed maps are skipped: a missing map as file missing, and an offtrailed map and a .hidden.jGIS excluded by .offtrail as offtrailed.
  • A new map file gets its AddAssetEvent before its Jupyter event.
  • A subject keeps its asset when its map is renamed, and does not switch to a new file created at the old path.
  • A stale path in a renamed folder resolves through the moves Trail already logged.
  • After map.jGIS moves to first.jGIS and then second.jGIS, the old path follows the latest logged move to second.jGIS. A path with no logged move is file missing.
  • A symlink in the server root resolves to its target in the project.
  • Malformed messages do not end the feed: invalid text, a non-object, a missing or null schema ID, another schema (counted under other), and an object that is a list (invalid payload) are skipped, and the next valid message is recorded.
  • With a lower Messages.limit, the oldest messages drop and arrival numbers stay.

Events

tests/jupyter/test_events.py covers recording and replay:

  • An event for an unknown schema about untracked untracked.txt replays as a base JupyterEvent with no asset.
  • The payload is copied: changing the original afterward does not affect the event. The event is selectable by nested payload values such as data.object.new.parameters.opacity<0.5.
  • After the log is cleared, a recorded event keeps its asset ID, and event.entry is trail.assets[event.entry.id] after reopening.
  • Registered names cannot be replaced: an event class from another module with an existing name in Event.classes, or a second class for the same schema in JupyterEvent.registry, raises TypeError.
  • The same event is selected by the emitted and the resolved path: data.object.document_path=map.jGIS and entry.path=map.jGIS.

Ruff configuration

pyproject.toml sets allow-dict-calls-with-keyword-arguments = true under [tool.ruff.lint.flake8-comprehensions]. Ruff rule C408 no longer flags dict(key=value) calls, such as the fields dict in Consumer. It still flags dict() and dict([...]).

…cording

- Discover running Jupyter servers from their runtime files, or add one with trail.jupyter.connect(), and keep one websocket feed subscription per server with reconnects, backoff and a connection state
- Resolve each feed message's map path to a tracked asset and record a JupyterEvent, skipping duplicate or unattributable messages with a reason
- Factor the run lifecycle into a Session base; watchdog and Jupyter sessions share Trail's lock, and the console runs both and shows subscribed servers in its header
- Event.apply() appends by default and Event.from_record() dispatches to the subclass, so JupyterEvent replays from the log
- Add the PR draft, notes and demo notebook under ai/ and human/, moving notes/ into ai/plan, ai/report and ai/explain

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant