Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.
Ruby agplai-assistantdockerdsgvogdprhotwireissue-trackerjira-alternativeknowledge-basellmmcp-servermeeting-notesopen-sourceproject-managementredmine-alternativeruby-on-railsself-hostedticketingtime-tracking
Let programs create meetings over the API and MCP
Guido Boykee2a5382af6e3
diff --git a/.github/workflows/guards.yml b/.github/workflows/guards.ymlindex 3fada00..b99ce3f 100644--- a/.github/workflows/guards.yml+++ b/.github/workflows/guards.yml@@ -263,6 +263,7 @@ jobs:spec/requests/api/mcp_time_report_spec.rbspec/requests/api/mcp_people_spec.rbspec/requests/api/mcp_list_projects_spec.rb+ spec/requests/api/mcp_create_meeting_spec.rbspec/requests/api/v1/projects_listing_spec.rbspec/requests/api/mcp_idempotency_key_bound_spec.rbspec/services/mcp/idempotency_store_spec.rb@@ -301,6 +302,7 @@ jobs:spec/requests/api/v1/ticket_view_spec.rbspec/requests/api/v1/comment_files_spec.rbspec/requests/api/v1/people_spec.rb+ spec/requests/api/v1/meetings_spec.rbspec/requests/api/people_parity_spec.rbspec/requests/api/v1/post_comment_format_spec.rbspec/requests/api/v1/ticket_changes_spec.rbdiff --git a/app/controllers/api/v1/meetings_controller.rb b/app/controllers/api/v1/meetings_controller.rbnew file mode 100644index 0000000..5f8837e--- /dev/null+++ b/app/controllers/api/v1/meetings_controller.rb@@ -0,0 +1,77 @@+# frozen_string_literal: true++module Api+ module V1+ # POST /api/v1/organisations/:organisation_id/meetings+ #+ # Under the organisation, not the project: the project may be missing, the+ # meeting then lands in the inbox. The rule is Meetings::Intake, shared with+ # the MCP tool create_meeting; the write is Actors::SaveMeeting.+ class MeetingsController < BaseController+ idempotent :create++ def create+ organisation = Organisation.find(params[:organisation_id])++ with_organisation_scope(organisation) do+ intake = Meetings::Intake.new(organisation: organisation, reach: current_token.reach, viewer: current_user,+ input: meeting_input)+ next render_refusal(intake.refusal) if intake.refusal++ with_project_scope(intake.project) do+ authorize intake.project, :show?+ authorize intake.meeting_for_policy, :create?+ answer(intake)+ end+ end+ end++ private++ def answer(intake)+ result = intake.save+ return render json: { data: Meetings::Intake.summary(intake.meeting) }, status: :created if result.success?+ return render_error(error: 'internal_error', status: :internal_server_error) if result.code == :internal_error++ render_error(error: 'validation_failed', errors: result.errors, status: :unprocessable_entity)+ end++ # Nothing was authorized: the refusal itself is the decision, and it comes+ # before there is a record to ask a policy about.+ def render_refusal(refusal)+ skip_authorization+ case refusal.code+ when :not_found then not_found+ when :forbidden then render_error(error: 'forbidden', reason: refusal.reason, status: :forbidden)+ when :invalid_input+ render_error(error: 'validation_failed', errors: [refusal_message(refusal)], reason: refusal.reason,+ status: :unprocessable_entity)+ else+ render_error(error: refusal.reason, message: refusal_message(refusal), status: :unprocessable_entity)+ end+ end++ def refusal_message(refusal)+ I18n.t("services.meetings.intake.#{refusal.reason}")+ end++ # The participants pass by hand: permit drops a value of the wrong shape,+ # and a meeting silently without them reads like a meeting without them.+ # Meetings::Intake refuses what is no list of objects.+ def meeting_input+ input = params.require(:meeting)+ raise ActionController::ParameterMissing, :meeting unless input.is_a?(ActionController::Parameters)++ fields = input.permit(:project_id, *Meetings::Intake::FIELDS).to_h+ fields[:participants] = participant_rows(input[:participants]) if input.key?(:participants)+ fields+ end++ def participant_rows(raw)+ return raw unless raw.is_a?(Array)++ raw.map { |row| row.is_a?(ActionController::Parameters) ? row.permit(:display_name, :ref).to_h : row }+ end+ end+ end+enddiff --git a/app/services/actors/save_meeting.rb b/app/services/actors/save_meeting.rbindex 8d22816..f25a05c 100644--- a/app/services/actors/save_meeting.rb+++ b/app/services/actors/save_meeting.rb@@ -14,8 +14,12 @@ module Actors# transaction (add / remove / rename, no orphans). A nil payload means "not# provided" and leaves existing participants untouched.class SaveMeeting < BaseActor- def initialize(project:, params:, current_user:, id: nil)+ # participant_links: normalized name => person_id, for a caller that has+ # resolved people through the directory itself (Meetings::Intake). Separate+ # from `params` on purpose: a payload never names a person_id.+ def initialize(project:, params:, current_user:, id: nil, participant_links: {})super()+ @participant_links = participant_links# Extract BEFORE find_meeting: a new record does project.meetings.build(params),# which would choke on a :participants key that is not a Meeting column.@participants_payload = extract_participants(params)@@ -148,7 +152,7 @@ module Actors# Rows are matched and updated in place, never rebuilt. That is what keeps# person_id (the link to the people directory): the form does not know it,- # and it never comes from the payload. A row survives every save that keeps+ # and it never comes from the payload (a caller hands it in participant_links). A row survives every save that keeps# the participant, with its link: the same normalized name in any spelling,# or the same member under another name (the form labels a member chip with# the member's current profile name, so a change of name in the profile@@ -175,6 +179,8 @@ module Actorsbecomes_member = d[:user_id].present? && d[:user_id] != participant.user_idparticipant.person_id = nil if becomes_memberparticipant.user_id = d[:user_id]+ link = @participant_links[d[:normalized_name]]+ participant.person_id = link if linkparticipant.save!endenddiff --git a/app/services/api/v1/capabilities.rb b/app/services/api/v1/capabilities.rbindex f7ef029..a0d99bc 100644--- a/app/services/api/v1/capabilities.rb+++ b/app/services/api/v1/capabilities.rb@@ -19,8 +19,9 @@ module Api# time_sessions.book (R6); 1.5.0 adds posts.plain (R3a); 1.6.0 adds# knowledge.search (R2); 1.7.0 adds tickets.changes (R3b); 1.8.0 adds a# comment's attachments (R7), a field and no capability: a client takes- # its presence as the signal.- API_VERSION = '1.8.0'+ # its presence as the signal; 1.9.0 adds meetings.create and the field+ # meeting_inbox on projects.list.+ API_VERSION = '1.9.0'# name => [verb, path as the router spells it]ENDPOINTS = {@@ -28,6 +29,7 @@ module Api'organisations.list' => ['GET', '/api/v1/organisations'],'people.list' => ['GET', '/api/v1/organisations/:organisation_id/people'],'people.show' => ['GET', '/api/v1/organisations/:organisation_id/people/:id'],+ 'meetings.create' => ['POST', '/api/v1/organisations/:organisation_id/meetings'],'projects.list' => ['GET', '/api/v1/projects'],'projects.ticket_attribute_definitions' => ['GET', '/api/v1/projects/:id/ticket_attribute_definitions'],'knowledge.search' => ['GET', '/api/v1/projects/:project_id/knowledge'],diff --git a/app/services/lalabase/CLAUDE.md b/app/services/lalabase/CLAUDE.mdindex e003d62..aae63bf 100644--- a/app/services/lalabase/CLAUDE.md+++ b/app/services/lalabase/CLAUDE.md@@ -1,4 +1,4 @@-# Karte: app/services/lalabase (Stand: 2026-10-31)+# Karte: app/services/lalabase (Stand: 2026-11-01)AI/RAG-Domäne (Produktname „Lalabase"): alles rund um LLM-Aufrufe, Embeddings undCodebase-Verständnis.@@ -50,7 +50,9 @@ Codebase-Verständnis.Organisation selbst setzen). Die Inbox-Zeilen kommen aus `Notifications::InboxQuery` + `Serializer`, geteilt mit der HTTP-API.Schreibende Werkzeuge gibt es nur im `:mcp`-Set: `create_ticket`, `post_comment`,- `create_time_session`, `mark_notification_read`, `update_ticket`. `create_time_session`+ `create_time_session`, `mark_notification_read`, `update_ticket`, `create_meeting`+ (token-scoped, setzt den Tenant selbst; Regel `Meetings::Intake`, dieselbe wie+ `POST /api/v1/organisations/:id/meetings`). `create_time_session`bucht über `TimeSessions::Booking`, dieselbe Regel wie die HTTP-API (seit 29.10.2026,REST R6); im Werkzeug bleiben nur Argumente, Rechte und die Texte. `post_comment` schreibtüber `Actors::SavePost` wie das Web-Formular (Activity `post_added`, Benachrichtigungen,diff --git a/app/services/lalabase/tools/create_meeting.rb b/app/services/lalabase/tools/create_meeting.rbnew file mode 100644index 0000000..381e164--- /dev/null+++ b/app/services/lalabase/tools/create_meeting.rb@@ -0,0 +1,112 @@+# frozen_string_literal: true++module Lalabase+ module Tools+ # Creates a meeting by the rule POST /api/v1/organisations/:id/meetings writes+ # by (Meetings::Intake, Actors::SaveMeeting). Token-scoped: the project may be+ # missing, the meeting then lands in the organisation's inbox, so there is no+ # project for the seam to gate and this tool sets the tenant itself. A flat+ # name of its own class, like McpFindPeople; only in the :mcp set, a write.+ class CreateMeeting < Base+ ORGANISATION_NOT_REACHABLE = 'organisation not found or not reachable with this token'++ def self.requires_actor?+ true+ end++ def self.mutating?+ true+ end++ def self.scope_mode+ :token+ end++ def self.authorization_mode+ :record+ end++ def self.tool_name+ 'create_meeting'+ end++ def self.description+ 'Creates a meeting with its transcript. Without project_id it lands in the inbox project of the ' \+ 'organisation. Write the transcript as lines of "Name: text", the names as in participants; a ' \+ 'participant may carry ref, the id from find_people. Returns the meeting without the transcript.'+ end++ def self.input_schema+ {+ type: 'object',+ properties: {+ organisation_id: { type: 'string', description: 'UUID of the organisation (list_organisations names them).' },+ project_id: { type: 'string', description: 'Optional. UUID of the project; without it the inbox project.' },+ title: { type: 'string', description: 'Meeting title (required).' },+ occurred_at: { type: 'string', description: 'When it took place, ISO 8601 (required).' },+ duration_minutes: { type: 'integer', description: 'Length in minutes.' },+ notes: { type: 'string', description: 'Notes.' },+ transcript: { type: 'string', description: 'Transcript, lines of "Name: text".' },+ participants: {+ type: 'array',+ description: 'Who took part.',+ items: {+ type: 'object',+ properties: {+ display_name: { type: 'string', description: 'Name as in the transcript.' },+ ref: { type: 'string', description: 'Optional. The id from find_people (person:<uuid>, member:<uuid>).' }+ },+ required: ['display_name']+ }+ }+ },+ required: %w[organisation_id title occurred_at]+ }+ end++ def self.execute(args:, context:)+ return Result.new(error: 'token context missing') unless token_wide?(context)++ args = symbolized(args)+ organisation = reachable_organisation(args[:organisation_id], context)+ return organisation if organisation.is_a?(Result)++ ActsAsTenant.with_tenant(organisation) { create(organisation, args, context) }+ end++ def self.reachable_organisation(raw, context)+ id = raw.to_s.strip+ return Result.invalid_input("invalid organisation_id #{raw.inspect} (expected a UUID)") unless Lalabase::Uuid.valid?(id)++ organisation = Organisation.find_by(id: id)+ return organisation if organisation && context.reach.organisation?(organisation.id)++ Result.new(error: ORGANISATION_NOT_REACHABLE, code: :not_found)+ end+ private_class_method :reachable_organisation++ def self.create(organisation, args, context)+ intake = Meetings::Intake.new(organisation: organisation, reach: context.reach, viewer: context.actor,+ input: args.except(:organisation_id))+ return refused(intake.refusal, context) if intake.refusal++ authorize!(context, intake.meeting_for_policy, :create?)++ result = intake.save+ return Result.new(error: "create failed: #{Array(result.errors).join(', ')}") unless result.success?++ Result.new(content: Meetings::Intake.summary(intake.meeting).to_json)+ end+ private_class_method :create++ # The refusal is the decision here, as in the REST controller; the policy has+ # no record to ask about yet.+ def self.refused(refusal, context)+ context.authorization&.record!+ message = I18n.t("services.meetings.intake.#{refusal.reason}")+ Result.new(error: message, code: refusal.code, reason: refusal.reason)+ end+ private_class_method :refused+ end+ end+enddiff --git a/app/services/lalabase/tools/registry.rb b/app/services/lalabase/tools/registry.rbindex 9b84f5b..7efc5dc 100644--- a/app/services/lalabase/tools/registry.rb+++ b/app/services/lalabase/tools/registry.rb@@ -145,7 +145,10 @@ module Lalabase# How an agent finds the organisation and project ids the tools above take,# token-scoped reads. Appended for the same reason.ListOrganisations,- ListProjects+ ListProjects,+ # A meeting with its transcript, token-scoped because the project may be+ # missing (it then lands in the inbox). Appended for the same reason.+ CreateMeeting].freeze# Sets whose tools reach the LLM tool loop. The guard-spec enforces thediff --git a/app/services/mcp/dispatcher.rb b/app/services/mcp/dispatcher.rbindex 33118d9..773c724 100644--- a/app/services/mcp/dispatcher.rb+++ b/app/services/mcp/dispatcher.rb@@ -55,7 +55,9 @@ module Mcp# content_type, byte_size; REST R7), beside attachments_count.# 0.15 = list_organisations and list_projects: the ids the other tools take,# from the same reader as GET /api/v1/organisations and /projects.- SERVER_VERSION = '0.15.0'+ # 0.16 = create_meeting, by the rule of POST /api/v1/organisations/:id/meetings,+ # and meeting_inbox on the rows of list_projects.+ SERVER_VERSION = '0.16.0'# MCP surface — sourced from the single tool registry (D6): the :mcp set is the# ONE definition of this surface, so a registry refactor can't drift it (R3);diff --git a/app/services/meetings/intake.rb b/app/services/meetings/intake.rbnew file mode 100644index 0000000..48ce00e--- /dev/null+++ b/app/services/meetings/intake.rb@@ -0,0 +1,148 @@+# frozen_string_literal: true++# A meeting a program sends, for both surfaces (POST /api/v1/organisations/:id/meetings+# and the MCP tool create_meeting): where it lands and who took part. The write is+# Actors::SaveMeeting, the web form's, so the activity and the participants run as+# they do there. Each surface authorizes `meeting_for_policy` itself, which is what+# marks its tripwire, and answers a refusal in its own envelope.+#+# Without a project the meeting lands in the organisation's inbox+# (Organisation#meeting_inbox). The difference to a named project is the refusal:+# the caller did not choose the inbox, so an inbox out of reach says so (forbidden)+# instead of a 404 nobody could act on. It tells nothing but that the organisation+# has one.+#+# A participant is a name, optionally with `ref`, the id the people list hands out+# (member:<uuid>, person:<uuid>). A ref is resolved through People::Lookup, so the+# token's reach and the writer's people right apply, and a ref that does not resolve+# refuses the whole meeting: sent on without its link, the meeting would look fine+# and the person's history would lack it.+#+# Entry point: new, refusal, meeting_for_policy, save, .summary+module Meetings+ class Intake+ # reason: names the refusal for a program. code: the error class of both surfaces.+ Refusal = Data.define(:reason, :code)++ FIELDS = %i[title occurred_at duration_minutes notes transcript].freeze++ NOT_FOUND = Refusal.new(reason: :not_found, code: :not_found)+ INBOX_MISSING = Refusal.new(reason: :meeting_inbox_missing, code: :refused)+ INBOX_FORBIDDEN = Refusal.new(reason: :meeting_inbox_forbidden, code: :forbidden)+ PROJECT_ARCHIVED = Refusal.new(reason: :project_archived, code: :refused)+ UNKNOWN_PARTICIPANT = Refusal.new(reason: :unknown_participant, code: :invalid_input)++ attr_reader :project, :refusal, :meeting++ # #refusal is a Refusal, or nil when the meeting may go on to the policy and #save.+ # @param organisation [Organisation] reached by the token; the caller holds its tenant+ # @param reach [PersonalAccessToken::Reach]+ # @param input [Hash] project_id, FIELDS, participants: [{ display_name:, ref: }]+ def initialize(organisation:, reach:, viewer:, input:)+ @organisation = organisation+ @reach = reach+ @viewer = viewer+ @input = input.to_h.deep_symbolize_keys+ @participants = []+ @links = {}+ @refusal = resolve_target || resolve_participants+ end++ # What the surface authorizes :create? on.+ def meeting_for_policy+ project.meetings.build+ end++ # @return [BaseActor::Result]+ def save+ actor = Actors::SaveMeeting.new(project: project, params: meeting_params, current_user: @viewer,+ participant_links: @links)+ actor.call.tap { @meeting = actor.record }+ end++ # The answer of both surfaces, and it stays this small: an idempotent write+ # stores its answer for good (Mcp::IdempotencyStore), outside the meeting, so+ # a transcript in here would survive the meeting's deletion.+ def self.summary(meeting)+ {+ id: meeting.id,+ project_id: meeting.project_id,+ in_meeting_inbox: meeting.project.meeting_inbox?,+ title: meeting.title,+ occurred_at: meeting.occurred_at.iso8601,+ path: Rails.application.routes.url_helpers.organisation_project_meeting_path(+ meeting.organisation_id, meeting.project_id, meeting+ )+ }+ end++ private++ def meeting_params+ fields = @input.slice(*FIELDS)+ fields[:participants] = @participants if @input.key?(:participants)+ fields.with_indifferent_access+ end++ def resolve_target+ return resolve_inbox if @input[:project_id].blank?++ @project = @organisation.projects.find_by(id: @input[:project_id])+ return NOT_FOUND unless @reach.project?(@project)++ # Asked here, not left to the policy: its area check lets an account admin+ # write into an archived project (see MeetingPolicy#move?).+ PROJECT_ARCHIVED if @project.archived?+ end++ def resolve_inbox+ @project = @organisation.meeting_inbox+ return INBOX_MISSING if @project.nil?+ return if @reach.project?(@project) && Pundit.policy!(@viewer, meeting_for_policy).create?++ INBOX_FORBIDDEN+ end++ def resolve_participants+ entries = @input.fetch(:participants, [])+ return UNKNOWN_PARTICIPANT unless entries.is_a?(Array) && entries.all?(Hash)++ entries.each do |entry|+ participant = { display_name: entry[:display_name], user_id: nil }+ if entry[:ref].present?+ found = directory_entry(entry[:ref])+ return UNKNOWN_PARTICIPANT if found.nil?++ attach(participant, found)+ end+ @participants << participant+ end+ nil+ end++ # A member is linked by user_id, the path the meeting form uses; a contact by+ # person_id, which the actor takes from participant_links, never from a payload.+ def attach(participant, found)+ if found.member?+ participant[:user_id] = found.user.id+ else+ @links[MeetingParticipant.normalize_name(participant[:display_name])] = found.person.id+ end+ end++ def directory_entry(ref)+ people = people_lookup+ return nil unless people&.allowed?++ people.entry(ref)+ rescue People::Lookup::InvalidArgument+ nil+ end++ def people_lookup+ return @people_lookup if defined?(@people_lookup)++ @people_lookup = People::Lookup.for_token(reach: @reach, viewer: @viewer, organisation_id: @organisation.id)+ end+ end+enddiff --git a/app/services/personal_access_tokens/reach_listing.rb b/app/services/personal_access_tokens/reach_listing.rbindex d5b380d..4fbbf93 100644--- a/app/services/personal_access_tokens/reach_listing.rb+++ b/app/services/personal_access_tokens/reach_listing.rb@@ -80,6 +80,7 @@ module PersonalAccessTokensname: project.name,description: project.description,archived: project.archived_at.present?,+ meeting_inbox: project.meeting_inbox?,organisation: {id: project.organisation_id,name: project.organisation&.namediff --git a/config/locales/services.de.yml b/config/locales/services.de.ymlindex 9e3fccd..81c336a 100644--- a/config/locales/services.de.yml+++ b/config/locales/services.de.yml@@ -117,6 +117,11 @@ de:# not end up in the user-visible summary_creation_error column.provider_error: "Der gewählte KI-Anbieter konnte keine Zusammenfassung erstellen. Bitte prüfen Sie Anbieter, Modell und Zugang in den KI-Einstellungen."meetings:+ intake:+ meeting_inbox_missing: Ohne Projekt braucht die Organisation ein Eingangsprojekt. Dort ist keines gesetzt.+ meeting_inbox_forbidden: Sie dürfen im Eingangsprojekt keine Meetings anlegen. Geben Sie ein Projekt an oder lassen Sie sich Zugriff geben.+ project_archived: Das Projekt ist archiviert und nimmt keine Meetings an.+ unknown_participant: Ein Teilnehmer lässt sich nicht zuordnen.summary:ai_disabled: "KI-Funktionen sind für diese Organisation deaktiviert."not_configured: "Es ist kein gültiger KI-Zugang konfiguriert."diff --git a/config/locales/services.en.yml b/config/locales/services.en.ymlindex 91d6d5b..1d11104 100644--- a/config/locales/services.en.yml+++ b/config/locales/services.en.yml@@ -117,6 +117,11 @@ en:# not end up in the user-visible summary_creation_error column.provider_error: "The selected AI provider could not create a summary. Please check provider, model and access in the AI settings."meetings:+ intake:+ meeting_inbox_missing: Without a project the organisation needs an inbox project, and none is set.+ meeting_inbox_forbidden: You may not create meetings in the inbox project. Name a project or ask for access.+ project_archived: The project is archived and takes no meetings.+ unknown_participant: A participant cannot be resolved.summary:ai_disabled: "AI features are disabled for this organisation."not_configured: "No valid AI access is configured."diff --git a/config/routes.rb b/config/routes.rbindex 5af673c..e25bf38 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -928,6 +928,9 @@ Rails.application.routes.draw doresources :organisations, only: %i[index] do# People S3b: the people directory of one organisation, read only.resources :people, only: %i[index show]+ # A meeting, under the organisation because the project may be missing+ # (it then lands in the organisation's inbox project).+ resources :meetings, only: %i[create]endget 'time_sessions/open', to: 'time_sessions#open'resources :projects, only: %i[index] dodiff --git a/spec/architecture/website_feature_claims_guard_spec.rb b/spec/architecture/website_feature_claims_guard_spec.rbindex b014da0..4e56add 100644--- a/spec/architecture/website_feature_claims_guard_spec.rb+++ b/spec/architecture/website_feature_claims_guard_spec.rb@@ -29,13 +29,13 @@ RSpec.describe 'Mechanisms behind the claims on lalabase.com' do# until 10.09.2026. update_ticket (terminal client S2) ended the promise "no status# changes from outside" in two FAQ answers; the sentence that still holds is "no# deleting from outside".- it 'has exactly the five mutating MCP tools those sentences enumerate' do+ it 'has exactly the six mutating MCP tools those sentences enumerate' domutating = Lalabase::Tools::Registry.for(:mcp).select(&:mutating?)expect(mutating.map(&:name)).to match_array(%w[Lalabase::Tools::CreateTicket Lalabase::Tools::PostCommentLalabase::Tools::CreateTimeSession Lalabase::Tools::MarkNotificationRead- Lalabase::Tools::UpdateTicket]+ Lalabase::Tools::UpdateTicket Lalabase::Tools::CreateMeeting])enddiff --git a/spec/contracts/mcp_contract_recorder.rb b/spec/contracts/mcp_contract_recorder.rbindex 63aca5c..bf6bee2 100644--- a/spec/contracts/mcp_contract_recorder.rb+++ b/spec/contracts/mcp_contract_recorder.rb@@ -356,7 +356,10 @@ module McpContract'comment_file' => comment_file_calls(website),# MCP 0.15, appended last: reads, so every answer above stays as it was.'list_organisations' => { 'ok' => tool_call(:read, 'list_organisations') },- 'list_projects' => list_projects_calls+ 'list_projects' => list_projects_calls,+ # MCP 0.16, appended last: refusals that write nothing, so every answer+ # above stays as it was.+ 'create_meeting' => create_meeting_calls}end@@ -380,6 +383,16 @@ module McpContract}end+ def create_meeting_calls+ meeting = { title: 'Abstimmung', occurred_at: '2026-01-01T10:00:00Z' }+ {+ 'refused_no_inbox' => tool_call(:write, 'create_meeting', organisation_id: id(:organisation), **meeting),+ 'read_only' => tool_call(:read, 'create_meeting', organisation_id: id(:organisation), **meeting),+ 'invalid_input' => tool_call(:write, 'create_meeting', organisation_id: 'oops', **meeting),+ 'not_found' => tool_call(:write, 'create_meeting', organisation_id: id(:other_organisation), **meeting)+ }+ end+def list_projects_calls{'ok' => tool_call(:read, 'list_projects'),diff --git a/spec/fixtures/mcp_contract.json b/spec/fixtures/mcp_contract.jsonindex 4323f1e..6aa0dec 100644--- a/spec/fixtures/mcp_contract.json+++ b/spec/fixtures/mcp_contract.json@@ -1,9 +1,9 @@{"header": {"regenerate": "RAILS_ENV=test bin/rails mcp:contract",- "core_commit": "302d7c6ee2599bbbb175966c7a5e56964647aa3f",- "core_dirty": true,- "contract_sha256": "14a7896191ee2dbeb1742e350ed5bbcc89797759b7b4711e54f472df698cb14e"+ "core_commit": "9d5713e64258818e8a30252d744c23f2c2862643",+ "core_dirty": false,+ "contract_sha256": "3c2a9bb917338f78ae481cd9d2d5d294d2da4993e201186af2a7c6bedad82d1c"},"contract": {"mcp": {@@ -42,7 +42,7 @@},"serverInfo": {"name": "lalabase",- "version": "0.15.0"+ "version": "0.16.0"}}}@@ -689,6 +689,73 @@},"required": []}+ },+ {+ "name": "create_meeting",+ "description": "Creates a meeting with its transcript. Without project_id it lands in the inbox project of the organisation. Write the transcript as lines of \"Name: text\", the names as in participants; a participant may carry ref, the id from find_people. Returns the meeting without the transcript.",+ "inputSchema": {+ "$schema": "https://json-schema.org/draft/2020-12/schema",+ "type": "object",+ "properties": {+ "organisation_id": {+ "type": "string",+ "description": "UUID of the organisation (list_organisations names them)."+ },+ "project_id": {+ "type": "string",+ "description": "Optional. UUID of the project; without it the inbox project."+ },+ "title": {+ "type": "string",+ "description": "Meeting title (required)."+ },+ "occurred_at": {+ "type": "string",+ "description": "When it took place, ISO 8601 (required)."+ },+ "duration_minutes": {+ "type": "integer",+ "description": "Length in minutes."+ },+ "notes": {+ "type": "string",+ "description": "Notes."+ },+ "transcript": {+ "type": "string",+ "description": "Transcript, lines of \"Name: text\"."+ },+ "participants": {+ "type": "array",+ "description": "Who took part.",+ "items": {+ "type": "object",+ "properties": {+ "display_name": {+ "type": "string",+ "description": "Name as in the transcript."+ },+ "ref": {+ "type": "string",+ "description": "Optional. The id from find_people (person:<uuid>, member:<uuid>)."+ }+ },+ "required": [+ "display_name"+ ]+ }+ },+ "idempotency_key": {+ "type": "string",+ "description": "Optional. Repeating a write with the same key returns the original result instead of creating a duplicate. At most 255 bytes of valid UTF-8 without NUL."+ }+ },+ "required": [+ "organisation_id",+ "title",+ "occurred_at"+ ]+ }}]}@@ -3928,7 +3995,7 @@"content": [{"type": "text",- "text": "{\n \"data\": [\n {\n \"id\": \"00000000-0000-4000-8000-000000000035\",\n \"name\": \"Archiv\",\n \"description\": \"Nur lesen\",\n \"archived\": false,\n \"organisation\": {\n \"id\": \"00000000-0000-4000-8000-000000000001\",\n \"name\": \"Nordlicht GmbH\"\n },\n \"created_at\": \"2026-01-05T09:13:00Z\",\n \"updated_at\": \"2026-01-05T09:13:00Z\"\n },\n {\n \"id\": \"00000000-0000-4000-8000-000000000033\",\n \"name\": \"Handbuch\",\n \"description\": \"Nur Notizen\",\n \"archived\": false,\n \"organisation\": {\n \"id\": \"00000000-0000-4000-8000-000000000001\",\n \"name\": \"Nordlicht GmbH\"\n },\n \"created_at\": \"2026-01-05T09:12:00Z\",\n \"updated_at\": \"2026-01-05T09:12:00Z\"\n },\n {\n \"id\": \"00000000-0000-4000-8000-000000000032\",\n \"name\": \"Intern\",\n \"description\": \"Noch leer\",\n \"archived\": false,\n \"organisation\": {\n \"id\": \"00000000-0000-4000-8000-000000000001\",\n \"name\": \"Nordlicht GmbH\"\n },\n \"created_at\": \"2026-01-05T09:11:00Z\",\n \"updated_at\": \"2026-01-05T09:11:00Z\"\n },\n {\n \"id\": \"00000000-0000-4000-8000-000000000031\",\n \"name\": \"Website-Relaunch\",\n \"description\": \"Neue Website bis März\",\n \"archived\": false,\n \"organisation\": {\n \"id\": \"00000000-0000-4000-8000-000000000001\",\n \"name\": \"Nordlicht GmbH\"\n },\n \"created_at\": \"2026-01-05T09:10:00Z\",\n \"updated_at\": \"2026-01-05T09:10:00Z\"\n }\n ],\n \"meta\": {\n \"page\": 1,\n \"per_page\": 100,\n \"total\": 4\n }\n}"+ "text": "{\n \"data\": [\n {\n \"id\": \"00000000-0000-4000-8000-000000000035\",\n \"name\": \"Archiv\",\n \"description\": \"Nur lesen\",\n \"archived\": false,\n \"meeting_inbox\": false,\n \"organisation\": {\n \"id\": \"00000000-0000-4000-8000-000000000001\",\n \"name\": \"Nordlicht GmbH\"\n },\n \"created_at\": \"2026-01-05T09:13:00Z\",\n \"updated_at\": \"2026-01-05T09:13:00Z\"\n },\n {\n \"id\": \"00000000-0000-4000-8000-000000000033\",\n \"name\": \"Handbuch\",\n \"description\": \"Nur Notizen\",\n \"archived\": false,\n \"meeting_inbox\": false,\n \"organisation\": {\n \"id\": \"00000000-0000-4000-8000-000000000001\",\n \"name\": \"Nordlicht GmbH\"\n },\n \"created_at\": \"2026-01-05T09:12:00Z\",\n \"updated_at\": \"2026-01-05T09:12:00Z\"\n },\n {\n \"id\": \"00000000-0000-4000-8000-000000000032\",\n \"name\": \"Intern\",\n \"description\": \"Noch leer\",\n \"archived\": false,\n \"meeting_inbox\": false,\n \"organisation\": {\n \"id\": \"00000000-0000-4000-8000-000000000001\",\n \"name\": \"Nordlicht GmbH\"\n },\n \"created_at\": \"2026-01-05T09:11:00Z\",\n \"updated_at\": \"2026-01-05T09:11:00Z\"\n },\n {\n \"id\": \"00000000-0000-4000-8000-000000000031\",\n \"name\": \"Website-Relaunch\",\n \"description\": \"Neue Website bis März\",\n \"archived\": false,\n \"meeting_inbox\": false,\n \"organisation\": {\n \"id\": \"00000000-0000-4000-8000-000000000001\",\n \"name\": \"Nordlicht GmbH\"\n },\n \"created_at\": \"2026-01-05T09:10:00Z\",\n \"updated_at\": \"2026-01-05T09:10:00Z\"\n }\n ],\n \"meta\": {\n \"page\": 1,\n \"per_page\": 100,\n \"total\": 4\n }\n}"}],"isError": false,@@ -3962,7 +4029,7 @@"content": [{"type": "text",- "text": "{\n \"data\": [\n {\n \"id\": \"00000000-0000-4000-8000-000000000035\",\n \"name\": \"Archiv\",\n \"description\": \"Nur lesen\",\n \"archived\": false,\n \"organisation\": {\n \"id\": \"00000000-0000-4000-8000-000000000001\",\n \"name\": \"Nordlicht GmbH\"\n },\n \"created_at\": \"2026-01-05T09:13:00Z\",\n \"updated_at\": \"2026-01-05T09:13:00Z\"\n },\n {\n \"id\": \"00000000-0000-4000-8000-000000000033\",\n \"name\": \"Handbuch\",\n \"description\": \"Nur Notizen\",\n \"archived\": false,\n \"organisation\": {\n \"id\": \"00000000-0000-4000-8000-000000000001\",\n \"name\": \"Nordlicht GmbH\"\n },\n \"created_at\": \"2026-01-05T09:12:00Z\",\n \"updated_at\": \"2026-01-05T09:12:00Z\"\n }\n ],\n \"meta\": {\n \"page\": 1,\n \"per_page\": 2,\n \"total\": 4\n }\n}"+ "text": "{\n \"data\": [\n {\n \"id\": \"00000000-0000-4000-8000-000000000035\",\n \"name\": \"Archiv\",\n \"description\": \"Nur lesen\",\n \"archived\": false,\n \"meeting_inbox\": false,\n \"organisation\": {\n \"id\": \"00000000-0000-4000-8000-000000000001\",\n \"name\": \"Nordlicht GmbH\"\n },\n \"created_at\": \"2026-01-05T09:13:00Z\",\n \"updated_at\": \"2026-01-05T09:13:00Z\"\n },\n {\n \"id\": \"00000000-0000-4000-8000-000000000033\",\n \"name\": \"Handbuch\",\n \"description\": \"Nur Notizen\",\n \"archived\": false,\n \"meeting_inbox\": false,\n \"organisation\": {\n \"id\": \"00000000-0000-4000-8000-000000000001\",\n \"name\": \"Nordlicht GmbH\"\n },\n \"created_at\": \"2026-01-05T09:12:00Z\",\n \"updated_at\": \"2026-01-05T09:12:00Z\"\n }\n ],\n \"meta\": {\n \"page\": 1,\n \"per_page\": 2,\n \"total\": 4\n }\n}"}],"isError": false,@@ -3995,7 +4062,7 @@"content": [{"type": "text",- "text": "{\n \"data\": [\n {\n \"id\": \"00000000-0000-4000-8000-000000000035\",\n \"name\": \"Archiv\",\n \"description\": \"Nur lesen\",\n \"archived\": false,\n \"organisation\": {\n \"id\": \"00000000-0000-4000-8000-000000000001\",\n \"name\": \"Nordlicht GmbH\"\n },\n \"created_at\": \"2026-01-05T09:13:00Z\",\n \"updated_at\": \"2026-01-05T09:13:00Z\"\n },\n {\n \"id\": \"00000000-0000-4000-8000-000000000033\",\n \"name\": \"Handbuch\",\n \"description\": \"Nur Notizen\",\n \"archived\": false,\n \"organisation\": {\n \"id\": \"00000000-0000-4000-8000-000000000001\",\n \"name\": \"Nordlicht GmbH\"\n },\n \"created_at\": \"2026-01-05T09:12:00Z\",\n \"updated_at\": \"2026-01-05T09:12:00Z\"\n },\n {\n \"id\": \"00000000-0000-4000-8000-000000000032\",\n \"name\": \"Intern\",\n \"description\": \"Noch leer\",\n \"archived\": false,\n \"organisation\": {\n \"id\": \"00000000-0000-4000-8000-000000000001\",\n \"name\": \"Nordlicht GmbH\"\n },\n \"created_at\": \"2026-01-05T09:11:00Z\",\n \"updated_at\": \"2026-01-05T09:11:00Z\"\n },\n {\n \"id\": \"00000000-0000-4000-8000-000000000031\",\n \"name\": \"Website-Relaunch\",\n \"description\": \"Neue Website bis März\",\n \"archived\": false,\n \"organisation\": {\n \"id\": \"00000000-0000-4000-8000-000000000001\",\n \"name\": \"Nordlicht GmbH\"\n },\n \"created_at\": \"2026-01-05T09:10:00Z\",\n \"updated_at\": \"2026-01-05T09:10:00Z\"\n }\n ],\n \"meta\": {\n \"page\": 1,\n \"per_page\": 100,\n \"total\": 4\n }\n}"+ "text": "{\n \"data\": [\n {\n \"id\": \"00000000-0000-4000-8000-000000000035\",\n \"name\": \"Archiv\",\n \"description\": \"Nur lesen\",\n \"archived\": false,\n \"meeting_inbox\": false,\n \"organisation\": {\n \"id\": \"00000000-0000-4000-8000-000000000001\",\n \"name\": \"Nordlicht GmbH\"\n },\n \"created_at\": \"2026-01-05T09:13:00Z\",\n \"updated_at\": \"2026-01-05T09:13:00Z\"\n },\n {\n \"id\": \"00000000-0000-4000-8000-000000000033\",\n \"name\": \"Handbuch\",\n \"description\": \"Nur Notizen\",\n \"archived\": false,\n \"meeting_inbox\": false,\n \"organisation\": {\n \"id\": \"00000000-0000-4000-8000-000000000001\",\n \"name\": \"Nordlicht GmbH\"\n },\n \"created_at\": \"2026-01-05T09:12:00Z\",\n \"updated_at\": \"2026-01-05T09:12:00Z\"\n },\n {\n \"id\": \"00000000-0000-4000-8000-000000000032\",\n \"name\": \"Intern\",\n \"description\": \"Noch leer\",\n \"archived\": false,\n \"meeting_inbox\": false,\n \"organisation\": {\n \"id\": \"00000000-0000-4000-8000-000000000001\",\n \"name\": \"Nordlicht GmbH\"\n },\n \"created_at\": \"2026-01-05T09:11:00Z\",\n \"updated_at\": \"2026-01-05T09:11:00Z\"\n },\n {\n \"id\": \"00000000-0000-4000-8000-000000000031\",\n \"name\": \"Website-Relaunch\",\n \"description\": \"Neue Website bis März\",\n \"archived\": false,\n \"meeting_inbox\": false,\n \"organisation\": {\n \"id\": \"00000000-0000-4000-8000-000000000001\",\n \"name\": \"Nordlicht GmbH\"\n },\n \"created_at\": \"2026-01-05T09:10:00Z\",\n \"updated_at\": \"2026-01-05T09:10:00Z\"\n }\n ],\n \"meta\": {\n \"page\": 1,\n \"per_page\": 100,\n \"total\": 4\n }\n}"}],"isError": false,@@ -4105,6 +4172,149 @@}}}+ },+ "create_meeting": {+ "refused_no_inbox": {+ "token": "write",+ "request": {+ "jsonrpc": "2.0",+ "id": 1,+ "method": "tools/call",+ "params": {+ "name": "create_meeting",+ "arguments": {+ "organisation_id": "00000000-0000-4000-8000-000000000001",+ "title": "Abstimmung",+ "occurred_at": "2026-01-01T10:00:00Z"+ }+ }+ },+ "response": {+ "status": 200,+ "body": {+ "jsonrpc": "2.0",+ "id": 1,+ "result": {+ "content": [+ {+ "type": "text",+ "text": "Ohne Projekt braucht die Organisation ein Eingangsprojekt. Dort ist keines gesetzt."+ }+ ],+ "isError": true,+ "_meta": {+ "lalabase/code": "refused",+ "lalabase/reason": "meeting_inbox_missing"+ }+ }+ }+ }+ },+ "read_only": {+ "token": "read",+ "request": {+ "jsonrpc": "2.0",+ "id": 1,+ "method": "tools/call",+ "params": {+ "name": "create_meeting",+ "arguments": {+ "organisation_id": "00000000-0000-4000-8000-000000000001",+ "title": "Abstimmung",+ "occurred_at": "2026-01-01T10:00:00Z"+ }+ }+ },+ "response": {+ "status": 200,+ "body": {+ "jsonrpc": "2.0",+ "id": 1,+ "result": {+ "content": [+ {+ "type": "text",+ "text": "This token is read-only; writes are not permitted."+ }+ ],+ "isError": true,+ "_meta": {+ "lalabase/code": "read_only"+ }+ }+ }+ }+ },+ "invalid_input": {+ "token": "write",+ "request": {+ "jsonrpc": "2.0",+ "id": 1,+ "method": "tools/call",+ "params": {+ "name": "create_meeting",+ "arguments": {+ "organisation_id": "oops",+ "title": "Abstimmung",+ "occurred_at": "2026-01-01T10:00:00Z"+ }+ }+ },+ "response": {+ "status": 200,+ "body": {+ "jsonrpc": "2.0",+ "id": 1,+ "result": {+ "content": [+ {+ "type": "text",+ "text": "invalid organisation_id \"oops\" (expected a UUID)"+ }+ ],+ "isError": true,+ "_meta": {+ "lalabase/code": "invalid_input"+ }+ }+ }+ }+ },+ "not_found": {+ "token": "write",+ "request": {+ "jsonrpc": "2.0",+ "id": 1,+ "method": "tools/call",+ "params": {+ "name": "create_meeting",+ "arguments": {+ "organisation_id": "00000000-0000-4000-8000-000000000002",+ "title": "Abstimmung",+ "occurred_at": "2026-01-01T10:00:00Z"+ }+ }+ },+ "response": {+ "status": 200,+ "body": {+ "jsonrpc": "2.0",+ "id": 1,+ "result": {+ "content": [+ {+ "type": "text",+ "text": "organisation not found or not reachable with this token"+ }+ ],+ "isError": true,+ "_meta": {+ "lalabase/code": "not_found"+ }+ }+ }+ }+ }}}},@@ -4140,12 +4350,13 @@"all_projects": true}],- "api_version": "1.8.0",+ "api_version": "1.9.0","capabilities": ["error_codes","idempotency","knowledge.search","me.show",+ "meetings.create","notifications.archive","notifications.list","notifications.mark_all_as_read",@@ -4206,12 +4417,13 @@"all_projects": true}],- "api_version": "1.8.0",+ "api_version": "1.9.0","capabilities": ["error_codes","idempotency","knowledge.search","me.show",+ "meetings.create","notifications.archive","notifications.list","notifications.mark_all_as_read",@@ -4317,6 +4529,7 @@"name": "Archiv","description": "Nur lesen","archived": false,+ "meeting_inbox": false,"organisation": {"id": "00000000-0000-4000-8000-000000000001","name": "Nordlicht GmbH"@@ -4329,6 +4542,7 @@"name": "Handbuch","description": "Nur Notizen","archived": false,+ "meeting_inbox": false,"organisation": {"id": "00000000-0000-4000-8000-000000000001","name": "Nordlicht GmbH"@@ -4341,6 +4555,7 @@"name": "Intern","description": "Noch leer","archived": false,+ "meeting_inbox": false,"organisation": {"id": "00000000-0000-4000-8000-000000000001","name": "Nordlicht GmbH"@@ -4353,6 +4568,7 @@"name": "Website-Relaunch","description": "Neue Website bis März","archived": false,+ "meeting_inbox": false,"organisation": {"id": "00000000-0000-4000-8000-000000000001","name": "Nordlicht GmbH"@@ -4378,6 +4594,7 @@"name": "Archiv","description": "Nur lesen","archived": false,+ "meeting_inbox": false,"organisation": {"id": "00000000-0000-4000-8000-000000000001","name": "Nordlicht GmbH"@@ -4390,6 +4607,7 @@"name": "Handbuch","description": "Nur Notizen","archived": false,+ "meeting_inbox": false,"organisation": {"id": "00000000-0000-4000-8000-000000000001","name": "Nordlicht GmbH"@@ -4402,6 +4620,7 @@"name": "Intern","description": "Noch leer","archived": false,+ "meeting_inbox": false,"organisation": {"id": "00000000-0000-4000-8000-000000000001","name": "Nordlicht GmbH"@@ -4414,6 +4633,7 @@"name": "Website-Relaunch","description": "Neue Website bis März","archived": false,+ "meeting_inbox": false,"organisation": {"id": "00000000-0000-4000-8000-000000000001","name": "Nordlicht GmbH"diff --git a/spec/requests/api/mcp_create_meeting_spec.rb b/spec/requests/api/mcp_create_meeting_spec.rbnew file mode 100644index 0000000..bcb90d7--- /dev/null+++ b/spec/requests/api/mcp_create_meeting_spec.rb@@ -0,0 +1,102 @@+# frozen_string_literal: true++require 'rails_helper'++# What: create_meeting over POST /api/mcp, by the rule of POST /api/v1/organisations/:id/meetings+# (Meetings::Intake), token-scoped because the project may be missing.+# Why: the same refusals on both surfaces, or a program learns one rule and hits another;+# a token-scoped tool has no project gate, so the tool itself is the gate.+RSpec.describe 'MCP create_meeting', :ci_guard, type: :request do+ let(:organisation) { create(:organisation) }+ let(:user) { create(:user) }+ let(:role) { ActsAsTenant.with_tenant(organisation) { create(:role, organisation: organisation) } }+ let(:project) { ActsAsTenant.with_tenant(organisation) { create(:project, organisation: organisation) } }++ before do+ ActsAsTenant.with_tenant(organisation) do+ create(:membership, user: user, organisation: organisation, role: role, active: true)+ create(:project_permission, user: user, project: project, meetings_access: :read_write)+ end+ end++ def build_pat(read_only: false)+ build(:personal_access_token, user: user, organisations: [organisation], read_only: read_only).tap do |pat|+ pat.token_hash = nil+ pat.token_prefix = nil+ pat.generate_token!+ pat.save!+ end+ end++ def call_tool(arguments, token: build_pat)+ post '/api/mcp', params: { jsonrpc: '2.0', id: 1, method: 'tools/call',+ params: { name: 'create_meeting', arguments: arguments } }.to_json,+ headers: { 'Authorization' => "Bearer #{token.token}", 'Content-Type' => 'application/json' }+ response.parsed_body['result']+ end++ def args(**overrides)+ { organisation_id: organisation.id, title: 'Abstimmung', occurred_at: '2026-11-01T10:00:00+01:00',+ transcript: "Erika: Guten Tag.\n" }.merge(overrides)+ end++ def meeting_count = ActsAsTenant.with_tenant(organisation) { Meeting.count }++ it 'creates a meeting in the named project, without the transcript in the answer' do+ result = call_tool(args(project_id: project.id))++ expect(result['isError']).to be_falsey+ text = result['content'].first['text']+ expect(JSON.parse(text)).to include('project_id' => project.id)+ expect(text).not_to include('Guten Tag')+ expect(meeting_count).to eq(1)+ end++ it 'creates a meeting in the inbox without a project' do+ organisation.update!(meeting_inbox_project: project)++ result = call_tool(args)++ expect(JSON.parse(result['content'].first['text'])).to include('in_meeting_inbox' => true)+ end++ it 'names the refusal when there is no inbox' do+ result = call_tool(args)++ expect(result['isError']).to be(true)+ expect(result['_meta'].values).to include('refused', 'meeting_inbox_missing')+ expect(meeting_count).to eq(0)+ end++ it 'refuses without the write right' do+ ActsAsTenant.with_tenant(organisation) do+ ProjectPermission.find_by!(user: user, project: project).update!(meetings_access: :read_only)+ end++ result = call_tool(args(project_id: project.id))++ expect(result['isError']).to be(true)+ expect(meeting_count).to eq(0)+ end++ it 'refuses an organisation outside the token' do+ result = call_tool(args(organisation_id: create(:organisation).id))++ expect(result['isError']).to be(true)+ expect(result['_meta'].values).to include('not_found')+ end++ it 'refuses a read-only token' do+ result = call_tool(args(project_id: project.id), token: build_pat(read_only: true))++ expect(result['isError']).to be(true)+ expect(meeting_count).to eq(0)+ end++ it 'creates one meeting for a repeated key' do+ token = build_pat+ 2.times { call_tool(args(project_id: project.id, idempotency_key: 'aufnahme-1'), token: token) }++ expect(meeting_count).to eq(1)+ end+enddiff --git a/spec/requests/api/mcp_idempotency_key_bound_spec.rb b/spec/requests/api/mcp_idempotency_key_bound_spec.rbindex a05142a..1b10e1b 100644--- a/spec/requests/api/mcp_idempotency_key_bound_spec.rb+++ b/spec/requests/api/mcp_idempotency_key_bound_spec.rb@@ -37,7 +37,7 @@ RSpec.describe 'MCP writes and an idempotency_key the store cannot hold', :ci_gulet!(:project_permission) doActsAsTenant.with_tenant(organisation) do- create(:project_permission, user: user, project: project, tickets_access: :read_write)+ create(:project_permission, user: user, project: project, tickets_access: :read_write, meetings_access: :read_write)endend@@ -88,7 +88,9 @@ RSpec.describe 'MCP writes and an idempotency_key the store cannot hold', :ci_gu-> { TimeSession.count }],'mark_notification_read' => [{ notification_id: notification.id }, -> { notification.reload.state }],'update_ticket' => [{ project_id: project.id, ticket_id: ticket.id, title: 'Neuer Titel' },- -> { ticket.reload.title }]+ -> { ticket.reload.title }],+ 'create_meeting' => [{ organisation_id: project.organisation_id, project_id: project.id, title: 'Abstimmung',+ occurred_at: '2026-11-01T10:00:00+01:00' }, -> { Meeting.count }]}enddiff --git a/spec/requests/api/mcp_list_projects_spec.rb b/spec/requests/api/mcp_list_projects_spec.rbindex d5d36f6..7d8ee2b 100644--- a/spec/requests/api/mcp_list_projects_spec.rb+++ b/spec/requests/api/mcp_list_projects_spec.rb@@ -57,13 +57,13 @@ RSpec.describe 'MCP list_organisations and list_projects', :ci_guard, type: :reqenddescribe 'tools/list' do- it 'offers both as the last tools, so the order of every tool before them holds' do+ it 'offers both after the pinned tools, so the order of every tool before them holds' dopat = token_for(organisations: [organisation])post '/api/mcp', params: { jsonrpc: '2.0', id: 1, method: 'tools/list' }.to_json,headers: { 'Authorization' => "Bearer #{pat.token}", 'CONTENT_TYPE' => 'application/json' }- expect(response.parsed_body.dig('result', 'tools').pluck('name').last(2))- .to eq(%w[list_organisations list_projects])+ expect(response.parsed_body.dig('result', 'tools').pluck('name').last(3))+ .to eq(%w[list_organisations list_projects create_meeting])endit 'points the project_id of a project tool at list_projects' dodiff --git a/spec/requests/api/mcp_people_spec.rb b/spec/requests/api/mcp_people_spec.rbindex e7ac446..a0ff46f 100644--- a/spec/requests/api/mcp_people_spec.rb+++ b/spec/requests/api/mcp_people_spec.rb@@ -117,7 +117,7 @@ RSpec.describe 'MCP people tools', :ci_guard, type: :request doget_ticket search_knowledge create_ticket post_commentlist_notifications create_time_session mark_notification_readupdate_ticket summarize_time_sessions find_people get_person- list_organisations list_projects+ list_organisations list_projects create_meeting])enddiff --git a/spec/requests/api/v1/capabilities_spec.rb b/spec/requests/api/v1/capabilities_spec.rbindex 88d9f56..a150e88 100644--- a/spec/requests/api/v1/capabilities_spec.rb+++ b/spec/requests/api/v1/capabilities_spec.rb@@ -33,7 +33,7 @@ RSpec.describe 'API V1 capabilities', :ci_guard, type: :request doit 'names the API version and the capabilities beside the existing fields' dodata = me(token(read_only: false))- expect(data['api_version']).to eq('1.8.0')+ expect(data['api_version']).to eq('1.9.0')expect(data['capabilities']).to eq(Api::V1::Capabilities.names)expect(data.keys).to include('user', 'token', 'scoped_organisations')end@@ -47,7 +47,7 @@ RSpec.describe 'API V1 capabilities', :ci_guard, type: :request do'me.show', 'organisations.list', 'projects.list', 'tickets.list', 'tickets.create', 'tickets.show','tickets.update', 'tickets.attachments', 'posts.create', 'time_sessions.create','notifications.list', 'notifications.mark_as_read', 'people.list', 'people.show', 'idempotency', 'error_codes',- 'tickets.by_number', 'posts.show', 'tickets.paging', 'time_sessions.book', 'posts.plain', 'knowledge.search',+ 'meetings.create', 'tickets.by_number', 'posts.show', 'tickets.paging', 'time_sessions.book', 'posts.plain', 'knowledge.search','tickets.changes')enddiff --git a/spec/requests/api/v1/meetings_spec.rb b/spec/requests/api/v1/meetings_spec.rbnew file mode 100644index 0000000..3a83c3d--- /dev/null+++ b/spec/requests/api/v1/meetings_spec.rb@@ -0,0 +1,336 @@+# frozen_string_literal: true++require 'rails_helper'++# What: POST /api/v1/organisations/:organisation_id/meetings: a program creates a meeting+# with a transcript, in a named project or, without one, in the organisation's inbox.+# Why: this is the write the recording app sends after a call. It must land in the right+# place, keep every door shut that the web form keeps shut, and a retry after a dropped+# connection must not create a second meeting. A refused meeting writes nothing, and the+# transcript stays out of the stored answer, or it would outlive the meeting.+RSpec.describe 'API V1 Meetings', :ci_guard, type: :request do+ let(:organisation) { create(:organisation) }+ let(:user) { create(:user) }+ let(:role) do+ ActsAsTenant.with_tenant(organisation) do+ create(:role, organisation: organisation).tap do |role|+ create(:permission, role: role, category: 'people', action: 'view_people', allowed: true)+ end+ end+ end+ let(:project) { in_org { create(:project, organisation: organisation) } }+ let(:inbox) { in_org { create(:project, organisation: organisation) } }+ let(:contact) { in_org { create(:person, organisation: organisation, name: 'Erika Beispiel') } }++ before do+ in_org do+ create(:membership, user: user, organisation: organisation, role: role, active: true)+ [project, inbox].each { |target| grant(target) }+ end+ end++ def in_org(&) = ActsAsTenant.with_tenant(organisation, &)++ def grant(target, access: :read_write)+ create(:project_permission, user: user, project: target, meetings_access: access)+ end++ def build_pat(read_only: false, **scope)+ build(:personal_access_token, user: user, read_only: read_only, **scope).tap do |pat|+ pat.token_hash = nil+ pat.token_prefix = nil+ pat.generate_token!+ pat.save!+ end+ end++ let(:pat) { build_pat(organisations: [organisation]) }++ def body(**overrides)+ { title: 'Abstimmung', occurred_at: '2026-11-01T10:00:00+01:00', duration_minutes: 30,+ transcript: "Erika Beispiel: Guten Tag.\n" }.merge(overrides)+ end++ def send_meeting(fields = body, token: pat, headers: {}, org: organisation)+ post "/api/v1/organisations/#{org.id}/meetings", params: { meeting: fields }.to_json,+ headers: { 'Authorization' => "Bearer #{token.token}",+ 'Content-Type' => 'application/json' }.merge(headers)+ end++ def meeting_count = in_org { Meeting.count }++ def json = response.parsed_body++ describe 'where it lands' do+ it 'writes into the named project and answers without the transcript' do+ send_meeting(body(project_id: project.id))++ expect(response).to have_http_status(:created)+ meeting = in_org { Meeting.find(json.dig('data', 'id')) }+ expect(meeting.project_id).to eq(project.id)+ expect(meeting.creator).to eq(user)+ expect(meeting.transcript).to include('Guten Tag')+ expect(meeting.create_embeddings).to be(false)+ expect(json['data']).to include('project_id' => project.id, 'in_meeting_inbox' => false, 'title' => 'Abstimmung')+ expect(json['data']['path']).to end_with("/meetings/#{meeting.id}")+ expect(response.body).not_to include('Guten Tag')+ end++ it 'writes into the inbox without a project' do+ organisation.update!(meeting_inbox_project: inbox)++ send_meeting++ expect(response).to have_http_status(:created)+ expect(json['data']).to include('project_id' => inbox.id, 'in_meeting_inbox' => true)+ end++ it 'records the activity the web form records' do+ expect { send_meeting(body(project_id: project.id)) }.to(change { in_org { Activity.count } })+ end++ it 'refuses without a project when no inbox is set' do+ send_meeting++ expect(response).to have_http_status(:unprocessable_content)+ expect(json).to include('error' => 'meeting_inbox_missing', 'code' => 'refused', 'reason' => 'meeting_inbox_missing')+ expect(meeting_count).to eq(0)+ end++ it 'treats an archived inbox as none' do+ organisation.update!(meeting_inbox_project: inbox)+ in_org { inbox.archive!(user) }++ send_meeting++ expect(json['reason']).to eq('meeting_inbox_missing')+ end++ it 'says so when the inbox is out of the writer\'s rights' do+ organisation.update!(meeting_inbox_project: inbox)+ in_org { ProjectPermission.find_by!(user: user, project: inbox).update!(meetings_access: :read_only) }++ send_meeting++ expect(response).to have_http_status(:forbidden)+ expect(json).to include('code' => 'forbidden', 'reason' => 'meeting_inbox_forbidden')+ expect(meeting_count).to eq(0)+ end++ it 'says so when the inbox is out of the token\'s reach' do+ organisation.update!(meeting_inbox_project: inbox)+ token = build_pat(organisations: [organisation], project_scopes: { organisation => [project] })++ send_meeting(body, token: token)++ expect(response).to have_http_status(:forbidden)+ expect(json['reason']).to eq('meeting_inbox_forbidden')+ end+ end++ describe 'the doors' do+ it 'refuses a read-only token' do+ send_meeting(body(project_id: project.id), token: build_pat(read_only: true, organisations: [organisation]))++ expect(response).to have_http_status(:forbidden)+ expect(json['code']).to eq('read_only')+ expect(meeting_count).to eq(0)+ end++ it 'answers 404 for an organisation outside the token' do+ send_meeting(body, org: create(:organisation))++ expect(response).to have_http_status(:not_found)+ end++ it 'answers 404 for a project of another organisation' do+ other = create(:organisation)+ foreign = ActsAsTenant.with_tenant(other) { create(:project, organisation: other) }++ send_meeting(body(project_id: foreign.id))++ expect(response).to have_http_status(:not_found)+ end++ it 'answers 404 for a project outside the token' do+ token = build_pat(organisations: [organisation], project_scopes: { organisation => [inbox] })++ send_meeting(body(project_id: project.id), token: token)++ expect(response).to have_http_status(:not_found)+ end++ it 'answers 404 for a malformed project id' do+ send_meeting(body(project_id: 'kein-projekt'))++ expect(response).to have_http_status(:not_found)+ end++ it 'answers 403 without the write right on a named project' do+ in_org { ProjectPermission.find_by!(user: user, project: project).update!(meetings_access: :read_only) }++ send_meeting(body(project_id: project.id))++ expect(response).to have_http_status(:forbidden)+ expect(meeting_count).to eq(0)+ end++ it 'keeps an account admin out of an archived project' do+ in_org do+ Membership.find_by!(user: user).update!(role: create(:role, organisation: organisation, title: 'account_admin'))+ project.archive!(user)+ end++ send_meeting(body(project_id: project.id))++ expect(json).to include('code' => 'refused', 'reason' => 'project_archived')+ expect(meeting_count).to eq(0)+ end+ end++ describe 'the input' do+ it 'refuses a meeting without a title or date' do+ send_meeting({ project_id: project.id, transcript: 'Text' })++ expect(response).to have_http_status(:unprocessable_content)+ expect(json['code']).to eq('invalid_input')+ expect(meeting_count).to eq(0)+ end++ it 'answers bad_request without a meeting object' do+ post "/api/v1/organisations/#{organisation.id}/meetings",+ params: { meeting: 'text' }.to_json,+ headers: { 'Authorization' => "Bearer #{pat.token}", 'Content-Type' => 'application/json' }++ expect(response).to have_http_status(:bad_request)+ end++ it 'takes a transcript just under the limit and refuses one above it' do+ fill = 'x' * (Meeting::MAX_CONTENT_BYTES - 1)+ send_meeting(body(project_id: project.id, transcript: fill))+ expect(response).to have_http_status(:created)++ send_meeting(body(project_id: project.id, transcript: "#{fill}xx"))+ expect(response).to have_http_status(:unprocessable_content)+ end+ end++ describe 'the participants' do+ def participants_of(id) = in_org { MeetingParticipant.where(meeting_id: id).order(:display_name).to_a }++ it 'keeps a name without a ref as an external participant' do+ send_meeting(body(project_id: project.id, participants: [{ display_name: 'Max Muster' }]))++ row = participants_of(json.dig('data', 'id')).first+ expect(row).to have_attributes(display_name: 'Max Muster', user_id: nil, person_id: nil)+ end++ it 'links a contact and a member by the ids of the people list' do+ send_meeting(body(project_id: project.id, participants: [+ { display_name: 'Erika Beispiel', ref: "person:#{contact.id}" },+ { display_name: 'Ich Selbst', ref: "member:#{user.id}" }+ ]))++ expect(response).to have_http_status(:created)+ erika, ich = participants_of(json.dig('data', 'id'))+ expect(erika).to have_attributes(person_id: contact.id, user_id: nil)+ expect(ich).to have_attributes(user_id: user.id, person_id: nil)+ end++ it 'refuses the whole meeting for a ref that does not resolve' do+ other = create(:organisation)+ foreign = ActsAsTenant.with_tenant(other) { create(:person, organisation: other) }++ ["person:#{foreign.id}", 'quatsch'].each do |ref|+ send_meeting(body(project_id: project.id, participants: [{ display_name: 'Wer', ref: ref }]))++ expect(response).to have_http_status(:unprocessable_content)+ expect(json).to include('code' => 'invalid_input', 'reason' => 'unknown_participant')+ end+ expect(meeting_count).to eq(0)+ end++ it 'refuses a ref without the people right' do+ in_org { Permission.where(role: role, action: 'view_people').delete_all }++ send_meeting(body(project_id: project.id, participants: [{ display_name: 'Erika', ref: "person:#{contact.id}" }]))++ expect(json['reason']).to eq('unknown_participant')+ expect(meeting_count).to eq(0)+ end++ it 'refuses a ref with a token limited to some projects, a plain name still goes' do+ token = build_pat(organisations: [organisation], project_scopes: { organisation => [project] })++ send_meeting(body(project_id: project.id, participants: [{ display_name: 'Erika', ref: "person:#{contact.id}" }]), token: token)+ expect(json['reason']).to eq('unknown_participant')++ send_meeting(body(project_id: project.id, participants: [{ display_name: 'Erika' }]), token: token)+ expect(response).to have_http_status(:created)+ end++ it 'refuses participants that are no list of objects' do+ send_meeting(body(project_id: project.id, participants: 'Erika'))++ expect(json['reason']).to eq('unknown_participant')+ expect(meeting_count).to eq(0)+ end++ it 'refuses a name given twice' do+ send_meeting(body(project_id: project.id, participants: [{ display_name: 'Erika' }, { display_name: 'erika' }]))++ expect(response).to have_http_status(:unprocessable_content)+ expect(meeting_count).to eq(0)+ end+ end++ describe 'a retry' do+ let(:key) { { 'Idempotency-Key' => 'aufnahme-1' } }++ it 'creates one meeting and answers the first answer again' do+ send_meeting(body(project_id: project.id), headers: key)+ first = response.body++ send_meeting(body(project_id: project.id), headers: key)++ expect(response).to have_http_status(:created)+ expect(response.body).to eq(first)+ expect(meeting_count).to eq(1)+ end++ it 'refuses the same key with another content' do+ send_meeting(body(project_id: project.id), headers: key)+ send_meeting(body(project_id: project.id, title: 'Anders'), headers: key)++ expect(json['error']).to eq('idempotency_key_reused')+ expect(meeting_count).to eq(1)+ end++ it 'leaves the key free after a refusal' do+ send_meeting(body, headers: key)+ expect(response).to have_http_status(:unprocessable_content)++ send_meeting(body(project_id: project.id), headers: key)+ expect(response).to have_http_status(:created)+ end++ it 'stores no transcript with the key' do+ send_meeting(body(project_id: project.id), headers: key)++ stored = McpIdempotencyKey.find_by!(idempotency_key: 'aufnahme-1')+ expect(stored.response_content).not_to include('Guten Tag')+ expect(stored.request_fingerprint).not_to include('Guten Tag')+ end+ end++ describe 'the project list' do+ it 'names the inbox' do+ organisation.update!(meeting_inbox_project: inbox)++ get '/api/v1/projects', headers: { 'Authorization' => "Bearer #{pat.token}" }++ flags = json['data'].to_h { |row| [row['id'], row['meeting_inbox']] }+ expect(flags).to include(inbox.id => true, project.id => false)+ end+ end+enddiff --git a/spec/requests/api/v1/write_endpoints_spec.rb b/spec/requests/api/v1/write_endpoints_spec.rbindex 0b0ae06..f7cb799 100644--- a/spec/requests/api/v1/write_endpoints_spec.rb+++ b/spec/requests/api/v1/write_endpoints_spec.rb@@ -19,7 +19,7 @@ RSpec.describe 'API V1 Write Endpoints', :ci_guard, type: :request dolet!(:project_permission) doActsAsTenant.with_tenant(organisation) do- create(:project_permission, user: user, project: project, tickets_access: :read_write)+ create(:project_permission, user: user, project: project, tickets_access: :read_write, meetings_access: :read_write)endend@@ -678,9 +678,11 @@ RSpec.describe 'API V1 Write Endpoints', :ci_guard, type: :request dodef request_write(verb, path_spec, controller)record_id = controller == 'api/v1/notifications' ? notification.id : ticket.id- path = path_spec.gsub(':project_id', project.id).gsub(':ticket_id', ticket.id).gsub(':id', record_id)+ path = path_spec.gsub(':organisation_id', organisation.id).gsub(':project_id', project.id)+ .gsub(':ticket_id', ticket.id).gsub(':id', record_id)params = { ticket: { title: 'Written anyway' }, post: { body: 'Written anyway' }, change: { title: 'Written anyway' },- time_session: { occurred_on: '2026-05-20T10:00:00Z', duration_minutes: 30 } }+ time_session: { occurred_on: '2026-05-20T10:00:00Z', duration_minutes: 30 },+ meeting: { project_id: project.id, title: 'Written anyway', occurred_at: '2026-05-20T10:00:00Z' } }process verb.downcase.to_sym, path, params: params, headers: auth_headersenddiff --git a/spec/services/actors/save_meeting_spec.rb b/spec/services/actors/save_meeting_spec.rbindex d704f07..23d8cf0 100644--- a/spec/services/actors/save_meeting_spec.rb+++ b/spec/services/actors/save_meeting_spec.rb@@ -223,6 +223,26 @@ RSpec.describe Actors::SaveMeeting dodescribe 'person link (person_id)' dolet(:person) { create(:person, organisation: organisation, name: 'Karl Krause') }+ it 'sets a link a caller resolved, by the normalized name' do+ result = described_class.call(+ project: project, current_user: user,+ params: valid_params.merge(participants: [{ display_name: 'Karl Krause' }, { display_name: 'Anna Ananas' }]),+ participant_links: { MeetingParticipant.normalize_name('Karl Krause') => person.id }+ )++ expect(result.resource.meeting_participants.find_by(display_name: 'Karl Krause').person_id).to eq(person.id)+ expect(result.resource.meeting_participants.find_by(display_name: 'Anna Ananas').person_id).to be_nil+ end++ it 'never takes a person_id from the payload' do+ result = described_class.call(+ project: project, current_user: user,+ params: valid_params.merge(participants: [{ display_name: 'Karl Krause', person_id: person.id }])+ )++ expect(result.resource.meeting_participants.first.person_id).to be_nil+ end+# The meeting is created through the actor; the link is set directly, as the# link dialog (a separate writer) will.def meeting_with(*names)diff --git a/spec/services/lalabase/tools/registry_spec.rb b/spec/services/lalabase/tools/registry_spec.rbindex ab8766a..3ee3532 100644--- a/spec/services/lalabase/tools/registry_spec.rb+++ b/spec/services/lalabase/tools/registry_spec.rb@@ -94,11 +94,12 @@ RSpec.describe Lalabase::Tools::Registry doend# Terminal client S6 (the booked time of a ticket), then People S3b, then the two lists an- # agent finds its ids with: each appended LAST, so the pinned wire order of every tool- # before them stays intact.- it 'offers the time report, the people twins and the two id lists as the last tools on :mcp (wire order pinned)' do- expect(described_class.for(:mcp).last(5)).to eq(- [t::SummarizeTimeSessions, t::McpFindPeople, t::McpGetPerson, t::ListOrganisations, t::ListProjects]+ # agent finds its ids with, then create_meeting: each appended LAST, so the pinned wire+ # order of every tool before them stays intact.+ it 'offers the time report, the people twins, the two id lists and create_meeting last on :mcp (wire order pinned)' do+ expect(described_class.for(:mcp).last(6)).to eq(+ [t::SummarizeTimeSessions, t::McpFindPeople, t::McpGetPerson, t::ListOrganisations, t::ListProjects,+ t::CreateMeeting])end@@ -117,7 +118,7 @@ RSpec.describe Lalabase::Tools::Registry dot::GetCapabilityDetails, t::GetSymbolDetails, t::ListTickets,t::GetTicket, t::SearchKnowledge, t::CreateTicket, t::PostComment, t::ListNotifications,t::CreateTimeSession, t::MarkNotificationRead, t::UpdateTicket, t::SummarizeTimeSessions,- t::McpFindPeople, t::McpGetPerson, t::ListOrganisations, t::ListProjects+ t::McpFindPeople, t::McpGetPerson, t::ListOrganisations, t::ListProjects, t::CreateMeeting)end@@ -171,7 +172,7 @@ RSpec.describe Lalabase::Tools::Registry doit ':mcp is the only set permitted to carry mutating tools (contrast)' doexpect(described_class.for(:mcp).select(&:mutating?)).to contain_exactly(t::CreateTicket, t::PostComment, t::CreateTimeSession, t::MarkNotificationRead,- t::UpdateTicket)+ t::UpdateTicket, t::CreateMeeting)endend@@ -223,7 +224,7 @@ RSpec.describe Lalabase::Tools::Registry doget_ticket search_knowledge create_ticket post_commentlist_notifications create_time_session mark_notification_readupdate_ticket summarize_time_sessions find_people get_person- list_organisations list_projects+ list_organisations list_projects create_meeting]enddiff --git a/spec/services/personal_access_tokens/reach_listing_spec.rb b/spec/services/personal_access_tokens/reach_listing_spec.rbindex 8a0a4be..d4a8bd4 100644--- a/spec/services/personal_access_tokens/reach_listing_spec.rb+++ b/spec/services/personal_access_tokens/reach_listing_spec.rb@@ -84,7 +84,7 @@ RSpec.describe PersonalAccessTokens::ReachListing, :ci_guard dotoken = create(:personal_access_token, user: user, organisations: [other_organisation])expect(listing(token).projects(viewer: user)).to eq(- [{ id: foreign.id, name: 'Foreign', description: foreign.description, archived: false,+ [{ id: foreign.id, name: 'Foreign', description: foreign.description, archived: false, meeting_inbox: false,organisation: { id: other_organisation.id, name: 'Alpha' },created_at: foreign.created_at.iso8601, updated_at: foreign.updated_at.iso8601 }])