Skip to content

bug(company-os): heartbeat resume/terminate routes record the acting user inconsistently #21136

Closed

Description

@mrveiss

Found in review of PR #21135 (#21119), which makes the budget-policy resume route record the verified caller as approved_by via resolve_principal_id. Two neighbouring heartbeat control routes still record their actor in different ways.

Route Current behaviour
autobot-backend/api/heartbeat.py:324 resume_agent records no resumer and emits no audit event
autobot-backend/api/heartbeat.py:401 terminate_agent stores the username, not the principal id, in paused_by

The same operation should behave the same way on every route. A pause, resume or terminate should record who did it in one form: the principal id from resolve_principal_id(current_user), the canonical helper in autobot_shared/principal.py. That form should go both in the row and in an audit event.

Acceptance criteria

  • resume_agent records the verified caller via resolve_principal_id and emits an audit event naming them.
  • terminate_agent stores the principal id, not the username.
  • Neither route takes an actor from the request body. A test sends a forged actor in the body and asserts it is ignored.
  • The pause, resume and terminate routes share one actor-resolution path, with no per-route variants.

Related: #21056 is the pause-overwrite defect in the same controls flow; it is a separate fix.

Activity

  1. added
    bugSomething isn't working
    area: company-osWave 4 · cluster A — Company OS & LLC canvas
    phase:M2.6Budgets enforced and costs recorded
    on Nov 8, 2026
  2. added
    needs-structureMissing goal milestone, matching phase label or native parent (#19522)
    on Nov 8, 2026
  3. github-actions commented on Nov 8, 2026

    @github-actions
    Contributor

    needs-structure cleared: goal milestone, matching phase label and native parent (or sub-issues) are all present (#19522).

  4. removed
    needs-structureMissing goal milestone, matching phase label or native parent (#19522)
    on Nov 8, 2026
  5. added
    needs-ac-evidenceClosed by a merge keyword; awaits an AC evidence table comment (#19520)
    on Nov 12, 2026
  6. github-actions commented on Nov 12, 2026

    @github-actions
    Contributor

    Landed via the merge train (#21382, merge 6199adcab0) via #21148

  7. mrveiss commented on Nov 12, 2026

    @mrveiss
    OwnerAuthor

    Closure check, 2026-11-12 (Riga), against merged main. PR #21148 landed via train #21382, merge commit 6199adc. The issue was closed by Closes #21136; all four ACs are now ticked with code evidence, so it stays closed.

    AC Status Evidence (autobot-backend/)
    resume_agent records the verified caller and emits an audit event Met api/heartbeat.py:416-417 resumer = _actor_id(_user), _audit_control(resumer, AuditAction.AGENT_RESUME, ...); services/audit/taxonomy.py:154 AGENT_RESUME; test test_resume_emits_audit_event_naming_caller
    terminate_agent stores the principal id, not the username Met heartbeat.py:450-455 actor = _actor_id(_user), state.paused_by = actor; test test_terminate_stores_principal_id_not_username
    No route takes an actor from the body; a forged-actor test Met heartbeat.py:324 comment and use of _actor_id(_user); test test_pause_records_principal_and_ignores_forged_body_actor (api/heartbeat_actor_21136_test.py:52). AgentResumeRequest and AgentTerminateRequest carry no actor field (terminate has only reason), so pause is the only route with a forgeable body field
    One shared actor-resolution path Met _actor_id (heartbeat.py:274, wraps resolve_principal_id) and _audit_control (:280) are used by pause (:325), resume (:416), terminate (:450)

    Ticked 4 of 4. Behaviour on a live install is not evidenced: the host still runs pre-update code (#21343). None of the ACs is a host criterion.

    Remaining, by design: heartbeat routes are not company-scoped (#21376). Until #21376, paused_by_name (PR #21148) can show a pausing user's display name across companies. Resume has no resumer column; the audit event is the record. Parent link: #21137.

  8. removed
    needs-ac-evidenceClosed by a merge keyword; awaits an AC evidence table comment (#19520)
    on Nov 12, 2026
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

    area: company-osWave 4 · cluster A — Company OS & LLC canvasbackendbugSomething isn't workingphase:M2.6Budgets enforced and costs recorded

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions