Files
ZitPlane/notes/P05-CI-02.md
T

4.3 KiB
Raw Blame History

P05-CI-02 — Targeted Remediation & CI Acceptance

Date: 2026-11-22 Baseline: 42adaba0044ee5cb86e6e6bcfd4e00e5fe96ad00 (local main = Gitea main) State: APPROVED / PRE-CHANGE SCOPE LOCK Previous CI evidence: Gitea Run #81, tested 42b79362c13b9dbb07f85a58ad278742d91b1f5b, overall FAILURE.

Exact approved write scope

  • users/ui/src/auth.ts — B01 narrow session callback typing only.
  • 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.
  2. Strengthen Gitea job: auth typecheck/build, Login frozen build/unit regression, JSON advisory triage alongside existing HIGH+ gates, disposable Docker preflight plus Postgres persistence/ready/discovery/JWKS verification and always cleanup.
  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.