Skip to content

[factory] Orphan-reaper dispatchCallActive guard can never fire #331

Description

@khaliqgant

Found while working #211, pre-existing and unrelated to it. Not fixed there
because it changes orphan-release behaviour on the dispatch critical path.

In #githubOrphanRecoveryContext (src/orchestrator/factory.ts):

const dispatchCallActive = this.#dispatchInFlight.has(issueKey(lifecycle.issue))

#dispatchInFlight is not keyed by a bare issue key. dispatch() composes its
entries as:

const key = `${...(decision.issue)}:${dryRun ? 'dry-run' : 'live'}:${phase}`

so the lookup above compares a bare key against strings that always carry the
:dry-run|live: and :dispatch|escalation suffixes. It can never match.
dispatchCallActive is therefore always false, and the guard it feeds — meant
to stop the orphan reaper releasing a lifecycle while a dispatch call for that
issue is still in flight — is inert.

The caller does verify provider status, open-PR absence, a second roster read and
the lifecycle lease before releasing an orphan-shaped row, so this is a missing
layer rather than an open hole. But it is a safety check that reads as active and
is not, which is worth either fixing or deleting.

Whichever way it goes, the fix should compose the same key dispatch() does
rather than reconstructing it by hand, so the two cannot drift apart again.

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