feat(crewing): Phase 1 foundations — SITE_STAFF role, ranks reference data + admin (flagged) #64

Merged
shad0w merged 4 commits from feat/crewing-foundations into master 2026-06-22 18:46:21 +00:00
Owner

Crewing — Phase 1 (Foundations)

First slice of the Crewing module per the wiki Crewing-Implementation-Spec (§12 build order). Everything is dark behind NEXT_PUBLIC_CREWING_ENABLED (off by default), so production is unchanged. Schema is added incrementally per phase — this PR lands only the reference-data layer.

What's in

  • Role: SITE_STAFF added to the Role enum (PM/APM/Site In-charge logins; MPO stays MANNING).
  • Schema: Rank (self-referential org hierarchy, like Account) + RankDocRequirement; RankCategory & SeafarerDocType enums. Migration crewing_foundations.
  • Permissions: the full §6 grant matrix (PO_ROLE_PERMISSIONS + CREWING_ROLE_PERMISSIONS merged). MPO has no attendance/leave; approvals/selection are Manager-only; manage_ranks = Manager + Admin.
  • Feature flag: CREWING_ENABLED (opt-in "true").
  • Nav: flag-gated Crewing section scaffold + Ranks & documents under Administration.
  • Reference data: rank-data.ts + rank-doc-data.ts seeded via shared seed-ranks.ts in dev and prod seeds (19 ranks, 118 doc requirements).
  • Screen: /admin/ranks — rank-hierarchy card (with the grantsLogin flag shown) + per-rank required-documents card, full CRUD.

Tests & docs

  • Unit: permissions-crewing.test.ts — verifies the §6 matrix cells + the flag default.
  • Integration: admin-ranks.test.ts — ranks CRUD, parent linking, cycle/children guards, doc-requirement upsert/remove, permission gating (8 tests).
  • Docs: CLAUDE.md "Crewing (feature-flagged)" section + env var.

Verification

db:migrate applies cleanly · db:seed → 19 ranks / 118 requirements · type-check clean · unit suite green (incl. 10 new) · admin-ranks integration 8/8 · /admin/ranks renders for a Manager with the flag on, no console errors.

Note: two pre-existing provideVendorId integration tests fail only on the local shared prod-mirror DB (they findFirst a seed vendor that lacks a verified id there); they are unrelated to this change and pass on CI's clean ephemeral DB.

🤖 Generated with Claude Code


Part of Epic L — Reference data & admin (#86).

## Crewing — Phase 1 (Foundations) First slice of the Crewing module per the wiki **Crewing-Implementation-Spec** (§12 build order). Everything is dark behind `NEXT_PUBLIC_CREWING_ENABLED` (off by default), so production is unchanged. Schema is added **incrementally per phase** — this PR lands only the reference-data layer. ### What's in - **Role:** `SITE_STAFF` added to the `Role` enum (PM/APM/Site In-charge logins; MPO stays `MANNING`). - **Schema:** `Rank` (self-referential org hierarchy, like `Account`) + `RankDocRequirement`; `RankCategory` & `SeafarerDocType` enums. Migration `crewing_foundations`. - **Permissions:** the full §6 grant matrix (`PO_ROLE_PERMISSIONS` + `CREWING_ROLE_PERMISSIONS` merged). MPO has **no** attendance/leave; approvals/selection are Manager-only; `manage_ranks` = Manager + Admin. - **Feature flag:** `CREWING_ENABLED` (opt-in `"true"`). - **Nav:** flag-gated Crewing section scaffold + **Ranks & documents** under Administration. - **Reference data:** `rank-data.ts` + `rank-doc-data.ts` seeded via shared `seed-ranks.ts` in **dev and prod** seeds (19 ranks, 118 doc requirements). - **Screen:** `/admin/ranks` — rank-hierarchy card (with the `grantsLogin` flag shown) + per-rank required-documents card, full CRUD. ### Tests & docs - **Unit:** `permissions-crewing.test.ts` — verifies the §6 matrix cells + the flag default. - **Integration:** `admin-ranks.test.ts` — ranks CRUD, parent linking, cycle/children guards, doc-requirement upsert/remove, permission gating (8 tests). - **Docs:** `CLAUDE.md` "Crewing (feature-flagged)" section + env var. ### Verification `db:migrate` applies cleanly · `db:seed` → 19 ranks / 118 requirements · `type-check` clean · unit suite green (incl. 10 new) · `admin-ranks` integration 8/8 · `/admin/ranks` renders for a Manager with the flag on, no console errors. > Note: two pre-existing `provideVendorId` integration tests fail **only on the local shared prod-mirror DB** (they `findFirst` a seed vendor that lacks a verified id there); they are unrelated to this change and pass on CI's clean ephemeral DB. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- Part of **Epic L — Reference data & admin** (#86).
shad0w added 1 commit 2026-06-22 07:57:15 +00:00
feat(crewing): foundations — SITE_STAFF role, ranks reference data + admin (flagged)
All checks were successful
PR checks / checks (pull_request) Successful in 36s
PR checks / integration (pull_request) Successful in 28s
d0006a8fc7
Phase 1 of the Crewing module per wiki Crewing-Implementation-Spec §12, all dark
behind NEXT_PUBLIC_CREWING_ENABLED (off by default — production unchanged).

- schema: add SITE_STAFF to Role; add Rank (self-referential org hierarchy, like
  Account) + RankDocRequirement, RankCategory & SeafarerDocType enums.
- permissions: full §6 crewing grant matrix (PO_ROLE_PERMISSIONS +
  CREWING_ROLE_PERMISSIONS merged); SITE_STAFF row; MPO has no attendance/leave,
  approvals are Manager-only, manage_ranks is Manager+Admin.
- feature flag: CREWING_ENABLED (opt-in "true").
- nav: flag-gated Crewing section scaffold + "Ranks & documents" under Admin.
- reference data: rank-data.ts + rank-doc-data.ts seeded via shared seed-ranks.ts
  in both dev and prod seeds (19 ranks, 118 doc requirements).
- screen: /admin/ranks — rank hierarchy card + per-rank required-documents card.
- role-label/prefix maps updated for the new role.

Tests: unit (permission matrix + flag), integration (ranks admin CRUD, parent
linking, cycle/children guards, doc-requirement upsert/remove, permission gating).
Docs: CLAUDE.md "Crewing (feature-flagged)" section + env var.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
shad0w added 1 commit 2026-06-22 10:58:59 +00:00
ci(crewing): also run PR checks for PRs into feat/crewing-foundations
All checks were successful
PR checks / checks (pull_request) Successful in 36s
PR checks / integration (pull_request) Successful in 27s
ff0539de92
The crewing module is built as a stack of feature-flagged phases that land on
feat/crewing-foundations (the integration branch) before the whole thing merges
to master. PRs into that branch were skipped because pr-checks only triggered on
`branches: [master]`. Add feat/crewing-foundations so each stacked phase PR runs
the same hard gates (test-presence policy, type-check, unit + integration).

For pull_request events the workflow is read from the base branch, so this must
live on feat/crewing-foundations to take effect for PRs targeting it.
shad0w added 1 commit 2026-06-22 12:52:43 +00:00
ci(crewing): match the whole stack with a feat/crewing-* glob
All checks were successful
PR checks / checks (pull_request) Successful in 37s
PR checks / integration (pull_request) Successful in 26s
4528c059aa
Replace the per-branch PR-checks trigger ([master, feat/crewing-foundations])
with [master, "feat/crewing-*"] so every branch in the stacked crewing series
(foundations → requisitions → candidates → …) runs the same hard gates without
adding each one by hand. The workflow is evaluated from the branch under test,
so the glob is propagated down the stack.
shad0w added 1 commit 2026-06-22 18:45:13 +00:00
Merge branch 'master' into feat/crewing-foundations
All checks were successful
PR checks / checks (pull_request) Successful in 36s
PR checks / integration (pull_request) Successful in 26s
c32fb6979c
shad0w merged commit 9cac83013e into master 2026-06-22 18:46:21 +00:00
Sign in to join this conversation.
No description provided.