8000 feat(automations): stream of activities with kinds, an event log and following by adeelahmad · Pull Request #426 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content

feat(automations): stream of activities with kinds, an event log and following - #426

Merged
adeelahmad merged 1 commit into
mainfrom
claude/project-thread-3p5r9r
Oct 15, 2026
Merged

adeelahmad merged 1 commit into
mainfrom
claude/project-thread-3p5r9r

Conversation

@adeelahmad
Copy link
8000 Copy Markdown
Owner

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 as asset.added activities 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 (recording by created_at with the id tiebreak), and a small event_log holds activities with no row of their own (events.emit, idempotent by key, carrying an automation's cause). events.follow keeps a cursor per consumer and source, starts new consumers at now, re-reads the last 60 seconds once caught up, and events.claim makes a CREATE only one process wins. events.page merges 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, so match.describe(tree, kind) now names fields by their titles. routines.run_due tidies 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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change; ! in the title)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (make hooks checks it on commit).
  • I added or updated tests.
  • My change requires documentation updates, and I have updated docs/ accordingly.
  • Users need more than the title to understand it, so I wrote it under ## Unreleased in CHANGELOG.md. (n/a: nothing user-facing yet; the timeline API comes next)

Done questions (AGENTS.md)

  • Goal: the stream core of M1, merged on green CI; the read API and tools follow in the next PR.
  • Agents: n/a in this step; the next M1 PR adds the API route, MCP timeline/event_kinds and the assistant tool over these functions.
  • Zero setup: new tables and indexes arrive through SCHEMA; nothing to install or configure.
  • Fewest clicks: n/a, no UI.
  • Configurable: events.keep_days (30) and events.poll_seconds (5) have defaults now; their Settings section comes in M1's settings PR.
  • Light: no new process or dependency; nothing runs until a consumer follows the stream; tidy runs once an hour.
  • Private and secure: reads apply namespace roles and lens.audience (owner, admins); outside text is marked in lens.untrusted; no new network surface.
  • Cost: no model calls; summaries come from fixed rules.
  • User decides: defaults unchanged; nothing acts on the stream yet.
  • Upgrades: only new tables and indexes (event_log, event_log_key, event_cursor, event_claim, upload_recording), so no upgrade step is needed.
  • Honest: docs/automations.md labels the stream built and the API, tools and more kinds planned.
  • Tests, docs and generated files: 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.
  • Open standards: W3C Activity Streams 2.0 shape and JSON Schema; no new dependencies.
  • Reported; refine later (AS2 JSON-LD view, collection-only members, pushing instead of polling) is in docs/automations.md.
  • Reuse: the cursor, lookback and claim pattern is notify.py's; filters reuse match trees and flow.test; actor kinds reuse render.kind.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RFQUkVmALkdhRqXY1yFxW5


Generated by Claude Code

…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
@adeelahmad adeelahmad self-assigned this Oct 15, 2026
@adeelahmad
adeelahmad merged commit 9b62877 into main Oct 15, 2026
10 checks passed
@adeelah
78F9
mad
adeelahmad deleted the claude/project-thread-3p5r9r branch October 15, 2026 17:36
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.

2 participants

0