Build a reverse dependency index: for each ticket ID, collect the tickets
that directly depend on it. Pass only non-terminal, non-satisfies_deps
tickets so that closed work does not inflate effective priority.
Close a ticket from any state. Commits the change to the ticket branch,
pushes it (non-fatal if no remote), then merges into the default branch
so that apm clean can detect and remove the worktree.
Returns true if a ticket in dep_state satisfies the dependency gate
required by the dependent ticket. required_gate is Some("tag") when
the dependent’s state has dep_requires = "tag", or None for the
default (requires satisfies_deps = true or terminal = true).
Return the effective priority of a ticket: the max of its own priority and
the priority of all direct and transitive dependents reachable via the
reverse index. Uses a visited set to handle cycles safely.
Return the highest-scoring ticket from tickets whose state is in
actionable and (if startable is non-empty) also in startable,
and whose depends_on deps are all satisfied.