Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .forge/features/career-job-router/spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Career Job Router Spec

Status: Agreed with Kevin on 2026-11-16. Dev-lead review happens on the PR.

## User-facing purpose

Members get one place in Blade to explore scraped job listings, track their own
applications with dates, and find other members going through the same hiring
process. This slice (#651, part of #633) provides the data those pages need; the
pages themselves are #655 and #656.

## Users / actors

- Members: signed-in users with a member profile.
- Signed-in users without a member profile: no access.
- Officers: unchanged here. They already manage Career Discord channels and
roles through the existing platform configuration console (#648).

## User-visible interface

No pages in this slice. It supplies:

- Explore: search, sort and filter listings by track, company, category,
location and posted date. Closed listings are hidden unless asked for.
- A job view: listing details, where it was found, members in process for it,
and the viewer's own progress.
- A company view: that company's listings, each with its members in process.
- People in process: members by company, role and stage.
- My applications: the member's own tracker with notes, visibility and a dated
timeline.

## Scope

### In scope

- Save a listing, set stage, optional round and optional interview label,
update or remove it.
- An optional date for each stage change, so progress logged later is dated
correctly (applied 10/22, interview 11/01). Defaults to the time of saving and
cannot be in the future.
- Community visibility by default, with a private setting.

### Out of scope

- Ping preferences and digest opt-ins. They follow in a second PR once the
matching services in #650 merge.
- Editing or deleting individual timeline entries.
- Blade pages, cron, ingestion and Discord delivery.

## Vocabulary

- `community application`: one other signed-in members can see.
- `private application`: one only its owner can see.
- `progress`: a change to stage, round or interview label.

## Acceptance criteria

- A user without a member profile cannot read or change anything.
- Other members see a community application's name, picture, Discord username,
stage, round and interview label, and never its notes.
- A private application appears in no view except its owner's.
- A `saved` application (bookmarked, not yet applied) appears in no view except
its owner's, whatever its visibility.
- Each progress change adds one dated timeline entry; editing notes or
visibility adds none.
- A member can change or remove only their own applications.

## Open questions

- Location filters widen each other (a city or U.S. remote). Confirm with #655.
106 changes: 106 additions & 0 deletions .forge/features/career-job-router/srd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Career Job Router SRD

Status: Implemented for PR 1 of #651. References: #633, #646, #647, #648, #650.

## Technical purpose

Add the `jobBoard` tRPC namespace over the Career job tables. A separate router
rather than more `career.*` procedures: `career` is Guild companies and
employment history, and the consts, validators and schema for this feature are
already named `job-board`.

## Relevant principles

`docs/API-AND-PERMISSIONS.md` and the `forge-api` skill: guard first, validators
from `@forge/validators`, typed return shapes, extracted logic in
`utils/<domain>/`, transactions for multi-table writes.

## Access policy

- Unauthenticated: none.
- Signed-in without a member profile: `FORBIDDEN` from every procedure
(`requireJobBoardMember`).
- Member: all eight procedures. Writes are scoped to the caller's `Member.id`;
another member's application answers `NOT_FOUND`.
- Officer: no additional access. Officers do not see private applications.
- No `permProcedure`, so nothing is added to `utils/audit/coverage.ts`.

## Architecture / data flow

- `routers/job-board.ts`: procedures only.
- `utils/job-board/access.ts`: the member guard.
- `utils/job-board/search.ts`: filter and sort building, listing columns,
locations and sources.
- `utils/job-board/community.ts`: the single projection for other members'
applications. It applies `visibility = 'community'` and never selects
`privateNotes`.
- `utils/job-board/applications.ts`: save, update and remove.

## tRPC/API behavior

| Procedure | Kind | Notes |
| --------------------- | -------- | ---------------------------------------------------------------- |
| `searchJobs` | query | Paged. Inactive excluded unless `includeInactive`. |
| `getJob` | query | Listing, locations, sources, people in process, own application. |
| `getCompany` | query | By company key; up to 200 listings, open first, with applicants. |
| `listPeopleInProcess` | query | Paged community applications with member identity. |
| `listMyApplications` | query | Own applications with notes, visibility and timeline. |
| `saveApplication` | mutation | `CONFLICT` if already tracking; `NOT_FOUND` for an unknown job. |
| `updateApplication` | mutation | Partial. Rechecks round and label against the stored stage. |
| `removeApplication` | mutation | Deletes the row; history cascades. |

Listings never expose delivery state, identity keys or raw source data.

Application writes:

- Save and update write `JobApplication` and a `JobApplicationHistory` snapshot
in one transaction. History is written on the initial save and when stage,
round or interview label changes, not for notes or visibility.
- `occurredAt` is stored as `JobApplicationHistory.changedAt`. Sending it
without a progress change is `BAD_REQUEST`.
- Leaving `interviewing` clears round and label, as the table checks require.
- Removal writes the audit event `job_board.application.removed` inside the
transaction before the delete. The event carries the member and no job
details, because officers read the audit log and the application may be
private.

## Validation

`applicationSaveInputSchema` and `applicationUpdateInputSchema` gain
`interviewLabel` (trimmed, at most `MAX_APPLICATION_INTERVIEW_LABEL_LENGTH`,
only while interviewing) and `occurredAt` (not in the future). Other inputs
reuse the #646 schemas unchanged.

## Data / migration / compatibility

No schema or migration change. `changedAt` already accepts an explicit value.
One audit action key is added to the catalog. No existing procedure is renamed
or removed.

## Discord integration

None. Member identity includes `Member.discordUser` (a username) for display
only; it is never used for mentions.

## Configurability review

Would this require a developer change next year?

- Answer: No. Stages, tracks, categories and limits come from `JOB_BOARD`.
- If yes, why is hard-coding acceptable or what admin-configurable path is planned? N/A.

## React / frontend constraints

None in this slice.

## Testing / verification strategy

- `packages/validators/src/tests/job-board.test.ts`: label and date rules.
- `packages/api/src/tests/integration/job-board.test.ts`: access, privacy,
history and ownership against disposable PostgreSQL.
- `packages/api/src/tests/job-board/router-contract.test.ts` and the API surface
snapshot pin the procedure names.

## Open questions

- See spec.md. Search returns rows only once #649's ingestion lands.
56 changes: 56 additions & 0 deletions .forge/features/career-job-router/status.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Career Job Router Status

Current phase: PR 1 implemented, validated locally and opened as a draft PR.

## Decision log

- 2026-11-16: Kevin split #651. PR 1 is job search, job and company views,
applications with history, people in process and privacy. Ping preferences
and digest opt-ins wait for #650.
- 2026-11-16: New `jobBoard` router instead of extending `career`.
- 2026-11-16: Stage changes take an optional date, not in the future, defaulting
to the time of saving. Timeline entries are not editable.
- 2026-11-16: Community views show name, profile picture, Discord username,
stage, round and interview label.
- 2026-11-16: Kevin decided `saved` applications are never shown to other
members; someone who has not applied is not in a process.
- Implementation choices to confirm in review: no new officer procedure because
`discordConfig.list` and `discordConfig.update` already cover the Career keys;
a missing member profile is `FORBIDDEN`; location filters widen each other;
the removal audit event carries no job details.

## Open questions

- Confirm location filter behavior with the #655 owner.

## Task list

- [x] Reverse-prompt scope and decisions with Kevin.
- [x] Extend application validators with interview label and stage date.
- [x] Add the `jobBoard` router, access guard, search, community projection and
application mutations.
- [x] Add validator, integration and contract tests; update the API surface snapshot.
- [x] Commit and open the draft PR for Kevin's review.
- [ ] PR 2: ping preferences and digest opt-ins after #650.

## Validation / commands

- `pnpm --filter @forge/validators exec vitest run src/tests/audit.test.ts src/tests/job-board.test.ts`:
39 passed.
- `pnpm with-env vitest run src/tests/integration/job-board.test.ts src/tests/job-board src/tests/root/api-surface.test.ts src/tests/audit/coverage.test.ts`
in `packages/api` with `NODE_ENV=test`: 19 passed, including 5 integration
tests on disposable local PostgreSQL. Snapshot gained the eight `jobBoard.*` paths.
- `src/tests/root/version-pins.test.ts` fails on this checkout because
`pnpm-lock.yaml` has no `overrides:` block; the lockfile is unchanged by this work.
- Root `pnpm lint`: passed, 31 tasks, warnings only. Root `pnpm typecheck`:
passed, 33 tasks.
- Root `pnpm format`: fails in 24 packages on this Windows checkout's CRLF line
endings in untouched files (same limitation as #647). A Prettier check of
every file changed here passes.

## Links

- PRs:
- Issues: https://github.com/KnightHacks/forge/issues/651,
https://github.com/KnightHacks/forge/issues/633
- Discord/thread context:
70 changes: 70 additions & 0 deletions .forge/features/career-job-router/test-cases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Career Job Router Test Cases

Status: Implemented. Kept to the key rules, per the small-slice testing guidance.

## Scope

Member access, privacy of applications and notes, dated history, ownership, and
the default search filter. Preferences, digests, UI and ingestion are excluded.

## Test placement plan

- `pnpm --filter @forge/validators exec vitest run src/tests/job-board.test.ts`
- `pnpm --filter @forge/api with-env vitest run src/tests/integration/job-board.test.ts src/tests/job-board src/tests/root/api-surface.test.ts`
(the integration file needs a local PostgreSQL and skips without one)

## Test cases

### TC-001: Search hides closed listings by default

Setup: one active and one inactive job for the same company.

Action: search by company, then with `includeInactive`.

Expected observations: one job, then two; unknown company or other track returns none.

### TC-002: Progress is dated, notes edits are not

Setup: a member saves a job as applied on a past date.

Action: move to interviewing round 1 with a label and a later past date, then edit notes only.

Expected observations: two history entries carrying the supplied dates; the notes edit adds none; moving to offer adds a third and clears round and label.

### TC-003: Community views show identity and no notes

Setup: one community application with notes, one private application.

Action: read the job view, company view and people-in-process list as the private owner.

Expected observations: only the community application, with name, Discord username and stage; no notes anywhere. The owner's own list and job view show their private application and notes.

### TC-004: Stage date and interview label input rules

Action: parse a label while interviewing and while applied; parse a past and a future date.

Expected observations: label kept only while interviewing; future date rejected.

## Negative / regression cases

### TC-NEG-001: No member profile

Action: a signed-in user without a member profile searches or saves.

Expected observations: `FORBIDDEN`.

### TC-NEG-002: Duplicate and misplaced input

Action: save the same job twice; set a round on an application that is not interviewing.

Expected observations: `CONFLICT`; `BAD_REQUEST`.

### TC-NEG-003: Another member's application

Action: update and remove someone else's application, then the owner removes it.

Expected observations: `NOT_FOUND` for the other member; the owner's removal deletes the row and its history and writes one audit event with no job details.

## Open questions

- None beyond spec.md.
6 changes: 6 additions & 0 deletions docs/DATABASE-USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ Do not return raw application rows: private notes are always private, including
when application visibility is community. No end-user row authorization is implied
by these foreign keys.

`JobApplicationHistory` rows are written by the `jobBoard` application mutations
in the same transaction as the `JobApplication` change, one per change to stage,
round or interview label. `changedAt` is when the member says the change
happened, which may be earlier than when the row was saved; order timelines by
it and do not treat it as a write timestamp.

### Identifier fingerprints

`Job.identityHash`, `JobSource.boardKeyHash` and `JobObservation.externalIdHash` are
Expand Down
3 changes: 3 additions & 0 deletions packages/api/src/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { hackathonEventRouter } from "./routers/hackathon-event";
import { hackerRouter } from "./routers/hacker";
import { hackerTeamRouter } from "./routers/hacker-team";
import { issuesRouter } from "./routers/issues";
import { jobBoardRouter } from "./routers/job-board";
import { judgingRouter } from "./routers/judging";
import { mcpActivityRouter } from "./routers/mcp-activity";
import { memberRouter } from "./routers/member";
Expand Down Expand Up @@ -53,6 +54,7 @@ export interface AppRouterShape {
hacker: typeof hackerRouter;
health: typeof healthProcedure;
issues: typeof issuesRouter;
jobBoard: typeof jobBoardRouter;
judging: typeof judgingRouter;
mcpActivity: typeof mcpActivityRouter;
member: typeof memberRouter;
Expand Down Expand Up @@ -90,6 +92,7 @@ const appRouterRecord: AppRouterRecord = {
hacker: hackerRouter,
health: healthProcedure,
issues: issuesRouter,
jobBoard: jobBoardRouter,
judging: judgingRouter,
mcpActivity: mcpActivityRouter,
member: memberRouter,
Expand Down
Loading
Loading