core

PHP Simple Fast & Secure

View on GitHub

Home › Admin UI › Design history › Admin 2.0 Phase 1 Parity Implementation Plan

Admin 2.0 Phase 1 Parity Implementation Plan

For agentic workers: REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (- [ ]) syntax for tracking.

Goal: Make the two currently supported Admin 2.0 mutations preserve the legacy configuration side effects and reject route regeneration without a session CSRF token.

Architecture: Keep business operations in their existing PSFS services. AdminFrontendConfigController gains small protected seams around the legacy post-save effects so the adapter can call the identical cache/document-root lifecycle and tests can observe it without filesystem writes. AdminFrontendRoutesController calls the established AdminFrontendCsrf guard before it invokes the Router; its existing Admin authorization remains unchanged.

Tech Stack: PHP 8.3, PHPUnit 11, PSFS Config/Router/Security, Docker Compose.

Spec: docs/superpowers/specs/2026-09-09-admin-v2-phase-0-ui-boundary.md

Global Constraints


Task 1: Preserve legacy configuration post-save effects

Files:

Interfaces:

public function testSavedProductionConfigRefreshesTheLegacyCacheState(): void
{
    $controller = new AdminFrontendConfigControllerProbe(
        ['values' => ['app.name' => 'PSFS v2'], 'extra' => []],
        [true, false]
    );
    $controller->update();

    self::assertSame(1, $controller->cacheRefreshes);
    self::assertSame(1, $controller->documentRootClears);
}

public function testSavedConfigDoesNotClearDocumentRootWhenDebugDoesNotChange(): void
{
    $controller = new AdminFrontendConfigControllerProbe(
        ['values' => ['app.name' => 'PSFS v2'], 'extra' => []],
        [false, false]
    );
    $controller->update();

    self::assertSame(1, $controller->cacheRefreshes);
    self::assertSame(0, $controller->documentRootClears);
}

Run: docker exec psfs-php-1 php vendor/bin/phpunit tests/controller/AdminFrontendConfigControllerTest.php

Expected: assertions fail because no post-save effect is invoked.

$previousDebug = $this->debugMode();
if (!$this->save($form->getData(), $this->normalizeExtra($extra))) { /* existing 500 */ }
$this->applyPostSaveEffects($previousDebug);

protected function applyPostSaveEffects(bool $previousDebug): void
{
    $currentDebug = $this->debugMode();
    if (!$currentDebug) $this->refreshCacheState();
    if ($previousDebug !== $currentDebug) $this->clearDocumentRoot();
}

Run: docker exec psfs-php-1 php vendor/bin/phpunit tests/controller/AdminFrontendConfigControllerTest.php

Expected: all configuration-controller tests pass without modifying config/config.json.

Task 2: Require CSRF before regenerating routes

Files:

Interfaces:

public function testRegenerationRejectsAMissingCsrfTokenBeforeRouteWork(): void
{
    Security::setTest(false);
    Security::dropInstance();

    $this->expectException(ApiException::class);
    $this->expectExceptionMessage('Invalid CSRF token');
    (new AdminFrontendRoutesControllerProbe())->regenerate();
}

Run: docker exec psfs-php-1 php vendor/bin/phpunit tests/controller/AdminFrontendRoutesControllerTest.php

Expected: failure because the current implementation reports Restricted area, demonstrating that no CSRF guard runs first.

public function regenerate(): string
{
    AdminFrontendCsrf::assertValid();
    $this->assertAdminAuthorization();
    // existing Router work unchanged
}

Run: docker exec psfs-php-1 php vendor/bin/phpunit tests/controller/AdminFrontendRoutesControllerTest.php

Expected: missing token returns the established Invalid CSRF token API exception; other route/docs tests remain green.

Task 3: Verify phase-level regression safety

Files:

Run: docker exec psfs-php-1 php vendor/bin/phpunit tests/controller/AdminFrontendConfigControllerTest.php tests/controller/AdminFrontendRoutesControllerTest.php tests/base/admin/AdminFormSchemaFactoryTest.php

Expected: all pass with no warnings.

Run: git diff --check && git diff -- src/controller/AdminFrontendConfigController.php src/controller/AdminFrontendRoutesController.php tests/controller/AdminFrontendConfigControllerTest.php tests/controller/AdminFrontendRoutesControllerTest.php

Expected: only phase-1 parity code and tests are present; unrelated working-tree changes remain untouched.

Present the passing test output and diff. Do not create a commit.


← Back to Design history