Skip to content

Service has no session-end signal over gRPC/HTTP (learned permission rules never evict there) #10

Closed

Description

@JAORMX

Surfaced by the #3 panel review (done in 67c6da4).

Problem

Service.CloseSession is the only path that evicts a session's learned permission rules (OnCloseSession → permstore.Forget). Today only the ACP adapter calls CloseSession (on editor disconnect). The gRPC and HTTP transports have no session-end signal, so on a long-lived mecated served over gRPC/HTTP, a session's learned allow_always rules (and any future per-session state wired to OnCloseSession) persist until process exit.

Bounded and per-session-isolated (each rule requires a human allow-always approval; permstore dedups), so not attacker-exploitable — but a real slow accumulation, and the per-session learned-rule slice is itself uncapped.

Options

  1. Give gRPC/HTTP a session-end RPC/signal that routes through Service.CloseSession (symmetric with ACP).
  2. Add a per-session cap on learned rules in permstore.Memory as a backstop.
  3. A session TTL/idle eviction in the Service.

Related design note

The architecture review also flagged that Service.Config now has cross-cutting func hooks (OnCloseSession); if a third session-lifecycle consumer appears, prefer a single SessionLifecycleListener interface over more OnX hooks.

Refs: internal/adapter/server/service.go (CloseSession, Config.OnCloseSession), internal/adapter/permstore/, docs/adr/0001-acp-adapter.md (Deferred).

Activity

  1. JAORMX commented on Jun 1, 2026

    @JAORMX
    ContributorAuthor

    Shipped — closing as done

    Implemented in f3c8b07 (feat(server): session-end signal over gRPC/HTTP + per-session learned-rule cap).

    Option 1 — symmetric session-end signal ✅

    • New gRPC CloseSession RPC and HTTP DELETE /v1/sessions/{id}, both routing through a new precondition-checked Service.EndSession (verifies the session exists → NotFound/404 for a never-created id, then runs the same idempotent CloseSession teardown that ACP already used on editor disconnect).
    • Service.CloseSession keeps its void/idempotent signature (ACP depends on it); EndSession is its error-returning sibling for the request surfaces.
    • Close releases session-scoped resources only: it does not delete the persisted snapshot and does not cancel an in-flight run.

    Option 2 — client-independent backstop ✅

    • permstore.Memory caps a session's learned-rule slice at maxRulesPerSession (256). Dedup runs first, so an identical re-learn at the cap is a no-op; only a new distinct rule is dropped — which makes that call keep asking. Fail-safe toward asking, never toward a silent allow.

    Option 3 — TTL / idle eviction: deferred

    • Deliberately deferred pending telemetry. Recorded in ADR 0001.

    Design note (from the related architecture flag)

    Tests are offline (mockllm + memfs): gRPC/HTTP close idempotency + NotFound, EndSession eviction/teardown-once, and the permstore cap + dedup-at-cap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions