diff --git a/FILE_INDEX.md b/FILE_INDEX.md index 25e2fdc..85802e9 100644 --- a/FILE_INDEX.md +++ b/FILE_INDEX.md @@ -39,6 +39,8 @@ https://github.com/Open-Factory-Initiative/Factory-Intelligence-Platform - `docs/GOVERNED_ACTIONS.md` — recommendation and approval model - `docs/API_DESIGN.md` — initial API shape - `docs/TESTING.md` — unit/integration/contract/e2e strategy +- `docs/runtime/DOCKER_COMPOSE.md` — Docker Compose runtime guide +- `docs/runtime/TROUBLESHOOTING.md` — local runtime troubleshooting guide - `docs/DEVELOPMENT.md` — local development workflow - `docs/DOCUMENTATION.md` — documentation standards - `docs/OBSERVABILITY.md` — logging/metrics/traceability direction diff --git a/README.md b/README.md index 8f480f2..04fcf55 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,10 @@ curl http://localhost:8000/health docker compose -f infra/docker/docker-compose.yml down ``` +Use `docker compose down` for normal shutdown. Use +`docker compose -f infra/docker/docker-compose.yml down -v` only when you +intentionally want to delete FIP named volumes, such as local Postgres data. + Some Compose services are still landing in follow-up issues. Until then, contributors can run the API and Workbench directly for focused development: @@ -134,6 +138,10 @@ http://127.0.0.1:3000 - `docs/DEMO_RUNBOOK.md` - current Docker/Demo-Factory runtime direction and transition notes. +- `docs/runtime/DOCKER_COMPOSE.md` - detailed Docker Compose startup, + shutdown, rebuild, logs, health-check, and reset commands. +- `docs/runtime/TROUBLESHOOTING.md` - Docker daemon, port, Postgres, + connector, API, and Workbench troubleshooting. - `docs/demo/OPERATIONS_WORKBENCH_DEMO_RUNBOOK.md` - Workbench runtime notes for the operator console. - `docs/demo/MANUFACTURER_DEMO_RUNBOOK.md` - manufacturer discussion framing. @@ -149,6 +157,7 @@ http://127.0.0.1:3000 Run these before opening a pull request: ```bash +docker compose -f infra/docker/docker-compose.yml config make lint make typecheck make test diff --git a/apps/web/README.md b/apps/web/README.md index e74c82f..45aabfa 100644 --- a/apps/web/README.md +++ b/apps/web/README.md @@ -46,6 +46,10 @@ NEXT_PUBLIC_API_BASE_URL=http://127.0.0.1:8001 npm run dev ## Runtime Direction +Use `../../docs/runtime/DOCKER_COMPOSE.md` for the detailed local runtime guide +and `../../docs/runtime/TROUBLESHOOTING.md` when Docker, API, or Workbench +startup fails. + Start Demo-Factory separately from its sibling checkout: ```bash @@ -58,6 +62,10 @@ Start FIP from this repository: ```bash cd ../Factory-Intelligence-Platform docker compose -f infra/docker/docker-compose.yml up --build +docker compose -f infra/docker/docker-compose.yml ps +docker compose -f infra/docker/docker-compose.yml logs -f +curl http://localhost:8000/health +docker compose -f infra/docker/docker-compose.yml down ``` For focused Workbench development before all Compose services land, run the API @@ -88,6 +96,8 @@ electronic-signature, or compliance claim. ## Related Docs +- `../../docs/runtime/DOCKER_COMPOSE.md` +- `../../docs/runtime/TROUBLESHOOTING.md` - `../../docs/demo/OPERATIONS_WORKBENCH_DEMO_RUNBOOK.md` - `../../docs/demo/MANUFACTURER_DEMO_RUNBOOK.md` - `../../docs/demo/TROUBLESHOOTING.md` diff --git a/docs/DEMO_RUNBOOK.md b/docs/DEMO_RUNBOOK.md index 5d5f7eb..db515d0 100644 --- a/docs/DEMO_RUNBOOK.md +++ b/docs/DEMO_RUNBOOK.md @@ -5,6 +5,10 @@ This runbook replaces the old in-repo generated-data demo path as the current runtime direction for the Factory Intelligence Platform. +For detailed Docker Compose startup, shutdown, rebuild, logs, health-check, +reset, expected URL, and troubleshooting commands, use +`docs/runtime/DOCKER_COMPOSE.md` and `docs/runtime/TROUBLESHOOTING.md`. + Demo-Factory is now the separate local source/simulation repository. FIP should consume external Demo-Factory protocol data through read-only connectors, then normalize readings into FactoryEvents for Process Sentinel, the API, and the @@ -46,6 +50,10 @@ curl http://localhost:8000/health docker compose -f infra/docker/docker-compose.yml down ``` +Use `docker compose down` for normal shutdown. Use +`docker compose -f infra/docker/docker-compose.yml down -v` only when you +intentionally want to delete FIP named volumes such as local Postgres data. + The Compose runtime is being built across the Dockerized runtime epic. Some services may be placeholders until the child issues for API/web images, connector worker, Postgres-backed runtime storage, Sentinel worker, and Compose diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md index 49be745..a80a47d 100644 --- a/docs/DEVELOPMENT.md +++ b/docs/DEVELOPMENT.md @@ -58,6 +58,10 @@ git checkout -b feat/read-only-runtime-slice The current direction is a Docker Compose runtime that consumes external Demo-Factory protocol data through read-only connectors. +Use `docs/runtime/DOCKER_COMPOSE.md` as the detailed runtime guide and +`docs/runtime/TROUBLESHOOTING.md` for Docker daemon, port conflict, Postgres, +connector, API, and Workbench failures. + Start Demo-Factory separately from a sibling checkout: ```bash @@ -76,6 +80,10 @@ curl http://localhost:8000/health docker compose -f infra/docker/docker-compose.yml down ``` +Use `docker compose down` for normal shutdown. Use +`docker compose -f infra/docker/docker-compose.yml down -v` only when you +intentionally want to delete FIP named volumes such as local Postgres data. + Some Compose services are still landing through the Dockerized runtime epic. For focused API or Workbench development before the full composed stack is available, run: diff --git a/docs/LEARNING_LOG.md b/docs/LEARNING_LOG.md index 3f40612..50c09ad 100644 --- a/docs/LEARNING_LOG.md +++ b/docs/LEARNING_LOG.md @@ -22,6 +22,67 @@ This file should be updated by Codex after each meaningful change. ### What to learn next ``` +## 2026-05-26 - Docker Compose runtime documentation + +### What changed + +Added `docs/runtime/DOCKER_COMPOSE.md` and +`docs/runtime/TROUBLESHOOTING.md` as the detailed local runtime references for +running FIP alongside the separate Demo-Factory source stack. + +### Why it matters + +Contributors now have one place for startup, shutdown, rebuild, logs, +health-check, reset, expected URL, and troubleshooting commands while the +Dockerized runtime epic lands service by service. + +### How it works + +The runtime docs keep the dependency order explicit: start Demo-Factory first, +then start FIP. Demo-Factory provides local development source fixtures, while +FIP consumes those sources through read-only connectors, normalizes readings +into FactoryEvents, and exposes API and Workbench views over platform state. + +### How to run it + +```bash +cd ../Demo-Factory +docker compose up -d --build + +cd ../Factory-Intelligence-Platform +docker compose -f infra/docker/docker-compose.yml up --build +docker compose -f infra/docker/docker-compose.yml ps +docker compose -f infra/docker/docker-compose.yml logs -f +curl http://localhost:8000/health +docker compose -f infra/docker/docker-compose.yml down +``` + +Use `docker compose -f infra/docker/docker-compose.yml down -v` only when +intentionally deleting FIP named volumes such as local Postgres data. + +### How to test it + +```bash +.venv/bin/python -m pytest services/simulator/tests/test_docker_compose_runtime_docs.py +docker compose -f infra/docker/docker-compose.yml config +make test +make lint +make typecheck +cd apps/web && npm test +``` + +### Key files + +- `docs/runtime/DOCKER_COMPOSE.md` +- `docs/runtime/TROUBLESHOOTING.md` +- `services/simulator/tests/test_docker_compose_runtime_docs.py` + +### What to learn next + +Use these runtime docs as the command baseline while adding Postgres-backed +storage, service images, connector workers, scheduled Sentinel execution, and +Compose smoke tests in the remaining Dockerized runtime issues. + ## 2026-05-26 - Runtime documentation direction cleanup ### What changed diff --git a/docs/TESTING.md b/docs/TESTING.md index 4d57363..7f1c2b5 100644 --- a/docs/TESTING.md +++ b/docs/TESTING.md @@ -86,6 +86,39 @@ state. It is retained for compatibility while the Compose smoke path is being introduced. Prefer the Docker/Demo-Factory runtime path for new documentation and issue work. +## Docker Compose Runtime Checks + +Detailed runtime commands live in `docs/runtime/DOCKER_COMPOSE.md`, with +troubleshooting in `docs/runtime/TROUBLESHOOTING.md`. + +Validate the FIP Compose file without starting containers: + +```bash +docker compose -f infra/docker/docker-compose.yml config +``` + +Start Demo-Factory before FIP when validating the local runtime: + +```bash +cd ../Demo-Factory +docker compose up -d --build +``` + +Start, inspect, and stop FIP: + +```bash +cd ../Factory-Intelligence-Platform +docker compose -f infra/docker/docker-compose.yml up --build +docker compose -f infra/docker/docker-compose.yml ps +docker compose -f infra/docker/docker-compose.yml logs -f +curl http://localhost:8000/health +docker compose -f infra/docker/docker-compose.yml down +``` + +Use `docker compose down` for normal shutdown. Use +`docker compose -f infra/docker/docker-compose.yml down -v` only when a test or +manual reset intentionally deletes FIP named volumes. + ## Backend Testing Current tools: diff --git a/docs/runtime/DOCKER_COMPOSE.md b/docs/runtime/DOCKER_COMPOSE.md new file mode 100644 index 0000000..bccfb1e --- /dev/null +++ b/docs/runtime/DOCKER_COMPOSE.md @@ -0,0 +1,164 @@ +# Docker Compose Runtime + +## Purpose + +This document is the current local runtime guide for running the Factory +Intelligence Platform alongside the separate Demo-Factory source stack. + +Target runtime flow: + +```text +Demo-Factory protocols +-> FIP read-only connector worker +-> FactoryEvent ingestion and storage +-> Process Sentinel worker +-> FastAPI API +-> Next.js Workbench +``` + +The Dockerized runtime is being built across epic #232. Some FIP services may +remain placeholders until the child issues for Postgres-backed storage, service +images, connector worker, Sentinel worker, Workbench/API wording, and Compose +smoke tests land. Keep using the commands below as the shared local runtime +shape while those pieces are added. + +## Dependency Order + +Start Demo-Factory first. It is the local development source fixture for +industrial-style protocol data. Demo-Factory validation is not production +validation evidence and must not be used to claim validated GxP use, +electronic signatures, compliance status, or production readiness. + +Then start FIP. FIP should consume Demo-Factory protocol data through read-only +connectors, normalize readings into FactoryEvents, and expose API and +Workbench views over platform state. + +## Start Demo-Factory + +From a sibling checkout: + +```bash +cd ../Demo-Factory +docker compose up -d --build +``` + +Useful Demo-Factory checks: + +```bash +docker compose ps +docker compose logs -f +``` + +## Start FIP + +From this repository: + +```bash +cd ../Factory-Intelligence-Platform +docker compose -f infra/docker/docker-compose.yml up --build +``` + +Use `--build` when Dockerfiles, dependency files, or Compose service +configuration changed. If you only need to restart existing containers without +rebuilding images, use: + +```bash +docker compose -f infra/docker/docker-compose.yml up +``` + +## Inspect FIP + +List containers and their health: + +```bash +docker compose -f infra/docker/docker-compose.yml ps +``` + +Follow logs for all FIP services: + +```bash +docker compose -f infra/docker/docker-compose.yml logs -f +``` + +Follow one service when troubleshooting: + +```bash +docker compose -f infra/docker/docker-compose.yml logs -f postgres +``` + +Check API health when the API container is available: + +```bash +curl http://localhost:8000/health +``` + +Validate the Compose file without starting containers: + +```bash +docker compose -f infra/docker/docker-compose.yml config +``` + +## Expected Local URLs + +| Surface | URL | Notes | +| --- | --- | --- | +| API health | `http://localhost:8000/health` | FastAPI health endpoint once the API service is in Compose. | +| OpenAPI docs | `http://localhost:8000/docs` | FastAPI interactive API docs. | +| Workbench | `http://localhost:3000` | Next.js Operations Workbench once the web service is in Compose. | +| Workbench protocol diagnostics | `http://localhost:3000/protocol-diagnostics` | UI for read-only connection and mapping diagnostics. | +| Connection profiles API | `http://localhost:8000/connection-profiles` | Read/list configured connection profiles. | +| Connection test API | `POST http://localhost:8000/connection-profiles/{profile_id}/test` | Read-only diagnostic endpoint; must not write to protocol sources. | + +## Stop FIP + +Stop and remove FIP containers and networks while keeping named volumes: + +```bash +docker compose -f infra/docker/docker-compose.yml down +``` + +Use this for normal shutdown. It keeps local Postgres data and other named +volumes so the next startup can reuse state. + +## Reset FIP Volumes + +Reset FIP volumes only when intended: + +```bash +docker compose -f infra/docker/docker-compose.yml down -v +``` + +Use `down -v` only when you intentionally want to delete named volumes, such as +resetting local Postgres data or clearing a broken local runtime state. Do not +use it when you need to preserve ingested events, connection profiles, or other +state for debugging. + +## Rebuild After Dependency Changes + +When service dependencies or Dockerfiles change, rebuild FIP: + +```bash +docker compose -f infra/docker/docker-compose.yml up --build +``` + +If a future issue adds multiple service images and only one service needs a +rebuild, prefer rebuilding that service by name once it exists: + +```bash +docker compose -f infra/docker/docker-compose.yml up --build api +``` + +## Safety Boundary + +The local runtime remains read-only toward external industrial-style sources. +FIP must not perform industrial writeback, arbitrary tag writes, MQTT command +publishing, BACnet writes, product disposition, QMS/MES integration, or +production CAPA creation. + +Demo-Factory is a local development source fixture. It is useful for protocol +integration and smoke testing, but it is not production validation evidence. + +## Troubleshooting + +Use `docs/runtime/TROUBLESHOOTING.md` for Docker daemon, port conflict, +Postgres, connector, API, and Workbench failures. diff --git a/docs/runtime/TROUBLESHOOTING.md b/docs/runtime/TROUBLESHOOTING.md new file mode 100644 index 0000000..701575c --- /dev/null +++ b/docs/runtime/TROUBLESHOOTING.md @@ -0,0 +1,199 @@ +# Runtime Troubleshooting + +Use this guide for the local Docker Compose runtime documented in +`docs/runtime/DOCKER_COMPOSE.md`. + +## Docker Daemon Is Not Running + +Symptoms: + +- `Cannot connect to the Docker daemon` +- `docker compose` exits before reading the Compose file +- Docker Desktop is not started + +Checks: + +```bash +docker version +docker compose -f infra/docker/docker-compose.yml config +``` + +Fix: + +Start Docker Desktop or your compatible Docker runtime, then rerun: + +```bash +docker compose -f infra/docker/docker-compose.yml up --build +``` + +## Demo-Factory Is Not Running + +FIP should consume protocol data from the separate Demo-Factory source stack. +Start it before FIP: + +```bash +cd ../Demo-Factory +docker compose up -d --build +docker compose ps +docker compose logs -f +``` + +Demo-Factory is a local development source fixture, not production validation +evidence. + +## Port Conflict + +Symptoms: + +- Docker reports a port is already allocated. +- API, Workbench, Postgres, or protocol fixture ports fail to bind. + +Expected local ports include: + +- API: `8000` +- Workbench: `3000` +- Postgres: `5432` +- Demo-Factory protocol services: owned by the Demo-Factory checkout + +Checks: + +```bash +docker compose -f infra/docker/docker-compose.yml ps +docker compose -f infra/docker/docker-compose.yml logs -f +``` + +Fix: + +Stop the conflicting local process or adjust the development port in the +service configuration. Use `docker compose down` for normal FIP shutdown: + +```bash +docker compose -f infra/docker/docker-compose.yml down +``` + +Do not use `docker compose down -v` for a port conflict unless you also intend +to delete FIP named volumes. + +## Postgres Fails Health Checks + +Symptoms: + +- `postgres` is unhealthy in `docker compose ps`. +- API or workers cannot connect to the event store. +- Logs mention authentication, database startup, or schema initialization. + +Checks: + +```bash +docker compose -f infra/docker/docker-compose.yml ps +docker compose -f infra/docker/docker-compose.yml logs -f postgres +``` + +Normal reset: + +```bash +docker compose -f infra/docker/docker-compose.yml down +docker compose -f infra/docker/docker-compose.yml up --build +``` + +Destructive reset when local volume state is intentionally disposable: + +```bash +docker compose -f infra/docker/docker-compose.yml down -v +docker compose -f infra/docker/docker-compose.yml up --build +``` + +Use `down -v` only when you intentionally want to delete local Postgres data and +other named volumes. + +## Connector Worker Cannot Reach Sources + +Symptoms: + +- Connector logs show refused connections or timeouts. +- No new FactoryEvents appear after startup. +- Protocol diagnostics show a failed read-only connection test. + +Checks: + +```bash +cd ../Demo-Factory +docker compose ps + +cd ../Factory-Intelligence-Platform +docker compose -f infra/docker/docker-compose.yml logs -f +curl http://localhost:8000/connection-profiles +``` + +Then use the read-only test endpoint for a configured profile: + +```bash +curl -X POST http://localhost:8000/connection-profiles/{profile_id}/test +``` + +Connector diagnostics must remain read-only. Do not troubleshoot by adding +OPC-UA writes, MQTT command publishing, BACnet writes, product disposition, or +QMS/MES integration. + +## API Is Not Healthy + +Symptoms: + +- `curl http://localhost:8000/health` fails. +- The Workbench cannot load platform state. +- OpenAPI docs are not available at `http://localhost:8000/docs`. + +Checks: + +```bash +docker compose -f infra/docker/docker-compose.yml ps +docker compose -f infra/docker/docker-compose.yml logs -f +curl http://localhost:8000/health +``` + +If the API service is not yet part of the Compose stack for the current issue, +use the focused local development loop: + +```bash +make api +``` + +## Workbench Is Not Loading + +Symptoms: + +- `http://localhost:3000` does not load. +- The Workbench loads but reports API connection errors. +- Protocol diagnostics are unavailable at + `http://localhost:3000/protocol-diagnostics`. + +Checks: + +```bash +docker compose -f infra/docker/docker-compose.yml ps +docker compose -f infra/docker/docker-compose.yml logs -f +curl http://localhost:8000/health +``` + +For focused Workbench development before the web service is available in +Compose: + +```bash +make api +cd apps/web +npm run dev +``` + +If the API runs on a non-default port: + +```bash +NEXT_PUBLIC_API_BASE_URL=http://127.0.0.1:8001 npm run dev +``` + +## Safety Boundary + +The local runtime is for read-only connector validation, FactoryEvent +normalization, Process Sentinel behavior, API checks, and Workbench rendering. +It must not perform industrial writeback, arbitrary tag writes, MQTT command +publishing, BACnet writes, product disposition, QMS/MES writeback, or +production CAPA creation. diff --git a/services/api/README.md b/services/api/README.md index 842eddf..ef07e1a 100644 --- a/services/api/README.md +++ b/services/api/README.md @@ -2,6 +2,11 @@ FastAPI shell for the Factory Intelligence Platform MVP. +For the Docker Compose runtime, start Demo-Factory first and then start FIP +using `docs/runtime/DOCKER_COMPOSE.md`. Use +`docs/runtime/TROUBLESHOOTING.md` for Docker daemon, port, Postgres, connector, +API, and Workbench failures. + The API currently exposes: - Health and event query endpoints. diff --git a/services/ingestion/README.md b/services/ingestion/README.md index d98a566..8b37573 100644 --- a/services/ingestion/README.md +++ b/services/ingestion/README.md @@ -20,6 +20,10 @@ Demo-Factory owns local source simulation. The ingestion service should treat protocol readings as external source data that has already passed through a read-only adapter boundary. +Use `docs/runtime/DOCKER_COMPOSE.md` for startup, shutdown, rebuild, logs, +health-check, and reset commands. Use `docs/runtime/TROUBLESHOOTING.md` for +Docker daemon, port conflict, Postgres, connector, API, and Workbench failures. + ## Safety Boundary Ingestion is a validation and persistence boundary. It must not perform diff --git a/services/process-sentinel/README.md b/services/process-sentinel/README.md index 2f35298..bb60029 100644 --- a/services/process-sentinel/README.md +++ b/services/process-sentinel/README.md @@ -33,6 +33,10 @@ Process Sentinel should consume normalized FactoryEvents from storage. It should not know whether those events originated from Demo-Factory fixtures, legacy generated local fixtures, or future read-only connectors. +Use `docs/runtime/DOCKER_COMPOSE.md` for the local Docker Compose runtime and +`docs/runtime/TROUBLESHOOTING.md` when Docker, Postgres, connector, API, or +Workbench checks fail. + ## Focused Development From the repository root: diff --git a/services/simulator/README.md b/services/simulator/README.md index 67cdca6..be5a383 100644 --- a/services/simulator/README.md +++ b/services/simulator/README.md @@ -19,7 +19,8 @@ in this directory available for legacy tests, historical fixtures, and narrowly scoped compatibility checks, but do not present it as the default FIP development or demo path. -For current runtime instructions, use `docs/DEMO_RUNBOOK.md`. +For current runtime instructions, use `docs/runtime/DOCKER_COMPOSE.md`, +`docs/runtime/TROUBLESHOOTING.md`, and `docs/DEMO_RUNBOOK.md`. Safety boundary: FIP remains read-only by default. This legacy fixture is not a production OPC-UA connector, and FIP must not perform industrial writeback, diff --git a/services/simulator/tests/test_docker_compose_runtime_docs.py b/services/simulator/tests/test_docker_compose_runtime_docs.py new file mode 100644 index 0000000..a0189ea --- /dev/null +++ b/services/simulator/tests/test_docker_compose_runtime_docs.py @@ -0,0 +1,124 @@ +from __future__ import annotations + +from pathlib import Path + +REPO_ROOT = Path(__file__).resolve().parents[3] +README = REPO_ROOT / "README.md" +DOCKER_COMPOSE_DOC = REPO_ROOT / "docs" / "runtime" / "DOCKER_COMPOSE.md" +TROUBLESHOOTING_DOC = REPO_ROOT / "docs" / "runtime" / "TROUBLESHOOTING.md" + +LINKING_DOCS = [ + REPO_ROOT / "README.md", + REPO_ROOT / "docs" / "DEMO_RUNBOOK.md", + REPO_ROOT / "docs" / "DEVELOPMENT.md", + REPO_ROOT / "docs" / "TESTING.md", + REPO_ROOT / "apps" / "web" / "README.md", + REPO_ROOT / "services" / "api" / "README.md", + REPO_ROOT / "services" / "ingestion" / "README.md", + REPO_ROOT / "services" / "process-sentinel" / "README.md", + REPO_ROOT / "services" / "simulator" / "README.md", +] + + +def _read(path: Path) -> str: + return path.read_text(encoding="utf-8") + + +def test_docker_compose_runtime_doc_includes_required_commands() -> None: + content = _read(DOCKER_COMPOSE_DOC) + readme = _read(README) + + required_commands = [ + "cd ../Demo-Factory", + "docker compose up -d --build", + "cd ../Factory-Intelligence-Platform", + "docker compose -f infra/docker/docker-compose.yml up --build", + "docker compose -f infra/docker/docker-compose.yml ps", + "docker compose -f infra/docker/docker-compose.yml logs -f", + "curl http://localhost:8000/health", + "docker compose -f infra/docker/docker-compose.yml down", + "docker compose -f infra/docker/docker-compose.yml down -v", + "docker compose -f infra/docker/docker-compose.yml config", + ] + + for command in required_commands: + assert command in content + + for command in [ + "docker compose -f infra/docker/docker-compose.yml up --build", + "docker compose -f infra/docker/docker-compose.yml ps", + "docker compose -f infra/docker/docker-compose.yml logs -f", + "curl http://localhost:8000/health", + "docker compose -f infra/docker/docker-compose.yml down", + "docker compose -f infra/docker/docker-compose.yml down -v", + ]: + assert command in readme + + +def test_docker_compose_runtime_doc_covers_urls_and_dependency_order() -> None: + content = _read(DOCKER_COMPOSE_DOC) + + required_terms = [ + "Start Demo-Factory first", + "Demo-Factory is a local development source fixture", + "http://localhost:8000/health", + "http://localhost:8000/docs", + "http://localhost:3000", + "http://localhost:3000/protocol-diagnostics", + "http://localhost:8000/connection-profiles", + "POST http://localhost:8000/connection-profiles/{profile_id}/test", + ] + + for term in required_terms: + assert term in content + + +def test_runtime_troubleshooting_covers_expected_failure_modes() -> None: + content = _read(TROUBLESHOOTING_DOC) + + required_sections = [ + "Docker Daemon Is Not Running", + "Demo-Factory Is Not Running", + "Port Conflict", + "Postgres Fails Health Checks", + "Connector Worker Cannot Reach Sources", + "API Is Not Healthy", + "Workbench Is Not Loading", + ] + + for section in required_sections: + assert section in content + + for command in [ + "docker version", + "docker compose -f infra/docker/docker-compose.yml config", + "docker compose -f infra/docker/docker-compose.yml logs -f postgres", + "curl http://localhost:8000/health", + "curl -X POST http://localhost:8000/connection-profiles/{profile_id}/test", + ]: + assert command in content + + +def test_runtime_docs_linked_from_required_entry_points() -> None: + for path in LINKING_DOCS: + content = _read(path) + assert "docs/runtime/DOCKER_COMPOSE.md" in content, str(path) + assert "docs/runtime/TROUBLESHOOTING.md" in content, str(path) + + +def test_runtime_docs_preserve_read_only_safety_boundary() -> None: + content = _read(DOCKER_COMPOSE_DOC) + "\n" + _read(TROUBLESHOOTING_DOC) + + required_terms = [ + "read-only", + "industrial writeback", + "arbitrary tag writes", + "MQTT command publishing", + "BACnet writes", + "product disposition", + "QMS/MES", + "not production validation evidence", + ] + + for term in required_terms: + assert term in content diff --git a/services/simulator/tests/test_runtime_docs_transition.py b/services/simulator/tests/test_runtime_docs_transition.py index ccc3e7f..4dbf5ba 100644 --- a/services/simulator/tests/test_runtime_docs_transition.py +++ b/services/simulator/tests/test_runtime_docs_transition.py @@ -19,6 +19,8 @@ REPO_ROOT / "docs" / "MVP_SCOPE.md", REPO_ROOT / "docs" / "SECURITY_MODEL.md", REPO_ROOT / "docs" / "START_HERE_FOR_CODEX.md", + REPO_ROOT / "docs" / "runtime" / "DOCKER_COMPOSE.md", + REPO_ROOT / "docs" / "runtime" / "TROUBLESHOOTING.md", REPO_ROOT / "prompts" / "03-synthetic-factory-simulator.md", REPO_ROOT / "docs" / "demo" / "DEMO_SAFE_COPY_GUIDELINES.md", REPO_ROOT / "docs" / "demo" / "MANUFACTURER_DEMO_RUNBOOK.md",