Skip to content

feat: scoped machine keys and transport-free query services #83

Open

Description

@Igloczek

Rewritten on 2026-11-21 to fit the project plan: the product is fully operable by AI agents through MCP (north star P8, D14, D15) and the backend is written in Effect (D16). The previous version is in this issue's edit history.

Problem

Agents need authenticated, bounded access to everything the owner can see, without a session cookie.

Scope

  • Extend the existing API keys with scopes read, write, delete, and admin (D15), plus an optional restriction to specific telemetry projects. Keep shown-once hashed secrets, expiry, disable, and revoke. Existing keys (Prometheus metrics keys until SCOPE-001, SCOPE-001: Remove all public-facing features (status pages, public incidents, badges, Prometheus) #192, removed that endpoint) get no scopes, so nothing is promoted silently; the owner re-scopes them explicitly.
  • Introduce typed, transport-free query services for monitors (list and current status, bounded history and uptime, important events, certificate and domain expiry). Socket handlers and MCP tools both call them (D14). Move at least the monitor-list socket handler onto them to prove there is one owner.
  • Every query has bounded page size, time range, and response bytes, with stable cursors and typed errors. DTOs gain freshness fields when feat: expose observation freshness and measured uptime coverage #78 lands (additive).

Acceptance criteria

  • Scope tests: a read key cannot mutate anything; an unscoped legacy key can do nothing; revoked, disabled, and expired keys fail consistently.
  • Pagination is deterministic across equal timestamps and bounded against abusive input.
  • Credential admission reuses the existing bounded auth and trusted-proxy policies.

Cut from the original issue

The general REST read API (MCP is the machine interface, D14), and the hard dependencies on #77, #78, and #82. Their fields join the DTOs when they land.

Constraints

Keep Bun, Vue, one compiled executable and SQLite (kuma.db), with the supported Kuma importer. No required hosted service, extra database, worker deployment, Node/npm fallback or new distribution path. Backend code is written in Effect (north star D16, house style in docs/effect.md): dependencies are Effect services provided through layers, expected failures are tagged errors, and every input is decoded with Schema. Use direct @/ imports; no new barrel, ad-hoc registry, broad any facade or @ts-nocheck. Code passes the TS 7 strict typecheck and the @cloudflare/oxlint-config lint (D17). Make additive schema changes through the existing upgrade path; keep legacy rows meaningful.

Implement the idea independently. Staygreen is a design reference at the pinned revision, licensed FSL-1.1-MIT; do not transplant its source, CSS, illustrations or branding into this MIT project.

Source starting points

Plan placement

Reconciled on 2026-11-21 with the project plan (docs/roadmap.md) and the fixed decisions (docs/north-star.md). If this issue and those documents still disagree, raise it instead of choosing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions