refactor: rename lib/ to core/ for clearer core-module separation

Rename the top-level lib/ directory to core/ so the project root
immediately communicates which code is core platform and which lives
in modules/. PHP namespaces (MintyPHP\*) are unchanged — only the
Composer PSR-4 path mapping moves from lib/ to core/.

Module-internal lib/ directories (modules/*/lib/) are untouched.

Updated across the full stack:
- composer.json PSR-4 mapping
- bootstrap entry points (web/index.php, bin/*, tests/bootstrap.php)
- tooling configs (phpstan.neon, phpunit.xml, php-cs-fixer)
- 26 architecture contract tests
- enforcement-policy, guard-catalog, quality-gates
- all documentation (CLAUDE.md, README, 25 docs/, .agents/skills/)
- bin/qa-extended.sh search paths
- .claude/settings.local.json permission paths

Workflow: .agents/runs/CORE-LIB-RENAME-001/ (Analyst → Planner →
Executor → Code Review (4 findings fixed) → Security Review →
Acceptance Test → Finalizer)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-13 23:20:05 +02:00
parent 7c10fadcb9
commit 0e86925464
371 changed files with 191 additions and 192 deletions

View File

@@ -54,7 +54,7 @@ docker compose exec php vendor/bin/composer-unused
## Project Structure
```
lib/ # All backend PHP (namespace MintyPHP\)
core/ # All backend PHP (namespace MintyPHP\)
App/ # DI container + bootstrap (AppContainer, Container/Registrars/)
Module/ # Module platform (Registry, Manifest, Autoloader, Builder)
Repository/ # SQL queries, prepared statements, filters/paging
@@ -66,7 +66,7 @@ lib/ # All backend PHP (namespace MintyPHP\)
Support/ # Crypto, flash, guard, search, helpers
modules/ # Self-contained feature modules (namespace MintyPHP\Module\<Name>\)
<id>/module.php # Module manifest (routes, slots, providers, permissions)
<id>/lib/ # Module PHP classes (Service, Repository, Providers)
<id>/lib/ # Module PHP classes (Service, Repository, Providers)
<id>/pages/ # Module actions + views (symlinked into runtime)
<id>/templates/ # Module-specific templates
<id>/web/ # Module CSS/JS (published to web/modules/<id>/)
@@ -101,13 +101,13 @@ docker/ # Dockerfiles, Nginx configs, PHP configs
### Strict Layering (enforce in all changes)
1. **App** (`lib/App/`): DI container bootstrap. Registers all service/repository factories. No business logic.
2. **Repository** (`lib/Repository/`): All SQL lives here. No HTTP, session, or rendering.
3. **Service** (`lib/Service/`): Business rules and validation. No HTML. Four internal sub-types:
1. **App** (`core/App/`): DI container bootstrap. Registers all service/repository factories. No business logic.
2. **Repository** (`core/Repository/`): All SQL lives here. No HTTP, session, or rendering.
3. **Service** (`core/Service/`): Business rules and validation. No HTML. Four internal sub-types:
- **Service** (`*Service.php`): Business logic + orchestration. Coordinates repositories and gateways.
- **Gateway** (`*Gateway.php`): Adapter for a single external dependency (repository, settings, HTTP API, scope). No orchestration flow.
- **Factory** (`*Factory.php`): Only place inside `lib/Service/` that may call `new` on services/gateways/repositories. Registers via DI container.
- **Policy** (`*Policy.php` in `lib/Service/Access/`): Authorization decisions per resource type. Returns `AuthorizationDecision`. No HTTP, no business logic.
- **Factory** (`*Factory.php`): Only place inside `core/Service/` that may call `new` on services/gateways/repositories. Registers via DI container.
- **Policy** (`*Policy.php` in `core/Service/Access/`): Authorization decisions per resource type. Returns `AuthorizationDecision`. No HTTP, no business logic.
4. **Action** (`pages/**/*.php`): Reads input, checks permissions + tenant scope, calls services, sets view vars.
5. **View** (`pages/**/*.phtml`): Pure rendering. **No DB calls.** HTML escaping via `e(...)`.
6. **Template** (`templates/`): Layouts and partials.
@@ -139,7 +139,7 @@ docker/ # Dockerfiles, Nginx configs, PHP configs
### PHP Conventions
- PSR-4 autoload: `MintyPHP\``lib/`, `MintyPHP\Module\*``modules/*/lib/`, `MintyPHP\Tests\``tests/`
- PSR-4 autoload: `MintyPHP\``core/`, `MintyPHP\Module\*``modules/*/lib/`, `MintyPHP\Tests\``tests/`
- All user-facing text uses `t('key')` translation helper — keys must exist in all language files under `i18n/`
- Request input via `requestInput()` — never raw `$_GET`/`$_POST`/`$_SESSION` (GR-CORE-003)
- Permissions + tenant scope enforced in actions/services, never just in UI
@@ -198,7 +198,7 @@ These rules are enforced by guards GR-SEC-001 through GR-SEC-010 in `.agents/che
- No PII or secrets in logs or audit metadata (GR-SEC-002)
- SQL only via Repository prepared statements — no inline queries (GR-SEC-003)
- No external CDN or remote asset loading (GR-SEC-004)
- Encryption only via `lib/Support/Crypto.php` AES-256-GCM (GR-SEC-005)
- Encryption only via `core/Support/Crypto.php` AES-256-GCM (GR-SEC-005)
- File uploads: `storage/` only, authz-gated serving, MIME-validated (GR-SEC-006)
- API requests must not start sessions (GR-SEC-007)
- Authorization enforced server-side, not just in UI (GR-SEC-008)