agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

feat(scm): OneDev SCM provider

Open johnkattenhorn opened this issue 3 months ago • 3 comments

First — thanks for AO. We've been running it against a real project this week and the PR/CI loop is the thing that sold us: a worker opened a PR, its own CI went red on a pnpm/action-setup version conflict, and it diagnosed and fixed it without anyone touching it. The reviewer then found five genuine defects a green build would have shipped. That's the workflow we want, and the only thing standing between us and using AO properly is that our repos live on OneDev, not GitHub or GitLab.

We're planning to write a OneDev SCM provider in a fork. We'd much rather it lived upstream — opening this first per CONTRIBUTING so scope can be agreed before we invest the time, and to check you actually want it.

Context for why we're asking rather than just sending a PR: #825 (Forgejo), #741 (Bitbucket) and #1674 were all closed during the Go rewrite, with the note "If the underlying change still makes sense for the current app, please open a fresh PR against the new codebase." We'd like to avoid a fourth forge adapter written against a tree that's about to move.

Feasibility — we've mapped every method against a live OneDev instance

observe/scm.Provider is a clean seam and adapters/scm/gitlab is a good template. All seven methods map to real endpoints:

scm.Provider method OneDev endpoint Notes
ParseRepository — URL parsing only
ListPRsByRepo GET /~api/pulls?query=&offset=&count= Verified live. Returns lastActivity.date, usable for updatedAfter
FetchPullRequests GET /~api/pulls/{id} + /{id}/merge-preview merge-preview supplies mergeability / conflict state
FetchReviewThreads GET /~api/pulls/{id}/reviews, plus pull-request and code comment resources
FetchFailedCheckLogTail GET /~api/streaming/build-logs/{buildId} Purpose-built streaming endpoint
CommitChecksGuard GET /~api/builds?query= See caveat
RepoPRListGuard GET /~api/pulls?query= See caveat

One design question we'd want your steer on

OneDev returns no ETag or Last-Modified headers. We checked the response headers directly. The two *Guard methods exist so the observer can skip unchanged data cheaply, which matters a lot for a rate-limited GitHub and much less for a self-hosted, usually LAN-local OneDev.

Our proposal is to synthesise a guard from a cheap max(lastActivity) query and fall back to reporting "changed" when that isn't conclusive — correctness preserved, at the cost of more full fetches. If you'd rather SCMGuardResult grew an explicit "provider has no conditional-request support" signal instead of each adapter improvising, we're happy to do it that way — that seems like your call rather than ours.

Shape of the change

Additive, mirroring adapters/scm/gitlab:

  • internal/adapters/scm/onedev/ — provider.go, observer_provider.go, client.go, auth.go, cache.go
  • internal/config/config.go — OneDevConfig following the existing AO_GITLAB_ALLOWED_HOSTS / AO_GITLAB_HOST_TOKENS pattern (OneDev is always self-hosted, so per-host tokens matter from day one)
  • internal/daemon/scm_wiring.go — register as a scmmulti.NamedProvider, same degrade-gracefully behaviour as the existing two

Tests would follow provider_test.go, plus integration coverage against a real instance — including the absent-ETag path, so the fallback is exercised rather than assumed.

A companion issue covers the tracker side and the issue-intake wiring.

What we're asking

  1. Do you want OneDev support upstream at all?
  2. If yes, any preference on the guard question above before we write it?
  3. Happy to follow the claim-and-assignment process — just say the word and we'll pick it up.

Either way, thanks — we'll build it in a fork regardless because we need it, so the only question is whether it's useful to you too.

johnkattenhorn avatar Aug 27 '26 17:08 johnkattenhorn

Thanks for contributing to Agent Orchestrator.

This issue is being picked up by the current external contributor on-call pair:

  • @illegalcall
  • @somewherelostt

If someone is already working on this, please continue as usual. The on-call pair is added for visibility, tracking, and support, not to take over the work. If you need help with review, direction, reproduction, or next steps, please tag @illegalcall and @somewherelostt here.

For faster context or live questions, you can also join the AO Discord.

Join the session here: https://discord.gg/H6ZDcUXmq

Come by if you want to see what is being built, ask questions, or just hang around with the community.

somewherelostt avatar Aug 28 '26 15:08 somewherelostt

@illegalcall @somewherelostt — PR up for this one: #4654.

It's the OneDev SCM provider: provider foundation and per-host credential resolution, the observer (PR state, CI builds, build logs, review state), authenticated-identity resolution, registration in every SCM constructor, and an ao doctor section. Eight commits plus one lint-only commit, rebased onto current main, go build/go vet clean.

Two things I'd rather you heard from me than found in review:

  • MergePullRequest deliberately returns unsupported. OneDev's merge API has no compare-and-swap, so a merge can't be made safe against a racing push the way the GitHub and GitLab paths are. The adapter declines rather than risk landing the wrong head; users merge in the OneDev UI. That's the one capability gap versus the other providers, and it's a decision, not an oversight.
  • fix(daemon): register OneDev in every SCM constructor fixes a real bug but points at a pattern issue — scm_wiring.go builds providers in three places that must be kept in sync, and only one of them registered the new provider. Worth a maintainer opinion on whether that should be restructured rather than patched.

CONTRIBUTING says to get a thumbs-up on Discord before non-trivial work. This was already built and running against a real OneDev instance before I raised the issue, so there was nothing to gate — but I'm raising it here rather than assuming. If you'd rather this were split smaller, reordered, or approached differently, I'll rework it; nothing here is precious.

#4655 covers #4557 and is stacked on this branch.

johnkattenhorn avatar Aug 29 '26 21:08 johnkattenhorn

Closed as not planned. AO's SCM support stays with GitHub and GitLab, and we're not taking on a third forge provider. Thanks for mapping the OneDev API so thoroughly and for the work in #4654.

Rishet11 avatar Nov 15 '26 20:11 Rishet11