# Phyllis Schlafly Site Rebuild

## Purpose

This repository supports a safe rebuild of `https://phyllisschlafly.com`.
It provides a local WordPress environment and controlled access instructions.
Production stays read-only unless the operator gives explicit approval for a specific change.

## Prerequisites

Install these tools:

- Git
- Docker Engine
- Docker Compose
- Node.js and npm
- An SSH client
- WP-CLI for approved WordPress inspection

Obtain required credentials through an approved private channel.
Do not store credentials in this repository.

## Local Setup

Run these commands from the repository root:

```bash
cp .env.example .env
chmod 600 .env
docker compose up -d
npm ci
npx playwright install chromium
```

The example database passwords are only for the isolated local stack.
Replace the example database passwords when you need different local values.
Do not put production credentials in `.env` unless read-only inspection requires them.
Docker Compose binds WordPress only to `127.0.0.1:8080`.

Add custom source only in these directories:

- `wp-content/themes/custom-theme`
- `wp-content/plugins/custom-plugin`
- `wp-content/mu-plugins/custom-mu-plugin.php`
- `wp-content/mu-plugins/custom-mu-plugin`

Docker Compose mounts each custom component directory separately.
The root must-use plugin loader loads PHP files from `custom-mu-plugin` in name order.
This layout keeps bundled WordPress content outside the tracked directories.
Do not add production uploads, plugins, themes, or database data.

## Validation

Run the offline checks:

```bash
npm test
```

This command validates the URL policies and the Playwright test discovery.
This command also runs the existing repository validation.
This command does not navigate to the production site.

Run the local site check after you start the local environment:

```bash
npm run test:local
```

Run the read-only public site check when you must validate production:

```bash
npm run test:public
```

Run these commands from the repository root:

```bash
docker compose config
docker compose ps
scripts/validate-mu-plugin-loader.sh
git status --short
git diff --cached
git diff --cached --check
git diff --check
```

Review the complete staged diff before each commit.
Confirm that the local site uses `LOCAL_SITE_URL`.
Confirm that each production operation is read-only.
Follow [docs/SAFETY.md](docs/SAFETY.md) for more checks.

## Access Activation Sequence

Activate access in this order:

1. Copy `.env.example` to `.env`.
2. Configure the local WordPress database values.
3. Start and validate the local environment.
4. Ask the operator for the minimum required remote access.
5. Receive credentials through an approved private channel.
6. Store the credentials only in the local `.env` file or an approved secret store.
7. Review each value in `.env`.
8. Use `scripts/with-environment.sh` to run a wrapper with the approved values.
9. Confirm TLS verification before each network request.
10. Test the access method with a read-only operation.
11. Stop if an operation can change production.
12. Get explicit operator approval for each specific production change.

The environment loader accepts only `NAME=VALUE` entries from the known contract.
The loader does not source `.env`.
The loader does not execute values from `.env`.
The loader clears all ambient contract values before it reads `.env`.
The loader exports only the values for the selected access mode.

Review the file before each remote command:

```bash
sed -n '1,240p' .env
```

Validate REST configuration and run the unauthenticated public check:

```bash
scripts/with-environment.sh rest .env scripts/rest-public-read.sh
```

Run each guarded command with its access-specific mode:

```bash
scripts/with-environment.sh ssh .env scripts/wp-read.sh core version
scripts/with-environment.sh database .env scripts/db-read.sh "SHOW TABLES"
```

See [docs/ACCESS.md](docs/ACCESS.md) for access-specific controls.
See [docs/SITE-INVENTORY.md](docs/SITE-INVENTORY.md) for the public site structure.
