**Previous CI evidence:** Gitea Run [#81](https://dev.ivib.cc/vibtools/ZitPlane/actions/runs/81), tested `42b79362c13b9dbb07f85a58ad278742d91b1f5b`, overall FAILURE.
-`users/ui/src/types/next-auth.d.ts` — only if needed; avoid otherwise.
-`.gitea/workflows/p05-ci.yml` — CI isolation/verification/triage/cleanup.
-`tests/ci/**` — focused CI-only OIDC negative/discovery/production and audit scripts, plus README/MINIFEST.
-`notes/**`, `project/**`, relevant `docs/**`, associated `.gitea/**/README.md` and `MINIFEST.md`; root `README.md`, `MINIFEST.md` only as necessary.
READ ONLY: `core/backend/zitadel/dev.py`, `deployment/docker/compose.backend.dev.yaml`, all `auth/ui/v2/**` original source and lockfile, `users/ui/package.json` / `package-lock.json`, portal UI pages/feature logic and all other files. Preserve unrelated untracked `AI_INSTRUCTIONS.md`.
**No local builds, local tests, dev servers, Docker, real credentials/users, production deployments, tags or releases.** Source-level preflight/diff is permitted. Only ONE new manually dispatched Gitea CI acceptance cycle; no repeated reruns to chase green checks.
## Root-cause evidence (before edits)
- **B01 / TS2345**: Run #81 job 165, `users/ui/src/auth.ts(14,61)` generic NextAuth config callback rejected; downstream `callbacks.session` at lines 50–65 returns inferred `user.id: {}` instead of `string`. The current ternary uses `valid ? token.zitadelSubject! : ""`; the inferred `token.zitadelSubject!` type is not a reliable string despite the boolean `valid` expression. Correct by independently narrowing the JWT subject using `typeof ... === "string"` before constructing the session, and preserve expiry fail-closed. No `as any`, disabling strict mode or weakening route guards.
- **B02 / Docker checkout**: Run #81 job 168 failed in `node:22-alpine``actions/checkout@v4`: Git missing, archive fallback `Not found`. Current Gitea `main` already has pre-checkout `apk add --no-cache git` at workflow lines 106–110, not yet executed by CI. Current Compose uses fixed local-only network/port; refuse collisions and cleanup ONLY owned disposable project volumes. Verify Postgres volume survives service restart, then readiness, OIDC issuer/discovery/JWKS on disposable network. No edits to Compose or backend helper.
- **B03 / Moderates**: Run #81 job 167 passed HIGH/CRITICAL threshold, but `pnpm audit --prod` reported **18 MODERATE findings**, without individual package/advisory IDs. Account `npm audit` also found **1 MODERATE Next.js issue** with multiple GHSA IDs. Generate structured advisory inventory in CI using registry data, record package/affected range/available fix; no blind dependency upgrades.
- **B04 / OIDC**: `tests/ci/oidc_discovery.py` currently checks ready/discovery/JWKS only, not authenticated user callback, session, MFA or admin login. Add robust negative/issuer/JWKS tests, while keeping real login E2E explicitly BLOCKED until separately approved disposable user/client provisioning.
## Implementation plan
1. Narrow `users/ui/src/auth.ts` TypeScript narrowing patch, no auth flow change. Add CI negative contract probes and source contract checks.
3. Ensure job isolation: no shared Docker network/port takeover, no existing project teardown; fail-closed if daemon/capability/isolation unavailable. No real secrets. One CI run, read job logs and exact conclusions.
4. Update `project/`, `docs/`, `notes/`, manifests. Exact scope/security diff audit, Git commit and authorized Gitea `main` push, verify final remote/local SHA. Phase acceptance remains BLOCKED if required gates fail; never claim unexecuted E2E PASS.
## Verification ledger
**NOT STARTED.** Record run ID/SHA, exact terminal job statuses, advisory IDs and severity, Docker persistence/cleanup, remaining blockers and final Git SHA only after real evidence is received.
| Dependency security | 173 | **PASS at HIGH/CRITICAL only** | Account npm audit 1 Moderate vulnerable `next`; Login pnpm 18 Moderate advisory records; neither has HIGH/CRITICAL at the reported audit date |
| Disposable Docker | 174 | **FAIL** | Git/checkout, Docker preflight, 3 Python P02 static tests, official image pulls, PostgreSQL, ZITADEL API and prebuilt Login V2 **HEALTHY**. Traefik proxy failed: `Bind for 0.0.0.0:8080 failed: port is already allocated`. Postgres marker write/restart/persistence and OIDC discovery/JWKS **NOT REACHED**. Always-cleanup **PASS**: job-owned containers, network, volumes removed |
**B01 disposition:** FIXED and CI typecheck/build **verified PASS**. No TypeScript config relaxation, unsafe cast, PKCE/nonce/state change, session expiration bypass or UI change.
**B02 disposition:** Git checkout fixed and verified; PostgreSQL, ZITADEL API, Login V2 reached healthy state. Port 8080 was occupied on shared Docker runner; scope did not permit editing P02 Compose. **After the terminal run**, added a narrow CI-only `tests/ci/compose.portless.override.yaml` with `proxy.ports: !reset []` and applied it consistently to all 9 workflow Compose commands; enforced effective config `proxy.ports` empty before startup. Official Docker Compose documented reset behavior: https://docs.docker.com/reference/compose-file/merge/#reset-value. **This source fix is NOT VERIFIED by CI**, and the remaining persistence/discovery gates are BLOCKED until a separately approved run. P02 developer Compose remains untouched.
### B03 — exact live registry advisory triage (2026-11-22)
**Disposition:** all 19 Moderate audit records (18 Login + 1 Account package record) remain OPEN; HIGH/CRITICAL gate passed. Fixed-version metadata is a candidate only, not proof of compatibility or runtime exploitability. No blind npm/pnpm dependency upgrades, upstream Login fork edits or lockfile changes in P05-CI-02. A separate dependency-only security phase must evaluate reachability, runtime vs tooling transitive paths, pin consistency with official upstream, package/lock changes and CI regression.
- B02 **PARTIALLY VERIFIED** (checkout + health), but fixed portless CI overlay, restart persistence and OIDC/JWKS smoke remain **UNVERIFIED**; full backend gate FAIL.
- B03 **TRIAGE COMPLETE**, 19 Moderate records remain open pending approved dependency remediation; High/Critical gates PASS.
- B04 **PARTIALLY VERIFIED** (anonymous Account checks + synthetic negative OIDC metadata contracts in source); live Docker OIDC discovery/keys NOT RUN; authenticated client/user callback, MFA, Admin Console and federated logout **DEFERRED**.
- No live user data, production network, production host, Coolify deployment, tags, releases or local application tests/builds used. **No Gitea run rerun**. Untracked `AI_INSTRUCTIONS.md` preserved.
**Post-run commit:** contains only approved CI overlay/workflow and accurate notes/project/docs, no core/Compose/manifest/lock changes. The new commit SHA is recorded in Git history; **Run #83 tested `c27fe3d`, not the later documentation/portless patch SHA.**