8000 feat(automations): save automations for their maker, with checks and an API by adeelahmad · Pull Request #451 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content

feat(automations): save automations for their maker, with checks and an API - #451

Merged
adeelahmad merged 9 commits into
mainfrom
claude/project-thread-sxrerj
Oct 16, 2026
Merged

adeelahmad merged 9 commits into
mainfrom
claude/project-thread-sxrerj

Conversation

@adeelahmad
@adeelahmad adeelahmad commented Oct 16, 2026 •
Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Description

Before: an automation's shapes (triggers, joins, an If, a policy) could be checked, and its Then drawn as an event workflow, but nothing kept an automation.

After: POST /api/v1/automations saves one for the person who makes it (run_as), working in namespaces they can edit (by default each one they edit; an admin's works everywhere). Its Then is a graph, saved as a workflow of scope event, or a saved event workflow. GET, PATCH, DELETE (with /restore to undo), /enable and /policy manage it, and GET /automations/actions lists the actions an action node can take. Running automations is the next PR.

How: app/domain/automations.py checks every save (triggers, join, If, graph, namespaces, limits, policy) and keeps an existing auto pick only where it already was. Only the person, signed in to the web app, lets a node run on its own (POST /automations/{id}/policy); API keys, apps and agents get a 403. Webhook triggers get their address when saved (automation_hooks.token_for, from #442): the answer's hooks gives each new one's URL and signing secret once, saving again keeps it, and a webhook trigger that is dropped has its hook revoked at once. Saving sets the timers of its schedule and at triggers through timers.schedule_automation (#450), and switching it off or deleting it calls them off; they start runs once running automations lands (next PR). Joins other than any are refused as coming soon until joins land. Credentials in an http_request node's headers are sealed when the graph is saved (actions_web.seal_headers, from #439), with the key of the automation's first namespace and bound to the automation and the node's address; a {{ }} value stays as written, and a credential needs a written-out url. Switching on records enabled_at, so turning one on never replays the past. Admins see every automation; anyone else sees only those working entirely in namespaces they edit, and others answer 404.

Motivation and Context

Workflow studio, module M6 (automation engine), part 2 of 5: storage and checks. Next come running them (dispatcher, runs, limits, budgets), agent tools, and drafting from a sentence.

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 changelog line comes with running them, the next PR)

Done questions (AGENTS.md)

  • Goal: one part of the studio's engine; merged on green CI.
  • Agents: the whole API works with an API key; MCP and assistant tools follow in this module.
  • Zero setup: a new table, made on start; nothing to install.
  • Fewest clicks and keystrokes: n/a, API only until the builder (M11); namespaces default to the ones you edit.
  • Configurable: n/a, no new setting (limits are per automation, with defaults).
  • Light: no new dependency.
  • Private and secure: acts only as its maker, in namespaces they edit; auto only from a signed-in session; web-call credentials sealed with the namespace key on save. Threat model entries come with running them.
  • Cost: no model calls.
  • User decides: nodes ask first unless the person sets auto; nothing runs yet; no defaults change.
  • Upgrades: a new automation table (DEFINE TABLE, idempotent); no existing data changes.
  • Honest: docs label saving built and running planned.
  • Tests (tests/api/test_automations.py; tests.helpers.without hides studio modules not merged yet, so the "coming soon" checks here and from feat(workflows): an event scope for automations, with action and decide nodes #436 hold as M4 and M5 land), docs (docs/automations.md, docs/api.md) and the generated client (make openapi) updated.
  • Open standards; no new dependencies.
  • Result reported with evidence; "refine later" items written in docs/automations.md.

Checked locally: full backend suite (1262 passed, with a test that a schedule sets its timer and switching off or deleting calls it off), ruff, mypy, the threat model check and mkdocs build --strict.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VCAZ9NEmBJNovqdzxvK3qi

…an API

An automation is saved with its triggers, join, If, a Then (a graph saved as a
workflow of scope event, or a saved one), namespaces its person can edit,
limits and a policy. It is switched on and off (enabled_at records when),
deleted with restore as the undo, and only the person in a signed-in session
lets a node run on its own. Schedules, webhooks and joins other than any are
refused as coming soon until their modules land, and are armed through them
once they are there. GET /automations/actions lists the action catalog.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VCAZ9NEmBJNovqdzxvK3qi
@adeelahmad adeelahmad self-assigned this Oct 16, 2026
…-sxrerj

# Conflicts:
#	docs/automations.md
#	fastapi_backend/tests/domain/test_automation_nodes.py
#	nextjs-frontend/app/openapi-client/index.ts
#	nextjs-frontend/app/openapi-client/sdk.gen.ts
…-sxrerj

# Conflicts:
#	docs/automations.md
#	fastapi_backend/app/api/v1/router.py
#	nextjs-frontend/app/openapi-client/index.ts
#	nextjs-frontend/app/openapi-client/sdk.gen.ts
#	nextjs-frontend/app/openapi-client/types.gen.ts
#	nextjs-frontend/openapi.json
…-sxrerj

# Conflicts:
#	docs/automations.md
#	nextjs-frontend/app/openapi-client/sdk.gen.ts
#	nextjs-frontend/app/openapi-client/types.gen.ts
#	nextjs-frontend/openapi.json
@adeelahmad
adeelahmad merged commit c22b40b into main Oct 16, 2026
10 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-sxrerj branch October 16, 2026 02:55
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