8000 feat(automations): comments, notes and graph changes as activities by adeelahmad · Pull Request #443 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content

feat(automations): comments, notes and graph changes as activities - #443

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

adeelahmad merged 1 commit into
mainfrom
claude/project-thread-pss8a6

Conversation

@adeelahmad
Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Description

Before: the stream of activities had nothing for what people and agents write and curate, so an automation couldn't react to a comment, a note or a change to the entity graph.

After: four more kinds, each with its own source.

Kind Source Object adds Example summary
comment.added comments a Note: content, inReplyTo, quote, t0, t1; target is the asset Sam commented on “Call with the school”
note.created note_pages a Page: summary, about, place, author Assistant wrote the note “St Mary's School”
note.saved note_versions as above, with version and why Sam edited the note “School trip plans”
entity.changed graph op (created, renamed, merged, split, linked, unlinked, deleted, rolled back, changed), change, entityType, before, version, count; tagged with its entities Sam renamed “St Marys” to “St Mary's School”

How: comment.added reads comment by created_at. note.saved reads the versions the notebook keeps of each change (note_version by at) and keeps one per page in each ten minutes of the clock (note-<page>-<window>): a follower hears of a window's first change, the timeline shows its newest, and a read goes on past versions already told of, so a page is never short. note.created reads note_page by created_at, so pages the assistant or an agent write (only ever created) are seen too. entity.changed reads graph_event by at, the event number breaking ties; its actor is the automation, the assistant or the MCP agent it came through, else the person, routine or Lens; a change spanning namespaces (a link) names entities of each, so it is for admins, with every namespace in lens.spaces. Each source reads several activities in one query (get_many). New indexes: comment_created, note_page_created, note_version_at, graph_event_at.

Also a fix: SurrealDB 3.2.4 gives an index range's first rows, not its last, for ORDER BY ... DESC LIMIT n, so a timeline page filtered by since or until (an admin's, which has no namespace condition) could list the oldest activities in the range instead of the newest. Sources now write a page's time bounds so that no index range is used (events_content._bound); a new test fails without it.

Workflow studio M2 (content sources), part 3 of 3, after #435 and #440.

Motivation and Context

Workflow studio plan, module M2 (/mnt/project-files/workflow-studio/briefs/M2.md), items 5, 6 and 8. Where this differs from the brief is in /mnt/project-files/workflow-studio/m2-notes.md for later modules.

Defaults taken (reversible): note.created added next to note.saved, not under it, so a page made and then written on doesn't fire a note.saved trigger twice; the graph is read by (at, number) rather than the number alone, so it fits the stream's [time, id] positions; up to twenty entity tags; multi-namespace graph changes for admins only (under Refine later).

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: the title says it)

Done questions (AGENTS.md)

  • Goal: delivers the rest of M2, merged on green CI. (merged on green)
  • Agents: the kinds show in GET /api/v1/activities and /kinds, and the MCP and assistant timeline and event_kinds tools.
  • Zero setup: nothing to install or set; the indexes are made at start-up like every other.
  • Fewest clicks and keystrokes: n/a, no UI.
  • Configurable: n/a, no new settings.
  • Light: reads rows already written, by indexed columns; a few batched queries per page.
  • Private and secure: data stays in the database; comment text, quotes, note titles and entity names marked untrusted; a change spanning namespaces shown to admins only. Threat model: n/a, no new surface.
  • Cost: no model calls.
  • User decides: nothing acts on these yet; defaults unchanged.
  • Upgrades: four new indexes, built on start-up; no stored data changes shape, so no upgrade step.
  • Honest: docs/automations.md labels these built and lists what's left for later.
  • Tests, docs updated; no API schema change, so no make openapi.
  • Open standards: Activity Streams 2.0 (Note, Page, inReplyTo, target, Mention tags); no new dependencies.
  • Result reported with evidence; "refine later" items written in docs/automations.md.

Tests: tests/domain/test_events_content.py: comments and replies through comments.create; notes through notebook.create and notebook.update by two people and the assistant (one activity per window, newest on the timeline); 99 versions in one window paged one at a time; graph changes from analysis (seed), entities.rename, entities.merge through the assistant and entities.link by an automation (admins only); a page between two times for an admin and a viewer. The timeline tests that list the seeded assets now ask for asset.added, since analysis changes the graph too. Full backend suite green locally (1199 passed).

🤖 Generated with Claude Code

https://claude.ai/code/session_019nbuG2q5wEXeUxWb8vr5HJ


Generated by Claude Code

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019nbuG2q5wEXeUxWb8vr5HJ
@adeelahmad
adeelahmad merged commit c2a5bc0 into main Oct 15, 2026
10 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-pss8a6 branch October 15, 2026 23:39
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