# Tech Site Deployment and Verification

> **Status:** CURRENT
> **Last verified:** 2026-11-28

This is the controlled deployment runbook for `https://tech.telegram365books.stream/`. It documents the required gates implemented by `deploy-google.sh` and `verify_site.py`; completed deployment evidence is recorded below. A local commit or a successful restart alone is not proof of a production deployment.

## Current Google origin

| Item | Current value |
| --- | --- |
| Host | Google `ebstudy-vm` (`35.209.206.38`) |
| SSH user | `zxc-funnel` |
| Document root | `/home/zxc-funnel/tech.eb2026` |
| Service | `tech-static.service` |
| Unit | `/etc/systemd/system/tech-static.service` |
| Listener | `127.0.0.1:8087` |
| Public path | Cloudflare tunnel: `tech.telegram365books.stream` → `http://localhost:8087` |
| Server | `/usr/bin/python3 /home/zxc-funnel/tech.eb2026/serve.py` |
| Root behavior | Generated Python directory listing; there is no `index.html` or `index.md` |

Do not redesign the generated root listing. It automatically includes newly deployed files. [llms.txt](llms.txt) is the curated navigation/index, and [sitemap.xml](sitemap.xml) is the canonical URL inventory. The checked-in `tech-static.service` matches the live unit above; unit installation remains a separate change-controlled operation.

## Ownership and safety gates

- Deploy only reviewed files from the approved `tech/` source tree.
- Use the direct Google SSH identity from [ssh.md](ssh.md). Never target the retired Oracle hosting arrangement recorded in [history.md](history.md), and do not use the stale `oracle-eb` alias.
- Do not read `.env` for this documentation task. During an approved deployment, the controlled preflight requires `CF_API_TOKEN_PURGE` and `CF_ZONE_ID` in the operator's local `$HOME/.env`. `CF_API_TOKEN_READ` is a separate read credential and is never used for the purge. The deployer reads these values locally, never prints or logs them, and never sends them to the VM. Never source the file casually or commit its values.
- Do not deploy secrets, `.env` files, backups, session data, memory files, local tooling caches, or unrelated site content.
- Do not change DNS, Cloudflare ingress, application ports, or any service other than `tech-static.service` as part of this runbook.
- Stop on every failed gate. A partial transfer or a successful restart alone is not a completed deployment.

## Explicit document-root manifest

`deploy-google.sh` must use an explicit manifest, not a wildcard, recursive directory copy, or broad delete. The approved remote document-root set after Task 5 is exactly:

```text
ai-agents.md
api-examples.md
architecture.md
deployment.md
endpoints.md
hermes.md
history.md
hrmis-vm.md
llms.txt
memory-map.md
openapi.json
reg-site.md
robots.txt
sea-engine-guide.md
sea.md
security.md
serve.py
sitemap.xml
sites.md
ssh.md
state.md
telegram.md
```

`serve.py` is required operational server code but is deliberately excluded from `llms.txt` and `sitemap.xml`. `sitemap.xml` is deployed and publicly readable but does not list itself. The root listing has no corresponding file and is represented by the canonical root URL.

Local-only tooling is not part of this document-root manifest: `deploy-google.sh`, `verify_site.py`, the deprecated `deploy-oracle.sh`, and `tech-static.service`. Task 6 does not install or modify the systemd unit. After transfer and parity pass, `deploy-google.sh` restarts the existing `tech-static.service`, requires it to be active/running and enabled, and retries the `127.0.0.1:8087` listener check for up to 20 seconds at 2-second intervals before HTTP probing. Unit installation remains a separate change-controlled operation. Any future manifest change requires a matching index/sitemap review.

## Preflight

Before changing the live tree, `deploy-google.sh` must:

1. Run the local verifier and review the complete scoped diff.
2. Confirm every manifest file exists, is a regular file, and has no unexpected symlink or nested path.
3. Confirm the Google host/user, live document root, unit, loopback listener, and available disk space with read-only commands.
4. Confirm the active service is the expected tech server and that no second process owns `127.0.0.1:8087`.
5. Run `bash tech/deploy-google.sh --dry-run` and review the sorted SHA-256 source manifest and planned explicit uploads. Review additions and modifications before approving transfer. Any unexpected remote file is a hard stop; the script does not plan or perform removals.
6. Confirm `CF_API_TOKEN_PURGE` and `CF_ZONE_ID` are present and nonempty in the local `$HOME/.env` without retaining or printing their values. `CF_API_TOKEN_READ` does not satisfy this gate. Missing or empty purge credentials are a hard stop before any deployment write, not a reason to skip the mandatory purge.

## Backup and transfer

1. Create a timestamped backup of the entire prior document root under `/home/zxc-funnel/tech-backups/`, outside that root. Preserve file contents, modes, ownership where permitted, and the prior sorted SHA-256 manifest. Record the backup path in the deployment evidence.
2. Keep backups out of Git and out of the public document root. Do not include `.env` files or other secret-bearing material.
3. Transfer only the explicit manifest. Do not use `rsync --delete` against the document root; reconcile unexpected files explicitly so an unreviewed file cannot be removed or published.
4. Verify every transferred file against the source SHA-256 manifest and verify the exact remote filename set. A checksum or set mismatch is a hard failure before restart.

## Restart and local probes

After transfer and parity pass:

1. Restart only `tech-static.service` using the approved privileged deployment path.
2. Require `active/running` and `enabled`, then retry the service-owned listener check on `127.0.0.1:8087` at 2-second intervals for up to 20 seconds. Exhausting that bounded readiness window is a hard failure.
3. Probe the local origin at `http://127.0.0.1:8087/`, `/llms.txt`, `/sitemap.xml`, `/robots.txt`, `/openapi.json`, and every public article URL.
4. Require HTTP 200 from the local origin. The local verifier separately checks source XML/JSON, links, indexes, and topology; post-transfer SHA-256 and exact-filename parity verify the deployed bytes. The HTTP probes themselves do not inspect content type or response-body checksums.
5. Confirm the generated root listing includes `history.md`, `deployment.md`, and the rest of the deployed manifest without creating an index page. This is a manual/evidence review in addition to the scripted HTTP 200 probe.

## Public verification and mandatory Cloudflare purge

After local probes pass, verify the canonical public origin at `https://tech.telegram365books.stream/` with the same URL and HTTP 200 checks. Public HTTP 200 establishes reachability; it does not replace the separate local content validation, SHA-256 parity, or manual generated-root-listing review.

Every deployment to the Google VM then requires a full-zone Cloudflare cache purge. The controlled script must:

1. Read `CF_API_TOKEN_PURGE` and `CF_ZONE_ID` from the operator's local `$HOME/.env` only inside the protected execution context and never emit their values. Do not use `CF_API_TOKEN_READ`, and do not copy either credential to the VM.
2. POST to the Cloudflare cache-purge endpoint for that zone with the exact payload `{"purge_everything":true}`.
3. Require a successful HTTP response and a response body whose `success` field is `true`. Print only redacted status/result metadata.
4. Re-run local content validation and public HTTP 200 probes for the canonical root and every sitemap URL. Review the generated root listing again as deployment evidence; the scripted probes do not inspect response bodies.

A missing token, HTTP error, unsuccessful API result, failed post-purge probe, or unexecuted purge block means the deployment is **not complete**. Do not report success or create a deployment-success commit.

## Rollback

Trigger rollback on any transfer, checksum, restart, listener, local-probe, public-probe, or purge failure:

1. Stop further changes and preserve redacted failure evidence plus the failed source/remote checksum manifests.
2. Restore the complete timestamped pre-deployment backup to `/home/zxc-funnel/tech.eb2026`, including the prior file set and modes.
3. Restart only `tech-static.service`; require active state and the expected `127.0.0.1:8087` listener.
4. Re-run local and public probes and verify the restored checksums/content.
5. Execute the same mandatory Cloudflare `purge_everything:true` operation again and require success, then re-run public checks.
6. Report the deployment as failed/rolled back. Do not claim completion. Fix the cause and repeat from preflight only after review.

## Completed deployment evidence

On 2026-11-28, an earlier deployment attempt was rolled back after the public verifier received HTTP 403 responses. The prior 18-file root and its public availability were restored and cache-purged before the retry.

The reviewed 23-file deployment then passed every required gate:

- A timestamped backup of the complete prior root was created outside the document root.
- Explicit transfer, all 23 SHA-256 values, and the exact remote filename set matched.
- Only `tech-static.service` was restarted; it remained active/enabled and owned `127.0.0.1:8087`.
- All 23 localhost URLs returned HTTP 200, followed by all 22 public sitemap URLs before purge.
- Cloudflare accepted the mandatory full-zone `purge_everything:true` request with HTTP 200 and `success=true`.
- All 22 public sitemap URLs returned HTTP 200 after purge.
- The generated public root listing linked all 23 deployed filenames.

This evidence applies to the completed deployment recorded on that date. Later deployments must produce fresh backup, parity, probe, purge, and post-purge evidence.

## Commit after verification

A local documentation commit may record reviewed source changes, but it is not proof of a successful production deployment. A deployment-success commit or completion claim may be made only after backup, checksum parity, restart, local/public probes, the mandatory successful full-zone purge, and post-purge verification are all recorded. Never push unless separately requested.

## Related

- [Architecture](architecture.md) — current host and service topology.
- [SSH](ssh.md) — direct access and read-only inspection rules.
- [State](state.md) — dated service/listener snapshot.
- [History](history.md) — former Oracle hosting and topology changes.
