phase 0: environment assessment + test baseline #2
Labels
No labels
P1
P2
P3
PHP
agent-ready
bug
clotho
discovery
docs
epic
refactor
review
security
testing
athena
athena-gemini
audit
clotho
clotho-gemini
codex
darbs-claude
security
wiki
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: core/php-tenant#2
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
You are a domain expert for core/php-tenant - the multi-tenancy module. Depends on host-uk/core (php-framework).
Phase 0 Tasks
1. Environment Check
If composer install fails due to host-uk/core dependency, check if there is a repositories section in composer.json or try adding the forge package registry.
2. Run Tests
Document: pass/fail/skip counts.
3. Code Quality
4. Architecture Review
Document the tenant isolation pattern:
5. Create TODO.md + FINDINGS.md
Phased task queue based on findings. Commit to dev and push.
Rules
Phase 0 Assessment Complete
Branch:
feat/phase-0-assessment| PR: #41. Environment
composer installhost-uk/coreis a private package with norepositoriesentry incomposer.json. Vendor directory is empty.This blocks all tooling (tests, Pint, PHPStan). See ENV-001 added to TODO.md.
2. Test Baseline
Cannot run — vendor missing. Inventory: 15 test files, ~4,053 lines, covering workspace, entitlement, security, cache, 2FA, invitations, and API endpoints.
3. Code Quality (static)
Cannot run Pint or PHPStan. Static scan found 9 files missing
declare(strict_types=1)— DX-005 added to TODO.md.4. Architecture Review
Workspace isolation:
BelongsToWorkspacetrait: auto-assignsworkspace_idoncreating, throwsMissingWorkspaceContextExceptionif no context in strict mode, auto-invalidates cache onsaved/deletedWorkspaceScopeglobal scope: auto-filters all queries,withoutStrictMode()for admin/test contexts, fail-safe empty result set in non-strict modeMiddleware chain:
ResolveWorkspaceFromSubdomain— resolves{slug}.host.uk.com→ workspace model → stored inrequest()->attributes->get(workspace_model)RequireWorkspaceContext— validates user has access, logs denied attemptsCheckWorkspacePermission— per-permission authorisationResolveNamespace— resolves namespace from query/header/sessionMigrations: 6 migrations, 17 tables, all with composite indexes. Single large initial migration creates all core tables.
Entitlement system: Features (boolean/limit/unlimited), packages, boosts, usage records with rolling/monthly/none reset. Cascade: namespace → workspace → user tier. Cache with Redis tags (O(1)) or fallback O(n) per feature count.
5. Critical Bug Found: BUG-001 (P1)
namespace_idcolumns missing fromentitlement_usage_recordsandentitlement_booststables.The
UsageRecordandBoostmodels havenamespace_idin$fillable.EntitlementService::recordNamespaceUsage()andprovisionNamespaceBoost()both attempt to write this column. No migration adds it. Runtime result:Added as BUG-001 (P1) in TODO.md. A migration is needed adding nullable
namespace_idFK + indexes to both tables.Full report in
FINDINGS.md.