Skip to content

fix(runner): restart when hub identity changes#303

Merged
tiann merged 2 commits intotiann:mainfrom
ROOOO:pr/runner-restart-on-identity-change
Mar 18, 2026
Merged

fix(runner): restart when hub identity changes#303
tiann merged 2 commits intotiann:mainfrom
ROOOO:pr/runner-restart-on-identity-change

Conversation

@ROOOO
Copy link
Contributor

@ROOOO ROOOO commented Mar 17, 2026

Summary

  • persist the runner's hub connection identity in local runner state
  • treat API URL, machine ID, and CLI API token changes as runner incompatibilities
  • force a new runner instance to take over when that identity changes
  • add tests for runner identity compatibility and token hashing

Testing

  • bun x vitest run src/runner/runnerIdentity.test.ts
  • bun run typecheck

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings

  • [Major] Identity mismatch not detected when current identity missing — optional checks mean clearing settings/env can keep stale runner bound to old hub/namespace. evidence cli/src/runner/runnerIdentity.ts:29 cli/src/runner/runnerIdentity.ts:33
    Suggested fix:
    if (!current.machineId || state.startedWithMachineId !== current.machineId) {
        return false
    }
    
    if (!current.cliApiTokenHash || state.startedWithCliApiTokenHash !== current.cliApiTokenHash) {
        return false
    }

Summary

  • Review mode: initial
  • 1 major issue. Identity check allows stale runner when current identity missing.

Testing

  • Not run (automation)
  • Suggested: add test for missing current machineId/token to lock behavior.

return false
}

if (current.machineId && state.startedWithMachineId !== current.machineId) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MAJOR] Identity mismatch not detected when current identity missing — optional checks mean clearing settings/env can keep stale runner bound to old hub/namespace.

Suggested fix:

if (!current.machineId || state.startedWithMachineId !== current.machineId) {
    return false
}

if (!current.cliApiTokenHash || state.startedWithCliApiTokenHash !== current.cliApiTokenHash) {
    return false
}

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings

  • None.

Summary

  • Review mode: initial. No issues found in changed lines. Residual risk: runner restart behavior on identity mismatch only unit-tested.

Testing

  • Not run (automation)

@tiann tiann merged commit f967bd9 into tiann:main Mar 18, 2026
2 checks passed
@ROOOO ROOOO deleted the pr/runner-restart-on-identity-change branch March 19, 2026 13:17
Hwwwww-dev pushed a commit to Hwwwww-dev/hapi that referenced this pull request Mar 20, 2026
* fix(runner): restart when hub identity changes

* fix(runner): fail closed on missing identity
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