Files
ZitPlane/docs/PHASES.md
T

76 lines
11 KiB
Markdown

# Phase register and scope locks
Implement one explicitly approved phase at a time. Keep out-of-scope files, existing authentication machinery and production systems unchanged.
## P01 - Foundation (COMPLETE)
- Baseline commit `8f54ccb30426f2955472c0cd40fb94d0b18e86ac`.
- Initial monorepo folder structure, docs, project Git identity and clean commit completed.
## P02 - ZITADEL local backend (APPROVED 2026-11-22)
- **Allowed source writes:** `core/backend/zitadel/**`, `deployment/docker/compose.backend.dev.yaml`, `.env.example`, backend-focused `tests/**`, and narrow `docs/**` / `README.md`.
- Official versioned ZITADEL v4 backend image, local PostgreSQL persistence, secure random dev secret generation, first-admin bootstrap and health checks.
- Official prebuilt Login V2 image as a **runtime dependency only** (v4 Admin Console login requires it); no Login V2 source import.
- No backend Go source vendoring, UI redesign, public domain, Coolify deploy, production keys, remote push or changes to unrelated files.
- Verify: static focused test/patch audit; with Docker available, live startup/ready/Admin Console, persistent DB after restart and shutdown.
- **Execution evidence:** Docker CLI/Desktop absent on connected Windows PC; live Compose startup, admin login and persistence remain NOT VERIFIED. Prior P02 static checks are recorded in `docs/P02-EVIDENCE.md`.
- **P02-RUNTIME-ACCEPTANCE-01 instruction update (2026-11-22):** user explicitly deferred all local test/dev execution to a future Gitea Actions phase; this is a source handoff, **not** runtime acceptance. Existing source is committed; authorized push to `vibtools/ZitPlane` is in scope. CI workflow creation and UI import remain outside P02.
- Existing unrelated untracked `AI_INSTRUCTIONS.md` must remain untouched.
## P03 - Official Login V2 source import (APPROVED 2026-11-22; SOURCE IMPLEMENTED)
- **Baseline:** `eadd0e558b459061e48583192badfc0579e95140`.
- **Write Scope:** `auth/ui/v2/**` (Login V2 and required upstream workspace files), narrow `README.md` and `docs/**` (P03 source/phase notes). No other files.
- **Upstream tag:** `v4.20.4` at `384bb9ec96b501ad39dc232ee2061a40fe180bbd`, matching P02 Go backend image.
- Import `apps/login`, `packages/zitadel-client`, `packages/zitadel-proto`, `proto`, root pnpm/Nx/build files and licensing **nested under `auth/ui/v2/`**. Preserve auth/UI behavior. Exclude upstream environment files; never commit secrets.
- User explicitly requested **no local builds, tests, dev servers or deployments**. Only source/provenance/patch audit, documentation, Git commit and approved Gitea push. CI deferred.
- P02 prebuilt Login UI remains configured in the development Compose; do **not** replace it or call runtime acceptance complete.
- Evidence and known gaps: `docs/P03-SOURCE-IMPORT.md`. CI workflow not part of this scope.
## P04 - User Account Portal foundation (APPROVED 2026-11-22; SOURCE IMPLEMENTED)
- **Baseline:** `4404849fc4bd30c7b4b7cabe7caed54cbd7cd37d`.
- **Exact Write Scope:** `users/ui/**`, narrow project `README.md` and relevant `docs/**` (phase/evidence/architecture/developer guide). **P02/P03 source read-only.**
- Separate compact Next.js portal, ZITADEL OIDC/PKCE authentication, server-protected user routes, read-only profile and security settings structure.
- Real OIDC only; no fake production auth, browser admin credentials, billing or user-management mutation endpoints. Existing ZITADEL core/Login V2 untouched.
- Explicitly **no local builds, tests, dev server, Docker or deployment**. Source-level audit only, Git commit and approved Gitea main push. Gitea Actions testing deferred; no CI workflow in this scope.
- Evidence and pending runtime acceptance: `docs/P04-ACCOUNT-PORTAL.md`.
## P05-CI-01 - Gitea Actions Verification Foundation (APPROVED 2026-11-22)
- Baseline `7ecf53169776cc7f08af3dde6fe4b4492acf3ea1`.
- Approved paths `.gitea/**`, `tests/ci/**`, narrow `users/ui/package.json` and lockfile, `auth/ui/v2/pnpm-workspace.yaml` and lockfile, `notes/**`, `project/**`, relevant `docs/**` and `README.md`; root `MINIFEST.md` is a documentation-maintenance exception. Backend/Account auth/UI source READ-ONLY.
- Manual Gitea workflow: account reproducible build, Login frozen build, dependency audit, disposable Docker backend readiness/discovery. **No local tests/build/dev server.**
- Full OIDC login/session/MFA/Admin Console interactive acceptance is not covered without disposable app/user provisioning; status remains BLOCKED/PENDING, not fabricated PASS.
- **Gitea Run #81:** 2 PASS (Login V2 frozen build + 1219/1219 unit tests; high/critical audit) and 2 FAIL (Account Auth.js TypeScript TS2345; Docker Alpine checkout missing Git). 18 moderate advisories unresolved. Pre-checkout Git source fix applied *after* the run, not rerun. See `notes/P05-CI-01.md` and `docs/P05-CI-01.md`. No production deployment/release.
## P05-CI-02 - Targeted Root-Cause Remediation (APPROVED 2026-11-22)
- Baseline `42adaba0044ee5cb86e6e6bcfd4e00e5fe96ad00` (Gitea `main`).
- Narrow write scope: `users/ui/src/auth.ts`, optional `src/types/next-auth.d.ts`, `.gitea/workflows/p05-ci.yml`, `tests/ci/**`, `notes/**`, `project/**`, relevant `docs/**`, associated CI README/MINIFEST, root navigation only if required.
- B01 Auth.js TypeScript TS2345: real subject string narrowing, preserve PKCE/state/nonce, expiry and protected identity guard. B02: verify in-CI Docker checkout, disposable ZITADEL, PostgreSQL restart persistence and OIDC discovery/JWKS. B03: report real Moderate advisory IDs/package/fix; HIGH+ security threshold remains a failure gate. B04: negative OIDC metadata and anonymous Account Portal checks, with interactive user E2E explicitly deferred.
- **One** manual Gitea Run #83: Account Portal, Login V2, security gates PASS; Docker health progressed to PostgreSQL/ZITADEL API/Login V2 healthy, but runner host 8080 collision blocked proxy, database persistence and discovery. Full CI acceptance BLOCKED. Post-run CI-only `tests/ci/compose.portless.override.yaml` clears inherited host port, **not CI-verified**. 18 Moderate Login + 1 Moderate Account audit record still open, no package changes. Exact evidence in `notes/P05-CI-02.md`, `docs/P05-CI-02.md`.
## P05-CI-03 - Backend Runtime Final Acceptance (APPROVED 2026-11-22)
- Baseline `485755800504a7dea6e4c303e6b39ec9cc610b54`; prior Run #83 had 3 job PASS and backend FAIL due to runner host TCP 8080 collision.
- **Exact Write Scope:** optional `.gitea/workflows/p05-backend-acceptance.yml`, narrow existing P05 workflow if justified, focused `tests/ci/**`, notes/project/docs, associated workflow README/MINIFEST and root navigation if needed. Core backend, developer Compose, Login V2, Account Portal, dependencies/locks and production config all READ ONLY.
- **Manual backend-only** Gitea Actions acceptance: effective Compose proxy portless check, four-service health, disposable Postgres restart marker persistence, ZITADEL readiness/discovery/JWKS, malformed issuer/JWKS negative contracts and verified CI-only cleanup.
- One focused isolated run after source commit/push, no local test/build/Docker, no repeated Account/Login suites, no real users/secrets or production deployment. Full interactive login/MFA remains a separate phase.
- **Gitea Actions Run #86 SUCCESS** on `03fb58954dec886128a4011b6121754cbcdd79ff`: portless effective config PASS, all four services ready, disposable PostgreSQL marker persisted after restart, ZITADEL ready/OIDC issuer/discovery/JWKS and negative contracts PASS, CI-owned network/containers/volumes cleanup verified PASS. No Account/Login build rerun, no local build/Docker. Full interactive OIDC login/MFA and Moderate dependencies remain outside this phase. Evidence: `notes/P05-CI-03.md`, `docs/P05-CI-03.md`.
## P05-SEC-01 - Dependency Security Remediation (APPROVED 2026-11-22)
- Baseline `1a602551ad9a791efcc594834f2fa6ce748339ae`. Previous Run #83 security: 18 Moderate Login advisory records and 1 Moderate Account vulnerable Next.js package; Run #86 backend-only SUCCESS.
- Narrow approved manifest writes: `users/ui/{package.json,package-lock.json}`, `auth/ui/v2/apps/login/package.json`, root `auth/ui/v2/{package.json,pnpm-lock.yaml}` only if justified; new `.gitea/workflows/p05-security-acceptance.yml`, focused `tests/ci/**`, notes/project/docs and associated README/MINIFEST. **`pnpm-workspace.yaml`, application source, Go backend, developer Compose, production and unrelated files remain read-only.**
- Direct Next.js pinned 16.4.6; Login coordinated OTel auto-instrumentation 0.80.0 / SDK 0.222.0 family, PNPM/npm metadata-only lockfile reconciliation. Root overrides are read-only, so glob14/minimatch11 major transitive remediation remains an explicit blocker if registry audit reproduces it.
- **Gitea Run #87**, tested SHA `752d243ae8fb24ce3cfa990343082e2d0431306b`: 3 job PASS (Account npm frozen typecheck/build/anonymous regressions, Login pnpm frozen Nx build + 1219/1219 unit tests, Account security 0), Login security FAIL on 2 Moderate transitive advisories (`glob` and `minimatch`), High/Critical 0. Prior 19 reported records reduced to 2; **full security acceptance BLOCKED**. Only one CI run, no local app build/test/dev server, no backend/production change. Exact result: `notes/P05-SEC-01.md`, `docs/P05-SEC-01.md`.
## P05-SEC-02 - Final Transitive Dependency Remediation (APPROVED 2026-11-22)
- Baseline `43eee54e7ad6b647e38491ac4dc28703547cf410`; prior Gitea Run #87: 3 PASS/1 FAIL, only 2 Login Moderate GHSA (`glob`/`minimatch`) remaining, Account audit 0.
- Exact Scope Lock: `auth/ui/v2/pnpm-workspace.yaml`, `pnpm-lock.yaml`, justified root or Login dependency manifests only, `.gitea/workflows/p05-security-acceptance.yml`, focused `tests/ci/**`, notes/project/docs and associated README/MINIFEST. **Login/auth/UI source, users/ui/**, Go backend, developer Compose, other packages and production READ-ONLY.** Preserve untracked AI_INSTRUCTIONS.md.
- Seven **exact parent-scoped** overrides: two glob10 parents → glob14.0.6, five minimatch10 parents → minimatch11.0.9. No broad global major override; pinned PNPM 10.30.3 metadata-only lockfile regeneration; compatibility subject to CI proof.
- **Actual Gitea Run #88**, tested source SHA `66cfed5a8b6bd5845b229c9934695e307f9a0775`, overall **FAILURE**: Account jobs correctly SKIPPED, Login live production audit **0 Moderate/High/Critical PASS**; Login build job FAIL before frozen install because new contract helper falsely treated existing `>=` semver ranges as parent overrides. No frozen install/build/units executed in this run. Corrected parser to recognize exact `>glob` or `>minimatch` selectors after the run, **not CI-verified**. Full security/compatibility acceptance **BLOCKED** pending separately approved focused CI; one run only, no local app builds/tests or deployment. Exact evidence: `notes/P05-SEC-02.md`, `docs/P05-SEC-02.md`.
## P05 - Full Integration (proposed, NOT approved)
Shared design system, production-safe Compose topology and verified Login/Account OIDC wiring. No live deployment; separate approval.
## P06 - UI redesign (proposed, NOT approved)
Compact login and account UI, accessibility, responsive design and scoped regressions. Protected authentication semantics unchanged.
## P07 - Production deployment (proposed, NOT approved)
Coolify, HTTPS, secrets, backups, durable storage and focused production readiness; explicit approval required.