fix(forge,claw): forge keys separate the issue from the pull

The watch key encoded source, repo, and number but not the thread
kind, and on GitLab an issue and a merge request share one number
space: iid 7 twice produced one key, one snapshot, and comments on
the merge request landing in the issue (or a 404 fallback that
misrouted the other way). The key carries the kind now —
{source}:{kind}:{owner}/{name}#{number}, with GitLab spelling the
pull variant mr — comment and snapshot route outright by kind, and a
kind-less payload parses to the unparsable key instead of guessing
issue. The claw's callers thread the kind from the payload and strip
the segment where the bare repo is wanted; pre-kind stored keys parse
as None rather than misroute. Four route-pinning wiremock tests cover
the GitLab split, and the GitHub/Gitea clients take the kind without
using it (their issues and PRs share the same REST space).
This commit is contained in:
vhaudiquet committed 2026-11-05 19:03:52 +01:00
1 parent 10efe85f38
commit 00adf092ff
15 files changed
+478 -178

No files matched your search

@@ -55,8 +55,26 @@ pub enum ThreadState {
Merged,
}
/// Repository coordinates. `owner` + `name` + a thread [`ForgeEvent::number`]
/// is the resource key the RSD dispatcher forms (`host:owner/repo#number`).
/// Which of a forge's thread sequences a number names. GitLab numbers
/// issues and merge requests from separate sequences, so the kind is part
/// of the thread's identity there; GitHub and Gitea share one sequence,
/// where the kind rides along for a uniform vocabulary.
///
/// `PullRequest` is the crate's umbrella term for the issue's
/// counterpart: GitHub's and Gitea's pull request, GitLab's merge
/// request.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ForgeThreadKind {
/// A thread in the forge's issue sequence.
Issue,
/// A thread in the forge's pull/merge-request sequence.
PullRequest,
}
/// Repository coordinates. `owner` + `name` + a thread's [`ForgeEvent::number`]
/// and [`ForgeThreadKind`] are the resource key the RSD dispatcher forms
/// (`host:issue:owner/repo#number`).
///
/// GitLab's `owner` is the whole namespace path (`group/subgroup`), so
/// [`RepoRef::path`] is always the full project path the forge addresses.