8000 feat(automations): an automation's action that asks first waits as an approval by adeelahmad · Pull Request #447 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content

feat(automations): an automation's action that asks first waits as an approval - #447

Merged
adeelahmad merged 5 commits into
mainfrom
claude/project-thread-gfulp2
Oct 16, 2026
Merged

adeelahmad merged 5 commits into
mainfrom
claude/project-thread-gfulp2

Conversation

@adeelahmad
Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Description

Before: approvals were only the assistant's proposals in a conversation. An automation's action that asks first (a post to a room, a change to another asset) had nowhere to wait, and GET /api/v1/approvals listed the last 100 with no filters.

After: workflow studio M8, part 1 of 5. The engine hands such an intent to approvals.ask(db, cfg, intent, event=None). That keeps it as an approval for the automation's person: what it would do, the activity that caused it, and when it expires. The person is told once in their own chat app: "School emails wants to post … Open to decide." Nothing runs until they pick:

  • approve carries the intent out through actions.perform, as the automation and for its person. Model calls go in the ledger under the run, and what it causes carries the run as its cause. The outcome (done or failed) goes on the approval and on the run (automations.update_intent once M6 lands).
  • decline does nothing and records it.
  • edit takes new params, checks them against the action's schema, then performs. Credential headers stay hidden and sealed.
  • always approves, then sets that node to auto (automations.set_policy). Only actions that reach outside Lens can be set this way, and only once M6 has landed. Until then it says "approve it this once".

Approving, editing and always need the person signed in. An API key or an app can list and decline, and each approval's can says what the caller may do. Two decisions at once can't both run it (a claim on the row). At most 100 approvals wait per automation; past that its intents are dropped and the run says so. Undecided ones expire after automations.approval_days (Settings → Automations, default 7) via an hourly sweep from routines.run_due, and nothing runs.

GET /api/v1/approvals gains status, origin=automation|chat, automation, before and limit. New: GET /approvals/count (for the badge) and GET /approvals/{aid}. POST /approvals/{aid} gains edit (with params) and always.

Defaults picked (reversible): API keys and apps can't approve automation approvals (the brief's "agents never approve"); the assistant's own chat approvals work exactly as before and never expire.

Motivation and Context

Adeel's workflow studio, module M8 (approvals inbox), brief in the project's workflow-studio/briefs/M8.md. Next PRs: a yes in your own chat, approval activities and notifications, agents' approval tools, the /approvals page with a top-bar badge.

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: studio modules land under one release note)

Done questions (AGENTS.md)

  • Goal: part 1 of M8; merged on green CI.
  • Agents: list, read, count and decline over the API. Approving is deliberately the person's (brief, AGENTS principle 7). MCP and assistant tools come in part 4.
  • Zero setup: no new prerequisite or manual step.
  • Fewest clicks: one pick per approval; always stops future asks for that node. The page comes in part 5.
  • Configurable: automations.approval_days in Settings → Automations, default 7, out of the wizard.
  • Light: one table and an hourly sweep; no new process or dependency.
  • Private and secure: data stays local; new P-AUTOMATION-APPROVAL in threat-model.md (approval flooding, who approves).
  • Cost: no model call to ask; a performed action's model calls go in the ledger under the run.
  • User decides: nothing runs until the person picks; chat approvals unchanged.
  • Upgrades: new fields are optional and reads tolerate their absence; only DEFINE INDEX IF NOT EXISTS, so no upgrade step is needed.
  • Honest: docs label approvals built and the page, chat yes, activities and agent tools planned.
  • Tests (tests/api/test_approvals.py), docs (automations.md, api.md, configuration.md) and the client regenerated with make openapi.
  • Open: no new dependency.
  • Reported; "refine later" in docs/automations.md (cost estimates on asked actions, chat buttons, two-person approvals, batching, retrying a failed one, expiring when an automation is removed).

🤖 Generated with Claude Code

https://claude.ai/code/session_01VF3LK1DBx3dXX2b8c5T3cQ


Generated by Claude Code

… approval

approvals.ask keeps an intent that asks first as an approval of the automation's
person, tells them once in their chat app, caps 100 waiting per automation and
expires undecided ones after automations.approval_days (Settings > Automations,
default 7) with nothing run. Approving performs the intent as the automation;
decline, edit (params checked against the action's schema) and always (the node
runs on its own from now on) are the other picks. Only the person approves, signed
in: an API key or an app can list and decline. GET /api/v1/approvals gains
filters and paging, with /approvals/count and /approvals/{aid}.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VF3LK1DBx3dXX2b8c5T3cQ
@adeelahmad adeelahmad self-assigned this Oct 16, 2026
Moves P-AUTOMATION-APPROVAL into the claimed properties table and adds it to
threat-model.yaml and threat-model.json with the prose hash.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VF3LK1DBx3dXX2b8c5T3cQ
Keeps automations.catch_up (timers) beside automations.approval_days in the
settings, defaults, docs and the hourly tidy.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VF3LK1DBx3dXX2b8c5T3cQ
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VF3LK1DBx3dXX2b8c5T3cQ
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VF3LK1DBx3dXX2b8c5T3cQ
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