feat(orgs): org request endpoints — submit + mine (task 1.2, ORG-01/04/06) #54

Merged
amiryahaya merged 1 commit from feat/1.2-org-requests into main 2026-11-04 19:06:26 +01:00
Owner

Phase 1 task 1.2: the founder journey's entry point, riding on task 1.1's Pending state.

New: Features/OrgRequests/ on /api/org-requests

  • POST / — no-org users file an organization request (name ≤200 chars, optional reason ≤2000). Guards: 403 if already in an org (ORG-01 "no-org users only"); 403 without an email (ORG-03 — wallet-only accounts in the dual-auth window must link email first, otherwise approval/rejection notifications silently never arrive); 409 while a request is pending (ORG-06). Creates TenantRequest(Pending) and flips the user NoWorkspace → Pending (state machine §4.2; ExecuteUpdate per #44). Audited.
  • GET /mine — requester polls status / timestamps / rejection reason (ORG-04); 404 when never requested; most-recent request wins.

Rejected requesters can re-submit (ORG-03 premise — test-covered). The legacy /api/tenant-requests admin queue is unchanged (same entity).

Tests (TDD §2.1)

OrgRequestTests (7) written first — red at 6 (routes absent), green after. Two review notes from red: #17 had been closed prematurely (reopened); the middleware allowlist from 1.1 already carried the route.

Verification

761/761 ×2 (Release); pre-push hook green, coverage 83.53% ≥ 80.

Closes #17 (task 1.2). Next: task 1.3 — approval rework (ORG-02/03).

Phase 1 task 1.2: the founder journey's entry point, riding on task 1.1's Pending state. ## New: `Features/OrgRequests/` on `/api/org-requests` - **POST /** — no-org users file an organization request (name ≤200 chars, optional reason ≤2000). Guards: 403 if already in an org (ORG-01 "no-org users only"); 403 without an email (ORG-03 — wallet-only accounts in the dual-auth window must link email first, otherwise approval/rejection notifications silently never arrive); 409 while a request is pending (ORG-06). Creates `TenantRequest(Pending)` and **flips the user NoWorkspace → Pending** (state machine §4.2; ExecuteUpdate per #44). Audited. - **GET /mine** — requester polls status / timestamps / rejection reason (ORG-04); 404 when never requested; most-recent request wins. Rejected requesters can re-submit (ORG-03 premise — test-covered). The legacy `/api/tenant-requests` admin queue is unchanged (same entity). ## Tests (TDD §2.1) `OrgRequestTests` (7) written first — red at 6 (routes absent), green after. Two review notes from red: #17 had been closed prematurely (reopened); the middleware allowlist from 1.1 already carried the route. ## Verification 761/761 ×2 (Release); pre-push hook green, coverage **83.53%** ≥ 80. Closes #17 (task 1.2). Next: task 1.3 — approval rework (ORG-02/03).
feat(orgs): org request endpoints — submit + mine (task 1.2, ORG-01/04/06)
Some checks failed
API CI / build-and-test (pull_request) Failing after 29m40s
f65a320a85
New Features/OrgRequests/ on /api/org-requests (allowlisted by the 1.1
workspace gate, so Pending and no-workspace founders can reach it):

- POST /: no-org users file an organization request (name ≤200, optional
  reason ≤2000). Guards: 403 for users already in an org (ORG-01 "no-org
  users only"); 403 without an email (ORG-03 — wallet-only accounts in
  the dual-auth window must link email first, else notifications would
  silently never arrive); 409 while a request is pending (ORG-06).
  Creates TenantRequest(Pending) and flips the user NoWorkspace →
  Pending (state machine §4.2; ExecuteUpdate — accessor.User is
  AsNoTracking #44). Audits tenant.requested.
- GET /mine: requester polls status/timestamps/rejection reason
  (ORG-04); 404 when never requested. Most-recent request wins.

Rejected requesters can re-submit (ORG-03 premise — covered by test).
Legacy /api/tenant-requests admin queue unchanged (same entity).

TDD (§2.1): OrgRequestTests (7) written first — red at 6 (routes
absent), green after implementation.

Verified: 761/761 ×2 (Release).

🤖 Generated with [ZCode](https://zcode.ai)

Co-Authored-By: ZCode <noreply@anthropic.com>
Author
Owner

ponytail-review (§2.4 AI first-pass) — Verdict: Ship.

What this change does: adds the org-request submit/poll endpoints on the repurposed TenantRequest entity, gates submissions to no-org users with an email, enforces one-pending-request (409), and flips the submitting user to UserStatus.Pending.

Checked: route group sits inside the 1.1 middleware allowlist (pending + no-workspace founders can reach it; workspace holders too — but the handler 403s them, defense in depth); ExecuteUpdate for the status flip (AsNoTracking #44); email guard closes the baseline-review silent-failure path (RequesterEmail == ""); length caps on name/reason (DB has no max on those columns — bounded before insert); audit action kept as tenant.requested for admin-queue compatibility; /mine is AsNoTracking + most-recent-first.

Notes (not blocking): slug collision handling lives in the approval path (task 1.3, existing -2/-3 logic); no pagination needed on /mine (single row by construction); legacy /api/tenant-requests submit route still exists in parallel — removed at decommission per MIG-04.

**ponytail-review (§2.4 AI first-pass) — Verdict: Ship.** What this change does: adds the org-request submit/poll endpoints on the repurposed TenantRequest entity, gates submissions to no-org users with an email, enforces one-pending-request (409), and flips the submitting user to UserStatus.Pending. Checked: route group sits inside the 1.1 middleware allowlist (pending + no-workspace founders can reach it; workspace holders too — but the handler 403s them, defense in depth); ExecuteUpdate for the status flip (AsNoTracking #44); email guard closes the baseline-review silent-failure path (RequesterEmail == ""); length caps on name/reason (DB has no max on those columns — bounded before insert); audit action kept as tenant.requested for admin-queue compatibility; /mine is AsNoTracking + most-recent-first. Notes (not blocking): slug collision handling lives in the approval path (task 1.3, existing -2/-3 logic); no pagination needed on /mine (single row by construction); legacy /api/tenant-requests submit route still exists in parallel — removed at decommission per MIG-04.
amiryahaya deleted branch feat/1.2-org-requests 2026-11-04 19:06:27 +01:00
Sign in to join this conversation.
No description provided.