Files
ZitPlane/notes/P05-OIDC-08-A02.md
T

80 lines
13 KiB
Markdown
Raw Normal View History

# P05-OIDC-08-A02 — Docker Compose Normalized Zero-Replica RCA & Full Synthetic Contract Acceptance
**Date:** 2026-11-23 (Asia/Dhaka).
**Approved immutable baseline:** `eaf299f36ff12e625657521f97bd1d269904eaec`, live Gitea `main` independently matched.
**Previous CI:** [Gitea Run #102](https://dev.ivib.cc/vibtools/ZitPlane/actions/runs/102), Job #218 `completed/failure`, source-tested `07c91ea5bcb2037e3c7b76261e1eb106b49d223f`. Synthetic Compose `config --quiet` PASS, all five services emitted safe `command: null` and `entrypoint: null`, previous `RUNTIME_BEHAVIOR` blocker resolved, next `ZITPLANE_P08_FAIL_CLOSED_DEPLOY_DISABLED` FAIL. Original 25 and four new runtime negative fixtures NOT EXECUTED; manual-only/no Docker resource action policy PASS, Gitea task cleanup PASS.
**Prior real login acceptance:** imported source-built Login V2 [Run #99](https://dev.ivib.cc/vibtools/ZitPlane/actions/runs/99) separate disposable OIDC success, unchanged; not production authentication.
**Initial tracked file inventory:** 785; untracked root `AI_INSTRUCTIONS.md` must remain untouched.
## Pre-source-change exact Scope Lock (user APPROVED)
**FIRST WRITE:** commit `notes/P05-OIDC-08-A02.md` **before any source edit**.
**SOURCE WRITE (EXACT, only):** `tests/ci/production_contract/validate.py`. Do not change the unchanged declarative fixture `deployment/production-contract/compose.ci.yaml`, `routing-policy.json`, original manual workflow, or any other source.
**DOCUMENTATION WRITE:** `notes/**`, relevant `project/**`, `docs/**`, and necessary associated existing `README.md`/`MINIFEST.md` files.
**STRICT READ-ONLY:** `auth/**`, `users/**`, `core/**`, all `deployment/**`, all existing `.gitea/workflows/**`, all `tests/**` except the approved validator and associated documentation, all package manifests/lockfiles, runner setup, live DNS/VPS/Coolify/Cloudflare/SSL, production secrets/infrastructure, unrelated files and untracked `AI_INSTRUCTIONS.md`.
**PROHIBITED:** local application builds/tests, Docker Compose `up`/`run`/`build`/`pull`, service startup or image publish, real DNS/TLS queries, production secret or user creation, registration, production deployment, tags/releases, repeated CI dispatch or post-run source patch. This is a synthetic source-based static contract only.
## Evidence and implementation gate
1. First inspect read-only the prior validator, unchanged synthetic YAML/JSON, workflow and previous Run #102. The checked-in YAML `compose.ci.yaml` explicitly declares `deploy:\n replicas: 0` in **each of five** service blocks (`ingress-policy`, `zitadel-api`, `zitadel-login`, `account`, `postgres`). Its actual Docker Compose JSON normalization of those declarations is **UNKNOWN** before this phase's approved one-shot CI.
2. Modify **only** the validator to emit sanitized, allowlisted service identifiers and safe `deploy` presence/object shape, `replicas` present/missing and type/classified zero/nonzero values; no arbitrary keys, input values, URLs, environments, secrets, full JSON or unsafe logs. Reuse the previously approved safe null runtime-field diagnostics.
3. Verify raw synthetic YAML **read-only from the tracked repository** for *exactly* five canonical service blocks, **one** exact `deploy: replicas: 0` per block and no additional replica entries. Require a separate normalized JSON security check, which can accept **only** an explicitly verified harmless omission of a zero in this known fixture if Compose normalization drops it. Do not generally interpret missing replica as safe for arbitrary Compose files; no broad bypass. A normalized nonzero integer/string/bool, extra deployment keys, unfamiliar field, deployable image, nonempty command/entrypoint/config, build, privileged access, Docker socket, published port, wrong network or missing secret must fail closed.
4. Preserve all existing **25** original negative fixtures and **4** runtime negative fixtures. Add a focused explicit nonzero replica mutation (if needed), strict expected `DEPLOY_DISABLED` failure class and safe positive static markers.
5. Focused pre-CI exact source/security diff audit, commit and push the source; **exactly one separately approved** existing manual `p05-production-contract-dry-run.yml` Gitea CI run on that SHA. Validate `docker compose config --quiet`, policy positive checks (issuer/callback, Login V2/Console/API h2c, Host/Forwarded, private network/no ports/secret refs), all original 25 and four new negatives plus zero-replica negative, manual-only workflow safety and runner-owned task cleanup. On failure, stop, document actual evidence and propose a separately approved narrow correction, **no rerun**.
6. Synchronize notes/project/docs, appropriate README/MINIFEST/inventory, perform one cumulative scope/secret/diff audit, commit/push documentation and verify exact remote Gitea `main` SHA. Report **PASS/FAIL/NOT EXECUTED**; documentation SHA is not the CI source-tested SHA.
## Terminal Gitea CI — One-run A02 acceptance and forensic root-cause narrowing
**Pre-source Scope Lock committed FIRST:** `798f87864414c81ecf50b9fc58f078ac338e5747`. The only source modification was `tests/ci/production_contract/validate.py` in tested SHA `45a2edb854acd98546e60a68482075bc5f742bd2`; manual workflow, Compose YAML, routing-policy JSON, all other application/CI files and production resources unchanged. Pre-CI exact scope/security audit confirmed only the new A02 note and approved validator changed; original 25, runtime four and new three replica negatives present in source. No local tests/builds or independent Docker environment execution.
**Exactly one manual CI run:** [Gitea Run #103](https://dev.ivib.cc/vibtools/ZitPlane/actions/runs/103), Job #219, immutable source `45a2edb854acd98546e60a68482075bc5f742bd2`. Terminal **`completed/failure`**; 2026-11-23T13:10:43Z to 13:11:07Z. Step #0 toolchain SUCCESS, #1 checkout SUCCESS, #2 static Compose+validator FAILURE, #3 `always()` workflow-safety SUCCESS. No rerun, no post-dispatch code edit, no production/service startup.
| Acceptance checkpoint | Terminal evidence (PASS / FAIL / NOT EXECUTED) |
| --- | --- |
| `docker compose config --quiet` syntax/shape validation | **PASS** `ZITPLANE_P08_COMPOSE_STATIC_CONFIG_PASS` |
| Source fixture original five `deploy.replicas: 0` declarations | **PASS** `ZITPLANE_P08_SOURCE_ALL_FIVE_REPLICAS_ZERO_PASS` |
| Docker-normalized inert `command: null` and `entrypoint: null` in five synthetic services | **VERIFIED** with the 10 allowlisted field/type-only markers from A01, unchanged |
| Actual normalized `deploy` mapping for five services | **VERIFIED** via `ZITPLANE_P08_NORMALIZED_DEPLOY_*_OBJECT` — each is a nonempty object |
| Actual normalized `deploy.replicas` for five services | **VERIFIED** via `ZITPLANE_P08_NORMALIZED_DEPLOY_*_REPLICAS_INT_ZERO` — all integer 0, no missing/string/nonzero |
| Additional normalized `deploy` keys | **VERIFIED PRESENT** via `ZITPLANE_P08_NORMALIZED_DEPLOY_*_UNEXPECTED_FIELDS_PRESENT` on **all five**; exact names, safe type, values and behavioral effects **UNKNOWN** (not logged) |
| Strict normalized deployment safety allowlist | **FAIL** `ZITPLANE_P08_FAIL_CLOSED_DEPLOY_DISABLED`; unexpected extra deploy keys, not zero-replica mismatch |
| Synthetic canonical HTTPS issuer/callback, h2c Login/Console/API, headers, private network, no-port/secret final success markers | **NOT REACHED / NOT INDEPENDENTLY VERIFIED** after early fail |
| Original 25 negative fixtures | **NOT EXECUTED** (source present, validator never entered `negative_cases()`) |
| Four nonempty runtime field negative fixtures | **NOT EXECUTED** |
| Three additional string/bool/extra-deploy replica negative fixtures | **NOT EXECUTED** |
| Workflow manual-only/no Docker lifecycle action configuration | **PASS** `ZITPLANE_P08_MANUAL_ONLY_NO_RESOURCE_ACTIONS_CONFIGURED_PASS` during run and in `always()` step |
| Gitea ephemeral job resources removed | **PASS** in terminal job log: task container, its two volumes and task network removed; does NOT inspect production |
| Live production DNS, HTTPS/TLS, master key, PATs, images, Console/MFA/SSO, backup/restore, users or deployment | **NOT EXECUTED / OUT OF SCOPE** |
### What this resolves, and what remains unknown
**A02 actually settled the Run #102 replicas ambiguity:** The unchanged source explicitly requests five numeric zero replicas, and the normalized Compose JSON **retains all five as integer 0**. The `DEPLOY_DISABLED` block now has a much narrower proven cause: **additional top-level fields inside each normalized `deploy` object**, not missing or nonzero replicas. The current exact-key validator restricts `set(deploy)` to subset `{"replicas"}`, so it correctly fails closed when the additional keys appear. **No actual extra deploy key name or semantics were measured**. Do not assume `resources`, `restart_policy`, `placement`, `mode` or any other particular key. Do not accept unknown deploy fields or reinterpret a different deployment mode as inert.
**A02 result:** partial RCA PASS (source=0 and normalized=integer zero), full static contract CI **FAILED**; all 32 invalid fixtures (25+4+3) **NOT EXECUTED**. The existing successful [Run #99](https://dev.ivib.cc/vibtools/ZitPlane/actions/runs/99) imported Login V2 custom-source *disposable HTTP localhost* browser OIDC success stands separately. Nothing public/production is verified.
### Prioritized remaining blockers
- **P0 / next CI:** identify exact additional Compose-normalized `deploy` field names, allowlisted safe types/empty-vs-nonempty, evaluate whether truly inert and fail closed on dangerous settings; reverify the full positive static contract and 25+4+3 invalid fixtures. **Do not change Compose/YAML or existing workflow.**
- **P0 / later production phases:** immutable source-built image provenance and current dependency security, secure master-key/PAT/client-secret custody and encrypted PostgreSQL backup/restore/break-glass, canonical real HTTPS ingress/issuer/h2c and strict cookies/redirects.
- **P1 / separate acceptance:** Admin Console cutover/recovery, real MFA/passkeys/SMTP and multi-app SSO. Not bundled into this static contract RCA.
### Proposed next exact Scope Lock — P05-OIDC-08-A03 (SEPARATE APPROVAL REQUIRED)
**Title:** Safe Extra `deploy` Normalization RCA & Complete Static Security Contract Gate.
**Baseline:** final A02 documentation closure Gitea SHA (verify and copy in approval). Prior tested source `45a2edb854acd98546e60a68482075bc5f742bd2`, existing Run #103 / Job #219 `completed/failure`.
1. **Commit `notes/P05-OIDC-08-A03.md` first**, with approved baseline and exact read/write security scope, before new source edit.
2. **SOURCE WRITE ONLY** `tests/ci/production_contract/validate.py`. **DOCS WRITE** `notes/**`, relevant `project/**`, `docs/**` and necessary associated README/MINIFEST. All `deployment/**`, existing `.gitea/workflows/**`, `auth/**`, `users/**`, `core/**`, other `tests/**`, manifests/locks, runner settings, live DNS/VPS/Coolify/SSL/secrets and unrelated files strictly **READ ONLY**. Preserve untracked `AI_INSTRUCTIONS.md`.
3. Add strictly safe diagnostics of the **extra normalized `deploy` field names** from a predefined finite allowlist of known Compose deployment metadata and only type/empty/nonempty categories; unknown keys must be classified as **UNKNOWN_KEY_PRESENT**, never printed. Do not print raw JSON, values, arbitrary key names, credentials, URLs, Host headers or secrets. The actual names/types from Run #103 are **unknown** now.
4. Verify canonical raw source still has exactly five `replicas: 0` and no other deployment directives, with normalized five true integer zero replicas. **Only if grounded in evidence** approve specifically named **semantically inert** Compose-added default fields (and safe shapes) while rejecting deployment-capable nonempty placement/mode/resources/update/restart/replica behavior. Do not broadly allow all `deploy` keys or remove `DEPLOY_DISABLED`.
5. Preserve original **25**, runtime **4**, replica **3** targeted negative checks and strengthen with an explicit nonempty/unknown-extra deploy-key rejection fixture (only if necessary). Reject Docker lifecycle, unsafe ingress/headers, missing secrets, altered issuer/callback, real images, public ports or mutable app security policies.
6. Perform one focused source/security/diff audit, commit/push tested SHA and dispatch **exactly one independently approved** manual `p05-production-contract-dry-run.yml` Gitea run; record source static parse, positive issuer/route/headers/secrets/private network/zero replicas, 25+4+3 (and any extra) negative fixtures and `always()` workflow safety as PASS/FAIL/NOT EXECUTED. If fails, stop; no repeated CI, no post-run source patch.
7. Synchronize notes/project/docs and associated manifests, one cumulative exact diff/inventory/secret audit, push documentation and verify remote SHA. No local app test, service startup, DNS/TLS/production data, secret generation, registry, tag or release.
**No A03 implementation without separate user approval.**