8000 feat(scaling): find units Lens lost track of, and let them go on a person's yes by adeelahmad · Pull Request #666 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content

feat(scaling): find units Lens lost track of, and let them go on a person's yes - #666

Merged
adeelahmad merged 1 commit into
mainfrom
claude/project-thread-azm2mb
Oct 19, 2026
Merged

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

Conversation

@adeelahmad
Copy link
Copy Markdown
Owner

Description

Before: if a launch started a machine but its answer never reached Lens (a timeout, a crash between the call and the write), or a terminate half failed, that machine kept running and billing at the provider, and nothing in Lens showed it. Each driver's listing existed but nothing called it.

After: while scaling runs, the scaler asks each provider every ten minutes for the units it runs with Lens's tag. A unit that no unit of Lens's stands for is a stray. It shows on its provider (strays and list_error in GET /api/v1/scaling/providers, and a red line in Settings › Auto scaling) and goes in the activity ledger once, as scaling.stray. Lens lets none of them go itself. A person signed in to the web app does, with Let go (Undo stays for a few seconds) or POST /api/v1/scaling/providers/{id}/strays/let-go. The assistant can only ask (let_go_scaling_stray), and its ask waits for that yes on the Approvals page. An API key or an app gets 403.

How: Scaler._strays runs each tick and lists only providers not asked in the last ten minutes. A unit that runs is known by its id or its name. One let go in the last hour is known by its id only, since the provider may still show it while it goes. A failed launch (no id came back) is not known, so a machine it left behind is reported at once. Letting one go calls the driver's own terminate with the stray's id (every driver keys on external_id), and first refuses if a live unit now matches it.

Motivation and Context

Adeel asked for auto scaling that "setups and manage every single thing", auditable and agent native. Machines that cost money with nothing in Lens to show them are the gap a manager has to close.

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 (ruff, eslint, prettier).
  • I added or updated tests (test_units_lens_lost_track_of_show_on_their_provider, test_a_person_lets_a_stray_go_and_an_agent_cant, test_the_assistant_asks_to_let_a_stray_go_and_the_person_says_yes, and two web tests).
  • Documentation updated (docs/scaling.md "Units Lens lost track of" and Agents, docs/requirements.md, README).
  • Changelog fragment in changelog.d/scaling-strays.md.

Done questions (AGENTS.md)

  • Goal: merges on green CI.
  • Agents: strays show in scaling (assistant and MCP) and the API. The assistant asks to let one go, and a person approves.
  • Zero setup: nothing to set up; it runs with the scaler.
  • Fewest clicks: one click on Let go, with Undo instead of a confirm dialog.
  • Configurable: no new setting. The ten-minute cadence is a constant, like the scaler's other timings.
  • Light: one read-only list call per provider every ten minutes, only while scaling runs.
  • Private and secure: letting a stray go is person-only (403 to tokens and apps, Approvals for the assistant). Threat model P-SCALING (md and yaml) says so. Names from providers are length-bounded and shown as text.
  • Cost: it finds machines that bill with no record in Lens. The listing calls are in the activity ledger.
  • User decides: Lens never lets a stray go on its own. Existing defaults are unchanged.
  • Upgrades: new optional fields on the schemaless scale_provider table only. Old rows read as no strays.
  • Honest: docs say what counts as a stray and that Lens doesn't act on its own.
  • Tested and documented; OpenAPI client regenerated with make openapi.
  • Open: n/a, no new dependency.
  • Reported in the thread.
  • Reuse: each driver's existing listing and terminate, the activity ledger, the Approvals flow and the panel's Undo pattern.

Generated by Claude Code

…rson's yes

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALjNbLobvPe7VwvDL8j7V3
@adeelahmad
adeelahmad merged commit 92d194d into main Oct 19, 2026
12 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-azm2mb branch October 19, 2026 04:15
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