elsa-core/specs/008-weaver-ai-copilot/data-model.md
Sipke Schoorstra 3936258146
Implement Weaver AI Copilot core (#7523)
* Implement Weaver AI Copilot core

* Address Greptile review feedback

* Address Greptile persistence feedback

* Address Greptile orchestration feedback

* Address Greptile tool isolation feedback

* Wire chat audit events

* Stream chat events over SSE

* Use server identity for AI endpoints

* Validate AI proposal persistence

* Isolate AI audit failures

* Enforce AI tool lookup scope

* Support AI tool result continuations

* Handle AI chat reconnects safely

* Tighten AI context and reconnect behavior

* Guard AI conversation and persistence setup

* Persist AI tool-loop progress

* Tighten AI tool registry and reconnect cleanup

* Handle AI preparation failures cleanly

* Order AI tool messages after assistant turns

* Initialize AI provider sessions

* Align AI context capabilities

* Prevent completed AI reconnect replay

* Enforce AI conversation ownership

* Default AI proposal creation time

* Persist AI session and retention defaults

* Allow AI context provider overrides

* Scope AI tool results per turn

* Apply AI provider configuration

* Scope AI proposal reads

* Avoid duplicate AI tool continuations

* Resolve AI tool registry scopes

* Tighten AI reconnect cleanup

* Honor default AI proposal tools

* Pass AI provider session to turns

* Close AI observability gaps

* Fix AI capabilities options alias

* Harden AI orchestration lifetimes

* Track actual AI reconnect conversation

* Address AI audit and context review findings

* Fix AI reconnect and persistence capabilities

* Handle AI session startup failures

* Tighten AI orchestration review gaps

* Warn on placeholder AI context

* Filter disabled AI provider tools

* Add durable AI conversation persistence

* Fix AI orchestrator persistence lifetime

* Handle failed AI reconnect edge cases

* Harden AI reconnect failure handling

* Address AI reconnect and cleanup review gaps

* Tighten AI audit and cleanup persistence

* Keep expired AI cleanup best effort

* Tighten AI tool lookup and cleanup fallback

* Handle AI provider and tenant edge cases

* Tighten AI proposal and agent authorization

* Address AI tool scope cleanup review

* Close remaining AI greptile findings

* Harden AI stores and tool defaults

* Harden AI conversation persistence edge cases

* Cover AI proposal and tool visibility guards

* Fix AI capabilities and audit batch resilience

* Fix AI conversation truncation for unicode

* Resolve remaining AI persistence review nits

* Wire AI conversation persistence option

* Address AI audit and proposal style review

* Fix AI stream truncation surrogate handling

* Address AI context and cleanup review

* Preserve AI titles and tenant tool defaults

* Guard AI conversation user ownership

* Align in-memory AI conversation ownership

* Fix expired AI conversation cleanup tracking

* Harden AI proposal persistence retry

* Tighten AI proposal reads and cleanup SQL

* Harden AI reconnect and provider defaults

* Optimize AI tool listing and message trimming

* Preserve AI conversation timestamps

* Address final AI persistence review nits

* Normalize AI acronym casing

* Address Copilot AI review comments

* Normalize default tenant handling for AI stores

* Harden AI registry and message truncation

* Make AI tool filtering explicit

* Align AI contracts with implementation

* Align remaining AI review contracts

* address greptile ai persistence feedback

* Address Copilot AI persistence feedback

* Address Copilot AI host feedback

* Order persisted AI conversation messages

* Address Copilot chat and cleanup feedback

* Release unused AI reconnect reservations

* Address Copilot AI review feedback

* Address Copilot tool and conversation feedback

* Address Copilot governance feedback

* Address Copilot tool test feedback

* Address AI review follow-ups

* Address Copilot AI follow-ups

* Clean up AI persistence tests

* Address IAITool disposal review

* Address AI integration review follow-ups

* Address AI chat persistence review

* Address AI registry and truncation review

* Enable read-only AI tools by default

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-06-04 11:35:44 +02:00

4.5 KiB

Data Model: Weaver AI Copilot Platform

AIConversation

Represents a Weaver chat thread visible to a user.

Fields: Id, TenantId, UserId, Title, Status, CreatedAt, UpdatedAt, ProviderSessionId, RetentionMode, RetentionExpiresAt.

Relationships: Has many AIMessage, AIContextAttachment, AIToolInvocation, and AIAuditEvent records.

Rules:

  • Conversation access is tenant- and actor-scoped.
  • Provider session IDs are internal server metadata and never exposed as provider objects.
  • Retention policy controls conversation history visibility, durability, and cleanup.

AIMessage

Represents user, assistant, system, or tool-visible content in a conversation.

Fields: Id, ConversationId, Role, Content, CreatedAt, StreamSequence, Metadata.

Rules:

  • Stored content must already be redacted.
  • Tool result details may be summarized for model context and preserved separately for display when safe.

AIContextAttachment

Represents a client-supplied reference to server-resolved context.

Fields: Id, ConversationId, Kind, ReferenceId, TenantId, Scope, TimeRange, ActivityId, Metadata.

Supported Kinds: WorkflowDefinition, WorkflowInstance, ActivitySelection, Tenant, DiagnosticsScope, TimeRange.

Rules:

  • Studio sends references only.
  • Server resolves attachments per request and validates authorization before use.
  • Context resolution applies size limits and redaction.

AIToolDefinition

Represents a registered Weaver tool.

Fields: Name, DisplayName, Description, Schema, Mutability, DangerLevel, Permissions, TenantBehavior, AuditBehavior, AgentScopes, Provider, EnabledByDefault, IsEnabled.

Rules:

  • Tool names are stable and namespaced, such as workflow.getDefinition.
  • Mutating tools are either proposal-only or administrative; administrative tools are out of MVP scope.
  • Tool metadata is validated during registration.
  • Read-only module tools may be enabled by default; proposal, administrative, and MCP-backed tools require explicit administrator enablement.

AIToolInvocation

Represents a single attempted tool execution.

Fields: Id, ConversationId, ToolName, Arguments, AuthorizationResult, StartedAt, CompletedAt, Status, ResultSummary, Error, TraceId, TenantId, ActorId.

Rules:

  • Authorization is checked before execution.
  • Arguments and results are redacted before audit and stream output.
  • Failed and denied invocations are audited.

AIProposal

Represents a reviewable AI-generated workflow creation or update.

Fields: Id, TenantId, ConversationId, Kind, Status, BaselineWorkflowDefinitionId, BaselineVersionId, WorkflowPayload, Rationale, Warnings, ValidationDiagnostics, GraphDiff, CreatedBy, CreatedAt, ReviewedBy, ReviewedAt, AppliedBy, AppliedAt.

States: Draft, Validated, Blocked, Approved, Rejected, Applied, Expired.

Rules:

  • Proposals are the only AI path to workflow writes.
  • Apply requires approval, authorization, validation pass, and baseline match.
  • The same authorized user may create, approve, reject, and apply a proposal in MVP.
  • Proposals are durable governance artifacts.
  • Proposal payloads are structured workflow definitions or patches, not free-form text.

AIAuditEvent

Represents durable governance evidence.

Fields: Id, TenantId, ActorId, ConversationId, ProposalId, ToolInvocationId, Type, Timestamp, TraceId, Summary, Data.

Rules:

  • Audit data is redacted.
  • Prompt, context resolution, tool call, denial, proposal, approval, rejection, and apply events are recorded.

AIAgentDefinition

Represents a named Weaver agent contributed by Core or a module.

Fields: Name, DisplayName, Description, Instructions, AllowedTools, AllowedContextProviders, AllowedMcpServers, Permissions, Enabled.

Rules:

  • Agents operate with least-privilege tool and context scopes.
  • Agent instructions cannot grant permissions or bypass server enforcement.

AIMcpServerRegistration

Represents a governed external tool server registration.

Fields: Name, Transport, Endpoint, ToolAllowlist, AgentScopes, Permissions, TenantBehavior, AuditBehavior, Enabled.

Rules:

  • Only allowlisted MCP tools are exposed.
  • Local and remote servers are configured server-side.
  • Per-agent scoping is mandatory.
  • MCP-backed tools require explicit administrator enablement before use.