Repository navigation
feat(automations): stream of activities with kinds, an event log and following - #426
Merged
Merged
Conversation
…following Activities in the Activity Streams 2.0 shape with a Lens kind; a catalog of kinds with schemas and parents; sources that read existing rows (new recordings as asset.added) and an event log for the rest; following the stream once across processes with cursors, a lookback and claims; and timeline reads newest first with who may see what. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RFQUkVmALkdhRqXY1yFxW5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Adeel · project thread
Description
Before: Lens had no single stream of what happens in it. Notifications read jobs and recordings with their own cursor, and nothing else could follow changes across the API and worker processes.
After: one stream of time-coded activities in the Activity Streams 2.0 shape (
app/domain/events.py), which the rest of the workflow studio builds on. New assets show up asasset.addedactivities with who added them (a person's upload, a storage source, an automation, or Lens). A consumer can follow the stream and handle each activity exactly once even with the API and a worker both running, and the timeline can be read newest first with filters and the same namespace rules as the rest of Lens. Nothing follows the stream yet, so installs behave as before.How: generalizes
notify.py's pattern. Sources read rows Lens already keeps (recordingbycreated_atwith the id tiebreak), and a smallevent_logholds activities with no row of their own (events.emit, idempotent by key, carrying an automation's cause).events.followkeeps a cursor per consumer and source, starts new consumers at now, re-reads the last 60 seconds once caught up, andevents.claimmakes aCREATEonly one process wins.events.pagemerges sources newest first with an opaque cursor and reads on (up to five pages a source) when filters thin a page out. The kinds catalog carries JSON Schemas, somatch.describe(tree, kind)now names fields by their titles.routines.run_duetidies old log rows and claims once an hour. This is the second part of workflow studio module M1; the API, MCP and assistant tools come next.Motivation and Context
Workflow studio plan (
/mnt/project-files/workflow-studio/plan.md, M1 steps 1 and 2); where the built contract differs is in/mnt/project-files/workflow-studio/m1-notes.md.Types of changes
!in the title)Checklist:
make hookschecks it on commit).docs/accordingly.## UnreleasedinCHANGELOG.md. (n/a: nothing user-facing yet; the timeline API comes next)Done questions (AGENTS.md)
timeline/event_kindsand the assistant tool over these functions.SCHEMA; nothing to install or configure.events.keep_days(30) andevents.poll_seconds(5) have defaults now; their Settings section comes in M1's settings PR.lens.audience(owner, admins); outside text is marked inlens.untrusted; no new network surface.event_log,event_log_key,event_cursor,event_claim,upload_recording), so no upgrade step is needed.tests/domain/test_events.py(shape, catalog, emit idempotency, following across sources with equal times and page boundaries, lookback, first-time start, claims across threads, timeline order, visibility and filters, tidy); docs/automations.md § Contract, docs/database.md. No generated files change.notify.py's; filters reuse match trees andflow.test; actor kinds reuserender.kind.🤖 Generated with Claude Code
https://claude.ai/code/session_01RFQUkVmALkdhRqXY1yFxW5
Generated by Claude Code