Class ModelDraftService

java.lang.Object
io.jmix.dynmodelai.session.ModelDraftService

@Component("dmagent_ModelDraftService") public class ModelDraftService extends Object
Manages run workspaces and one current immutable Draft per Conversation in local memory. Unknown identifiers fail instead of creating data.

Engine runs own temporary workspaces modified by Dynamic Model Tools. Successful verification produces the immutable Draft that the host transfers to its editor.
  • Constructor Details

  • Method Details

    • readActiveSettingsId

      public @Nullable UUID readActiveSettingsId()
      Reads the active Dynamic Model revision. Queries the database within the Conversation registration command.
    • requireReadable

      public void requireReadable(EditorModelSnapshot snapshot)
      Rejects an editor snapshot whose YAML cannot be read, before a Conversation or Run is created for it.
      Throws:
      IllegalArgumentException - with a message for the user
    • beginWorkspace

      public RunWorkspace beginWorkspace(UUID conversationId, UUID runId, @Nullable UUID expectedBaselineSettingsId, AgentPlan plan)
      Opens the working copy of a run, seeded from the editor snapshot or from the active settings.
      Throws:
      ConcurrentDynamicModelChangeException - if the active revision is no longer the expected one
    • beginWorkspace

      public RunWorkspace beginWorkspace(UUID conversationId, UUID runId, @Nullable UUID expectedBaselineSettingsId, AgentPlan plan, @Nullable EditorModelSnapshot editorSnapshot)
    • requireWorkspace

      public RunWorkspace requireWorkspace(UUID conversationId, UUID runId)
      Returns the workspace for a run. Read and mutate it only within its Conversation command.
      Throws:
      CancellationException - if the workspace belonged to a run that has already been closed
      IllegalArgumentException - if this Conversation has no workspace for the requested run
    • completeWorkspaceAsDraft

      public ModelDraft completeWorkspaceAsDraft(UUID conversationId, UUID runId, AgentPlan plan, String actor)
      Closes the workspace and makes its result the current Draft.
      Parameters:
      actor - username of the run that produced the Draft
    • prepareDraft

      public ModelDraft prepareDraft(UUID conversationId, UUID runId, AgentPlan plan, String actor)
      Builds the candidate without replacing the previous Draft or closing the workspace.
    • installDraft

      public void installDraft(ModelDraft draft)
      Installs a prepared candidate after mandatory history has been written in the same command.
    • abortWorkspace

      public void abortWorkspace(UUID runId)
    • requireCurrentDraft

      public ModelDraft requireCurrentDraft(UUID conversationId, UUID runId)
    • requestDraftRemoval

      public void requestDraftRemoval(UUID conversationId)
      Removes the current Draft when its Conversation UI closes.