Skip to content

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.

Hold the analysis push and the summary start to the meeting's current project

Guido Boyke4759aac2455e
diff --git a/CLAUDE.md b/CLAUDE.md
index dbeb83e..7370584 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -220,9 +220,12 @@ from this project": refuse, or answer as if it were not found.
actors that lock and then authorize again, under the lock, in the project the meeting is in
now (`AcceptTicketSuggestion`, `StartTicketSuggestionRun`). It only shrinks, and every entry
gives its reason.
-* `WRITERS` pins the six writes that exist: the move, the edit, the delete, the ticket link,
- the analysis publication and the booking. Three review rounds of the move found each of
- them landing in the old project after a move.
+* `WRITERS` pins the files of the seven writes that exist: the move, the edit, the delete, the
+ ticket link, the analysis publication, the booking and the start of a summary. Four review
+ rounds of the move found each of them landing in the old project after a move.
+* ⚠️ **The guard checks files, not actions.** A second write in a listed file passes as soon
+ as one other write there takes the lock: `create_summary` sat next to the delete without
+ it until a fourth review round.
* ⚠️ **Not seen: a new write that takes no lock at all.** Writing a meeting's data (its
project, links, analyses, bookings) means calling the helper; the guard cannot know that a
file it has never heard of should.
diff --git a/app/controllers/organisations/meetings_controller.rb b/app/controllers/organisations/meetings_controller.rb
index 093141c..a7b28e0 100644
--- a/app/controllers/organisations/meetings_controller.rb
+++ b/app/controllers/organisations/meetings_controller.rb
@@ -230,7 +230,13 @@ module Organisations
# Pending flag → the section shows "wird erstellt…"; the job clears it on
# completion and the after_update_commit broadcast pushes the final state.
- @meeting.update!(summary_creation_flag: true, summary_creation_error: '')
+ # Under the meeting's lock: a meeting that moved meanwhile is gone from
+ # here, and its summary is not started from a project it left.
+ Meeting.transaction do
+ raise ActiveRecord::RecordNotFound unless @meeting.lock_in_project!(@project.id)
+
+ @meeting.update!(summary_creation_flag: true, summary_creation_error: '')
+ end
Meetings::SummaryJob.perform_later(meeting_id: @meeting.id)
respond_to do |format|
diff --git a/app/models/meeting_analysis.rb b/app/models/meeting_analysis.rb
index fb64510..137a8fa 100644
--- a/app/models/meeting_analysis.rb
+++ b/app/models/meeting_analysis.rb
@@ -166,7 +166,13 @@ class MeetingAnalysis < ApplicationRecord
recipient = User.find_by(id: creator_id)
return unless recipient
- project_policy = ProjectPolicy.new(recipient, meeting.project)
+ # The meeting as stored, not the job's copy: a move (Actors::MoveMeeting)
+ # may have committed while the model answered, and the creator's page in
+ # the old project must not hear of it unless they read the new one.
+ current_meeting = reload_meeting
+ return unless current_meeting
+
+ project_policy = ProjectPolicy.new(recipient, current_meeting.project)
return unless project_policy.area_access?(:meetings, :read)
# Only replace the stored-results list. The request-rendered assistant entry
@@ -176,10 +182,10 @@ class MeetingAnalysis < ApplicationRecord
# organisation: a job has no assistant_available? helper, and a retry button
# for someone the gate excludes would only ever answer 403.
broadcast_replace_to(
- meeting, recipient, :analyses,
- target: ActionView::RecordIdentifier.dom_id(meeting, :analyses_list),
+ current_meeting, recipient, :analyses,
+ target: ActionView::RecordIdentifier.dom_id(current_meeting, :analyses_list),
partial: 'organisations/meetings/analyses_list',
- locals: { meeting: meeting, analyses: self.class.visible_for(meeting, recipient),
+ locals: { meeting: current_meeting, analyses: self.class.visible_for(current_meeting, recipient),
can_write: project_policy.area_access?(:meetings, :write),
can_rerun: ChatPolicy.assistant_gate_open?(recipient, organisation) }
)
diff --git a/spec/models/meeting_analysis_spec.rb b/spec/models/meeting_analysis_spec.rb
index 47201af..5002329 100644
--- a/spec/models/meeting_analysis_spec.rb
+++ b/spec/models/meeting_analysis_spec.rb
@@ -178,6 +178,33 @@ RSpec.describe MeetingAnalysis do
analysis.update!(creation_flag: false, creation_error: 'kaputt')
end
+
+ # A job loads the analysis and its meeting, a move commits (Actors::MoveMeeting)
+ # while the model answers, the job finishes on its stale copy. The creator
+ # reads meetings only in the old project and gets nothing pushed.
+ it 'pushes nothing once the meeting is in a project the creator cannot read' do
+ analysis = create(:meeting_analysis, meeting: meeting, creator: creator, creation_flag: true)
+ stale = described_class.find(analysis.id)
+ stale.meeting.project
+ elsewhere = create(:project, organisation: organisation)
+ Meeting.where(id: meeting.id).update_all(project_id: elsewhere.id)
+
+ expect(stale).not_to receive(:broadcast_replace_to)
+ stale.update!(creation_flag: false, content: 'Ergebnis nach dem Umzug')
+ end
+
+ it 'still pushes to a creator who reads meetings in the new project' do
+ analysis = create(:meeting_analysis, meeting: meeting, creator: creator, creation_flag: true)
+ stale = described_class.find(analysis.id)
+ stale.meeting.project
+ elsewhere = create(:project, organisation: organisation)
+ create(:project_permission, user: creator, project: elsewhere, meetings_access: 'read_only')
+ Meeting.where(id: meeting.id).update_all(project_id: elsewhere.id)
+
+ expect(stale).to receive(:broadcast_replace_to).with(meeting, creator, :analyses,
+ hash_including(locals: hash_including(can_write: false)))
+ stale.update!(creation_flag: false, content: 'Ergebnis nach dem Umzug')
+ end
end
# Standalone destroy purge (embedding v2 PR 2, Delete-Matrix §3.5 row 7): destroying
diff --git a/spec/requests/organisations/meeting_move_spec.rb b/spec/requests/organisations/meeting_move_spec.rb
index 5e50101..1b87f33 100644
--- a/spec/requests/organisations/meeting_move_spec.rb
+++ b/spec/requests/organisations/meeting_move_spec.rb
@@ -190,6 +190,24 @@ RSpec.describe 'Organisations::Meetings move', :ci_guard, type: :request do
expect(ActsAsTenant.without_tenant { Meeting.exists?(meeting.id) }).to be(true)
end
+ # The move commits during the last check before the write. The summary
+ # would start in a project where this writer has no rights.
+ it 'does not start a summary on a meeting that moved away after the start was authorized' do
+ writer = member(move: false, access: { source => 'read_write' })
+ ActsAsTenant.with_tenant(organisation) { meeting.update!(transcript: 'Kunde will Feature X bis Q3.') }
+ allow_any_instance_of(Organisation).to receive(:has_valid_ai_configuration?) do
+ Meeting.where(id: meeting.id).update_all(project_id: target.id)
+ true
+ end
+ allow(Meetings::SummaryJob).to receive(:perform_later)
+ sign_in writer
+ post create_summary_organisation_project_meeting_path(organisation, source, meeting)
+
+ expect(response).to have_http_status(:not_found)
+ expect(Meetings::SummaryJob).not_to have_received(:perform_later)
+ expect(ActsAsTenant.without_tenant { meeting.reload.summary_creation_flag }).to be(false)
+ end
+
context 'with a target the move refuses' do
def expect_refused(target_id, message)
sign_in mover