docs: consolidate documentation into organized structure

- Move 12 markdown files from root to docs/ subdirectories
- Organize documentation by category:
  • docs/troubleshooting/ (1 file)  - Technical troubleshooting guides
  • docs/deployment/      (4 files) - Deployment and security documentation
  • docs/guides/          (3 files) - Feature-specific guides
  • docs/planning/        (4 files) - Planning and improvement proposals

Root directory cleanup:
- Reduced from 16 to 4 markdown files in root
- Only essential project files remain:
  • CLAUDE.md (AI instructions)
  • README.md (Main project readme)
  • CLEANUP_PLAN.md (Current cleanup plan)
  • SRC_STRUCTURE_IMPROVEMENTS.md (Structure improvements)

This improves:
 Documentation discoverability
 Logical organization by purpose
 Clean root directory
 Better maintainability
This commit is contained in:
2025-10-05 11:05:04 +02:00
parent 887847dde6
commit 5050c7d73a
36686 changed files with 196456 additions and 12398919 deletions

View File

@@ -14,7 +14,7 @@ use App\Framework\Core\ValueObjects\Byte;
*/
final class MemoryGuard
{
private array $memoryHistory = [];
private CircularMemoryBuffer $memoryHistory;
private int $checkCounter = 0;
@@ -26,6 +26,7 @@ final class MemoryGuard
private readonly DiscoveryMemoryManager $memoryManager,
?callable $emergencyCallback = null
) {
$this->memoryHistory = new CircularMemoryBuffer(maxSize: 100);
$this->emergencyCallback = $emergencyCallback;
}
@@ -37,13 +38,8 @@ final class MemoryGuard
$this->checkCounter++;
$memoryStatus = $this->memoryManager->getMemoryStatus();
// Track memory history for leak detection
$this->memoryHistory[] = $memoryStatus->currentUsage;
// Keep only recent history to prevent memory growth
if (count($this->memoryHistory) > 100) {
$this->memoryHistory = array_slice($this->memoryHistory, -50);
}
// Track memory history for leak detection using CircularMemoryBuffer
$this->memoryHistory->add($memoryStatus->currentUsage);
$actions = [];
@@ -73,7 +69,7 @@ final class MemoryGuard
}
}
// Check for memory leaks periodically
// Check for memory leaks periodically using CircularMemoryBuffer
if ($this->checkCounter % 20 === 0) {
$leakInfo = $this->memoryManager->checkForMemoryLeaks($this->memoryHistory);
if ($leakInfo !== null) {
@@ -121,13 +117,15 @@ final class MemoryGuard
{
$memoryStatus = $this->memoryManager->getMemoryStatus();
$historyCount = count($this->memoryHistory);
$samples = $this->memoryHistory->getSamples();
$historyCount = $this->memoryHistory->getCount();
$averageUsage = $historyCount > 0
? Byte::fromBytes((int) (array_sum(array_map(fn ($byte) => $byte->toBytes(), $this->memoryHistory)) / $historyCount))
? Byte::fromBytes((int) (array_sum(array_map(fn (Byte $byte) => $byte->toBytes(), $samples)) / $historyCount))
: Byte::zero();
$peakUsage = $historyCount > 0
? array_reduce($this->memoryHistory, fn ($max, $current) => $current->greaterThan($max ?? Byte::zero()) ? $current : $max, Byte::zero())
? array_reduce($samples, fn ($max, $current) => $current->greaterThan($max ?? Byte::zero()) ? $current : $max, Byte::zero())
: Byte::zero();
return new GuardStatistics(
@@ -145,7 +143,7 @@ final class MemoryGuard
*/
public function reset(): void
{
$this->memoryHistory = [];
$this->memoryHistory->clear();
$this->checkCounter = 0;
$this->emergencyMode = false;
}
@@ -192,8 +190,8 @@ final class MemoryGuard
break;
}
// Check for potential leaks
if (count($this->memoryHistory) > 10) {
// Check for potential leaks using CircularMemoryBuffer
if ($this->memoryHistory->getCount() > 10) {
$leakInfo = $this->memoryManager->checkForMemoryLeaks($this->memoryHistory);
if ($leakInfo !== null) {
$recommendations[] = "Memory leak detected ({$leakInfo->severity->value}): Review object retention";