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

@@ -0,0 +1,113 @@
<?php
namespace MintyPHP\Repository\System;
use MintyPHP\DB;
class SystemHealthRepository implements SystemHealthRepositoryInterface
{
/**
* @return bool True if DB responds to SELECT 1.
*/
public function checkDatabaseConnectivity(): bool
{
return (int) (DB::selectValue('select 1') ?? 0) === 1;
}
/**
* @return list<string> Table names present in the current schema.
*/
public function listPresentTables(array $requiredTables): array
{
$rows = DB::select(
'select table_name from information_schema.tables where table_schema = database() and table_name in (???)',
$requiredTables
);
$present = [];
foreach ((array) $rows as $row) {
$table = (string) (($row['tables']['table_name'] ?? $row['table_name'] ?? ''));
if ($table !== '') {
$present[] = $table;
}
}
return array_values(array_unique($present));
}
/**
* @return array{last_heartbeat_at: string, last_result: string, last_error_code: string}|null
*/
public function getSchedulerStatus(): ?array
{
$row = DB::selectOne('select last_heartbeat_at, last_result, last_error_code from scheduler_runtime_status where id = 1 limit 1');
$status = is_array($row) ? ($row['scheduler_runtime_status'] ?? $row) : null;
if (!is_array($status)) {
return null;
}
return [
'last_heartbeat_at' => trim((string) ($status['last_heartbeat_at'] ?? '')),
'last_result' => trim((string) ($status['last_result'] ?? 'unknown')),
'last_error_code' => trim((string) ($status['last_error_code'] ?? '')),
];
}
/**
* @return list<string> Active permission keys matching the given list.
*/
public function listActivePermissionKeys(array $keys): array
{
$rows = DB::select(
'select `key` from permissions where active = 1 and `key` in (???)',
$keys
);
$present = [];
foreach ((array) $rows as $row) {
$key = (string) (($row['permissions']['key'] ?? $row['key'] ?? ''));
if ($key !== '') {
$present[] = $key;
}
}
return array_values(array_unique($present));
}
public function countAdminUsers(): int
{
return (int) (DB::selectValue(
'select count(distinct ur.user_id) from user_roles ur join roles r on r.id = ur.role_id and r.active = 1 where r.description in (?, ?) or r.id = 1',
'Admin',
'Administrator'
) ?? 0);
}
public function countActivePermissions(): int
{
return (int) (DB::selectValue('select count(*) from permissions where active = 1') ?? 0);
}
public function countInactivePermissions(): int
{
return (int) (DB::selectValue('select count(*) from permissions where active = 0') ?? 0);
}
/**
* @return list<string> All active permission keys.
*/
public function listAllActivePermissionKeys(): array
{
$rows = DB::select('select `key` from permissions where active = 1 order by `key`');
$keys = [];
foreach ((array) $rows as $row) {
$key = (string) (($row['permissions']['key'] ?? $row['key'] ?? ''));
if ($key !== '') {
$keys[] = $key;
}
}
return $keys;
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace MintyPHP\Repository\System;
interface SystemHealthRepositoryInterface
{
public function checkDatabaseConnectivity(): bool;
/**
* @param list<string> $requiredTables
* @return list<string>
*/
public function listPresentTables(array $requiredTables): array;
/**
* @return array{last_heartbeat_at: string, last_result: string, last_error_code: string}|null
*/
public function getSchedulerStatus(): ?array;
/**
* @param list<string> $keys
* @return list<string>
*/
public function listActivePermissionKeys(array $keys): array;
public function countAdminUsers(): int;
public function countActivePermissions(): int;
public function countInactivePermissions(): int;
/**
* @return list<string>
*/
public function listAllActivePermissionKeys(): array;
}