SILLBEAM HANDBOOK

Architecture

Understand reported module relationships and account for the limits of architecture validation.

Overview

To validate module references, Sillbeam records static class references in a shared source index during the container build. PHP-Parser resolves namespaces and imports and identifies attributes on descriptors. Discovery assigns descriptors to their configured boundaries and checks for unique, non-overlapping module and Project directories.

For active modules, the code analyzer checks whether a direct module reference is permitted by the direct dependency declarations and the private Project boundary. Transitive declarations do not permit direct access. The compiler checks IDs, declared dependencies, cycles and host assignments, and determines active graphs. A visited node is expanded once per graph.

This result feeds registries, native service imports, routing and optionally Doctrine. Disabled or unassigned modules remain available for diagnostics without automatic imports. Parent imports from Projects also exclude module areas. Explicit native Symfony/Doctrine imports remain a deliberate escape hatch and can reactivate code.

Directory, File and FileExistence resources monitor source boundaries, including default directories that do not yet exist. The production cache is rebuilt during deployment, as with Symfony. Activation values from environment variables are resolved at build time; changes require a cache rebuild.

A Project represents an interface with host routing and request context. The container, event system and EntityManager are shared. Global handlers are not isolated; Projects do not create a security boundary.

Technical reference: published Core tag v0.2.0, commit cf2f4102ad7c15db30ad5c5af21852bc2aaec99a in the Core repository. Historical verification records identify their own source snapshots separately. The unchanged contracts were checked against the published Core v0.3.0.

Distinguish declarations, observations and activation

When a reference is unclear, start with sillbeam:inspect:module Billing; -v shows reference locations and original findings. sillbeam:graph --module=Billing visualizes direct relationships. Both use existing architecture evidence, not an additional analyzer.

The declared module graph describes intended direct dependencies. Observed class references are separate evidence and do not create declarations. Effectively active modules require a validated graph; enabled alone is insufficient. Invalid architecture and incomplete diagnosis are different states. A diagnostic export must not be interpreted as a runtime graph.

The CLI reference describes SVG, raw Mermaid, filters and exit codes. A graph replaces neither architecture corrections nor container and application tests. Historical diagrams and terminal evidence below remain original evidence for their respective versions.

Collected findings and analysis limits

ArchitectureAnalyzer collects independently detectable discovery, Module, Project, host and dependency errors. Findings include a stable rule ID, error or fatal, a message and available context. Ordering and deduplication are deterministic. A complete run can be invalid; a fatal blocker prevents further reliable analysis while retaining earlier findings.

Container compilation remains strict: invalid results throw ArchitectureValidationException, derived from LogicException. result.architecture is available only for valid analysis. An error report or observed reference is not an approved runtime graph. File and line appear only when actually known; configuration errors may lack them.

Direct module references from active source modules remain subject to code.private, code.inactive and code.undeclared_dependency. Unknown declared target modules remain dependency.unknown. The newer code.unknown_class check covers unresolved application-owned classes or types, including Project code and inactive modules; it does not validate every external PHP type or service autowiring.

Application couplings show known indexed target classes outside every module with source and target files. They are informational only. There is no recursive vendor analysis; only targets visible in discovery roots can provide coupling evidence. Dynamic class names, PHPDoc and unused imports remain outside the collected static references.

Current text, JSON and Markdown reports use the same analysis. The historical v0.1.0 outputs below instead show the former first-error failure behavior and require successful container compilation for their catalog.

Diagnoses group related findings through the internal Diagnostic Engine. It groups only findings with evidence of a shared cause or module relationship; matching rule codes or files alone are insufficient. Finding and diagnosis counts remain separate. Each diagnosis describes the problem, impact, known context and next steps while retaining links to all original findings. This improves presentation without changing architecture rules or the schema version.

Recommendations distinguish technical recovery and investigation (technical) from domain decision options (option). A missing direct dependency is suggested as a possible declaration only with complete evidence and no cycle or private boundary violation. A verified return path shows the resulting cycle; existing cycles show an evidenced directed path, not every possible cycle. You decide the correct domain direction for your application. Sillbeam never changes application code automatically.

A declaration does not grant access across private Project boundaries. For disabled modules, guidance uses the actual owner and evidenced configuration key; an enabled but unassigned shared module instead requires a domain decision about Project assignment. Unknown targets prompt checks of descriptors, discovery roots and exclusions. Unknown activation or ownership remains unknown; missing files or configuration names are never invented.

Fatal blockers mark analysis as incomplete and take priority in diagnosis. Known nonfatal findings remain available, but changes to activation or dependencies must wait until blockers are resolved and analysis is rerun. PHP descriptor recommendations retain fully qualified concrete ::class references, such as \App\Module\Payment\PaymentModule::class; a service or entity with the same short name must not be mistaken for the descriptor.

Development, production and deployment

The policy follows kernel.debug, usually APP_DEBUG, not the environment name alone. Cold or rebuilt debug containers validate fully. Warm debug requests follow Symfony resource tracking and revalidate when rebuilding is necessary. CLI compilation remains strict even without debug.

Warm non-debug HTTP requests use prebuilt registries, services, routes and mappings without source analysis. If the compiled container is missing, HTTP compilation is rejected before discovery/analysis with a generic HTTP 503 response. Run production with APP_DEBUG=0.

BASH
APP_ENV=prod APP_DEBUG=0 php bin/console cache:clear
APP_ENV=prod APP_DEBUG=0 php bin/console cache:warmup
APP_ENV=prod APP_DEBUG=0 php bin/console sillbeam:architecture --format=json

Every immutable release needs its own fresh cache/build path. Stop on every nonzero exit and switch traffic only after successful warmup and validation. cache:clear and cache:warmup check current sources even with a warm cache and with --no-warmup or --no-optional-warmers. Never replace sources under a running production cache; a valid architecture report does not replace the Symfony container build.

Core v0.2.0 consumer: actual reporting output

This new evidence was verified in a real isolated Composer consumer application on PHP 8.5.4. Its Core snapshot is dev-v0.2.x commit 74cffb0; Composer mirrored it as simulated local version 0.2.0. This does not prove public package availability. FrameworkBundle/Console/Yaml: 7.4.21; HttpKernel/DependencyInjection: 8.1.9; PHP parser: 5.9.0. No Doctrine or Projects.

Billing directly references PaymentService. Without PaymentModule in dependencies, the optional Console adapter returns exit 1 with code.undeclared_dependency before successful container compilation. The following JSON is unchanged original output, not a schematic example.

PHP
<?php

declare(strict_types=1);

namespace App\Module\Billing;

use App\Module\Payment\PaymentModule;
use Sillbeam\Core\Module\Attribute\SillbeamModule;

#[SillbeamModule(
    id: 'billing',
    description: 'Invoices',
    dependencies: [PaymentModule::class],
)]
final class BillingModule
{
}
Original output · php bin/console sillbeam:architecture --format=json --no-ansi
{
    "schema_version": 1,
    "status": "violations",
    "valid": false,
    "complete": true,
    "findings": [
        {
            "rule": "code.undeclared_dependency",
            "message": "/tmp/sillbeam-website-v020-_zrb15oy/consumer/src/Module/Billing/Service/InvoiceService.php:11: Module \"billing\" uses \"App\\Module\\Payment\\Service\\PaymentService\" from module \"payment\": does not declare a direct dependency.",
            "context": {
                "class": "App\\Module\\Payment\\Service\\PaymentService",
                "file": "/tmp/sillbeam-website-v020-_zrb15oy/consumer/src/Module/Billing/Service/InvoiceService.php",
                "line": 11,
                "module": "App\\Module\\Billing\\BillingModule",
                "project": null,
                "target": "App\\Module\\Payment\\PaymentModule",
                "suggestion": "Declare the target module as a direct dependency in the source module descriptor."
            },
            "severity": "error"
        }
    ],
    "modules": [
        {
            "id": "billing",
            "class": "App\\Module\\Billing\\BillingModule",
            "scope": "shared",
            "project": null,
            "enabled": true,
            "active": null,
            "inactive_reason": "unknown",
            "directory": "/tmp/sillbeam-website-v020-_zrb15oy/consumer/src/Module/Billing",
            "descriptor": "/tmp/sillbeam-website-v020-_zrb15oy/consumer/src/Module/Billing/BillingModule.php",
            "declared_dependencies": [],
            "observed_dependencies": [
                "App\\Module\\Payment\\PaymentModule"
            ],
            "references": [
                {
                    "module": "App\\Module\\Payment\\PaymentModule",
                    "class": "App\\Module\\Payment\\Service\\PaymentService",
                    "file": "/tmp/sillbeam-website-v020-_zrb15oy/consumer/src/Module/Billing/Service/InvoiceService.php",
                    "line": 11
                }
            ],
            "activation_reasons": [],
            "controllers": [],
            "entities": []
        },
        {
            "id": "payment",
            "class": "App\\Module\\Payment\\PaymentModule",
            "scope": "shared",
            "project": null,
            "enabled": true,
            "active": null,
            "inactive_reason": "unknown",
            "directory": "/tmp/sillbeam-website-v020-_zrb15oy/consumer/src/Module/Payment",
            "descriptor": "/tmp/sillbeam-website-v020-_zrb15oy/consumer/src/Module/Payment/PaymentModule.php",
            "declared_dependencies": [],
            "observed_dependencies": [],
            "references": [],
            "activation_reasons": [],
            "controllers": [],
            "entities": []
        }
    ],
    "projects": []
}

The corresponding text report groups the finding and includes remediation; sillbeam:report wrote a Markdown file even with exit 1. After restoring the declaration, cache clear, production warmup and JSON reporting succeeded. An additional broken service reference still allowed a successful architecture report while actual container compilation failed.

This local evidence verifies this specific combination, not every allowed version, the full generator scope or all production HTTP cases. The handbook separately identifies the source-code and repository-test basis for those cases.

Billing and Payment: runnable example

Historical evidence for v0.1.0: previous package name, previous PHP namespace and unchanged original outputs from that version. This is not evidence of v0.2.0 reporting.

This example was executed with the published v0.1.0 bundle in an isolated Symfony application. Billing uses a service from Payment. The classes demonstrate architecture validation only; they do not process a payment.

TEXT
src/Module/
├── Billing/
│   ├── BillingModule.php
│   └── Service/
│       └── InvoiceService.php
└── Payment/
    ├── PaymentModule.php
    └── Service/
        └── PaymentService.php

These are all module files in the test application under the default root src/Module/. Without Projects, both enabled shared modules are active. Controllers, entities and a database are not required for this validation.

BillingModule.php: the corrected descriptor

PHP
<?php

declare(strict_types=1);

namespace App\Module\Billing;

use App\Module\Payment\PaymentModule;
use Sillbeam\Module\Attribute\SillbeamModule;

#[SillbeamModule(
    id: 'billing',
    description: 'Invoices',
    dependencies: [PaymentModule::class],
)]
final class BillingModule
{
}

PaymentModule.php: the target module

PHP
<?php

declare(strict_types=1);

namespace App\Module\Payment;

use Sillbeam\Module\Attribute\SillbeamModule;

#[SillbeamModule(id: 'payment', description: 'Payments')]
final class PaymentModule
{
}

InvoiceService.php: the direct code reference

PHP
<?php

declare(strict_types=1);

namespace App\Module\Billing\Service;

use App\Module\Payment\Service\PaymentService;

final readonly class InvoiceService
{
    public function __construct(private PaymentService $payments)
    {
    }
}

PaymentService.php: the referenced service

PHP
<?php

declare(strict_types=1);

namespace App\Module\Payment\Service;

final class PaymentService
{
}

Editorial explanation: The constructor parameter on line 11 directly references PaymentService. Billing must therefore list the descriptor PaymentModule::class directly in dependencies. A use import alone would not count as a checked reference; a transitive dependency would not permit this direct access.

Missing declaration: the build fails

Historical evidence for v0.1.0: previous package name, previous PHP namespace and unchanged original outputs from that version. This is not evidence of v0.2.0 reporting.

Remove only the PaymentModule::class entry from the Billing descriptor. The code reference in the service remains. The complete invalid descriptor is:

PHP
<?php

declare(strict_types=1);

namespace App\Module\Billing;

use App\Module\Payment\PaymentModule;
use Sillbeam\Module\Attribute\SillbeamModule;

#[SillbeamModule(
    id: 'billing',
    description: 'Invoices',
    dependencies: [],
)]
final class BillingModule
{
}
BASH
php bin/console cache:clear --no-ansi
Original output · php bin/console cache:clear --no-ansi

In CodeDependencyAnalyzer.php line 65:
                                                                               
  /tmp/sillbeam-billing-payment/src/Module/Billing/Service/InvoiceService.php  
  :11: Module "billing" uses "App\Module\Payment\Service\PaymentService" from  
   module "payment": does not declare a direct dependency.                     
                                                                               

Editorial explanation: Exit code 1. The error occurs during the Symfony container build, rather than as the result of a successful architecture command. CodeDependencyAnalyzer reports the concrete reference with its file and line. The absolute path comes from this run and changes with the application directory.

The command php bin/console sillbeam:architecture --no-ansi was also run before the correction: exit code 1 with the same build error and no architecture table. Validation stops at the first error raised. Multiple violations are not automatically reported together.

After the correction: the actual architecture

Historical evidence for v0.1.0: previous package name, previous PHP namespace and unchanged original outputs from that version. This is not evidence of v0.2.0 reporting.

Restore dependencies: [PaymentModule::class] in the Billing descriptor. Rebuild the cache, then run the architecture command. Both commands returned exit code 0 in this run.

BASH
php bin/console cache:clear --no-ansi
php bin/console sillbeam:architecture --no-ansi
Original output · php bin/console cache:clear --no-ansi

 // Clearing the cache for the dev environment with debug true                  

 [OK] Cache for the "dev" environment (debug=true) was successfully cleared.    

Original output · php bin/console sillbeam:architecture --no-ansi
 --------- -------- -------- --------------------- -------------------------------------------------- 
  Module    Scope    State    Declared / observed   Directory                                         
 --------- -------- -------- --------------------- -------------------------------------------------- 
  billing   shared   active   1 / 1                 /tmp/sillbeam-billing-payment/src/Module/Billing  
  payment   shared   active   0 / 0                 /tmp/sillbeam-billing-payment/src/Module/Payment  
 --------- -------- -------- --------------------- -------------------------------------------------- 

Editorial explanation: Declared / observed counts direct module dependencies, rather than individual class references. Billing has one declared and one observed dependency; Payment has none. Both modules are shared and active.

Also executed: php bin/console sillbeam:architecture --format=json --no-ansi. For Billing, the JSON catalog contains App\Module\Payment\PaymentModule in both declared_dependencies and observed_dependencies, plus the service, file path and line 11 under references. The complete unchanged JSON output is included with the reproduction files.

Versions, reproduction and technical sources

Historical evidence for v0.1.0: previous package name, previous PHP namespace and unchanged original outputs from that version. This is not evidence of v0.2.0 reporting.

Executed on 17 October 2026: PHP 8.5.4 CLI, Composer 2.9.5, websign-dev/sillbeam v0.1.0 (commit 5684563a6800dc5653f4d8f61c5de3bc9f17c54e), FrameworkBundle and Console v7.4.21, HttpKernel and DependencyInjection v8.1.9, PHP-Parser v5.9.0. This is a mixed Symfony installation allowed by the package constraints; all installed versions are recorded in composer.lock.

Download the reproduction files. The archive contains the complete application, composer.lock, reproduce.sh and the unchanged original outputs in evidence/. Requirements: Bash, PHP 8.5 with the extensions required by Composer, Composer 2 and network access for package installation.

BASH
unzip billing-payment.zip
bash billing-payment/reproduce.sh

The script copies the application to a new directory under /tmp, installs the locked package versions with composer install --no-interaction --prefer-dist --no-progress, removes the declaration, checks both failing commands and then restores the correct descriptor. It then checks the build, text output and JSON dependencies. Outputs and the run directory are retained for inspection; absolute paths and console widths may differ.

The test application registers FrameworkBundle and SillbeamBundle in config/bundles.php, uses a standard Symfony kernel with MicroKernelTrait and Composer PSR-4 App\ → src/. There is no broad App service import, no Projects and no Doctrine. Sillbeam uses its discovery and service import defaults; no sillbeam.yaml is needed.

Authoritative product sources: module guide, CLI reference and the modules-only example application. The guide already contains the Billing/Payment descriptor; the example application demonstrates a runnable module structure using other domains.

The homepage was checked against product revision 0600e005e515e680cc71dd51957811b1babc6566. ArchitectureCompiler validates the graph, CodeDependencyAnalyzer checks direct references, and ArchitectureCommand displays the compiled catalog. Runtime verification uses the separately published v0.1.0 package. The product repository was not modified.