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
fix: review round 2 of #94, pin a grant in each area and the float bound
Guido Boykedfed8250bcac
diff --git a/spec/services/lalabase/tools/list_projects_spec.rb b/spec/services/lalabase/tools/list_projects_spec.rbindex ff200cb..fda8cb0 100644--- a/spec/services/lalabase/tools/list_projects_spec.rb+++ b/spec/services/lalabase/tools/list_projects_spec.rb@@ -157,6 +157,11 @@ RSpec.describe Lalabase::Tools::ListProjects doexpect(call(per_page: 2.5).code).to eq(:invalid_input)end+ it 'answers invalid_input for a number with no whole value, instead of raising' do+ expect(call(page: Float::INFINITY).code).to eq(:invalid_input)+ expect(call(per_page: Float::NAN).code).to eq(:invalid_input)+ end+it 'answers invalid_input for a page or per_page below one' doexpect(call(page: 0).code).to eq(:invalid_input)expect(call(per_page: 0).code).to eq(:invalid_input)diff --git a/spec/services/personal_access_tokens/reach_listing_spec.rb b/spec/services/personal_access_tokens/reach_listing_spec.rbindex 8614e3c..8a0a4be 100644--- a/spec/services/personal_access_tokens/reach_listing_spec.rb+++ b/spec/services/personal_access_tokens/reach_listing_spec.rb@@ -172,6 +172,29 @@ RSpec.describe PersonalAccessTokens::ReachListing, :ci_guard doendend+ # members has no role key at all: a grant is the only way in through that area.+ ProjectPermission.access_areas.each do |area|+ it "lists a project opened by a grant in #{area} alone" do+ project+ ActsAsTenant.with_tenant(organisation) do+ create(:membership, user: stranger, organisation: organisation, role: create(:role, organisation: organisation),+ active: true)+ levels = ProjectPermission.access_areas.to_h do |name|+ [:"#{name}_access", name == area ? :read_only : :no_access]+ end+ create(:project_permission, user: stranger, project: project, **levels)+ end++ listed = listing(token).projects(viewer: stranger, openable_only: true).pluck(:id)+ opens = ActsAsTenant.with_tenant(organisation) do+ AccessCheck::ProjectAccessService.can_access_project?(stranger, project)+ end++ expect(opens).to be true+ expect(listed).to eq([project.id])+ end+ end+it 'leaves out a project only time tracking reaches, which the gate refuses' doActsAsTenant.with_tenant(organisation) { project && member_with('read_access_time_tracking_all_projects') }diff --git a/spec/support/prosopite.rb b/spec/support/prosopite.rbindex 98ec45f..d50756b 100644--- a/spec/support/prosopite.rb+++ b/spec/support/prosopite.rb@@ -89,7 +89,7 @@ Prosopite.allow_stack_paths = ['from_attachable_sgid', # ActionText: one Blob.find per <action-text-attachment sgid> when a rich text with images is saved or rendered (GlobalID::Locator.locate_signed, ActionText's own embeds sync in before_save does the same). Bounded by the images in ONE text, inherent to ActionText, not a per-record N+1 of our code; the cost per screenshot is the Paket-2 measurement of doc/inline_bilder_spike_plan.md (E2). RichTextEmbedGuard's own queries stay under watch'db/seeds/demo', # db/seeds/demo.rb: five demo tickets saved one by one through Actors::SaveTicket, each with its own assignment sync, as a real user would create them. Bounded by DemoSeed::TICKETS, run from db:seed in development only, never in a request. Surfaces only in spec/db/seeds_spec.rb'db/seeds/prompt_personas', # db/seeds/prompt_personas.rb: one find_or_initialize_by per seeded persona (bounded by the entries in GLOBAL_PROMPT_PERSONAS, four today), run from db:seed or a rails runner, never in a request. Surfaces only in spec/db/seeds/prompt_personas_spec.rb, which loads the file on purpose- 'projects_in_organisation', # PersonalAccessTokens::ReachListing#projects: one policy-scoped project read per ORGANISATION the token reaches (PersonalAccessToken#organisation_scopes), bounded by that handful, the per-tenant loop of aggregate_org_slice. Hidden until 2026-10-02 by Pundit memoising policy_scope(Project) per class, which also answered every organisation with the first one's projects+ 'projects_in_organisation', # PersonalAccessTokens::ReachListing#projects: one bundle of reads per ORGANISATION (the policy-scoped projects and, for MCP, the area reads of ProjectAccessService.openable_project_ids) the token reaches (PersonalAccessToken#organisation_scopes), bounded by that handful, the per-tenant loop of aggregate_org_slice. Hidden until 2026-10-02 by Pundit memoising policy_scope(Project) per class, which also answered every organisation with the first one's projects'inbox_query_readable_rows', # Notifications::InboxQuery: the AREA resolution behind Notification.readable (one per area the mapping names, plus any area) for ONE organisation of a token's reach. Same bounded per-organisation loop as inbox_query_current_access below: for a role with rights in all projects it is one exclusion read (ProjectAccessService.find_excluded_project_ids_for_area) per area and organisation, bounded by the organisations the TOKEN names. Pinned: area_rights_spec.rb, the token inbox over organisations'open_hours_in_organisation', # TimeSessions::OpenHours (GET /api/v1/time_sessions/open): one ViewingScope resolution per ORGANISATION in a token's reach (active membership, admin check, ONE read of the time permission rows), to narrow that organisation's own bookings the way TimeSessionPolicy::Scope does. ViewingScope answers per organisation by construction, so the loop is mandatory; it is bounded by the organisations the TOKEN names, not by any record count. A frame of its own for the same reason as inbox_query_current_access below'readable_open_hour_tickets', # TimeSessions::OpenHours: one TicketPolicy::Scope resolution plus one pluck per ORGANISATION that has a ticket on the current page (at most the organisations of the token, and at most per_page rows), the tickets the person may read. The policy scope takes one organisation as its tenant, so the loop is mandatory; a check per ROW would be the real N+1 (time_sessions_open_access_spec.rb pins it)