Project-scoped AI task pause with confirmation that admitted workspace launches have drained #3211
skudr opened 4 weeks ago

Question / enhancement request

Is there a supported way to pause AI task admission for one project and then confirm that all previously admitted workspace-launch handlers have finished?

We need a safe point for an operator to clean up the project's AI workspaces and resume automation explicitly, without stopping the whole OneDev server or disabling the same AI users in other projects.

Why revoking permission and listing workspaces may not be enough

We use OneDev 16.9.7. Reading that tag suggests a possible interval between permission checking and workspace creation:

  • DefaultListenerRegistry.post dispatches project-event listeners asynchronously after commit (DefaultListenerRegistry.java:109–129).
  • The issue notification path checks canCreateWorkspace before preparing and running the prompt (IssueNotificationManager.java:287–288,451–475,500–508).
  • DefaultWorkspaceService.runPrompt selects an applicable automation spec and creates a workspace without repeating that permission check (DefaultWorkspaceService.java:1157–1175).

Therefore, an event handler that already passed the permission check might still create a workspace after an operator revokes the AI user's project authorization. A single empty workspace listing would not establish that all previously admitted launches have completed.

This is an inference from source ordering, not a reproduced race or a claim that permission revocation is documented as a drain operation. We may be missing an existing supported mechanism.

Desired contract

A documented procedure or project-scoped operation that lets an operator:

  1. Prevent new AI task admissions for the selected project.
  2. Obtain a completion acknowledgement once previously admitted handlers can no longer create additional workspaces, or have been cancelled before creation.
  3. Clean up existing AI workspaces separately and resume admission explicitly.

It should not require disabling those AI users globally or pausing unrelated projects. An admission/drain acknowledgement is distinct from an empty list of currently visible workspaces.

Does such a mechanism already exist in 16.9.7 or a later release? If not, could a supported project-level pause/drain contract be added?

  • Robin Shen commented 4 weeks ago

    Can you please describe usage scenario of this enhancement?

  • skudr commented 4 weeks ago

    Thanks for looking at this. Here is the scenario.

    We run a bug-fixing pipeline entirely on OneDev AI users. Three AI users – an acceptor, an executor and a reviewer – are shared across several projects. They wake on issue assignment and review requests, work in workspaces (Codex in a container), open pull requests, and AutoMerge merges them when the required builds pass and the AI reviewer approves.

    Sometimes the operator has to stop this automation for one project while the other projects keep working:

    1. The project’s main build turns red. Every new pull request would build on a broken base, and the AI users would keep spending workspace slots on retries and new pull requests.
    2. An AI user misbehaves on that project – for example, a prompt or workspace-spec change makes it rewrite issues it should only comment on. We need to stop it, fix the prompt or spec, and resume.
    3. Maintenance of the project’s build spec, branch protection or workspace specs, which should not race with running AI tasks.

    Today we stop a project by removing the AI users’ authorization on that project, disabling AutoMerge on their open pull requests and deleting their workspaces. Disabling the AI users globally is not an option, because they serve the other projects too.

    What we cannot tell is when the cleanup is safe. If a notification handler passed the permission check just before we revoked it, it may still create a workspace after we listed and deleted the existing ones. We would like either a documented guarantee – for example, “after the authorization is removed, no new workspace is created for that project once X is true” – or a project-level “pause AI tasks” switch that reports when no admitted launch is still pending.

  • Robin Shen commented 4 weeks ago

    Thanks for explaining your workflow in detail. I can see why you need a reliable way to pause automation for one project and safely clean up its workspaces while other projects continue running.

    This issue can be addressed via maintenance mode introduced in 17.0.2: simply set project in maintenance mode in general setting and all non-manager users will not be allowed to work on the project, including AI users. If you want to allow operator to continue to work on in maintenance mode, change relevant role to tick the "work in maintenance mode" privilege.

    We've decided to offer this feature as part of OneDev Enterprise Edition, which helps fund the ongoing development and long-term maintenance of OneDev.

    I appreciate the time you took to describe both the workflow and the limitations of your current approach. That context was very helpful in understanding the need.

  • Robin Shen changed state to 'Closed' 4 weeks ago
    Previous Value Current Value
    Open
    Closed
1/1
Type
Enhancement
Priority
Normal
Assignee
Labels
No labels
Issue Votes (0)
Watchers (2)
Reference
OD-3211
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover