Phase 1 + 2: multi-tenant hierarchy, stateless company context, settings engine#202
Open
TLemmAI wants to merge 21 commits intofleetbase:mainfrom
Open
Phase 1 + 2: multi-tenant hierarchy, stateless company context, settings engine#202TLemmAI wants to merge 21 commits intofleetbase:mainfrom
TLemmAI wants to merge 21 commits intofleetbase:mainfrom
Conversation
- DocumentQueueItem model with safe-failure status flow - DocumentIngestionService: heuristic classification first, AI fallback, PDF extraction optional, conditional CarrierInvoice creation only at confidence >= 0.85 - Manual upload as primary path; works without Anthropic key, without spatie/pdf-to-text, without queue workers, without IMAP - All FleetOps/Ledger references guarded with class_exists() Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… client_code, client_settings to companies
…fill is_default on company_users
…pers to Company model
…cessCompany helpers to User
…ith client hard-guardrail
…-closed semantics
…trait wiring on main-branch tenant models
…nt + switch endpoints
…nostic context resolution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Foundation layer for fleetbase's TMS productization. Phase 1 introduces parent-organization → client-organization hierarchy with stateless per-request company context. Phase 2 adds a settings surface with parent-to-client inheritance.
Phase 1 — Multi-tenant hierarchy
companiesschema:parent_company_uuid,company_type,is_client,client_code,client_settingscompany_userspivot:access_levelenum +is_defaultbooleanparentCompany(),clientCompanies(),isClient(),isOrganization(),getAccessibleCompanyUuids(),defaultCompany(),accessibleCompanyUuids(),canAccessCompany()company_usersrow per user asis_defaultusing deterministic tie-breakerCompanyContextResolvermiddleware — stateless per-request, readsX-Company-Contextheader with$user->defaultCompany()fallback, client-role hard guardrailCompanyContextSelfResolvermiddleware — role-agnostic variant (no client hard-block) for self-service routes like settingsScopedToCompanyContexttrait — fail-closed local scope (empty result when no context bound)ClientCompanyController— org-scoped CRUD for client companiesCompanyContextController—currentandswitchendpoints (validation-only, no state mutation)Phase 2 — Settings engine
CompanySettingsResolverhelper — dot-notation, typed defaults, parent→client inheritance on top of existingSettingmodel (no newcompany_settingstable)CompanySettingsController—GET/PUT/PATCH /v1/company-settings/currentCompanySettingsUpdateRequest— validates flat dot-notation key map payloadTest infrastructure
tests/TestCase.php+tests/Pest.phpresponsecachenoop +mysql → sqliteconnection alias into TestCaseMerged from upstream/main
origin/maindrifted by 3 commits (schedule_items company_uuid, hos_*, v1.6.39). Auto-merged cleanly — disjoint from multi-tenant / settings surface.Test plan
Current feature branch: 116 Pest tests passed (279 assertions) covering every surface above.
Dependencies
This is the foundation PR — fleetops, ledger, ember-core, ember-ui, and the fleetbase parent all depend on it.