Package io.jmix.dynmodelai.session
Class ModelDraftService
java.lang.Object
io.jmix.dynmodelai.session.ModelDraftService
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 Summary
ConstructorsConstructorDescriptionModelDraftService(DynamicModelSettingsService settingsService, DynamicModelDefinitionSerializer serializer, EntityStates entityStates, ConversationSessions sessions, ConversationCommands commands, Messages messages) -
Method Summary
Modifier and TypeMethodDescriptionvoidabortWorkspace(UUID runId) 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.beginWorkspace(UUID conversationId, UUID runId, @Nullable UUID expectedBaselineSettingsId, AgentPlan plan, @Nullable EditorModelSnapshot editorSnapshot) completeWorkspaceAsDraft(UUID conversationId, UUID runId, AgentPlan plan, String actor) Closes the workspace and makes its result the current Draft.voidinstallDraft(ModelDraft draft) Installs a prepared candidate after mandatory history has been written in the same command.prepareDraft(UUID conversationId, UUID runId, AgentPlan plan, String actor) Builds the candidate without replacing the previous Draft or closing the workspace.@Nullable UUIDReads the active Dynamic Model revision.voidrequestDraftRemoval(UUID conversationId) Removes the current Draft when its Conversation UI closes.requireCurrentDraft(UUID conversationId, UUID runId) voidrequireReadable(EditorModelSnapshot snapshot) Rejects an editor snapshot whose YAML cannot be read, before a Conversation or Run is created for it.requireWorkspace(UUID conversationId, UUID runId) Returns the workspace for a run.
-
Constructor Details
-
ModelDraftService
public ModelDraftService(DynamicModelSettingsService settingsService, DynamicModelDefinitionSerializer serializer, EntityStates entityStates, ConversationSessions sessions, ConversationCommands commands, Messages messages)
-
-
Method Details
-
readActiveSettingsId
Reads the active Dynamic Model revision. Queries the database within the Conversation registration command. -
requireReadable
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
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 closedIllegalArgumentException- 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
Builds the candidate without replacing the previous Draft or closing the workspace. -
installDraft
Installs a prepared candidate after mandatory history has been written in the same command. -
abortWorkspace
-
requireCurrentDraft
-
requestDraftRemoval
Removes the current Draft when its Conversation UI closes.
-