Skip to content

ADR 0071 says the agent-device heartbeat carries leaseBackend; its RPC params do not #1480

Closed

Description

@V3RON

docs/internal/adr/0071-a-restart-re-allocates-a-live-agent-device-lease.md:27 lists leaseBackend among the scope the CLI sends with a heartbeat. At agent-device v0.21.35 the CLI passes it to client.leases.heartbeat, but leaseScopeToLeaseRpcParams (packages/contracts/src/lease-scope.ts) puts backend only on lease_allocate. A heartbeat RPC carries tenantId, runId, leaseProvider, clientId, deviceKey, leaseId and ttlMs, and no backend.

The Context line is the fact the re-allocate was built on, so the next reader of the ADR will trust a field that is not there.

Found while triaging #1472.

Written by an agent.

Activity

  1. added
    bug:new
    on Nov 9, 2026
  2. self-assigned this
    on Nov 9, 2026
  3. V3RON commented on Nov 9, 2026

    @V3RON
    ContributorAuthor

    Reproduction

    Confirmed. This is a defect in ADR text only, so no test can fail and no bug/1480-repro branch was pushed (precedent: #1375, #1095, #666). The evidence is agent-device at the pinned tag, plus the installed 0.21.35 dist:

    gh api 'repos/callstack/agent-device/contents/packages/contracts/src/lease-scope.ts?ref=v0.21.35'
      197  case 'lease_allocate':  ... backend: scope.leaseBackend,     (line 204)
      207  case 'lease_heartbeat': ... leaseId, ttlMs                    (no backend)
    installed dist back-mode.js:
      case`lease_heartbeat`:return{...r,...m({leaseId:e.leaseId,ttlMs:e.leaseTtlMs})}
    

    simlock repeats the claim nowhere else (git grep leaseBackend: only allocate calls in e2e).

    Root cause

    Defect, in an ADR's Context: docs/internal/adr/0071-a-restart-re-allocates-a-live-agent-device-lease.md:26-29 lists leaseBackend in the scope a heartbeat sends. The CLI does pass it to the heartbeat (connection-runtime.ts:892-941), but leaseScopeToLeaseRpcParams drops it from lease_heartbeat. allocateAgain (src/agent-device/front/heartbeat.ts:120-126) copies the heartbeat's params, so a re-allocate names no backend. The decision is unaffected.

    Simplest fix

    Correct the sentence. The code stays as it is:

    The agent-device CLI heartbeats before each command and sends its lease
    scope with it: `runId`, `clientId`, `leaseProvider` and `deviceKey`
    (agent-device v0.21.35, `src/cli/commands/connection-runtime.ts:892-941`).
    The CLI hands its `leaseBackend` to the heartbeat too, but the RPC drops
    it: `leaseScopeToLeaseRpcParams` puts `backend` on `lease_allocate` only
    (`packages/contracts/src/lease-scope.ts:178-223`). agent-device accepts an

    Applied, then discarded:

    pnpm exec vitest run --project unit src/adr-index.test.ts src/stale-refs.test.ts src/adr-flip-check.test.ts
    Test Files  3 passed (3)   Tests  14 passed (14)
    

    Alternatives rejected

    • A superseding ADR: the decision does not change, only a fact in its Context.
    • Deleting the field list: readers need to know which scope fields the re-allocate can copy.

    Risk

    • Because a re-allocate names no backend, agent-device records its default ios-simulator (installed lease-registry-scope.js), Android leases included. This is harmless today because simlock sets no AGENT_DEVICE_MAX_SIMULATOR_LEASES (src/agent-device/shared/daemon-environment.ts). The reviewer should decide whether the ADR says so.

    Fast track

    • Defect: yes
    • Fix tried: no — doc-only, no failing reproduction to make pass
    • Nothing public added or broken: yes
    • No ADR or rule changed: no — the fix edits ADR 0071's Context
    • One fix: yes

    Written by an agent.

  4. removed their assignment
    on Nov 9, 2026
  5. added
    bug:ready
    and removed
    bug:new
    on Nov 9, 2026
  6. V3RON commented on Nov 9, 2026

    @V3RON
    ContributorAuthor

    Maintainer accepted the triage report. Land the ADR correction in the same change as #1472's fix, and have the reworded sentence say that the re-allocate now sends the platform's backend itself. The report's Risk note that the missing backend has no effect today is wrong: it is the cause of #1472 (Lease does not match tenant/run scope).

    Written by an agent.

  7. V3RON commented on Nov 10, 2026

    @V3RON
    ContributorAuthor

    Fixed by #1484 (merged as d7195cf), which also corrected the ADR 0071 sentence about the heartbeat carrying the lease's backend. Closed by hand: coding rule 3 lets a PR from bug/1472 close only #1472.

    Written by an agent.

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

    bug:ready

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions