# Stage editorial runtime wiring This slice is executable but does not itself deploy or submit a live proposal. Parent must promote this commit through the existing authenticated, serialized Stage CI. No Production, cron activation, approval, executor or publishing changes. `stage_runtime_provision` runs disposable tests and the clean approved-SHA gate before provisioning. It inspects the persistent target home and streams the reviewed Python source plus an exact 22-file package (installer, client, manifest and 19 allowlisted payloads) through `docker exec -i canina-hermes python3 -B`. It uses the container's configured identity, never host-UID writes into the home. The fixed package directory is `$HERMES_HOME/editorial-v4/runtime-package` (0700); source/package files and deployment marker are 0400. The 19 profile/status files are installed and verified by the existing installer; the six skill paths are checked by actual `hermes skills list` calls under each profile home. No profile config.yaml is replaced. A dedicated random 64-character PMO credential is generated within the target at `credentials/editorial-pmo-token` (0400, runtime owner). Existing runtime-owned credentials directories may be 0700 or non-writable-by-others 0755 without changing unrelated files. Only the digest crosses back to CI. CI atomically extends the fixed backend four-field secret, preserving existing worker/CI identities and digests; conflicts fail closed. Backend grants remain 0400 and owned by its mapped UID/GID. Repeat Stage provisioning validates the optional canonical third PMO grant rather than rejecting its own installation. Clean approved SHA is checked again at the wiring entrypoint. ## Verify after successful Stage CI On the remote host: ```sh docker exec canina-hermes sh -c 'python3 -B "$HERMES_HOME/editorial-v4/runtime-package/installer.py" verify --target-home "$HERMES_HOME"' for profile in pmo canina-competitor-worker canina-seo-worker canina-content-worker canina-vet-review-worker canina-qa-worker; do docker exec -e HERMES_HOME="/opt/data/profiles/$profile" canina-hermes /opt/hermes/bin/hermes skills list done ``` Target home `/opt/data` was confirmed read-only during development. CI derives it from inspect rather than hardcoding it. These commands are not evidence that installation happened before promotion. ## Submit FROM target only Owner/PMO supplies a private runtime-owned 0400 JSON file, e.g. `/opt/data/editorial-v4/owner-proposal.json`, containing exactly `researchTopic` and `acceptanceCriteria` as described in `backend/src/orchestration-worker/editorial-bridge.md`. No sample topic/content is authored by this provisioning slice. ```sh docker exec canina-hermes sh -c 'python3 -B "$HERMES_HOME/editorial-v4/runtime-package/client.py" --proposal-file "$HERMES_HOME/editorial-v4/owner-proposal.json"' ``` The CLI accepts no URL, credential, actor, budget or commit override. It reads the deployment SHA installed by the approved CI rollout and posts only to `https://stageapi.canina.ir/api/internal/prepare-worker/editorial-proposals`, disables redirects and ambient proxies, sends Bearer PMO authentication, and fixes PREPARE/staging/editorial scope/pilot/budget20. Only taskId/requestId are returned. Confirm successful deployed SHA in CI before submitting. The stable request body is saved privately in `editorial-v4/client-state/proposal.json` before the first HTTP attempt. Retry the same invocation after timeout, denial or unknown outcome. Changed immutable proposal/SHA is refused; do not delete the state to retry an ambiguous request. This client intentionally represents one bounded pilot; starting a different proposal requires separate owner review, not automatic state reset. The proposal endpoint creates Gate1 pending only; genuine independent authenticated panel review is still required. This commit performs no live approval and claims no ten-step editorial execution. ## Tests ```sh PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s scripts/tests PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s infra/hermes-editorial/tests PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s scripts -p test_editorial_provision.py bash -n scripts/rollout-stage.sh git diff --check ``` Verified 15 existing script tests, six installer/client tests and one real disposable runtime-install/grant test. HTTP tests exercise a real local TCP server (401/403/409/redirect denial, bounded timeout, identical retry body and changed-SHA rejection). Stage wiring tests execute streamed source against a private home and real Compose rendering, preserving existing grants over repeat provisioning; Docker/DB reads are isolated fixtures and no live install occurs in tests.