# Phase 12 — CI pipeline and reproducible dependency resolution

## Why this phase exists

The project does not yet include `composer.lock`. A production PHP application must deploy the reviewed dependency versions represented by a committed lock file. Generating a lock file without Composer or a package-resolution environment would be misleading, so this phase adds a controlled process rather than fabricating one.

## Generate the dependency lock

On a trusted development workstation or the manual GitHub Actions workflow:

```bash
scripts/generate-composer-lock.sh
```

The script:
1. Requires Composer.
2. Backs up an existing lock file before updating.
3. Resolves dependencies.
4. Validates Composer metadata.
5. Audits known dependency advisories.
6. Asks maintainers to review and commit the generated lock file.

Alternatively, run GitHub Actions → **Generate Composer Lock (manual)** and download the `composer-lock-review` artifact. Review it before committing.

## Continuous integration

`.github/workflows/ci.yml` runs on pushes and pull requests to `main` and `develop`. It:
- requires a committed `composer.lock`;
- validates Composer metadata;
- installs exact locked dependencies;
- audits dependencies;
- creates a temporary test environment;
- compiles Laravel routes;
- runs PHPUnit feature tests against in-memory SQLite;
- checks PHP and JavaScript syntax.

CI intentionally fails while `composer.lock` is missing. This prevents accidental unpinned dependency resolution from being treated as a release.

## Staging preflight

After dependencies are installed and `.env` is configured:

```bash
scripts/staging-preflight.sh
```

This checks for the lock file, environment, vendor autoloader, front controller, APP_KEY, disabled debug mode, PDO MySQL and Composer, then validates/audits dependencies and inspects Laravel's application and route table.

## Staging migration sequence

Only against a disposable, empty staging database:

```bash
php artisan migrate --seed --force
php artisan route:list --except-vendor
php artisan test
```

Never run `migrate:fresh` against a database containing data.

## Current environment limitation

The source-generation environment has PHP and Node.js but no Composer, Docker, MySQL client/server, or PDO database driver. Therefore no real `composer.lock` can be generated here and no Laravel runtime, migrations or PHPUnit tests are claimed as passed.
